From b7dd6d43feb123be8551c4fd6f0a8608c5ec5295 Mon Sep 17 00:00:00 2001 From: Jose Manuel Delicado Date: Mon, 16 Jan 2017 14:11:54 +0100 Subject: [PATCH] Fixed sintax errors. Added a new option to set the proxy type --- src/app-configuration.defaults | 1 + src/controller/settings.py | 7 +++++-- src/fixes/fix_requests.py | 4 ++-- src/wxUI/dialogs/configuration.py | 13 ++++++++++--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/app-configuration.defaults b/src/app-configuration.defaults index fdf20d4e..6900ef98 100644 --- a/src/app-configuration.defaults +++ b/src/app-configuration.defaults @@ -19,6 +19,7 @@ donation_dialog_displayed = boolean(default=False) check_for_updates = boolean(default=True) [proxy] +type = string(default="Direct connection") server = string(default="") port = string(default="") user = string(default="") diff --git a/src/controller/settings.py b/src/controller/settings.py index 6c8e1165..68825a7d 100644 --- a/src/controller/settings.py +++ b/src/controller/settings.py @@ -67,7 +67,9 @@ class globalSettingsController(object): self.dialog.set_value("general", "disable_sapi5", config.app["app-settings"]["voice_enabled"]) self.dialog.set_value("general", "hide_gui", config.app["app-settings"]["hide_gui"]) self.dialog.set_value("general", "check_for_updates", config.app["app-settings"]["check_for_updates"]) - self.dialog.create_proxy() + proxyTypes=[_(u"Direct connection"), u"http", u"https", u"socks4", u"socks5"] + self.dialog.create_proxy(proxyTypes) + self.dialog.proxy.type.SetSelection(proxyTypes.index(config.app["proxy"]["type"])) self.dialog.set_value("proxy", "server", config.app["proxy"]["server"]) self.dialog.set_value("proxy", "port", config.app["proxy"]["port"]) self.dialog.set_value("proxy", "user", config.app["proxy"]["user"]) @@ -100,9 +102,10 @@ class globalSettingsController(object): config.app["app-settings"]["play_ready_sound"] = self.dialog.get_value("general", "play_ready_sound") config.app["app-settings"]["speak_ready_msg"] = self.dialog.get_value("general", "speak_ready_msg") config.app["app-settings"]["check_for_updates"] = self.dialog.get_value("general", "check_for_updates") - if config.app["proxy"]["server"] != self.dialog.get_value("proxy", "server") or config.app["proxy"]["port"] != self.dialog.get_value("proxy", "port") or config.app["proxy"]["user"] != self.dialog.get_value("proxy", "user") or config.app["proxy"]["password"] != self.dialog.get_value("proxy", "password"): + if config.app["proxy"]["type"]!=self.dialog.get_value("proxy", "type") or config.app["proxy"]["server"] != self.dialog.get_value("proxy", "server") or config.app["proxy"]["port"] != self.dialog.get_value("proxy", "port") or config.app["proxy"]["user"] != self.dialog.get_value("proxy", "user") or config.app["proxy"]["password"] != self.dialog.get_value("proxy", "password"): if self.is_started == True: self.needs_restart = True + config.app["proxy"]["type"]=self.dialog.get_value("proxy", "type") config.app["proxy"]["server"] = self.dialog.get_value("proxy", "server") config.app["proxy"]["port"] = self.dialog.get_value("proxy", "port") config.app["proxy"]["user"] = self.dialog.get_value("proxy", "user") diff --git a/src/fixes/fix_requests.py b/src/fixes/fix_requests.py index 0defb66a..e6589fbe 100644 --- a/src/fixes/fix_requests.py +++ b/src/fixes/fix_requests.py @@ -19,12 +19,12 @@ def patched_session_init(self): self.proxies={"http":"http://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), "https": "https://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), "http": "socks5://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), - "https": "socks5://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"]) + "https": "socks5://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), "http": "socks4://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), "https": "socks4://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"])} if config.app["proxy"]["user"] != "" and config.app["proxy"]["password"] != "": self.proxies={"http": "http://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]), - "https": "https://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]) + "https": "https://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]), "http": "socks5://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]), "https": "socks5://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]), "http": "socks4://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]), diff --git a/src/wxUI/dialogs/configuration.py b/src/wxUI/dialogs/configuration.py index 64dc203f..aada89b0 100644 --- a/src/wxUI/dialogs/configuration.py +++ b/src/wxUI/dialogs/configuration.py @@ -47,9 +47,16 @@ class general(wx.Panel, baseDialog.BaseWXDialog): class proxy(wx.Panel, baseDialog.BaseWXDialog): - def __init__(self, parent): + def __init__(self, parent, proxyTypes): super(proxy, self).__init__(parent) sizer = wx.BoxSizer(wx.VERTICAL) + type=wx.StaticText(self, wx.NewId(), _(u"Proxy type: ")) + self.type=wx.ComboBox(self, -1, choices=proxyTypes, style=wx.CB_READONLY) + self.type.SetSize(self.type.GetBestSize()) + typeBox = wx.BoxSizer(wx.HORIZONTAL) + typeBox.Add(type, 0, wx.ALL, 5) + typeBox.Add(self.type, 0, wx.ALL, 5) + sizer.Add(typeBox, 0, wx.ALL, 5) lbl = wx.StaticText(self, wx.NewId(), _(u"Proxy server: ")) self.server = wx.TextCtrl(self, -1) serverBox = wx.BoxSizer(wx.HORIZONTAL) @@ -335,8 +342,8 @@ class configurationDialog(baseDialog.BaseWXDialog): self.notebook.AddPage(self.general, _(u"General")) self.general.SetFocus() - def create_proxy(self): - self.proxy = proxy(self.notebook) + def create_proxy(self, proxyTypes): + self.proxy = proxy(self.notebook, proxyTypes) self.notebook.AddPage(self.proxy, _(u"Proxy")) def create_general_account(self):