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