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
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 *************************************************************************
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. *
19 *************************************************************************
25 #include <QtCore/QList>
30 #include <kopetechatsessionmanager.h>
31 #include <kopetecontact.h>
35 #include <kopetepasswordedaccount.h>
44 class GroupWiseContact
;
45 class GroupWiseChatSession
;
46 class GroupWiseProtocol
;
47 class KNetworkConnector
;
56 using namespace GroupWise
;
59 * This represents an account on a Novell GroupWise Messenger Server
61 class GroupWiseAccount
: public Kopete::PasswordedAccount
65 GroupWiseAccount( GroupWiseProtocol
*parent
, const QString
& accountID
, const char *name
= 0 );
69 * Construct the context menu used for the status bar icon
71 virtual void fillActionMenu( KActionMenu
*actionMenu
);
77 * Creates a protocol specific Kopete::Contact subclass and adds it to the supplied
80 virtual bool createContact(const QString
& contactId
, Kopete::MetaContact
* parentContact
);
82 * Delete a contact on the server
84 void deleteContact( GroupWiseContact
* contact
);
86 * Called when Kopete is set globally away
88 virtual void setAway(bool away
, const QString
& reason
);
90 * Utility access to the port given by the user
94 * Utility access to the server given by the user
96 const QString
server() const;
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
);
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
146 void syncContact( GroupWiseContact
* contact
);
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() );
162 * Set the status message for the account. Reimplemented from Kopete::Account
164 void setStatusMessage( const Kopete::StatusMessage
&statusMessage
);
167 void conferenceCreated( const int mmId
, const GroupWise::ConferenceGuid
& guid
);
168 void conferenceCreationFailed( const int mmId
, const int statusCode
);
169 void contactTyping( const ConferenceEvent
& );
170 void contactNotTyping( const ConferenceEvent
& );
171 void privacyChanged( const QString
& dn
, bool allowed
);
175 void slotMessageSendingFailed();
177 * Set an auto reply message for use when the account is away
178 * TODO: Extend Kopete::AwayAction so you can set multiple ones there.
180 void slotSetAutoReply();
182 * Manage the user's privacy settings
187 * Show a dialog to join a chatroom without first adding it to the contact list
189 void slotJoinChatRoom();
192 * Slot informing GroupWise when a group is renamed
194 void slotKopeteGroupRenamed( Kopete::Group
* );
196 * Slot informing GroupWise when a group is removed
198 void slotKopeteGroupRemoved( Kopete::Group
* );
200 // SERVER SIDE CONTACT LIST PROCESSING
202 * Called when we receive a FOLDER from the server side contact list
203 * Adds to the Kopete contact list if not already present.
205 void receiveFolder( const FolderItem
& folder
);
207 * Called when we receive a CONTACT from the server side contact list
208 * Adds to a folder in the Kopete contact list.
210 void receiveContact( const ContactItem
& );
212 * Called when we receive a CONTACT'S METADATA (including initial status) from the server side contact list,
213 * or in response to an explicitly query. This is necessary to handle some events from the server.
214 * These events are queued in the account until the data arrives and then we handle the event.
216 void receiveContactUserDetails( const GroupWise::ContactDetails
& );
218 * Called after we create a contact on the server
220 void receiveContactCreated();
222 * Handles the response to deleting a contact on the server
224 void receiveContactDeleted( const ContactItem
& instance
);
226 // SLOTS HANDLING PROTOCOL EVENTS
228 * Received a message from the server.
229 * Find the conversation that this message belongs to, and display it there.
230 * @param event contains event type, sender, content, flags. Type is used to handle autoreplies, normal messages, and [system] broadcasts.
232 void handleIncomingMessage( const ConferenceEvent
& );
234 * A contact changed status
236 void receiveStatus( const QString
&, quint16
, const QString
& );
238 * Our status changed on the server
240 void changeOurStatus( GroupWise::Status
, const QString
&, const QString
& );
242 * Called when we've been disconnected for logging in as this user somewhere else
244 void slotConnectedElsewhere();
246 * Called when we've logged in successfully
250 * Called when a login attempt failed
252 void slotLoginFailed();
254 * We joined a conference having accepted an invitation, create a message manager
256 void receiveConferenceJoin( const GroupWise::ConferenceGuid
& guid
, const QStringList
& participants
, const QStringList
& invitees
);
258 * Someone joined a conference, add them to the appropriate message manager
260 void receiveConferenceJoinNotify( const ConferenceEvent
& );
262 * Someone left a conference, remove them from the message manager
264 void receiveConferenceLeft( const ConferenceEvent
& );
266 * The user was invited to join a conference
268 void receiveInvitation( const ConferenceEvent
& );
270 * Notification that a third party was invited to join conference
272 void receiveInviteNotify( const ConferenceEvent
& );
274 * Notification that a third party declined an invitation
276 void receiveInviteDeclined( const ConferenceEvent
& );
278 * A conference was closed by the server because everyone has left or declined invitations
279 * Prevents any further messages to this conference
281 // void closeConference();
282 // SLOTS HANDLING NETWORK EVENTS
284 * Update the local user's metadata
286 void receiveAccountDetails( const GroupWise::ContactDetails
& details
);
288 * The TLS handshake has happened, check the result
290 void slotTLSHandshaken();
291 /** The connection is ready for a login */
292 void slotTLSReady( int secLayerCode
);
294 * Called when the clientstream is connected, debug only
296 void slotCSConnected();
298 * Performs necessary actions when the client stream has been disconnected
300 void slotCSDisconnected();
301 void slotCSError( int error
);
302 void slotCSWarning( int warning
);
306 * We listen for the destroyed() signal and leave any conferences we
307 * might have been in, and remove it from our map.
309 void slotLeavingConference( GroupWiseChatSession
* );
312 void slotConnError();
313 void slotConnConnected();
316 * Sends a status message to the server - called by the status specific slotGoAway etc
318 //void setStatus( GroupWise::Status status, const QString & reason = QString() );
320 int handleTLSWarning (QCA::TLS::IdentityResult identityResult
,
321 QCA::Validity validityResult
, QString server
, QString accountId
);
323 GroupWiseChatSession
* findChatSessionByGuid( const GroupWise::ConferenceGuid
& guid
);
325 * reconcile any changes to the contact list which happened offline
327 void reconcileOfflineChanges();
333 // action menu and its actions
334 KAction
* m_actionAutoReply
;
335 KAction
* m_actionManagePrivacy
;
336 KAction
* m_actionJoinChatRoom
;
338 KNetworkConnector
* m_connector
;
339 QCA::Initializer m_qcaInit
;
341 QCATLSHandler
* m_tlsHandler
;
342 ClientStream
* m_clientStream
;
343 // Client, entry point of libgroupwise
347 QString m_initialReason
;
348 QList
<GroupWiseChatSession
*> m_chatSessions
;
350 GWContactList
* m_serverListModel
;
355 * 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.
357 /*class OnlineStatusMessageAction : public KAction
361 OnlineStatusMessageAction ( const Kopete::OnlineStatus& status, const QString &text, const QString &message, const QIcon &pix, QObject *parent=0, const char *name=0);
363 void activated( const Kopete::OnlineStatus& status, const QString & );
365 void slotActivated();
367 Kopete::OnlineStatus m_status;