2 kopeteaddedinfoevent.h - Kopete Added Info Event
4 Copyright (c) 2008 by Roman Jarosz <kedgedev@centrum.cz>
5 Kopete (c) 2008 by the Kopete developers <kopete-devel@kde.org>
7 *************************************************************************
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. *
14 *************************************************************************
16 #ifndef KOPETEADDEDINFOEVENT_H
17 #define KOPETEADDEDINFOEVENT_H
19 #include "kopeteinfoevent.h"
26 * @brief Event which is shown when a contact added you into the contact list or requested authorization.
28 * This event allows the user to give authorization for the addition to the
29 * person who added the user and also allows the user to add the person into
30 * the user's contact list.
32 * The @p title() and @p text() will be filled with predefined text.
33 * If you want to add additional information use @p setAdditionalText()
35 * The @p actionActivated(uint) signal can be emitted more than once.
36 * All AddedInfoEvent object will be closed and deleted automatically.
40 Kopete::AddedInfoEvent* event = new Kopete::AddedInfoEvent( contactId, account );
41 QObject::connect( event, SIGNAL(actionActivated(uint)), this, SLOT(addedInfoEventActionActivated(uint)) );
45 * and in your addedInfoEventActionActivated slot
47 Kopete::AddedInfoEvent *event = dynamic_cast<Kopete::AddedInfoEvent *>(sender());
53 case Kopete::AddedInfoEvent::AddContactAction:
56 case Kopete::AddedInfoEvent::AuthorizeAction:
57 socket->authorize( event->contactId() );
59 case Kopete::AddedInfoEvent::InfoAction:
65 * @author Roman Jarosz <kedgedev@centrum.cz>
67 class KOPETE_EXPORT AddedInfoEvent
: public InfoEvent
72 * All actions that may be shown and emitted.
76 AddAction
= 0x001, /** Add action was activated. The default implementation shows
77 ContactAddedNotifyDialog if activate(uint) isn't replaced */
78 AuthorizeAction
= 0x002, /** You should authorize the contact */
79 BlockAction
= 0x004, /** You should block this and future requests */
80 InfoAction
= 0x008, /** You should show info about contact */
82 AddContactAction
= 0x100, /** You should add contact to Kopete contact list with @p addContact()
83 this is only emitted if activate(uint) isn't replaced */
86 Q_DECLARE_FLAGS(ShowActionOptions
, ShowAction
)
91 * @param contactId the contactId of the contact which has added you
92 * @param account the account which has generated this event
94 AddedInfoEvent( const QString
& contactId
, Kopete::Account
*account
);
99 * Return the contactId of a contact which has added you.
101 QString
contactId() const;
104 * Return the account that has generated this event.
106 Kopete::Account
* account() const;
109 * Set which actions should be shown.
111 * @param actions a bitmask of ShowAction used to show specific actions.
112 * @note by default everything is shown.
114 void showActions( ShowActionOptions actions
);
117 * Set contact nickname
119 * @param nickname the nickname of the contact.
121 void setContactNickname( const QString
& nickname
);
124 * @brief create a metacontact.
126 * This function only works if the AddContactAction action was activated, otherwise
129 * it uses the Account::addContact function to add the contact
131 * @return the new metacontact created, or 0L if the operation failed.
133 MetaContact
* addContact() const;
137 * Activate the action specified action
139 virtual void activate( uint actionId
);
144 virtual void sendEvent();
148 void addDialogInfo();
149 void addDialogFinished();
155 Q_DECLARE_OPERATORS_FOR_FLAGS( AddedInfoEvent::ShowActionOptions
)