Initial implementation of AP positions update
[wifihood] / wifiscanner / wifiscanner
index f6e9253..f1fe5e4 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( config.scan_period )
     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):
@@ -43,14 +43,14 @@ def stop_scan(button, scanner):
     button.set_label("Start scanning")
 
 
-class scanner ( wifimap.Scanner ) :
+class scanner ( wifimap.ReplayScanner ) :
 
     def scan ( self ) :
-        wifimap.Scanner.scan( self )
+        wifimap.ReplayScanner.scan( self )
         self.report()
 
     def report ( self ) :
-        self.status.set_label( wifimap.Scanner.report(self) )
+        self.status.set_label( wifimap.ReplayScanner.report(self) )
         start, end = self.buffer.get_bounds()
         self.buffer.delete( start , end )
         for mac,rss in self.scanlist.iteritems() :
@@ -59,7 +59,12 @@ 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 )
+            while self.aps :
+                self.map.plot( pixmap , self.aps.pop() , "green" , 1 )
             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()
 
@@ -107,7 +112,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, self.map.config)
         buttons.pack_start(button, expand=False)
 
         button_scan = self.Button( "Start scanning")
@@ -122,14 +127,14 @@ class AbstractWifiscanner :
         status = gtk.Label( "status bar ..." )
         _scanner.status = status
         _scanner.buffer = textview.get_buffer() 
-        _scanner.map = self.map
+        _scanner.map = self.map.child
         bottom_box.pack_start( status , expand=False , padding=20 )
 
     def run ( self ) :
         gtk.main()
 
-def settings_cb ( widget , config ) :
-    wifimap.config.SettingsWindow( config )
+def settings_cb ( widget , map ) :
+    window = wifimap.config.SettingsWindow( map.config , map.child.SetZoom )
 
 
 if hildon :
@@ -139,8 +144,7 @@ if hildon :
         def __init__(self):
             gtk.Frame.__init__( self )
 
-            self.config = wifimap.config.Configuration()
-            self.config.zoom = 16
+            self.config = wifimap.config.Configuration( 'scanner' )
             self.add( wifimap.simpleMapWidget( self.config ) )
 
     class Wifiscanner ( AbstractWifiscanner , hildon.StackableWindow ) :
@@ -186,7 +190,7 @@ if hildon :
                                      hildon.BUTTON_ARRANGEMENT_VERTICAL,
                                      "Settings",
                                      None)
-            settings.connect( "clicked", settings_cb , self.map.config )
+            settings.connect( "clicked", settings_cb , self.map )
             menubar.append( settings )
 
             menubar.show_all()
@@ -198,8 +202,7 @@ else :
         def __init__(self):
             gtk.Frame.__init__( self )
 
-            self.config = wifimap.config.Configuration()
-            self.config.zoom = 16
+            self.config = wifimap.config.Configuration( 'scanner' )
             self.add( wifimap.simpleMapWidget( self.config , (640,400) ) )
 
     class Wifiscanner ( AbstractWifiscanner , gtk.Window ) :
@@ -240,7 +243,7 @@ else :
             self.vbox.pack_start( menubar )
 
             settings = gtk.MenuItem( "Settings" )
-            settings.connect( "activate", settings_cb , self.map.config )
+            settings.connect( "activate", settings_cb , self.map )
             menubar.append( settings )
 
             menubar.show_all()