#include <QDebug>
#include <QMessageBox>
+#include <QNetworkProxy>
#include "coreconnectdlg.h"
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()));
/*** Phase One: initializing the core connection ***/
void CoreConnectDlg::connectToCore() {
+ ui.secureConnection->hide();
ui.connectIcon->setPixmap(QPixmap::fromImage(QImage(":/22x22/actions/network-disconnect")));
ui.connectLabel->setText(tr("Connect to %1").arg(accountData["Host"].toString()));
ui.coreInfoLabel->setText("");
void CoreConnectDlg::initPhaseError(const QString &error) {
doingAutoConnect = false;
+ ui.secureConnection->hide();
ui.connectIcon->setPixmap(QPixmap::fromImage(QImage(":/22x22/status/dialog-error")));
//ui.connectLabel->setBrush(QBrush("red"));
ui.connectLabel->setText(tr("<div style=color:red;>Connection to %1 failed!</div>").arg(accountData["Host"].toString()));
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();
existing = _existing;
account = acct;
if(id.isValid()) {
+ // add new settings
+ if(!acct.contains("useProxy")) {
+ account["useProxy"] = false;
+ account["proxyHost"] = "localhost";
+ account["proxyPort"] = 8080;
+ account["proxyType"] = QNetworkProxy::Socks5Proxy;
+ account["proxyUser"] = "";
+ account["proxyPassword"] = "";
+ }
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());
+ ui.useSsl->setChecked(account["useSsl"].toBool());
+ ui.useProxy->setChecked(account["useProxy"].toBool());
+ ui.proxyHost->setText(account["proxyHost"].toString());
+ ui.proxyPort->setValue(account["proxyPort"].toUInt());
+ ui.proxyType->setCurrentIndex(account["proxyType"].toInt() == QNetworkProxy::Socks5Proxy ? 0 : 1);
+ ui.proxyHost->setText(account["proxyUser"].toString());
+ ui.proxyHost->setText(account["proxyPassword"].toString());
} else {
setWindowTitle(tr("Add Core Account"));
}
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();
+ account["proxyPort"] = ui.proxyPort->value();
+ account["proxyType"] = ui.proxyType->currentIndex() == 0 ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy;
+ account["proxyUser"] = ui.proxyUser->text().trimmed();
+ account["proxyPassword"] = ui.proxyPassword->text().trimmed();
return account;
}