BUGFIX : commit proper objects for release version
[wifihood] / wifiscanner / wifiscanner
index 341ad90..7fe9bc7 100755 (executable)
@@ -8,18 +8,18 @@ try :
 except :
     hildon = False
 
-def global_start(button, scanner):
-    scanner.start()
+def global_start(button, scanner, config):
+    scanner.start( int( 1000 * config.scan_period ) , config.store_log )
     if button._id :
         button.disconnect( button._id )
-    button._id = button.connect("clicked", global_stop, scanner)
+    button._id = button.connect("clicked", global_stop, scanner, config)
     button.set_label("Switch GPS Off")
 
-def global_stop(button, scanner):
+def global_stop(button, scanner, config):
     scanner.stop()
     if button._id :
         button.disconnect( button._id )
-    button._id = button.connect("clicked", global_start, scanner)
+    button._id = button.connect("clicked", global_start, scanner, config)
     button.set_label("Switch GPS On")
 
 def enable_agps(button):
@@ -59,7 +59,14 @@ class scanner ( wifimap.Scanner ) :
             self.map.hide()
             self.map.recenter( self.info[4:6] )
             pixmap,mask = self.map.get_pixbuf().render_pixmap_and_mask()
-            self.map.plot( pixmap , ( float(self.info[4]) , float(self.info[5]) ) , "red" , 2 )
+            pointsize = 2
+            if self.newaps :
+                pointsize += 2
+            self.map.plot( pixmap , ( float(self.info[4]) , float(self.info[5]) ) , "red" , pointsize )
+            for mac,ap in self.aps.iteritems() :
+                if self.oldpos.get( mac ) :
+                    self.map.line( pixmap , self.oldpos[mac] , ( ap[1]/ap[0] , ap[2]/ap[0] ) , "green" )
+                self.map.plot( pixmap , ( ap[1]/ap[0] , ap[2]/ap[0] ) , "green" , 2 )
             self.map.get_pixbuf().get_from_drawable( pixmap , pixmap.get_colormap() , 0, 0 , 0 , 0 , self.map.win_x, self.map.win_y )
             self.map.show()
 
@@ -68,7 +75,8 @@ class AbstractWifiscanner :
 
     def __init__ ( self ) :
 
-        _scanner = scanner( "wlan0" )
+        config = wifimap.config.Configuration( 'scanner' )
+        _scanner = scanner( config , "wlan0" )
 
         self.connect("delete_event", gtk.main_quit, None)
 
@@ -95,7 +103,7 @@ class AbstractWifiscanner :
 
         scrollview = gtk.ScrolledWindow()
         notebook.append_page( scrollview , gtk.Label("Scanning") )
-        self.map = MapWindow()
+        self.map = MapWindow( config )
         notebook.append_page( self.map , gtk.Label("Map") )
 
         buttons = gtk.VBox(homogeneous=False, spacing=0)
@@ -107,7 +115,7 @@ class AbstractWifiscanner :
 
         # Buttons creation
         button = self.Button( "Switch GPS On")
-        button._id = button.connect("clicked", global_start, _scanner)
+        button._id = button.connect("clicked", global_start, _scanner, config)
         buttons.pack_start(button, expand=False)
 
         button_scan = self.Button( "Start scanning")
@@ -137,10 +145,9 @@ if hildon :
     class MapWindow ( gtk.Frame ) :
 
         def __init__(self):
-            gtk.Frame.__init__( self )
+            gtk.Frame.__init__( self , config )
 
-            self.config = wifimap.config.Configuration()
-            self.config.zoom = 16
+            self.config = config
             self.add( wifimap.simpleMapWidget( self.config ) )
 
     class Wifiscanner ( AbstractWifiscanner , hildon.StackableWindow ) :
@@ -196,10 +203,9 @@ else :
     class MapWindow ( gtk.Frame ) :
 
         def __init__(self):
-            gtk.Frame.__init__( self )
+            gtk.Frame.__init__( self , config )
 
-            self.config = wifimap.config.Configuration()
-            self.config.zoom = 16
+            self.config = config
             self.add( wifimap.simpleMapWidget( self.config , (640,400) ) )
 
     class Wifiscanner ( AbstractWifiscanner , gtk.Window ) :