From: Manuel Nickschas Date: Sat, 28 Nov 2009 23:18:53 +0000 (+0100) Subject: Reenable CoreConfigWizard X-Git-Tag: 0.6-beta1~147 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=f8c55c528ed7e5e1fd0090b4bbd6ef30d9c0f251 Reenable CoreConfigWizard Adapt the wizard to CoreConnection and make it work again. --- diff --git a/src/client/coreconnection.cpp b/src/client/coreconnection.cpp index 3d769cc3..3a6b7845 100644 --- a/src/client/coreconnection.cpp +++ b/src/client/coreconnection.cpp @@ -200,9 +200,9 @@ void CoreConnection::coreHasData() { disconnectFromCore(); return; } else if(msg["MsgType"] == "CoreSetupAck") { - //emit coreSetupSuccess(); + emit coreSetupSuccess(); } else if(msg["MsgType"] == "CoreSetupReject") { - //emit coreSetupFailed(msg["Error"].toString()); + emit coreSetupFailed(msg["Error"].toString()); } else if(msg["MsgType"] == "ClientLoginReject") { loginFailed(msg["Error"].toString()); } else if(msg["MsgType"] == "ClientLoginAck") { @@ -459,6 +459,13 @@ void CoreConnection::connectionReady() { _coreMsgBuffer.clear(); } +void CoreConnection::loginToCore(const QString &user, const QString &password, bool remember) { + _account.setUser(user); + _account.setPassword(password); + _account.setStorePassword(remember); + loginToCore(); +} + void CoreConnection::loginToCore(const QString &prevError) { emit connectionMsg(tr("Logging in...")); if(currentAccount().user().isEmpty() || currentAccount().password().isEmpty() || !prevError.isEmpty()) { @@ -565,3 +572,10 @@ void CoreConnection::checkSyncState() { emit synchronized(); } } + +void CoreConnection::doCoreSetup(const QVariant &setupData) { + QVariantMap setup; + setup["MsgType"] = "CoreSetupData"; + setup["SetupData"] = setupData; + SignalProxy::writeDataToDevice(_socket, setup); +} diff --git a/src/client/coreconnection.h b/src/client/coreconnection.h index 5342636f..2f9d7cc4 100644 --- a/src/client/coreconnection.h +++ b/src/client/coreconnection.h @@ -90,6 +90,9 @@ signals: void progressTextChanged(const QString &); void startCoreSetup(const QVariantList &); + void coreSetupSuccess(); + void coreSetupFailed(const QString &error); + void startInternalCore(); void connectToInternalCore(SignalProxy *proxy); @@ -122,12 +125,14 @@ private slots: void resetConnection(); void connectionReady(); - //void doCoreSetup(const QVariant &setupData); + void loginToCore(const QString &user, const QString &password, bool remember); // for config wizard void loginToCore(const QString &previousError = QString()); void loginSuccess(); void loginFailed(const QString &errorMessage); + void doCoreSetup(const QVariant &setupData); + void updateProgress(int value, int maximum); void setProgressText(const QString &text); void setProgressValue(int value); @@ -159,6 +164,8 @@ private: QString _coreInfoString(const QVariantMap &); inline CoreAccountModel *accountModel() const; + + friend class CoreConfigWizard; }; Q_DECLARE_METATYPE(CoreConnection::ConnectionState) diff --git a/src/qtui/coreconfigwizard.cpp b/src/qtui/coreconfigwizard.cpp index 0d5c9778..837b0844 100644 --- a/src/qtui/coreconfigwizard.cpp +++ b/src/qtui/coreconfigwizard.cpp @@ -24,15 +24,24 @@ #include #include "coreconfigwizard.h" +#include "coreconnection.h" #include "iconloader.h" -CoreConfigWizard::CoreConfigWizard(const QList &backends, QWidget *parent) : QWizard(parent) { - foreach(QVariant v, backends) _backends[v.toMap()["DisplayName"].toString()] = v; +CoreConfigWizard::CoreConfigWizard(CoreConnection *connection, const QList &backends, QWidget *parent) + : QWizard(parent), + _connection(connection) +{ + setModal(true); + setAttribute(Qt::WA_DeleteOnClose); + + foreach(const QVariant &v, backends) + _backends[v.toMap()["DisplayName"].toString()] = v; + setPage(IntroPage, new CoreConfigWizardPages::IntroPage(this)); setPage(AdminUserPage, new CoreConfigWizardPages::AdminUserPage(this)); setPage(StorageSelectionPage, new CoreConfigWizardPages::StorageSelectionPage(_backends, this)); syncPage = new CoreConfigWizardPages::SyncPage(this); - connect(syncPage, SIGNAL(setupCore(const QString &, const QVariantMap &)), this, SLOT(prepareCoreSetup(const QString &, const QVariantMap &))); + connect(syncPage, SIGNAL(setupCore(const QString &, const QVariantMap &)), SLOT(prepareCoreSetup(const QString &, const QVariantMap &))); setPage(SyncPage, syncPage); syncRelayPage = new CoreConfigWizardPages::SyncRelayPage(this); connect(syncRelayPage, SIGNAL(startOver()), this, SLOT(startOver())); @@ -59,6 +68,12 @@ CoreConfigWizard::CoreConfigWizard(const QList &backends, QWidget *par setWindowTitle(tr("Core Configuration Wizard")); setPixmap(QWizard::LogoPixmap, DesktopIcon("quassel")); + + connect(connection, SIGNAL(coreSetupSuccess()), SLOT(coreSetupSuccess())); + connect(connection, SIGNAL(coreSetupFailed(QString)), SLOT(coreSetupFailed(QString))); + //connect(connection, SIGNAL(loginSuccess()), SLOT(loginSuccess())); + connect(connection, SIGNAL(synchronized()), SLOT(syncFinished())); + connect(this, SIGNAL(rejected()), connection, SLOT(disconnectFromCore())); } QHash CoreConfigWizard::backends() const { @@ -75,18 +90,14 @@ void CoreConfigWizard::prepareCoreSetup(const QString &backend, const QVariantMa foo["AdminPasswd"] = field("adminUser.password").toString(); foo["Backend"] = backend; foo["ConnectionProperties"] = properties; - emit setupCore(foo); + coreConnection()->doCoreSetup(foo); } void CoreConfigWizard::coreSetupSuccess() { syncPage->setStatus(tr("Your core has been successfully configured. Logging you in...")); syncPage->setError(false); syncRelayPage->setMode(CoreConfigWizardPages::SyncRelayPage::Error); - QVariantMap loginData; - loginData["User"] = field("adminUser.user"); - loginData["Password"] = field("adminUser.password"); - loginData["RememberPasswd"] = field("adminUser.rememberPasswd"); - emit loginToCore(loginData); + coreConnection()->loginToCore(field("adminUser.user").toString(), field("adminUser.password").toString(), field("adminUser.rememberPasswd").toBool()); } void CoreConfigWizard::coreSetupFailed(const QString &error) { @@ -112,8 +123,7 @@ void CoreConfigWizard::loginSuccess() { } void CoreConfigWizard::syncFinished() { - // TODO: display identities and networks settings if appropriate! - // accept(); + accept(); } namespace CoreConfigWizardPages { @@ -201,22 +211,22 @@ QVariantMap StorageSelectionPage::connectionProperties() const { QWidget *widget = _connectionBox->findChild(key); QVariant def; if(defaults.contains(key)) { - def = defaults[key]; + def = defaults[key]; } switch(def.type()) { case QVariant::Int: - { - QSpinBox *spinbox = qobject_cast(widget); - Q_ASSERT(spinbox); - def = QVariant(spinbox->value()); - } - break; + { + QSpinBox *spinbox = qobject_cast(widget); + Q_ASSERT(spinbox); + def = QVariant(spinbox->value()); + } + break; default: - { - QLineEdit *lineEdit = qobject_cast(widget); - Q_ASSERT(lineEdit); - def = QVariant(lineEdit->text()); - } + { + QLineEdit *lineEdit = qobject_cast(widget); + Q_ASSERT(lineEdit); + def = QVariant(lineEdit->text()); + } } properties[key] = def; } @@ -271,25 +281,25 @@ void StorageSelectionPage::on_backendList_currentIndexChanged() { QWidget *widget = 0; QVariant def; if(defaults.contains(key)) { - def = defaults[key]; + def = defaults[key]; } switch(def.type()) { case QVariant::Int: - { - QSpinBox *spinbox = new QSpinBox(propertyBox); - spinbox->setMaximum(64000); - spinbox->setValue(def.toInt()); - widget = spinbox; - } - break; + { + QSpinBox *spinbox = new QSpinBox(propertyBox); + spinbox->setMaximum(64000); + spinbox->setValue(def.toInt()); + widget = spinbox; + } + break; default: - { - QLineEdit *lineEdit = new QLineEdit(def.toString(), propertyBox); - if(key.toLower().contains("password")) { - lineEdit->setEchoMode(QLineEdit::Password); - } - widget = lineEdit; - } + { + QLineEdit *lineEdit = new QLineEdit(def.toString(), propertyBox); + if(key.toLower().contains("password")) { + lineEdit->setEchoMode(QLineEdit::Password); + } + widget = lineEdit; + } } widget->setObjectName(key); formlayout->addRow(key + ":", widget); diff --git a/src/qtui/coreconfigwizard.h b/src/qtui/coreconfigwizard.h index 91b532fc..b6d9de8d 100644 --- a/src/qtui/coreconfigwizard.h +++ b/src/qtui/coreconfigwizard.h @@ -30,6 +30,8 @@ #include "ui_coreconfigwizardstorageselectionpage.h" #include "ui_coreconfigwizardsyncpage.h" +class CoreConnection; + namespace CoreConfigWizardPages { class SyncPage; class SyncRelayPage; @@ -49,12 +51,14 @@ class CoreConfigWizard : public QWizard { ConclusionPage }; - CoreConfigWizard(const QList &backends, QWidget *parent = 0); + CoreConfigWizard(CoreConnection *connection, const QList &backends, QWidget *parent = 0); QHash backends() const; + inline CoreConnection *coreConnection() const { return _connection; } + signals: void setupCore(const QVariant &setupData); - void loginToCore(const QVariantMap &loginData); + void loginToCore(const QString &user, const QString &password, bool rememberPassword); public slots: void loginSuccess(); @@ -70,6 +74,8 @@ class CoreConfigWizard : public QWizard { QHash _backends; CoreConfigWizardPages::SyncPage *syncPage; CoreConfigWizardPages::SyncRelayPage *syncRelayPage; + + CoreConnection *_connection; }; namespace CoreConfigWizardPages { diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 63127493..24d9ac6e 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -55,6 +55,7 @@ #include "clientbufferviewconfig.h" #include "clientbufferviewmanager.h" #include "clientignorelistmanager.h" +#include "coreconfigwizard.h" #include "coreconnectdlg.h" #include "coreconnection.h" #include "coreconnectionstatuswidget.h" @@ -160,6 +161,8 @@ void MainWin::init() { SLOT(messagesInserted(const QModelIndex &, int, int))); connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId))); connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString))); + + connect(Client::coreConnection(), SIGNAL(startCoreSetup(QVariantList)), SLOT(showCoreConfigWizard(QVariantList))); connect(Client::coreConnection(), SIGNAL(connectionErrorPopup(QString)), SLOT(handleCoreConnectionError(QString))); connect(Client::coreConnection(), SIGNAL(userAuthenticationRequired(CoreAccount *, bool *, QString)), SLOT(userAuthenticationRequired(CoreAccount *, bool *, QString))); connect(Client::coreConnection(), SIGNAL(handleNoSslInClient(bool*)), SLOT(handleNoSslInClient(bool *))); @@ -882,6 +885,12 @@ void MainWin::showCoreConnectionDlg() { } } +void MainWin::showCoreConfigWizard(const QVariantList &backends) { + CoreConfigWizard *wizard = new CoreConfigWizard(Client::coreConnection(), backends, this); + + wizard->show(); +} + void MainWin::showChannelList(NetworkId netId) { ChannelListDlg *channelListDlg = new ChannelListDlg(); diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 8caa8b3c..bc4ba1ee 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -119,6 +119,7 @@ class MainWin void showAboutDlg(); void showChannelList(NetworkId netId = NetworkId()); void showCoreConnectionDlg(); + void showCoreConfigWizard(const QVariantList &); void showCoreInfoDlg(); void showAwayLog(); void showSettingsDlg(); diff --git a/src/qtui/ui/coreconfigwizardadminuserpage.ui b/src/qtui/ui/coreconfigwizardadminuserpage.ui index 261d5f8b..e55859fa 100644 --- a/src/qtui/ui/coreconfigwizardadminuserpage.ui +++ b/src/qtui/ui/coreconfigwizardadminuserpage.ui @@ -1,7 +1,8 @@ - + + CoreConfigWizardAdminUserPage - - + + 0 0 @@ -9,53 +10,53 @@ 273 - + Form - + - - - - + + + + Username: - - + + - - - + + + Password: - - - + + + QLineEdit::Password - - - + + + Repeat password: - - - + + + QLineEdit::Password - - - + + + Remember password @@ -63,29 +64,25 @@ - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Sans'; font-size:8pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:13pt;"><span style=" font-size:10pt; font-weight:600;">Note: </span><span style=" font-size:10pt;">Adding more users and changing your username/password is not possible via Quassel's interface yet.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:10pt;">If you need to do these things have a look at the manageusers.py script which is located in the /scripts directory.</p></body></html> + + + <b>Note:</b> Adding more users and changing your username/password is not possible via Quassel's client interface yet. +If you need to do these things, please run "<tt><nobr>quasselcore --help</nobr></tt>". - + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - + true - + Qt::Vertical - + 405 51