From kde-commits Sun Apr 17 14:53:59 2016 From: Nick Shaforostoff Date: Sun, 17 Apr 2016 14:53:59 +0000 To: kde-commits Subject: [ktorrent] /: store interface name as string in cfg file, thanks Alan for the patch Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=146090484821206 Git commit 74d7b94f12e8357c4ed402917342ac1999572376 by Nick Shaforostoff. Committed on 17/04/2016 at 14:51. Pushed by shaforo into branch 'master'. store interface name as string in cfg file, thanks Alan for the patch CCMAIL: alan.ezust@gmail.com M +4 -7 ktmagnetdownloader/magnettest.cpp M +4 -7 ktorrent/core.cpp M +26 -4 ktorrent/pref/networkpref.cpp M +1 -0 ktorrent/pref/networkpref.h M +1 -1 ktorrent/pref/networkpref.ui M +2 -2 libktcore/dbus/dbussettings.cpp M +2 -2 libktcore/dbus/dbussettings.h M +1 -16 libktcore/interfaces/functions.cpp M +1 -4 libktcore/ktorrent.kcfg http://commits.kde.org/ktorrent/74d7b94f12e8357c4ed402917342ac1999572376 diff --git a/ktmagnetdownloader/magnettest.cpp b/ktmagnetdownloader/magnett= est.cpp index ad09750..481a3db 100644 --- a/ktmagnetdownloader/magnettest.cpp +++ b/ktmagnetdownloader/magnettest.cpp @@ -79,14 +79,11 @@ void MagnetTest::start() } = // Make sure network interface is set properly before server is initia= lized - if (Settings::networkInterface() !=3D 0) + if (!Settings::networkInterface().isEmpty()) { - QList iface_list =3D QNetworkInterface::allInte= rfaces(); - int iface =3D Settings::networkInterface(); - if (iface > iface_list.count()) - SetNetworkInterface(QString::null); - else - SetNetworkInterface(iface_list[iface - 1].name()); + //QList iface_list =3D QNetworkInterface::allIn= terfaces(); + QString iface =3D Settings::networkInterface(); + SetNetworkInterface(iface); } = = diff --git a/ktorrent/core.cpp b/ktorrent/core.cpp index d579ae4..0274f9d 100644 --- a/ktorrent/core.cpp +++ b/ktorrent/core.cpp @@ -101,14 +101,11 @@ namespace kt connect(&update_timer, &QTimer::timeout, this, &Core::update); = // Make sure network interface is set properly before server is in= itialized - if (Settings::networkInterface() !=3D 0) + if (!Settings::networkInterface().isEmpty()) { - QList iface_list =3D QNetworkInterface::all= Interfaces(); - int iface =3D Settings::networkInterface(); - if (iface > iface_list.count()) - SetNetworkInterface(QString::null); - else - SetNetworkInterface(iface_list[iface - 1].name()); + // QList iface_list =3D QNetworkInterface::a= llInterfaces(); + QString iface =3D Settings::networkInterface(); + SetNetworkInterface(iface); } = = diff --git a/ktorrent/pref/networkpref.cpp b/ktorrent/pref/networkpref.cpp index e159876..07b2078 100644 --- a/ktorrent/pref/networkpref.cpp +++ b/ktorrent/pref/networkpref.cpp @@ -44,6 +44,7 @@ namespace kt { } = + void NetworkPref::loadSettings() { kcfg_maxDownloadRate->setValue(Settings::maxDownloadRate()); @@ -51,8 +52,8 @@ namespace kt kcfg_maxConnections->setValue(Settings::maxConnections()); kcfg_maxTotalConnections->setValue(Settings::maxTotalConnections()= ); = - kcfg_networkInterface->clear(); - kcfg_networkInterface->addItem(QIcon::fromTheme("network-wired"), = i18n("All interfaces")); + combo_networkInterface->clear(); + combo_networkInterface->addItem(QIcon::fromTheme("network-wired"),= i18n("All interfaces")); = kcfg_onlyUseUtp->setEnabled(Settings::utpEnabled()); kcfg_primaryTransportProtocol->setEnabled(Settings::utpEnabled() &= & !Settings::onlyUseUtp()); @@ -79,10 +80,31 @@ namespace kt } #endif = - kcfg_networkInterface->addItem(icon, iface.name()); + combo_networkInterface->addItem(icon, iface.name()); } + QString iface =3D Settings::networkInterface(); + int idx =3D (iface.isEmpty())? 0 /*all*/: combo_networkInterface->= findText(iface); + if (idx < 0) + { + bool ok; + iface.toInt(&ok); + if (ok) + { + idx =3D 0; + } + else + { + combo_networkInterface->addItem(iface); + idx =3D combo_networkInterface->findText(iface); + } + } + combo_networkInterface->setCurrentIndex(idx); + } = - kcfg_networkInterface->setCurrentIndex(Settings::networkInterface(= )); + void NetworkPref::updateSettings() + { + QString iface =3D combo_networkInterface->currentText(); + Settings::setNetworkInterface(iface); } = void NetworkPref::loadDefaults() diff --git a/ktorrent/pref/networkpref.h b/ktorrent/pref/networkpref.h index 67ab858..3fb6261 100644 --- a/ktorrent/pref/networkpref.h +++ b/ktorrent/pref/networkpref.h @@ -39,6 +39,7 @@ namespace kt = virtual void loadSettings(); virtual void loadDefaults(); + virtual void updateSettings(); signals: void calculateRecommendedSettings(); = diff --git a/ktorrent/pref/networkpref.ui b/ktorrent/pref/networkpref.ui index f1dd4c9..38b25a3 100644 --- a/ktorrent/pref/networkpref.ui +++ b/ktorrent/pref/networkpref.ui @@ -211,7 +211,7 @@ - + 0 diff --git a/libktcore/dbus/dbussettings.cpp b/libktcore/dbus/dbussettings.= cpp index 5c785d4..e2eb1af 100644 --- a/libktcore/dbus/dbussettings.cpp +++ b/libktcore/dbus/dbussettings.cpp @@ -598,12 +598,12 @@ namespace kt Settings::setMaxSeedTime(val); } = - int DBusSettings::networkInterface() + QString DBusSettings::networkInterface() { return Settings::networkInterface(); } = - void DBusSettings::setNetworkInterface(int val) + void DBusSettings::setNetworkInterface(const QString &val) { Settings::setNetworkInterface(val); } diff --git a/libktcore/dbus/dbussettings.h b/libktcore/dbus/dbussettings.h index e7337d3..2425f13 100644 --- a/libktcore/dbus/dbussettings.h +++ b/libktcore/dbus/dbussettings.h @@ -149,8 +149,8 @@ namespace kt Q_SCRIPTABLE void setCompletedDir(QString val); Q_SCRIPTABLE double maxSeedTime(); Q_SCRIPTABLE void setMaxSeedTime(double val); - Q_SCRIPTABLE int networkInterface(); - Q_SCRIPTABLE void setNetworkInterface(int val); + Q_SCRIPTABLE QString networkInterface(); + Q_SCRIPTABLE void setNetworkInterface(const QString &val); Q_SCRIPTABLE bool openMultipleTorrentsSilently(); Q_SCRIPTABLE void setOpenMultipleTorrentsSilently(bool val); Q_SCRIPTABLE bool openAllTorrentsSilently(); diff --git a/libktcore/interfaces/functions.cpp b/libktcore/interfaces/func= tions.cpp index 3d7e56a..3516203 100644 --- a/libktcore/interfaces/functions.cpp +++ b/libktcore/interfaces/functions.cpp @@ -160,22 +160,7 @@ namespace kt = bt::TorrentControl::setDataCheckWhenCompleted(Settings::checkWhenF= inished()); bt::TorrentControl::setMinimumDiskSpace(Settings::minDiskSpace()); - - - if (Settings::networkInterface() =3D=3D 0) - { - SetNetworkInterface(QString::null); - } - else - { - QList iface_list =3D QNetworkInterface::all= Interfaces(); - int iface =3D Settings::networkInterface(); - if (iface > iface_list.count()) - SetNetworkInterface(QString::null); - else - SetNetworkInterface(iface_list[iface - 1].name()); - } - + bt::SetNetworkInterface(Settings::networkInterface()); net::Socks::setSocksEnabled(Settings::socksEnabled()); net::Socks::setSocksVersion(Settings::socksVersion()); net::Socks::setSocksServerAddress(Settings::socksProxy(), Settings= ::socksPort()); diff --git a/libktcore/ktorrent.kcfg b/libktcore/ktorrent.kcfg index 80f8882..c29643d 100644 --- a/libktcore/ktorrent.kcfg +++ b/libktcore/ktorrent.kcfg @@ -244,10 +244,7 @@ 0 0 - - 0 - 0 - 255 + false