1 | /*
|
---|
2 | * profiles.cpp - deal with profiles
|
---|
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 | #include"profiles.h"
|
---|
22 | #include"common.h"
|
---|
23 | #include<qdir.h>
|
---|
24 | #include<qfileinfo.h>
|
---|
25 | #include<qdom.h>
|
---|
26 |
|
---|
27 | #include<qapplication.h>
|
---|
28 | #include"eventdlg.h"
|
---|
29 | #include"chatdlg.h"
|
---|
30 | #include"contactview.h"
|
---|
31 | #include"xmpp_xmlcommon.h"
|
---|
32 | #include"fancylabel.h"
|
---|
33 | #include"advwidget.h"
|
---|
34 |
|
---|
35 | using namespace XMPP;
|
---|
36 | using namespace XMLHelper;
|
---|
37 |
|
---|
38 | UserAccount::UserAccount()
|
---|
39 | {
|
---|
40 | reset();
|
---|
41 | }
|
---|
42 |
|
---|
43 | void UserAccount::reset()
|
---|
44 | {
|
---|
45 | name = "Default";
|
---|
46 | opt_enabled = TRUE;
|
---|
47 | opt_auto = FALSE;
|
---|
48 | opt_ssl = FALSE;
|
---|
49 | tog_offline = TRUE;
|
---|
50 | tog_away = TRUE;
|
---|
51 | tog_hidden = TRUE;
|
---|
52 | tog_agents = TRUE;
|
---|
53 | tog_self = FALSE;
|
---|
54 | jid = "";
|
---|
55 | pass = "";
|
---|
56 | opt_pass = FALSE;
|
---|
57 | port = 5222;
|
---|
58 | opt_host = FALSE;
|
---|
59 | host = "";
|
---|
60 | resource = "Psi";
|
---|
61 | priority = 5;
|
---|
62 | olr_string = "";
|
---|
63 | opt_keepAlive = TRUE;
|
---|
64 | opt_plain = FALSE;
|
---|
65 | opt_log = TRUE;
|
---|
66 | opt_reconn = FALSE;
|
---|
67 | opt_ignoreSSLWarnings = false;
|
---|
68 | pgpSecretKeyID = "";
|
---|
69 |
|
---|
70 | proxy_index = 0;
|
---|
71 | proxy_type = PROXY_NONE;
|
---|
72 | proxy_host = "";
|
---|
73 | proxy_port = 8080;
|
---|
74 | proxy_user = "";
|
---|
75 | proxy_pass = "";
|
---|
76 |
|
---|
77 | keybind.clear();
|
---|
78 |
|
---|
79 | roster.clear();
|
---|
80 | }
|
---|
81 |
|
---|
82 | UserAccount::~UserAccount()
|
---|
83 | {
|
---|
84 | }
|
---|
85 |
|
---|
86 | // FIXME: this should be a const function (as should other ::toXml functions)
|
---|
87 | QDomElement UserAccount::toXml(QDomDocument &doc, const QString &tagName)
|
---|
88 | {
|
---|
89 | QDomElement a = doc.createElement(tagName);
|
---|
90 |
|
---|
91 | setBoolAttribute(a, "enabled", opt_enabled);
|
---|
92 | setBoolAttribute(a, "auto", opt_auto);
|
---|
93 | setBoolAttribute(a, "ssl", opt_ssl);
|
---|
94 | setBoolAttribute(a, "showOffline", tog_offline);
|
---|
95 | setBoolAttribute(a, "showAway", tog_away);
|
---|
96 | setBoolAttribute(a, "showHidden", tog_hidden);
|
---|
97 | setBoolAttribute(a, "showAgents", tog_agents);
|
---|
98 | setBoolAttribute(a, "showSelf", tog_self);
|
---|
99 | setBoolAttribute(a, "keepAlive", opt_keepAlive);
|
---|
100 | setBoolAttribute(a, "plain", opt_plain);
|
---|
101 | setBoolAttribute(a, "log", opt_log);
|
---|
102 | setBoolAttribute(a, "reconn", opt_reconn);
|
---|
103 | setBoolAttribute(a, "ignoreSSLWarnings", opt_ignoreSSLWarnings);
|
---|
104 | //setBoolAttribute(a, "gpg", opt_gpg);
|
---|
105 |
|
---|
106 | //QString jid = user + '@' + vhost;
|
---|
107 | a.appendChild(textTag(doc, "name", name));
|
---|
108 | a.appendChild(textTag(doc, "jid", jid));
|
---|
109 | if(opt_pass)
|
---|
110 | a.appendChild(textTag(doc, "password", encodePassword(pass, jid) ));
|
---|
111 | a.appendChild(textTag(doc, "useHost", opt_host));
|
---|
112 | a.appendChild(textTag(doc, "host", host));
|
---|
113 | a.appendChild(textTag(doc, "port", QString::number(port)));
|
---|
114 | a.appendChild(textTag(doc, "resource", resource));
|
---|
115 | a.appendChild(textTag(doc, "priority", QString::number(priority)));
|
---|
116 | a.appendChild(textTag(doc, "OLR", olr_string));
|
---|
117 | a.appendChild(textTag(doc, "pgpSecretKeyID", pgpSecretKeyID));
|
---|
118 |
|
---|
119 | QDomElement r = doc.createElement("roster");
|
---|
120 | a.appendChild(r);
|
---|
121 | Roster::ConstIterator rit = roster.begin();
|
---|
122 | for ( ; rit != roster.end(); ++rit) {
|
---|
123 | const RosterItem &i = *rit;
|
---|
124 | QDomElement tag = i.toXml(&doc);
|
---|
125 | r.appendChild(tag);
|
---|
126 | }
|
---|
127 |
|
---|
128 | // now we check for redundant entries
|
---|
129 | QStringList groupList, removeList;
|
---|
130 | groupList << "/\\/" + name + "\\/\\"; // account name is a very 'special' group
|
---|
131 |
|
---|
132 | // special groups that should also have their state remembered
|
---|
133 | groupList << ContactProfile::tr("General");
|
---|
134 | groupList << ContactProfile::tr("Agents/Transports");
|
---|
135 |
|
---|
136 | // first, add all groups' names to groupList
|
---|
137 | rit = roster.begin();
|
---|
138 | for ( ; rit != roster.end(); ++rit) {
|
---|
139 | const RosterItem &i = *rit;
|
---|
140 | groupList += i.groups();
|
---|
141 | }
|
---|
142 |
|
---|
143 | // now, check if there's groupState name entry in groupList
|
---|
144 | QMap<QString, GroupData>::Iterator git = groupState.begin();
|
---|
145 | for ( ; git != groupState.end(); ++git) {
|
---|
146 | bool found = false;
|
---|
147 |
|
---|
148 | QStringList::Iterator it = groupList.begin();
|
---|
149 | for ( ; it != groupList.end(); ++it)
|
---|
150 | if ( git.key() == *it ) {
|
---|
151 | found = true;
|
---|
152 | break;
|
---|
153 | }
|
---|
154 |
|
---|
155 | if ( !found )
|
---|
156 | removeList << git.key();
|
---|
157 | }
|
---|
158 |
|
---|
159 | // remove redundant groups
|
---|
160 | QStringList::Iterator it = removeList.begin();
|
---|
161 | for ( ; it != removeList.end(); ++it)
|
---|
162 | groupState.remove( *it );
|
---|
163 |
|
---|
164 | // and finally, save the data
|
---|
165 | QDomElement gs = doc.createElement("groupState");
|
---|
166 | a.appendChild(gs);
|
---|
167 | git = groupState.begin();
|
---|
168 | for ( ; git != groupState.end(); ++git) {
|
---|
169 | //if ( !git.data().open || git.data().rank ) { // don't save unnecessary entries (the default is 'true' to open, and '0' to rank)
|
---|
170 | QDomElement group = doc.createElement("group");
|
---|
171 | group.setAttribute("name", git.key());
|
---|
172 | group.setAttribute("open", git.data().open ? "true" : "false");
|
---|
173 | group.setAttribute("rank", QString::number(git.data().rank));
|
---|
174 | gs.appendChild(group);
|
---|
175 | //}
|
---|
176 | }
|
---|
177 |
|
---|
178 | a.appendChild(textTag(doc, "proxyindex", QString::number(proxy_index)));
|
---|
179 | //a.appendChild(textTag(doc, "proxytype", QString::number(proxy_type)));
|
---|
180 | //a.appendChild(textTag(doc, "proxyhost", proxy_host));
|
---|
181 | //a.appendChild(textTag(doc, "proxyport", QString::number(proxy_port)));
|
---|
182 | //a.appendChild(textTag(doc, "proxyuser", proxy_user));
|
---|
183 | //a.appendChild(textTag(doc, "proxypass", encodePassword(proxy_pass, jid)));
|
---|
184 |
|
---|
185 | a.appendChild(keybind.toXml(doc, "pgpkeybindings"));
|
---|
186 | a.appendChild(textTag(doc, "dtProxy", dtProxy.full()));
|
---|
187 |
|
---|
188 | return a;
|
---|
189 | }
|
---|
190 |
|
---|
191 | void UserAccount::fromXml(const QDomElement &a)
|
---|
192 | {
|
---|
193 | reset();
|
---|
194 |
|
---|
195 | bool found;
|
---|
196 |
|
---|
197 | readEntry(a, "name", &name);
|
---|
198 | readBoolAttribute(a, "enabled", &opt_enabled);
|
---|
199 | readBoolAttribute(a, "auto", &opt_auto);
|
---|
200 | readBoolAttribute(a, "ssl", &opt_ssl);
|
---|
201 | readBoolAttribute(a, "showOffline", &tog_offline);
|
---|
202 | readBoolAttribute(a, "showAway", &tog_away);
|
---|
203 | readBoolAttribute(a, "showHidden", &tog_hidden);
|
---|
204 | readBoolAttribute(a, "showAgents", &tog_agents);
|
---|
205 | readBoolAttribute(a, "showSelf", &tog_self);
|
---|
206 | readBoolAttribute(a, "keepAlive", &opt_keepAlive);
|
---|
207 | readBoolAttribute(a, "plain", &opt_plain);
|
---|
208 | readBoolAttribute(a, "log", &opt_log);
|
---|
209 | readBoolAttribute(a, "reconn", &opt_reconn);
|
---|
210 | readBoolAttribute(a, "ignoreSSLWarnings", &opt_ignoreSSLWarnings);
|
---|
211 | //readBoolAttribute(a, "gpg", &opt_gpg);
|
---|
212 |
|
---|
213 | readEntry(a, "host", &host);
|
---|
214 | readNumEntry(a, "port", &port);
|
---|
215 |
|
---|
216 | // 0.8.6 and >= 0.9
|
---|
217 | QDomElement j = findSubTag(a, "jid", &found);
|
---|
218 | if(found) {
|
---|
219 | readBoolAttribute(j, "manual", &opt_host);
|
---|
220 | jid = tagContent(j);
|
---|
221 | }
|
---|
222 | // 0.8.7
|
---|
223 | else {
|
---|
224 | QString user, vhost;
|
---|
225 | readEntry(a, "username", &user);
|
---|
226 | QDomElement j = findSubTag(a, "vhost", &found);
|
---|
227 | if(found) {
|
---|
228 | readBoolAttribute(j, "manual", &opt_host);
|
---|
229 | vhost = tagContent(j);
|
---|
230 | }
|
---|
231 | else {
|
---|
232 | opt_host = false;
|
---|
233 | vhost = host;
|
---|
234 | host = "";
|
---|
235 | port = 0;
|
---|
236 | }
|
---|
237 | jid = user + '@' + vhost;
|
---|
238 | }
|
---|
239 |
|
---|
240 | readBoolEntry(a, "useHost", &opt_host);
|
---|
241 |
|
---|
242 | // read password (we must do this after reading the jid, to decode properly)
|
---|
243 | readEntry(a, "password", &pass);
|
---|
244 | if(!pass.isEmpty()) {
|
---|
245 | opt_pass = TRUE;
|
---|
246 | pass = decodePassword(pass, jid);
|
---|
247 | }
|
---|
248 |
|
---|
249 | readEntry(a, "resource", &resource);
|
---|
250 | readNumEntry(a, "priority", &priority);
|
---|
251 | readEntry(a, "OLR", &olr_string);
|
---|
252 | readEntry(a, "pgpSecretKeyID", &pgpSecretKeyID);
|
---|
253 |
|
---|
254 | QDomElement r = findSubTag(a, "roster", &found);
|
---|
255 | if(found) {
|
---|
256 | for(QDomNode n = r.firstChild(); !n.isNull(); n = n.nextSibling()) {
|
---|
257 | QDomElement i = n.toElement();
|
---|
258 | if(i.isNull())
|
---|
259 | continue;
|
---|
260 |
|
---|
261 | if(i.tagName() == "item") {
|
---|
262 | RosterItem ri;
|
---|
263 | if(!ri.fromXml(i))
|
---|
264 | continue;
|
---|
265 | roster += ri;
|
---|
266 | }
|
---|
267 | }
|
---|
268 | }
|
---|
269 |
|
---|
270 | groupState.clear();
|
---|
271 | QDomElement gs = findSubTag(a, "groupState", &found);
|
---|
272 | if (found) {
|
---|
273 | for (QDomNode n = gs.firstChild(); !n.isNull(); n = n.nextSibling()) {
|
---|
274 | QDomElement i = n.toElement();
|
---|
275 | if (i.isNull())
|
---|
276 | continue;
|
---|
277 |
|
---|
278 | if (i.tagName() == "group") {
|
---|
279 | GroupData gd;
|
---|
280 | gd.open = i.attribute("open") == "true";
|
---|
281 | gd.rank = i.attribute("rank").toInt();
|
---|
282 | groupState.insert(i.attribute("name"), gd);
|
---|
283 | }
|
---|
284 | }
|
---|
285 | }
|
---|
286 |
|
---|
287 | readNumEntry(a, "proxyindex", &proxy_index);
|
---|
288 | readNumEntry(a, "proxytype", &proxy_type);
|
---|
289 | readEntry(a, "proxyhost", &proxy_host);
|
---|
290 | readNumEntry(a, "proxyport", &proxy_port);
|
---|
291 | readEntry(a, "proxyuser", &proxy_user);
|
---|
292 | readEntry(a, "proxypass", &proxy_pass);
|
---|
293 | if(!proxy_pass.isEmpty())
|
---|
294 | proxy_pass = decodePassword(proxy_pass, jid);
|
---|
295 |
|
---|
296 | r = findSubTag(a, "pgpkeybindings", &found);
|
---|
297 | if(found)
|
---|
298 | keybind.fromXml(r);
|
---|
299 |
|
---|
300 | QString str;
|
---|
301 | readEntry(a, "dtProxy", &str);
|
---|
302 | dtProxy = str;
|
---|
303 | }
|
---|
304 |
|
---|
305 | UserProfile::UserProfile()
|
---|
306 | {
|
---|
307 | reset();
|
---|
308 | }
|
---|
309 |
|
---|
310 | void UserProfile::reset()
|
---|
311 | {
|
---|
312 | bool nix, win, mac, os2;
|
---|
313 | nix = win = mac = os2 = FALSE;
|
---|
314 |
|
---|
315 | #ifdef Q_WS_X11
|
---|
316 | nix = TRUE;
|
---|
317 | #endif
|
---|
318 | #ifdef Q_WS_WIN
|
---|
319 | win = TRUE;
|
---|
320 | #endif
|
---|
321 | #ifdef Q_WS_MAC
|
---|
322 | mac = TRUE;
|
---|
323 | #endif
|
---|
324 | #ifdef Q_WS_PM
|
---|
325 | os2 = TRUE;
|
---|
326 | #endif
|
---|
327 |
|
---|
328 | progver = PROG_VERSION;
|
---|
329 |
|
---|
330 | // global
|
---|
331 | mwgeom.setRect(64, 64, 150, 360);
|
---|
332 | lastStatusString = "";
|
---|
333 | useSound = TRUE;
|
---|
334 | proxyList.clear();
|
---|
335 | acc.clear();
|
---|
336 |
|
---|
337 | // prefs
|
---|
338 | prefs.useleft = FALSE;
|
---|
339 | prefs.singleclick = FALSE;
|
---|
340 | prefs.hideMenubar = TRUE;
|
---|
341 | prefs.defaultAction = 1;
|
---|
342 | prefs.delChats = dcHour;
|
---|
343 | prefs.showJoins = TRUE;
|
---|
344 | prefs.browser = 0;
|
---|
345 | prefs.customBrowser = "";
|
---|
346 | prefs.customMailer = "";
|
---|
347 | prefs.alwaysOnTop = FALSE;
|
---|
348 | prefs.keepSizes = TRUE;
|
---|
349 | prefs.ignoreHeadline = FALSE;
|
---|
350 | prefs.ignoreNonRoster = FALSE;
|
---|
351 | prefs.excludeGroupChatsFromIgnore = TRUE;
|
---|
352 | prefs.useDock = win ? TRUE: FALSE;
|
---|
353 | prefs.dockDCstyle = win ? TRUE: FALSE;
|
---|
354 | prefs.dockHideMW = FALSE;
|
---|
355 | prefs.dockToolMW = FALSE;
|
---|
356 | prefs.isWMDock = false;
|
---|
357 | prefs.alertStyle = 2;
|
---|
358 | prefs.popupMsgs = FALSE;
|
---|
359 | prefs.popupChats = FALSE;
|
---|
360 | prefs.popupHeadlines = FALSE;
|
---|
361 | prefs.popupFiles = FALSE;
|
---|
362 | prefs.noAwayPopup = FALSE;
|
---|
363 | prefs.noUnlistedPopup = false;
|
---|
364 | prefs.raise = FALSE;
|
---|
365 | prefs.incomingAs = 0;
|
---|
366 | prefs.askOnline = FALSE;
|
---|
367 | prefs.askOffline = FALSE;
|
---|
368 | prefs.rosterAnim = TRUE;
|
---|
369 | prefs.autoVersion = false;
|
---|
370 | prefs.autoVCardOnLogin = true;
|
---|
371 | prefs.xmlConsoleOnLogin = false;
|
---|
372 | prefs.asAway = 10;
|
---|
373 | prefs.asXa = 30;
|
---|
374 | prefs.asOffline = 0;
|
---|
375 | prefs.use_asAway = TRUE;
|
---|
376 | prefs.use_asXa = TRUE;
|
---|
377 | prefs.use_asOffline = FALSE;
|
---|
378 | prefs.asMessage = QObject::tr("Auto Status (idle)");
|
---|
379 | prefs.scrollTo = TRUE;
|
---|
380 | prefs.useEmoticons = false;
|
---|
381 | prefs.alertOpenChats = false;
|
---|
382 | prefs.raiseChatWindow = false;
|
---|
383 | prefs.showSubjects = true;
|
---|
384 | prefs.showCounter = false;
|
---|
385 | prefs.chatSays = false;
|
---|
386 | prefs.chatSoftReturn = true;
|
---|
387 | prefs.showGroupCounts = true;
|
---|
388 | prefs.smallChats = false;
|
---|
389 | prefs.chatLineEdit = true;
|
---|
390 | prefs.useTabs = false;
|
---|
391 | prefs.usePerTabCloseButton = true;
|
---|
392 | prefs.putTabsAtBottom = false;
|
---|
393 | prefs.autoRosterSize = false;
|
---|
394 | prefs.autoRosterSizeGrowTop = false;
|
---|
395 | prefs.autoResolveNicksOnAdd = false;
|
---|
396 | prefs.chatBgImage = "";
|
---|
397 | prefs.rosterBgImage = "";
|
---|
398 | prefs.autoCopy = false;
|
---|
399 |
|
---|
400 | prefs.sp.clear();
|
---|
401 | prefs.sp.set(QObject::tr("Away from desk"), QObject::tr("I am away from my desk. Leave a message."));
|
---|
402 | prefs.sp.set(QObject::tr("Showering"), QObject::tr("I'm in the shower. You'll have to wait for me to get out."));
|
---|
403 | prefs.sp.set(QObject::tr("Eating"), QObject::tr("Out eating. Mmmm.. food."));
|
---|
404 | prefs.sp.set(QObject::tr("Sleep"), QObject::tr("Sleep is good. Zzzzz"));
|
---|
405 | prefs.sp.set(QObject::tr("Work"), QObject::tr("Can't chat. Gotta work."));
|
---|
406 | prefs.sp.set(QObject::tr("Air"), QObject::tr("Stepping out to get some fresh air."));
|
---|
407 | prefs.sp.set(QObject::tr("Movie"), QObject::tr("Out to a movie. Is that OK with you?"));
|
---|
408 | prefs.sp.set(QObject::tr("Secret"), QObject::tr("I'm not available right now and that's all you need to know."));
|
---|
409 | prefs.sp.set(QObject::tr("Out for the night"), QObject::tr("Out for the night."));
|
---|
410 | prefs.sp.set(QObject::tr("Greece"), QObject::tr("I have gone to a far away place. I will be back someday!"));
|
---|
411 | prefs.recentStatus.clear();
|
---|
412 |
|
---|
413 | prefs.color[cOnline] = QColor("#000000");
|
---|
414 | prefs.color[cListBack] = QColor("#FFFFFF");
|
---|
415 | prefs.color[cAway] = QColor("#004BB4");
|
---|
416 | prefs.color[cDND] = QColor("#7E0000");
|
---|
417 | prefs.color[cOffline] = QColor("#646464");
|
---|
418 | prefs.color[cProfileFore] = QColor("#FFFFFF");
|
---|
419 | prefs.color[cProfileBack] = QColor("#969696");
|
---|
420 | prefs.color[cGroupFore] = QColor("#5A5A5A");
|
---|
421 | prefs.color[cGroupBack] = QColor("#F0F0F0");
|
---|
422 | prefs.color[cAnimFront] = QColor("#000000");
|
---|
423 | prefs.color[cAnimBack] = QColor("#969696");
|
---|
424 |
|
---|
425 | prefs.font[fRoster] = QApplication::font().toString();
|
---|
426 | prefs.font[fMessage] = QApplication::font().toString();
|
---|
427 | prefs.font[fChat] = QApplication::font().toString();
|
---|
428 | {
|
---|
429 | QFont font = QApplication::font();
|
---|
430 | font.setPointSize( font.pointSize() - 2 );
|
---|
431 | prefs.font[fPopup] = font.toString();
|
---|
432 | }
|
---|
433 |
|
---|
434 | // calculate the small font size
|
---|
435 | const int minimumFontSize = 7;
|
---|
436 | prefs.smallFontSize = qApp->font().pointSize();
|
---|
437 | prefs.smallFontSize -= 2;
|
---|
438 | if ( prefs.smallFontSize < minimumFontSize )
|
---|
439 | prefs.smallFontSize = minimumFontSize;
|
---|
440 | FancyLabel::setSmallFontSize( prefs.smallFontSize );
|
---|
441 |
|
---|
442 | prefs.clNewHeadings = false;
|
---|
443 | prefs.chatOpacity = 100;
|
---|
444 | prefs.rosterOpacity = 95;
|
---|
445 | prefs.outlineHeadings = false;
|
---|
446 |
|
---|
447 | prefs.player = "play";
|
---|
448 | prefs.noAwaySound = FALSE;
|
---|
449 |
|
---|
450 | prefs.onevent[eMessage] = g.pathBase + "/sound/chat2.wav";
|
---|
451 | prefs.onevent[eChat1] = g.pathBase + "/sound/chat1.wav";
|
---|
452 | prefs.onevent[eChat2] = g.pathBase + "/sound/chat2.wav";
|
---|
453 | prefs.onevent[eSystem] = g.pathBase + "/sound/chat2.wav";
|
---|
454 | prefs.onevent[eHeadline] = g.pathBase + "/sound/chat2.wav";
|
---|
455 | prefs.onevent[eOnline] = g.pathBase + "/sound/online.wav";
|
---|
456 | prefs.onevent[eOffline] = g.pathBase + "/sound/offline.wav";
|
---|
457 | prefs.onevent[eSend] = g.pathBase + "/sound/send.wav";
|
---|
458 | prefs.onevent[eIncomingFT] = g.pathBase + "/sound/ft_incoming.wav";
|
---|
459 | prefs.onevent[eFTComplete] = g.pathBase + "/sound/ft_complete.wav";
|
---|
460 |
|
---|
461 | // Added by Kiko 020621: sets up the default certificate store
|
---|
462 | prefs.trustCertStoreDir = g.pathBase + "/certs";
|
---|
463 |
|
---|
464 | prefs.sizeEventDlg = EventDlg::defaultSize();
|
---|
465 | prefs.sizeChatDlg = ChatDlg::defaultSize();
|
---|
466 | prefs.sizeTabDlg = ChatDlg::defaultSize(); //TODO: no!
|
---|
467 |
|
---|
468 | prefs.jidComplete = true;
|
---|
469 | prefs.grabUrls = false;
|
---|
470 | prefs.noGCSound = true;
|
---|
471 |
|
---|
472 | prefs.pgp = "";
|
---|
473 |
|
---|
474 | // toolbars
|
---|
475 | prefs.toolbars.clear();
|
---|
476 |
|
---|
477 | Options::ToolbarPrefs tbDef;
|
---|
478 | tbDef.name = QString::null;
|
---|
479 | tbDef.on = false;
|
---|
480 | tbDef.locked = false;
|
---|
481 | tbDef.stretchable = false;
|
---|
482 | tbDef.keys.clear();
|
---|
483 |
|
---|
484 | tbDef.dock = Qt::DockTop;
|
---|
485 | tbDef.nl = true;
|
---|
486 | tbDef.extraOffset = 0;
|
---|
487 |
|
---|
488 | tbDef.dirty = true;
|
---|
489 |
|
---|
490 | {
|
---|
491 | Options::ToolbarPrefs tb[3];
|
---|
492 | uint i;
|
---|
493 | for (i = 0; i < sizeof(tb)/sizeof(Options::ToolbarPrefs); i++) {
|
---|
494 | tb[i] = tbDef;
|
---|
495 | tb[i].index = i + 1;
|
---|
496 | }
|
---|
497 |
|
---|
498 | bool defaultEnableToolbars;
|
---|
499 | #ifdef Q_WS_MAC
|
---|
500 | defaultEnableToolbars = false;
|
---|
501 | #else
|
---|
502 | defaultEnableToolbars = true;
|
---|
503 | #endif
|
---|
504 |
|
---|
505 | // Imitate old Psi button layout by default
|
---|
506 | tb[0].name = QObject::tr("Buttons");
|
---|
507 | tb[0].on = defaultEnableToolbars;
|
---|
508 | tb[0].locked = true;
|
---|
509 | tb[0].stretchable = true;
|
---|
510 | tb[0].keys << "button_options" << "button_status";
|
---|
511 | tb[0].dock = Qt::DockBottom;
|
---|
512 |
|
---|
513 | tb[1].name = QObject::tr("Show contacts");
|
---|
514 | tb[1].on = defaultEnableToolbars;
|
---|
515 | tb[1].locked = true;
|
---|
516 | tb[1].keys << "show_offline" << "show_away" << "show_agents" << "show_self";
|
---|
517 |
|
---|
518 | tb[2].name = QObject::tr("Event notifier");
|
---|
519 | tb[2].on = false;
|
---|
520 | tb[2].locked = true;
|
---|
521 | tb[2].stretchable = true;
|
---|
522 | tb[2].keys << "event_notifier";
|
---|
523 | tb[2].dock = Qt::DockBottom;
|
---|
524 | tb[2].index = 0;
|
---|
525 |
|
---|
526 | for ( i = 0; i < sizeof(tb)/sizeof(Options::ToolbarPrefs); i++ )
|
---|
527 | prefs.toolbars["mainWin"].append( tb[i] );
|
---|
528 | }
|
---|
529 |
|
---|
530 | // groupchat
|
---|
531 | prefs.gcHighlighting = true;
|
---|
532 | prefs.gcHighlights.clear();
|
---|
533 |
|
---|
534 | prefs.gcNickColoring = true;
|
---|
535 | prefs.gcNickColors.clear();
|
---|
536 |
|
---|
537 | prefs.gcNickColors << "Blue";
|
---|
538 | prefs.gcNickColors << "Green";
|
---|
539 | prefs.gcNickColors << "Orange";
|
---|
540 | prefs.gcNickColors << "Purple";
|
---|
541 | prefs.gcNickColors << "Red";
|
---|
542 |
|
---|
543 | // popups
|
---|
544 | prefs.ppIsOn = false;
|
---|
545 | prefs.ppOnline = true;
|
---|
546 | prefs.ppOffline = true;
|
---|
547 | prefs.ppStatus = false;
|
---|
548 | prefs.ppMessage = true;
|
---|
549 | prefs.ppChat = true;
|
---|
550 | prefs.ppHeadline = true;
|
---|
551 | prefs.ppFile = true;
|
---|
552 | prefs.ppJidClip = 25;
|
---|
553 | prefs.ppStatusClip = -1;
|
---|
554 | prefs.ppTextClip = 300;
|
---|
555 | prefs.ppHideTime = 10000; // 10 sec
|
---|
556 | prefs.ppBorderColor = QColor (0x52, 0x97, 0xF9);
|
---|
557 |
|
---|
558 | // Bouncing of the dock (Mac OS X)
|
---|
559 | prefs.bounceDock = Options::BounceForever;
|
---|
560 |
|
---|
561 | // lockdown
|
---|
562 | prefs.lockdown.roster = false;
|
---|
563 | prefs.lockdown.options = false;
|
---|
564 | prefs.lockdown.profiles = false;
|
---|
565 | prefs.lockdown.services = false;
|
---|
566 | prefs.lockdown.accounts = false;
|
---|
567 |
|
---|
568 | prefs.useTransportIconsForContacts = false;
|
---|
569 |
|
---|
570 | // iconsets
|
---|
571 | prefs.systemIconset = "default";
|
---|
572 | prefs.emoticons = "default";
|
---|
573 | prefs.defaultRosterIconset = "default";
|
---|
574 |
|
---|
575 | prefs.serviceRosterIconset.clear();
|
---|
576 | prefs.serviceRosterIconset["transport"] = "crystal-service.jisp";
|
---|
577 | prefs.serviceRosterIconset["aim"] = "crystal-aim.jisp";
|
---|
578 | prefs.serviceRosterIconset["gadugadu"] = "crystal-gadugadu.jisp";
|
---|
579 | prefs.serviceRosterIconset["icq"] = "crystal-icq.jisp";
|
---|
580 | prefs.serviceRosterIconset["msn"] = "crystal-msn.jisp";
|
---|
581 | prefs.serviceRosterIconset["yahoo"] = "crystal-yahoo.jisp";
|
---|
582 | prefs.serviceRosterIconset["sms"] = "crystal-sms.jisp";
|
---|
583 |
|
---|
584 | prefs.customRosterIconset.clear();
|
---|
585 |
|
---|
586 | // roster sorting
|
---|
587 | prefs.rosterContactSortStyle = Options::ContactSortStyle_Status;
|
---|
588 | prefs.rosterGroupSortStyle = Options::GroupSortStyle_Alpha;
|
---|
589 | prefs.rosterAccountSortStyle = Options::AccountSortStyle_Alpha;
|
---|
590 |
|
---|
591 | // tip of the day
|
---|
592 | prefs.showTips = true;
|
---|
593 | prefs.tipNum = 0;
|
---|
594 |
|
---|
595 | // disco dialog
|
---|
596 | prefs.discoItems = true;
|
---|
597 | prefs.discoInfo = true;
|
---|
598 |
|
---|
599 | // auto-auth
|
---|
600 | prefs.autoAuth = false;
|
---|
601 |
|
---|
602 | // Notify authorization
|
---|
603 | prefs.notifyAuth = true;
|
---|
604 |
|
---|
605 | // message events
|
---|
606 | prefs.messageEvents = true;
|
---|
607 |
|
---|
608 | // event priority
|
---|
609 | prefs.eventPriorityHeadline = 0;
|
---|
610 | prefs.eventPriorityChat = 1;
|
---|
611 | prefs.eventPriorityMessage = 1;
|
---|
612 | prefs.eventPriorityAuth = 2;
|
---|
613 | prefs.eventPriorityFile = 3;
|
---|
614 |
|
---|
615 | // Last used path remembering
|
---|
616 | prefs.lastPath = QDir::homeDirPath();
|
---|
617 | prefs.lastSavePath = QDir::homeDirPath();
|
---|
618 |
|
---|
619 | // data transfer
|
---|
620 | prefs.dtPort = 8010;
|
---|
621 | prefs.dtExternal = "";
|
---|
622 |
|
---|
623 | // Avatars
|
---|
624 | prefs.avatarsEnabled = true;
|
---|
625 | prefs.avatarsChatdlgEnabled = true;
|
---|
626 | prefs.avatarsSize = 48;
|
---|
627 |
|
---|
628 | // global accelerators
|
---|
629 | prefs.globalAccels.clear();
|
---|
630 | prefs.globalAccels.append(QKeySequence()); // process next event
|
---|
631 | prefs.globalAccels.append(QKeySequence()); // show/hide roster
|
---|
632 |
|
---|
633 | // advanced widget
|
---|
634 | GAdvancedWidget::setStickEnabled( false ); //until this is bugless
|
---|
635 | GAdvancedWidget::setStickToWindows( false ); //again
|
---|
636 | GAdvancedWidget::setStickAt( 5 );
|
---|
637 | }
|
---|
638 |
|
---|
639 | static Options::ToolbarPrefs loadToolbarData( const QDomElement &e )
|
---|
640 | {
|
---|
641 | QDomElement tb_prefs = e;
|
---|
642 | Options::ToolbarPrefs tb;
|
---|
643 |
|
---|
644 | readEntry(tb_prefs, "name", &tb.name);
|
---|
645 | readBoolEntry(tb_prefs, "on", &tb.on);
|
---|
646 | readBoolEntry(tb_prefs, "locked", &tb.locked);
|
---|
647 | readBoolEntry(tb_prefs, "stretchable", &tb.stretchable);
|
---|
648 | xmlToStringList(tb_prefs, "keys", &tb.keys);
|
---|
649 |
|
---|
650 | bool found3 = false;
|
---|
651 | QDomElement tb_position = findSubTag(tb_prefs, "position", &found3);
|
---|
652 | if (found3)
|
---|
653 | {
|
---|
654 | QString dockStr;
|
---|
655 | Qt::Dock dock = Qt::DockTop;
|
---|
656 | readEntry(tb_position, "dock", &dockStr);
|
---|
657 | if (dockStr == "DockTop")
|
---|
658 | dock = Qt::DockTop;
|
---|
659 | else if (dockStr == "DockBottom")
|
---|
660 | dock = Qt::DockBottom;
|
---|
661 | else if (dockStr == "DockLeft")
|
---|
662 | dock = Qt::DockLeft;
|
---|
663 | else if (dockStr == "DockRight")
|
---|
664 | dock = Qt::DockRight;
|
---|
665 | else if (dockStr == "DockMinimized")
|
---|
666 | dock = Qt::DockMinimized;
|
---|
667 | else if (dockStr == "DockTornOff")
|
---|
668 | dock = Qt::DockTornOff;
|
---|
669 | else if (dockStr == "DockUnmanaged")
|
---|
670 | dock = Qt::DockUnmanaged;
|
---|
671 |
|
---|
672 | tb.dock = dock;
|
---|
673 |
|
---|
674 | readNumEntry(tb_position, "index", &tb.index);
|
---|
675 | readBoolEntry(tb_position, "nl", &tb.nl);
|
---|
676 | readNumEntry(tb_position, "extraOffset", &tb.extraOffset);
|
---|
677 | }
|
---|
678 |
|
---|
679 | return tb;
|
---|
680 | }
|
---|
681 |
|
---|
682 | bool UserProfile::toFile(const QString &fname)
|
---|
683 | {
|
---|
684 | QDomDocument doc;
|
---|
685 |
|
---|
686 | QDomElement base = doc.createElement("psiconf");
|
---|
687 | base.setAttribute("version", "1.0");
|
---|
688 | doc.appendChild(base);
|
---|
689 |
|
---|
690 | base.appendChild(textTag(doc, "progver", PROG_VERSION));
|
---|
691 | base.appendChild(textTag(doc, "geom", mwgeom));
|
---|
692 | base.appendChild(stringListToXml(doc, "recentGCList", recentGCList));
|
---|
693 | base.appendChild(stringListToXml(doc, "recentBrowseList", recentBrowseList));
|
---|
694 | base.appendChild(textTag(doc, "lastStatusString", lastStatusString));
|
---|
695 | base.appendChild(textTag(doc, "useSound", useSound));
|
---|
696 |
|
---|
697 | QDomElement accs = doc.createElement("accounts");
|
---|
698 | base.appendChild(accs);
|
---|
699 | for(UserAccountList::Iterator ai = acc.begin(); ai != acc.end(); ++ai)
|
---|
700 | accs.appendChild((*ai).toXml(doc, "account"));
|
---|
701 |
|
---|
702 | QDomElement prox = doc.createElement("proxies");
|
---|
703 | base.appendChild(prox);
|
---|
704 | for(ProxyItemList::Iterator pi = proxyList.begin(); pi != proxyList.end(); ++pi) {
|
---|
705 | const ProxyItem &p = *pi;
|
---|
706 | QDomElement i = doc.createElement("proxy");
|
---|
707 | i.appendChild(textTag(doc, "name", p.name));
|
---|
708 | i.appendChild(textTag(doc, "type", p.type));
|
---|
709 | i.appendChild(p.settings.toXml(&doc));
|
---|
710 | prox.appendChild(i);
|
---|
711 | }
|
---|
712 |
|
---|
713 | QDomElement p = doc.createElement("preferences");
|
---|
714 | base.appendChild(p);
|
---|
715 |
|
---|
716 | {
|
---|
717 | QDomElement p_general = doc.createElement("general");
|
---|
718 | p.appendChild(p_general);
|
---|
719 |
|
---|
720 | {
|
---|
721 | QDomElement p_roster = doc.createElement("roster");
|
---|
722 | p_general.appendChild(p_roster);
|
---|
723 |
|
---|
724 | p_roster.appendChild(textTag(doc, "useleft", prefs.useleft));
|
---|
725 | p_roster.appendChild(textTag(doc, "rosterBgImage", prefs.rosterBgImage));
|
---|
726 | p_roster.appendChild(textTag(doc, "singleclick", prefs.singleclick));
|
---|
727 | p_roster.appendChild(textTag(doc, "hideMenubar", prefs.hideMenubar));
|
---|
728 | p_roster.appendChild(textTag(doc, "defaultAction", prefs.defaultAction));
|
---|
729 | p_roster.appendChild(textTag(doc, "useTransportIconsForContacts", prefs.useTransportIconsForContacts));
|
---|
730 |
|
---|
731 | {
|
---|
732 | QDomElement sorting = doc.createElement("sortStyle");
|
---|
733 | p_roster.appendChild(sorting);
|
---|
734 |
|
---|
735 | QString name = "status";
|
---|
736 | if ( prefs.rosterContactSortStyle == Options::ContactSortStyle_Alpha )
|
---|
737 | name = "alpha";
|
---|
738 | sorting.appendChild(textTag(doc, "contact", name));
|
---|
739 |
|
---|
740 | name = "alpha";
|
---|
741 | if ( prefs.rosterGroupSortStyle == Options::GroupSortStyle_Rank )
|
---|
742 | name = "rank";
|
---|
743 | sorting.appendChild(textTag(doc, "group", name));
|
---|
744 |
|
---|
745 | name = "alpha";
|
---|
746 | if ( prefs.rosterAccountSortStyle == Options::AccountSortStyle_Rank )
|
---|
747 | name = "rank";
|
---|
748 | sorting.appendChild(textTag(doc, "account", name));
|
---|
749 | }
|
---|
750 | }
|
---|
751 |
|
---|
752 | // Avatars
|
---|
753 | {
|
---|
754 | QDomElement p_avatars = doc.createElement("avatars");
|
---|
755 | p_general.appendChild(p_avatars);
|
---|
756 | p_avatars.appendChild(textTag(doc, "use", prefs.avatarsEnabled));
|
---|
757 | p_avatars.appendChild(textTag(doc, "use_chatdlg", prefs.avatarsChatdlgEnabled));
|
---|
758 | p_avatars.appendChild(textTag(doc, "size", prefs.avatarsSize));
|
---|
759 | }
|
---|
760 | {
|
---|
761 | QDomElement p_misc = doc.createElement("misc");
|
---|
762 | p_general.appendChild(p_misc);
|
---|
763 |
|
---|
764 | p_misc.appendChild(textTag(doc, "chatBgImage", prefs.chatBgImage));
|
---|
765 | p_misc.appendChild(textTag(doc, "smallChats", prefs.smallChats));
|
---|
766 | p_misc.appendChild(textTag(doc, "chatLineEdit", prefs.chatLineEdit));
|
---|
767 | p_misc.appendChild(textTag(doc, "useTabs", prefs.useTabs));
|
---|
768 | p_misc.appendChild(textTag(doc, "usePerTabCloseButton", prefs.usePerTabCloseButton));
|
---|
769 | p_misc.appendChild(textTag(doc, "putTabsAtBottom", prefs.putTabsAtBottom));
|
---|
770 | p_misc.appendChild(textTag(doc, "autoRosterSize", prefs.autoRosterSize));
|
---|
771 | p_misc.appendChild(textTag(doc, "autoRosterSizeGrowTop", prefs.autoRosterSizeGrowTop));
|
---|
772 | p_misc.appendChild(textTag(doc, "autoResolveNicksOnAdd", prefs.autoResolveNicksOnAdd));
|
---|
773 | p_misc.appendChild(textTag(doc, "delChats", prefs.delChats));
|
---|
774 | p_misc.appendChild(textTag(doc, "showJoins", prefs.showJoins));
|
---|
775 | p_misc.appendChild(textTag(doc, "browser", prefs.browser));
|
---|
776 | p_misc.appendChild(textTag(doc, "customBrowser", prefs.customBrowser));
|
---|
777 | p_misc.appendChild(textTag(doc, "customMailer", prefs.customMailer));
|
---|
778 | p_misc.appendChild(textTag(doc, "alwaysOnTop", prefs.alwaysOnTop));
|
---|
779 | p_misc.appendChild(textTag(doc, "keepSizes", prefs.keepSizes));
|
---|
780 | p_misc.appendChild(textTag(doc, "ignoreHeadline", prefs.ignoreHeadline));
|
---|
781 | p_misc.appendChild(textTag(doc, "ignoreNonRoster", prefs.ignoreNonRoster));
|
---|
782 | p_misc.appendChild(textTag(doc, "excludeGroupChatIgnore", prefs.excludeGroupChatsFromIgnore));
|
---|
783 | p_misc.appendChild(textTag(doc, "scrollTo", prefs.scrollTo));
|
---|
784 | p_misc.appendChild(textTag(doc, "useEmoticons", prefs.useEmoticons));
|
---|
785 | p_misc.appendChild(textTag(doc, "alertOpenChats", prefs.alertOpenChats));
|
---|
786 | p_misc.appendChild(textTag(doc, "raiseChatWindow", prefs.raiseChatWindow));
|
---|
787 | p_misc.appendChild(textTag(doc, "showSubjects", prefs.showSubjects));
|
---|
788 | p_misc.appendChild(textTag(doc, "showCounter", prefs.showCounter));
|
---|
789 | p_misc.appendChild(textTag(doc, "chatSays", prefs.chatSays));
|
---|
790 | p_misc.appendChild(textTag(doc, "chatSoftReturn", prefs.chatSoftReturn));
|
---|
791 | p_misc.appendChild(textTag(doc, "showGroupCounts", prefs.showGroupCounts));
|
---|
792 | p_misc.appendChild(textTag(doc, "jidComplete", prefs.jidComplete));
|
---|
793 | p_misc.appendChild(textTag(doc, "grabUrls", prefs.grabUrls));
|
---|
794 | p_misc.appendChild(textTag(doc, "messageEvents", prefs.messageEvents));
|
---|
795 | p_misc.appendChild(textTag(doc, "lastPath", prefs.lastPath));
|
---|
796 | p_misc.appendChild(textTag(doc, "lastSavePath", prefs.lastSavePath));
|
---|
797 | p_misc.appendChild(textTag(doc, "autoCopy", prefs.autoCopy));
|
---|
798 | }
|
---|
799 | {
|
---|
800 | QDomElement p_dock = doc.createElement("dock");
|
---|
801 | p_general.appendChild(p_dock);
|
---|
802 |
|
---|
803 | p_dock.appendChild(textTag(doc, "useDock", prefs.useDock));
|
---|
804 | p_dock.appendChild(textTag(doc, "dockDCstyle", prefs.dockDCstyle));
|
---|
805 | p_dock.appendChild(textTag(doc, "dockHideMW", prefs.dockHideMW));
|
---|
806 | p_dock.appendChild(textTag(doc, "dockToolMW", prefs.dockToolMW));
|
---|
807 | p_dock.appendChild(textTag(doc, "isWMDock", prefs.isWMDock));
|
---|
808 | }
|
---|
809 | /*{
|
---|
810 | QDomElement p_sec = doc.createElement("security");
|
---|
811 | p_general.appendChild(p_sec);
|
---|
812 |
|
---|
813 | p_sec.appendChild(textTag(doc, "pgp", prefs.pgp));
|
---|
814 | }*/
|
---|
815 | }
|
---|
816 |
|
---|
817 | // Added by Kiko 020621: stores SSL cert chain validation configuration
|
---|
818 | {
|
---|
819 | QDomElement p_ssl = doc.createElement("ssl");
|
---|
820 | p.appendChild(p_ssl);
|
---|
821 |
|
---|
822 | p_ssl.appendChild(textTag(doc, "trustedcertstoredir", prefs.trustCertStoreDir));
|
---|
823 | }
|
---|
824 |
|
---|
825 | {
|
---|
826 | QDomElement p_events = doc.createElement("events");
|
---|
827 | p.appendChild(p_events);
|
---|
828 |
|
---|
829 | p_events.appendChild(textTag(doc, "alertstyle", prefs.alertStyle));
|
---|
830 | p_events.appendChild(textTag(doc, "autoAuth", prefs.autoAuth));
|
---|
831 | p_events.appendChild(textTag(doc, "notifyAuth", prefs.notifyAuth));
|
---|
832 |
|
---|
833 |
|
---|
834 | {
|
---|
835 | QDomElement p_receive = doc.createElement("receive");
|
---|
836 | p_events.appendChild(p_receive);
|
---|
837 |
|
---|
838 | p_receive.appendChild(textTag(doc, "popupMsgs", prefs.popupMsgs));
|
---|
839 | p_receive.appendChild(textTag(doc, "popupChats", prefs.popupChats));
|
---|
840 | p_receive.appendChild(textTag(doc, "popupHeadlines", prefs.popupHeadlines));
|
---|
841 | p_receive.appendChild(textTag(doc, "popupFiles", prefs.popupFiles));
|
---|
842 | p_receive.appendChild(textTag(doc, "noAwayPopup", prefs.noAwayPopup));
|
---|
843 | p_receive.appendChild(textTag(doc, "noUnlistedPopup", prefs.noUnlistedPopup));
|
---|
844 | p_receive.appendChild(textTag(doc, "raise", prefs.raise));
|
---|
845 | p_receive.appendChild(textTag(doc, "incomingAs", prefs.incomingAs));
|
---|
846 | }
|
---|
847 |
|
---|
848 | {
|
---|
849 | QDomElement p_priority = doc.createElement("priority");
|
---|
850 | p_events.appendChild(p_priority);
|
---|
851 |
|
---|
852 | p_priority.appendChild(textTag(doc, "message", prefs.eventPriorityMessage));
|
---|
853 | p_priority.appendChild(textTag(doc, "chat", prefs.eventPriorityChat));
|
---|
854 | p_priority.appendChild(textTag(doc, "headline", prefs.eventPriorityHeadline));
|
---|
855 | p_priority.appendChild(textTag(doc, "auth", prefs.eventPriorityAuth));
|
---|
856 | p_priority.appendChild(textTag(doc, "file", prefs.eventPriorityFile));
|
---|
857 | }
|
---|
858 | }
|
---|
859 |
|
---|
860 | {
|
---|
861 | QDomElement p_pres = doc.createElement("presence");
|
---|
862 | p.appendChild(p_pres);
|
---|
863 |
|
---|
864 | {
|
---|
865 | QDomElement tag = doc.createElement("misc");
|
---|
866 | p_pres.appendChild(tag);
|
---|
867 |
|
---|
868 | tag.appendChild(textTag(doc, "askOnline", prefs.askOnline));
|
---|
869 | tag.appendChild(textTag(doc, "askOffline", prefs.askOffline));
|
---|
870 | tag.appendChild(textTag(doc, "rosterAnim", prefs.rosterAnim));
|
---|
871 | tag.appendChild(textTag(doc, "autoVersion", prefs.autoVersion));
|
---|
872 | tag.appendChild(textTag(doc, "autoVCardOnLogin", prefs.autoVCardOnLogin));
|
---|
873 | tag.appendChild(textTag(doc, "xmlConsoleOnLogin", prefs.xmlConsoleOnLogin));
|
---|
874 | }
|
---|
875 | {
|
---|
876 | QDomElement tag = doc.createElement("autostatus");
|
---|
877 | p_pres.appendChild(tag);
|
---|
878 |
|
---|
879 | QDomElement e;
|
---|
880 |
|
---|
881 | e = textTag(doc, "away", prefs.asAway);
|
---|
882 | setBoolAttribute(e, "use", prefs.use_asAway);
|
---|
883 | tag.appendChild(e);
|
---|
884 |
|
---|
885 | e = textTag(doc, "xa", prefs.asXa);
|
---|
886 | setBoolAttribute(e, "use", prefs.use_asXa);
|
---|
887 | tag.appendChild(e);
|
---|
888 |
|
---|
889 | e = textTag(doc, "offline", prefs.asOffline);
|
---|
890 | setBoolAttribute(e, "use", prefs.use_asOffline);
|
---|
891 | tag.appendChild(e);
|
---|
892 |
|
---|
893 | tag.appendChild(textTag(doc, "message", prefs.asMessage));
|
---|
894 | }
|
---|
895 | {
|
---|
896 | p_pres.appendChild(prefs.sp.toXml(doc, "statuspresets"));
|
---|
897 | }
|
---|
898 | {
|
---|
899 | p_pres.appendChild(stringListToXml(doc, "recentstatus",prefs.recentStatus));
|
---|
900 | }
|
---|
901 | }
|
---|
902 |
|
---|
903 | {
|
---|
904 | QDomElement p_lnf = doc.createElement("lookandfeel");
|
---|
905 | p.appendChild(p_lnf);
|
---|
906 |
|
---|
907 | p_lnf.appendChild(textTag(doc, "newHeadings", prefs.clNewHeadings));
|
---|
908 | p_lnf.appendChild(textTag(doc, "chat-opacity", prefs.chatOpacity));
|
---|
909 | p_lnf.appendChild(textTag(doc, "roster-opacity", prefs.rosterOpacity));
|
---|
910 | p_lnf.appendChild(textTag(doc, "outline-headings", prefs.outlineHeadings));
|
---|
911 |
|
---|
912 | {
|
---|
913 | QDomElement tag = doc.createElement("colors");
|
---|
914 | p_lnf.appendChild(tag);
|
---|
915 |
|
---|
916 | tag.appendChild(textTag(doc, "online", prefs.color[cOnline].name() ));
|
---|
917 | tag.appendChild(textTag(doc, "listback", prefs.color[cListBack].name() ));
|
---|
918 | tag.appendChild(textTag(doc, "away", prefs.color[cAway].name() ));
|
---|
919 | tag.appendChild(textTag(doc, "dnd", prefs.color[cDND].name() ));
|
---|
920 | tag.appendChild(textTag(doc, "offline", prefs.color[cOffline].name() ));
|
---|
921 | tag.appendChild(textTag(doc, "profilefore", prefs.color[cProfileFore].name() ));
|
---|
922 | tag.appendChild(textTag(doc, "profileback", prefs.color[cProfileBack].name() ));
|
---|
923 | tag.appendChild(textTag(doc, "groupfore", prefs.color[cGroupFore].name() ));
|
---|
924 | tag.appendChild(textTag(doc, "groupback", prefs.color[cGroupBack].name() ));
|
---|
925 | tag.appendChild(textTag(doc, "animfront", prefs.color[cAnimFront].name() ));
|
---|
926 | tag.appendChild(textTag(doc, "animback", prefs.color[cAnimBack].name() ));
|
---|
927 | }
|
---|
928 |
|
---|
929 | {
|
---|
930 | QDomElement tag = doc.createElement("fonts");
|
---|
931 | p_lnf.appendChild(tag);
|
---|
932 |
|
---|
933 | tag.appendChild(textTag(doc, "roster", prefs.font[fRoster] ));
|
---|
934 | tag.appendChild(textTag(doc, "message", prefs.font[fMessage] ));
|
---|
935 | tag.appendChild(textTag(doc, "chat", prefs.font[fChat] ));
|
---|
936 | tag.appendChild(textTag(doc, "popup", prefs.font[fPopup] ));
|
---|
937 | }
|
---|
938 | }
|
---|
939 |
|
---|
940 | {
|
---|
941 | QDomElement p_sound = doc.createElement("sound");
|
---|
942 | p.appendChild(p_sound);
|
---|
943 |
|
---|
944 | p_sound.appendChild(textTag(doc, "player", prefs.player));
|
---|
945 | p_sound.appendChild(textTag(doc, "noawaysound", prefs.noAwaySound));
|
---|
946 | p_sound.appendChild(textTag(doc, "noGCSound", prefs.noGCSound));
|
---|
947 |
|
---|
948 | {
|
---|
949 | QDomElement p_onevent = doc.createElement("onevent");
|
---|
950 | p_sound.appendChild(p_onevent);
|
---|
951 |
|
---|
952 | p_onevent.appendChild(textTag(doc, "message", prefs.onevent[eMessage]));
|
---|
953 | p_onevent.appendChild(textTag(doc, "chat1", prefs.onevent[eChat1]));
|
---|
954 | p_onevent.appendChild(textTag(doc, "chat2", prefs.onevent[eChat2]));
|
---|
955 | p_onevent.appendChild(textTag(doc, "system", prefs.onevent[eSystem]));
|
---|
956 | p_onevent.appendChild(textTag(doc, "headline", prefs.onevent[eHeadline]));
|
---|
957 | p_onevent.appendChild(textTag(doc, "online", prefs.onevent[eOnline]));
|
---|
958 | p_onevent.appendChild(textTag(doc, "offline", prefs.onevent[eOffline]));
|
---|
959 | p_onevent.appendChild(textTag(doc, "send", prefs.onevent[eSend]));
|
---|
960 | p_onevent.appendChild(textTag(doc, "incoming_ft", prefs.onevent[eIncomingFT]));
|
---|
961 | p_onevent.appendChild(textTag(doc, "ft_complete", prefs.onevent[eFTComplete]));
|
---|
962 | }
|
---|
963 | }
|
---|
964 |
|
---|
965 | {
|
---|
966 | QDomElement p_sizes = doc.createElement("sizes");
|
---|
967 | p.appendChild(p_sizes);
|
---|
968 |
|
---|
969 | p_sizes.appendChild(textTag(doc, "eventdlg", prefs.sizeEventDlg));
|
---|
970 | p_sizes.appendChild(textTag(doc, "chatdlg", prefs.sizeChatDlg));
|
---|
971 | p_sizes.appendChild(textTag(doc, "tabdlg", prefs.sizeTabDlg));
|
---|
972 | }
|
---|
973 |
|
---|
974 | {
|
---|
975 | QDomElement p_toolbars = doc.createElement("toolbars");
|
---|
976 | p.appendChild(p_toolbars);
|
---|
977 |
|
---|
978 | QMap< QString, QValueList<Options::ToolbarPrefs> >::Iterator itBars = prefs.toolbars.begin();
|
---|
979 | for ( ; itBars != prefs.toolbars.end(); ++itBars ) {
|
---|
980 | QValueList<Options::ToolbarPrefs> toolbars = itBars.data();
|
---|
981 | QDomElement p_bars = doc.createElement( itBars.key() );
|
---|
982 | p_toolbars.appendChild( p_bars );
|
---|
983 |
|
---|
984 | QValueList<Options::ToolbarPrefs>::Iterator it = toolbars.begin();
|
---|
985 | for ( ; it != toolbars.end(); ++it) {
|
---|
986 | Options::ToolbarPrefs tb = *it;
|
---|
987 | if ( tb.keys.size() ||
|
---|
988 | !tb.name.isEmpty() )
|
---|
989 | {
|
---|
990 | QDomElement tb_prefs = doc.createElement("toolbar");
|
---|
991 | p_bars.appendChild(tb_prefs);
|
---|
992 |
|
---|
993 | tb_prefs.appendChild(textTag(doc, "name", tb.name));
|
---|
994 | tb_prefs.appendChild(textTag(doc, "on", tb.on));
|
---|
995 | tb_prefs.appendChild(textTag(doc, "locked", tb.locked));
|
---|
996 | tb_prefs.appendChild(textTag(doc, "stretchable", tb.stretchable));
|
---|
997 | tb_prefs.appendChild(stringListToXml(doc, "keys", tb.keys));
|
---|
998 |
|
---|
999 | QDomElement tb_position = doc.createElement("position");
|
---|
1000 | tb_prefs.appendChild(tb_position);
|
---|
1001 |
|
---|
1002 | QString dockStr;
|
---|
1003 | Qt::Dock dock = tb.dock;
|
---|
1004 | if (dock == Qt::DockTop)
|
---|
1005 | dockStr = "DockTop";
|
---|
1006 | else if (dock == Qt::DockBottom)
|
---|
1007 | dockStr = "DockBottom";
|
---|
1008 | else if (dock == Qt::DockLeft)
|
---|
1009 | dockStr = "DockLeft";
|
---|
1010 | else if (dock == Qt::DockRight)
|
---|
1011 | dockStr = "DockRight";
|
---|
1012 | else if (dock == Qt::DockMinimized)
|
---|
1013 | dockStr = "DockMinimized";
|
---|
1014 | else if (dock == Qt::DockTornOff)
|
---|
1015 | dockStr = "DockTornOff";
|
---|
1016 | else if (dock == Qt::DockUnmanaged)
|
---|
1017 | dockStr = "DockUnmanaged";
|
---|
1018 |
|
---|
1019 | tb_position.appendChild(textTag(doc, "dock", dockStr));
|
---|
1020 | tb_position.appendChild(textTag(doc, "index", tb.index));
|
---|
1021 | tb_position.appendChild(textTag(doc, "nl", tb.nl));
|
---|
1022 | tb_position.appendChild(textTag(doc, "extraOffset", tb.extraOffset));
|
---|
1023 | }
|
---|
1024 | }
|
---|
1025 | }
|
---|
1026 | }
|
---|
1027 |
|
---|
1028 | {
|
---|
1029 | QDomElement pp = doc.createElement("popups");
|
---|
1030 | p.appendChild(pp);
|
---|
1031 | pp.appendChild(textTag(doc, "on", prefs.ppIsOn));
|
---|
1032 | pp.appendChild(textTag(doc, "online", prefs.ppOnline));
|
---|
1033 | pp.appendChild(textTag(doc, "offline", prefs.ppOffline));
|
---|
1034 | pp.appendChild(textTag(doc, "statusChange", prefs.ppStatus));
|
---|
1035 | pp.appendChild(textTag(doc, "message", prefs.ppMessage));
|
---|
1036 | pp.appendChild(textTag(doc, "chat", prefs.ppChat));
|
---|
1037 | pp.appendChild(textTag(doc, "headline", prefs.ppHeadline));
|
---|
1038 | pp.appendChild(textTag(doc, "file", prefs.ppFile));
|
---|
1039 | pp.appendChild(textTag(doc, "jidClip", prefs.ppJidClip));
|
---|
1040 | pp.appendChild(textTag(doc, "statusClip", prefs.ppStatusClip));
|
---|
1041 | pp.appendChild(textTag(doc, "textClip", prefs.ppTextClip));
|
---|
1042 | pp.appendChild(textTag(doc, "hideTime", prefs.ppHideTime));
|
---|
1043 | pp.appendChild(textTag(doc, "borderColor", prefs.ppBorderColor.name()));
|
---|
1044 | }
|
---|
1045 |
|
---|
1046 | {
|
---|
1047 | // Bouncing dock (on Mac OS X)
|
---|
1048 | QDomElement dock = doc.createElement("dock");
|
---|
1049 | p.appendChild(dock);
|
---|
1050 | switch (prefs.bounceDock) {
|
---|
1051 | case Options::NoBounce :
|
---|
1052 | dock.setAttribute("bounce", "never");
|
---|
1053 | break;
|
---|
1054 | case Options::BounceOnce :
|
---|
1055 | dock.setAttribute("bounce", "once");
|
---|
1056 | break;
|
---|
1057 | case Options::BounceForever :
|
---|
1058 | dock.setAttribute("bounce", "forever");
|
---|
1059 | break;
|
---|
1060 | default:
|
---|
1061 | break;
|
---|
1062 | }
|
---|
1063 | }
|
---|
1064 |
|
---|
1065 | {
|
---|
1066 | //group chat
|
---|
1067 | QDomElement gc = doc.createElement("groupchat");
|
---|
1068 | p.appendChild(gc);
|
---|
1069 | gc.appendChild(stringListToXml(doc, "highlightwords", prefs.gcHighlights));
|
---|
1070 | gc.appendChild(stringListToXml(doc, "nickcolors", prefs.gcNickColors));
|
---|
1071 | gc.appendChild(textTag(doc, "nickcoloring", prefs.gcNickColoring));
|
---|
1072 | gc.appendChild(textTag(doc, "highlighting", prefs.gcHighlighting));
|
---|
1073 | }
|
---|
1074 |
|
---|
1075 | {
|
---|
1076 | QDomElement p_lockdown = doc.createElement("lockdown");
|
---|
1077 | p.appendChild(p_lockdown);
|
---|
1078 | p_lockdown.appendChild(textTag(doc, "roster", prefs.lockdown.roster));
|
---|
1079 | p_lockdown.appendChild(textTag(doc, "options", prefs.lockdown.options));
|
---|
1080 | p_lockdown.appendChild(textTag(doc, "profiles", prefs.lockdown.profiles));
|
---|
1081 | p_lockdown.appendChild(textTag(doc, "services", prefs.lockdown.services));
|
---|
1082 | p_lockdown.appendChild(textTag(doc, "accounts", prefs.lockdown.accounts));
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 | {
|
---|
1086 | QDomElement is = doc.createElement("iconset");
|
---|
1087 | p.appendChild(is);
|
---|
1088 |
|
---|
1089 | // system
|
---|
1090 | is.appendChild(textTag(doc, "system", prefs.systemIconset));
|
---|
1091 |
|
---|
1092 | // roster - default
|
---|
1093 | QDomElement is_roster = doc.createElement("roster");
|
---|
1094 | is.appendChild(is_roster);
|
---|
1095 | is_roster.appendChild(textTag(doc, "default", prefs.defaultRosterIconset));
|
---|
1096 |
|
---|
1097 | {
|
---|
1098 | // roster - service
|
---|
1099 | QDomElement roster_service = doc.createElement("service");
|
---|
1100 | is_roster.appendChild(roster_service);
|
---|
1101 |
|
---|
1102 | QMapIterator<QString, QString> it = prefs.serviceRosterIconset.begin();
|
---|
1103 | for ( ; it != prefs.serviceRosterIconset.end(); ++it) {
|
---|
1104 | QDomElement item = doc.createElement("item");
|
---|
1105 | roster_service.appendChild(item);
|
---|
1106 |
|
---|
1107 | item.setAttribute("service", it.key());
|
---|
1108 | item.setAttribute("iconset", it.data());
|
---|
1109 | }
|
---|
1110 | }
|
---|
1111 |
|
---|
1112 | {
|
---|
1113 | // roster - custom
|
---|
1114 | QDomElement roster_custom = doc.createElement("custom");
|
---|
1115 | is_roster.appendChild(roster_custom);
|
---|
1116 |
|
---|
1117 | QMapIterator<QString, QString> it = prefs.customRosterIconset.begin();
|
---|
1118 | for ( ; it != prefs.customRosterIconset.end(); ++it) {
|
---|
1119 | QDomElement item = doc.createElement("item");
|
---|
1120 | roster_custom.appendChild(item);
|
---|
1121 |
|
---|
1122 | item.setAttribute("regExp", it.key());
|
---|
1123 | item.setAttribute("iconset", it.data());
|
---|
1124 | }
|
---|
1125 | }
|
---|
1126 |
|
---|
1127 | {
|
---|
1128 | // emoticons
|
---|
1129 | QDomElement is_emoticons = doc.createElement("emoticons");
|
---|
1130 | is.appendChild(is_emoticons);
|
---|
1131 |
|
---|
1132 | QStringList::Iterator it = prefs.emoticons.begin();
|
---|
1133 | for ( ; it != prefs.emoticons.end(); ++it)
|
---|
1134 | is_emoticons.appendChild(textTag(doc, "item", *it));
|
---|
1135 | }
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | {
|
---|
1139 | // tip of the day
|
---|
1140 | QDomElement p_tip = doc.createElement("tipOfTheDay");
|
---|
1141 | p.appendChild(p_tip);
|
---|
1142 |
|
---|
1143 | p_tip.appendChild( textTag(doc, "show", prefs.showTips ) );
|
---|
1144 | p_tip.appendChild( textTag(doc, "num", prefs.tipNum ) );
|
---|
1145 | }
|
---|
1146 |
|
---|
1147 | {
|
---|
1148 | // disco dialog
|
---|
1149 | QDomElement p_disco = doc.createElement("disco");
|
---|
1150 | p.appendChild(p_disco);
|
---|
1151 |
|
---|
1152 | p_disco.appendChild( textTag(doc, "items", prefs.discoItems ) );
|
---|
1153 | p_disco.appendChild( textTag(doc, "info", prefs.discoInfo ) );
|
---|
1154 | }
|
---|
1155 |
|
---|
1156 | {
|
---|
1157 | // data transfer
|
---|
1158 | QDomElement p_dt = doc.createElement("dt");
|
---|
1159 | p.appendChild(p_dt);
|
---|
1160 | p_dt.appendChild( textTag(doc, "port", prefs.dtPort ) );
|
---|
1161 | p_dt.appendChild( textTag(doc, "external", prefs.dtExternal ) );
|
---|
1162 | }
|
---|
1163 |
|
---|
1164 | {
|
---|
1165 | // global accelerators
|
---|
1166 | QDomElement p_globalAccel = doc.createElement("globalAccel");
|
---|
1167 | p.appendChild(p_globalAccel);
|
---|
1168 |
|
---|
1169 | QStringList accelNames;
|
---|
1170 | accelNames << "processNextEvent";
|
---|
1171 | accelNames << "showHideRoster";
|
---|
1172 |
|
---|
1173 | QStringList::Iterator it1 = accelNames.begin();
|
---|
1174 | QValueList<QKeySequence>::iterator it2 = prefs.globalAccels.begin();
|
---|
1175 |
|
---|
1176 | for ( ; it2 != prefs.globalAccels.end(); ++it1, ++it2 ) {
|
---|
1177 | QDomElement item = doc.createElement("command");
|
---|
1178 | p_globalAccel.appendChild(item);
|
---|
1179 | item.setAttribute("type", *it1);
|
---|
1180 | item.appendChild( doc.createTextNode(*it2) );
|
---|
1181 | }
|
---|
1182 | }
|
---|
1183 |
|
---|
1184 | {
|
---|
1185 | // advanced widget
|
---|
1186 | QDomElement p_advWidget = doc.createElement("advancedWidget");
|
---|
1187 | p.appendChild(p_advWidget);
|
---|
1188 |
|
---|
1189 | QDomElement stick = doc.createElement("sticky");
|
---|
1190 | p_advWidget.appendChild(stick);
|
---|
1191 |
|
---|
1192 | setBoolAttribute(stick, "enabled", GAdvancedWidget::stickEnabled());
|
---|
1193 | stick.appendChild( textTag(doc, "offset", GAdvancedWidget::stickAt()) );
|
---|
1194 | stick.appendChild( textTag(doc, "stickToWindows", GAdvancedWidget::stickToWindows()) );
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 | QFile f(fname);
|
---|
1198 | if(!f.open(IO_WriteOnly))
|
---|
1199 | return FALSE;
|
---|
1200 | QTextStream t;
|
---|
1201 | t.setDevice(&f);
|
---|
1202 | t.setEncoding(QTextStream::UnicodeUTF8);
|
---|
1203 | t << doc.toString();
|
---|
1204 | t.unsetDevice();
|
---|
1205 | f.close();
|
---|
1206 |
|
---|
1207 | return TRUE;
|
---|
1208 | }
|
---|
1209 |
|
---|
1210 | bool UserProfile::fromFile(const QString &fname)
|
---|
1211 | {
|
---|
1212 | QString confver;
|
---|
1213 | QDomDocument doc;
|
---|
1214 |
|
---|
1215 | QFile f(fname);
|
---|
1216 | if(!f.open(IO_ReadOnly))
|
---|
1217 | return FALSE;
|
---|
1218 | if(!doc.setContent(&f))
|
---|
1219 | return FALSE;
|
---|
1220 | f.close();
|
---|
1221 |
|
---|
1222 | QDomElement base = doc.documentElement();
|
---|
1223 | if(base.tagName() != "psiconf")
|
---|
1224 | return FALSE;
|
---|
1225 | confver = base.attribute("version");
|
---|
1226 | if(confver != "1.0")
|
---|
1227 | return FALSE;
|
---|
1228 |
|
---|
1229 | readEntry(base, "progver", &progver);
|
---|
1230 |
|
---|
1231 | readRectEntry(base, "geom", &mwgeom);
|
---|
1232 | xmlToStringList(base, "recentGCList", &recentGCList);
|
---|
1233 | xmlToStringList(base, "recentBrowseList", &recentBrowseList);
|
---|
1234 | readEntry(base, "lastStatusString", &lastStatusString);
|
---|
1235 | readBoolEntry(base, "useSound", &useSound);
|
---|
1236 |
|
---|
1237 | bool found;
|
---|
1238 | QDomElement accs = findSubTag(base, "accounts", &found);
|
---|
1239 | if(found) {
|
---|
1240 | for(QDomNode n = accs.firstChild(); !n.isNull(); n = n.nextSibling()) {
|
---|
1241 | QDomElement a = n.toElement();
|
---|
1242 | if(a.isNull())
|
---|
1243 | continue;
|
---|
1244 |
|
---|
1245 | if(a.tagName() == "account") {
|
---|
1246 | UserAccount ua;
|
---|
1247 | ua.fromXml(a);
|
---|
1248 | acc.append(ua);
|
---|
1249 | }
|
---|
1250 | }
|
---|
1251 | }
|
---|
1252 |
|
---|
1253 | // convert old proxy config into new
|
---|
1254 | for(UserAccountList::Iterator it = acc.begin(); it != acc.end(); ++it) {
|
---|
1255 | UserAccount &a = *it;
|
---|
1256 | if(a.proxy_type > 0) {
|
---|
1257 | ProxyItem p;
|
---|
1258 | p.name = QObject::tr("%1 Proxy").arg(a.name);
|
---|
1259 | p.type = "http";
|
---|
1260 | p.settings.host = a.proxy_host;
|
---|
1261 | p.settings.port = a.proxy_port;
|
---|
1262 | p.settings.useAuth = !a.proxy_user.isEmpty();
|
---|
1263 | p.settings.user = a.proxy_user;
|
---|
1264 | p.settings.pass = a.proxy_pass;
|
---|
1265 | proxyList.append(p);
|
---|
1266 |
|
---|
1267 | a.proxy_index = proxyList.count(); // 1 and up are proxies
|
---|
1268 | }
|
---|
1269 | }
|
---|
1270 |
|
---|
1271 | QDomElement prox = findSubTag(base, "proxies", &found);
|
---|
1272 | if(found) {
|
---|
1273 | QDomNodeList list = prox.elementsByTagName("proxy");
|
---|
1274 | for(uint n = 0; n < list.count(); ++n) {
|
---|
1275 | QDomElement e = list.item(n).toElement();
|
---|
1276 | ProxyItem p;
|
---|
1277 | p.name = "";
|
---|
1278 | p.type = "";
|
---|
1279 | readEntry(e, "name", &p.name);
|
---|
1280 | readEntry(e, "type", &p.type);
|
---|
1281 | if(p.type == "0")
|
---|
1282 | p.type = "http";
|
---|
1283 | QDomElement pset = e.elementsByTagName("proxySettings").item(0).toElement();
|
---|
1284 | if(!pset.isNull())
|
---|
1285 | p.settings.fromXml(pset);
|
---|
1286 | proxyList.append(p);
|
---|
1287 | }
|
---|
1288 | }
|
---|
1289 |
|
---|
1290 | QDomElement p = findSubTag(base, "preferences", &found);
|
---|
1291 | if(found) {
|
---|
1292 | bool found;
|
---|
1293 |
|
---|
1294 | QDomElement p_general = findSubTag(p, "general", &found);
|
---|
1295 | if(found) {
|
---|
1296 | bool found;
|
---|
1297 |
|
---|
1298 | QDomElement p_roster = findSubTag(p_general, "roster", &found);
|
---|
1299 | if(found) {
|
---|
1300 | readEntry(p_roster, "rosterBgImage", &prefs.rosterBgImage);
|
---|
1301 | readBoolEntry(p_roster, "useleft", &prefs.useleft);
|
---|
1302 | readBoolEntry(p_roster, "singleclick", &prefs.singleclick);
|
---|
1303 | readBoolEntry(p_roster, "hideMenubar", &prefs.hideMenubar);
|
---|
1304 | readNumEntry(p_roster, "defaultAction", &prefs.defaultAction);
|
---|
1305 | readBoolEntry(p_roster, "useTransportIconsForContacts", &prefs.useTransportIconsForContacts);
|
---|
1306 |
|
---|
1307 | QDomElement sorting = findSubTag(p_roster, "sortStyle", &found);
|
---|
1308 | if(found) {
|
---|
1309 | QString name;
|
---|
1310 |
|
---|
1311 | readEntry(sorting, "contact", &name);
|
---|
1312 | if ( name == "alpha" )
|
---|
1313 | prefs.rosterContactSortStyle = Options::ContactSortStyle_Alpha;
|
---|
1314 | else
|
---|
1315 | prefs.rosterContactSortStyle = Options::ContactSortStyle_Status;
|
---|
1316 |
|
---|
1317 | readEntry(sorting, "group", &name);
|
---|
1318 | if ( name == "rank" )
|
---|
1319 | prefs.rosterGroupSortStyle = Options::GroupSortStyle_Rank;
|
---|
1320 | else
|
---|
1321 | prefs.rosterGroupSortStyle = Options::GroupSortStyle_Alpha;
|
---|
1322 |
|
---|
1323 | readEntry(sorting, "account", &name);
|
---|
1324 | if ( name == "rank" )
|
---|
1325 | prefs.rosterAccountSortStyle = Options::AccountSortStyle_Rank;
|
---|
1326 | else
|
---|
1327 | prefs.rosterAccountSortStyle = Options::AccountSortStyle_Alpha;
|
---|
1328 | }
|
---|
1329 | }
|
---|
1330 |
|
---|
1331 | // Avatars
|
---|
1332 | QDomElement avTag = findSubTag(p_general, "avatars", &found);
|
---|
1333 | if(found) {
|
---|
1334 | readBoolEntry(avTag, "use", &prefs.avatarsEnabled);
|
---|
1335 | readBoolEntry(avTag, "use_chatdlg", &prefs.avatarsChatdlgEnabled);
|
---|
1336 | readNumEntry(avTag, "size", &prefs.avatarsSize);
|
---|
1337 | }
|
---|
1338 |
|
---|
1339 | QDomElement tag = findSubTag(p_general, "misc", &found);
|
---|
1340 | if(found) {
|
---|
1341 | readEntry(tag, "chatBgImage", &prefs.chatBgImage);
|
---|
1342 | readNumEntry(tag, "delChats", &prefs.delChats);
|
---|
1343 | readBoolEntry(tag, "showJoins", &prefs.showJoins);
|
---|
1344 | readNumEntry(tag, "browser", &prefs.browser);
|
---|
1345 | readEntry(tag, "customBrowser", &prefs.customBrowser);
|
---|
1346 | readEntry(tag, "customMailer", &prefs.customMailer);
|
---|
1347 | readBoolEntry(tag, "alwaysOnTop", &prefs.alwaysOnTop);
|
---|
1348 | readBoolEntry(tag, "keepSizes", &prefs.keepSizes);
|
---|
1349 | readBoolEntry(tag, "ignoreHeadline", &prefs.ignoreHeadline);
|
---|
1350 | readBoolEntry(tag, "ignoreNonRoster", &prefs.ignoreNonRoster);
|
---|
1351 | readBoolEntry(tag, "excludeGroupChatIgnore", &prefs.excludeGroupChatsFromIgnore);
|
---|
1352 | readBoolEntry(tag, "scrollTo", &prefs.scrollTo);
|
---|
1353 | readBoolEntry(tag, "useEmoticons", &prefs.useEmoticons);
|
---|
1354 | readBoolEntry(tag, "alertOpenChats", &prefs.alertOpenChats);
|
---|
1355 | readBoolEntry(tag, "raiseChatWindow", &prefs.raiseChatWindow);
|
---|
1356 | readBoolEntry(tag, "showSubjects", &prefs.showSubjects);
|
---|
1357 | readBoolEntry(tag, "chatSoftReturn", &prefs.chatSoftReturn);
|
---|
1358 | readBoolEntry(tag, "showGroupCounts", &prefs.showGroupCounts);
|
---|
1359 | readBoolEntry(tag, "showCounter", &prefs.showCounter);
|
---|
1360 | readBoolEntry(tag, "chatSays", &prefs.chatSays);
|
---|
1361 | readBoolEntry(tag, "jidComplete", &prefs.jidComplete);
|
---|
1362 | readBoolEntry(tag, "grabUrls", &prefs.grabUrls);
|
---|
1363 | readBoolEntry(tag, "smallChats", &prefs.smallChats);
|
---|
1364 | readBoolEntry(tag, "chatLineEdit", &prefs.chatLineEdit);
|
---|
1365 | readBoolEntry(tag, "useTabs", &prefs.useTabs);
|
---|
1366 | readBoolEntry(tag, "usePerTabCloseButton", &prefs.usePerTabCloseButton);
|
---|
1367 | readBoolEntry(tag, "putTabsAtBottom", &prefs.putTabsAtBottom);
|
---|
1368 | readBoolEntry(tag, "autoRosterSize", &prefs.autoRosterSize);
|
---|
1369 | readBoolEntry(tag, "autoRosterSizeGrowTop", &prefs.autoRosterSizeGrowTop);
|
---|
1370 | readBoolEntry(tag, "autoResolveNicksOnAdd", &prefs.autoResolveNicksOnAdd);
|
---|
1371 | readBoolEntry(tag, "messageEvents", &prefs.messageEvents);
|
---|
1372 | readEntry(tag, "lastPath", &prefs.lastPath);
|
---|
1373 | readEntry(tag, "lastSavePath", &prefs.lastSavePath);
|
---|
1374 | readBoolEntry(tag, "autoCopy", &prefs.autoCopy);
|
---|
1375 | }
|
---|
1376 |
|
---|
1377 | tag = findSubTag(p_general, "dock", &found);
|
---|
1378 | if(found) {
|
---|
1379 | readBoolEntry(tag, "useDock", &prefs.useDock);
|
---|
1380 | readBoolEntry(tag, "dockDCstyle", &prefs.dockDCstyle);
|
---|
1381 | readBoolEntry(tag, "dockHideMW", &prefs.dockHideMW);
|
---|
1382 | readBoolEntry(tag, "dockToolMW", &prefs.dockToolMW);
|
---|
1383 | readBoolEntry(tag, "isWMDock", &prefs.isWMDock);
|
---|
1384 | }
|
---|
1385 |
|
---|
1386 | /*tag = findSubTag(p_general, "security", &found);
|
---|
1387 | if(found) {
|
---|
1388 | readEntry(tag, "pgp", &prefs.pgp);
|
---|
1389 | }*/
|
---|
1390 | }
|
---|
1391 |
|
---|
1392 | // Added by Kiko 020621: retrieves SSL cert chain validation configuration
|
---|
1393 | QDomElement p_ssl = findSubTag(p,"ssl",&found);
|
---|
1394 | if(found) {
|
---|
1395 | readEntry(p_ssl, "trustedcertstoredir", &prefs.trustCertStoreDir);
|
---|
1396 | }
|
---|
1397 |
|
---|
1398 | QDomElement p_events = findSubTag(p, "events", &found);
|
---|
1399 | if(found) {
|
---|
1400 | bool found;
|
---|
1401 |
|
---|
1402 | readNumEntry(p_events, "alertstyle", &prefs.alertStyle);
|
---|
1403 | readBoolEntry(p_events, "autoAuth", &prefs.autoAuth);
|
---|
1404 | readBoolEntry(p_events, "notifyAuth", &prefs.notifyAuth);
|
---|
1405 |
|
---|
1406 | QDomElement tag = findSubTag(p_events, "receive", &found);
|
---|
1407 | if(found) {
|
---|
1408 | readBoolEntry(tag, "popupMsgs", &prefs.popupMsgs);
|
---|
1409 | readBoolEntry(tag, "popupChats", &prefs.popupChats);
|
---|
1410 | readBoolEntry(tag, "popupHeadlines", &prefs.popupHeadlines);
|
---|
1411 | readBoolEntry(tag, "popupFiles", &prefs.popupFiles);
|
---|
1412 | readBoolEntry(tag, "noAwayPopup", &prefs.noAwayPopup);
|
---|
1413 | readBoolEntry(tag, "noUnlistedPopup", &prefs.noUnlistedPopup);
|
---|
1414 | readBoolEntry(tag, "raise", &prefs.raise);
|
---|
1415 | readNumEntry(tag, "incomingAs", &prefs.incomingAs);
|
---|
1416 | }
|
---|
1417 |
|
---|
1418 | tag = findSubTag(p_events, "priority", &found);
|
---|
1419 | if(found) {
|
---|
1420 | readNumEntry(tag, "message", &prefs.eventPriorityMessage);
|
---|
1421 | readNumEntry(tag, "chat", &prefs.eventPriorityChat);
|
---|
1422 | readNumEntry(tag, "headline", &prefs.eventPriorityHeadline);
|
---|
1423 | readNumEntry(tag, "auth", &prefs.eventPriorityAuth);
|
---|
1424 | readNumEntry(tag, "file", &prefs.eventPriorityFile);
|
---|
1425 | }
|
---|
1426 | }
|
---|
1427 |
|
---|
1428 | QDomElement p_pres = findSubTag(p, "presence", &found);
|
---|
1429 | if(found) {
|
---|
1430 | bool found;
|
---|
1431 |
|
---|
1432 | QDomElement tag = findSubTag(p_pres, "misc", &found);
|
---|
1433 | if(found) {
|
---|
1434 | readBoolEntry(tag, "askOnline", &prefs.askOnline);
|
---|
1435 | readBoolEntry(tag, "askOffline", &prefs.askOffline);
|
---|
1436 | readBoolEntry(tag, "rosterAnim", &prefs.rosterAnim);
|
---|
1437 | readBoolEntry(tag, "autoVersion", &prefs.autoVersion);
|
---|
1438 | readBoolEntry(tag, "autoVCardOnLogin", &prefs.autoVCardOnLogin);
|
---|
1439 | readBoolEntry(tag, "xmlConsoleOnLogin", &prefs.xmlConsoleOnLogin);
|
---|
1440 | }
|
---|
1441 |
|
---|
1442 | tag = findSubTag(p_pres, "autostatus", &found);
|
---|
1443 | if(found) {
|
---|
1444 | bool found;
|
---|
1445 | QDomElement e;
|
---|
1446 | e = findSubTag(tag, "away", &found);
|
---|
1447 | if(found) {
|
---|
1448 | if(e.hasAttribute("use"))
|
---|
1449 | readBoolAttribute(e, "use", &prefs.use_asAway);
|
---|
1450 | else
|
---|
1451 | prefs.use_asAway = TRUE;
|
---|
1452 | }
|
---|
1453 | e = findSubTag(tag, "xa", &found);
|
---|
1454 | if(found) {
|
---|
1455 | if(e.hasAttribute("use"))
|
---|
1456 | readBoolAttribute(e, "use", &prefs.use_asXa);
|
---|
1457 | else
|
---|
1458 | prefs.use_asXa = TRUE;
|
---|
1459 | }
|
---|
1460 | e = findSubTag(tag, "offline", &found);
|
---|
1461 | if(found) {
|
---|
1462 | if(e.hasAttribute("use"))
|
---|
1463 | readBoolAttribute(e, "use", &prefs.use_asOffline);
|
---|
1464 | else
|
---|
1465 | prefs.use_asOffline = TRUE;
|
---|
1466 | }
|
---|
1467 |
|
---|
1468 | readNumEntry(tag, "away", &prefs.asAway);
|
---|
1469 | readNumEntry(tag, "xa", &prefs.asXa);
|
---|
1470 | readNumEntry(tag, "offline", &prefs.asOffline);
|
---|
1471 |
|
---|
1472 | readEntry(tag, "message", &prefs.asMessage);
|
---|
1473 | }
|
---|
1474 |
|
---|
1475 | tag = findSubTag(p_pres, "statuspresets", &found);
|
---|
1476 | if(found)
|
---|
1477 | prefs.sp.fromXml(tag);
|
---|
1478 | xmlToStringList(p_pres, "recentstatus", &prefs.recentStatus);
|
---|
1479 | }
|
---|
1480 |
|
---|
1481 | QDomElement p_lnf = findSubTag(p, "lookandfeel", &found);
|
---|
1482 | if(found) {
|
---|
1483 | bool found;
|
---|
1484 |
|
---|
1485 | readBoolEntry(p_lnf, "newHeadings", &prefs.clNewHeadings);
|
---|
1486 | readBoolEntry(p_lnf, "outline-headings", &prefs.outlineHeadings);
|
---|
1487 | readNumEntry(p_lnf, "chat-opacity", &prefs.chatOpacity);
|
---|
1488 | readNumEntry(p_lnf, "roster-opacity", &prefs.rosterOpacity);
|
---|
1489 |
|
---|
1490 | QDomElement tag = findSubTag(p_lnf, "colors", &found);
|
---|
1491 | if(found) {
|
---|
1492 | readColorEntry(tag, "online", &prefs.color[cOnline]);
|
---|
1493 | readColorEntry(tag, "listback", &prefs.color[cListBack]);
|
---|
1494 | readColorEntry(tag, "away", &prefs.color[cAway]);
|
---|
1495 | readColorEntry(tag, "dnd", &prefs.color[cDND]);
|
---|
1496 | readColorEntry(tag, "offline", &prefs.color[cOffline]);
|
---|
1497 | readColorEntry(tag, "groupfore", &prefs.color[cGroupFore]);
|
---|
1498 | readColorEntry(tag, "groupback", &prefs.color[cGroupBack]);
|
---|
1499 | readColorEntry(tag, "profilefore", &prefs.color[cProfileFore]);
|
---|
1500 | readColorEntry(tag, "profileback", &prefs.color[cProfileBack]);
|
---|
1501 | readColorEntry(tag, "animfront", &prefs.color[cAnimFront]);
|
---|
1502 | readColorEntry(tag, "animback", &prefs.color[cAnimBack]);
|
---|
1503 | }
|
---|
1504 |
|
---|
1505 | tag = findSubTag(p_lnf, "fonts", &found);
|
---|
1506 | if(found) {
|
---|
1507 | readEntry(tag, "roster", &prefs.font[fRoster]);
|
---|
1508 | readEntry(tag, "message", &prefs.font[fMessage]);
|
---|
1509 | readEntry(tag, "chat", &prefs.font[fChat]);
|
---|
1510 | readEntry(tag, "popup", &prefs.font[fPopup]);
|
---|
1511 | }
|
---|
1512 | }
|
---|
1513 |
|
---|
1514 | QDomElement p_sound = findSubTag(p, "sound", &found);
|
---|
1515 | if(found) {
|
---|
1516 | bool found;
|
---|
1517 |
|
---|
1518 | readEntry(p_sound, "player", &prefs.player);
|
---|
1519 | readBoolEntry(p_sound, "noawaysound", &prefs.noAwaySound);
|
---|
1520 | readBoolEntry(p_sound, "noGCSound", &prefs.noGCSound);
|
---|
1521 |
|
---|
1522 | QDomElement tag = findSubTag(p_sound, "onevent", &found);
|
---|
1523 | if(found) {
|
---|
1524 | readEntry(tag, "message", &prefs.onevent[eMessage]);
|
---|
1525 | readEntry(tag, "chat1", &prefs.onevent[eChat1]);
|
---|
1526 | readEntry(tag, "chat2", &prefs.onevent[eChat2]);
|
---|
1527 | readEntry(tag, "system", &prefs.onevent[eSystem]);
|
---|
1528 | readEntry(tag, "headline", &prefs.onevent[eHeadline]);
|
---|
1529 | readEntry(tag, "online", &prefs.onevent[eOnline]);
|
---|
1530 | readEntry(tag, "offline", &prefs.onevent[eOffline]);
|
---|
1531 | readEntry(tag, "send", &prefs.onevent[eSend]);
|
---|
1532 | readEntry(tag, "incoming_ft", &prefs.onevent[eIncomingFT]);
|
---|
1533 | readEntry(tag, "ft_complete", &prefs.onevent[eFTComplete]);
|
---|
1534 | }
|
---|
1535 | }
|
---|
1536 |
|
---|
1537 | QDomElement p_sizes = findSubTag(p, "sizes", &found);
|
---|
1538 | if(found) {
|
---|
1539 | readSizeEntry(p_sizes, "eventdlg", &prefs.sizeEventDlg);
|
---|
1540 | readSizeEntry(p_sizes, "chatdlg", &prefs.sizeChatDlg);
|
---|
1541 | readSizeEntry(p_sizes, "tabdlg", &prefs.sizeTabDlg);
|
---|
1542 | }
|
---|
1543 |
|
---|
1544 |
|
---|
1545 | QDomElement p_toolbars = findSubTag(p, "toolbars", &found);
|
---|
1546 | if (found) {
|
---|
1547 | QStringList goodTags;
|
---|
1548 | goodTags << "toolbar";
|
---|
1549 | goodTags << "mainWin";
|
---|
1550 |
|
---|
1551 | bool mainWinCleared = false;
|
---|
1552 | bool oldStyle = true;
|
---|
1553 |
|
---|
1554 | for(QDomNode n = p_toolbars.firstChild(); !n.isNull(); n = n.nextSibling()) {
|
---|
1555 | QDomElement e = n.toElement();
|
---|
1556 | if( e.isNull() )
|
---|
1557 | continue;
|
---|
1558 |
|
---|
1559 | QString tbGroup;
|
---|
1560 | bool isGood = false;
|
---|
1561 | QStringList::Iterator it = goodTags.begin();
|
---|
1562 | for ( ; it != goodTags.end(); ++it ) {
|
---|
1563 | if ( e.tagName().left( (*it).length() ) == *it ) {
|
---|
1564 | isGood = true;
|
---|
1565 |
|
---|
1566 | if ( e.tagName().left(7) == "toolbar" )
|
---|
1567 | tbGroup = "mainWin";
|
---|
1568 | else {
|
---|
1569 | tbGroup = *it;
|
---|
1570 | oldStyle = false;
|
---|
1571 | }
|
---|
1572 |
|
---|
1573 | break;
|
---|
1574 | }
|
---|
1575 | }
|
---|
1576 |
|
---|
1577 | if ( isGood ) {
|
---|
1578 | if ( tbGroup != "mainWin" || !mainWinCleared ) {
|
---|
1579 | prefs.toolbars[tbGroup].clear();
|
---|
1580 | if ( tbGroup == "mainWin" )
|
---|
1581 | mainWinCleared = true;
|
---|
1582 | }
|
---|
1583 |
|
---|
1584 | if ( oldStyle ) {
|
---|
1585 | Options::ToolbarPrefs tb = loadToolbarData( e );
|
---|
1586 | prefs.toolbars[tbGroup].append(tb);
|
---|
1587 | }
|
---|
1588 | else {
|
---|
1589 | for(QDomNode nn = e.firstChild(); !nn.isNull(); nn = nn.nextSibling()) {
|
---|
1590 | QDomElement ee = nn.toElement();
|
---|
1591 | if( ee.isNull() )
|
---|
1592 | continue;
|
---|
1593 |
|
---|
1594 | if ( ee.tagName() == "toolbar" ) {
|
---|
1595 | Options::ToolbarPrefs tb = loadToolbarData( ee );
|
---|
1596 | prefs.toolbars[tbGroup].append(tb);
|
---|
1597 | }
|
---|
1598 | }
|
---|
1599 | }
|
---|
1600 | }
|
---|
1601 | }
|
---|
1602 |
|
---|
1603 | // event notifier in these versions was not implemented as an action, so add it
|
---|
1604 | if ( progver == "0.9" || progver == "0.9-CVS" ) {
|
---|
1605 | // at first, we need to scan the options, to determine, whether event_notifier already available
|
---|
1606 | bool found = false;
|
---|
1607 | QValueList<Options::ToolbarPrefs>::Iterator it = prefs.toolbars["mainWin"].begin();
|
---|
1608 | for ( ; it != prefs.toolbars["mainWin"].end(); ++it) {
|
---|
1609 | QStringList::Iterator it2 = (*it).keys.begin();
|
---|
1610 | for ( ; it2 != (*it).keys.end(); ++it2) {
|
---|
1611 | if ( *it2 == "event_notifier" ) {
|
---|
1612 | found = true;
|
---|
1613 | break;
|
---|
1614 | }
|
---|
1615 | }
|
---|
1616 | }
|
---|
1617 |
|
---|
1618 | if ( !found ) {
|
---|
1619 | Options::ToolbarPrefs tb;
|
---|
1620 | tb.name = QObject::tr("Event notifier");
|
---|
1621 | tb.on = false;
|
---|
1622 | tb.locked = true;
|
---|
1623 | tb.stretchable = true;
|
---|
1624 | tb.keys << "event_notifier";
|
---|
1625 | tb.dock = Qt::DockBottom;
|
---|
1626 | tb.index = 0;
|
---|
1627 | prefs.toolbars["mainWin"].append(tb);
|
---|
1628 | }
|
---|
1629 | }
|
---|
1630 | }
|
---|
1631 |
|
---|
1632 | //group chat
|
---|
1633 | QDomElement p_groupchat = findSubTag(p, "groupchat", &found);
|
---|
1634 | if (found) {
|
---|
1635 | readBoolEntry(p_groupchat, "nickcoloring", &prefs.gcNickColoring);
|
---|
1636 | readBoolEntry(p_groupchat, "highlighting", &prefs.gcHighlighting);
|
---|
1637 | xmlToStringList(p_groupchat, "highlightwords", &prefs.gcHighlights);
|
---|
1638 | xmlToStringList(p_groupchat, "nickcolors", &prefs.gcNickColors);
|
---|
1639 | }
|
---|
1640 |
|
---|
1641 | // Bouncing dock icon (Mac OS X)
|
---|
1642 | QDomElement p_dock = findSubTag(p, "dock", &found);
|
---|
1643 | if(found) {
|
---|
1644 | if (p_dock.attribute("bounce") == "once") {
|
---|
1645 | prefs.bounceDock = Options::BounceOnce;
|
---|
1646 | }
|
---|
1647 | else if (p_dock.attribute("bounce") == "forever") {
|
---|
1648 | prefs.bounceDock = Options::BounceForever;
|
---|
1649 | }
|
---|
1650 | else if (p_dock.attribute("bounce") == "never") {
|
---|
1651 | prefs.bounceDock = Options::NoBounce;
|
---|
1652 | }
|
---|
1653 | }
|
---|
1654 |
|
---|
1655 | QDomElement p_popup = findSubTag(p, "popups", &found);
|
---|
1656 | if(found) {
|
---|
1657 | readBoolEntry(p_popup, "on", &prefs.ppIsOn);
|
---|
1658 | readBoolEntry(p_popup, "online", &prefs.ppOnline);
|
---|
1659 | readBoolEntry(p_popup, "offline", &prefs.ppOffline);
|
---|
1660 | readBoolEntry(p_popup, "statusChange", &prefs.ppStatus);
|
---|
1661 | readBoolEntry(p_popup, "message", &prefs.ppMessage);
|
---|
1662 | readBoolEntry(p_popup, "chat", &prefs.ppChat);
|
---|
1663 | readBoolEntry(p_popup, "headline", &prefs.ppHeadline);
|
---|
1664 | readBoolEntry(p_popup, "file", &prefs.ppFile);
|
---|
1665 | readNumEntry(p_popup, "jidClip", &prefs.ppJidClip);
|
---|
1666 | readNumEntry(p_popup, "statusClip", &prefs.ppStatusClip);
|
---|
1667 | readNumEntry(p_popup, "textClip", &prefs.ppTextClip);
|
---|
1668 | readNumEntry(p_popup, "hideTime", &prefs.ppHideTime);
|
---|
1669 | readColorEntry(p_popup, "borderColor", &prefs.ppBorderColor);
|
---|
1670 | }
|
---|
1671 |
|
---|
1672 | QDomElement p_lockdown = findSubTag(p, "lockdown", &found);
|
---|
1673 | if(found) {
|
---|
1674 | readBoolEntry(p_lockdown, "roster", &prefs.lockdown.roster);
|
---|
1675 | readBoolEntry(p_lockdown, "options", &prefs.lockdown.options);
|
---|
1676 | readBoolEntry(p_lockdown, "profiles", &prefs.lockdown.profiles);
|
---|
1677 | readBoolEntry(p_lockdown, "services", &prefs.lockdown.services);
|
---|
1678 | readBoolEntry(p_lockdown, "accounts", &prefs.lockdown.accounts);
|
---|
1679 | }
|
---|
1680 |
|
---|
1681 | QDomElement p_iconset = findSubTag(p, "iconset", &found);
|
---|
1682 | if(found) {
|
---|
1683 | readEntry(p_iconset, "system", &prefs.systemIconset);
|
---|
1684 |
|
---|
1685 | QDomElement roster = findSubTag(p_iconset, "roster", &found);
|
---|
1686 | if (found) {
|
---|
1687 | readEntry(roster, "default", &prefs.defaultRosterIconset);
|
---|
1688 |
|
---|
1689 | QDomElement service = findSubTag(roster, "service", &found);
|
---|
1690 | if (found) {
|
---|
1691 | prefs.serviceRosterIconset.clear();
|
---|
1692 | for (QDomNode n = service.firstChild(); !n.isNull(); n = n.nextSibling()) {
|
---|
1693 | QDomElement i = n.toElement();
|
---|
1694 | if ( i.isNull() )
|
---|
1695 | continue;
|
---|
1696 |
|
---|
1697 | prefs.serviceRosterIconset[i.attribute("service")] = i.attribute("iconset");
|
---|
1698 | }
|
---|
1699 | }
|
---|
1700 |
|
---|
1701 | QDomElement custom = findSubTag(roster, "custom", &found);
|
---|
1702 | if (found) {
|
---|
1703 | prefs.customRosterIconset.clear();
|
---|
1704 | for (QDomNode n = custom.firstChild(); !n.isNull(); n = n.nextSibling()) {
|
---|
1705 | QDomElement i = n.toElement();
|
---|
1706 | if ( i.isNull() )
|
---|
1707 | continue;
|
---|
1708 |
|
---|
1709 | prefs.customRosterIconset[i.attribute("regExp")] = i.attribute("iconset");
|
---|
1710 | }
|
---|
1711 | }
|
---|
1712 | }
|
---|
1713 |
|
---|
1714 | QDomElement emoticons = findSubTag(p_iconset, "emoticons", &found);
|
---|
1715 | if (found) {
|
---|
1716 | prefs.emoticons.clear();
|
---|
1717 | for (QDomNode n = emoticons.firstChild(); !n.isNull(); n = n.nextSibling()) {
|
---|
1718 | QDomElement i = n.toElement();
|
---|
1719 | if ( i.isNull() )
|
---|
1720 | continue;
|
---|
1721 |
|
---|
1722 | if ( i.tagName() == "item" ) {
|
---|
1723 | QString is = i.text();
|
---|
1724 | prefs.emoticons << is;
|
---|
1725 | }
|
---|
1726 | }
|
---|
1727 | }
|
---|
1728 | }
|
---|
1729 |
|
---|
1730 | QDomElement p_tip = findSubTag(p, "tipOfTheDay", &found);
|
---|
1731 | if (found) {
|
---|
1732 | readBoolEntry(p_tip, "show", &prefs.showTips);
|
---|
1733 | readNumEntry(p_tip, "num", &prefs.tipNum);
|
---|
1734 | }
|
---|
1735 |
|
---|
1736 | QDomElement p_disco = findSubTag(p, "disco", &found);
|
---|
1737 | if (found) {
|
---|
1738 | readBoolEntry(p_disco, "items", &prefs.discoItems);
|
---|
1739 | readBoolEntry(p_disco, "info", &prefs.discoInfo);
|
---|
1740 | }
|
---|
1741 |
|
---|
1742 | QDomElement p_dt = findSubTag(p, "dt", &found);
|
---|
1743 | if (found) {
|
---|
1744 | readNumEntry(p_dt, "port", &prefs.dtPort);
|
---|
1745 | readEntry(p_dt, "external", &prefs.dtExternal);
|
---|
1746 | }
|
---|
1747 |
|
---|
1748 | QDomElement p_globalAccel = findSubTag(p, "globalAccel", &found);
|
---|
1749 | if (found) {
|
---|
1750 | QMap<QString, int> accelNames;
|
---|
1751 | accelNames["processNextEvent"] = 0;
|
---|
1752 | accelNames["showHideRoster"] = 1;
|
---|
1753 |
|
---|
1754 | for (QDomNode n = p_globalAccel.firstChild(); !n.isNull(); n = n.nextSibling()) {
|
---|
1755 | QDomElement i = n.toElement();
|
---|
1756 | if ( i.isNull() )
|
---|
1757 | continue;
|
---|
1758 |
|
---|
1759 | if ( i.tagName() == "command" && i.hasAttribute("type") ) {
|
---|
1760 | int n = accelNames[i.attribute("type")];
|
---|
1761 | prefs.globalAccels[n] = QKeySequence(i.text());
|
---|
1762 | }
|
---|
1763 | }
|
---|
1764 | }
|
---|
1765 |
|
---|
1766 | QDomElement p_advWidget = findSubTag(p, "advancedWidget", &found);
|
---|
1767 | if (found) {
|
---|
1768 | QDomElement stick = findSubTag(p_advWidget, "sticky", &found);
|
---|
1769 | if (found) {
|
---|
1770 | bool enabled, toWindows;
|
---|
1771 | int offs;
|
---|
1772 |
|
---|
1773 | readBoolAttribute(stick, "enabled", &enabled);
|
---|
1774 | readNumEntry(stick, "offset", &offs);
|
---|
1775 | readBoolEntry(stick, "stickToWindows", &toWindows);
|
---|
1776 |
|
---|
1777 | GAdvancedWidget::setStickEnabled( enabled );
|
---|
1778 | GAdvancedWidget::setStickAt( offs );
|
---|
1779 | GAdvancedWidget::setStickToWindows( toWindows );
|
---|
1780 | }
|
---|
1781 | }
|
---|
1782 | }
|
---|
1783 |
|
---|
1784 | return TRUE;
|
---|
1785 | }
|
---|
1786 |
|
---|
1787 |
|
---|
1788 | QString pathToProfile(const QString &name)
|
---|
1789 | {
|
---|
1790 | return g.pathProfiles + "/" + name;
|
---|
1791 | }
|
---|
1792 |
|
---|
1793 | QString pathToProfileConfig(const QString &name)
|
---|
1794 | {
|
---|
1795 | return pathToProfile(name) + "/config.xml";
|
---|
1796 | }
|
---|
1797 |
|
---|
1798 | QStringList getProfilesList()
|
---|
1799 | {
|
---|
1800 | QStringList list;
|
---|
1801 |
|
---|
1802 | QDir d(g.pathProfiles);
|
---|
1803 | if(!d.exists())
|
---|
1804 | return list;
|
---|
1805 |
|
---|
1806 | QStringList entries = d.entryList();
|
---|
1807 | for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
|
---|
1808 | if(*it == "." || *it == "..")
|
---|
1809 | continue;
|
---|
1810 | QFileInfo info(d, *it);
|
---|
1811 | if(!info.isDir())
|
---|
1812 | continue;
|
---|
1813 |
|
---|
1814 | list.append(*it);
|
---|
1815 | }
|
---|
1816 |
|
---|
1817 | list.sort();
|
---|
1818 |
|
---|
1819 | return list;
|
---|
1820 | }
|
---|
1821 |
|
---|
1822 | bool profileExists(const QString &_name)
|
---|
1823 | {
|
---|
1824 | QString name = _name.lower();
|
---|
1825 |
|
---|
1826 | QStringList list = getProfilesList();
|
---|
1827 | for(QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) {
|
---|
1828 | if((*it).lower() == name)
|
---|
1829 | return TRUE;
|
---|
1830 | }
|
---|
1831 | return FALSE;
|
---|
1832 | }
|
---|
1833 |
|
---|
1834 | bool profileNew(const QString &name)
|
---|
1835 | {
|
---|
1836 | if(name.isEmpty())
|
---|
1837 | return FALSE;
|
---|
1838 |
|
---|
1839 | // verify the string is sane
|
---|
1840 | for(int n = 0; n < (int)name.length(); ++n) {
|
---|
1841 | if(!name.at(n).isLetterOrNumber())
|
---|
1842 | return FALSE;
|
---|
1843 | }
|
---|
1844 |
|
---|
1845 | // make it
|
---|
1846 | QDir d(g.pathProfiles);
|
---|
1847 | if(!d.exists())
|
---|
1848 | return FALSE;
|
---|
1849 | QDir p(g.pathProfiles + "/" + name);
|
---|
1850 | if(!p.exists()) {
|
---|
1851 | d.mkdir(name);
|
---|
1852 | if(!p.exists())
|
---|
1853 | return FALSE;
|
---|
1854 | }
|
---|
1855 |
|
---|
1856 | p.mkdir("history");
|
---|
1857 | p.mkdir("vcard");
|
---|
1858 |
|
---|
1859 | return TRUE;
|
---|
1860 | }
|
---|
1861 |
|
---|
1862 | bool profileRename(const QString &oldname, const QString &name)
|
---|
1863 | {
|
---|
1864 | // verify the string is sane
|
---|
1865 | for(int n = 0; n < (int)name.length(); ++n) {
|
---|
1866 | if(!name.at(n).isLetterOrNumber())
|
---|
1867 | return FALSE;
|
---|
1868 | }
|
---|
1869 |
|
---|
1870 | // locate the folder
|
---|
1871 | QDir d(g.pathProfiles);
|
---|
1872 | if(!d.exists())
|
---|
1873 | return FALSE;
|
---|
1874 | if(!d.rename(oldname, name))
|
---|
1875 | return FALSE;
|
---|
1876 |
|
---|
1877 | return TRUE;
|
---|
1878 | }
|
---|
1879 |
|
---|
1880 | static bool folderRemove(const QDir &_d)
|
---|
1881 | {
|
---|
1882 | QDir d = _d;
|
---|
1883 |
|
---|
1884 | QStringList entries = d.entryList();
|
---|
1885 | for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
|
---|
1886 | if(*it == "." || *it == "..")
|
---|
1887 | continue;
|
---|
1888 | QFileInfo info(d, *it);
|
---|
1889 | if(info.isDir()) {
|
---|
1890 | if(!folderRemove(QDir(info.filePath())))
|
---|
1891 | return FALSE;
|
---|
1892 | }
|
---|
1893 | else {
|
---|
1894 | //printf("deleting [%s]\n", info.filePath().latin1());
|
---|
1895 | d.remove(info.fileName());
|
---|
1896 | }
|
---|
1897 | }
|
---|
1898 | QString name = d.dirName();
|
---|
1899 | if(!d.cdUp())
|
---|
1900 | return FALSE;
|
---|
1901 | //printf("removing folder [%s]\n", d.filePath(name).latin1());
|
---|
1902 | d.rmdir(name);
|
---|
1903 |
|
---|
1904 | return TRUE;
|
---|
1905 | }
|
---|
1906 |
|
---|
1907 | bool profileDelete(const QString &path)
|
---|
1908 | {
|
---|
1909 | QDir d(path);
|
---|
1910 | if(!d.exists())
|
---|
1911 | return TRUE;
|
---|
1912 |
|
---|
1913 | return folderRemove(QDir(path));
|
---|
1914 | }
|
---|