188
191
delete iconSelect;
191
void saveProfile(UserAccountList acc = UserAccountList())
194
void saveProfile(UserAccountList acc)
193
pro.recentGCList = recentGCList;
194
pro.recentBrowseList = recentBrowseList;
195
pro.lastStatusString = lastStatusString;
196
pro.useSound = useSound;
199
pro.proxyList = proxy->itemList();
204
pro.toFile(pathToProfileConfig(activeProfile));
197
accountTree.removeOption("accounts", true);
198
// save accounts with known base
199
QSet<QString> cbases;
200
foreach(UserAccount ua, acc) {
201
if (!ua.optionsBase.isEmpty()) {
202
ua.toOptions(&accountTree);
203
cbases += ua.optionsBase;
208
foreach(UserAccount ua, acc) {
209
if (ua.optionsBase.isEmpty()) {
212
base = "accounts.a"+QString::number(idx++);
213
} while (cbases.contains(base));
215
ua.toOptions(&accountTree, base);
218
QFile accountsFile(pathToProfile( activeProfile ) + "/accounts.xml");
219
accountTree.saveOptions(accountsFile.fileName(), "accounts", ApplicationInfo::optionsNS(), ApplicationInfo::version());;
207
224
void updateIconSelect()
291
320
connect(d->contactList, SIGNAL(accountActivityChanged()), SIGNAL(accountActivityChanged()));
292
321
connect(d->contactList, SIGNAL(saveAccounts()), SLOT(saveAccounts()));
323
// do some backuping in case we are about to start migration from config.xml+options.xml
324
// to options.xml only.
325
QString backupfile = optionsFile() + "-preOptionsMigration";
326
if (QFile::exists(pathToProfileConfig(activeProfile))
327
&& QFile::exists(optionsFile())
328
&& !QFile::exists(backupfile)) {
329
QFile::copy(optionsFile(), backupfile);
333
GAdvancedWidget::setStickEnabled( false ); //until this is bugless
334
GAdvancedWidget::setStickToWindows( false ); //again
335
GAdvancedWidget::setStickAt( 5 );
294
338
// To allow us to upgrade from old hardcoded options gracefully, be careful about the order here
295
339
PsiOptions *options=PsiOptions::instance();
296
340
//load the system-wide defaults, if they exist
304
348
d->tuneController = new CombinedTuneController();
351
// calculate the small font size
352
const int minimumFontSize = 7;
353
common_smallFontSize = qApp->font().pointSize();
354
common_smallFontSize -= 2;
355
if ( common_smallFontSize < minimumFontSize )
356
common_smallFontSize = minimumFontSize;
357
FancyLabel::setSmallFontSize( common_smallFontSize );
360
if (!QFile::exists(optionsFile()) && !QFile::exists(pathToProfileConfig(activeProfile))) {
361
if (!options->load(":/options/newprofile.xml")) {
362
qWarning("ERROR: Failed to new profile default options");
307
366
// load the old profile
309
d->pro.fromFile(pathToProfileConfig(activeProfile));
367
d->optionsMigration.fromFile(pathToProfileConfig(activeProfile));
311
369
//load the new profile
312
QString optionsFile=pathToProfile( activeProfile );
313
optionsFile += "/options.xml";
314
options->load(optionsFile);
315
370
//Save every time an option is changed
316
options->autoSave(true, optionsFile);
371
options->load(optionsFile());
372
options->autoSave(true, optionsFile());
318
374
//just set a dummy option to trigger saving
319
375
options->setOption("trigger-save",false);
320
376
options->setOption("trigger-save",true);
322
connect(options, SIGNAL(optionChanged(const QString&)), SLOT(optionsUpdate()));
378
// do some late migration work
379
d->optionsMigration.lateMigration();
381
QFile accountsFile(pathToProfile( activeProfile ) + "/accounts.xml");
382
bool accountMigration = false;
383
if (!accountsFile.exists()) {
384
accountMigration = true;
386
foreach(UserAccount a, d->optionsMigration.accMigration) {
387
QString base = "accounts.a"+QString::number(idx++);
388
a.toOptions(&d->accountTree, base);
391
d->accountTree.loadOptions(accountsFile.fileName(), "accounts", ApplicationInfo::optionsNS());
395
d->proxy = new ProxyManager(&d->accountTree, this);
396
if (accountMigration) d->proxy->migrateItemList(d->optionsMigration.proxyMigration);
397
connect(d->proxy, SIGNAL(settingsChanged()), SLOT(proxy_settingsChanged()));
399
connect(options, SIGNAL(optionChanged(const QString&)), SLOT(optionChanged(const QString&)));
324
401
QDir profileDir( pathToProfile( activeProfile ) );
325
402
profileDir.rmdir( "info" ); // remove unused dir
327
d->recentGCList = d->pro.recentGCList;
328
d->recentBrowseList = d->pro.recentBrowseList;
329
d->lastStatusString = d->pro.lastStatusString;
330
useSound = d->pro.useSound;
332
option = d->pro.prefs;
404
d->iconSelect = new IconSelectPopup(0);
405
connect(PsiIconset::instance(), SIGNAL(emoticonsChanged()), d, SLOT(updateIconSelect()));
334
407
// first thing, try to load the iconset
335
408
if( !PsiIconset::instance()->loadAll() ) {
336
//option.iconset = "stellar";
337
//if(!is.load(option.iconset)) {
409
//LEGOPTS.iconset = "stellar";
410
//if(!is.load(LEGOPTS.iconset)) {
338
411
QMessageBox::critical(0, tr("Error"), tr("Unable to load iconset! Please make sure Psi is properly installed."));
364
434
connect(d->mainwin, SIGNAL(doToolbars()), SLOT(doToolbars()));
365
435
connect(d->mainwin, SIGNAL(doFileTransDlg()), SLOT(doFileTransDlg()));
366
436
connect(d->mainwin, SIGNAL(recvNextEvent()), SLOT(recvNextEvent()));
367
connect(d->mainwin, SIGNAL(geomChanged(QRect)), SLOT(mainWinGeomChanged(QRect)));
368
437
connect(this, SIGNAL(emitOptionsUpdate()), d->mainwin, SLOT(optionsUpdate()));
370
439
connect(this, SIGNAL(emitOptionsUpdate()), d->mainwin->cvlist, SLOT(optionsUpdate()));
372
d->mainwin->restoreSavedGeometry(d->pro.mwgeom);
373
d->mwgeom = d->pro.mwgeom;
441
d->mainwin->setGeometryOptionPath("options.ui.contactlist.saved-window-geometry");
375
if(!(option.useDock && option.dockHideMW))
443
if(!(PsiOptions::instance()->getOption("options.ui.systemtray.enable").toBool() && PsiOptions::instance()->getOption("options.contactlist.hide-on-start").toBool()))
376
444
d->mainwin->show();
378
446
d->ftwin = new FileTransDlg(this);
383
451
d->s5bServer = new S5BServer;
387
d->proxy = new ProxyManager(this);
388
d->proxy->setItemList(d->pro.proxyList);
389
connect(d->proxy, SIGNAL(settingsChanged()), SLOT(proxy_settingsChanged()));
391
// Disable accounts if necessary, and overwrite locked properties
392
if (PsiOptions::instance()->getOption("options.ui.account.single").toBool() || !PsiOptions::instance()->getOption("options.account.domain").toString().isEmpty()) {
393
bool haveEnabled = false;
394
for(UserAccountList::Iterator it = d->pro.acc.begin(); it != d->pro.acc.end(); ++it) {
395
// With single accounts, only modify the first account
396
if (PsiOptions::instance()->getOption("options.ui.account.single").toBool()) {
398
haveEnabled = it->opt_enabled;
399
if (it->opt_enabled) {
400
if (!PsiOptions::instance()->getOption("options.account.domain").toString().isEmpty())
401
it->jid = JIDUtil::accountFromString(Jid(it->jid).user()).bare();
405
it->opt_enabled = false;
408
// Overwirte locked properties
409
if (!PsiOptions::instance()->getOption("options.account.domain").toString().isEmpty())
410
it->jid = JIDUtil::accountFromString(Jid(it->jid).user()).bare();
415
454
// Connect to the system monitor
416
455
SystemWatch* sw = SystemWatch::instance();
417
456
connect(sw, SIGNAL(sleep()), this, SLOT(doSleep()));
425
464
// Global shortcuts
428
// Entity capabilities
429
CapsRegistry::instance()->setFile(ApplicationInfo::homeDir() + "/caps.xml");
433
469
#warning "Temporary hard-coding caps registration of own version"
435
471
// client()->identity()
436
DiscoItem::Identity identity = { "client", ApplicationInfo::name(), "pc" };
437
DiscoItem::Identities identities;
438
identities += identity;
439
QStringList features;
440
features << "http://jabber.org/protocol/bytestreams"
441
<< "http://jabber.org/protocol/si"
442
<< "http://jabber.org/protocol/si/profile/file-transfer"
443
<< "http://jabber.org/protocol/disco#info"
444
<< "http://jabber.org/protocol/commands"
445
<< "http://jabber.org/protocol/rosterx"
446
<< "http://jabber.org/protocol/muc"
448
CapsRegistry::instance()->registerCaps(CapsSpec(ApplicationInfo::capsNode(),ApplicationInfo::capsVersion(),ApplicationInfo::capsVersion()),identities,Features(features));
449
CapsRegistry::instance()->registerCaps(CapsSpec(ApplicationInfo::capsNode(),ApplicationInfo::capsVersion(),"cs"),identities,Features("http://jabber.org/protocol/chatstates"));
451
features << "http://jabber.org/protocol/mood"
452
<< "http://jabber.org/protocol/tune"
453
<< "http://jabber.org/protocol/physloc"
454
<< "http://jabber.org/protocol/geoloc"
455
<< "http://www.xmpp.org/extensions/xep-0084.html#ns-data"
456
<< "http://www.xmpp.org/extensions/xep-0084.html#ns-metadata";
457
CapsRegistry::instance()->registerCaps(CapsSpec(ApplicationInfo::capsNode(),ApplicationInfo::capsVersion(),"ep"),identities,features);
459
features << "http://jabber.org/protocol/mood+notify"
460
<< "http://jabber.org/protocol/tune+notify"
461
<< "http://jabber.org/protocol/physloc+notify"
462
<< "http://jabber.org/protocol/geoloc+notify"
463
<< "http://www.xmpp.org/extensions/xep-0084.html#ns-metadata+notify";
464
CapsRegistry::instance()->registerCaps(CapsSpec(ApplicationInfo::capsNode(),ApplicationInfo::capsVersion(),"ep-notify"),identities,features);
465
CapsRegistry::instance()->registerCaps(CapsSpec(ApplicationInfo::capsNode(),ApplicationInfo::capsVersion(),"html"),identities,Features("http://jabber.org/protocol/xhtml-im"));
473
registerCaps(ApplicationInfo::capsVersion(), QStringList()
474
<< "http://jabber.org/protocol/bytestreams"
475
<< "http://jabber.org/protocol/si"
476
<< "http://jabber.org/protocol/si/profile/file-transfer"
477
<< "http://jabber.org/protocol/disco#info"
478
<< "http://jabber.org/protocol/commands"
479
<< "http://jabber.org/protocol/rosterx"
480
<< "http://jabber.org/protocol/muc"
484
registerCaps("ep", QStringList()
485
<< "http://jabber.org/protocol/mood"
486
<< "http://jabber.org/protocol/tune"
487
<< "http://jabber.org/protocol/physloc"
488
<< "http://jabber.org/protocol/geoloc"
489
<< "http://www.xmpp.org/extensions/xep-0084.html#ns-data"
490
<< "http://www.xmpp.org/extensions/xep-0084.html#ns-metadata"
493
registerCaps("ep-notify", QStringList()
494
<< "http://jabber.org/protocol/mood+notify"
495
<< "http://jabber.org/protocol/tune+notify"
496
<< "http://jabber.org/protocol/physloc+notify"
497
<< "http://jabber.org/protocol/geoloc+notify"
498
<< "http://www.xmpp.org/extensions/xep-0084.html#ns-metadata+notify"
501
registerCaps("html", QStringList("http://jabber.org/protocol/xhtml-im"));
502
registerCaps("cs", QStringList("http://jabber.org/protocol/chatstates"));
503
//I've commented out the automatic replies, so commenting out support as well - KIS
504
registerCaps("mr", QStringList("urn:xmpp:receipts"));
469
d->contactList->loadAccounts(d->pro.acc);
508
QList<UserAccount> accs;
509
QStringList bases = d->accountTree.getChildOptionNames("accounts", true, true);
510
foreach (QString base, bases) {
512
ua.fromOptions(&d->accountTree, base);
516
// Disable accounts if necessary, and overwrite locked properties
517
if (PsiOptions::instance()->getOption("options.ui.account.single").toBool() || !PsiOptions::instance()->getOption("options.account.domain").toString().isEmpty()) {
518
bool haveEnabled = false;
519
for(UserAccountList::Iterator it = accs.begin(); it != accs.end(); ++it) {
520
// With single accounts, only modify the first account
521
if (PsiOptions::instance()->getOption("options.ui.account.single").toBool()) {
523
haveEnabled = it->opt_enabled;
524
if (it->opt_enabled) {
525
if (!PsiOptions::instance()->getOption("options.account.domain").toString().isEmpty())
526
it->jid = JIDUtil::accountFromString(Jid(it->jid).user()).bare();
530
it->opt_enabled = false;
533
// Overwirte locked properties
534
if (!PsiOptions::instance()->getOption("options.account.domain").toString().isEmpty())
535
it->jid = JIDUtil::accountFromString(Jid(it->jid).user()).bare();
540
d->contactList->loadAccounts(accs);
470
543
checkAccountsEmpty();
471
546
// try autologin if needed
472
547
foreach(PsiAccount* account, d->contactList->accounts()) {
473
548
account->autoLogin();
476
551
// show tip of the day
477
if ( PsiOptions::instance()->getOption("options.ui.tip.show").toBool() )
552
if ( PsiOptions::instance()->getOption("options.ui.tip.show").toBool() ) {
478
553
TipDlg::show(this);
557
addPsiConAdapter(this);
560
connect(ActiveProfiles::instance(), SIGNAL(raiseMainWindow()), SLOT(raiseMainwin()));
565
void PsiCon::registerCaps(const QString& ext, const QStringList& features)
567
DiscoItem::Identity identity = { "client", ApplicationInfo::name(), "pc" };
568
DiscoItem::Identities identities;
569
identities += identity;
571
d->capsRegistry->registerCaps(CapsSpec(ApplicationInfo::capsNode(),
572
ApplicationInfo::capsVersion(), ext),
483
577
void PsiCon::deinit()
485
579
// this deletes all dialogs except for mainwin
663
750
return d->defaultMenuBar;
666
TabDlg* PsiCon::newTabs()
669
tab=new TabDlg(this);
671
connect (tab, SIGNAL ( isDying(TabDlg*) ), SLOT ( tabDying(TabDlg*) ) );
672
connect(this, SIGNAL(emitOptionsUpdate()), tab, SLOT(optionsUpdate()));
676
TabDlg* PsiCon::getTabs()
678
if (!d->tabs.isEmpty())
680
return d->tabs.getFirst();
688
void PsiCon::tabDying(TabDlg* tab)
693
bool PsiCon::isChatTabbed(ChatDlg* chat)
695
for (uint i = 0; i < d->tabs.count(); ++i)
697
if ( d->tabs.at(i)->managesChat(chat) )
703
ChatDlg* PsiCon::getChatInTabs(QString jid){
704
for (uint i = 0; i < d->tabs.count(); ++i)
706
if ( d->tabs.at(i)->getChatPointer(jid) )
707
return d->tabs.at(i)->getChatPointer(jid);
713
TabDlg* PsiCon::getManagingTabs(ChatDlg* chat)
715
for (uint i = 0; i < d->tabs.count(); ++i)
717
if ( d->tabs.at(i)->managesChat(chat) )
718
return d->tabs.at(i);
724
Q3PtrList<TabDlg>* PsiCon::getTabSets()
729
bool PsiCon::isChatActiveWindow(ChatDlg* chat)
731
//returns true if chat is on top of a tab pile
732
if ( chat->isHidden() )
738
return chat->isActiveWindow();
740
for (uint i = 0; i < d->tabs.count(); ++i)
742
if ( d->tabs.at(i)->isActiveWindow() )
744
if ( d->tabs.at(i)->chatOnTop( chat ) )
753
754
void PsiCon::dialogRegister(QWidget *w)
778
779
delete i->widget;
782
d->tabManager->deleteAll();
784
785
AccountsComboBox *PsiCon::accountsComboBox(QWidget *parent, bool online_only)
786
AccountsComboBox *acb = new AccountsComboBox(this, parent, online_only);
787
AccountsComboBox* acb = new AccountsComboBox(parent);
788
acb->setController(this);
789
acb->setOnlineOnly(online_only);
790
void PsiCon::createAccount(const QString &name, const Jid &j, const QString &pass, bool opt_host, const QString &host, int port, bool legacy_ssl_probe, UserAccount::SSLFlag ssl, int proxy)
793
void PsiCon::createAccount(const QString &name, const Jid &j, const QString &pass, bool opt_host, const QString &host, int port, bool legacy_ssl_probe, UserAccount::SSLFlag ssl, QString proxy)
792
795
d->contactList->createAccount(name, j, pass, opt_host, host, port, legacy_ssl_probe, ssl, proxy);
795
798
PsiAccount *PsiCon::createAccount(const UserAccount& acc)
797
PsiAccount *pa = new PsiAccount(acc, d->contactList);
800
PsiAccount *pa = new PsiAccount(acc, d->contactList, d->capsRegistry, d->tabManager);
798
801
connect(&d->idle, SIGNAL(secondsIdle(int)), pa, SLOT(secondsIdle(int)));
799
802
connect(pa, SIGNAL(updatedActivity()), SLOT(pa_updatedActivity()));
800
803
connect(pa, SIGNAL(updatedAccount()), SLOT(pa_updatedAccount()));
801
804
connect(pa, SIGNAL(queueChanged()), SLOT(queueChanged()));
805
connect(pa, SIGNAL(startBounce()), SLOT(startBounce()));
803
807
pa->client()->s5bManager()->setServer(d->s5bServer);
812
817
void PsiCon::statusMenuChanged(int x)
814
if(x == STATUS_OFFLINE && !option.askOffline) {
815
setGlobalStatus(Status("","Logged out",0,false));
816
if(option.useDock == true)
817
d->mainwin->setTrayToolTip(Status("","",0,false));
819
if(x == STATUS_OFFLINE && !PsiOptions::instance()->getOption("options.status.ask-for-message-on-offline").toBool()) {
820
setGlobalStatus(Status(Status::Offline, "Logged out", 0));
821
if(PsiOptions::instance()->getOption("options.ui.systemtray.enable").toBool() == true)
822
d->mainwin->setTrayToolTip(Status(Status::Offline, "", 0));
820
if(x == STATUS_ONLINE && !option.askOnline) {
825
if(x == STATUS_ONLINE && !PsiOptions::instance()->getOption("options.status.ask-for-message-on-online").toBool()) {
821
826
setGlobalStatus(Status());
822
if(option.useDock == true)
827
if(PsiOptions::instance()->getOption("options.ui.systemtray.enable").toBool() == true)
823
828
d->mainwin->setTrayToolTip(Status());
825
830
else if(x == STATUS_INVISIBLE){
826
831
Status s("","",0,true);
827
832
s.setIsInvisible(true);
828
833
setGlobalStatus(s);
829
if(option.useDock == true)
834
if(PsiOptions::instance()->getOption("options.ui.systemtray.enable").toBool() == true)
830
835
d->mainwin->setTrayToolTip(s);
833
838
// Create a dialog with the last status message
834
StatusSetDlg *w = new StatusSetDlg(this, makeStatus(x, d->lastStatusString));
839
StatusSetDlg *w = new StatusSetDlg(this, makeStatus(x, PsiOptions::instance()->getOption("options.status.last-message").toString()));
835
840
connect(w, SIGNAL(set(const XMPP::Status &, bool)), SLOT(setStatusFromDialog(const XMPP::Status &, bool)));
836
841
connect(w, SIGNAL(cancelled()), SLOT(updateMainwinStatus()));
837
if(option.useDock == true)
842
if(PsiOptions::instance()->getOption("options.ui.systemtray.enable").toBool() == true)
838
843
connect(w, SIGNAL(set(const XMPP::Status &, bool)), d->mainwin, SLOT(setTrayToolTip(const XMPP::Status &, bool)));
919
void PsiCon::setToggles(bool tog_offline, bool tog_away, bool tog_agents, bool tog_hidden, bool tog_self)
921
if(d->contactList->enabledAccounts().count() > 1)
924
d->mainwin->cvlist->setShowOffline(tog_offline);
925
d->mainwin->cvlist->setShowAway(tog_away);
926
d->mainwin->cvlist->setShowAgents(tog_agents);
927
d->mainwin->cvlist->setShowHidden(tog_hidden);
928
d->mainwin->cvlist->setShowSelf(tog_self);
931
void PsiCon::getToggles(bool *tog_offline, bool *tog_away, bool *tog_agents, bool *tog_hidden, bool *tog_self)
933
*tog_offline = d->mainwin->cvlist->isShowOffline();
934
*tog_away = d->mainwin->cvlist->isShowAway();
935
*tog_agents = d->mainwin->cvlist->isShowAgents();
936
*tog_hidden = d->mainwin->cvlist->isShowHidden();
937
*tog_self = d->mainwin->cvlist->isShowSelf();
940
926
void PsiCon::doOptions()
942
928
OptionsDlg *w = (OptionsDlg *)dialogFind("OptionsDlg");
946
w = new OptionsDlg(this, option);
947
connect(w, SIGNAL(applyOptions(const Options &)), SLOT(slotApplyOptions(const Options &)));
932
w = new OptionsDlg(this);
933
connect(w, SIGNAL(applyOptions()), SLOT(slotApplyOptions()));
957
943
void PsiCon::checkAccountsEmpty()
959
if (d->pro.acc.count() == 0) {
945
if (d->contactList->accounts().count() == 0) {
960
946
promptUserToCreateAccount();
950
void PsiCon::doOpenUri(const QUrl &uriToOpen)
955
QUrl uri(uriToOpen); // got to copy, because setQueryDelimiters() is not const
957
qWarning("uri: " + uri.toString());
961
if (uri.scheme() != "xmpp") { // try handling legacy URIs
962
QMessageBox::warning(0, tr("Warning"), QString("URI (link) type \"%1\" is unsupported.").arg(uri.scheme()));
968
if (uri.authority().isEmpty()) {
969
pa = d->contactList->defaultAccount();
971
QMessageBox::warning(0, tr("Warning"), QString("You don't have any account enabled."));
975
qWarning("uri auth: [" + uri.authority() + "]");
977
Jid authJid = JIDUtil::fromString(uri.authority());
978
foreach(PsiAccount* acc, d->contactList->enabledAccounts()) {
979
if (acc->jid().compare(authJid, false)) {
985
foreach(PsiAccount* acc, d->contactList->accounts()) {
986
if (acc->jid().compare(authJid, false)) {
987
QMessageBox::warning(0, tr("Warning"), QString("The account for %1 JID is disabled right now.").arg(authJid.bare()));
988
return; // FIX-ME: Should suggest enabling it now
993
QMessageBox::warning(0, tr("Warning"), QString("You don't have an account for %1.").arg(authJid.bare()));
1000
QString path = uri.path();
1001
if (path.startsWith('/')) // this happens when authority part is present
1003
Jid entity = JIDUtil::fromString(path);
1007
uri.setQueryDelimiters('=', ';');
1009
QString querytype = uri.queryItems().value(0).first; // defaults to empty string
1011
if (querytype == "message") {
1012
if (uri.queryItemValue("type") == "chat")
1013
pa->actionOpenChat(entity);
1015
pa->dj_newMessage(entity, uri.queryItemValue("body"), uri.queryItemValue("subject"), uri.queryItemValue("thread"));
1018
else if (querytype == "roster") {
1019
pa->openAddUserDlg(entity, uri.queryItemValue("name"), uri.queryItemValue("group"));
1021
else if (querytype == "join") {
1022
pa->actionJoin(entity, uri.queryItemValue("password"));
1024
else if (querytype == "vcard") {
1025
pa->actionInfo(entity);
1027
else if (querytype == "disco") {
1028
pa->actionDisco(entity, uri.queryItemValue("node"));
1031
pa->actionSendMessage(entity);
964
1035
void PsiCon::doToolbars()
966
1037
OptionsDlg *w = (OptionsDlg *)dialogFind("OptionsDlg");
969
1040
bringToFront(w);
972
w = new OptionsDlg(this, option);
973
connect(w, SIGNAL(applyOptions(const Options &)), SLOT(slotApplyOptions(const Options &)));
1043
w = new OptionsDlg(this);
1044
connect(w, SIGNAL(applyOptions()), SLOT(slotApplyOptions()));
974
1045
w->openTab("toolbars");
979
void PsiCon::slotApplyOptions(const Options &opt)
1050
void PsiCon::optionChanged(const QString& option)
981
Options oldOpt = option;
982
1052
bool notifyRestart = true;
1057
if (option == "options.ui.notifications.alert-style") {
1058
alertIconUpdateAlertStyle();
1061
if (option == "options.ui.tabs.use-tabs") {
1062
QMessageBox::information(0, tr("Information"), tr("Some of the options you changed will only have full effect upon restart."));
1063
notifyRestart = false;
1067
if (option == "options.p2p.bytestreams.listen-port") {
1072
void PsiCon::slotApplyOptions()
1074
PsiOptions *o = PsiOptions::instance();
1075
PsiIconset::instance()->reloadRoster();
986
1077
#ifndef Q_WS_MAC
987
if (option.hideMenubar) {
1078
if (!PsiOptions::instance()->getOption("options.ui.contactlist.show-menubar").toBool()) {
988
1079
// check if all toolbars are disabled
989
1080
bool toolbarsVisible = false;
990
QList<Options::ToolbarPrefs>::ConstIterator it = option.toolbars["mainWin"].begin();
991
for ( ; it != option.toolbars["mainWin"].end() && !toolbarsVisible; ++it) {
992
toolbarsVisible = toolbarsVisible || (*it).on;
1081
foreach(QString base, o->getChildOptionNames("options.ui.contactlist.toolbars", true, true)) {
1082
if (o->getOption( base + ".visible").toBool()) {
1083
toolbarsVisible = true;
995
1088
// Check whether it is legal to disable the menubar
996
1089
if ( !toolbarsVisible ) {
997
1090
QMessageBox::warning(0, tr("Warning"),
998
tr("You can not disable <i>all</i> toolbars <i>and</i> the menubar. If you do so, you will be unable to enable them back, when you'll change your mind.\n"
1000
"If you really-really want to disable all toolbars and the menubar, you need to edit the config.xml file by hand."),
1091
tr("You can not disable <i>all</i> toolbars <i>and</i> the menubar. If you do so, you will be unable to enable them back, when you'll change your mind."),
1001
1092
tr("I understand"));
1002
option.hideMenubar = false;
1093
PsiOptions::instance()->setOption("options.ui.contactlist.show-menubar", true);
1007
if ( option.useTabs != oldOpt.useTabs ) {
1008
QMessageBox::information(0, tr("Information"), tr("Some of the options you changed will only have full effect upon restart."));
1009
notifyRestart = false;
1013
if ( option.systemIconset != oldOpt.systemIconset ||
1014
option.emoticons != oldOpt.emoticons ||
1015
option.defaultRosterIconset != oldOpt.defaultRosterIconset ||
1016
operator!=(option.serviceRosterIconset,oldOpt.serviceRosterIconset) ||
1017
operator!=(option.customRosterIconset,oldOpt.customRosterIconset) )
1019
if ( notifyRestart && PsiIconset::instance()->optionsChanged(&oldOpt) )
1020
QMessageBox::information(0, tr("Information"), tr("The complete iconset update will happen on next Psi start."));
1022
// update icon selector
1023
d->updateIconSelect();
1025
// flush the QPixmapCache
1026
QPixmapCache::clear();
1029
if ( oldOpt.alertStyle != option.alertStyle )
1030
alertIconUpdateAlertStyle();
1032
d->mainwin->buildToolbars();
1034
/*// change pgp engine
1035
if(option.pgp != oldpgp) {
1041
pgp_init(option.pgp);
1045
if(oldOpt.dtPort != option.dtPort)
1047
1098
updateS5BServerAddresses();
1049
1100
// mainwin stuff
1050
d->mainwin->setWindowOpts(option.alwaysOnTop, (option.useDock && option.dockToolMW));
1051
d->mainwin->setUseDock(option.useDock);
1101
d->mainwin->setWindowOpts(PsiOptions::instance()->getOption("options.ui.contactlist.always-on-top").toBool(), (PsiOptions::instance()->getOption("options.ui.systemtray.enable").toBool() && PsiOptions::instance()->getOption("options.contactlist.use-toolwindow").toBool()));
1102
d->mainwin->setUseDock(PsiOptions::instance()->getOption("options.ui.systemtray.enable").toBool());
1103
d->mainwin->buildToolbars();
1053
1105
// notify about options change
1054
emitOptionsUpdate();
1056
// save just the options
1057
//d->pro.prefs = option;
1058
//d->pro.toFile(pathToProfileConfig(activeProfile));
1106
emit emitOptionsUpdate();
1062
1109
int PsiCon::getId()
1133
1171
d->mainwin->showNoFocus();
1136
const QStringList & PsiCon::recentGCList() const
1174
QStringList PsiCon::recentGCList() const
1138
return d->recentGCList;
1176
return PsiOptions::instance()->getOption("options.muc.recent-joins.jids").toStringList();
1141
1179
void PsiCon::recentGCAdd(const QString &str)
1181
QStringList recentList = recentGCList();
1143
1183
// remove it if we have it
1144
for(QStringList::Iterator it = d->recentGCList.begin(); it != d->recentGCList.end(); ++it) {
1184
for(QStringList::Iterator it = recentList.begin(); it != recentList.end(); ++it) {
1145
1185
if(*it == str) {
1146
d->recentGCList.remove(it);
1186
recentList.remove(it);
1151
1191
// put it in the front
1152
d->recentGCList.prepend(str);
1192
recentList.prepend(str);
1154
1194
// trim the list if bigger than 10
1155
while(d->recentGCList.count() > PsiOptions::instance()->getOption("options.muc.recent-joins.maximum").toInt())
1156
d->recentGCList.remove(d->recentGCList.fromLast());
1195
while(recentList.count() > PsiOptions::instance()->getOption("options.muc.recent-joins.maximum").toInt()) {
1196
recentList.remove(recentList.fromLast());
1199
PsiOptions::instance()->setOption("options.muc.recent-joins.jids", recentList);
1159
const QStringList & PsiCon::recentBrowseList() const
1202
QStringList PsiCon::recentBrowseList() const
1161
return d->recentBrowseList;
1204
return PsiOptions::instance()->getOption("options.ui.service-discovery.recent-jids").toStringList();
1164
1207
void PsiCon::recentBrowseAdd(const QString &str)
1209
QStringList recentList = recentBrowseList();
1166
1210
// remove it if we have it
1167
for(QStringList::Iterator it = d->recentBrowseList.begin(); it != d->recentBrowseList.end(); ++it) {
1211
for(QStringList::Iterator it = recentList.begin(); it != recentList.end(); ++it) {
1168
1212
if(*it == str) {
1169
d->recentBrowseList.remove(it);
1213
recentList.remove(it);
1174
1218
// put it in the front
1175
d->recentBrowseList.prepend(str);
1219
recentList.prepend(str);
1177
1221
// trim the list if bigger than 10
1178
while(d->recentBrowseList.count() > 10)
1179
d->recentBrowseList.remove(d->recentBrowseList.fromLast());
1222
while(recentList.count() > 10) {
1223
recentList.remove(recentList.fromLast());
1226
PsiOptions::instance()->setOption("options.ui.service-discovery.recent-jids", recentList);
1182
1229
const QStringList & PsiCon::recentNodeList() const
1272
1306
if ( isChat ) {
1273
if ( option.alertOpenChats && sentToChatWindow ) {
1307
PsiAccount* account = e->account();
1308
XMPP::Jid from = e->from();
1310
if ( PsiOptions::instance()->getOption("options.ui.chat.alert-for-already-open-chats").toBool() && sentToChatWindow ) {
1274
1311
// Message already displayed, need only to pop up chat dialog, so that
1275
1312
// it will be read (or marked as read)
1276
ChatDlg *c = e->account()->findDialog<ChatDlg*>(e->from());
1313
ChatDlg *c = account->findChatDialog(from);
1278
c = e->account()->findDialog<ChatDlg*>(e->jid());
1315
c = account->findChatDialog(e->jid());
1280
1317
return; // should never happen
1282
e->account()->processChats(e->from()); // this will delete all events, corresponding to that chat dialog
1283
//KIS: I changed the following line with the one following that to attempt to get tabs to behave correctly. Lots of this stuff isn't great.
1284
bringToFront((QWidget *)c);
1285
if ( option.useTabs)
1287
TabDlg* tabSet = getManagingTabs(c);
1288
if (tabSet) tabSet->selectTab(c);
1319
account->processChats(from); // this will delete all events, corresponding to that chat dialog
1292
e->account()->openChat(e->from());
1322
// as the event could be deleted just above, we're using cached account and from values
1323
account->openChat(from, activationType);
1295
1326
// search for an already opened eventdlg
1384
1410
//setGlobalStatus(Status());
1386
1412
foreach(PsiAccount* account, d->contactList->enabledAccounts()) {
1387
if (account->userAccount().opt_reconn) {
1413
if (account->userAccount().opt_connectAfterSleep) {
1388
1414
// Should we do this when the network comes up ?
1389
1415
account->setStatus(Status("", "", account->userAccount().priority));
1395
QList<PsiToolBar*> PsiCon::toolbarList() const
1397
return d->mainwin->toolbars;
1400
PsiToolBar *PsiCon::findToolBar(QString group, int index)
1402
PsiToolBar *toolBar = 0;
1404
if (( group == "mainWin" ) && (index < d->mainwin->toolbars.size()))
1405
toolBar = d->mainwin->toolbars.at(index);
1410
void PsiCon::buildToolbars()
1412
d->mainwin->buildToolbars();
1415
bool PsiCon::getToolbarLocation(Q3DockWindow* dw, Qt::Dock& dock, int& index, bool& nl, int& extraOffset) const
1417
return d->mainwin->getLocation(dw, dock, index, nl, extraOffset);
1420
1420
PsiActionList *PsiCon::actionList() const
1422
1422
return d->actionList;