+ } 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.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.channelsProgress->setRange(0, 1);
+ ui.channelsProgress->setValue(0);
+ ui.ircUsersProgress->setRange(0, 1);
+ ui.ircUsersProgress->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);
+ 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::coreChannelsProgress(quint32 val, quint32 max) {
+ if(max == 0) {
+ ui.channelsProgress->setFormat("0/0");
+ ui.channelsProgress->setRange(0, 1);
+ ui.channelsProgress->setValue(1);