[tor-commits] [arm/release] 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.

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


commit 97789357dea31bfee8843da1410b9820623fbdbc
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Apr 12 16:40:25 2011 +0000

    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.
    
    
    
    svn:r24596
---
 src/interface/controller.py      |   23 ++++++++++++++++++++---
 src/interface/descriptorPopup.py |   20 ++++++++++++++------
 2 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/src/interface/controller.py b/src/interface/controller.py
index 167be0a..8be65c7 100644
--- a/src/interface/controller.py
+++ b/src/interface/controller.py
@@ -1007,7 +1007,7 @@ def drawTorMonitor(stdscr, startTime, loggedEvents, isBlindMode):
           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 @@ def drawTorMonitor(stdscr, startTime, loggedEvents, isBlindMode):
           
           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 @@ def drawTorMonitor(stdscr, startTime, loggedEvents, isBlindMode):
         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()
diff --git a/src/interface/descriptorPopup.py b/src/interface/descriptorPopup.py
index 51ea2e3..7d51ee5 100644
--- a/src/interface/descriptorPopup.py
+++ b/src/interface/descriptorPopup.py
@@ -9,6 +9,7 @@ from TorCtl import TorCtl
 
 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 @@ class PopupProperties:
     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 @@ def showDescriptorPopup(popup, stdscr, connectionPanel):
   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