X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fcoreconnectdlg.cpp;h=16655ffd128cc5d2b7259282def24028374a3e2b;hp=5be28e80be22c724756b4e1c3568344e0f353592;hb=4aed4b037ea6feaeec09743e5d6018f58d47a535;hpb=9a892ffc7a9a2388e6ca42c1ade65c5b42b8503e diff --git a/src/qtui/coreconnectdlg.cpp b/src/qtui/coreconnectdlg.cpp index 5be28e80..16655ffd 100644 --- a/src/qtui/coreconnectdlg.cpp +++ b/src/qtui/coreconnectdlg.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel IRC Team * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,11 +18,17 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "coreconnectdlg.h" + #include +#include #include #include -#include "coreconnectdlg.h" +#ifdef HAVE_SSL +#include +#include +#endif #include "client.h" #include "clientsettings.h" @@ -50,8 +56,7 @@ CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent) setWindowFlags(Qt::Sheet); clientSyncer = new ClientSyncer(this); - connect(this, SIGNAL(newClientSyncer(ClientSyncer *)), Client::instance(), SIGNAL(newClientSyncer(ClientSyncer *))); - emit newClientSyncer(clientSyncer); // announce the new client syncer via the client. + Client::registerClientSyncer(clientSyncer); wizard = 0; @@ -86,8 +91,8 @@ CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent) connect(clientSyncer, SIGNAL(socketStateChanged(QAbstractSocket::SocketState)),this, SLOT(initPhaseSocketState(QAbstractSocket::SocketState))); connect(clientSyncer, SIGNAL(connectionError(const QString &)), this, SLOT(initPhaseError(const QString &))); + connect(clientSyncer, SIGNAL(connectionWarnings(const QStringList &)), this, SLOT(initPhaseWarnings(const QStringList &))); connect(clientSyncer, SIGNAL(connectionMsg(const QString &)), this, SLOT(initPhaseMsg(const QString &))); - connect(clientSyncer, SIGNAL(encrypted(bool)), this, SLOT(encrypted(bool))); connect(clientSyncer, SIGNAL(startLogin()), this, SLOT(startLogin())); connect(clientSyncer, SIGNAL(loginFailed(const QString &)), this, SLOT(loginFailed(const QString &))); connect(clientSyncer, SIGNAL(loginSuccess()), this, SLOT(startSync())); @@ -95,6 +100,7 @@ CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent) connect(clientSyncer, SIGNAL(sessionProgress(quint32, quint32)), this, SLOT(coreSessionProgress(quint32, quint32))); connect(clientSyncer, SIGNAL(networksProgress(quint32, quint32)), this, SLOT(coreNetworksProgress(quint32, quint32))); connect(clientSyncer, SIGNAL(syncFinished()), this, SLOT(syncFinished())); + connect(clientSyncer, SIGNAL(encrypted()), ui.secureConnection, SLOT(show())); connect(ui.user, SIGNAL(textChanged(const QString &)), this, SLOT(setLoginWidgetStates())); connect(ui.password, SIGNAL(textChanged(const QString &)), this, SLOT(setLoginWidgetStates())); @@ -219,16 +225,8 @@ void CoreConnectDlg::on_accountButtonBox_accepted() { } void CoreConnectDlg::on_useInternalCore_clicked() { - if(!_internalAccountId.isValid()) { - _internalAccountId = findFreeAccountId(); - QVariantMap data; - data["InternalAccount"] = true; - CoreAccountSettings accountSettings; - accountSettings.storeAccountData(_internalAccountId, data); - } - clientSyncer->useInternalCore(_internalAccountId); + clientSyncer->useInternalCore(); ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Cancel); - startSync(); } /***************************************************** @@ -266,15 +264,41 @@ void CoreConnectDlg::initPhaseError(const QString &error) { connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(reject())); } -void CoreConnectDlg::initPhaseMsg(const QString &msg) { - ui.coreInfoLabel->setText(msg); +void CoreConnectDlg::initPhaseWarnings(const QStringList &warnings) { + doingAutoConnect = false; + ui.secureConnection->hide(); + ui.connectIcon->setPixmap(BarIcon("dialog-warning")); + ui.connectLabel->setText(tr("
Errors occurred while connecting to \"%1\":
").arg(accountData["Host"].toString())); + QStringList warningItems; + foreach(QString warning, warnings) { + warningItems << QString("
  • %1
  • ").arg(warning); + } + ui.coreInfoLabel->setText(QString("
      %1
    ").arg(warningItems.join(""))); + ui.loginStack->setCurrentWidget(ui.connectionWarningsPage); + ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Cancel); + ui.loginButtonBox->button(QDialogButtonBox::Cancel)->setFocus(); + disconnect(ui.loginButtonBox, 0, this, 0); + connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull())); +} + +void CoreConnectDlg::on_viewSslCertButton_clicked() { +#ifdef HAVE_SSL + const QSslSocket *socket = qobject_cast(clientSyncer->currentDevice()); + if(!socket) + return; + + SslCertDisplayDialog dialog(socket->peerName(), socket->peerCertificate()); + dialog.exec(); +#endif } -void CoreConnectDlg::encrypted(bool useSsl) { - if(useSsl) - ui.secureConnection->show(); - else - ui.secureConnection->hide(); +void CoreConnectDlg::on_ignoreWarningsButton_clicked() { + clientSyncer->ignoreWarnings(ui.ignoreWarningsPermanently->isChecked()); +} + + +void CoreConnectDlg::initPhaseMsg(const QString &msg) { + ui.coreInfoLabel->setText(msg); } void CoreConnectDlg::initPhaseSocketState(QAbstractSocket::SocketState state) { @@ -530,3 +554,59 @@ void CoreAccountEditDlg::on_accountName_textChanged(const QString &text) { Q_UNUSED(text); setWidgetStates(); } + + +// ======================================== +// SslCertDisplayDialog +// ======================================== +SslCertDisplayDialog::SslCertDisplayDialog(const QString &host, const QSslCertificate &cert, QWidget *parent) + : QDialog(parent) +{ +#ifndef HAVE_SSL + Q_UNUSED(cert) +#else + + setWindowTitle(tr("SSL Certificate used by %1").arg(host)); + + QVBoxLayout *mainLayout = new QVBoxLayout(this); + + QGroupBox *issuerBox = new QGroupBox(tr("Issuer Info"), this); + QFormLayout *issuerLayout = new QFormLayout(issuerBox); + issuerLayout->addRow(tr("Organization:"), new QLabel(cert.issuerInfo(QSslCertificate::Organization), this)); + issuerLayout->addRow(tr("Locality Name:"), new QLabel(cert.issuerInfo(QSslCertificate::LocalityName), this)); + issuerLayout->addRow(tr("Organizational Unit Name:"), new QLabel(cert.issuerInfo(QSslCertificate::OrganizationalUnitName), this)); + issuerLayout->addRow(tr("Country Name:"), new QLabel(cert.issuerInfo(QSslCertificate::CountryName), this)); + issuerLayout->addRow(tr("State or Province Name:"), new QLabel(cert.issuerInfo(QSslCertificate::StateOrProvinceName), this)); + mainLayout->addWidget(issuerBox); + + QGroupBox *subjectBox = new QGroupBox(tr("Subject Info"), this); + QFormLayout *subjectLayout = new QFormLayout(subjectBox); + subjectLayout->addRow(tr("Organization:"), new QLabel(cert.subjectInfo(QSslCertificate::Organization), this)); + subjectLayout->addRow(tr("Locality Name:"), new QLabel(cert.subjectInfo(QSslCertificate::LocalityName), this)); + subjectLayout->addRow(tr("Organizational Unit Name:"), new QLabel(cert.subjectInfo(QSslCertificate::OrganizationalUnitName), this)); + subjectLayout->addRow(tr("Country Name:"), new QLabel(cert.subjectInfo(QSslCertificate::CountryName), this)); + subjectLayout->addRow(tr("State or Province Name:"), new QLabel(cert.subjectInfo(QSslCertificate::StateOrProvinceName), this)); + mainLayout->addWidget(subjectBox); + + QGroupBox *additionalBox = new QGroupBox(tr("Additional Info"), this); + QFormLayout *additionalLayout = new QFormLayout(additionalBox); + additionalLayout->addRow(tr("Valid From:"), new QLabel(cert.effectiveDate().toString(), this)); + additionalLayout->addRow(tr("Valid To:"), new QLabel(cert.expiryDate().toString(), this)); + QStringList hostnames = cert.alternateSubjectNames().values(QSsl::DnsEntry); + for(int i = 0; i < hostnames.count(); i++) { + additionalLayout->addRow(tr("Hostname %1:").arg(i + 1), new QLabel(hostnames[i], this)); + } + QStringList mailaddresses = cert.alternateSubjectNames().values(QSsl::EmailEntry); + for(int i = 0; i < mailaddresses.count(); i++) { + additionalLayout->addRow(tr("E-Mail Address %1:").arg(i + 1), new QLabel(mailaddresses[i], this)); + } + mainLayout->addWidget(additionalBox); + + + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, this); + mainLayout->addWidget(buttonBox); + + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); +#endif +};