1 | /*
|
---|
2 | * psicon.h - core of Psi
|
---|
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 PSICON_H
|
---|
22 | #define PSICON_H
|
---|
23 |
|
---|
24 | #include<qcombobox.h>
|
---|
25 | #include"profiles.h"
|
---|
26 | #include"psievent.h"
|
---|
27 | #include"im.h"
|
---|
28 |
|
---|
29 | using namespace XMPP;
|
---|
30 |
|
---|
31 | class PsiCon;
|
---|
32 | class PsiAccount;
|
---|
33 | class ContactView;
|
---|
34 | class EventDlg;
|
---|
35 | class UserListItem;
|
---|
36 | class EDB;
|
---|
37 | class EDBItem;
|
---|
38 | class ProxyManager;
|
---|
39 | class MainWin;
|
---|
40 | class FileTransDlg;
|
---|
41 | class IconSelectPopup;
|
---|
42 | class QThread;
|
---|
43 | class PsiActionList;
|
---|
44 | class PsiToolBar;
|
---|
45 | class TabDlg;
|
---|
46 | class ChatDlg;
|
---|
47 |
|
---|
48 | namespace OpenPGP
|
---|
49 | {
|
---|
50 | class Engine;
|
---|
51 | }
|
---|
52 |
|
---|
53 | typedef QPtrList<PsiAccount> PsiAccountList;
|
---|
54 | typedef QPtrListIterator<PsiAccount> PsiAccountListIt;
|
---|
55 |
|
---|
56 | class AccountsComboBox : public QComboBox
|
---|
57 | {
|
---|
58 | Q_OBJECT
|
---|
59 | public:
|
---|
60 | AccountsComboBox(PsiCon *, QWidget *parent=0, bool online_only = false);
|
---|
61 | ~AccountsComboBox();
|
---|
62 |
|
---|
63 | void setAccount(PsiAccount *);
|
---|
64 |
|
---|
65 | signals:
|
---|
66 | void activated(PsiAccount *);
|
---|
67 |
|
---|
68 | private slots:
|
---|
69 | void changeAccount();
|
---|
70 | void updateAccounts();
|
---|
71 | void deleteMe();
|
---|
72 |
|
---|
73 | private:
|
---|
74 | PsiCon *psi;
|
---|
75 | PsiAccount *pa;
|
---|
76 | bool onlineOnly;
|
---|
77 | };
|
---|
78 |
|
---|
79 | class PsiCon : public QObject
|
---|
80 | {
|
---|
81 | Q_OBJECT
|
---|
82 | public:
|
---|
83 | enum { QuitProgram, QuitProfile };
|
---|
84 | PsiCon();
|
---|
85 | ~PsiCon();
|
---|
86 |
|
---|
87 | bool init();
|
---|
88 | void deinit();
|
---|
89 |
|
---|
90 | ContactView *contactView() const;
|
---|
91 | const PsiAccountList & accountList(bool enabledOnly=FALSE) const;
|
---|
92 | EDB *edb() const;
|
---|
93 | OpenPGP::Engine *pgp() const;
|
---|
94 | ProxyManager *proxy() const;
|
---|
95 | FileTransDlg *ftdlg() const;
|
---|
96 |
|
---|
97 | TabDlg* getTabs();
|
---|
98 | TabDlg* newTabs();
|
---|
99 | bool isChatTabbed(ChatDlg*);
|
---|
100 | bool isChatActiveWindow(ChatDlg*);
|
---|
101 | ChatDlg* getChatInTabs(QString);
|
---|
102 | TabDlg* getManagingTabs(ChatDlg*);
|
---|
103 | QPtrList<TabDlg>* getTabSets();
|
---|
104 |
|
---|
105 | QWidget *dialogFind(const char *className);
|
---|
106 | void dialogRegister(QWidget *w);
|
---|
107 | void dialogUnregister(QWidget *w);
|
---|
108 |
|
---|
109 | bool isValid(PsiAccount *);
|
---|
110 | void createAccount(const QString &name, const Jid &j="", const QString &pass="", bool opt_host=false, const QString &host="", int port=5222, bool ssl=false, int proxy=0);
|
---|
111 | //void createAccount(const QString &, const QString &host="", int port=5222, bool ssl=false, const QString &user="", const QString &pass="");
|
---|
112 | void modifyAccount(PsiAccount *);
|
---|
113 | void removeAccount(PsiAccount *);
|
---|
114 | void enableAccount(PsiAccount *, bool e=TRUE);
|
---|
115 |
|
---|
116 | void playSound(const QString &);
|
---|
117 | void raiseMainwin();
|
---|
118 |
|
---|
119 | // global event handling
|
---|
120 | int queueCount();
|
---|
121 | PsiAccount *queueLowestEventId();
|
---|
122 |
|
---|
123 | AccountsComboBox *accountsComboBox(QWidget *parent=0, bool online_only = false);
|
---|
124 |
|
---|
125 | const QStringList & recentGCList() const;
|
---|
126 | void recentGCAdd(const QString &);
|
---|
127 | const QStringList & recentBrowseList() const;
|
---|
128 | void recentBrowseAdd(const QString &);
|
---|
129 | const QStringList & recentNodeList() const;
|
---|
130 | void recentNodeAdd(const QString &);
|
---|
131 |
|
---|
132 | EventDlg *createEventDlg(const QString &, PsiAccount *);
|
---|
133 | void updateContactGlobal(PsiAccount *, const Jid &);
|
---|
134 |
|
---|
135 | QPtrList<PsiToolBar> *toolbarList() const;
|
---|
136 | PsiToolBar *findToolBar(QString group, int index);
|
---|
137 | PsiActionList *actionList() const;
|
---|
138 |
|
---|
139 | MainWin *mainWin() const;
|
---|
140 | IconSelectPopup *iconSelectPopup() const;
|
---|
141 | void processEvent(PsiEvent *);
|
---|
142 |
|
---|
143 | signals:
|
---|
144 | void quit(int);
|
---|
145 | void accountAdded(PsiAccount *);
|
---|
146 | void accountUpdated(PsiAccount *);
|
---|
147 | void accountRemoved(PsiAccount *);
|
---|
148 | void accountCountChanged();
|
---|
149 | void accountActivityChanged();
|
---|
150 | void emitOptionsUpdate();
|
---|
151 | void pgpToggled(bool);
|
---|
152 | void pgpKeysUpdated();
|
---|
153 |
|
---|
154 | public slots:
|
---|
155 | void setGlobalStatus(const Status &);
|
---|
156 | QWidget *doToolbars();
|
---|
157 |
|
---|
158 | private slots:
|
---|
159 | void doSleep();
|
---|
160 | void doWakeup();
|
---|
161 | void closeProgram();
|
---|
162 | void changeProfile();
|
---|
163 | void doManageAccounts();
|
---|
164 | void doGroupChat();
|
---|
165 | void doNewBlankMessage();
|
---|
166 | void doOptions();
|
---|
167 | void doFileTransDlg();
|
---|
168 | void statusMenuChanged(int);
|
---|
169 | void pa_updatedActivity();
|
---|
170 | void pa_updatedAccount();
|
---|
171 | void slotApplyOptions(const Options &);
|
---|
172 | void queueChanged();
|
---|
173 | void recvNextEvent();
|
---|
174 | void setStatusFromDialog(const Status &);
|
---|
175 | void pgp_initFinished(bool, const QString &);
|
---|
176 | void pgp_keysUpdated();
|
---|
177 | void proxy_settingsChanged();
|
---|
178 | void accel_activated(int);
|
---|
179 | void updateMainwinStatus();
|
---|
180 | void tabDying(TabDlg*);
|
---|
181 |
|
---|
182 | void mainWinGeomChanged(int x, int y, int w, int h);
|
---|
183 |
|
---|
184 | private:
|
---|
185 | class Private;
|
---|
186 | Private *d;
|
---|
187 |
|
---|
188 | PsiAccount *loadAccount(const UserAccount &);
|
---|
189 | void loadAccounts(const UserAccountList &);
|
---|
190 | UserAccountList unloadAccounts();
|
---|
191 | void deleteAllDialogs();
|
---|
192 | void saveAccounts();
|
---|
193 | void pgp_init(const QString &);
|
---|
194 | void s5b_init();
|
---|
195 | void updateS5BServerAddresses();
|
---|
196 |
|
---|
197 | friend class PsiAccount;
|
---|
198 | void link(PsiAccount *);
|
---|
199 | void unlink(PsiAccount *);
|
---|
200 | void setToggles(bool tog_offline, bool tog_away, bool tog_agents, bool tog_hidden, bool tog_self);
|
---|
201 | void getToggles(bool *tog_offline, bool *tog_away, bool *tog_agents, bool *tog_hidden, bool *tog_self);
|
---|
202 |
|
---|
203 | friend class EventQueue;
|
---|
204 | int getId();
|
---|
205 | };
|
---|
206 |
|
---|
207 | #endif
|
---|