From 6365810a8668559545d15cd75f8c4e177f20aee0 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 23 Dec 2011 11:11:36 +0200 Subject: [PATCH 01/17] Made factor in reload time global option behave --- gui/builtinContextMenus/factorReload.py | 3 ++- gui/builtinPreferenceViews/pyfaGlobalPreferences.py | 3 ++- service/fit.py | 12 +++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gui/builtinContextMenus/factorReload.py b/gui/builtinContextMenus/factorReload.py index 5923469f8..ca499e163 100644 --- a/gui/builtinContextMenus/factorReload.py +++ b/gui/builtinContextMenus/factorReload.py @@ -17,8 +17,9 @@ class FactorReload(ContextMenu): def activate(self, fullContext, selection, i): sFit = service.Fit.getInstance() + sFit.serviceFittingOptions["useGlobalForceReload"] = not sFit.serviceFittingOptions["useGlobalForceReload"] fitID = self.mainFrame.getActiveFit() - sFit.toggleFactorReload(fitID) + sFit.refreshFit(fitID) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) def getBitmap(self, context, selection): diff --git a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py index 160dc4434..c80d0165f 100644 --- a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py @@ -32,7 +32,7 @@ class PFGlobalPref ( PreferenceView): self.cbGlobalDmgPattern = wx.CheckBox( panel, wx.ID_ANY, u"Use global damage pattern", wx.DefaultPosition, wx.DefaultSize, 0 ) mainSizer.Add( self.cbGlobalDmgPattern, 0, wx.ALL|wx.EXPAND, 5 ) - self.cbGlobalForceReload = wx.CheckBox( panel, wx.ID_ANY, u"Use force reload", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.cbGlobalForceReload = wx.CheckBox( panel, wx.ID_ANY, u"Factor in reload time", wx.DefaultPosition, wx.DefaultSize, 0 ) mainSizer.Add( self.cbGlobalForceReload, 0, wx.ALL|wx.EXPAND, 5 ) defCharSizer = wx.BoxSizer( wx.HORIZONTAL ) @@ -77,6 +77,7 @@ class PFGlobalPref ( PreferenceView): def OnCBGlobalForceReloadStateChange(self, event): self.sFit.serviceFittingOptions["useGlobalForceReload"] = self.cbGlobalForceReload.GetValue() fitID = self.mainFrame.getActiveFit() + self.sFit.refreshFit(fitID) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) event.Skip() diff --git a/service/fit.py b/service/fit.py index 43c0c56b9..4f8494494 100644 --- a/service/fit.py +++ b/service/fit.py @@ -665,7 +665,17 @@ class Fit(object): else: return currState + def refreshFit(self, fitID): + if fitID is None: + return None + + fit = eos.db.getFit(fitID) + eos.db.commit() + self.recalc(fit) + def recalc(self, fit, withBoosters=False): + if fit.factorReload is not self.serviceFittingOptions["useGlobalForceReload"]: + fit.factorReload = self.serviceFittingOptions["useGlobalForceReload"] + eos.db.commit() fit.clear() - fit.forceReload = self.serviceFittingOptions["useGlobalForceReload"] fit.calculateModifiedAttributes(withBoosters=withBoosters, dirtyStorage=self.dirtyFitIDs) From 80203efb18fb72999f0f12e88cf96056bd2f53a9 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Fri, 23 Dec 2011 13:33:23 +0400 Subject: [PATCH 02/17] Remove commit from recalc Commit is issued in numerous other places anyway --- service/fit.py | 1 - 1 file changed, 1 deletion(-) diff --git a/service/fit.py b/service/fit.py index 4f8494494..900df974a 100644 --- a/service/fit.py +++ b/service/fit.py @@ -676,6 +676,5 @@ class Fit(object): def recalc(self, fit, withBoosters=False): if fit.factorReload is not self.serviceFittingOptions["useGlobalForceReload"]: fit.factorReload = self.serviceFittingOptions["useGlobalForceReload"] - eos.db.commit() fit.clear() fit.calculateModifiedAttributes(withBoosters=withBoosters, dirtyStorage=self.dirtyFitIDs) From 531967f513607ed4f7300c51f1c6b7f2cda9f09c Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 23 Dec 2011 16:30:54 +0200 Subject: [PATCH 03/17] Implemented UI part for proxy motherfrakking settings =) --- .../pyfaGlobalPreferences.py | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py index c80d0165f..be8523ad8 100644 --- a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py @@ -48,6 +48,43 @@ class PFGlobalPref ( PreferenceView): mainSizer.Add( defCharSizer, 0, wx.EXPAND, 5 ) + +# self.stPTitle = wx.StaticText( panel, wx.ID_ANY, "Proxy settings", wx.DefaultPosition, wx.DefaultSize, 0 ) +# self.stPTitle.Wrap( -1 ) +# self.stPTitle.SetFont( wx.Font( 12, 70, 90, 90, False, wx.EmptyString ) ) +# +# mainSizer.Add( self.stPTitle, 0, wx.ALL, 5 ) + + self.m_staticline2 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) + mainSizer.Add( self.m_staticline2, 0, wx.EXPAND, 5 ) + + self.cbProxySettings = wx.CheckBox( panel, wx.ID_ANY, u"Manual proxy settings", wx.DefaultPosition, wx.DefaultSize, 0 ) + mainSizer.Add( self.cbProxySettings, 0, wx.ALL, 5 ) + + ptypeSizer = wx.BoxSizer( wx.HORIZONTAL ) + + self.stPType = wx.StaticText( panel, wx.ID_ANY, u"Type:", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.stPType.Wrap( -1 ) + ptypeSizer.Add( self.stPType, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + self.chProxyTypeChoices = [ u"https", u"http", u"socks" ] + self.chProxyType = wx.Choice( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.chProxyTypeChoices, 0 ) + self.chProxyType.SetSelection( 0 ) + + ptypeSizer.Add( self.chProxyType, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + mainSizer.Add( ptypeSizer, 0, wx.EXPAND, 5 ) + psetSizer = wx.BoxSizer( wx.HORIZONTAL ) + + self.stPSet = wx.StaticText( panel, wx.ID_ANY, u"Addr:", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.stPSet.Wrap( -1 ) + psetSizer.Add( self.stPSet, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + self.editProxySettings = wx.TextCtrl( panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + + psetSizer.Add( self.editProxySettings, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + mainSizer.Add( psetSizer, 0, wx.EXPAND, 5) + cChar = service.Character.getInstance() charList = cChar.getCharacterList() @@ -69,11 +106,28 @@ class PFGlobalPref ( PreferenceView): self.cbGlobalDmgPattern.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalDmgPatternStateChange) self.cbGlobalForceReload.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalForceReloadStateChange) + self.cbProxySettings.Bind(wx.EVT_CHECKBOX, self.OnCBProxySettingsStateChange) self.chDefaultChar.Disable() + self.chDefaultChar.Show(False) + self.stDefChar.Show(False) + + self.ToggleProxySettings(self.cbProxySettings.GetValue()) panel.SetSizer( mainSizer ) panel.Layout() + def ToggleProxySettings(self, mode): + if mode: + self.chProxyType.Enable() + self.editProxySettings.Enable() + else: + self.chProxyType.Disable() + self.editProxySettings.Disable() + + def OnCBProxySettingsStateChange(self, event): + self.ToggleProxySettings(self.cbProxySettings.GetValue()) + event.Skip() + def OnCBGlobalForceReloadStateChange(self, event): self.sFit.serviceFittingOptions["useGlobalForceReload"] = self.cbGlobalForceReload.GetValue() fitID = self.mainFrame.getActiveFit() From 78ff4dc03d8315d23b5a3a1282d31a788a4733e7 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 23 Dec 2011 16:48:23 +0200 Subject: [PATCH 04/17] Show the list of proxies detected from system settings (informative only) --- .../pyfaGlobalPreferences.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py index be8523ad8..7578f2828 100644 --- a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py @@ -1,5 +1,6 @@ import wx import service +import urllib2 from gui.preferenceView import PreferenceView from gui import bitmapLoader @@ -85,6 +86,23 @@ class PFGlobalPref ( PreferenceView): psetSizer.Add( self.editProxySettings, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) mainSizer.Add( psetSizer, 0, wx.EXPAND, 5) + self.stPSAutoDetected = wx.StaticText( panel, wx.ID_ANY, u"Auto-detected: ", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.stPSAutoDetected.Wrap( -1 ) + mainSizer.Add( self.stPSAutoDetected, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + ps = urllib2.ProxyHandler().proxies + txt = "Auto-detected: " + + for type in ps: + txt += ps[type] + txt += " " + + if len(ps) == 0: + txt += "None" + + self.stPSAutoDetected.SetLabel(txt) + self.stPSAutoDetected.Disable() + cChar = service.Character.getInstance() charList = cChar.getCharacterList() From c6f61bc3bfabc70b18cf754d0a5d3b28ff106847 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 23 Dec 2011 18:16:01 +0200 Subject: [PATCH 05/17] Reworked proxy settings ui --- .../pyfaGlobalPreferences.py | 53 ++++++++++++------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py index 7578f2828..c86c64302 100644 --- a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py @@ -50,41 +50,56 @@ class PFGlobalPref ( PreferenceView): mainSizer.Add( defCharSizer, 0, wx.EXPAND, 5 ) -# self.stPTitle = wx.StaticText( panel, wx.ID_ANY, "Proxy settings", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.stPTitle.Wrap( -1 ) -# self.stPTitle.SetFont( wx.Font( 12, 70, 90, 90, False, wx.EmptyString ) ) -# -# mainSizer.Add( self.stPTitle, 0, wx.ALL, 5 ) - self.m_staticline2 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) mainSizer.Add( self.m_staticline2, 0, wx.EXPAND, 5 ) - self.cbProxySettings = wx.CheckBox( panel, wx.ID_ANY, u"Manual proxy settings", wx.DefaultPosition, wx.DefaultSize, 0 ) - mainSizer.Add( self.cbProxySettings, 0, wx.ALL, 5 ) + self.stPTitle = wx.StaticText( panel, wx.ID_ANY, "Proxy settings", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.stPTitle.Wrap( -1 ) + self.stPTitle.SetFont( wx.Font( 12, 70, 90, 90, False, wx.EmptyString ) ) + + mainSizer.Add( self.stPTitle, 0, wx.ALL, 5 ) + + +# self.cbProxySettings = wx.CheckBox( panel, wx.ID_ANY, u"Manual proxy settings", wx.DefaultPosition, wx.DefaultSize, 0 ) +# mainSizer.Add( self.cbProxySettings, 0, wx.ALL, 5 ) ptypeSizer = wx.BoxSizer( wx.HORIZONTAL ) - self.stPType = wx.StaticText( panel, wx.ID_ANY, u"Type:", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.stPType = wx.StaticText( panel, wx.ID_ANY, u"Mode:", wx.DefaultPosition, wx.DefaultSize, 0 ) self.stPType.Wrap( -1 ) ptypeSizer.Add( self.stPType, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) - self.chProxyTypeChoices = [ u"https", u"http", u"socks" ] + self.chProxyTypeChoices = [ u"No proxy settings", u"Auto-detected proxy settings", u"Manual proxy settings" ] self.chProxyType = wx.Choice( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.chProxyTypeChoices, 0 ) self.chProxyType.SetSelection( 0 ) ptypeSizer.Add( self.chProxyType, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) mainSizer.Add( ptypeSizer, 0, wx.EXPAND, 5 ) - psetSizer = wx.BoxSizer( wx.HORIZONTAL ) - self.stPSet = wx.StaticText( panel, wx.ID_ANY, u"Addr:", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.stPSet.Wrap( -1 ) - psetSizer.Add( self.stPSet, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + fgAddrSizer = wx.FlexGridSizer( 2, 2, 0, 0 ) + fgAddrSizer.SetFlexibleDirection( wx.BOTH ) + fgAddrSizer.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) - self.editProxySettings = wx.TextCtrl( panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) - psetSizer.Add( self.editProxySettings, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) - mainSizer.Add( psetSizer, 0, wx.EXPAND, 5) + self.stPSetAddr = wx.StaticText( panel, wx.ID_ANY, u"Addr:", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.stPSetAddr.Wrap( -1 ) + fgAddrSizer.Add( self.stPSetAddr, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + self.editProxySettingsAddr = wx.TextCtrl( panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + + fgAddrSizer.Add( self.editProxySettingsAddr, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + self.stPSetPort = wx.StaticText( panel, wx.ID_ANY, u"Port:", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.stPSetPort.Wrap( -1 ) + + fgAddrSizer.Add( self.stPSetPort, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + self.editProxySettingsPort = wx.TextCtrl( panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + + fgAddrSizer.Add( self.editProxySettingsPort, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + mainSizer.Add( fgAddrSizer, 0, wx.EXPAND, 5) self.stPSAutoDetected = wx.StaticText( panel, wx.ID_ANY, u"Auto-detected: ", wx.DefaultPosition, wx.DefaultSize, 0 ) self.stPSAutoDetected.Wrap( -1 ) @@ -124,12 +139,12 @@ class PFGlobalPref ( PreferenceView): self.cbGlobalDmgPattern.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalDmgPatternStateChange) self.cbGlobalForceReload.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalForceReloadStateChange) - self.cbProxySettings.Bind(wx.EVT_CHECKBOX, self.OnCBProxySettingsStateChange) +# self.cbProxySettings.Bind(wx.EVT_CHECKBOX, self.OnCBProxySettingsStateChange) self.chDefaultChar.Disable() self.chDefaultChar.Show(False) self.stDefChar.Show(False) - self.ToggleProxySettings(self.cbProxySettings.GetValue()) +# self.ToggleProxySettings(self.cbProxySettings.GetValue()) panel.SetSizer( mainSizer ) panel.Layout() From a090c1d411007b36c82dce5dae501814195c47a3 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 23 Dec 2011 19:56:09 +0200 Subject: [PATCH 06/17] Fully implemented proxy settings UI, the settings can be accessed thru settings.ProxySettings --- .../pyfaGlobalPreferences.py | 131 +++++++++++++++--- gui/preferenceDialog.py | 18 ++- service/settings.py | 43 ++++++ 3 files changed, 168 insertions(+), 24 deletions(-) diff --git a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py index c86c64302..b9b0f5647 100644 --- a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py @@ -16,6 +16,15 @@ class PFGlobalPref ( PreferenceView): def populatePanel( self, panel ): self.mainFrame = gui.mainFrame.MainFrame.getInstance() + self.proxySettings = service.settings.ProxySettings.getInstance() + self.dirtySettings = False + + self.nMode = self.proxySettings.getMode() + self.nAddr = self.proxySettings.getAddress() + self.nPort = self.proxySettings.getPort() + self.nType = self.proxySettings.getType() + + mainSizer = wx.BoxSizer( wx.VERTICAL ) self.stTitle = wx.StaticText( panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0 ) @@ -24,8 +33,8 @@ class PFGlobalPref ( PreferenceView): mainSizer.Add( self.stTitle, 0, wx.ALL, 5 ) - self.m_staticline1 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) - mainSizer.Add( self.m_staticline1, 0, wx.EXPAND, 5 ) +# self.m_staticline1 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) +# mainSizer.Add( self.m_staticline1, 0, wx.EXPAND, 5 ) self.cbGlobalChar = wx.CheckBox( panel, wx.ID_ANY, u"Use global character", wx.DefaultPosition, wx.DefaultSize, 0 ) mainSizer.Add( self.cbGlobalChar, 0, wx.ALL|wx.EXPAND, 5 ) @@ -60,24 +69,24 @@ class PFGlobalPref ( PreferenceView): mainSizer.Add( self.stPTitle, 0, wx.ALL, 5 ) -# self.cbProxySettings = wx.CheckBox( panel, wx.ID_ANY, u"Manual proxy settings", wx.DefaultPosition, wx.DefaultSize, 0 ) -# mainSizer.Add( self.cbProxySettings, 0, wx.ALL, 5 ) - ptypeSizer = wx.BoxSizer( wx.HORIZONTAL ) self.stPType = wx.StaticText( panel, wx.ID_ANY, u"Mode:", wx.DefaultPosition, wx.DefaultSize, 0 ) self.stPType.Wrap( -1 ) ptypeSizer.Add( self.stPType, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) - self.chProxyTypeChoices = [ u"No proxy settings", u"Auto-detected proxy settings", u"Manual proxy settings" ] + self.chProxyTypeChoices = [ u"No proxy", u"Auto-detected proxy settings", u"Manual proxy settings" ] self.chProxyType = wx.Choice( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.chProxyTypeChoices, 0 ) - self.chProxyType.SetSelection( 0 ) + + + self.chProxyType.SetSelection( self.nMode ) ptypeSizer.Add( self.chProxyType, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) mainSizer.Add( ptypeSizer, 0, wx.EXPAND, 5 ) fgAddrSizer = wx.FlexGridSizer( 2, 2, 0, 0 ) + fgAddrSizer.AddGrowableCol( 1 ) fgAddrSizer.SetFlexibleDirection( wx.BOTH ) fgAddrSizer.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) @@ -86,18 +95,18 @@ class PFGlobalPref ( PreferenceView): self.stPSetAddr.Wrap( -1 ) fgAddrSizer.Add( self.stPSetAddr, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) - self.editProxySettingsAddr = wx.TextCtrl( panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + self.editProxySettingsAddr = wx.TextCtrl( panel, wx.ID_ANY, self.nAddr, wx.DefaultPosition, wx.DefaultSize, 0 ) - fgAddrSizer.Add( self.editProxySettingsAddr, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + fgAddrSizer.Add( self.editProxySettingsAddr, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5 ) self.stPSetPort = wx.StaticText( panel, wx.ID_ANY, u"Port:", wx.DefaultPosition, wx.DefaultSize, 0 ) self.stPSetPort.Wrap( -1 ) fgAddrSizer.Add( self.stPSetPort, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) - self.editProxySettingsPort = wx.TextCtrl( panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + self.editProxySettingsPort = wx.TextCtrl( panel, wx.ID_ANY, self.nPort, wx.DefaultPosition, wx.DefaultSize, 0 ) - fgAddrSizer.Add( self.editProxySettingsPort, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + fgAddrSizer.Add( self.editProxySettingsPort, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5 ) mainSizer.Add( fgAddrSizer, 0, wx.EXPAND, 5) @@ -105,15 +114,38 @@ class PFGlobalPref ( PreferenceView): self.stPSAutoDetected.Wrap( -1 ) mainSizer.Add( self.stPSAutoDetected, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) - ps = urllib2.ProxyHandler().proxies + btnSizer = wx.BoxSizer( wx.HORIZONTAL ) + btnSizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 ) + + self.btnApply = wx.Button( panel, wx.ID_ANY, u"Apply", wx.DefaultPosition, wx.DefaultSize, 0 ) + + btnSizer.Add( self.btnApply, 0, wx.ALL, 5 ) + + mainSizer.Add(btnSizer, 0, wx.EXPAND,5) + + proxy = None + proxAddr = proxPort = "" + proxydict = urllib2.ProxyHandler().proxies txt = "Auto-detected: " - for type in ps: - txt += ps[type] - txt += " " + validPrefixes = ("https", "http") - if len(ps) == 0: + for prefix in validPrefixes: + if not prefix in proxydict: + continue + proxyline = proxydict[prefix] + proto = "{0}://".format(prefix) + if proxyline[:len(proto)] == proto: + proxyline = proxyline[len(proto):] + proxAddr, proxPort = proxyline.split(":") + proxPort = int(proxPort.rstrip("/")) + proxy = (proxAddr, proxPort) + break + + if len(proxAddr) == 0: txt += "None" + else: + txt += proto + proxAddr + ":" + str(proxPort) self.stPSAutoDetected.SetLabel(txt) self.stPSAutoDetected.Disable() @@ -139,23 +171,78 @@ class PFGlobalPref ( PreferenceView): self.cbGlobalDmgPattern.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalDmgPatternStateChange) self.cbGlobalForceReload.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalForceReloadStateChange) -# self.cbProxySettings.Bind(wx.EVT_CHECKBOX, self.OnCBProxySettingsStateChange) self.chDefaultChar.Disable() self.chDefaultChar.Show(False) self.stDefChar.Show(False) -# self.ToggleProxySettings(self.cbProxySettings.GetValue()) + self.chProxyType.Bind(wx.EVT_CHOICE, self.OnCHProxyTypeSelect) + self.editProxySettingsAddr.Bind(wx.EVT_TEXT, self.OnEditPSAddrText) + self.editProxySettingsPort.Bind(wx.EVT_TEXT, self.OnEditPSPortText) + + + self.btnApply.Bind(wx.EVT_BUTTON, self.OnBtnApply) + + self.UpdateApplyButtonState() + + if self.nMode is not 2: + self.ToggleProxySettings(False) + else: + self.ToggleProxySettings(True) panel.SetSizer( mainSizer ) panel.Layout() + def OnEditPSAddrText(self, event): + self.nAddr = self.editProxySettingsAddr.GetValue() + self.dirtySettings = True + self.UpdateApplyButtonState() + + def OnEditPSPortText(self, event): + self.nPort = self.editProxySettingsPort.GetValue() + self.dirtySettings = True + self.UpdateApplyButtonState() + + def OnBtnApply(self, event): + self.dirtySettings = False + self.UpdateApplyButtonState() + self.SaveSettings() + + def SaveSettings(self): + self.proxySettings.setMode(self.nMode) + self.proxySettings.setAddress(self.nAddr) + self.proxySettings.setPort(self.nPort) + self.proxySettings.setType(self.nType) + + def UpdateApplyButtonState(self): + if self.dirtySettings: + self.btnApply.Enable() + else: + self.btnApply.Disable() + + def OnCHProxyTypeSelect(self, event): + choice = self.chProxyType.GetSelection() + + self.nMode = choice + self.dirtySettings = True + + self.UpdateApplyButtonState() + + if choice is not 2: + self.ToggleProxySettings(False) + else: + self.ToggleProxySettings(True) + def ToggleProxySettings(self, mode): if mode: - self.chProxyType.Enable() - self.editProxySettings.Enable() + self.stPSetAddr.Enable() + self.editProxySettingsAddr.Enable() + self.stPSetPort.Enable() + self.editProxySettingsPort.Enable() else: - self.chProxyType.Disable() - self.editProxySettings.Disable() + self.stPSetAddr.Disable() + self.editProxySettingsAddr.Disable() + self.stPSetPort.Disable() + self.editProxySettingsPort.Disable() def OnCBProxySettingsStateChange(self, event): self.ToggleProxySettings(self.cbProxySettings.GetValue()) diff --git a/gui/preferenceDialog.py b/gui/preferenceDialog.py index 63be6f369..8127ad77f 100644 --- a/gui/preferenceDialog.py +++ b/gui/preferenceDialog.py @@ -37,7 +37,16 @@ class PreferenceDialog(wx.Dialog): self.imageList = wx.ImageList(64,64) self.listbook.SetImageList(self.imageList) - mainSizer.Add(self.listbook, 1, wx.EXPAND | wx.ALL, 5) + mainSizer.Add(self.listbook, 1, wx.EXPAND | wx.TOP|wx.BOTTOM|wx.LEFT, 5) + + self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) + mainSizer.Add( self.m_staticline2, 0, wx.EXPAND, 5 ) + + btnSizer = wx.BoxSizer( wx.HORIZONTAL ) + btnSizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 ) + self.btnOK = wx.Button( self, wx.ID_ANY, u"OK", wx.DefaultPosition, wx.DefaultSize, 0 ) + btnSizer.Add( self.btnOK, 0, wx.ALL, 5 ) + mainSizer.Add(btnSizer,0 , wx.EXPAND, 5) self.SetSizer(mainSizer) self.Centre(wx.BOTH) @@ -53,4 +62,9 @@ class PreferenceDialog(wx.Dialog): self.listbook.AddPage(page, title, imageId = imgID) self.Fit() - self.Layout() \ No newline at end of file + self.Layout() + + self.btnOK.Bind(wx.EVT_BUTTON, self.OnBtnOK) + + def OnBtnOK(self, event): + self.Destroy() \ No newline at end of file diff --git a/service/settings.py b/service/settings.py index 4a6428e43..d502dafef 100644 --- a/service/settings.py +++ b/service/settings.py @@ -104,3 +104,46 @@ class Settings(): def items(self): return self.info.items() + +class ProxySettings(): + _instance = None + @classmethod + def getInstance(cls): + if cls._instance == None: + cls._instance = ProxySettings() + + return cls._instance + + def __init__(self): + + # mode + # 0 - No proxy + # 1 - Auto-detected proxy settings + # 2 - Manual proxy settings + serviceProxyDefaultSettings = {"mode": 0, "type": "https", "address": "", "port": ""} + + self.serviceProxySettings = SettingsProvider.getInstance().getSettings("pyfaServiceProxySettings", serviceProxyDefaultSettings) + + def getMode(self): + return self.serviceProxySettings["mode"] + + def getAddress(self): + return self.serviceProxySettings["address"] + + def getPort(self): + return self.serviceProxySettings["port"] + + def getType(self): + return self.serviceProxySettings["type"] + + def setMode(self, mode): + self.serviceProxySettings["mode"] = mode + + def setAddress(self, addr): + self.serviceProxySettings["address"] = addr + + def setPort(self, port): + self.serviceProxySettings["port"] = port + + def setType(self, type): + self.serviceProxySettings["type"] = type \ No newline at end of file From ade951360ff909f9174803623b52855bf5693965 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 23 Dec 2011 20:17:36 +0200 Subject: [PATCH 07/17] Added proxy autodetection stuff to service.settings.ProxySettings --- .../pyfaGlobalPreferences.py | 24 +++-------------- service/settings.py | 26 ++++++++++++++++++- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py index b9b0f5647..45ac97509 100644 --- a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py @@ -123,29 +123,13 @@ class PFGlobalPref ( PreferenceView): mainSizer.Add(btnSizer, 0, wx.EXPAND,5) - proxy = None - proxAddr = proxPort = "" - proxydict = urllib2.ProxyHandler().proxies + proxy = self.proxySettings.autodetect() + txt = "Auto-detected: " - - validPrefixes = ("https", "http") - - for prefix in validPrefixes: - if not prefix in proxydict: - continue - proxyline = proxydict[prefix] - proto = "{0}://".format(prefix) - if proxyline[:len(proto)] == proto: - proxyline = proxyline[len(proto):] - proxAddr, proxPort = proxyline.split(":") - proxPort = int(proxPort.rstrip("/")) - proxy = (proxAddr, proxPort) - break - - if len(proxAddr) == 0: + if len(proxy) == 0: txt += "None" else: - txt += proto + proxAddr + ":" + str(proxPort) + txt += proxy self.stPSAutoDetected.SetLabel(txt) self.stPSAutoDetected.Disable() diff --git a/service/settings.py b/service/settings.py index d502dafef..ed1e170ab 100644 --- a/service/settings.py +++ b/service/settings.py @@ -20,6 +20,7 @@ import cPickle import os.path import config +import urllib2 class SettingsProvider(): BASE_PATH = os.path.join(config.savePath, "settings") @@ -146,4 +147,27 @@ class ProxySettings(): self.serviceProxySettings["port"] = port def setType(self, type): - self.serviceProxySettings["type"] = type \ No newline at end of file + self.serviceProxySettings["type"] = type + + def autodetect(self): + + proxy = None + proxAddr = proxPort = "" + proxydict = urllib2.ProxyHandler().proxies + txt = "Auto-detected: " + + validPrefixes = ("https", "http") + + for prefix in validPrefixes: + if not prefix in proxydict: + continue + proxyline = proxydict[prefix] + proto = "{0}://".format(prefix) + if proxyline[:len(proto)] == proto: + proxyline = proxyline[len(proto):] + proxAddr, proxPort = proxyline.split(":") + proxPort = proxPort.rstrip("/") + proxy = proto + proxAddr + proxPort + break + + return proxy \ No newline at end of file From 6b30eeaba13711b0b1ece97d3a614ec75601027f Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 23 Dec 2011 20:26:15 +0200 Subject: [PATCH 08/17] Make use of proxy settings in service.character api stuff --- .../pyfaGlobalPreferences.py | 7 +++---- service/character.py | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py index 45ac97509..2099de9a4 100644 --- a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py @@ -125,13 +125,12 @@ class PFGlobalPref ( PreferenceView): proxy = self.proxySettings.autodetect() - txt = "Auto-detected: " if len(proxy) == 0: - txt += "None" + txt = "None" else: - txt += proxy + txt = proxy - self.stPSAutoDetected.SetLabel(txt) + self.stPSAutoDetected.SetLabel("Auto-detected: " + txt) self.stPSAutoDetected.Disable() cChar = service.Character.getInstance() diff --git a/service/character.py b/service/character.py index 8bd63a6be..58965fee0 100644 --- a/service/character.py +++ b/service/character.py @@ -113,17 +113,28 @@ class Character(): char = eos.db.getCharacter(charID) return (char.apiID or "", char.apiKey or "") + def getProxySettings(self): + ps = service.settings.ProxySettings.getInstance() + if ps.getMode() == 0: + return None + elif ps.getMode() == 1: + return ps.autodetect() + elif ps.getMode == 2: + return ps.getAddress() + ps.getPort() + + def charList(self, charID, userID, apiKey): char = eos.db.getCharacter(charID) try: char.apiID = userID char.apiKey = apiKey - return char.apiCharList() + return char.apiCharList(proxy = self.getProxySettings()) except: return None def apiFetch(self, charID, charName): - char = eos.db.getCharacter(charID) + + char = eos.db.getCharacter(charID, proxy = self.getProxySettings()) char.apiFetch(charName) eos.db.commit() From 5d2519ec18870db9552b008499775dcc9d1060b1 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 23 Dec 2011 20:30:32 +0200 Subject: [PATCH 09/17] Fixed a little mistake in service.character.apiFetch --- service/character.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/service/character.py b/service/character.py index 58965fee0..18b2f0b83 100644 --- a/service/character.py +++ b/service/character.py @@ -133,9 +133,8 @@ class Character(): return None def apiFetch(self, charID, charName): - - char = eos.db.getCharacter(charID, proxy = self.getProxySettings()) - char.apiFetch(charName) + char = eos.db.getCharacter(charID) + char.apiFetch(charName, proxy = self.getProxySettings()) eos.db.commit() def changeLevel(self, charID, skillID, level): From 32f83a0d1b9706462067b0476fa04c9f844d4081 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 23 Dec 2011 20:44:38 +0200 Subject: [PATCH 10/17] Small fix in pyfaGlobalPreferences, proxy autodetection returns None if no proxy are available (from system settings) --- gui/builtinPreferenceViews/pyfaGlobalPreferences.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py index 2099de9a4..ff5440df2 100644 --- a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py @@ -125,10 +125,10 @@ class PFGlobalPref ( PreferenceView): proxy = self.proxySettings.autodetect() - if len(proxy) == 0: - txt = "None" - else: + if proxy: txt = proxy + else: + txt = "None" self.stPSAutoDetected.SetLabel("Auto-detected: " + txt) self.stPSAutoDetected.Disable() From fb46f742dde558b7e0b360258bfea1abd18a3354 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Fri, 23 Dec 2011 22:50:15 +0400 Subject: [PATCH 11/17] Add close button to damage pattern editor --- gui/patternEditor.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gui/patternEditor.py b/gui/patternEditor.py index d68ceb93b..8648afe1f 100644 --- a/gui/patternEditor.py +++ b/gui/patternEditor.py @@ -141,6 +141,11 @@ class DmgPatternEditorDlg (wx.Dialog): mainSizer.Add(contentSizer, 1, wx.EXPAND, 0) + if "wxGTK" in wx.PlatformInfo: + self.closeBtn = wx.Button( self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0 ) + mainSizer.Add( self.closeBtn, 0, wx.ALL|wx.ALIGN_RIGHT, 5 ) + self.closeBtn.Bind(wx.EVT_BUTTON, self.closeEvent) + self.SetSizer(mainSizer) importExport = (("Import", wx.ART_FILE_OPEN, "from"), @@ -192,6 +197,9 @@ class DmgPatternEditorDlg (wx.Dialog): self.patternChanged() + def closeEvent(self, event): + self.Destroy() + def ValuesUpdated(self, event=None): if self.block: return From c51a1400e12c9090ed65b039dcaee55926149282 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 23 Dec 2011 22:02:39 +0200 Subject: [PATCH 12/17] Fixed the the way proxy settings is sent to eveapi --- gui/builtinPreferenceViews/pyfaGlobalPreferences.py | 5 +++-- service/character.py | 6 +++--- service/settings.py | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py index ff5440df2..21f0330d3 100644 --- a/gui/builtinPreferenceViews/pyfaGlobalPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGlobalPreferences.py @@ -125,8 +125,9 @@ class PFGlobalPref ( PreferenceView): proxy = self.proxySettings.autodetect() - if proxy: - txt = proxy + if proxy is not None: + addr,port = proxy + txt = addr + ":" + str(port) else: txt = "None" diff --git a/service/character.py b/service/character.py index 18b2f0b83..59a80dbab 100644 --- a/service/character.py +++ b/service/character.py @@ -117,10 +117,10 @@ class Character(): ps = service.settings.ProxySettings.getInstance() if ps.getMode() == 0: return None - elif ps.getMode() == 1: + if ps.getMode() == 1: return ps.autodetect() - elif ps.getMode == 2: - return ps.getAddress() + ps.getPort() + if ps.getMode() == 2: + return (ps.getAddress(), int(ps.getPort())) def charList(self, charID, userID, apiKey): diff --git a/service/settings.py b/service/settings.py index ed1e170ab..420434597 100644 --- a/service/settings.py +++ b/service/settings.py @@ -156,7 +156,7 @@ class ProxySettings(): proxydict = urllib2.ProxyHandler().proxies txt = "Auto-detected: " - validPrefixes = ("https", "http") + validPrefixes = ("http", "https") for prefix in validPrefixes: if not prefix in proxydict: @@ -166,8 +166,8 @@ class ProxySettings(): if proxyline[:len(proto)] == proto: proxyline = proxyline[len(proto):] proxAddr, proxPort = proxyline.split(":") - proxPort = proxPort.rstrip("/") - proxy = proto + proxAddr + proxPort + proxPort = int(proxPort.rstrip("/")) + proxy = (proxAddr, proxPort) break return proxy \ No newline at end of file From 0a1ac49c978a8f34cabba6e3dc955c42eb737d68 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 23 Dec 2011 22:13:39 +0200 Subject: [PATCH 13/17] Moved getProxySettings from service.character to service.settings --- service/character.py | 14 ++------------ service/settings.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/service/character.py b/service/character.py index 59a80dbab..f97a1daa7 100644 --- a/service/character.py +++ b/service/character.py @@ -113,28 +113,18 @@ class Character(): char = eos.db.getCharacter(charID) return (char.apiID or "", char.apiKey or "") - def getProxySettings(self): - ps = service.settings.ProxySettings.getInstance() - if ps.getMode() == 0: - return None - if ps.getMode() == 1: - return ps.autodetect() - if ps.getMode() == 2: - return (ps.getAddress(), int(ps.getPort())) - - def charList(self, charID, userID, apiKey): char = eos.db.getCharacter(charID) try: char.apiID = userID char.apiKey = apiKey - return char.apiCharList(proxy = self.getProxySettings()) + return char.apiCharList(proxy = service.settings.ProxySettings.getInstance().getProxySettings()) except: return None def apiFetch(self, charID, charName): char = eos.db.getCharacter(charID) - char.apiFetch(charName, proxy = self.getProxySettings()) + char.apiFetch(charName, proxy = service.settings.ProxySettings.getInstance().getProxySettings()) eos.db.commit() def changeLevel(self, charID, skillID, level): diff --git a/service/settings.py b/service/settings.py index 420434597..066973b81 100644 --- a/service/settings.py +++ b/service/settings.py @@ -170,4 +170,13 @@ class ProxySettings(): proxy = (proxAddr, proxPort) break - return proxy \ No newline at end of file + return proxy + + def getProxySettings(self): + + if self.getMode() == 0: + return None + if self.getMode() == 1: + return ps.autodetect() + if self.getMode() == 2: + return (self.getAddress(), int(self.getPort())) \ No newline at end of file From 6452a563a9cfb3fbd7d79cfe7087ba6836afd62d Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 23 Dec 2011 22:19:12 +0200 Subject: [PATCH 14/17] Fixed a small oversight in settings.ProxySettings --- service/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/settings.py b/service/settings.py index 066973b81..47907baa1 100644 --- a/service/settings.py +++ b/service/settings.py @@ -177,6 +177,6 @@ class ProxySettings(): if self.getMode() == 0: return None if self.getMode() == 1: - return ps.autodetect() + return self.autodetect() if self.getMode() == 2: return (self.getAddress(), int(self.getPort())) \ No newline at end of file From 6036387b7b0439f3555345ebc15a6330a798781e Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sat, 24 Dec 2011 00:23:28 +0400 Subject: [PATCH 15/17] Update eos and direct price requests to proxy too --- eos | 2 +- service/market.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/eos b/eos index 2d9bb053e..7afaf9fb1 160000 --- a/eos +++ b/eos @@ -1 +1 @@ -Subproject commit 2d9bb053ea3f7d32a4321107ce0cbb28ef025f7a +Subproject commit 7afaf9fb119ef736cfea63a69c613889b7980058 diff --git a/service/market.py b/service/market.py index cb57232e2..e0677903e 100644 --- a/service/market.py +++ b/service/market.py @@ -26,7 +26,7 @@ import Queue import eos.db import eos.types -from service.settings import SettingsProvider +from service.settings import SettingsProvider, ProxySettings try: from collections import OrderedDict @@ -79,7 +79,11 @@ class PriceWorkerThread(threading.Thread): # Grab prices, this is the time-consuming part if len(requests) > 0: - eos.types.Price.fetchPrices(*requests) + proxy = ProxySettings.getInstance().getProxySettings() + if proxy is not None: + proxy = "{0}:{1}".format(*proxy) + print proxy + eos.types.Price.fetchPrices(requests, proxy=proxy) wx.CallAfter(callback) queue.task_done() From d81e11e64743043de12508612e2059c607e60fab Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sat, 24 Dec 2011 00:25:55 +0400 Subject: [PATCH 16/17] Remove debugging print --- service/market.py | 1 - 1 file changed, 1 deletion(-) diff --git a/service/market.py b/service/market.py index e0677903e..79917bd1d 100644 --- a/service/market.py +++ b/service/market.py @@ -82,7 +82,6 @@ class PriceWorkerThread(threading.Thread): proxy = ProxySettings.getInstance().getProxySettings() if proxy is not None: proxy = "{0}:{1}".format(*proxy) - print proxy eos.types.Price.fetchPrices(requests, proxy=proxy) wx.CallAfter(callback) From 74fe52eca495a6905617f80b4a1c754d5b9560a6 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sat, 24 Dec 2011 00:30:15 +0400 Subject: [PATCH 17/17] Bump pyfa version --- config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.py b/config.py index d5b293819..eb4652e1a 100644 --- a/config.py +++ b/config.py @@ -13,10 +13,10 @@ debug = False saveInRoot = False # Version data -version = "1.1" +version = "1.1.1" tag = "git" expansionName = "Crucible" -expansionVersion = "1.0" +expansionVersion = "1.0.3" pyfaPath = None savePath = None