Include a configuration setting to specify the interval among wireless scans
authorjaviplx <javiplx@gmail.com>
Mon, 9 May 2011 22:29:52 +0000 (22:29 +0000)
committerjaviplx <javiplx@gmail.com>
Mon, 9 May 2011 22:29:52 +0000 (22:29 +0000)
git-svn-id: file:///svnroot/wifihood/trunk@152 c51dfc6a-5949-4919-9c8e-f207a149c383

wifiscanner/wifimap/config.py
wifiscanner/wifiscanner

index 5b60f14..45afae4 100644 (file)
@@ -18,6 +18,8 @@ class Configuration :
         self.mapsdir = self._client.get_string( "/apps/wifihood/maps" ) or "/home/user/MyDocs/.maps"
         self.mapclass = self._client.get_string( "/apps/wifihood/maptype" ) or "OpenStreetMap I"
 
+        self.scan_period = self._client.get_int( "/apps/wifihood/scan-period" ) or 5000
+
         self.store_log = self._client.get_bool( "/apps/wifihood/store-logfile" )
 
         self.use_mapper = self._client.get_bool( "/apps/wifihood/use-mapper" )
@@ -150,18 +152,35 @@ class AbstractSettingsWindow :
         dataframe.show()
         vbox.pack_start(dataframe, True, True, 0)
 
+        datatable = gtk.Table(2, 2, False)
+        datatable.show()
+        dataframe.add(datatable)
+
+        scanlabel = gtk.Label( "Scanning interval" )
+        scanlabel.show()
+        datatable.attach(scanlabel, 0, 1, 0, 1, gtk.EXPAND|gtk.FILL)
+
+        scanvalue = self.Entry()
+        scanvalue.connect( "changed" , self.int_cb , config , "scan-period" , 1000 )
+        scanvalue.set_text( "%s" % ( float(config.scan_period) / 1000 ) )
+        scanvalue.show()
+        datatable.attach(scanvalue, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL)
+
         button = self.CheckButton()
         button.set_label( "Write full logfile" )
         button.connect( "toggled" , self.checkbutton_cb , config , "store-logfile" )
         button.set_active( config.store_log )
         button.show()
-        dataframe.add(button)
+        datatable.attach(button, 0, 2, 1, 2, gtk.EXPAND|gtk.FILL)
 
         self.show()
 
     def entry_cb ( self , entry , config , keyword ) :
         config._client.set_string( "%s/%s" % ( "/apps/wifihood" , keyword ) , entry.get_text() )
 
+    def int_cb ( self , entry , config , keyword , scale=1 ) :
+        config._client.set_int( "%s/%s" % ( "/apps/wifihood" , keyword ) , int( scale * float( entry.get_text() ) ) )
+
     def checkbutton_cb ( self , button , config , keyword ) :
         config._client.set_bool( "%s/%s" % ( "/apps/wifihood" , keyword ) , button.get_active() )
 
index 42e12e6..424c3f4 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() :
@@ -107,7 +107,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")