27
26
#include<qcheckbox.h>
29
28
#include<qlayout.h>
32
static AccountManageDlg *accountmanage_ptr = 0;
34
AccountManageDlg::AccountManageDlg(JabSessionManager *_jsm, QWidget *parent, const char *name)
35
:AccountManageUI(parent, name, FALSE, WDestructiveClose)
37
setCaption(CAP(tr("Jabber Accounts")));
39
accountmanage_ptr = this;
31
#include<qradiobutton.h>
32
#include<qbuttongroup.h>
33
#include<qtabwidget.h>
34
#include<qwhatsthis.h>
38
#include"psiaccount.h"
41
#include"xmpp_tasks.h"
43
#include"sslcertdlg.h"
44
#include"busywidget.h"
45
#include"iconwidget.h"
46
#include"fancylabel.h"
51
//----------------------------------------------------------------------------
53
//----------------------------------------------------------------------------
54
static QCA::Cert readCertXml(const QDomElement &e)
57
// there should be one child data tag
58
QDomElement data = e.elementsByTagName("data").item(0).toElement();
60
cert.fromDER(Base64::stringToArray(data.text()));
64
static QPtrList<QCA::Cert> getRootCerts(const QStringList &stores)
66
QPtrList<QCA::Cert> list;
68
for(QStringList::ConstIterator dit = stores.begin(); dit != stores.end(); ++dit) {
70
dir.setNameFilter("*.xml");
71
QStringList entries = dir.entryList();
72
for(QStringList::ConstIterator it = entries.begin(); it != entries.end(); ++it) {
73
QFile f(dir.filePath(*it));
74
if(!f.open(IO_ReadOnly))
77
bool ok = doc.setContent(&f);
82
QDomElement base = doc.documentElement();
83
if(base.tagName() != "store")
85
QDomNodeList cl = base.elementsByTagName("certificate");
88
for(int n = 0; n < (int)cl.count(); ++n) {
89
QCA::Cert *cert = new QCA::Cert(readCertXml(cl.item(n).toElement()));
104
MiniClient::MiniClient(QObject *parent)
107
_client = new Client;
112
certList.setAutoDelete(true);
115
MiniClient::~MiniClient()
121
void MiniClient::reset()
136
void MiniClient::connectToServer(const Jid &jid, bool ssl, const QString &_host, int _port, ProxyManager *pm, int proxy, QString *_pass)
142
if(!_host.isEmpty()) {
154
AdvancedConnector::Proxy p;
156
const ProxyItem &pi = pm->getItem(proxy-1);
157
if(pi.type == "http") // HTTP Connect
158
p.setHttpConnect(pi.settings.host, pi.settings.port);
159
else if(pi.type == "socks") // SOCKS
160
p.setSocks(pi.settings.host, pi.settings.port);
161
else if(pi.type == "poll") { // HTTP Poll
162
QUrl u = pi.settings.url;
163
if(u.query().isEmpty()) {
164
QString v = host + ':' + QString::number(port);
166
u.setQuery(QString("server=") + v);
168
p.setHttpPoll(pi.settings.host, pi.settings.port, u.toString());
169
p.setPollInterval(2);
172
if(pi.settings.useAuth)
173
p.setUserPass(pi.settings.user, pi.settings.pass);
176
conn = new AdvancedConnector;
178
QStringList certDirs;
179
certDirs += g.pathBase + "/certs";
180
certList = getRootCerts(certDirs);
183
tls->setCertificateStore(certList);
184
tlsHandler = new QCATLSHandler(tls);
185
connect(tlsHandler, SIGNAL(tlsHandshaken()), SLOT(tls_handshaken()));
188
conn->setOptHostPort(host, port);
189
conn->setOptSSL(ssl);
191
stream = new ClientStream(conn, tlsHandler);
192
stream->setOldOnly(true);
193
connect(stream, SIGNAL(connected()), SLOT(cs_connected()));
194
connect(stream, SIGNAL(securityLayerActivated(int)), SLOT(cs_securityLayerActivated(int)));
195
connect(stream, SIGNAL(needAuthParams(bool, bool, bool)), SLOT(cs_needAuthParams(bool, bool, bool)));
196
connect(stream, SIGNAL(authenticated()), SLOT(cs_authenticated()));
197
connect(stream, SIGNAL(connectionClosed()), SLOT(cs_connectionClosed()));
198
connect(stream, SIGNAL(delayedCloseFinished()), SLOT(cs_delayedCloseFinished()));
199
connect(stream, SIGNAL(warning(int)), SLOT(cs_warning(int)));
200
connect(stream, SIGNAL(error(int)), SLOT(cs_error(int)));
204
_client->connectToServer(stream, j);
207
_client->connectToServer(stream, j, false);
210
void MiniClient::close()
216
Client *MiniClient::client()
221
void MiniClient::tls_handshaken()
223
QCA::Cert cert = tls->peerCertificate();
224
int r = tls->certificateValidityResult();
225
if(r != QCA::TLS::Valid) {
226
QString str = PsiAccount::resultToString(r);
228
int n = QMessageBox::warning(0,
229
tr("Server Authentication"),
230
tr("The %1 certificate failed the authenticity test.").arg(j.host()) + '\n' + tr("Reason: %1").arg(str),
233
tr("&Cancel"), 0, 2);
235
SSLCertDlg::showCert(cert, r);
238
tlsHandler->continueAfterHandshake();
249
tlsHandler->continueAfterHandshake();
252
void MiniClient::cs_connected()
256
void MiniClient::cs_securityLayerActivated(int)
260
void MiniClient::cs_needAuthParams(bool, bool, bool)
262
stream->setPassword(pass);
263
stream->continueAfterParams();
266
void MiniClient::cs_authenticated()
268
_client->start(j.host(), j.user(), "", "");
272
void MiniClient::cs_connectionClosed()
277
void MiniClient::cs_delayedCloseFinished()
281
void MiniClient::cs_warning(int)
283
stream->continueAfterWarning();
286
void MiniClient::cs_error(int err)
291
PsiAccount::getErrorInfo(err, conn, stream, tlsHandler, &str, &reconn);
294
QMessageBox::critical(0, tr("Server Error"), tr("There was an error communicating with the Jabber server.\nDetails: %1").arg(str));
298
//----------------------------------------------------------------------------
300
//----------------------------------------------------------------------------
301
class AccountManageItem : public QCheckListItem
304
AccountManageItem(QListView *par, PsiAccount *_pa)
305
:QCheckListItem(par,"",CheckBox)
313
const UserAccount &acc = pa->userAccount();
314
setText(0, pa->name());
315
setPixmap(0, IconsetFactory::icon("psi/account"));
317
setText(1, acc.opt_host ? acc.host : j.host());
318
setText(2, pa->isActive() ? AccountManageDlg::tr("Active") : AccountManageDlg::tr("Not active"));
319
setOn(pa->enabled());
322
void stateChange( bool s)
325
if (pa->eventQueue()->count()) {
327
QMessageBox::information(listView(), AccountManageDlg::tr("Error"), AccountManageDlg::tr("Unable to disable the account, as it has pending events."));
331
if (pa->isActive()) {
332
if (QMessageBox::information(listView(), AccountManageDlg::tr("Disable Account"), AccountManageDlg::tr("The account is currently active.\nDo you want to log out ?"),QMessageBox::Yes,QMessageBox::No | QMessageBox::Default | QMessageBox::Escape, QMessageBox::NoButton) == QMessageBox::Yes) {
342
if (pa->enabled()!=s)
354
AccountManageDlg::AccountManageDlg(PsiCon *_psi, const char *name)
355
:AccountManageUI(0, name, false, WDestructiveClose)
358
psi->dialogRegister(this);
360
setCaption(CAP(caption()));
363
connect(pb_add, SIGNAL(clicked()), SLOT(add()));
43
364
connect(pb_modify, SIGNAL(clicked()), SLOT(modify()));
44
connect(pb_close, SIGNAL(clicked()), SLOT(reject()));
365
connect(pb_remove, SIGNAL(clicked()), SLOT(remove()));
366
connect(pb_close, SIGNAL(clicked()), SLOT(close()));
45
368
connect(lv_accs, SIGNAL(doubleClicked(QListViewItem *)), SLOT(modify(QListViewItem *)));
47
connect(jsm, SIGNAL(sessionUpdate(JabSession *)), SLOT(sessionUpdate(JabSession *)));
49
lv_accs->setAllColumnsShowFocus(TRUE);
51
QPtrList<JabSession> list = jsm->getList();
52
QPtrListIterator<JabSession> it(list);
53
for(JabSession *s; (s = it.current()); ++it)
54
new AccountViewItem(lv_accs, s);
56
pb_add->setEnabled(FALSE);
57
pb_remove->setEnabled(FALSE);
369
connect(lv_accs, SIGNAL(selectionChanged(QListViewItem *)), SLOT(qlv_selectionChanged(QListViewItem *)));
370
connect(psi, SIGNAL(accountAdded(PsiAccount *)), SLOT(accountAdded(PsiAccount *)));
371
connect(psi, SIGNAL(accountUpdated(PsiAccount *)), SLOT(accountUpdated(PsiAccount *)));
372
connect(psi, SIGNAL(accountRemoved(PsiAccount *)), SLOT(accountRemoved(PsiAccount *)));
374
lv_accs->setAllColumnsShowFocus(true);
375
lv_accs->setResizeMode(QListView::LastColumn);
377
PsiAccountListIt it(psi->accountList());
378
for(PsiAccount *pa; (pa = it.current()); ++it) {
379
new AccountManageItem(lv_accs, pa);
59
382
if(lv_accs->childCount() > 0)
60
lv_accs->setSelected(lv_accs->firstChild(), TRUE);
383
lv_accs->setSelected(lv_accs->firstChild(), true);
385
qlv_selectionChanged(0);
63
388
AccountManageDlg::~AccountManageDlg()
65
accountmanage_ptr = 0;
68
/* static */ AccountManageDlg *AccountManageDlg::find()
70
return accountmanage_ptr;
390
psi->dialogUnregister(this);
393
void AccountManageDlg::qlv_selectionChanged(QListViewItem *lvi)
395
AccountManageItem *i = (AccountManageItem *)lvi;
396
bool ok = i ? true: false;
398
pb_modify->setEnabled(ok);
399
pb_remove->setEnabled(ok);
402
void AccountManageDlg::add()
404
AccountAddDlg *w = new AccountAddDlg(psi, 0);
73
408
void AccountManageDlg::modify()
75
QListViewItem *lvi = lv_accs->currentItem();
410
modify(lv_accs->currentItem());
82
413
void AccountManageDlg::modify(QListViewItem *lvi)
84
signalModify(lvi->text(0));
87
void AccountManageDlg::updateEntry(JabSession *s)
415
AccountManageItem *i = (AccountManageItem *)lvi;
419
psi->modifyAccount(i->pa);
422
void AccountManageDlg::remove()
424
AccountManageItem *i = (AccountManageItem *)lv_accs->currentItem();
428
if(i->pa->isActive()) {
429
QMessageBox::information(this, tr("Error"), tr("Unable to remove the account, as it is currently active."));
433
AccountRemoveDlg *w = new AccountRemoveDlg(psi->proxy(), i->pa->userAccount());
435
if(n != QDialog::Accepted) {
440
psi->removeAccount(i->pa);
443
void AccountManageDlg::accountAdded(PsiAccount *pa)
445
new AccountManageItem(lv_accs, pa);
448
void AccountManageDlg::accountUpdated(PsiAccount *pa)
450
AccountManageItem *i;
90
451
QListViewItemIterator it(lv_accs);
91
for(; (i = (AccountViewItem *)it.current()) ; ++it) {
452
for(; (i = (AccountManageItem *)it.current()) ; ++it) {
101
void AccountManageDlg::sessionUpdate(JabSession *s)
107
AccountViewItem::AccountViewItem(QListView *par, JabSession *_s)
115
void AccountViewItem::updateInfo()
117
setText(0, s->name());
118
setPixmap(0, *pix_account);
119
setText(1, s->acc()->host);
120
setText(2, s->serv()->isActive() ? "Active" : "Not active");
124
AccountModifyDlg::AccountModifyDlg(JabSession *_s, bool _haveSSL, QWidget *parent, const char *name)
125
:AccountModifyUI(parent, name, FALSE, WDestructiveClose), UniqueWindow(TRUE, "AccountModifyDlg", this, _s->acc()->name)
127
setCaption(tr("Account Properties"));
128
setIcon(*pix_account);
130
resize(width(), sizeHint().height());
134
UserAccount &acc = *s->acc();
462
void AccountManageDlg::accountRemoved(PsiAccount *pa)
464
AccountManageItem *i;
465
QListViewItemIterator it(lv_accs);
466
for(; (i = (AccountManageItem *)it.current()) ; ++it) {
475
qlv_selectionChanged(lv_accs->currentItem());
479
//----------------------------------------------------------------------------
481
//----------------------------------------------------------------------------
482
AccountAddDlg::AccountAddDlg(PsiCon *_psi, QWidget *parent, const char *name)
483
:AccountAddUI(parent, name, false, WDestructiveClose)
486
psi->dialogRegister(this);
488
setCaption(CAP(caption()));
490
connect(pb_close, SIGNAL(clicked()), SLOT(close()));
491
connect(pb_add, SIGNAL(clicked()), SLOT(add()));
492
connect(le_name, SIGNAL(textChanged(const QString &)), SLOT(setAddButton(const QString &)));
494
QWhatsThis::add(ck_reg,
495
tr("Check this option if you don't yet have a Jabber account "
496
"and you want to register one. Note that this will only work "
497
"on servers that allow anonymous registration."));
499
QString def = tr("Default");
504
PsiAccountListIt it(psi->accountList());
505
for(PsiAccount *pa; (pa = it.current()); ++it) {
506
if(aname == pa->name()) {
514
aname = def + '_' + QString::number(++n);
517
le_name->setText(aname);
521
AccountAddDlg::~AccountAddDlg()
523
psi->dialogUnregister(this);
526
void AccountAddDlg::add()
528
QString def = le_name->text();
533
PsiAccountListIt it(psi->accountList());
534
for(PsiAccount *pa; (pa = it.current()); ++it) {
535
if(aname == pa->name()) {
543
aname = def + '_' + QString::number(++n);
545
le_name->setText( aname );
547
if(ck_reg->isChecked()) {
548
AccountRegDlg *w = new AccountRegDlg(psi->proxy(), this);
550
if(n != QDialog::Accepted) {
556
QString pass = w->pass;
557
bool opt_host = w->opt_host;
558
QString host = w->sp_host;
559
int port = w->sp_port;
561
int proxy = w->proxy;
565
psi->createAccount(le_name->text(), jid, pass, opt_host, host, port, ssl, proxy);
568
psi->createAccount(le_name->text());
574
void AccountAddDlg::setAddButton(const QString &s)
576
pb_add->setEnabled(!s.isEmpty());
580
//----------------------------------------------------------------------------
582
//----------------------------------------------------------------------------
583
AccountModifyDlg::AccountModifyDlg(PsiAccount *_pa, QWidget *parent, const char *name)
584
:AccountModifyUI(parent, name, false, WDestructiveClose)
587
connect(pa->psi(), SIGNAL(pgpToggled(bool)), SLOT(pgpToggled(bool)));
588
pa->dialogRegister(this);
590
setCaption(CAP(caption()));
591
setIcon(IconsetFactory::icon("psi/account"));
593
const UserAccount &acc = pa->userAccount();
136
595
connect(pb_close, SIGNAL(clicked()), SLOT(reject()));
137
596
connect(ck_pass, SIGNAL(toggled(bool)), le_pass, SLOT(setEnabled(bool)));
597
connect(ck_host, SIGNAL(toggled(bool)), SLOT(hostToggled(bool)));
598
connect(pb_key, SIGNAL(clicked()), SLOT(chooseKey()));
599
connect(pb_keyclear, SIGNAL(clicked()), SLOT(clearKey()));
138
600
connect(pb_save, SIGNAL(clicked()), SLOT(save()));
139
connect(pb_reg, SIGNAL(clicked()), SLOT(doRegister()));
141
le_pass->setEnabled(FALSE);
143
pb_unreg->setEnabled(FALSE);
145
if(!acc.name.isEmpty()) {
146
le_name->setText(acc.name);
147
le_host->setText(acc.host);
148
le_port->setText(QString::number(acc.port));
149
if(acc.opt_ssl && haveSSL)
150
ck_ssl->setChecked(acc.opt_ssl);
151
connect(ck_ssl, SIGNAL(toggled(bool)), SLOT(sslToggled(bool)));
153
le_user->setText(acc.user);
155
ck_pass->setChecked(TRUE);
156
le_pass->setText(acc.pass);
602
le_pass->setEnabled(false);
603
le_host->setEnabled(false);
604
le_port->setEnabled(false);
606
gb_pgp->setEnabled(false);
607
connect(ck_pp, SIGNAL(toggled(bool)), SLOT(optpp_toggled(bool)));
608
le_pp->setEnabled(false);
610
connect(pb_vcard, SIGNAL(clicked()), SLOT(detailsVCard()));
611
connect(pb_changepw, SIGNAL(clicked()), SLOT(detailsChangePW()));
613
le_name->setText(acc.name);
614
le_jid->setText(acc.jid);
616
ck_ssl->setChecked(acc.opt_ssl);
617
connect(ck_ssl, SIGNAL(toggled(bool)), SLOT(sslToggled(bool)));
620
ck_pass->setChecked(true);
621
le_pass->setText(acc.pass);
624
ck_host->setChecked(acc.opt_host);
625
le_host->setText(acc.host);
626
le_port->setText(QString::number(acc.port));
628
le_resource->setText(acc.resource);
629
le_priority->setText(QString::number(acc.priority));
631
ck_plain->setChecked(acc.opt_plain);
632
ck_auto->setChecked(acc.opt_auto);
633
ck_reconn->setChecked(acc.opt_reconn);
634
ck_log->setChecked(acc.opt_log);
635
ck_keepAlive->setChecked(acc.opt_keepAlive);
636
ck_ignoreSSLWarnings->setChecked(acc.opt_ignoreSSLWarnings);
637
le_dtProxy->setText(acc.dtProxy.full());
639
keyID = acc.pgpSecretKeyID;
641
if(pa->psi()->pgp()) {
642
gb_pgp->setEnabled(true);
643
if(acc.opt_passphrase) {
644
ck_pp->setChecked(true);
645
le_pp->setText(acc.pgpPassphrase);
158
le_resource->setText(acc.resource);
159
le_priority->setText(QString::number(acc.priority));
161
ck_plain->setChecked(acc.opt_plain);
162
ck_auto->setChecked(acc.opt_auto);
163
ck_log->setChecked(acc.opt_log);
164
ck_keepAlive->setChecked(acc.opt_keepAlive);
649
pc = pa->psi()->proxy()->createProxyChooser(gb_proxy);
650
replaceWidget(lb_proxychooser, pc);
651
pc->fixTabbing(le_pp, ck_ssl);
652
pc->setCurrentItem(acc.proxy_index);
654
if(le_name->text().isEmpty())
656
else if(le_jid->text().isEmpty())
166
659
pb_save->setFocus();
661
// QWhatsThis helpers
662
QWhatsThis::add(ck_plain,
663
tr("Normally, Psi logs in using the <i>digest</i> authentication "
664
"method. Check this box to force a plain text login "
665
"to the Jabber server. Use this option only if you have "
666
"problems connecting with the normal login procedure, as it "
667
"makes your connection potentially vulnerable to "
669
QWhatsThis::add(ck_auto,
670
tr("Automatically login to this account on Psi startup. Useful if "
671
"you have Psi automatically launched when an Internet "
672
"connection is detected."));
673
QWhatsThis::add(ck_reconn,
674
tr("Makes Psi try to reconnect if the connection was broken. "
675
"Useful, if you have an unstable connection and have to "
676
"reconnect often."));
677
QWhatsThis::add(ck_log,
678
tr("Keep a log of message history. Disable this "
679
"option if you want to conserve disk space or if you need "
680
"maximum security."));
681
QWhatsThis::add(ck_keepAlive,
682
tr("Sends so called \"Keep-alive\" packets periodically. "
683
"It is useful if your connection is set to be "
684
"automatically disconnected after a certain period of "
685
"inactivity (for example, by your ISP) and you want to keep it "
686
"up all the time."));
687
QWhatsThis::add(ck_ignoreSSLWarnings,
688
tr("Ignores all the SSL warnings, for example, about "
689
"incorrect certificates. Useful if your server doesn't "
690
"use a validated SSL certificate and you are "
691
"annoyed with warnings."));
692
QWhatsThis::add(ck_ssl,
693
tr("Check this option to use an encrypted SSL connection to "
694
"the Jabber server. You may use this option if your "
695
"server supports it and if you have the necessary QSSL "
696
"plugin installed. For more information, check the "
698
QWhatsThis::add(ck_pass,
699
tr("Check this option if you want Psi to remember your Jabber "
700
"account password. Don't use this feature if you want "
701
"maximum security and don't want to be compromised even "
702
"if someone would break in your system and steal your "
703
"configuration files."));
704
QWhatsThis::add(ck_host,
705
tr("Use this option for manual configuration of your Jabber host "
706
"if it is not the same as the host you are connecting to. This option is mostly useful "
707
"if you have some sort of proxy route on your "
708
"local machine (i.e. you connect to localhost), but your "
709
"account is registered on an external server."));
710
QWhatsThis::add(le_resource,
711
tr("You can have multiple clients connected to the Jabber server "
712
"with your single account. Each login is distinguished by a \"resource\" "
713
"name, which you can specify in this field."));
714
QWhatsThis::add(le_priority,
715
tr("<p>You can have multiple clients connected to the Jabber "
716
"server with your single account. In such a situation, "
717
"the client with the highest priority (that is specified in "
718
"this field) will be the one that will receive "
719
"all incoming events.</p>"
720
"<p>For example, if you have a permanent connection "
721
"to the Internet at your work location, and have a dial-up at home, "
722
"you can have your Jabber client permanently running at work "
723
"with a low priority, and you can still use the same account "
724
"from home, using a client with higher priority to "
725
"temporary \"disable\" the lower priority client at work.</p>"));
727
resize(minimumSize());
172
730
AccountModifyDlg::~AccountModifyDlg()
176
/*static*/ AccountModifyDlg * AccountModifyDlg::find(const QString &accname)
178
return (AccountModifyDlg *)UniqueWindowBank::find("AccountModifyDlg", accname.lower());
732
pa->dialogUnregister(this);
735
void AccountModifyDlg::updateUserID()
737
if(keyID.isEmpty()) {
741
QString userID = QString::null;
742
if(pa->psi()->pgp()) {
743
OpenPGP::KeyList list = pa->psi()->pgp()->secretKeys();
744
for(OpenPGP::KeyList::ConstIterator it = list.begin(); it != list.end(); ++it) {
745
const OpenPGP::Key &k = *it;
746
if(k.keyID() == keyID) {
753
setKeyID(true, tr("Unknown Key: %1").arg(keyID.left(8)));
755
setKeyID(true, userID);
759
void AccountModifyDlg::setKeyID(bool b, const QString &s)
762
lb_keyname->setText(s);
763
lb_keyname->setMinimumWidth(100);
764
lb_keyicon->setEnabled(true);
765
lb_keyname->setEnabled(true);
766
pb_keyclear->setEnabled(true);
767
ck_pp->setEnabled(true);
770
lb_keyname->setText(tr("No Key Selected"));
771
lb_keyicon->setEnabled(false);
772
lb_keyname->setEnabled(false);
773
pb_keyclear->setEnabled(false);
774
ck_pp->setChecked(false);
775
ck_pp->setEnabled(false);
779
void AccountModifyDlg::pgpToggled(bool b)
782
gb_pgp->setEnabled(true);
785
gb_pgp->setEnabled(false);
786
ck_pp->setChecked(false);
791
void AccountModifyDlg::optpp_toggled(bool b)
794
le_pp->setEnabled(true);
796
le_pp->setEnabled(false);
801
void AccountModifyDlg::setPassword(const QString &pw)
803
le_pass->setText(pw);
181
806
void AccountModifyDlg::sslToggled(bool on)
184
QMessageBox::information(this, tr("OpenSSL error"), QString("<qt>") + tr("Sorry, but you must have <b>OpenSSL v0.9.6b</b> or compatible installed to use this feature.") + "</qt>");
185
ck_ssl->setChecked(FALSE);
808
if(on && !QCA::isSupported(QCA::CAP_TLS)) {
809
QMessageBox::information(this, tr("SSL error"), tr("Cannot enable SSL/TLS. Plugin not found."));
810
ck_ssl->setChecked(false);
189
814
le_port->setText(on ? "5223": "5222");
817
void AccountModifyDlg::hostToggled(bool on)
819
le_host->setEnabled(on);
820
le_port->setEnabled(on);
823
void AccountModifyDlg::chooseKey()
825
OpenPGP::KeyList list = pa->psi()->pgp()->secretKeys();
826
PGPKeyDlg *w = new PGPKeyDlg(list, keyID, this);
827
w->setCaption(tr("Secret Key"));
830
if(r == QDialog::Accepted)
837
ck_pp->setChecked(false);
841
void AccountModifyDlg::clearKey()
847
void AccountModifyDlg::detailsVCard()
852
void AccountModifyDlg::detailsChangePW()
192
857
void AccountModifyDlg::save()
194
if(s->serv()->isActive()) {
195
QMessageBox::information(this, tr("Error"), tr("Please disconnect from this account before trying to modify it."));
199
UserAccount &acc = *s->acc();
201
QString before = acc.name.lower();
202
QString after = le_name->text().lower();
203
if(after.length() == 0) {
859
UserAccount acc = pa->userAccount();
861
if(le_name->text().isEmpty()) {
204
862
QMessageBox::information(this, tr("Error"), tr("You must specify a name for the account before you may save it."));
207
if(before != after) {
208
JabSessionManager *jsm = (JabSessionManager *)s->parent();
209
if(jsm->find(after)) {
210
QMessageBox::information(this, tr("Error"), tr("There is already an account with this name. Please select a different name."));
215
bool newUser = FALSE;
216
if(acc.user != le_user->text() || acc.host != le_host->text() || acc.port != le_port->text().toInt()) {
866
Jid newJid( le_jid->text() );
867
if ( newJid.user().isEmpty() || newJid.host().isEmpty() ) {
868
QMessageBox::information(this, tr("Error"), tr("<i>Jabber ID</i> must be specified in the format <i>user@host</i>."));
872
// do not allow duplicate account names
873
QString def = le_name->text();
877
PsiAccountListIt it(pa->psi()->accountList());
878
for(PsiAccount *pa; (pa = it.current()); ++it)
879
if(aname == pa->name())
883
if ( aname == acc.name )
887
aname = def + '_' + QString::number(++n);
888
le_name->setText( aname );
220
890
acc.name = le_name->text();
221
acc.host = le_host->text();
222
acc.port = le_port->text().toInt();
223
acc.opt_ssl = ck_ssl->isChecked();
224
acc.user = le_user->text();
891
acc.jid = le_jid->text();
225
892
acc.opt_pass = ck_pass->isChecked();
227
894
acc.pass = le_pass->text();
898
acc.opt_host = ck_host->isChecked();
899
acc.host = le_host->text();
900
acc.port = le_port->text().toInt();
230
902
acc.resource = le_resource->text();
231
903
acc.priority = le_priority->text().toInt();
905
acc.opt_ssl = ck_ssl->isChecked();
233
906
acc.opt_plain = ck_plain->isChecked();
234
907
acc.opt_auto = ck_auto->isChecked();
908
acc.opt_reconn = ck_reconn->isChecked();
235
909
acc.opt_log = ck_log->isChecked();
236
910
acc.opt_keepAlive = ck_keepAlive->isChecked();
911
acc.opt_ignoreSSLWarnings = ck_ignoreSSLWarnings->isChecked();
912
acc.dtProxy = le_dtProxy->text();
914
acc.pgpSecretKeyID = keyID;
915
acc.opt_passphrase = ck_pp->isChecked();
916
if(acc.opt_passphrase)
917
acc.pgpPassphrase = le_pp->text();
919
acc.pgpPassphrase = "";
921
acc.proxy_index = pc->currentItem();
924
QMessageBox::information(this, tr("Warning"), tr("This account is currently active, so certain changes may not take effect until the next login."));
927
pa->setUserAccount(acc);
243
void AccountModifyDlg::doRegister()
933
//----------------------------------------------------------------------------
935
//----------------------------------------------------------------------------
936
AccountRegDlg::AccountRegDlg(ProxyManager *_proxyman, QWidget *parent, const char *name)
937
:AccountRegUI(parent, name, false)
939
setCaption(CAP(caption()));
941
le_host->setEnabled(false);
942
le_port->setEnabled(false);
944
connect(pb_reg, SIGNAL(clicked()), SLOT(reg()));
945
connect(ck_ssl, SIGNAL(toggled(bool)), SLOT(sslToggled(bool)));
946
connect(ck_host, SIGNAL(toggled(bool)), SLOT(hostToggled(bool)));
948
proxyman = _proxyman;
949
pc = proxyman->createProxyChooser(gb_proxy);
950
replaceWidget(lb_proxychooser, pc);
951
pc->fixTabbing(le_confirm, ck_ssl);
952
pc->setCurrentItem(0);
954
le_port->setText("5222");
957
client = new MiniClient;
958
connect(client, SIGNAL(handshaken()), SLOT(client_handshaken()));
959
connect(client, SIGNAL(error()), SLOT(client_error()));
962
AccountRegDlg::~AccountRegDlg()
967
/*void AccountRegDlg::closeEvent(QCloseEvent *e)
973
void AccountRegDlg::done(int r)
975
if(busy->isActive()) {
976
int n = QMessageBox::information(this, tr("Warning"), tr("Are you sure you want to cancel the registration?"), tr("&Yes"), tr("&No"));
983
void AccountRegDlg::sslToggled(bool on)
985
if(on && !QCA::isSupported(QCA::CAP_TLS)) {
986
QMessageBox::information(this, tr("SSL error"), tr("Cannot enable SSL/TLS. Plugin not found."));
987
ck_ssl->setChecked(false);
991
le_port->setText(on ? "5223": "5222");
994
void AccountRegDlg::hostToggled(bool on)
996
le_host->setEnabled(on);
997
le_port->setEnabled(on);
1000
void AccountRegDlg::reg()
1003
Jid j(le_jid->text());
1004
if ( j.user().isEmpty() || j.host().isEmpty() ) {
1005
QMessageBox::information(this, tr("Error"), tr("<i>Jabber ID</i> must be specified in the format <i>user@host</i>."));
245
1009
if(le_pass->text().isEmpty()) {
246
QMessageBox::warning(this, tr("Error"), tr("You must specify a password for the new account."));
250
int n = QMessageBox::information(this, tr("Warning"),tr(
251
"You have elected to create a new account on the specified server.\n"
252
"Please note that this may not work on all servers, which means you may\n"
253
"have to sign up with the host some other way instead (like through the web).\n"
255
"Think about it like this: if you were running a mail server, would you\n"
256
"allow anonymous users to sign up for accounts on your system? Probably not.\n"
257
"For now though (Spring 2002), most hosts (like jabber.com and jabber.org) allow\n"
258
"anonymous signups. Check jabberview.com for a nice list of free hosts.\n"
260
"Click on \"Yes\" to attempt to register an account.\n"),
261
tr("&Yes"), tr("&No"));
1010
QMessageBox::information(this, tr("Error"), tr("You must fill out the fields properly before you can register."));
1014
if(le_pass->text() != le_confirm->text()) {
1015
QMessageBox::information(this, tr("Error"), tr("Password and confirmation do not match. Please enter them again."));
1016
le_pass->setText("");
1017
le_confirm->setText("");
1018
le_pass->setFocus();
1026
ssl = ck_ssl->isChecked();
1027
pass = le_pass->text();
1028
opt_host = ck_host->isChecked();
1029
sp_host = le_host->text();
1030
sp_port = le_port->text().toInt();
1032
client->connectToServer(jid, ssl, opt_host ? sp_host : QString(), sp_port, proxyman, pc->currentItem(), 0);
1035
void AccountRegDlg::client_handshaken()
1037
// try to register an account
1038
JT_Register *reg = new JT_Register(client->client()->rootTask());
1039
connect(reg, SIGNAL(finished()), SLOT(reg_finished()));
1040
reg->reg(jid.user(), pass);
1044
void AccountRegDlg::client_error()
1050
void AccountRegDlg::reg_finished()
1052
JT_Register *reg = (JT_Register *)sender();
1057
if(reg->success()) {
1058
QMessageBox::information(this, tr("Success"), tr("The account was registered successfully."));
1059
proxy = pc->currentItem();
1063
else if(reg->statusCode() != Task::ErrDisc) {
1065
QMessageBox::critical(this, tr("Error"), QString(tr("There was an error registering the account.\nReason: %1")).arg(reg->statusString()));
1069
void AccountRegDlg::block()
1071
gb_account->setEnabled(false);
1072
gb_proxy->setEnabled(false);
1073
gb_advanced->setEnabled(false);
1074
pb_reg->setEnabled(false);
1077
void AccountRegDlg::unblock()
1079
gb_account->setEnabled(true);
1080
gb_proxy->setEnabled(true);
1081
gb_advanced->setEnabled(true);
1082
pb_reg->setEnabled(true);
1087
//----------------------------------------------------------------------------
1089
//----------------------------------------------------------------------------
1090
class AccountRemoveDlg::Private
1097
ProxyManager *proxyman;
1100
AccountRemoveDlg::AccountRemoveDlg(ProxyManager *proxyman, const UserAccount &acc, QWidget *parent, const char *name)
1101
:AccountRemoveUI(parent, name, false)
1105
d->proxyman = proxyman;
1107
setCaption(CAP(caption()));
1109
connect(pb_close, SIGNAL(clicked()), SLOT(close()));
1110
connect(pb_remove, SIGNAL(clicked()), SLOT(remove()));
1112
d->bg = new QButtonGroup(0);
1113
d->bg->insert(rb_remove, 0);
1114
d->bg->insert(rb_removeAndUnreg, 1);
1115
connect(d->bg, SIGNAL(clicked(int)), SLOT(bg_clicked(int)));
1116
d->bg->setButton(0);
1119
pb_close->setFocus();
1121
client = new MiniClient;
1122
connect(client, SIGNAL(handshaken()), SLOT(client_handshaken()));
1123
connect(client, SIGNAL(error()), SLOT(client_error()));
1126
AccountRemoveDlg::~AccountRemoveDlg()
1134
/*void AccountRemoveDlg::closeEvent(QCloseEvent *e)
1140
void AccountRemoveDlg::done(int r)
1142
if(busy->isActive()) {
1143
int n = QMessageBox::information(this, tr("Warning"), tr("Are you sure you want to cancel the unregistration?"), tr("&Yes"), tr("&No"));
1150
void AccountRemoveDlg::bg_clicked(int x)
1153
lb_pass->setEnabled(false);
1154
le_pass->setEnabled(false);
1157
lb_pass->setEnabled(true);
1158
le_pass->setEnabled(true);
1159
le_pass->setFocus();
1163
void AccountRemoveDlg::remove()
1165
bool unreg = rb_removeAndUnreg->isChecked();
1168
if(le_pass->text() != d->acc.pass) {
1169
QMessageBox::information(this, tr("Error"), tr("Password does not match account. Please try again."));
1170
le_pass->setFocus();
1175
int n = QMessageBox::information(this, tr("Warning"), tr("Are you sure you want to remove <b>%1</b> ?").arg(d->acc.name), tr("&Yes"), tr("&No"));
266
// get the form opts that we need
267
QString host = le_host->text();
268
int port = le_port->text().toInt();
269
bool opt_ssl = ck_ssl->isChecked();
270
QString user = le_user->text();
271
QString pass = le_pass->text();
273
// we should probably verify they are ok
275
// perform a registration
276
AccountRegisterDlg::reg(this, host, port, opt_ssl, user, pass);
280
AccountRegisterDlg::AccountRegisterDlg(QWidget *par, const char *name)
281
:QDialog(par, name, TRUE)
283
setCaption(tr("Account Registration"));
285
QVBoxLayout *vb = new QVBoxLayout(this, 4);
286
QHBoxLayout *hb = new QHBoxLayout(vb);
287
QLabel *l = new QLabel(tr("Registering account..."), this);
289
busy = new BusyWidget(this);
291
QPushButton *pb_cancel = new QPushButton(tr("&Cancel"), this);
292
hb->addWidget(pb_cancel);
293
connect(pb_cancel, SIGNAL(clicked()), SLOT(cancel()));
294
pb_cancel->setFocus();
297
connect(jab, SIGNAL(accRegisterFinished(bool, const QString &)), SLOT(accRegisterFinished(bool, const QString &)));
298
connect(jab, SIGNAL(error(JabError *)), SLOT(jab_error(JabError *)));
301
AccountRegisterDlg::~AccountRegisterDlg()
306
void AccountRegisterDlg::closeEvent(QCloseEvent *e)
310
QDialog::closeEvent(e);
313
void AccountRegisterDlg::start(const QString &host, int port, bool opt_ssl, const QString &user, const QString &pass)
317
jab->setSSLEnabled(opt_ssl);
318
jab->setHost(host, port);
319
jab->setAccount(user, pass, "");
323
void AccountRegisterDlg::stop()
328
void AccountRegisterDlg::cancel()
334
bool AccountRegisterDlg::reg(QWidget *par, const QString &host, int port, bool opt_ssl, const QString &user, const QString &pass)
336
AccountRegisterDlg *w = new AccountRegisterDlg(par);
337
w->start(host, port, opt_ssl, user, pass);
344
void AccountRegisterDlg::accRegisterFinished(bool ok, const QString &errMsg)
350
QMessageBox::information(this, tr("Success"), tr("The account was registered successfully."));
352
QMessageBox::critical(this, tr("Error"), QString(tr("There was an error registering the account.\nReason: %1")).arg(errMsg));
357
void AccountRegisterDlg::jab_error(JabError *err)
362
QMessageBox::critical(this, tr("Error"), QString(tr("There was an error communicating with the Jabber server.\nReason: %1")).arg(err->msg));
1185
gb_account->setEnabled(false);
1186
pb_remove->setEnabled(false);
1189
j.setResource(d->acc.resource);
1190
client->connectToServer(j, d->acc.opt_ssl, d->acc.opt_host ? d->acc.host : QString(), d->acc.port, d->proxyman, d->acc.proxy_index, &d->acc.pass);
1193
void AccountRemoveDlg::client_handshaken()
1195
// try to unregister an account
1196
JT_Register *reg = new JT_Register(client->client()->rootTask());
1197
connect(reg, SIGNAL(finished()), SLOT(unreg_finished()));
1202
void AccountRemoveDlg::client_error()
1205
gb_account->setEnabled(true);
1206
pb_remove->setEnabled(true);
1209
void AccountRemoveDlg::unreg_finished()
1211
JT_Register *reg = (JT_Register *)sender();
1216
if(reg->success()) {
1217
QMessageBox::information(this, tr("Success"), tr("The account was unregistered successfully."));
1221
else if(reg->statusCode() != Task::ErrDisc) {
1222
gb_account->setEnabled(true);
1223
pb_remove->setEnabled(true);
1224
QMessageBox::critical(this, tr("Error"), QString(tr("There was an error unregistering the account.\nReason: %1")).arg(reg->statusString()));