Implement status bar and fix layout issues
[wifihood] / wifimap / wifiscan.py
index 574582e..b278d4c 100644 (file)
@@ -15,6 +15,9 @@ class Scanner ( gps.GPSObject ) :
         osso_rpc = osso.Rpc(self.osso_context)
         scan_out = osso_rpc.rpc_run("org.javiplx.wifiscan", "/org/javiplx/wifiscan", "org.javiplx.wifiscan", "wakeup", wait_reply = True)
         self._timer = None
+        self.nscan = 0
+        self.nfp = 0
+        self.aplist = {}
 
     def start ( self ) :
         osso_rpc = osso.Rpc(self.osso_context)
@@ -28,13 +31,17 @@ class Scanner ( gps.GPSObject ) :
         osso_rpc = osso.Rpc(self.osso_context)
         try :
             scan_out = osso_rpc.rpc_run("org.javiplx.wifiscan", "/org/javiplx/wifiscan", "org.javiplx.wifiscan", "scan", wait_reply = True)
+            self.nscan +=1
         except Exception , ex :
             osso.SystemNote(self.osso_context).system_note_infoprint("Exception scanning %s" % ex )
             return True
         out_str = ""
         for net in scan_out.split() :
+            self.nfp += 1
             items = net.rsplit(":", 1)
             out_str += " %s %s" % ( items[0] , items[1] )
+            self.aplist[ items[0] ] = 1
+        self.refresh_infowin()
         if self._debug :
         # Use osso or hildon for notes ???
             osso.SystemNote(self.osso_context).system_note_infoprint("Found %d APs" % len(scan_out) )
@@ -54,6 +61,9 @@ class Scanner ( gps.GPSObject ) :
 
         return True
 
+    def refresh_infowin ( self ) :
+        self.status.set_label( "%d gps\t%d scan\t%d fp\t%d ap" % ( self.ngps , self.nscan , self.nfp , len(self.aplist.keys()) ) )
+
 
 gobject.type_register(Scanner)