+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);
+ 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()));
+ }
+}
+
+/*****************************************************************************************
+ * CoreAccountEditDlg
+ *****************************************************************************************/
+CoreAccountEditDlg::CoreAccountEditDlg(AccountId id, const QVariantMap &acct, const QStringList &_existing, QWidget *parent)
+ : QDialog(parent)
+{
+ ui.setupUi(this);
+ existing = _existing;
+ if(id.isValid()) {
+ existing.removeAll(acct["AccountName"].toString());
+ ui.host->setText(acct["Host"].toString());
+ ui.port->setValue(acct["Port"].toUInt());
+ ui.useInternal->setChecked(acct["UseInternal"].toBool());
+ ui.accountName->setText(acct["AccountName"].toString());
+#ifndef QT_NO_OPENSSL
+ 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"));
+#ifdef QT_NO_OPENSSL
+ ui.useSsl->setChecked(false);
+ ui.useSsl->setEnabled(false);
+#endif
+ }
+
+#ifndef BUILD_MONO
+ // if we don't have a mono build we hide the option to use the internal connection and force the setting to use remote host
+ ui.useInternal->setChecked(false);
+ ui.useInternal->hide();
+ ui.useRemote->hide();
+ ui.labelUseBuiltinCore->hide();
+#endif