[tor-commits] r24596: {arm} Hack to allow the descriptor popup to function for the new c (arm/trunk/src/interface)

Damian Johnson atagar1 at gmail.com
Tue Apr 12 16:40:26 UTC 2011


Author: atagar
Date: 2011-04-12 16:40:25 +0000 (Tue, 12 Apr 2011)
New Revision: 24596

Modified:
   arm/trunk/src/interface/controller.py
   arm/trunk/src/interface/descriptorPopup.py
Log:
Hack to allow the descriptor popup to function for the new connection panel. This will probably be dropped when raw control port access is introduced.

This was the last piece of important partiy between the panels so the old connection panel can now be dropped from the codebase. I'll first wait a little first to see if any other uses for it pop up.



Modified: arm/trunk/src/interface/controller.py
===================================================================
--- arm/trunk/src/interface/controller.py	2011-04-12 16:19:31 UTC (rev 24595)
+++ arm/trunk/src/interface/controller.py	2011-04-12 16:40:25 UTC (rev 24596)
@@ -1007,7 +1007,7 @@
           popup.addfstr(2, 41, "<b>page down</b>: scroll down a page")
           
           popup.addfstr(3, 2, "<b>enter</b>: edit configuration option")
-          #popup.addfstr(3, 41, "<b>d</b>: raw consensus descriptor")
+          popup.addfstr(3, 41, "<b>d</b>: raw consensus descriptor")
           
           listingType = panels["conn2"]._listingType.lower()
           popup.addfstr(4, 2, "<b>l</b>: listed identity (<b>%s</b>)" % listingType)
@@ -1016,9 +1016,9 @@
           
           resolverUtil = connections.getResolver("tor").overwriteResolver
           if resolverUtil == None: resolverUtil = "auto"
-          popup.addfstr(3, 41, "<b>u</b>: resolving utility (<b>%s</b>)" % resolverUtil)
+          popup.addfstr(5, 2, "<b>u</b>: resolving utility (<b>%s</b>)" % resolverUtil)
           
-          pageOverrideKeys = (ord('l'), ord('s'), ord('u'))
+          pageOverrideKeys = (ord('d'), ord('l'), ord('s'), ord('u'))
         elif page == 3:
           popup.addfstr(1, 2, "<b>up arrow</b>: scroll up a line")
           popup.addfstr(1, 41, "<b>down arrow</b>: scroll down a line")
@@ -1611,6 +1611,23 @@
         setPauseState(panels, isPaused, page)
       finally:
         panel.CURSES_LOCK.release()
+    elif page == 2 and key in (ord('d'), ord('D')):
+      # presents popup for raw consensus data
+      panel.CURSES_LOCK.acquire()
+      try:
+        setPauseState(panels, isPaused, page, True)
+        curses.cbreak() # wait indefinitely for key presses (no timeout)
+        panelTitle = panels["conn2"]._title
+        panels["conn2"]._title = ""
+        panels["conn2"].redraw(True)
+        
+        descriptorPopup.showDescriptorPopup(panels["popup"], stdscr, panels["conn2"], True)
+        
+        panels["conn2"]._title = panelTitle
+        setPauseState(panels, isPaused, page)
+        curses.halfdelay(REFRESH_RATE * 10) # reset normal pausing behavior
+      finally:
+        panel.CURSES_LOCK.release()
     elif page == 2 and (key == ord('l') or key == ord('L')):
       # provides a menu to pick the primary information we list connections by
       options = interface.connections.entries.ListingType.values()

Modified: arm/trunk/src/interface/descriptorPopup.py
===================================================================
--- arm/trunk/src/interface/descriptorPopup.py	2011-04-12 16:19:31 UTC (rev 24595)
+++ arm/trunk/src/interface/descriptorPopup.py	2011-04-12 16:40:25 UTC (rev 24596)
@@ -9,6 +9,7 @@
 
 import controller
 import connPanel
+import connections.connEntry
 from util import panel, torTools, uiTools
 
 # field keywords used to identify areas for coloring
@@ -68,7 +69,7 @@
     elif key == curses.KEY_PPAGE: self.scroll = max(self.scroll - height, 0)
     elif key == curses.KEY_NPAGE: self.scroll = max(0, min(self.scroll + height, len(self.text) - height))
 
-def showDescriptorPopup(popup, stdscr, connectionPanel):
+def showDescriptorPopup(popup, stdscr, connectionPanel, isNewPanel=False):
   """
   Presents consensus descriptor in popup window with the following controls:
   Up, Down, Page Up, Page Down - scroll descriptor
@@ -82,11 +83,18 @@
   if not panel.CURSES_LOCK.acquire(False): return
   try:
     while isVisible:
-      selection = connectionPanel.cursorSelection
-      if not selection or not connectionPanel.connections: break
-      fingerprint = connectionPanel.getFingerprint(selection[connPanel.CONN_F_IP], selection[connPanel.CONN_F_PORT])
-      entryColor = connPanel.TYPE_COLORS[selection[connPanel.CONN_TYPE]]
-      properties.reset(fingerprint, entryColor)
+      if isNewPanel:
+        selection = connectionPanel._scroller.getCursorSelection(connectionPanel._entryLines)
+        if not selection: break
+        fingerprint = selection.foreign.getFingerprint()
+        entryColor = connections.connEntry.CATEGORY_COLOR[selection.getType()]
+        properties.reset(fingerprint, entryColor)
+      else:
+        selection = connectionPanel.cursorSelection
+        if not selection or not connectionPanel.connections: break
+        fingerprint = connectionPanel.getFingerprint(selection[connPanel.CONN_F_IP], selection[connPanel.CONN_F_PORT])
+        entryColor = connPanel.TYPE_COLORS[selection[connPanel.CONN_TYPE]]
+        properties.reset(fingerprint, entryColor)
       
       # constrains popup size to match text
       width, height = 0, 0



More information about the tor-commits mailing list