Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / protocols / groupwise / gwaccount.h
blob1a71f9ed406a46f96d080e9f9179baa8948ffdf2
1 /*
2 gwaccount.h - Kopete GroupWise Protocol
4 Copyright (c) 2006,2007 Novell, Inc http://www.opensuse.org
5 Copyright (c) 2004 SUSE Linux AG http://www.suse.com
7 Based on Testbed
8 Copyright (c) 2003-2007 by Will Stephenson <wstephenson@kde.org>
10 Kopete (c) 2002-2007 by the Kopete developers <kopete-devel@kde.org>
12 *************************************************************************
13 * *
14 * This library is free software; you can redistribute it and/or *
15 * modify it under the terms of the GNU General Public *
16 * License as published by the Free Software Foundation; either *
17 * version 2 of the License, or (at your option) any later version. *
18 * *
19 *************************************************************************
22 #ifndef GW_ACCOUNT_H
23 #define GW_ACCOUNT_H
25 #include <QtCore/QList>
26 #include <QtCrypto>
28 #include <kaction.h>
30 #include <kopetechatsessionmanager.h>
31 #include <kopetecontact.h>
33 #include "gwerror.h"
35 #include <kopetepasswordedaccount.h>
37 class KActionMenu;
39 namespace Kopete {
40 class Group;
41 class MetaContact;
44 class GroupWiseContact;
45 class GroupWiseChatSession;
46 class GroupWiseProtocol;
47 class KNetworkConnector;
48 namespace QCA {
49 class TLS;
51 class QCATLSHandler;
52 class ClientStream;
53 class Client;
54 class GWContactList;
56 using namespace GroupWise;
58 /**
59 * This represents an account on a Novell GroupWise Messenger Server
61 class GroupWiseAccount : public Kopete::PasswordedAccount
63 Q_OBJECT
64 public:
65 GroupWiseAccount( GroupWiseProtocol *parent, const QString& accountID, const char *name = 0 );
66 ~GroupWiseAccount();
68 /**
69 * Construct the context menu used for the status bar icon
71 virtual void fillActionMenu( KActionMenu *actionMenu );
73 // DEBUG ONLY
74 void dumpManagers();
75 // DEBUG ONLY
76 /**
77 * Creates a protocol specific Kopete::Contact subclass and adds it to the supplied
78 * Kopete::MetaContact
80 virtual bool createContact(const QString& contactId, Kopete::MetaContact* parentContact);
81 /**
82 * Delete a contact on the server
84 void deleteContact( GroupWiseContact * contact );
85 /**
86 * Called when Kopete is set globally away
88 virtual void setAway(bool away, const QString& reason);
89 /**
90 * Utility access to the port given by the user
92 int port() const;
93 /**
94 * Utility access to the server given by the user
96 const QString server() const;
97 /**
98 * Utility access to our protocol
100 GroupWiseProtocol * protocol() const;
102 * Utility access to the @ref Client which is the main interface exposed by libgroupwise.
103 * Most protocol actions are carried out using the client's member functions but the possibility exists
104 * to start Tasks directly on the client and respond directly to their signals.
106 Client * client() const;
108 * Utility to create or access a message manager instance for a given GUID and set of contacts
110 GroupWiseChatSession * chatSession( Kopete::ContactPtrList others, const ConferenceGuid & guid, Kopete::Contact::CanCreateFlags canCreate );
112 * Look up a contact given a DN
113 * Returns 0 if none found
115 GroupWiseContact * contactForDN( const QString & dn );
117 * Create a conference (start a chat) on the server
119 void createConference( const int clientId, const QStringList& invitees );
122 * Send a message
124 void sendMessage( const ConferenceGuid & guid, const Kopete::Message & message );
127 * Invite someone to join a conference
129 void sendInvitation( const ConferenceGuid & guid, const QString & dn, const QString & message );
132 * Check a contact's blocking status
133 * Only works when connected - otherwise always returns false
135 bool isContactBlocked( const QString & m_dn );
137 * Set up a temporary contact (not on our contact list but is messaging us or involved in a conversation that we have been invited to.
139 GroupWiseContact * createTemporaryContact( const QString & dn );
142 * Check whether sync is not currently needed
144 bool dontSync();
146 void syncContact( GroupWiseContact * contact );
148 public slots:
150 void slotTestRTFize();
152 /* Connects to the server. */
153 void connectWithPassword ( const QString &password );
155 /* Disconnects from the server. */
156 virtual void disconnect();
157 virtual void disconnect( Kopete::Account::DisconnectReason reason );
159 /** Set the online status for the account. Reimplemented from Kopete::Account */
160 void setOnlineStatus( const Kopete::OnlineStatus& status , const Kopete::StatusMessage &reason = Kopete::StatusMessage(),
161 const OnlineStatusOptions& options = None );
163 * Set the status message for the account. Reimplemented from Kopete::Account
165 void setStatusMessage( const Kopete::StatusMessage &statusMessage );
167 signals:
168 void conferenceCreated( const int mmId, const GroupWise::ConferenceGuid & guid );
169 void conferenceCreationFailed( const int mmId, const int statusCode );
170 void contactTyping( const ConferenceEvent & );
171 void contactNotTyping( const ConferenceEvent & );
172 void privacyChanged( const QString & dn, bool allowed );
175 protected slots:
176 void slotMessageSendingFailed();
178 * Set an auto reply message for use when the account is away
179 * TODO: Extend Kopete::AwayAction so you can set multiple ones there.
181 void slotSetAutoReply();
183 * Manage the user's privacy settings
185 void slotPrivacy();
188 * Show a dialog to join a chatroom without first adding it to the contact list
190 void slotJoinChatRoom();
193 * Slot informing GroupWise when a group is renamed
195 void slotKopeteGroupRenamed( Kopete::Group * );
197 * Slot informing GroupWise when a group is removed
199 void slotKopeteGroupRemoved( Kopete::Group * );
201 // SERVER SIDE CONTACT LIST PROCESSING
203 * Called when we receive a FOLDER from the server side contact list
204 * Adds to the Kopete contact list if not already present.
206 void receiveFolder( const FolderItem & folder );
208 * Called when we receive a CONTACT from the server side contact list
209 * Adds to a folder in the Kopete contact list.
211 void receiveContact( const ContactItem & );
213 * Called when we receive a CONTACT'S METADATA (including initial status) from the server side contact list,
214 * or in response to an explicitly query. This is necessary to handle some events from the server.
215 * These events are queued in the account until the data arrives and then we handle the event.
217 void receiveContactUserDetails( const GroupWise::ContactDetails & );
219 * Called after we create a contact on the server
221 void receiveContactCreated();
223 * Handles the response to deleting a contact on the server
225 void receiveContactDeleted( const ContactItem & instance );
227 // SLOTS HANDLING PROTOCOL EVENTS
229 * Received a message from the server.
230 * Find the conversation that this message belongs to, and display it there.
231 * @param event contains event type, sender, content, flags. Type is used to handle autoreplies, normal messages, and [system] broadcasts.
233 void handleIncomingMessage( const ConferenceEvent & );
235 * A contact changed status
237 void receiveStatus( const QString &, quint16, const QString & );
239 * Our status changed on the server
241 void changeOurStatus( GroupWise::Status, const QString &, const QString & );
243 * Called when we've been disconnected for logging in as this user somewhere else
245 void slotConnectedElsewhere();
247 * Called when we've logged in successfully
249 void slotLoggedIn();
251 * Called when a login attempt failed
253 void slotLoginFailed();
255 * We joined a conference having accepted an invitation, create a message manager
257 void receiveConferenceJoin( const GroupWise::ConferenceGuid & guid, const QStringList & participants, const QStringList & invitees );
259 * Someone joined a conference, add them to the appropriate message manager
261 void receiveConferenceJoinNotify( const ConferenceEvent & );
263 * Someone left a conference, remove them from the message manager
265 void receiveConferenceLeft( const ConferenceEvent & );
267 * The user was invited to join a conference
269 void receiveInvitation( const ConferenceEvent & );
271 * Notification that a third party was invited to join conference
273 void receiveInviteNotify( const ConferenceEvent & );
275 * Notification that a third party declined an invitation
277 void receiveInviteDeclined( const ConferenceEvent & );
279 * A conference was closed by the server because everyone has left or declined invitations
280 * Prevents any further messages to this conference
282 // void closeConference();
283 // SLOTS HANDLING NETWORK EVENTS
285 * Update the local user's metadata
287 void receiveAccountDetails( const GroupWise::ContactDetails & details );
289 * The TLS handshake has happened, check the result
291 void slotTLSHandshaken();
292 /** The connection is ready for a login */
293 void slotTLSReady( int secLayerCode );
295 * Called when the clientstream is connected, debug only
297 void slotCSConnected();
299 * Performs necessary actions when the client stream has been disconnected
301 void slotCSDisconnected();
302 void slotCSError( int error );
303 void slotCSWarning( int warning );
305 // HOUSEKEEPING
307 * We listen for the destroyed() signal and leave any conferences we
308 * might have been in, and remove it from our map.
310 void slotLeavingConference( GroupWiseChatSession * );
312 /** Debug slots */
313 void slotConnError();
314 void slotConnConnected();
315 protected:
317 * Sends a status message to the server - called by the status specific slotGoAway etc
319 //void setStatus( GroupWise::Status status, const QString & reason = QString() );
321 int handleTLSWarning (QCA::TLS::IdentityResult identityResult,
322 QCA::Validity validityResult, QString server, QString accountId);
324 GroupWiseChatSession * findChatSessionByGuid( const GroupWise::ConferenceGuid & guid );
326 * reconcile any changes to the contact list which happened offline
328 void reconcileOfflineChanges();
330 * Memory management
332 void cleanup();
333 private:
334 // action menu and its actions
335 KAction * m_actionAutoReply;
336 KAction * m_actionManagePrivacy;
337 KAction * m_actionJoinChatRoom;
338 // Network code
339 KNetworkConnector * m_connector;
340 QCA::Initializer m_qcaInit;
341 QCA::TLS * m_QCATLS;
342 QCATLSHandler * m_tlsHandler;
343 ClientStream * m_clientStream;
344 // Client, entry point of libgroupwise
345 Client * m_client;
347 QString m_password;
348 QString m_initialReason;
349 QList<GroupWiseChatSession*> m_chatSessions;
350 bool m_dontSync;
351 GWContactList * m_serverListModel;
355 * @internal
356 * An action that selects an OnlineStatus and provides a status message, but not using Kopete::Away, because the status message relates only to this status.
358 /*class OnlineStatusMessageAction : public KAction
360 Q_OBJECT
361 public:
362 OnlineStatusMessageAction ( const Kopete::OnlineStatus& status, const QString &text, const QString &message, const QIcon &pix, QObject *parent=0, const char *name=0);
363 signals:
364 void activated( const Kopete::OnlineStatus& status, const QString & );
365 private slots:
366 void slotActivated();
367 private:
368 Kopete::OnlineStatus m_status;
369 QString m_message;
372 #endif