Use a single Configuration instance alog all the code
authorjaviplx <javiplx@gmail.com>
Sat, 14 May 2011 18:06:31 +0000 (18:06 +0000)
committerjaviplx <javiplx@gmail.com>
Sat, 14 May 2011 18:06:31 +0000 (18:06 +0000)
git-svn-id: file:///svnroot/wifihood/trunk@170 c51dfc6a-5949-4919-9c8e-f207a149c383

wifiscanner/wifimap/replay.py
wifiscanner/wifimap/scanner.py
wifiscanner/wifiscanner

index 6a1b1fd..0d2c712 100644 (file)
@@ -1,5 +1,4 @@
 
-import config
 import db
 
 import gobject
@@ -8,10 +7,9 @@ import os
 
 class ReplayScanner ( gobject.GObject ) :
 
-    def __init__ ( self , ifname="wlan0" ) :
+    def __init__ ( self , conf , ifname="wlan0" ) :
         gobject.GObject.__init__( self )
         self.scan_timeout = 0
-        conf = config.Configuration( 'scanner' )
         self.db = db.database( os.path.join( conf.homedir , "wifireplay.db" ) )
 
         # Values specific to replaying
index 984e667..423f203 100644 (file)
@@ -6,7 +6,7 @@ except :
 
 import time
 
-import config , db
+import db
 import gps , wifiscan
 
 import gobject
@@ -15,12 +15,11 @@ import os
 
 class Scanner ( gps.GPSObject , wifiscan.WifiScanner ) :
 
-    def __init__ ( self , ifname="wlan0" ) :
+    def __init__ ( self , conf , ifname="wlan0" ) :
         gps.GPSObject.__init__( self )
         wifiscan.WifiScanner.__init__( self , ifname )
-        conf = config.Configuration( 'scanner' )
+        self.db = db.database( os.path.join( conf.homedir , conf.dbname ) )
         self.homedir = conf.homedir
-        self.db = db.database( os.path.join( self.homedir , conf.dbname ) )
 
         self.write = False
 
index 1f39e3d..ed0adc2 100755 (executable)
@@ -75,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)
 
@@ -102,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)
@@ -114,7 +115,7 @@ class AbstractWifiscanner :
 
         # Buttons creation
         button = self.Button( "Switch GPS On")
-        button._id = button.connect("clicked", global_start, _scanner, self.map.config)
+        button._id = button.connect("clicked", global_start, _scanner, config)
         buttons.pack_start(button, expand=False)
 
         button_scan = self.Button( "Start scanning")
@@ -144,9 +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( 'scanner' )
+            self.config = config
             self.add( wifimap.simpleMapWidget( self.config ) )
 
     class Wifiscanner ( AbstractWifiscanner , hildon.StackableWindow ) :
@@ -202,9 +203,9 @@ else :
     class MapWindow ( gtk.Frame ) :
 
         def __init__(self):
-            gtk.Frame.__init__( self )
+            gtk.Frame.__init__( self , config )
 
-            self.config = wifimap.config.Configuration( 'scanner' )
+            self.config = config
             self.add( wifimap.simpleMapWidget( self.config , (640,400) ) )
 
     class Wifiscanner ( AbstractWifiscanner , gtk.Window ) :