From 4afda6641d41a1f02cc5d707e140d410106e4750 Mon Sep 17 00:00:00 2001 From: javiplx Date: Mon, 9 May 2011 22:29:52 +0000 Subject: [PATCH] Include a configuration setting to specify the interval among wireless scans git-svn-id: file:///svnroot/wifihood/trunk@152 c51dfc6a-5949-4919-9c8e-f207a149c383 --- wifiscanner/wifimap/config.py | 21 ++++++++++++++++++++- wifiscanner/wifiscanner | 18 +++++++++--------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/wifiscanner/wifimap/config.py b/wifiscanner/wifimap/config.py index 5b60f14..45afae4 100644 --- a/wifiscanner/wifimap/config.py +++ b/wifiscanner/wifimap/config.py @@ -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() ) diff --git a/wifiscanner/wifiscanner b/wifiscanner/wifiscanner index 42e12e6..424c3f4 100755 --- a/wifiscanner/wifiscanner +++ b/wifiscanner/wifiscanner @@ -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") -- 1.7.9.5