Port things from MSN to WLM plugin:
[kdenetwork.git] / kopete / protocols / groupwise / gwmessagemanager.h
blob37d29d7917015941b1bced275caa8f827a1f14ca
1 /*
2 gwmessagemanager.h - Kopete GroupWise Protocol
4 Copyright (c) 2006 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 by Will Stephenson <will@stevello.free-online.co.uk>
10 Kopete (c) 2002-2003 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 GWMESSAGEMANAGER_H
23 #define GWMESSAGEMANAGER_H
25 #include <QLabel>
26 #include <QList>
27 #include <kopetemessage.h>
28 #include <kopetechatsession.h>
30 #include "gwerror.h"
32 class QLabel;
33 class KAction;
34 class KActionMenu;
35 class KDialog;
36 class GroupWiseAccount;
37 class GroupWiseContact;
38 class GroupWiseContactSearch;
39 /**
40 * Specialized message manager, which tracks the GUID used by GroupWise to uniquely identify a given chat, and provides invite actions and logging and security indicators. To instantiate call @ref GroupWiseAccount::chatSession().
41 * @author SUSE AG
44 using namespace GroupWise;
46 class GroupWiseChatSession : public Kopete::ChatSession
48 Q_OBJECT
50 friend class GroupWiseAccount;
52 public:
53 /**
54 * The destructor emits leavingConference so that the account can tell the server that the user has left the chat
56 ~GroupWiseChatSession();
57 /**
58 * The conference's globally unique identifier, which is given to it by the server
60 ConferenceGuid guid() const { return m_guid; }
61 /**
62 * Change the GUID
64 void setGuid( const ConferenceGuid & guid );
65 /**
66 * Utility account access
68 GroupWiseAccount * account();
69 /**
70 * Accessors and mutators for secure chat, logged chat, and closed conference flags
72 void setSecure( bool secure );
73 void setLogging( bool logged );
74 void setClosed();
75 bool secure();
76 bool logging();
77 bool closed();
78 /**
79 * Add invitees to the conference
81 void addInvitee( const Kopete::Contact * );
82 /**
83 * Add members to the conference
85 void joined( GroupWiseContact * );
86 /**
87 * Remove members from conference
89 void left( GroupWiseContact * );
90 /**
91 * An invitation was declined
93 void inviteDeclined( GroupWiseContact * );
94 /**
95 * Check whether the conversation being administratively logged and update the UI to indicate this
97 void updateArchiving();
98 /**
99 * Reimplemented from Kopete::ChatSession - invites contacts via DND
101 virtual void inviteContact(const QString& );
102 signals:
104 * Tell the contact we got a GUID so it can route incoming messages here.
106 void conferenceCreated();
108 * Tell the account that the GroupWiseChatSession is closing so it can tell the server that the user has left the conference
110 void leavingConference( GroupWiseChatSession * );
111 protected:
113 * Start the process of creating a conference for this GWMM on the server.
115 void createConference();
116 /**
117 * Sends any messages and invitations that were queued while waiting for the conference to be created
119 void dequeueMessagesAndInvites();
120 protected slots:
121 /**
122 * Receive the GUID returned by the server when we start a chat.
123 * @param mmId Message Manager ID, used to determine if this GUID is meant for this message manager
124 * @param guid The GUID allotted us by the server.
126 void receiveGuid( const int mmId, const GroupWise::ConferenceGuid & guid );
128 * An attempt to create a conference on the server failed.
129 * @param mmId Message Manager ID to see if the failure refers to this message manager
131 void slotCreationFailed( const int mmId,const int statusCode );
133 void slotSendTypingNotification ( bool typing );
134 void slotMessageSent( Kopete::Message &message, Kopete::ChatSession * );
135 // TODO: slots for us leaving conference, us inviting someone, someone joining, someone leaving, someone sending an invitation, getting typing?
136 void slotGotTypingNotification( const ConferenceEvent & );
137 void slotGotNotTypingNotification( const ConferenceEvent & );
139 * Popupulate the menu of invitable contacts
141 void slotActionInviteAboutToShow();
143 * Invite a contact to join this chat
145 void slotInviteContact( Kopete::Contact * );
146 /**
147 * Show the search dialog to invite another contact to the chat
149 void slotInviteOtherContact();
151 * Process the response from the search dialog; send the actual invitation
153 void slotSearchedForUsers();
155 void slotShowSecurity();
156 void slotShowArchiving();
157 private:
159 GroupWiseChatSession(const Kopete::Contact* user, Kopete::ContactPtrList others, Kopete::Protocol* protocol, const ConferenceGuid & guid, int id = 0 );
161 ConferenceGuid m_guid; // The conference's globally unique identifier, which is given to it by the server
162 int m_flags; // flags for secure connections, central logging and "conference closed" as given by the server
164 QList< Kopete::Message > m_pendingOutgoingMessages; // messages queued while we wait for the server to tell us the conference is created.
165 Kopete::ContactPtrList m_pendingInvites; // people we wanted to invite to the conference, queued while waiting for the conference to be created.
166 KActionMenu *m_actionInvite;
167 QList<KAction*> m_inviteActions;
168 // labels showing secure and logging status
169 KAction *m_secure;
170 KAction *m_logging;
171 // search widget and dialog used for inviting contacts
172 GroupWiseContactSearch * m_search;
173 KDialog * m_searchDlg;
174 // contacts who have been invited to join but have not yet joined the chat
175 Kopete::ContactPtrList m_invitees;
176 // track the number of members actually in the chat
177 uint m_memberCount;
180 * return an unique identifier for that kmm
181 * @todo check it!
183 uint mmId() const;
184 uint m_mmId;
188 #endif