diff --git a/src/bitmessageqt/settings.py b/src/bitmessageqt/settings.py
index 7fb0ea91..8fe1ecba 100644
--- a/src/bitmessageqt/settings.py
+++ b/src/bitmessageqt/settings.py
@@ -1,3 +1,4 @@
+import ConfigParser
import os
import sys
@@ -16,6 +17,7 @@ import tempfile
import widgets
from bmconfigparser import BMConfigParser
from helper_sql import sqlExecute, sqlStoredProcedure
+from helper_startup import start_proxyconfig
from network.asyncore_pollchoose import set_rates
from tr import _translate
@@ -32,6 +34,16 @@ class SettingsDialog(QtGui.QDialog):
self.net_restart_needed = False
self.timer = QtCore.QTimer()
+ try:
+ import pkg_resources
+ except ImportError:
+ pass
+ else:
+ # Append proxy types defined in plugins
+ for ep in pkg_resources.iter_entry_points(
+ 'bitmessage.proxyconfig'):
+ self.comboBoxProxyType.addItem(ep.name)
+
self.lineEditMaxOutboundConnections.setValidator(
QtGui.QIntValidator(0, 8, self.lineEditMaxOutboundConnections))
@@ -117,21 +129,16 @@ class SettingsDialog(QtGui.QDialog):
self.checkBoxOnionOnly.setChecked(
config.safeGetBoolean('bitmessagesettings', 'onionservicesonly'))
- proxy_type = config.safeGet(
- 'bitmessagesettings', 'socksproxytype', 'none')
- if proxy_type == 'none':
- self.comboBoxProxyType.setCurrentIndex(0)
- self.lineEditSocksHostname.setEnabled(False)
- self.lineEditSocksPort.setEnabled(False)
- self.lineEditSocksUsername.setEnabled(False)
- self.lineEditSocksPassword.setEnabled(False)
- self.checkBoxAuthentication.setEnabled(False)
- self.checkBoxSocksListen.setEnabled(False)
- self.checkBoxOnionOnly.setEnabled(False)
- elif proxy_type == 'SOCKS4a':
- self.comboBoxProxyType.setCurrentIndex(1)
- elif proxy_type == 'SOCKS5':
- self.comboBoxProxyType.setCurrentIndex(2)
+ try:
+ # Get real value, not temporary
+ self._proxy_type = ConfigParser.SafeConfigParser.get(
+ config, 'bitmessagesettings', 'socksproxytype')
+ except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
+ self._proxy_type = 'none'
+ self.comboBoxProxyType.setCurrentIndex(
+ 0 if self._proxy_type == 'none'
+ else self.comboBoxProxyType.findText(self._proxy_type))
+ self.comboBoxProxyTypeChanged(self.comboBoxProxyType.currentIndex())
self.lineEditSocksHostname.setText(
config.get('bitmessagesettings', 'sockshostname'))
@@ -219,7 +226,7 @@ class SettingsDialog(QtGui.QDialog):
self.checkBoxAuthentication.setEnabled(False)
self.checkBoxSocksListen.setEnabled(False)
self.checkBoxOnionOnly.setEnabled(False)
- elif comboBoxIndex in (1, 2):
+ else:
self.lineEditSocksHostname.setEnabled(True)
self.lineEditSocksPort.setEnabled(True)
self.checkBoxAuthentication.setEnabled(True)
@@ -321,27 +328,22 @@ class SettingsDialog(QtGui.QDialog):
upnpThread = upnp.uPnPThread()
upnpThread.start()
- proxy_type = self.config.safeGet(
- 'bitmessagesettings', 'socksproxytype', 'none')
- if (
- proxy_type == 'none' and
- self.comboBoxProxyType.currentText()[0:5] == 'SOCKS' and
- shared.statusIconColor != 'red'
- ):
- self.net_restart_needed = True
- if (
- proxy_type[0:5] == 'SOCKS' and
- self.comboBoxProxyType.currentText()[0:5] != 'SOCKS'
- ):
+ proxytype_index = self.comboBoxProxyType.currentIndex()
+ if proxytype_index == 0:
+ if self._proxy_type != 'none' and shared.statusIconColor != 'red':
+ self.net_restart_needed = True
+ elif self.comboBoxProxyType.currentText() != self._proxy_type:
self.net_restart_needed = True
self.parent.statusbar.clearMessage()
self.config.set(
'bitmessagesettings', 'socksproxytype',
- str(self.comboBoxProxyType.currentText())
- if self.comboBoxProxyType.currentText()[0:5] == 'SOCKS'
- else 'none'
+ 'none' if self.comboBoxProxyType.currentIndex() == 0
+ else str(self.comboBoxProxyType.currentText())
)
+ if proxytype_index > 2: # last literal proxytype in ui
+ start_proxyconfig()
+
self.config.set('bitmessagesettings', 'socksauthentication', str(
self.checkBoxAuthentication.isChecked()))
self.config.set('bitmessagesettings', 'sockshostname', str(
diff --git a/src/bitmessageqt/settings.ui b/src/bitmessageqt/settings.ui
index 33278e94..0ffbf442 100644
--- a/src/bitmessageqt/settings.ui
+++ b/src/bitmessageqt/settings.ui
@@ -419,12 +419,12 @@
-
- SOCKS4a
+ SOCKS4a
-
- SOCKS5
+ SOCKS5