From 6bcfaf51a90b3ec38cf8602cefd8aa8971d01586 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Thu, 19 Nov 2009 18:09:36 +0100 Subject: [PATCH] Kill CoreConnectDlg, kill it with fire! DIE DIE DIE --- src/qtui/CMakeLists.txt | 4 - src/qtui/coreconnectdlg.cpp | 612 ----------------------------- src/qtui/coreconnectdlg.h | 148 ------- src/qtui/mainwin.cpp | 7 +- src/qtui/mainwin.h | 1 - src/qtui/ui/coreaccounteditdlg.ui | 255 ------------ src/qtui/ui/coreconnectdlg.ui | 631 ------------------------------ 7 files changed, 1 insertion(+), 1657 deletions(-) delete mode 100644 src/qtui/coreconnectdlg.cpp delete mode 100644 src/qtui/coreconnectdlg.h delete mode 100644 src/qtui/ui/coreaccounteditdlg.ui delete mode 100644 src/qtui/ui/coreconnectdlg.ui diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index a0d16654..59d3ce8b 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -28,7 +28,6 @@ set(SOURCES chatviewsettings.cpp columnhandleitem.cpp coreconfigwizard.cpp - coreconnectdlg.cpp coreinfodlg.cpp debugbufferviewoverlay.cpp debugconsole.cpp @@ -73,7 +72,6 @@ set(MOC_HDRS chatviewsearchcontroller.h columnhandleitem.h coreconfigwizard.h - coreconnectdlg.h coreinfodlg.h debugbufferviewoverlay.h debugconsole.h @@ -113,12 +111,10 @@ set(FORMS bufferwidget.ui channellistdlg.ui chatviewsearchbar.ui - coreaccounteditdlg.ui coreconfigwizardintropage.ui coreconfigwizardadminuserpage.ui coreconfigwizardstorageselectionpage.ui coreconfigwizardsyncpage.ui - coreconnectdlg.ui coreinfodlg.ui debugbufferviewoverlay.ui debugconsole.ui diff --git a/src/qtui/coreconnectdlg.cpp b/src/qtui/coreconnectdlg.cpp deleted file mode 100644 index e6d30625..00000000 --- a/src/qtui/coreconnectdlg.cpp +++ /dev/null @@ -1,612 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * - * devel@quassel-irc.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) version 3. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "coreconnectdlg.h" - -#include -#include -#include -#include - -#ifdef HAVE_SSL -#include -#include -#endif - -#include "client.h" -#include "clientsettings.h" -#include "clientsyncer.h" -#include "coreconfigwizard.h" -#include "iconloader.h" -#include "quassel.h" -#include "util.h" - -CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent) - : QDialog(parent), - _internalAccountId(0) -{ - ui.setupUi(this); - ui.editAccount->setIcon(SmallIcon("document-properties")); - ui.addAccount->setIcon(SmallIcon("list-add")); - ui.deleteAccount->setIcon(SmallIcon("list-remove")); - ui.connectIcon->setPixmap(BarIcon("network-disconnect")); - ui.secureConnection->setPixmap(SmallIcon("document-encrypt")); - - if(Quassel::runMode() != Quassel::Monolithic) { - ui.useInternalCore->hide(); - } - - // make it look more native under Mac OS X: - setWindowFlags(Qt::Sheet); - - clientSyncer = new ClientSyncer(this); - Client::registerClientSyncer(clientSyncer); - - wizard = 0; - - doingAutoConnect = false; - - ui.stackedWidget->setCurrentWidget(ui.accountPage); - - CoreAccountSettings s; - AccountId lastacc = s.lastAccount(); - autoConnectAccount = s.autoConnectAccount(); - QListWidgetItem *currentItem = 0; - foreach(AccountId id, s.knownAccounts()) { - if(!id.isValid()) continue; - QVariantMap data = s.retrieveAccountData(id); - if(data.contains("InternalAccount") && data["InternalAccount"].toBool()) { - _internalAccountId = id; - continue; - } - data["AccountId"] = QVariant::fromValue(id); - accounts[id] = data; - QListWidgetItem *item = new QListWidgetItem(data["AccountName"].toString(), ui.accountList); - item->setData(Qt::UserRole, QVariant::fromValue(id)); - if(id == lastacc) currentItem = item; - } - if(currentItem) ui.accountList->setCurrentItem(currentItem); - else ui.accountList->setCurrentRow(0); - - setAccountWidgetStates(); - - ui.accountButtonBox->button(QDialogButtonBox::Ok)->setFocus(); - //ui.accountButtonBox->button(QDialogButtonBox::Ok)->setAutoDefault(true); - - 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(startLogin()), this, SLOT(startLogin())); - connect(clientSyncer, SIGNAL(loginFailed(const QString &)), this, SLOT(loginFailed(const QString &))); - connect(clientSyncer, SIGNAL(loginSuccess()), this, SLOT(startSync())); - connect(clientSyncer, SIGNAL(startCoreSetup(const QVariantList &)), this, SLOT(startCoreConfig(const QVariantList &))); - 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())); - - connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull())); - connect(ui.syncButtonBox->button(QDialogButtonBox::Abort), SIGNAL(clicked()), this, SLOT(restartPhaseNull())); - - if(autoconnect && ui.accountList->count() && autoConnectAccount.isValid() - && autoConnectAccount == ui.accountList->currentItem()->data(Qt::UserRole).value()) { - doingAutoConnect = true; - on_accountButtonBox_accepted(); - } -} - -CoreConnectDlg::~CoreConnectDlg() { - if(ui.accountList->selectedItems().count()) { - CoreAccountSettings s; - s.setLastAccount(ui.accountList->selectedItems()[0]->data(Qt::UserRole).value()); - } -} - - -/**************************************************** - * Account Management - ***************************************************/ - -void CoreConnectDlg::on_accountList_itemSelectionChanged() { - setAccountWidgetStates(); -} - -void CoreConnectDlg::setAccountWidgetStates() { - QList selectedItems = ui.accountList->selectedItems(); - ui.editAccount->setEnabled(selectedItems.count()); - ui.deleteAccount->setEnabled(selectedItems.count()); - ui.autoConnect->setEnabled(selectedItems.count()); - if(selectedItems.count()) { - ui.autoConnect->setChecked(selectedItems[0]->data(Qt::UserRole).value() == autoConnectAccount); - } - ui.accountButtonBox->button(QDialogButtonBox::Ok)->setEnabled(ui.accountList->count()); -} - -void CoreConnectDlg::on_autoConnect_clicked(bool state) { - if(!state) { - autoConnectAccount = 0; - } else { - if(ui.accountList->selectedItems().count()) { - autoConnectAccount = ui.accountList->selectedItems()[0]->data(Qt::UserRole).value(); - } else { - qWarning() << "Checked auto connect without an enabled item!"; // should never happen! - autoConnectAccount = 0; - } - } - setAccountWidgetStates(); -} - -void CoreConnectDlg::on_addAccount_clicked() { - QStringList existing; - for(int i = 0; i < ui.accountList->count(); i++) existing << ui.accountList->item(i)->text(); - CoreAccountEditDlg dlg(0, QVariantMap(), existing, this); - if(dlg.exec() == QDialog::Accepted) { - AccountId id = findFreeAccountId(); - QVariantMap data = dlg.accountData(); - data["AccountId"] = QVariant::fromValue(id); - accounts[id] = data; - QListWidgetItem *item = new QListWidgetItem(data["AccountName"].toString(), ui.accountList); - item->setData(Qt::UserRole, QVariant::fromValue(id)); - ui.accountList->setCurrentItem(item); - } -} - -void CoreConnectDlg::on_editAccount_clicked() { - QStringList existing; - for(int i = 0; i < ui.accountList->count(); i++) existing << ui.accountList->item(i)->text(); - AccountId id = ui.accountList->currentItem()->data(Qt::UserRole).value(); - QVariantMap acct = accounts[id]; - CoreAccountEditDlg dlg(id, acct, existing, this); - if(dlg.exec() == QDialog::Accepted) { - QVariantMap data = dlg.accountData(); - ui.accountList->currentItem()->setText(data["AccountName"].toString()); - accounts[id] = data; - } -} - -void CoreConnectDlg::on_deleteAccount_clicked() { - AccountId id = ui.accountList->currentItem()->data(Qt::UserRole).value(); - int ret = QMessageBox::question(this, tr("Remove Account Settings"), - tr("Do you really want to remove your local settings for this Quassel Core account?
" - "Note: This will not remove or change any data on the Core itself!"), - QMessageBox::Yes|QMessageBox::No, QMessageBox::No); - if(ret == QMessageBox::Yes) { - int idx = ui.accountList->currentRow(); - delete ui.accountList->takeItem(idx); - ui.accountList->setCurrentRow(qMin(idx, ui.accountList->count()-1)); - accounts[id]["Delete"] = true; // we only flag this here, actual deletion happens on accept! - setAccountWidgetStates(); - } -} - -void CoreConnectDlg::on_accountList_itemDoubleClicked(QListWidgetItem *item) { - Q_UNUSED(item); - on_accountButtonBox_accepted(); -} - -void CoreConnectDlg::on_accountButtonBox_accepted() { - // save accounts - CoreAccountSettings s; - foreach(QVariantMap acct, accounts.values()) { - AccountId id = acct["AccountId"].value(); - if(acct.contains("Delete")) { - s.removeAccount(id); - } else { - s.storeAccountData(id, acct); - } - } - s.setAutoConnectAccount(autoConnectAccount); - - ui.stackedWidget->setCurrentWidget(ui.loginPage); - account = ui.accountList->currentItem()->data(Qt::UserRole).value(); - accountData = accounts[account]; - s.setLastAccount(account); - connectToCore(); -} - -void CoreConnectDlg::on_useInternalCore_clicked() { - clientSyncer->useInternalCore(); - ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Cancel); -} - -/***************************************************** - * Connecting to the Core - ****************************************************/ - -/*** Phase One: initializing the core connection ***/ - -void CoreConnectDlg::connectToCore() { - ui.secureConnection->hide(); - ui.connectIcon->setPixmap(BarIcon("network-disconnect")); - ui.connectLabel->setText(tr("Connect to %1").arg(accountData["Host"].toString())); - ui.coreInfoLabel->setText(""); - ui.loginStack->setCurrentWidget(ui.loginEmptyPage); - ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); - ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDefault(true); - ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDisabled(true); - disconnect(ui.loginButtonBox, 0, this, 0); - connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull())); - - clientSyncer->connectToCore(accountData); -} - -void CoreConnectDlg::initPhaseError(const QString &error) { - doingAutoConnect = false; - ui.secureConnection->hide(); - ui.connectIcon->setPixmap(BarIcon("dialog-error")); - //ui.connectLabel->setBrush(QBrush("red")); - ui.connectLabel->setText(tr("
Connection to %1 failed!
").arg(accountData["Host"].toString())); - ui.coreInfoLabel->setText(error); - ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Retry|QDialogButtonBox::Cancel); - ui.loginButtonBox->button(QDialogButtonBox::Retry)->setFocus(); - disconnect(ui.loginButtonBox, 0, this, 0); - connect(ui.loginButtonBox, SIGNAL(accepted()), this, SLOT(restartPhaseNull())); - connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(reject())); -} - -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::on_ignoreWarningsButton_clicked() { - clientSyncer->ignoreWarnings(ui.ignoreWarningsPermanently->isChecked()); -} - - -void CoreConnectDlg::initPhaseMsg(const QString &msg) { - ui.coreInfoLabel->setText(msg); -} - -void CoreConnectDlg::initPhaseSocketState(QAbstractSocket::SocketState state) { - QString s; - QString host = accountData["Host"].toString(); - switch(state) { - case QAbstractSocket::UnconnectedState: s = tr("Not connected to %1.").arg(host); break; - case QAbstractSocket::HostLookupState: s = tr("Looking up %1...").arg(host); break; - case QAbstractSocket::ConnectingState: s = tr("Connecting to %1...").arg(host); break; - case QAbstractSocket::ConnectedState: s = tr("Connected to %1").arg(host); break; - default: s = tr("Unknown connection state to %1"); break; - } - ui.connectLabel->setText(s); -} - -void CoreConnectDlg::restartPhaseNull() { - doingAutoConnect = false; - ui.stackedWidget->setCurrentWidget(ui.accountPage); - clientSyncer->disconnectFromCore(); -} - -/********************************************************* - * Phase Two: Login - *********************************************************/ - -void CoreConnectDlg::startLogin() { - ui.connectIcon->setPixmap(BarIcon("network-connect")); - ui.loginStack->setCurrentWidget(ui.loginCredentialsPage); - //ui.loginStack->setMinimumSize(ui.loginStack->sizeHint()); ui.loginStack->updateGeometry(); - ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); - ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDefault(true); - ui.loginButtonBox->button(QDialogButtonBox::Ok)->setFocus(); - if(!accountData["User"].toString().isEmpty()) { - ui.user->setText(accountData["User"].toString()); - if(accountData["RememberPasswd"].toBool()) { - ui.password->setText(accountData["Password"].toString()); - ui.rememberPasswd->setChecked(true); - ui.loginButtonBox->button(QDialogButtonBox::Ok)->setFocus(); - } else { - ui.rememberPasswd->setChecked(false); - ui.password->setFocus(); - } - } else ui.user->setFocus(); - disconnect(ui.loginButtonBox, 0, this, 0); - connect(ui.loginButtonBox, SIGNAL(accepted()), this, SLOT(doLogin())); - connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull())); - if(doingAutoConnect) doLogin(); -} - -void CoreConnectDlg::doLogin() { - QVariantMap loginData; - loginData["User"] = ui.user->text(); - loginData["Password"] = ui.password->text(); - loginData["RememberPasswd"] = ui.rememberPasswd->isChecked(); - doLogin(loginData); -} - -void CoreConnectDlg::doLogin(const QVariantMap &loginData) { - disconnect(ui.loginButtonBox, 0, this, 0); - connect(ui.loginButtonBox, SIGNAL(accepted()), this, SLOT(doLogin())); - connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull())); - ui.loginStack->setCurrentWidget(ui.loginCredentialsPage); - ui.loginGroup->setTitle(tr("Logging in...")); - ui.user->setDisabled(true); - ui.password->setDisabled(true); - ui.rememberPasswd->setDisabled(true); - ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDisabled(true); - accountData["User"] = loginData["User"]; - accountData["RememberPasswd"] = loginData["RememberPasswd"]; - if(loginData["RememberPasswd"].toBool()) accountData["Password"] = loginData["Password"]; - else accountData.remove("Password"); - ui.user->setText(loginData["User"].toString()); - ui.password->setText(loginData["Password"].toString()); - ui.rememberPasswd->setChecked(loginData["RememberPasswd"].toBool()); - CoreAccountSettings s; - s.storeAccountData(account, accountData); - clientSyncer->loginToCore(loginData["User"].toString(), loginData["Password"].toString()); -} - -void CoreConnectDlg::setLoginWidgetStates() { - ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDisabled(ui.user->text().isEmpty() || ui.password->text().isEmpty()); -} - -void CoreConnectDlg::loginFailed(const QString &error) { - if(wizard) { - wizard->reject(); - } - ui.connectIcon->setPixmap(BarIcon("dialog-error")); - ui.loginStack->setCurrentWidget(ui.loginCredentialsPage); - ui.loginGroup->setTitle(tr("Login")); - ui.user->setEnabled(true); - ui.password->setEnabled(true); - ui.rememberPasswd->setEnabled(true); - ui.coreInfoLabel->setText(error); - ui.loginButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true); - ui.password->setFocus(); - doingAutoConnect = false; -} - -void CoreConnectDlg::startCoreConfig(const QVariantList &backends) { - storageBackends = backends; - ui.loginStack->setCurrentWidget(ui.coreConfigPage); - - //on_launchCoreConfigWizard_clicked(); - -} - -void CoreConnectDlg::on_launchCoreConfigWizard_clicked() { - Q_ASSERT(!wizard); - wizard = new CoreConfigWizard(storageBackends, this); - connect(wizard, SIGNAL(setupCore(const QVariant &)), clientSyncer, SLOT(doCoreSetup(const QVariant &))); - connect(wizard, SIGNAL(loginToCore(const QVariantMap &)), this, SLOT(doLogin(const QVariantMap &))); - connect(clientSyncer, SIGNAL(coreSetupSuccess()), wizard, SLOT(coreSetupSuccess())); - connect(clientSyncer, SIGNAL(coreSetupFailed(const QString &)), wizard, SLOT(coreSetupFailed(const QString &))); - connect(wizard, SIGNAL(accepted()), this, SLOT(configWizardAccepted())); - connect(wizard, SIGNAL(rejected()), this, SLOT(configWizardRejected())); - connect(clientSyncer, SIGNAL(loginSuccess()), wizard, SLOT(loginSuccess())); - connect(clientSyncer, SIGNAL(syncFinished()), wizard, SLOT(syncFinished())); - wizard->show(); -} - -void CoreConnectDlg::configWizardAccepted() { - - wizard->deleteLater(); - wizard = 0; -} - -void CoreConnectDlg::configWizardRejected() { - - wizard->deleteLater(); - wizard = 0; - //exit(1); // FIXME -} - - -/************************************************************ - * Phase Three: Syncing - ************************************************************/ - -void CoreConnectDlg::startSync() { - ui.sessionProgress->setRange(0, 1); - ui.sessionProgress->setValue(0); - ui.networksProgress->setRange(0, 1); - ui.networksProgress->setValue(0); - - ui.stackedWidget->setCurrentWidget(ui.syncPage); - // clean up old page - ui.loginGroup->setTitle(tr("Login")); - ui.user->setEnabled(true); - ui.password->setEnabled(true); - ui.rememberPasswd->setEnabled(true); - if(ui.loginButtonBox->standardButtons() & QDialogButtonBox::Ok) // in mono mode we don't show an Ok Button - ui.loginButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true); -} - -void CoreConnectDlg::coreSessionProgress(quint32 val, quint32 max) { - ui.sessionProgress->setRange(0, max); - ui.sessionProgress->setValue(val); - -} - -void CoreConnectDlg::coreNetworksProgress(quint32 val, quint32 max) { - if(max == 0) { - ui.networksProgress->setFormat("0/0"); - ui.networksProgress->setRange(0, 1); - ui.networksProgress->setValue(1); - } else { - ui.networksProgress->setFormat("%v/%m"); - ui.networksProgress->setRange(0, max); - ui.networksProgress->setValue(val); - } -} - -void CoreConnectDlg::syncFinished() { - if(!wizard) accept(); - else { - hide(); - disconnect(wizard, 0, this, 0); - connect(wizard, SIGNAL(finished(int)), this, SLOT(accept())); - } -} - -AccountId CoreConnectDlg::findFreeAccountId() { - for(AccountId i = 1;; i++) { - if(!accounts.contains(i) && i != _internalAccountId) - return i; - } -} - -/***************************************************************************************** - * CoreAccountEditDlg - *****************************************************************************************/ -CoreAccountEditDlg::CoreAccountEditDlg(AccountId id, const QVariantMap &acct, const QStringList &_existing, QWidget *parent) - : QDialog(parent) -{ - ui.setupUi(this); - ui.useSsl->setIcon(SmallIcon("document-encrypt")); - - existing = _existing; - if(id.isValid()) { - account = acct; - - existing.removeAll(acct["AccountName"].toString()); - ui.host->setText(acct["Host"].toString()); - ui.port->setValue(acct["Port"].toUInt()); - ui.accountName->setText(acct["AccountName"].toString()); -#ifdef HAVE_SSL - ui.useSsl->setChecked(acct["useSsl"].toBool()); -#else - ui.useSsl->setChecked(false); - ui.useSsl->setEnabled(false); -#endif - ui.useProxy->setChecked(acct["useProxy"].toBool()); - ui.proxyHost->setText(acct["proxyHost"].toString()); - ui.proxyPort->setValue(acct["proxyPort"].toUInt()); - ui.proxyType->setCurrentIndex(acct["proxyType"].toInt() == QNetworkProxy::Socks5Proxy ? 0 : 1); - ui.proxyUser->setText(acct["proxyUser"].toString()); - ui.proxyPassword->setText(acct["proxyPassword"].toString()); - } else { - setWindowTitle(tr("Add Core Account")); -#ifndef HAVE_SSL - ui.useSsl->setChecked(false); - ui.useSsl->setEnabled(false); -#endif - } -} - -QVariantMap CoreAccountEditDlg::accountData() { - account["AccountName"] = ui.accountName->text().trimmed(); - account["Host"] = ui.host->text().trimmed(); - account["Port"] = ui.port->value(); - account["useSsl"] = ui.useSsl->isChecked(); - account["useProxy"] = ui.useProxy->isChecked(); - account["proxyHost"] = ui.proxyHost->text().trimmed(); - account["proxyPort"] = ui.proxyPort->value(); - account["proxyType"] = ui.proxyType->currentIndex() == 0 ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy; - account["proxyUser"] = ui.proxyUser->text().trimmed(); - account["proxyPassword"] = ui.proxyPassword->text().trimmed(); - return account; -} - -void CoreAccountEditDlg::setWidgetStates() { - bool ok = !ui.accountName->text().trimmed().isEmpty() && !existing.contains(ui.accountName->text()) && !ui.host->text().isEmpty(); - ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok); -} - -void CoreAccountEditDlg::on_host_textChanged(const QString &text) { - Q_UNUSED(text); - setWidgetStates(); -} - -void CoreAccountEditDlg::on_accountName_textChanged(const QString &text) { - Q_UNUSED(text); - setWidgetStates(); -} - - - -// ======================================== -// SslCertDisplayDialog -// ======================================== -#ifdef HAVE_SSL -SslCertDisplayDialog::SslCertDisplayDialog(const QString &host, const QSslCertificate &cert, QWidget *parent) - : QDialog(parent) -{ - 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)); - } - additionalLayout->addRow(tr("Digest:"), new QLabel(QString(prettyDigest(cert.digest())))); - 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 diff --git a/src/qtui/coreconnectdlg.h b/src/qtui/coreconnectdlg.h deleted file mode 100644 index 70cab9a7..00000000 --- a/src/qtui/coreconnectdlg.h +++ /dev/null @@ -1,148 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * - * devel@quassel-irc.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) version 3. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef CORECONNECTDLG_H -#define CORECONNECTDLG_H - -#include - -#include "types.h" - -#include "ui_coreconnectdlg.h" -#include "ui_coreaccounteditdlg.h" - -class ClientSyncer; -class CoreConfigWizard; - -class CoreConnectDlg : public QDialog { - Q_OBJECT - -public: - CoreConnectDlg(bool = false, QWidget *parent = 0); - ~CoreConnectDlg(); - -// signals: -// void newClientSyncer(ClientSyncer *); - -private slots: - /*** Phase Null: Accounts ***/ - void restartPhaseNull(); - - void on_accountList_itemSelectionChanged(); - void on_autoConnect_clicked(bool); - - void on_addAccount_clicked(); - void on_editAccount_clicked(); - void on_deleteAccount_clicked(); - void on_useInternalCore_clicked(); - void on_viewSslCertButton_clicked(); - void on_ignoreWarningsButton_clicked(); - - void on_accountList_itemDoubleClicked(QListWidgetItem *item); - void on_accountButtonBox_accepted(); - - void setAccountWidgetStates(); - - /*** Phase One: Connection ***/ - void connectToCore(); - - void initPhaseError(const QString &error); - void initPhaseWarnings(const QStringList &warnings); - void initPhaseMsg(const QString &msg); - void initPhaseSocketState(QAbstractSocket::SocketState); - - /*** Phase Two: Login ***/ - void startLogin(); - void doLogin(); - void doLogin(const QVariantMap &loginData); - void loginFailed(const QString &); - void startCoreConfig(const QVariantList &backends); - void configWizardAccepted(); - void configWizardRejected(); - void on_launchCoreConfigWizard_clicked(); - - void setLoginWidgetStates(); - - /*** Phase Three: Sync ***/ - void startSync(); - void syncFinished(); - - void coreSessionProgress(quint32, quint32); - void coreNetworksProgress(quint32, quint32); - -private: - AccountId findFreeAccountId(); - - Ui::CoreConnectDlg ui; - - AccountId autoConnectAccount; - QHash accounts; - AccountId _internalAccountId; - QVariantMap accountData; - AccountId account; - - bool doingAutoConnect; - - QVariantList storageBackends; - - ClientSyncer *clientSyncer; - CoreConfigWizard *wizard; -}; - - -// ======================================== -// CoreAccountEditDlg -// ======================================== -class CoreAccountEditDlg : public QDialog { - Q_OBJECT - -public: - CoreAccountEditDlg(AccountId id, const QVariantMap &data, const QStringList &existing = QStringList(), QWidget *parent = 0); - - QVariantMap accountData(); - -private slots: - void on_host_textChanged(const QString &); - void on_accountName_textChanged(const QString &); - - void setWidgetStates(); - -private: - Ui::CoreAccountEditDlg ui; - - QStringList existing; - QVariantMap account; -}; - -// ======================================== -// SslCertDisplayDialog -// ======================================== -#ifdef HAVE_SSL -class QSslCertificate; - -class SslCertDisplayDialog : public QDialog { - Q_OBJECT - -public: - SslCertDisplayDialog(const QString &host, const QSslCertificate &cert, QWidget *parent = 0); -}; -#endif // HAVE_SSL - -#endif // CORECONNECTDLG_H diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 21d4959b..df1a7dcf 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -57,7 +57,6 @@ #include "clientbufferviewmanager.h" #include "clientignorelistmanager.h" #include "coreinfodlg.h" -#include "coreconnectdlg.h" #include "contextmenuactionprovider.h" #include "debugbufferviewoverlay.h" #include "debuglogwidget.h" @@ -212,7 +211,7 @@ void MainWin::init() { QtUi::actionCollection("General")->action("LockLayout")->setChecked(s.value("LockLayout", false).toBool()); if(Quassel::runMode() != Quassel::Monolithic) { - showCoreConnectionDlg(true); // autoconnect if appropriate + //showCoreConnectionDlg(true); // autoconnect if appropriate } else { startInternalCore(); } @@ -826,10 +825,6 @@ void MainWin::startInternalCore() { syncer->useInternalCore(); } -void MainWin::showCoreConnectionDlg(bool autoConnect) { - CoreConnectDlg(autoConnect, this).exec(); -} - void MainWin::showChannelList(NetworkId netId) { ChannelListDlg *channelListDlg = new ChannelListDlg(); diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index bee2cd27..7379f964 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -118,7 +118,6 @@ class MainWin void showAboutDlg(); void showChannelList(NetworkId netId = NetworkId()); void startInternalCore(); - void showCoreConnectionDlg(bool autoConnect = false); void showCoreInfoDlg(); void showAwayLog(); void showSettingsDlg(); diff --git a/src/qtui/ui/coreaccounteditdlg.ui b/src/qtui/ui/coreaccounteditdlg.ui deleted file mode 100644 index fcacc1c4..00000000 --- a/src/qtui/ui/coreaccounteditdlg.ui +++ /dev/null @@ -1,255 +0,0 @@ - - CoreAccountEditDlg - - - - 0 - 0 - 509 - 458 - - - - Edit Core Account - - - - - - - - Account Details - - - - - - - - Account Name: - - - - - - - Local Core - - - - - - - - - - - Hostname: - - - - - - - Port: - - - - - - - localhost - - - - - - - 1 - - - 65535 - - - 4242 - - - - - - - Use secure connection (SSL) - - - - :/16x16/actions/oxygen/16x16/actions/document-encrypt.png:/16x16/actions/oxygen/16x16/actions/document-encrypt.png - - - false - - - - - - - - - Use a proxy: - - - true - - - false - - - - - - Proxy Type: - - - - - - - - Socks 5 - - - - - HTTP - - - - - - - - Proxy Host: - - - - - - - Proxy Port: - - - - - - - localhost - - - - - - - - 0 - 0 - - - - 1 - - - 65535 - - - 8080 - - - - - - - Proxy Username: - - - - - - - - - - Proxy Password: - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - buttonBox - accepted() - CoreAccountEditDlg - accept() - - - 275 - 521 - - - 157 - 207 - - - - - buttonBox - rejected() - CoreAccountEditDlg - reject() - - - 343 - 521 - - - 286 - 207 - - - - - diff --git a/src/qtui/ui/coreconnectdlg.ui b/src/qtui/ui/coreconnectdlg.ui deleted file mode 100644 index f876bb7f..00000000 --- a/src/qtui/ui/coreconnectdlg.ui +++ /dev/null @@ -1,631 +0,0 @@ - - - CoreConnectDlg - - - - 0 - 0 - 539 - 347 - - - - - 0 - 0 - - - - Connect to Quassel Core - - - - :/16x16/actions/network-disconnect:/16x16/actions/network-disconnect - - - - 0 - - - - - - 0 - 0 - - - - 0 - - - - - - - Connect to Quassel Core - - - - - - true - - - - - - - - - Edit... - - - - :/16x16/actions/oxygen/16x16/actions/document-properties.png:/16x16/actions/oxygen/16x16/actions/document-properties.png - - - - - - - Add... - - - - :/16x16/actions/oxygen/16x16/actions/list-add.png:/16x16/actions/oxygen/16x16/actions/list-add.png - - - - - - - Delete - - - - :/16x16/actions/oxygen/16x16/actions/list-remove.png:/16x16/actions/oxygen/16x16/actions/list-remove.png - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Use internal core - - - - - - - - - - - - - - Always use this account - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - - - - 0 - 0 - - - - Initializing your connection - - - - - - - - - - - :/22x22/actions/network-disconnect - - - - - - - Connected to apollo.mindpool.net. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - - Qt::Horizontal - - - - 358 - 21 - - - - - - - - - 0 - 0 - - - - THIS IS A PLACEHOLDER -TO -RESERVE -SOME SPACE - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - - - - :/22x22/actions/oxygen/22x22/actions/document-encrypt.png - - - - - - - - - - 0 - 0 - - - - 1 - - - - - 0 - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - Login - - - - - - - - User: - - - - - - - - - - - - - - Password: - - - - - - - QLineEdit::Password - - - - - - - Remember - - - - - - - - - - - - - - 0 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - View SSL Certificate - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 48 - - - - - - - - - - Add to known hosts - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Continue connection - - - - - - - - - - - 0 - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - Configure your Quassel Core - - - - - - The Quassel Core you are connected to is not configured yet. You may now launch a configuration wizard that helps you setting up your Core. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Launch Wizard - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - label_7 - - - - - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - Initializing your session... - - - - - - - - <b>Please be patient while your client synchronizes with the Quassel Core!</b> - - - Qt::AlignHCenter|Qt::AlignTop - - - true - - - - - - - - - Session state: - - - - - - - 1 - - - 0 - - - - - - - Network states: - - - - - - - 1 - - - 0 - - - 0/0 - - - - - - - - - Qt::Vertical - - - - 483 - 61 - - - - - - - - - - - - - QDialogButtonBox::Abort - - - true - - - - - - - - - - - accountList - accountButtonBox - autoConnect - editAccount - addAccount - deleteAccount - user - password - rememberPasswd - loginButtonBox - launchCoreConfigWizard - syncButtonBox - - - - - accountButtonBox - rejected() - CoreConnectDlg - reject() - - - 279 - 434 - - - 286 - 237 - - - - - -- 2.20.1