@ -52,7 +52,6 @@
# include "base/rss/rss_session.h"
# include "base/rss/rss_session.h"
# include "base/torrentfileguard.h"
# include "base/torrentfileguard.h"
# include "base/torrentfileswatcher.h"
# include "base/torrentfileswatcher.h"
# include "base/utils/fs.h"
# include "base/utils/misc.h"
# include "base/utils/misc.h"
# include "base/utils/net.h"
# include "base/utils/net.h"
# include "base/utils/password.h"
# include "base/utils/password.h"
@ -770,42 +769,25 @@ void OptionsDialog::loadConnectionTabOptions()
}
}
const auto * proxyConfigManager = Net : : ProxyConfigurationManager : : instance ( ) ;
const auto * proxyConfigManager = Net : : ProxyConfigurationManager : : instance ( ) ;
Net : : ProxyConfiguration proxyConf = proxyConfigManager - > proxyConfiguration ( ) ;
const Net : : ProxyConfiguration proxyConf = proxyConfigManager - > proxyConfiguration ( ) ;
using Net : : ProxyType ;
bool useProxyAuth = false ;
m_ui - > comboProxyType - > addItem ( tr ( " SOCKS4 " ) , QVariant : : fromValue ( Net : : ProxyType : : SOCKS4 ) ) ;
switch ( proxyConf . type )
m_ui - > comboProxyType - > addItem ( tr ( " SOCKS5 " ) , QVariant : : fromValue ( Net : : ProxyType : : SOCKS5 ) ) ;
{
m_ui - > comboProxyType - > addItem ( tr ( " HTTP " ) , QVariant : : fromValue ( Net : : ProxyType : : HTTP ) ) ;
case ProxyType : : SOCKS4 :
m_ui - > comboProxyType - > setCurrentIndex ( m_ui - > comboProxyType - > findData ( QVariant : : fromValue ( proxyConf . type ) ) ) ;
m_ui - > comboProxyType - > setCurrentIndex ( 1 ) ;
adjustProxyOptions ( ) ;
break ;
case ProxyType : : SOCKS5_PW :
useProxyAuth = true ;
// fallthrough
case ProxyType : : SOCKS5 :
m_ui - > comboProxyType - > setCurrentIndex ( 2 ) ;
break ;
case ProxyType : : HTTP_PW :
useProxyAuth = true ;
// fallthrough
case ProxyType : : HTTP :
m_ui - > comboProxyType - > setCurrentIndex ( 3 ) ;
break ;
default :
m_ui - > comboProxyType - > setCurrentIndex ( 0 ) ;
}
m_ui - > textProxyIP - > setText ( proxyConf . ip ) ;
m_ui - > textProxyIP - > setText ( proxyConf . ip ) ;
m_ui - > spinProxyPort - > setValue ( proxyConf . port ) ;
m_ui - > spinProxyPort - > setValue ( proxyConf . port ) ;
m_ui - > checkProxyAuth - > setChecked ( useProxyAuth ) ;
m_ui - > checkProxyAuth - > setChecked ( proxyConf . authEnabled ) ;
m_ui - > textProxyUsername - > setText ( proxyConf . username ) ;
m_ui - > textProxyUsername - > setText ( proxyConf . username ) ;
m_ui - > textProxyPassword - > setText ( proxyConf . password ) ;
m_ui - > textProxyPassword - > setText ( proxyConf . password ) ;
m_ui - > checkProxyBitTorrent - > setChecked ( Preferences : : instance ( ) - > useProxyForBT ( ) ) ;
m_ui - > checkProxyPeerConnections - > setChecked ( session - > isProxyPeerConnectionsEnabled ( ) ) ;
m_ui - > checkProxyPeerConnections - > setChecked ( session - > isProxyPeerConnectionsEnabled ( ) ) ;
m_ui - > isProxyOnlyForTorrents - > setChecked ( proxyConfigManager - > isProxyOnlyForTorrents ( ) ) ;
m_ui - > checkProxyHostnameLookup - > setChecked ( session - > isProxyHostnameLookupEnabled ( ) ) ;
m_ui - > checkProxyHostnameLookup - > setChecked ( session - > isProxyHostnameLookupEnabled ( ) ) ;
enableProxy ( m_ui - > comboProxyType - > currentIndex ( ) ) ;
m_ui - > checkProxyRSS - > setChecked ( Preferences : : instance ( ) - > useProxyForRSS ( ) ) ;
m_ui - > checkProxyMisc - > setChecked ( Preferences : : instance ( ) - > useProxyForGeneralPurposes ( ) ) ;
m_ui - > checkIPFilter - > setChecked ( session - > isIPFilteringEnabled ( ) ) ;
m_ui - > checkIPFilter - > setChecked ( session - > isIPFilteringEnabled ( ) ) ;
m_ui - > textFilterPath - > setDialogCaption ( tr ( " Choose an IP filter file " ) ) ;
m_ui - > textFilterPath - > setDialogCaption ( tr ( " Choose an IP filter file " ) ) ;
@ -830,14 +812,17 @@ void OptionsDialog::loadConnectionTabOptions()
connect ( m_ui - > spinMaxUploads , qSpinBoxValueChanged , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > spinMaxUploads , qSpinBoxValueChanged , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > spinMaxUploadsPerTorrent , qSpinBoxValueChanged , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > spinMaxUploadsPerTorrent , qSpinBoxValueChanged , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > comboProxyType , qComboBoxCurrentIndexChanged , this , & ThisType : : enableProxy ) ;
connect ( m_ui - > comboProxyType , qComboBoxCurrentIndexChanged , this , & ThisType : : adjustProxyOptions ) ;
connect ( m_ui - > comboProxyType , qComboBoxCurrentIndexChanged , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > comboProxyType , qComboBoxCurrentIndexChanged , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > textProxyIP , & QLineEdit : : textChanged , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > textProxyIP , & QLineEdit : : textChanged , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > spinProxyPort , qSpinBoxValueChanged , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > spinProxyPort , qSpinBoxValueChanged , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > checkProxyBitTorrent , & QGroupBox : : toggled , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > checkProxyBitTorrent , & QGroupBox : : toggled , this , & ThisType : : adjustProxyOptions ) ;
connect ( m_ui - > checkProxyPeerConnections , & QAbstractButton : : toggled , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > checkProxyPeerConnections , & QAbstractButton : : toggled , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > isProxyOnlyForTorrents , & QAbstractButton : : toggled , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > checkProxyHostnameLookup , & QAbstractButton : : toggled , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > checkProxyHostnameLookup , & QAbstractButton : : toggled , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > checkProxyRSS , & QAbstractButton : : toggled , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > checkProxyMisc , & QAbstractButton : : toggled , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > checkProxyAuth , & QGroupBox : : toggled , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > checkProxyAuth , & QGroupBox : : toggled , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > textProxyUsername , & QLineEdit : : textChanged , this , & ThisType : : enableApplyButton ) ;
connect ( m_ui - > textProxyUsername , & QLineEdit : : textChanged , this , & ThisType : : enableApplyButton ) ;
@ -868,11 +853,15 @@ void OptionsDialog::saveConnectionTabOptions() const
proxyConf . type = getProxyType ( ) ;
proxyConf . type = getProxyType ( ) ;
proxyConf . ip = getProxyIp ( ) ;
proxyConf . ip = getProxyIp ( ) ;
proxyConf . port = getProxyPort ( ) ;
proxyConf . port = getProxyPort ( ) ;
proxyConf . authEnabled = m_ui - > checkProxyAuth - > isChecked ( ) ;
proxyConf . username = getProxyUsername ( ) ;
proxyConf . username = getProxyUsername ( ) ;
proxyConf . password = getProxyPassword ( ) ;
proxyConf . password = getProxyPassword ( ) ;
proxyConfigManager - > setProxyOnlyForTorrents ( m_ui - > isProxyOnlyForTorrents - > isChecked ( ) ) ;
proxyConfigManager - > setProxyConfiguration ( proxyConf ) ;
proxyConfigManager - > setProxyConfiguration ( proxyConf ) ;
Preferences : : instance ( ) - > setUseProxyForBT ( m_ui - > checkProxyBitTorrent - > isChecked ( ) ) ;
Preferences : : instance ( ) - > setUseProxyForRSS ( m_ui - > checkProxyRSS - > isChecked ( ) ) ;
Preferences : : instance ( ) - > setUseProxyForGeneralPurposes ( m_ui - > checkProxyMisc - > isChecked ( ) ) ;
session - > setProxyPeerConnectionsEnabled ( m_ui - > checkProxyPeerConnections - > isChecked ( ) ) ;
session - > setProxyPeerConnectionsEnabled ( m_ui - > checkProxyPeerConnections - > isChecked ( ) ) ;
session - > setProxyHostnameLookupEnabled ( m_ui - > checkProxyHostnameLookup - > isChecked ( ) ) ;
session - > setProxyHostnameLookupEnabled ( m_ui - > checkProxyHostnameLookup - > isChecked ( ) ) ;
@ -1321,21 +1310,7 @@ bool OptionsDialog::isIPFilteringEnabled() const
Net : : ProxyType OptionsDialog : : getProxyType ( ) const
Net : : ProxyType OptionsDialog : : getProxyType ( ) const
{
{
switch ( m_ui - > comboProxyType - > currentIndex ( ) )
return m_ui - > comboProxyType - > currentData ( ) . value < Net : : ProxyType > ( ) ;
{
case 1 :
return Net : : ProxyType : : SOCKS4 ;
case 2 :
if ( isProxyAuthEnabled ( ) )
return Net : : ProxyType : : SOCKS5_PW ;
return Net : : ProxyType : : SOCKS5 ;
case 3 :
if ( isProxyAuthEnabled ( ) )
return Net : : ProxyType : : HTTP_PW ;
return Net : : ProxyType : : HTTP ;
default :
return Net : : ProxyType : : None ;
}
}
}
int OptionsDialog : : getPort ( ) const
int OptionsDialog : : getPort ( ) const
@ -1512,41 +1487,29 @@ void OptionsDialog::toggleComboRatioLimitAct()
m_ui - > comboRatioLimitAct - > setEnabled ( m_ui - > checkMaxRatio - > isChecked ( ) | | m_ui - > checkMaxSeedingMinutes - > isChecked ( ) ) ;
m_ui - > comboRatioLimitAct - > setEnabled ( m_ui - > checkMaxRatio - > isChecked ( ) | | m_ui - > checkMaxSeedingMinutes - > isChecked ( ) ) ;
}
}
void OptionsDialog : : enableProxy ( const int index )
void OptionsDialog : : adjustProxyOptions ( )
{
{
if ( index > = 1 )
const auto currentProxyType = m_ui - > comboProxyType - > currentData ( ) . value < Net : : ProxyType > ( ) ;
{ // Any proxy type is used
const bool isAuthSupported = ( currentProxyType ! = Net : : ProxyType : : SOCKS4 ) ;
//enable
m_ui - > lblProxyIP - > setEnabled ( true ) ;
m_ui - > checkProxyAuth - > setEnabled ( isAuthSupported ) ;
m_ui - > textProxyIP - > setEnabled ( true ) ;
m_ui - > lblProxyPort - > setEnabled ( true ) ;
if ( currentProxyType = = Net : : ProxyType : : SOCKS4 )
m_ui - > spinProxyPort - > setEnabled ( true ) ;
{
m_ui - > checkProxyPeerConnections - > setEnabled ( true ) ;
m_ui - > labelProxyTypeIncompatible - > setVisible ( true ) ;
if ( index > = 2 )
{ // SOCKS5 or HTTP
m_ui - > checkProxyHostnameLookup - > setEnabled ( false ) ;
m_ui - > checkProxyAuth - > setEnabled ( true ) ;
m_ui - > checkProxyRSS - > setEnabled ( false ) ;
m_ui - > isProxyOnlyForTorrents - > setEnabled ( true ) ;
m_ui - > checkProxyMisc - > setEnabled ( false ) ;
m_ui - > checkProxyHostnameLookup - > setEnabled ( true ) ;
}
else
{
m_ui - > checkProxyAuth - > setEnabled ( false ) ;
m_ui - > isProxyOnlyForTorrents - > setEnabled ( false ) ;
m_ui - > isProxyOnlyForTorrents - > setChecked ( true ) ;
m_ui - > checkProxyHostnameLookup - > setEnabled ( false ) ;
}
}
}
else
else
{ // No proxy
{
// disable
// SOCKS5 or HTTP
m_ui - > lblProxyIP - > setEnabled ( false ) ;
m_ui - > labelProxyTypeIncompatible - > setVisible ( false ) ;
m_ui - > textProxyIP - > setEnabled ( false ) ;
m_ui - > lblProxyPort - > setEnabled ( false ) ;
m_ui - > checkProxyHostnameLookup - > setEnabled ( m_ui - > checkProxyBitTorrent - > isChecked ( ) ) ;
m_ui - > spinProxyPort - > setEnabled ( false ) ;
m_ui - > checkProxyRSS - > setEnabled ( true ) ;
m_ui - > checkProxyPeerConnections - > setEnabled ( false ) ;
m_ui - > checkProxyMisc - > setEnabled ( true ) ;
m_ui - > isProxyOnlyForTorrents - > setEnabled ( false ) ;
m_ui - > checkProxyHostnameLookup - > setEnabled ( false ) ;
m_ui - > checkProxyAuth - > setEnabled ( false ) ;
}
}
}
}
@ -1578,11 +1541,6 @@ bool OptionsDialog::isProxyEnabled() const
return m_ui - > comboProxyType - > currentIndex ( ) ;
return m_ui - > comboProxyType - > currentIndex ( ) ;
}
}
bool OptionsDialog : : isProxyAuthEnabled ( ) const
{
return m_ui - > checkProxyAuth - > isChecked ( ) ;
}
QString OptionsDialog : : getProxyIp ( ) const
QString OptionsDialog : : getProxyIp ( ) const
{
{
return m_ui - > textProxyIP - > text ( ) . trimmed ( ) ;
return m_ui - > textProxyIP - > text ( ) . trimmed ( ) ;