Use spinbox special value to represent "Use any available port"

WebAPI functionality is preserved (deprecated) for now and should be
removed in the future.
This commit is contained in:
Chocobo1 2021-07-28 12:24:03 +08:00
commit 49aab492e0
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
9 changed files with 39 additions and 54 deletions

View file

@ -407,7 +407,6 @@ Session::Session(QObject *parent)
, m_isBandwidthSchedulerEnabled(BITTORRENT_SESSION_KEY("BandwidthSchedulerEnabled"), false)
, m_saveResumeDataInterval(BITTORRENT_SESSION_KEY("SaveResumeDataInterval"), 60)
, m_port(BITTORRENT_SESSION_KEY("Port"), -1)
, m_useAnyAvailablePort(BITTORRENT_SESSION_KEY("UseRandomPort"), false)
, m_networkInterface(BITTORRENT_SESSION_KEY("Interface"))
, m_networkInterfaceName(BITTORRENT_SESSION_KEY("InterfaceName"))
, m_networkInterfaceAddress(BITTORRENT_SESSION_KEY("InterfaceAddress"))
@ -1421,13 +1420,12 @@ void Session::configureNetworkInterfaces(lt::settings_pack &settingsPack)
if (m_listenInterfaceConfigured)
return;
const int port = useAnyAvailablePort() ? 0 : this->port();
if (port > 0) // user specified port
if (port() > 0) // user has specified port number
settingsPack.set_int(lt::settings_pack::max_retry_port_bind, 0);
QStringList endpoints;
QStringList outgoingInterfaces;
const QString portString = ':' + QString::number(port);
const QString portString = ':' + QString::number(port());
for (const QString &ip : asConst(getListeningIPs()))
{
@ -2751,16 +2749,6 @@ void Session::setPort(const int port)
}
}
bool Session::useAnyAvailablePort() const
{
return m_useAnyAvailablePort;
}
void Session::setUseAnyAvailablePort(const bool value)
{
m_useAnyAvailablePort = value;
}
QString Session::networkInterface() const
{
return m_networkInterface;