~ubuntu-branches/ubuntu/jaunty/psi/jaunty

« back to all changes in this revision

Viewing changes to src/psiaccount.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2005-01-10 17:41:43 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050110174143-ltocv5zapl6blf5d
Tags: 0.9.3-1
* New upstream release
* Cleaned up debian/rules (some things are done by upstream Makefiles now)
* Fixed some lintian warnings:
  - removed executable bit from some .png files
  - moved psi.desktop to /usr/share/applications
* Updated menu files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * psiaccount.h - handles a Psi account
 
3
 * Copyright (C) 2001, 2002  Justin Karneges
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * as published by the Free Software Foundation; either version 2
 
8
 * of the License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this library; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 *
 
19
 */
 
20
 
 
21
#ifndef PSIACCOUNT_H
 
22
#define PSIACCOUNT_H
 
23
 
 
24
#include<qlabel.h>
 
25
#include<qptrlist.h>
 
26
#include<qdom.h>
 
27
#include"xmpp.h"
 
28
#include"openpgp.h"
 
29
#include"contactview.h"
 
30
#include"ui_pgpkey.h"
 
31
 
 
32
namespace XMPP
 
33
{
 
34
        class Status;
 
35
        class RosterItem;
 
36
        class Client;
 
37
        //class StreamError;
 
38
        class Resource;
 
39
        class Message;
 
40
};
 
41
 
 
42
using namespace XMPP;
 
43
 
 
44
class PsiCon;
 
45
class PsiAccount;
 
46
class PsiEvent;
 
47
class UserAccount;
 
48
class ContactProfile;
 
49
class QWidget;
 
50
class EventQueue;
 
51
class UserResource;
 
52
class UserListItem;
 
53
class UserList;
 
54
class EventDlg;
 
55
class ChatDlg;
 
56
class EDB;
 
57
class QSSLCert;
 
58
class QHostAddress;
 
59
//class AvatarFactory;
 
60
 
 
61
class PGPKeyDlg : public PGPKeyUI
 
62
{
 
63
        Q_OBJECT
 
64
public:
 
65
        PGPKeyDlg(const OpenPGP::KeyList &, const QString &choose, QWidget *parent=0, const char *name=0);
 
66
        ~PGPKeyDlg();
 
67
 
 
68
        QString keyID() const;
 
69
        QString userID() const;
 
70
 
 
71
private slots:
 
72
        void qlv_doubleClicked(QListViewItem *);
 
73
        void do_accept();
 
74
 
 
75
private:
 
76
        class Private;
 
77
        Private *d;
 
78
};
 
79
 
 
80
class AccountLabel : public QLabel
 
81
{
 
82
        Q_OBJECT
 
83
public:
 
84
        AccountLabel(PsiAccount *, QWidget *parent=0, bool simpleMode=false);
 
85
        ~AccountLabel();
 
86
 
 
87
private slots:
 
88
        void updateName();
 
89
        void deleteMe();
 
90
 
 
91
private:
 
92
        PsiAccount *pa;
 
93
        bool simpleMode;
 
94
};
 
95
 
 
96
class PGPTransaction : public OpenPGP::Request
 
97
{
 
98
        Q_OBJECT
 
99
public:
 
100
        PGPTransaction(OpenPGP::Engine *);
 
101
        ~PGPTransaction();
 
102
 
 
103
        int id() const;
 
104
        const Message & message() const;
 
105
        void setMessage(const Message &);
 
106
        const QDomElement & xml() const;
 
107
        void setXml(const QDomElement &);
 
108
 
 
109
        Jid jid() const;
 
110
        void setJid(const Jid &);
 
111
 
 
112
private:
 
113
        class Private;
 
114
        Private *d;
 
115
};
 
116
 
 
117
// sick sick remove this someday please!
 
118
#include"im.h"
 
119
struct GCContact
 
120
{
 
121
        Jid jid;
 
122
        Status status;
 
123
};
 
124
 
 
125
class PsiAccount : public QObject
 
126
{
 
127
        Q_OBJECT
 
128
public:
 
129
        PsiAccount(const UserAccount &acc, PsiCon *parent);
 
130
        ~PsiAccount();
 
131
 
 
132
        bool enabled() const;
 
133
        void setEnabled(bool e = TRUE);
 
134
 
 
135
        bool isActive() const;
 
136
        bool isConnected() const;
 
137
        const QString &name() const;
 
138
 
 
139
        const UserAccount & userAccount() const;
 
140
        void setUserAccount(const UserAccount &);
 
141
        const Jid & jid() const;
 
142
        QString nameWithJid() const;
 
143
 
 
144
        XMPP::Client *client() const;
 
145
        ContactProfile *contactProfile() const;
 
146
        EventQueue *eventQueue() const;
 
147
        EDB *edb() const;
 
148
        PsiCon *psi() const;
 
149
 
 
150
        // Avatars
 
151
        //AvatarFactory *avatarFactory() const;
 
152
 
 
153
        Status status() const;
 
154
        void setStatusDirect(const Status &);
 
155
        void setStatusActual(const Status &);
 
156
        void login();
 
157
        void logout(bool fast=false, const Status &s = Status("", "Logged out", 0, false));
 
158
        bool loggedIn() const;
 
159
        void setNick(const QString &);
 
160
        QString nick() const;
 
161
        QString pgpKey() const;
 
162
        QHostAddress *localAddress() const;
 
163
 
 
164
        QWidget *dialogFind(const char *className, const Jid &jid="");
 
165
        void dialogRegister(QWidget *w, const Jid &jid="");
 
166
        void dialogUnregister(QWidget *w);
 
167
 
 
168
        void modify();
 
169
        void changeVCard();
 
170
        void changePW();
 
171
        void changeStatus(int);
 
172
        void doDisco();
 
173
 
 
174
        void showXmlConsole();
 
175
        void openAddUserDlg();
 
176
        void openGroupChat(const Jid &);
 
177
        bool groupChatJoin(const QString &host, const QString &room, const QString &nick);
 
178
        void groupChatSetStatus(const QString &host, const QString &room, const Status &);
 
179
        void groupChatChangeNick(const QString &host, const QString &room, const QString& nick, const Status &);
 
180
        void groupChatLeave(const QString &host, const QString &room);
 
181
 
 
182
        UserListItem *find(const Jid &) const;
 
183
        QPtrList<UserListItem> findRelavent(const Jid &) const;
 
184
        UserListItem *findFirstRelavent(const Jid &) const;
 
185
        UserList *userList() const;
 
186
 
 
187
        bool checkConnected(QWidget *parent=0);
 
188
        void playSound(const QString &);
 
189
 
 
190
        QLabel *accountLabel(QWidget *parent=0, bool simpleMode=false);
 
191
        QStringList hiddenChats(const Jid &) const;
 
192
 
 
193
        int sendMessageEncrypted(const Message &);
 
194
 
 
195
        // sucks sucks sucks sucks sucks sucks sucks
 
196
        GCContact *findGCContact(const Jid &j);
 
197
        QStringList groupchats() const;
 
198
 
 
199
        void toggleSecurity(const Jid &, bool);
 
200
        bool ensureKey(const Jid &);
 
201
        void tryVerify(UserListItem *, UserResource *);
 
202
 
 
203
        static QString resultToString(int result);
 
204
        static void getErrorInfo(int err, AdvancedConnector *conn, Stream *stream, QCATLSHandler *tlsHandler, QString *_str, bool *_reconn);
 
205
 
 
206
        void deleteQueueFile();
 
207
 
 
208
signals:
 
209
        void disconnected();
 
210
        void updatedActivity();
 
211
        void updatedAccount();
 
212
        void queueChanged();
 
213
        void updateContact(const UserListItem &);
 
214
        void updateContact(const Jid &);
 
215
        void updateContact(const Jid &, bool);
 
216
        void nickChanged();
 
217
        void pgpKeyChanged();
 
218
        void encryptedMessageSent(int, bool);
 
219
 
 
220
public slots:
 
221
        void setStatus(const Status &);
 
222
 
 
223
        void secondsIdle(int);
 
224
        void openNextEvent();
 
225
 
 
226
        void dj_sendMessage(const Message &, bool log=true);
 
227
        void dj_composeMessage(const Jid &jid, const QString &body);
 
228
        void dj_composeMessage(const Jid &jid, const QString &body, const QString &subject, const QString &thread);
 
229
        void dj_addAuth(const Jid &);
 
230
        void dj_add(const Jid &, const QString &, const QStringList &, bool authReq);
 
231
        void dj_authReq(const Jid &);
 
232
        void dj_auth(const Jid &);
 
233
        void dj_deny(const Jid &);
 
234
        void dj_rename(const Jid &, const QString &);
 
235
        void dj_remove(const Jid &);
 
236
 
 
237
        void actionDefault(const Jid &);
 
238
        void actionRecvEvent(const Jid &);
 
239
        void actionSendMessage(const Jid &);
 
240
        void actionSendMessage(const JidList &);
 
241
        void actionSendUrl(const Jid &);
 
242
        void actionRemove(const Jid &);
 
243
        void actionRename(const Jid &, const QString &);
 
244
        void actionGroupRename(const QString &, const QString &);
 
245
        void actionHistory(const Jid &);
 
246
        void actionStatusShow(const Jid &);
 
247
        void actionOpenChat(const Jid &);
 
248
        void actionOpenChatSpecific(const Jid &);
 
249
        void actionAgentSetStatus(const Jid &, int);
 
250
        void actionInfo(const Jid &);
 
251
        void actionAuth(const Jid &);
 
252
        void actionAuthRequest(const Jid &);
 
253
        void actionAuthRemove(const Jid &);
 
254
        void actionAdd(const Jid &);
 
255
        void actionGroupAdd(const Jid &, const QString &);
 
256
        void actionGroupRemove(const Jid &, const QString &);
 
257
        void actionHistoryBox(PsiEvent *);
 
258
        void actionTest(const Jid &);
 
259
        void actionRegister(const Jid &);
 
260
        void actionSearch(const Jid &);
 
261
        void actionJoin(const Jid &);
 
262
        void actionDisco(const Jid &, const QString &);
 
263
        void actionInvite(const Jid &, const QString &);
 
264
        void actionSendFile(const Jid &);
 
265
        void actionSendFiles(const Jid &, const QStringList&);
 
266
        void featureActivated(QString feature, Jid jid, QString node);
 
267
 
 
268
        void actionAssignKey(const Jid &);
 
269
        void actionUnassignKey(const Jid &);
 
270
 
 
271
        void invokeGCMessage(const Jid &);
 
272
        void invokeGCChat(const Jid &);
 
273
        void invokeGCInfo(const Jid &);
 
274
        void invokeGCFile(const Jid &);
 
275
 
 
276
private slots:
 
277
        void tls_handshaken();
 
278
        void cs_connected();
 
279
        void cs_securityLayerActivated();
 
280
        void cs_needAuthParams(bool, bool, bool);
 
281
        void cs_authenticated();
 
282
        void cs_connectionClosed();
 
283
        void cs_delayedCloseFinished();
 
284
        void cs_warning(int);
 
285
        void cs_error(int);
 
286
        void client_rosterRequestFinished(bool, int, const QString &);
 
287
        void client_rosterItemUpdated(const RosterItem &);
 
288
        void client_rosterItemRemoved(const RosterItem &);
 
289
        void client_resourceAvailable(const Jid &, const Resource &);
 
290
        void client_resourceUnavailable(const Jid &, const Resource &);
 
291
        void client_presenceError(const Jid &, int, const QString &);
 
292
        void client_messageReceived(const Message &);
 
293
        void client_subscription(const Jid &, const QString &);
 
294
        void client_debugText(const QString &);
 
295
        void client_groupChatJoined(const Jid &);
 
296
        void client_groupChatLeft(const Jid &);
 
297
        void client_groupChatPresence(const Jid &, const Status &);
 
298
        void client_groupChatError(const Jid &, int, const QString &);
 
299
        void client_incomingJidLink();
 
300
        void client_incomingFileTransfer();
 
301
 
 
302
        void reconnect();
 
303
        void disconnect();
 
304
        void enableNotifyOnline();
 
305
 
 
306
        void slotClientVersionFinished();
 
307
 
 
308
        void chatMessagesRead(const Jid &);
 
309
 
 
310
        void slotCheckVCard();
 
311
        void edb_finished();
 
312
        void pgpToggled(bool);
 
313
        void pgpKeysUpdated();
 
314
 
 
315
        void trySignPresence();
 
316
        void pgp_needPassphrase();
 
317
        void pgp_signFinished(bool);
 
318
        void pgp_verifyFinished(bool);
 
319
        void pgp_finished(bool);
 
320
        void pgp_decryptFinished(bool);
 
321
 
 
322
        void submitPassphrase(const QString &);
 
323
        void rejectPassphrase();
 
324
 
 
325
        void optionsUpdate();
 
326
 
 
327
        void processReadNext(const UserListItem &);
 
328
        void processReadNext(const Jid &);
 
329
 
 
330
private slots:
 
331
        void handleEvent(PsiEvent *);
 
332
 
 
333
public:
 
334
        class Private;
 
335
private:
 
336
        Private *d;
 
337
 
 
338
        void deleteAllDialogs();
 
339
        void stateChanged();
 
340
        void simulateContactOffline(UserListItem *);
 
341
        void simulateRosterOffline();
 
342
        void cpUpdate(const UserListItem &, const QString &rname="", bool fromPresence=false);
 
343
        void logEvent(const Jid &, PsiEvent *);
 
344
        void queueEvent(PsiEvent *);
 
345
        void openNextEvent(const UserListItem &);
 
346
        void updateReadNext(const Jid &);
 
347
        ChatDlg *ensureChatDlg(const Jid &);
 
348
        void lastStepLogin();
 
349
        void processIncomingMessage(const Message &);
 
350
        void processEncryptedMessage(const Message &);
 
351
        void processMessageQueue();
 
352
        void processEncryptedMessageNext();
 
353
        void processEncryptedMessageDone();
 
354
        void verifyStatus(const Jid &j, const Status &s);
 
355
 
 
356
        void promptPassphrase();
 
357
        void processChats(const Jid &);
 
358
        void openChat(const Jid &);
 
359
        EventDlg *ensureEventDlg(const Jid &);
 
360
        friend class PsiCon;
 
361
 
 
362
        bool isDisconnecting, notifyOnlineOk, doReconnect, usingAutoStatus, rosterDone, presenceSent, v_isActive;
 
363
        void cleanupStream();
 
364
};
 
365
 
 
366
#endif