1 | /*
|
---|
2 | * common.h - contains all the common variables and functions for Psi
|
---|
3 | * Copyright (C) 2001-2003 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 COMMON_H
|
---|
22 | #define COMMON_H
|
---|
23 |
|
---|
24 | #include<qstring.h>
|
---|
25 | #include<qpixmap.h>
|
---|
26 | #include<qimage.h>
|
---|
27 | #include<qstringlist.h>
|
---|
28 | #include<qwidget.h>
|
---|
29 | #include<qmessagebox.h>
|
---|
30 | #include<qprocess.h>
|
---|
31 | #include<qkeysequence.h>
|
---|
32 | #include"im.h"
|
---|
33 | //#include"xmpp_message.h"
|
---|
34 | //#include"xmpp_client.h"
|
---|
35 | //#include"xmpp_types.h"
|
---|
36 | #include"varlist.h"
|
---|
37 | #include"psiiconset.h"
|
---|
38 |
|
---|
39 | #define PROXY_NONE 0
|
---|
40 | #define PROXY_HTTPS 1
|
---|
41 | #define PROXY_SOCKS4 2
|
---|
42 | #define PROXY_SOCKS5 3
|
---|
43 |
|
---|
44 | #define STATUS_OFFLINE 0
|
---|
45 | #define STATUS_ONLINE 1
|
---|
46 | #define STATUS_AWAY 2
|
---|
47 | #define STATUS_XA 3
|
---|
48 | #define STATUS_DND 4
|
---|
49 | #define STATUS_INVISIBLE 5
|
---|
50 | #define STATUS_CHAT 6
|
---|
51 |
|
---|
52 | #define STATUS_ASK 100
|
---|
53 | #define STATUS_NOAUTH 101
|
---|
54 | #define STATUS_ERROR 102
|
---|
55 |
|
---|
56 | // global
|
---|
57 | struct PsiGlobal
|
---|
58 | {
|
---|
59 | QString pathBase, pathHome, pathProfiles;
|
---|
60 | };
|
---|
61 |
|
---|
62 | extern QString activeProfile;
|
---|
63 |
|
---|
64 | //extern QStringList dtcp_hostList;
|
---|
65 | //extern int dtcp_port;
|
---|
66 | //extern QString dtcp_proxy;
|
---|
67 | //extern bool link_test;
|
---|
68 | extern bool use_gpg, no_gpg_agent;
|
---|
69 | extern uint psi_dialog_flags;
|
---|
70 |
|
---|
71 | // options stuff
|
---|
72 | enum { cOnline, cOffline, cAway, cDND, cProfileFore, cProfileBack, cGroupFore, cGroupBack, cListBack, cAnimFront, cAnimBack };
|
---|
73 | enum { fRoster, fMessage, fChat, fPopup };
|
---|
74 | enum { eMessage, eChat1, eChat2, eHeadline, eSystem, eOnline, eOffline, eSend, eIncomingFT, eFTComplete };
|
---|
75 | enum { dcClose, dcHour, dcDay, dcNever };
|
---|
76 |
|
---|
77 | struct Options
|
---|
78 | {
|
---|
79 | QColor color[11];
|
---|
80 | QString font[4];
|
---|
81 | int smallFontSize; // do not modify or save/load this value! it is calculated at run time!
|
---|
82 | int alertStyle;
|
---|
83 |
|
---|
84 | QString systemIconset;
|
---|
85 | QStringList emoticons;
|
---|
86 | QString defaultRosterIconset;
|
---|
87 | QMap<QString, QString> serviceRosterIconset;
|
---|
88 | QMap<QString, QString> customRosterIconset;
|
---|
89 | int chatOpacity, rosterOpacity;
|
---|
90 |
|
---|
91 | bool useleft, singleclick, hideMenubar, askOnline, askOffline, popupMsgs, popupChats, popupHeadlines, popupFiles, raise;
|
---|
92 | bool alwaysOnTop, noAwaySound, noAwayPopup, noUnlistedPopup, rosterAnim, autoVersion, autoVCardOnLogin, xmlConsoleOnLogin;
|
---|
93 | bool useDock, dockDCstyle, dockHideMW, dockToolMW, isWMDock;
|
---|
94 | bool smallChats, chatLineEdit, showJoins, useTabs, putTabsAtBottom, usePerTabCloseButton, autoRosterSize, autoRosterSizeGrowTop, autoResolveNicksOnAdd;
|
---|
95 |
|
---|
96 | bool autoCopy; // although this setting is ignored under linux,
|
---|
97 | // it is preserved in case user uses the same config file on different platforms
|
---|
98 |
|
---|
99 | bool oldSmallChats; //Filthy hack, see chat code.
|
---|
100 | int delChats, browser;
|
---|
101 |
|
---|
102 | // Avatars
|
---|
103 | bool avatarsEnabled, avatarsChatdlgEnabled;
|
---|
104 | int avatarsSize;
|
---|
105 |
|
---|
106 | int defaultAction;
|
---|
107 | int incomingAs;
|
---|
108 | VarList sp; //status message presets
|
---|
109 | QStringList recentStatus; //recent status messages
|
---|
110 |
|
---|
111 | int asAway, asXa, asOffline;
|
---|
112 | bool use_asAway, use_asXa, use_asOffline;
|
---|
113 | QString asMessage;
|
---|
114 | QString onevent[10];
|
---|
115 |
|
---|
116 | // Added by Kiko 020621: points to the directory where the trusted
|
---|
117 | // certificates used in validating the server's certificate are kept
|
---|
118 | QString trustCertStoreDir;
|
---|
119 |
|
---|
120 | QString player;
|
---|
121 | QString customBrowser, customMailer;
|
---|
122 |
|
---|
123 | bool ignoreHeadline, ignoreNonRoster, excludeGroupChatsFromIgnore, scrollTo, keepSizes, useEmoticons, alertOpenChats;
|
---|
124 | bool raiseChatWindow, showSubjects, showCounter, chatSays, chatSoftReturn, showGroupCounts;
|
---|
125 |
|
---|
126 | QSize sizeEventDlg, sizeChatDlg, sizeTabDlg;
|
---|
127 | bool jidComplete, grabUrls, noGCSound;
|
---|
128 |
|
---|
129 | QString pgp;
|
---|
130 |
|
---|
131 | struct ToolbarPrefs {
|
---|
132 | bool dirty;
|
---|
133 |
|
---|
134 | QString name;
|
---|
135 | bool on;
|
---|
136 | bool locked;
|
---|
137 | bool stretchable;
|
---|
138 | QStringList keys;
|
---|
139 |
|
---|
140 | Qt::Dock dock;
|
---|
141 | int index;
|
---|
142 | bool nl;
|
---|
143 | int extraOffset;
|
---|
144 | };
|
---|
145 | QMap< QString, QValueList<ToolbarPrefs> > toolbars;
|
---|
146 |
|
---|
147 | // groupchat highlighting/nick colouring
|
---|
148 | bool gcHighlighting, gcNickColoring;
|
---|
149 | QStringList gcHighlights, gcNickColors;
|
---|
150 |
|
---|
151 | bool clNewHeadings;
|
---|
152 | bool outlineHeadings;
|
---|
153 |
|
---|
154 | // passive popups
|
---|
155 | bool ppIsOn;
|
---|
156 | bool ppMessage, ppHeadline, ppChat, ppOnline, ppStatus, ppOffline, ppFile;
|
---|
157 | int ppJidClip, ppStatusClip, ppTextClip, ppHideTime;
|
---|
158 | QColor ppBorderColor;
|
---|
159 |
|
---|
160 | // Bouncing of the dock (Mac OS X)
|
---|
161 | typedef enum { NoBounce, BounceOnce, BounceForever } BounceDockSetting;
|
---|
162 | BounceDockSetting bounceDock;
|
---|
163 |
|
---|
164 | struct {
|
---|
165 | bool roster, options, profiles, services, accounts;
|
---|
166 | } lockdown;
|
---|
167 |
|
---|
168 | bool useTransportIconsForContacts;
|
---|
169 |
|
---|
170 | // roster sorting styles
|
---|
171 | typedef enum Roster_ContactSortStyle {
|
---|
172 | ContactSortStyle_Status = 0,
|
---|
173 | ContactSortStyle_Alpha
|
---|
174 | };
|
---|
175 | Roster_ContactSortStyle rosterContactSortStyle;
|
---|
176 |
|
---|
177 | typedef enum Roster_GroupSortStyle {
|
---|
178 | GroupSortStyle_Alpha = 0,
|
---|
179 | GroupSortStyle_Rank
|
---|
180 | };
|
---|
181 | Roster_GroupSortStyle rosterGroupSortStyle;
|
---|
182 |
|
---|
183 | typedef enum Roster_AccountSortStyle {
|
---|
184 | AccountSortStyle_Alpha = 0,
|
---|
185 | AccountSortStyle_Rank
|
---|
186 | };
|
---|
187 | Roster_AccountSortStyle rosterAccountSortStyle;
|
---|
188 |
|
---|
189 | bool showTips;
|
---|
190 | int tipNum;
|
---|
191 |
|
---|
192 | bool discoItems, discoInfo;
|
---|
193 |
|
---|
194 | bool autoAuth, notifyAuth;
|
---|
195 |
|
---|
196 | // event priority
|
---|
197 | enum { EventPriorityDontCare = -1 };
|
---|
198 | int eventPriorityHeadline;
|
---|
199 | int eventPriorityChat;
|
---|
200 | int eventPriorityMessage;
|
---|
201 | int eventPriorityAuth;
|
---|
202 | int eventPriorityFile;
|
---|
203 |
|
---|
204 | // Message events
|
---|
205 | bool messageEvents;
|
---|
206 |
|
---|
207 | int dtPort;
|
---|
208 | QString dtExternal;
|
---|
209 |
|
---|
210 | // Last used path remembering
|
---|
211 | QString lastPath;
|
---|
212 | QString lastSavePath;
|
---|
213 |
|
---|
214 | //background images
|
---|
215 | QString chatBgImage, rosterBgImage;
|
---|
216 |
|
---|
217 | // Global accelerators
|
---|
218 | QValueList<QKeySequence> globalAccels;
|
---|
219 | };
|
---|
220 |
|
---|
221 | // functions
|
---|
222 |
|
---|
223 | QString getResourcesDir();
|
---|
224 | QString getHomeDir();
|
---|
225 |
|
---|
226 | QString getHistoryDir();
|
---|
227 | QString getVCardDir();
|
---|
228 |
|
---|
229 | QString qstrlower(QString);
|
---|
230 | int qstrcasecmp(const QString &str1, const QString &str2);
|
---|
231 | int qstringlistmatch(QStringList &list, const QString &str);
|
---|
232 | QString qstringlistlookup(QStringList &list, int x);
|
---|
233 | QString CAP(const QString &str);
|
---|
234 |
|
---|
235 | QString status2txt(int status);
|
---|
236 |
|
---|
237 | QString eatptag(QString txt);
|
---|
238 | QString qstrquote(const QString &, int width=60, bool quoteEmpty=FALSE);
|
---|
239 | QString plain2rich(const QString &);
|
---|
240 | QString rich2plain(const QString &);
|
---|
241 | QString clipStatus(const QString &str, int width, int height);
|
---|
242 | QString expandEntities(const QString &in);
|
---|
243 | QString resolveEntities(const QString &);
|
---|
244 | QString linkify(const QString &);
|
---|
245 | QString emoticonify(const QString &in);
|
---|
246 |
|
---|
247 | QString encodePassword(const QString &, const QString &);
|
---|
248 | QString decodePassword(const QString &, const QString &);
|
---|
249 |
|
---|
250 | Icon category2icon(const QString &category, const QString &type);
|
---|
251 |
|
---|
252 | void bringToFront(QWidget *w, bool grabFocus = true);
|
---|
253 | QString jidEncode(const QString &jid);
|
---|
254 | QString jidDecode(const QString &jid);
|
---|
255 |
|
---|
256 | QString jidnick(const QString &jid, const QString &nick);
|
---|
257 |
|
---|
258 | int hexChar2int(char c);
|
---|
259 | char int2hexChar(int x);
|
---|
260 |
|
---|
261 | QString logencode(QString);
|
---|
262 | QString logdecode(const QString &);
|
---|
263 |
|
---|
264 | bool operator!=(const QMap<QString, QString> &, const QMap<QString, QString> &);
|
---|
265 | void qstringlistisort(QStringList &c);
|
---|
266 |
|
---|
267 | void openURL(const QString &);
|
---|
268 |
|
---|
269 | QString getOSName();
|
---|
270 | int getTZOffset();
|
---|
271 | QString getTZString();
|
---|
272 |
|
---|
273 | bool fileCopy(const QString &src, const QString &dest);
|
---|
274 |
|
---|
275 | #ifdef Q_WS_MAC
|
---|
276 | void stopDockTileBounce();
|
---|
277 | void bounceDockTile();
|
---|
278 | #endif
|
---|
279 |
|
---|
280 | #ifdef Q_WS_X11
|
---|
281 | void x11wmClass(Display *dsp, WId wid, QString resName);
|
---|
282 | #define X11WM_CLASS(x) x11wmClass(x11Display(), winId(), (x));
|
---|
283 | #else
|
---|
284 | #define X11WM_CLASS(x) /* dummy */
|
---|
285 | #endif
|
---|
286 |
|
---|
287 | void soundPlay(const QString &);
|
---|
288 |
|
---|
289 | XMPP::Status makeStatus(int, const QString &);
|
---|
290 | int makeSTATUS(const XMPP::Status &);
|
---|
291 |
|
---|
292 | void replaceWidget(QWidget *, QWidget *);
|
---|
293 | void closeDialogs(QWidget *);
|
---|
294 |
|
---|
295 | QString enc822jid(const QString &);
|
---|
296 | QString dec822jid(const QString &);
|
---|
297 |
|
---|
298 | extern
|
---|
299 | QString PROG_NAME, PROG_VERSION;
|
---|
300 |
|
---|
301 | extern char *pixdat_ft_back, *pixdat_ft_file, *pixdat_ft_folder;
|
---|
302 | extern int pixlen_ft_back, pixlen_ft_file, pixlen_ft_folder;
|
---|
303 |
|
---|
304 | extern
|
---|
305 | XMPP::Client *debug_jabber;
|
---|
306 |
|
---|
307 | extern
|
---|
308 | Options option;
|
---|
309 |
|
---|
310 | extern
|
---|
311 | PsiGlobal g;
|
---|
312 |
|
---|
313 | extern
|
---|
314 | PsiIconset *is;
|
---|
315 |
|
---|
316 | extern
|
---|
317 | bool useSound;
|
---|
318 |
|
---|
319 | // helper class for toolbars
|
---|
320 | class StretchWidget: public QWidget
|
---|
321 | {
|
---|
322 | public:
|
---|
323 | StretchWidget(QWidget *parent)
|
---|
324 | : QWidget( parent )
|
---|
325 | {
|
---|
326 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
---|
327 | }
|
---|
328 | };
|
---|
329 |
|
---|
330 | typedef QValueList<XMPP::Jid> JidList;
|
---|
331 | typedef QValueListIterator<XMPP::Jid> JidListIt;
|
---|
332 |
|
---|
333 |
|
---|
334 | #endif
|
---|