[tor-commits] [arm/release] fix: config panel handling for reattachment

atagar at torproject.org atagar at torproject.org
Sun Jul 17 06:08:27 UTC 2011


commit 487c6effbecc0e6415aa865547acce58f13e9c56
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Jun 19 14:14:55 2011 -0700

    fix: config panel handling for reattachment
    
    When arm's connected to a new tor instance the current config options are
    replaced with those of the new instance. This addresses a couple issues we
    previously had...
    
    1. if arm was initially detached then when connected to an instance the config
    panel would still be blank
    2. if tor was shut down and we were then reattached to a different version
    (with different config options) we'd still display the old set
---
 src/cli/configPanel.py |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/cli/configPanel.py b/src/cli/configPanel.py
index 913bc39..33cec34 100644
--- a/src/cli/configPanel.py
+++ b/src/cli/configPanel.py
@@ -190,6 +190,7 @@ class ConfigPanel(panel.Panel):
     
     self.configType = configType
     self.confContents = []
+    self.confImportantContents = []
     self.scroller = uiTools.Scroller(True)
     self.valsLock = threading.RLock()
     
@@ -197,6 +198,28 @@ class ConfigPanel(panel.Panel):
     # the 'important' flag are shown
     self.showAll = False
     
+    # initializes config contents if we're connected
+    conn = torTools.getConn()
+    conn.addStatusListener(self.resetListener)
+    
+    if conn.isAlive():
+      self.resetListener(conn, torTools.State.INIT)
+  
+  def resetListener(self, conn, eventType):
+    # fetches configuration options if a new instance, otherewise keeps our
+    # current contents
+    
+    if eventType == torTools.State.INIT:
+      self._loadConfigOptions()
+  
+  def _loadConfigOptions(self):
+    """
+    Fetches the configuration options available from tor or arm.
+    """
+    
+    self.confContents = []
+    self.confImportantContents = []
+    
     if self.configType == State.TOR:
       conn, configOptionLines = torTools.getConn(), []
       customOptions = torConfig.getCustomOptions()





More information about the tor-commits mailing list