From: Marcus Eggenberger Date: Fri, 12 Dec 2008 15:38:44 +0000 (+0100) Subject: Adding proxy support to the core X-Git-Tag: 0.4.0~342 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=4493458caaa821deb69a0cddf13beb98394977bb Adding proxy support to the core SSL Version can now be specified IRC servers are internaly no longer represented by a variantmap. breaking protocol --- diff --git a/src/common/network.cpp b/src/common/network.cpp index df2a8376..44004b3f 100644 --- a/src/common/network.cpp +++ b/src/common/network.cpp @@ -22,26 +22,10 @@ #include #include -#include "util.h" - QTextCodec *Network::_defaultCodecForServer = 0; QTextCodec *Network::_defaultCodecForEncoding = 0; QTextCodec *Network::_defaultCodecForDecoding = 0; -Network::Server Network::Server::fromVariant(const QVariant &variant) { - QVariantMap serverMap = variant.toMap(); - return Server(serverMap["Host"].toString(), serverMap["Port"].toUInt(), serverMap["Password"].toString(), serverMap["UseSSL"].toBool()); -} - -QVariant Network::Server::toVariant() const { - QVariantMap serverMap; - serverMap["Host"] = host; - serverMap["Port"] = port; - serverMap["Password"] = password; - serverMap["UseSSL"] = useSsl; - return QVariant::fromValue(serverMap); -} - // ==================== // Public: // ==================== @@ -94,7 +78,7 @@ NetworkInfo Network::networkInfo() const { info.codecForServer = codecForServer(); info.codecForEncoding = codecForEncoding(); info.codecForDecoding = codecForDecoding(); - info.serverList = variantServerList(); + info.serverList = serverList(); info.useRandomServer = useRandomServer(); info.perform = perform(); info.useAutoIdentify = useAutoIdentify(); @@ -115,7 +99,7 @@ void Network::setNetworkInfo(const NetworkInfo &info) { if(info.codecForServer != codecForServer()) setCodecForServer(QTextCodec::codecForName(info.codecForServer)); if(info.codecForEncoding != codecForEncoding()) setCodecForEncoding(QTextCodec::codecForName(info.codecForEncoding)); if(info.codecForDecoding != codecForDecoding()) setCodecForDecoding(QTextCodec::codecForName(info.codecForDecoding)); - if(info.serverList.count()) setServerList(info.serverList); // FIXME compare components + if(info.serverList.count()) setServerList(toVariantList(info.serverList)); // FIXME compare components if(info.useRandomServer != useRandomServer()) setUseRandomServer(info.useRandomServer); if(info.perform != perform()) setPerform(info.perform); if(info.useAutoIdentify != useAutoIdentify()) setUseAutoIdentify(info.useAutoIdentify); @@ -152,16 +136,6 @@ QStringList Network::nicks() const { return nicks; } -QVariantList Network::variantServerList() const { - QVariantList servers; - ServerList::const_iterator serverIter = _serverList.constBegin(); - while(serverIter != _serverList.constEnd()) { - servers << serverIter->toVariant(); - serverIter++; - } - return servers; -} - QString Network::prefixes() { if(_prefixes.isNull()) determinePrefixes(); @@ -477,10 +451,7 @@ void Network::setIdentity(IdentityId id) { } void Network::setServerList(const QVariantList &serverList) { - _serverList.clear(); - foreach(QVariant variant, serverList) { - _serverList << Server::fromVariant(variant); - } + _serverList = fromVariantList(serverList); emit serverListSet(serverList); } @@ -614,12 +585,6 @@ void Network::initSetSupports(const QVariantMap &supports) { } } -void Network::initSetServerList(const QVariantList &serverList) { - foreach(QVariant variant, serverList) { - _serverList << Server::fromVariant(variant); - } -} - IrcUser *Network::updateNickFromMask(const QString &mask) { QString nick(nickFromMask(mask).toLower()); IrcUser *ircuser; @@ -729,7 +694,7 @@ QDataStream &operator<<(QDataStream &out, const NetworkInfo &info) { i["CodecForServer"] = info.codecForServer; i["CodecForEncoding"] = info.codecForEncoding; i["CodecForDecoding"] = info.codecForDecoding; - i["ServerList"] = info.serverList; + i["ServerList"] = toVariantList(info.serverList); i["UseRandomServer"] = info.useRandomServer; i["Perform"] = info.perform; i["UseAutoIdentify"] = info.useAutoIdentify; @@ -753,7 +718,7 @@ QDataStream &operator>>(QDataStream &in, NetworkInfo &info) { info.codecForServer = i["CodecForServer"].toByteArray(); info.codecForEncoding = i["CodecForEncoding"].toByteArray(); info.codecForDecoding = i["CodecForDecoding"].toByteArray(); - info.serverList = i["ServerList"].toList(); + info.serverList = fromVariantList(i["ServerList"].toList()); info.useRandomServer = i["UseRandomServer"].toBool(); info.perform = i["Perform"].toStringList(); info.useAutoIdentify = i["UseAutoIdentify"].toBool(); @@ -769,11 +734,70 @@ QDataStream &operator>>(QDataStream &in, NetworkInfo &info) { QDebug operator<<(QDebug dbg, const NetworkInfo &i) { dbg.nospace() << "(id = " << i.networkId << " name = " << i.networkName << " identity = " << i.identity - << " codecForServer = " << i.codecForServer << " codecForEncoding = " << i.codecForEncoding << " codecForDecoding = " << i.codecForDecoding - << " serverList = " << i.serverList << " useRandomServer = " << i.useRandomServer << " perform = " << i.perform - << " useAutoIdentify = " << i.useAutoIdentify << " autoIdentifyService = " << i.autoIdentifyService << " autoIdentifyPassword = " << i.autoIdentifyPassword - << " useAutoReconnect = " << i.useAutoReconnect << " autoReconnectInterval = " << i.autoReconnectInterval - << " autoReconnectRetries = " << i.autoReconnectRetries << " unlimitedReconnectRetries = " << i.unlimitedReconnectRetries - << " rejoinChannels = " << i.rejoinChannels << ")"; + << " codecForServer = " << i.codecForServer << " codecForEncoding = " << i.codecForEncoding << " codecForDecoding = " << i.codecForDecoding + << " serverList = " << i.serverList << " useRandomServer = " << i.useRandomServer << " perform = " << i.perform + << " useAutoIdentify = " << i.useAutoIdentify << " autoIdentifyService = " << i.autoIdentifyService << " autoIdentifyPassword = " << i.autoIdentifyPassword + << " useAutoReconnect = " << i.useAutoReconnect << " autoReconnectInterval = " << i.autoReconnectInterval + << " autoReconnectRetries = " << i.autoReconnectRetries << " unlimitedReconnectRetries = " << i.unlimitedReconnectRetries + << " rejoinChannels = " << i.rejoinChannels << ")"; + return dbg.space(); +} + +QDataStream &operator<<(QDataStream &out, const Network::Server &server) { + QVariantMap serverMap; + serverMap["Host"] = server.host; + serverMap["Port"] = server.port; + serverMap["Password"] = server.password; + serverMap["UseSSL"] = server.useSsl; + serverMap["sslVersion"] = server.sslVersion; + serverMap["UseProxy"] = server.useProxy; + serverMap["ProxyType"] = server.proxyType; + serverMap["ProxyHost"] = server.proxyHost; + serverMap["ProxyPort"] = server.proxyPort; + serverMap["ProxyUser"] = server.proxyUser; + serverMap["ProxyPass"] = server.proxyPass; + out << serverMap; + return out; +} + +QDataStream &operator>>(QDataStream &in, Network::Server &server) { + QVariantMap serverMap; + in >> serverMap; + server.host = serverMap["Host"].toString(); + server.port = serverMap["Port"].toUInt(); + server.password = serverMap["Password"].toString(); + server.useSsl = serverMap["UseSSL"].toBool(); + server.sslVersion = serverMap["sslVersion"].toInt(); + server.useProxy = serverMap["UseProxy"].toBool(); + server.proxyType = serverMap["ProxyType"].toInt(); + server.proxyHost = serverMap["ProxyHost"].toString(); + server.proxyPort = serverMap["ProxyPort"].toUInt(); + server.proxyUser = serverMap["ProxyUser"].toString(); + server.proxyPass = serverMap["ProxyPass"].toString(); + return in; +} + + +bool Network::Server::operator==(const Server &other) const { + if(host != other.host) return false; + if(port != other.port) return false; + if(password != other.password) return false; + if(useSsl != other.useSsl) return false; + if(sslVersion != other.sslVersion) return false; + if(useProxy != other.useProxy) return false; + if(proxyType != other.proxyType) return false; + if(proxyHost != other.proxyHost) return false; + if(proxyPort != other.proxyPort) return false; + if(proxyUser != other.proxyUser) return false; + if(proxyPass != other.proxyPass) return false; + return true; +} + +bool Network::Server::operator!=(const Server &other) const { + return !(*this == other); +} + +QDebug operator<<(QDebug dbg, const Network::Server &server) { + dbg.nospace() << "Server(host = " << server.host << ":" << server.port << ", useSsl = " << server.useSsl << ")"; return dbg.space(); } diff --git a/src/common/network.h b/src/common/network.h index 84e86998..c9249532 100644 --- a/src/common/network.h +++ b/src/common/network.h @@ -24,12 +24,14 @@ #include #include #include +#include #include #include #include #include #include "types.h" +#include "util.h" #include "syncableobject.h" #include "signalproxy.h" @@ -93,12 +95,21 @@ public: uint port; QString password; bool useSsl; - Server() : port(0), useSsl(false) {} - Server(const QString &host, uint port, const QString &password, bool useSsl) - : host(host), port(port), password(password), useSsl(useSsl) {} + int sslVersion; + + bool useProxy; + int proxyType; + QString proxyHost; + uint proxyPort; + QString proxyUser; + QString proxyPass; - static Server fromVariant(const QVariant &variant); - QVariant toVariant() const; + Server() : port(6667), useSsl(false), sslVersion(0), useProxy(false), proxyType(QNetworkProxy::Socks5Proxy), proxyHost("localhost"), proxyPort(8080) {} + Server(const QString &host, uint port, const QString &password, bool useSsl) + : host(host), port(port), password(password), useSsl(useSsl), sslVersion(0), + useProxy(false), proxyType(QNetworkProxy::Socks5Proxy), proxyHost("localhost"), proxyPort(8080) {} + bool operator==(const Server &other) const; + bool operator!=(const Server &other) const; }; typedef QList ServerList; @@ -136,7 +147,6 @@ public: QStringList nicks() const; inline QStringList channels() const { return _ircChannels.keys(); } inline const ServerList &serverList() const { return _serverList; } - QVariantList variantServerList() const; inline bool useRandomServer() const { return _useRandomServer; } inline const QStringList &perform() const { return _perform; } inline bool useAutoIdentify() const { return _useAutoIdentify; } @@ -226,12 +236,12 @@ public slots: //init geters QVariantMap initSupports() const; - inline QVariantList initServerList() const { return variantServerList(); } + inline QVariantList initServerList() const { return toVariantList(serverList()); } virtual QVariantMap initIrcUsersAndChannels() const; //init seters void initSetSupports(const QVariantMap &supports); - void initSetServerList(const QVariantList &serverList); + inline void initSetServerList(const QVariantList &serverList) { _serverList = fromVariantList(serverList); } virtual void initSetIrcUsersAndChannels(const QVariantMap &usersAndChannels); IrcUser *updateNickFromMask(const QString &mask); @@ -356,7 +366,7 @@ struct NetworkInfo { QByteArray codecForDecoding; // Server entry: QString "Host", uint "Port", QString "Password", bool "UseSSL" - QVariantList serverList; + Network::ServerList serverList; bool useRandomServer; QStringList perform; @@ -378,7 +388,11 @@ struct NetworkInfo { QDataStream &operator<<(QDataStream &out, const NetworkInfo &info); QDataStream &operator>>(QDataStream &in, NetworkInfo &info); QDebug operator<<(QDebug dbg, const NetworkInfo &i); - Q_DECLARE_METATYPE(NetworkInfo) +QDataStream &operator<<(QDataStream &out, const Network::Server &server); +QDataStream &operator>>(QDataStream &in, Network::Server &server); +QDebug operator<<(QDebug dbg, const Network::Server &server); +Q_DECLARE_METATYPE(Network::Server) + #endif diff --git a/src/common/quassel.cpp b/src/common/quassel.cpp index 2273eeef..84301f96 100644 --- a/src/common/quassel.cpp +++ b/src/common/quassel.cpp @@ -104,6 +104,7 @@ void Quassel::registerMetaTypes() { qRegisterMetaType("Message"); qRegisterMetaType("BufferInfo"); qRegisterMetaType("NetworkInfo"); + qRegisterMetaType("Network::Server"); qRegisterMetaType("Identity"); qRegisterMetaType("Network::ConnectionState"); @@ -111,6 +112,7 @@ void Quassel::registerMetaTypes() { qRegisterMetaTypeStreamOperators("Message"); qRegisterMetaTypeStreamOperators("BufferInfo"); qRegisterMetaTypeStreamOperators("NetworkInfo"); + qRegisterMetaTypeStreamOperators("Network::Server"); qRegisterMetaTypeStreamOperators("Identity"); qRegisterMetaTypeStreamOperators("Network::ConnectionState"); diff --git a/src/common/util.h b/src/common/util.h index c7e89daa..6725a8d5 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -56,4 +56,22 @@ QDir quasselDir(); void loadTranslation(const QLocale &locale); +template +QVariantList toVariantList(const QList &list) { + QVariantList variants; + for(int i = 0; i < list.count(); i++) { + variants << QVariant::fromValue(list[i]); + } + return variants; +} + +template +QList fromVariantList(const QVariantList &variants) { + QList list; + for(int i = 0; i < variants.count(); i++) { + list << variants[i].value(); + } + return list; +} + #endif diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index a5c40e62..b3cbfc09 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -69,16 +69,14 @@ CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session) connect(this, SIGNAL(connectRequested()), this, SLOT(connectToIrc())); + connect(&socket, SIGNAL(connected()), this, SLOT(socketInitialized())); connect(&socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); connect(&socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(&socket, SIGNAL(readyRead()), this, SLOT(socketHasData())); #ifdef HAVE_SSL - connect(&socket, SIGNAL(connected()), this, SLOT(sslSocketConnected())); connect(&socket, SIGNAL(encrypted()), this, SLOT(socketInitialized())); connect(&socket, SIGNAL(sslErrors(const QList &)), this, SLOT(sslErrors(const QList &))); -#else - connect(&socket, SIGNAL(connected()), this, SLOT(socketInitialized())); #endif } @@ -155,7 +153,23 @@ void CoreNetwork::connectToIrc(bool reconnecting) { Server server = usedServer(); displayStatusMsg(tr("Connecting to %1:%2...").arg(server.host).arg(server.port)); displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Connecting to %1:%2...").arg(server.host).arg(server.port)); + + if(server.useProxy) { + QNetworkProxy proxy((QNetworkProxy::ProxyType)server.proxyType, server.proxyHost, server.proxyPort, server.proxyUser, server.proxyPass); + socket.setProxy(proxy); + } else { + socket.setProxy(QNetworkProxy::NoProxy); + } + +#ifdef HAVE_SSL + socket.setProtocol((QSsl::SslProtocol)server.sslVersion); + if(server.useSsl) + socket.connectToHostEncrypted(server.host, server.port); + else + socket.connectToHost(server.host, server.port); +#else socket.connectToHost(server.host, server.port); +#endif } void CoreNetwork::disconnectFromIrc(bool requested, const QString &reason) { @@ -264,16 +278,13 @@ void CoreNetwork::socketError(QAbstractSocket::SocketError) { } } +void CoreNetwork::socketInitialized() { + Server server = usedServer(); #ifdef HAVE_SSL -void CoreNetwork::sslSocketConnected() { - if(!usedServer().useSsl) - socketInitialized(); - else - socket.startClientEncryption(); -} + if(server.useSsl && !socket.isEncrypted()) + return; #endif -void CoreNetwork::socketInitialized() { Identity *identity = identityPtr(); if(!identity) { qCritical() << "Identity invalid!"; @@ -287,9 +298,8 @@ void CoreNetwork::socketInitialized() { _tokenBucket = 5; // init with a full bucket _tokenBucketTimer.start(_messagesPerSecond * 1000); - QString passwd = usedServer().password; - if(!passwd.isEmpty()) { - putRawLine(serverEncode(QString("PASS %1").arg(passwd))); + if(!server.password.isEmpty()) { + putRawLine(serverEncode(QString("PASS %1").arg(server.password))); } putRawLine(serverEncode(QString("NICK :%1").arg(identity->nicks()[0]))); putRawLine(serverEncode(QString("USER %1 8 * :%2").arg(identity->ident(), identity->realName()))); @@ -464,18 +474,7 @@ void CoreNetwork::startAutoWhoCycle() { void CoreNetwork::sslErrors(const QList &sslErrors) { Q_UNUSED(sslErrors) socket.ignoreSslErrors(); - /* TODO errorhandling - QVariantMap errmsg; - QVariantList errnums; - foreach(QSslError err, errors) errnums << err.error(); - errmsg["SslErrors"] = errnums; - errmsg["SslCert"] = socket.peerCertificate().toPem(); - errmsg["PeerAddress"] = socket.peerAddress().toString(); - errmsg["PeerPort"] = socket.peerPort(); - errmsg["PeerName"] = socket.peerName(); - emit sslErrors(errmsg); - disconnectFromIrc(); - */ + // TODO errorhandling } #endif // HAVE_SSL @@ -495,6 +494,13 @@ void CoreNetwork::writeToSocket(const QByteArray &data) { _tokenBucket--; } +Network::Server CoreNetwork::usedServer() const { + if(_lastUsedServerIndex < serverList().count()) + return serverList()[_lastUsedServerIndex]; + else + return Network::Server(); +} + void CoreNetwork::requestConnect() const { if(connectionState() != Disconnected) { qWarning() << "Requesting connect while already being connected!"; @@ -512,6 +518,16 @@ void CoreNetwork::requestDisconnect() const { } void CoreNetwork::requestSetNetworkInfo(const NetworkInfo &info) { + Network::Server currentServer = usedServer(); setNetworkInfo(info); Core::updateNetwork(coreSession()->user(), info); + + // update _lastUsedServerIndex; + for(int i = 0; i < serverList().count(); i++) { + Network::Server server = serverList()[i]; + if(server.host == currentServer.host && server.port == currentServer.port) { + _lastUsedServerIndex = i; + break; + } + } } diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h index f227de4f..8cbe9b81 100644 --- a/src/core/corenetwork.h +++ b/src/core/corenetwork.h @@ -105,7 +105,7 @@ public slots: bool setAutoWhoDone(const QString &channel); - inline const Server &usedServer() const { return serverList()[_lastUsedServerIndex]; } + Server usedServer() const; signals: void recvRawServerMsg(QString); @@ -136,7 +136,6 @@ private slots: void startAutoWhoCycle(); #ifdef HAVE_SSL - void sslSocketConnected(); void sslErrors(const QList &errors); #endif diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 79ccd27f..cc484206 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -246,12 +246,11 @@ bool SqliteStorage::updateNetwork(UserId user, const NetworkInfo &info) { QSqlQuery insertServersQuery(logDb()); insertServersQuery.prepare(queryString("insert_server")); - foreach(QVariant server_, info.serverList) { - QVariantMap server = server_.toMap(); - insertServersQuery.bindValue(":hostname", server["Host"]); - insertServersQuery.bindValue(":port", server["Port"].toInt()); - insertServersQuery.bindValue(":password", server["Password"]); - insertServersQuery.bindValue(":ssl", server["UseSSL"].toBool() ? 1 : 0); + foreach(Network::Server server, info.serverList) { + insertServersQuery.bindValue(":hostname", server.host); + insertServersQuery.bindValue(":port", server.port); + insertServersQuery.bindValue(":password", server.password); + insertServersQuery.bindValue(":ssl", server.useSsl ? 1 : 0); insertServersQuery.bindValue(":userid", user.toInt()); insertServersQuery.bindValue(":networkid", info.networkId.toInt()); @@ -358,13 +357,13 @@ QList SqliteStorage::networks(UserId user) { if(!watchQuery(serversQuery)) return nets; - QVariantList servers; + Network::ServerList servers; while(serversQuery.next()) { - QVariantMap server; - server["Host"] = serversQuery.value(0).toString(); - server["Port"] = serversQuery.value(1).toInt(); - server["Password"] = serversQuery.value(2).toString(); - server["UseSSL"] = serversQuery.value(3).toInt() == 1 ? true : false; + Network::Server server; + server.host = serversQuery.value(0).toString(); + server.port = serversQuery.value(1).toUInt(); + server.password = serversQuery.value(2).toString(); + server.useSsl = serversQuery.value(3).toInt() == 1 ? true : false; servers << server; } net.serverList = servers; diff --git a/src/qtui/settingspages/networkssettingspage.cpp b/src/qtui/settingspages/networkssettingspage.cpp index 2362c035..ffef9919 100644 --- a/src/qtui/settingspages/networkssettingspage.cpp +++ b/src/qtui/settingspages/networkssettingspage.cpp @@ -428,8 +428,8 @@ void NetworksSettingsPage::displayNetwork(NetworkId id) { NetworkInfo info = networkInfos[id]; ui.identityList->setCurrentIndex(ui.identityList->findData(info.identity.toInt())); ui.serverList->clear(); - foreach(QVariant v, info.serverList) { - ui.serverList->addItem(QString("%1:%2").arg(v.toMap()["Host"].toString()).arg(v.toMap()["Port"].toUInt())); + foreach(Network::Server server, info.serverList) { + ui.serverList->addItem(QString("%1:%2").arg(server.host).arg(server.port)); } //setItemState(id); ui.randomServer->setChecked(info.useRandomServer); @@ -586,14 +586,13 @@ void NetworksSettingsPage::on_serverList_itemSelectionChanged() { void NetworksSettingsPage::on_addServer_clicked() { if(currentId == 0) return; - ServerEditDlg dlg(QVariantMap(), this); + ServerEditDlg dlg(Network::Server(), this); if(dlg.exec() == QDialog::Accepted) { networkInfos[currentId].serverList.append(dlg.serverData()); displayNetwork(currentId); ui.serverList->setCurrentRow(ui.serverList->count()-1); widgetHasChanged(); } - } void NetworksSettingsPage::on_editServer_clicked() { @@ -619,8 +618,8 @@ void NetworksSettingsPage::on_deleteServer_clicked() { void NetworksSettingsPage::on_upServer_clicked() { int cur = ui.serverList->currentRow(); - QVariant foo = networkInfos[currentId].serverList.takeAt(cur); - networkInfos[currentId].serverList.insert(cur-1, foo); + Network::Server server = networkInfos[currentId].serverList.takeAt(cur); + networkInfos[currentId].serverList.insert(cur-1, server); displayNetwork(currentId); ui.serverList->setCurrentRow(cur-1); widgetHasChanged(); @@ -628,8 +627,8 @@ void NetworksSettingsPage::on_upServer_clicked() { void NetworksSettingsPage::on_downServer_clicked() { int cur = ui.serverList->currentRow(); - QVariant foo = networkInfos[currentId].serverList.takeAt(cur); - networkInfos[currentId].serverList.insert(cur+1, foo); + Network::Server server = networkInfos[currentId].serverList.takeAt(cur); + networkInfos[currentId].serverList.insert(cur+1, server); displayNetwork(currentId); ui.serverList->setCurrentRow(cur+1); widgetHasChanged(); @@ -662,30 +661,33 @@ void NetworkEditDlg::on_networkEdit_textChanged(const QString &text) { /************************************************************************** * ServerEditDlg *************************************************************************/ - -ServerEditDlg::ServerEditDlg(const QVariant &_serverData, QWidget *parent) : QDialog(parent) { +ServerEditDlg::ServerEditDlg(const Network::Server &server, QWidget *parent) : QDialog(parent) { ui.setupUi(this); ui.useSSL->setIcon(SmallIcon("document-encrypt")); - - QVariantMap serverData = _serverData.toMap(); - if(serverData.count()) { - ui.host->setText(serverData["Host"].toString()); - ui.port->setValue(serverData["Port"].toUInt()); - ui.password->setText(serverData["Password"].toString()); - ui.useSSL->setChecked(serverData["UseSSL"].toBool()); - } else { - ui.port->setValue(6667); - } + ui.host->setText(server.host); + ui.port->setValue(server.port); + ui.password->setText(server.password); + ui.useSSL->setChecked(server.useSsl); + ui.sslVersion->setCurrentIndex(server.sslVersion); + ui.useProxy->setChecked(server.useProxy); + ui.proxyType->setCurrentIndex(server.proxyType == QNetworkProxy::Socks5Proxy ? 0 : 1); + ui.proxyHost->setText(server.proxyHost); + ui.proxyPort->setValue(server.proxyPort); + ui.proxyUsername->setText(server.proxyUser); + ui.proxyPassword->setText(server.proxyPass); on_host_textChanged(); } -QVariant ServerEditDlg::serverData() const { - QVariantMap _serverData; - _serverData["Host"] = ui.host->text().trimmed(); - _serverData["Port"] = ui.port->value(); - _serverData["Password"] = ui.password->text(); - _serverData["UseSSL"] = ui.useSSL->isChecked(); - return _serverData; +Network::Server ServerEditDlg::serverData() const { + Network::Server server(ui.host->text().trimmed(), ui.port->value(), ui.password->text(), ui.useSSL->isChecked()); + server.sslVersion = ui.sslVersion->currentIndex(); + server.useProxy = ui.useProxy->isChecked(); + server.proxyType = ui.proxyType->currentIndex() == 0 ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy; + server.proxyHost = ui.proxyHost->text(); + server.proxyPort = ui.proxyPort->value(); + server.proxyUser = ui.proxyUsername->text(); + server.proxyPass = ui.proxyPassword->text(); + return server; } void ServerEditDlg::on_host_textChanged() { diff --git a/src/qtui/settingspages/networkssettingspage.h b/src/qtui/settingspages/networkssettingspage.h index 1b3b0fda..232c7f8a 100644 --- a/src/qtui/settingspages/networkssettingspage.h +++ b/src/qtui/settingspages/networkssettingspage.h @@ -18,8 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _NETWORKSSETTINGSPAGE_H_ -#define _NETWORKSSETTINGSPAGE_H_ +#ifndef NETWORKSSETTINGSPAGE_H +#define NETWORKSSETTINGSPAGE_H #include @@ -114,16 +114,16 @@ class NetworkEditDlg : public QDialog { class ServerEditDlg : public QDialog { Q_OBJECT - public: - ServerEditDlg(const QVariant &serverData = QVariant(), QWidget *parent = 0); +public: + ServerEditDlg(const Network::Server &server = Network::Server(), QWidget *parent = 0); - QVariant serverData() const; + Network::Server serverData() const; - private slots: - void on_host_textChanged(); +private slots: + void on_host_textChanged(); - private: - Ui::ServerEditDlg ui; +private: + Ui::ServerEditDlg ui; }; diff --git a/src/qtui/settingspages/servereditdlg.ui b/src/qtui/settingspages/servereditdlg.ui index d538539f..ec5f0ff7 100644 --- a/src/qtui/settingspages/servereditdlg.ui +++ b/src/qtui/settingspages/servereditdlg.ui @@ -5,92 +5,303 @@ 0 0 - 264 - 167 + 386 + 346 Dialog - + - - - - - Server address: - - - - - - - Port: - - - - - - - - - - 1 - - - 65535 - - - 6667 - - - - - - - - - - - Password: - - - - - - - true - - - QLineEdit::Password - - - - - - - - - true + + + - - Use SSL + + 0 - - - :/16x16/actions/oxygen/16x16/actions/document-encrypt.png:/16x16/actions/oxygen/16x16/actions/document-encrypt.png + + false + + + + 0 + 0 + 356 + 243 + + + + Server Info + + + + + + + + Server address: + + + + + + + Port: + + + + + + + + + + 1 + + + 65535 + + + 6667 + + + + + + + + + + + Password: + + + + + + + true + + + QLineEdit::Password + + + + + + + + + true + + + Use SSL + + + + :/16x16/actions/oxygen/16x16/actions/document-encrypt.png:/16x16/actions/oxygen/16x16/actions/document-encrypt.png + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 0 + 0 + 356 + 243 + + + + Advanced + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + SSL Version: + + + + + + + Do not change unless you're going to connect to a server not supporting SSLv3! + + + + SSLv3 (default) + + + + + SSLv2 + + + + + TLSv1 + + + + + + + + + + Use a Proxy + + + false + + + true + + + false + + + + + + + + Proxy Type: + + + + + + + + Socks 5 + + + + + HTTP + + + + + + + + + + + + Proxy Host: + + + + + + + localhost + + + + + + + Port: + + + + + + + 1 + + + 65535 + + + 8080 + + + + + + + + + + + Proxy Username: + + + + + + + + + + Proxy Password: + + + + + + + QLineEdit::Password + + + + + + + + + + - + Qt::Vertical 20 - 40 + 17 diff --git a/version.inc b/version.inc index fb1f18d7..f445fd7b 100644 --- a/version.inc +++ b/version.inc @@ -1,9 +1,9 @@ //! This is the fallback version number in case we can't autogenerate one baseVersion = "0.3.1"; -protocolVersion = 7; //< Version of the client/core protocol -coreNeedsProtocol = 7; //< Minimum protocol version the core needs -clientNeedsProtocol = 7; //< Minimum protocol version the client needs +protocolVersion = 8; //< Version of the client/core protocol +coreNeedsProtocol = 8; //< Minimum protocol version the core needs +clientNeedsProtocol = 8; //< Minimum protocol version the client needs distCommittish = $Format:%H$ distCommitDate = $Format:%at$