/***************************************************************************
- * 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 *
#include "coreconnectdlg.h"
+#include "client.h"
#include "clientsettings.h"
#include "clientsyncer.h"
#include "coreconfigwizard.h"
#include "iconloader.h"
-#include "monoapplication.h"
+#include "quassel.h"
CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent)
- : QDialog(parent)
+ : QDialog(parent),
+ _internalAccountId(0)
{
ui.setupUi(this);
ui.editAccount->setIcon(SmallIcon("document-properties"));
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);
+// connect(this, SIGNAL(newClientSyncer(ClientSyncer *)), Client::instance(), SIGNAL(newClientSyncer(ClientSyncer *)));
+// emit newClientSyncer(clientSyncer); // announce the new client syncer via the client.
wizard = 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<AccountId>(id);
accounts[id] = data;
QListWidgetItem *item = new QListWidgetItem(data["AccountName"].toString(), ui.accountList);
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) {
- // find free ID
- AccountId id = accounts.count() + 1;
- for(AccountId i = 1; i <= accounts.count(); i++) {
- if(!accounts.keys().contains(i)) {
- id = i;
- break;
- }
- }
+ AccountId id = findFreeAccountId();
QVariantMap data = dlg.accountData();
data["AccountId"] = QVariant::fromValue<AccountId>(id);
accounts[id] = data;
}
void CoreConnectDlg::on_useInternalCore_clicked() {
- // FIXME: this needs to be a qobject_cast - therefore MonolithicApplication needs to be a proper QObject... :/
- MonolithicApplication *monoApp = static_cast<MonolithicApplication *>(QApplication::instance());
- if(monoApp) {
- qDebug() << "starting core...";
- monoApp->startInternalCore();
- monoApp->connectClientSyncer(clientSyncer);
- }
clientSyncer->useInternalCore();
- startSync();
+ ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Cancel);
}
/*****************************************************
ui.user->setEnabled(true);
ui.password->setEnabled(true);
ui.rememberPasswd->setEnabled(true);
- ui.loginButtonBox->button(QDialogButtonBox::Ok)->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) {
}
}
+AccountId CoreConnectDlg::findFreeAccountId() {
+ for(AccountId i = 1;; i++) {
+ if(!accounts.contains(i) && i != _internalAccountId)
+ return i;
+ }
+}
+
/*****************************************************************************************
* CoreAccountEditDlg
*****************************************************************************************/
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.useInternal->setChecked(acct["UseInternal"].toBool());
ui.accountName->setText(acct["AccountName"].toString());
#ifdef HAVE_SSL
ui.useSsl->setChecked(acct["useSsl"].toBool());
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
}
QVariantMap CoreAccountEditDlg::accountData() {
account["AccountName"] = ui.accountName->text().trimmed();
account["Host"] = ui.host->text().trimmed();
account["Port"] = ui.port->value();
- account["UseInternal"] = ui.useInternal->isChecked();
account["useSsl"] = ui.useSsl->isChecked();
account["useProxy"] = ui.useProxy->isChecked();
account["proxyHost"] = ui.proxyHost->text().trimmed();
}
void CoreAccountEditDlg::setWidgetStates() {
- bool ok = !ui.accountName->text().trimmed().isEmpty() && !existing.contains(ui.accountName->text()) && (ui.useInternal->isChecked() || !ui.host->text().isEmpty());
+ bool ok = !ui.accountName->text().trimmed().isEmpty() && !existing.contains(ui.accountName->text()) && !ui.host->text().isEmpty();
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
}
Q_UNUSED(text);
setWidgetStates();
}
-
-void CoreAccountEditDlg::on_useRemote_toggled(bool state) {
- Q_UNUSED(state);
- setWidgetStates();
-}