/***************************************************************************
- * 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 "quassel.h"
CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent)
- : QDialog(parent)
+ : QDialog(parent),
+ _internalAccountId(0)
{
ui.setupUi(this);
ui.editAccount->setIcon(SmallIcon("document-properties"));
setWindowFlags(Qt::Sheet);
clientSyncer = new ClientSyncer(this);
- connect(this, SIGNAL(newClientSyncer(ClientSyncer *)), Client::instance(), SIGNAL(newClientSyncer(ClientSyncer *)));
- emit newClientSyncer(clientSyncer); // announce the new client syncer via the client.
+ 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);
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(connectionMsg(const QString &)), this, SLOT(initPhaseMsg(const QString &)));
- connect(clientSyncer, SIGNAL(encrypted(bool)), this, SLOT(encrypted(bool)));
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(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()));
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() {
clientSyncer->useInternalCore();
- startSync();
+ ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Cancel);
}
/*****************************************************
ui.coreInfoLabel->setText(msg);
}
-void CoreConnectDlg::encrypted(bool useSsl) {
- if(useSsl)
- ui.secureConnection->show();
- else
- ui.secureConnection->hide();
-}
-
void CoreConnectDlg::initPhaseSocketState(QAbstractSocket::SocketState state) {
QString s;
QString host = accountData["Host"].toString();
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
*****************************************************************************************/