[tor-commits] [arm/release] Initial commit for GUI connection listing.

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


commit 05a369b15000e76fbc4cc03bc102786ac0247225
Author: Kamran Riaz Khan <krkhan at inspirated.com>
Date:   Tue Jul 5 15:25:27 2011 +0500

    Initial commit for GUI connection listing.
    
    Currently derives from the CLI conn panel and lists rudimentary
    (unstructured) information about circuits for debugging.
---
 src/gui/arm.xml                  |   25 +----------------
 src/gui/connections/__init__.py  |    6 ++++
 src/gui/connections/connPanel.py |   56 ++++++++++++++++++++++++++++++++++++++
 src/gui/controller.py            |    5 +++
 4 files changed, 68 insertions(+), 24 deletions(-)

diff --git a/src/gui/arm.xml b/src/gui/arm.xml
index 1e3681c..dca5f33 100644
--- a/src/gui/arm.xml
+++ b/src/gui/arm.xml
@@ -72,29 +72,6 @@
       <!-- column-name foreground -->
       <column type="gchararray"/>
     </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">115.167.31.237:56835</col>
-        <col id="1" translatable="yes">188.120.245.249:9001 (ru)</col>
-        <col id="2" translatable="yes">10.7m</col>
-        <col id="3" translatable="yes">CLIENT</col>
-        <col id="4" translatable="yes">blue</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">115.167.31.237:44940</col>
-        <col id="1" translatable="yes">206.217.215.183:53 (us)</col>
-        <col id="2" translatable="yes">28.3m</col>
-        <col id="3" translatable="yes">CLIENT</col>
-        <col id="4" translatable="yes">blue</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">127.0.0.1:9051</col>
-        <col id="1" translatable="yes">127.0.0.1:51665</col>
-        <col id="2" translatable="yes">30.0m</col>
-        <col id="3" translatable="yes">CONTROL</col>
-        <col id="4" translatable="yes">red</col>
-      </row>
-    </data>
   </object>
   <object class="GtkListStore" id="liststore_config">
     <columns>
@@ -437,7 +414,7 @@
                         <child>
                           <object class="GtkLabel" id="label_conn_top">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">2 Clients, 1 Control</property>
+                            <property name="label" translatable="yes">Connections:</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
diff --git a/src/gui/connections/__init__.py b/src/gui/connections/__init__.py
new file mode 100644
index 0000000..3102ead
--- /dev/null
+++ b/src/gui/connections/__init__.py
@@ -0,0 +1,6 @@
+"""
+Connections.
+"""
+
+__all__ = ["connPanel"]
+
diff --git a/src/gui/connections/connPanel.py b/src/gui/connections/connPanel.py
new file mode 100644
index 0000000..cbabc41
--- /dev/null
+++ b/src/gui/connections/connPanel.py
@@ -0,0 +1,56 @@
+"""
+Connections panel.
+"""
+
+import random
+import sys
+import time
+
+from collections import deque
+
+import gobject
+import gtk
+
+from cli.connections import connEntry
+from cli.connections.connPanel import ConnectionPanel as CliConnectionPanel
+from TorCtl import TorCtl
+from util import connections, uiTools, torTools
+
+REFRESH_RATE = 3
+
+class ConnectionPanel(CliConnectionPanel):
+  def __init__(self, builder):
+    CliConnectionPanel.__init__(self, None)
+
+    self.builder = builder
+
+    self.resolver = connections.getResolver('tor')
+
+    gobject.timeout_add(3000, self._fill_entries)
+
+  def pack_widgets(self):
+    pass
+
+  def _fill_entries(self):
+    self.valsLock.acquire()
+
+    label = self.builder.get_object('label_conn_top')
+    label.set_text(self._title)
+
+    liststore = self.builder.get_object('liststore_conn')
+    liststore.clear()
+
+    for line in self._entryLines:
+      if isinstance(line, connEntry.ConnectionLine) and line.isUnresolvedApp():
+        self._resolveApps()
+
+      local = "%s:%s" % (line.local.ipAddr, line.local.port)
+      foreign = "%s:%s" % (line.foreign.ipAddr, line.foreign.port)
+      timeLabel = "%d s" % (time.time() - line.startTime)
+      row = (local, foreign, timeLabel, line.baseType, 'black')
+      liststore.append(row)
+
+    self.valsLock.release()
+
+    return True
+
diff --git a/src/gui/controller.py b/src/gui/controller.py
index 5f1712c..a69fdef 100644
--- a/src/gui/controller.py
+++ b/src/gui/controller.py
@@ -5,6 +5,7 @@ import thread
 import time
 
 from util import log, torTools
+from connections import connPanel
 from gui import logPanel
 from gui.graphing import bandwidthStats
 
@@ -24,6 +25,10 @@ class GuiController:
     self.bwStats = bandwidthStats.BandwidthStats(self.builder)
     self.bwStats.pack_widgets()
 
+    self.connPanel = connPanel.ConnectionPanel(self.builder)
+    self.connPanel.pack_widgets()
+    self.connPanel.start()
+
   def run(self):
     window = self.builder.get_object('window_main')
 





More information about the tor-commits mailing list