• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/libkopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • libkopete
kopeteaddedinfoevent.cpp
Go to the documentation of this file.
1 /*
2  kopeteaddedinfoevent.cpp - Kopete Added Info Event
3 
4  Copyright (c) 2008 by Roman Jarosz <kedgedev@centrum.cz>
5  Kopete (c) 2008 by the Kopete developers <kopete-devel@kde.org>
6 
7  *************************************************************************
8  * *
9  * This library is free software; you can redistribute it and/or *
10  * modify it under the terms of the GNU Lesser General Public *
11  * License as published by the Free Software Foundation; either *
12  * version 2 of the License, or (at your option) any later version. *
13  * *
14  *************************************************************************
15 */
16 #include "kopeteaddedinfoevent.h"
17 
18 #include <klocale.h>
19 #include <kdebug.h>
20 
21 #include "kopeteaccount.h"
22 #include "kopeteprotocol.h"
23 #include "ui/contactaddednotifydialog.h"
24 
25 namespace Kopete {
26 
27 class AddedInfoEvent::Private
28 {
29 public:
30  QString contactId;
31  Kopete::Account *account;
32  ShowActionOptions actions;
33 
34  QString contactNickname;
35 
36  bool suppressClose;
37  UI::ContactAddedNotifyDialog* addDialog;
38 };
39 
40 AddedInfoEvent::AddedInfoEvent( const QString& contactId, Kopete::Account *account )
41  : InfoEvent(account), d( new Private() )
42 {
43  d->suppressClose = false;
44  d->addDialog = 0;
45  d->contactId = contactId;
46  d->account = account;
47  d->actions = AllActions;
48 }
49 
50 AddedInfoEvent::~AddedInfoEvent()
51 {
52  if( d->addDialog )
53  d->addDialog->deleteLater();
54 
55  delete d;
56 }
57 
58 QString AddedInfoEvent::contactId() const
59 {
60  return d->contactId;
61 }
62 
63 Kopete::Account* AddedInfoEvent::account() const
64 {
65  return d->account;
66 }
67 
68 void AddedInfoEvent::showActions( ShowActionOptions actions )
69 {
70  d->actions = actions;
71 }
72 
73 void AddedInfoEvent::setContactNickname( const QString& nickname )
74 {
75  d->contactNickname = nickname;
76 }
77 
78 void AddedInfoEvent::activate( uint actionId )
79 {
80  if ( actionId == AddAction )
81  {
82  if ( d->addDialog )
83  {
84  d->addDialog->raise();
85  }
86  else
87  {
88  UI::ContactAddedNotifyDialog::HideWidgetOptions hideFlags = UI::ContactAddedNotifyDialog::DefaultHide;
89  if ( !(d->actions & AuthorizeAction) )
90  hideFlags |= UI::ContactAddedNotifyDialog::AuthorizeCheckBox;
91  if ( !(d->actions & InfoAction) )
92  hideFlags |= UI::ContactAddedNotifyDialog::InfoButton;
93 
94  d->addDialog = new UI::ContactAddedNotifyDialog( d->contactId, d->contactNickname, d->account, hideFlags );
95  d->addDialog->setAttribute( Qt::WA_DeleteOnClose, false );
96 
97  connect( d->addDialog, SIGNAL(finished()), this, SLOT(addDialogFinished()) );
98  connect( d->addDialog, SIGNAL(applyClicked(QString)), this, SLOT(addDialogOk()) );
99  connect( d->addDialog, SIGNAL(infoClicked(QString)), this, SLOT(addDialogInfo()) );
100  d->addDialog->show();
101  }
102  }
103  else
104  {
105  InfoEvent::activate( actionId );
106 
107  if ( !d->suppressClose && actionId != InfoAction && d->account->isConnected() )
108  close();
109  }
110 }
111 
112 MetaContact* AddedInfoEvent::addContact() const
113 {
114  if( !d->addDialog )
115  return 0L;
116 
117  return d->addDialog->addContact();
118 }
119 
120 void AddedInfoEvent::sendEvent()
121 {
122  setTitle( i18n( "You have been added" ) );
123 
124  if ( d->actions & AddAction )
125  addAction( AddAction, i18n("Add...") );
126  if ( d->actions & AuthorizeAction )
127  addAction( AuthorizeAction, i18n("Authorize") );
128  if ( d->actions & BlockAction )
129  addAction( BlockAction, i18n("Block") );
130  if ( d->actions & InfoAction )
131  addAction( InfoAction, i18n("Info...") );
132 
133  setText( i18n( "The contact <b>%1</b> has added you to his/her contact list.",
134  ( d->contactNickname.isEmpty() ) ? d->contactId : d->contactNickname ) );
135 
136  InfoEvent::sendEvent();
137 }
138 
139 void AddedInfoEvent::addDialogOk()
140 {
141  if( !d->addDialog )
142  return;
143 
144  d->suppressClose = true;
145  if ( d->addDialog->authorized() )
146  activate( AuthorizeAction );
147 
148 
149  if ( d->addDialog->added() )
150  activate( AddContactAction );
151 
152  if ( d->account->isConnected() )
153  close();
154 }
155 
156 void AddedInfoEvent::addDialogInfo()
157 {
158  activate( InfoAction );
159 }
160 
161 void AddedInfoEvent::addDialogFinished()
162 {
163  if( d->addDialog )
164  {
165  d->addDialog->deleteLater();
166  d->addDialog = 0;
167  }
168 }
169 
170 }
171 
172 #include "kopeteaddedinfoevent.moc"
contactaddednotifydialog.h
kopeteaccount.h
Kopete::AddedInfoEvent::~AddedInfoEvent
~AddedInfoEvent()
Definition: kopeteaddedinfoevent.cpp:50
Kopete::AddedInfoEvent::sendEvent
virtual void sendEvent()
Emit the event.
Definition: kopeteaddedinfoevent.cpp:120
Kopete::AddedInfoEvent::AllActions
You should add contact to Kopete contact list with addContact() this is only emitted if activate(uint...
Definition: kopeteaddedinfoevent.h:84
Kopete::AddedInfoEvent::BlockAction
You should authorize the contact.
Definition: kopeteaddedinfoevent.h:79
Kopete::UI::ContactAddedNotifyDialog::DefaultHide
Internal default.
Definition: contactaddednotifydialog.h:78
Kopete::AddedInfoEvent::AddAction
Definition: kopeteaddedinfoevent.h:76
Kopete::InfoEvent
Base class for all Info Events.
Definition: kopeteinfoevent.h:39
Kopete::AddedInfoEvent::contactId
QString contactId() const
Return the contactId of a contact which has added you.
Definition: kopeteaddedinfoevent.cpp:58
Kopete::AddedInfoEvent::activate
virtual void activate(uint actionId)
Activate the action specified action.
Definition: kopeteaddedinfoevent.cpp:78
Kopete::UI::ContactAddedNotifyDialog
Dialog which is shown when a contact added you in the contact list.
Definition: contactaddednotifydialog.h:69
Kopete::InfoEvent::addAction
void addAction(uint actionId, const QString &actionText)
Set the list of actions link.
Definition: kopeteinfoevent.cpp:94
Kopete::AddedInfoEvent::addContact
MetaContact * addContact() const
create a metacontact.
Definition: kopeteaddedinfoevent.cpp:112
Kopete::AddedInfoEvent::InfoAction
You should block this and future requests.
Definition: kopeteaddedinfoevent.h:80
Kopete::AddedInfoEvent::AuthorizeAction
Add action was activated.
Definition: kopeteaddedinfoevent.h:78
Kopete::UI::ContactAddedNotifyDialog::AuthorizeCheckBox
the checkbox which ask for authorize the contact
Definition: contactaddednotifydialog.h:80
Kopete::InfoEvent::actions
QMap< uint, QString > actions() const
Definition: kopeteinfoevent.cpp:89
Kopete::InfoEvent::close
void close()
Close the info event.
Definition: kopeteinfoevent.cpp:120
Kopete::InfoEvent::activate
virtual void activate(uint actionId)
Activate the action specified action.
Definition: kopeteinfoevent.cpp:110
kopeteprotocol.h
Kopete::AddedInfoEvent::AddedInfoEvent
AddedInfoEvent(const QString &contactId, Kopete::Account *account)
Constructor.
Definition: kopeteaddedinfoevent.cpp:40
Kopete::InfoEvent::setTitle
void setTitle(const QString &title)
Set the Info Event title.
Definition: kopeteinfoevent.cpp:61
Kopete::InfoEvent::setText
void setText(const QString &text)
Set the Info Event text.
Definition: kopeteinfoevent.cpp:72
QString
Kopete::AddedInfoEvent::setContactNickname
void setContactNickname(const QString &nickname)
Set contact nickname.
Definition: kopeteaddedinfoevent.cpp:73
Kopete::InfoEvent::sendEvent
virtual void sendEvent()
Emit the event.
Definition: kopeteinfoevent.cpp:51
Kopete::AddedInfoEvent::AddContactAction
You should show info about contact.
Definition: kopeteaddedinfoevent.h:82
Kopete::AddedInfoEvent::account
Kopete::Account * account() const
Return the account that has generated this event.
Definition: kopeteaddedinfoevent.cpp:63
Kopete::UI::ContactAddedNotifyDialog::InfoButton
the button which ask for more info about the contact
Definition: contactaddednotifydialog.h:79
Kopete::MetaContact
Definition: kopetemetacontact.h:54
kopeteaddedinfoevent.h
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Kopete::Account
The Kopete::Account class handles one account.
Definition: kopeteaccount.h:72
Kopete::AddedInfoEvent::showActions
void showActions(ShowActionOptions actions)
Set which actions should be shown.
Definition: kopeteaddedinfoevent.cpp:68
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal