Added gconf facility
authorjaviplx <javiplx@gmail.com>
Sun, 10 Oct 2010 10:33:44 +0000 (10:33 +0000)
committerjaviplx <javiplx@gmail.com>
Sun, 10 Oct 2010 10:33:44 +0000 (10:33 +0000)
git-svn-id: file:///svnroot/wifihood/trunk/wifiscanner@33 c51dfc6a-5949-4919-9c8e-f207a149c383

MANIFEST
wifimap/__init__.py
wifimap/config.py [new file with mode: 0644]
wifimap/wifiscan.py

index 8de51db..5a61b67 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -6,3 +6,5 @@ wifiview.desktop
 wifimap/__init__.py
 wifimap/gps.py
 wifimap/wifiscan.py
+wifimap/db.py
+wifimap/config.py
index aa7a6b8..3f6a473 100644 (file)
@@ -1,7 +1,11 @@
 
-from gps import *
+__all__ = [ 'config' , 'db' , 'gps' , 'wifiscan' ]
 
-from wifiscan import *
+from config import *
 
 from db import *
 
+from gps import *
+
+from wifiscan import *
+
diff --git a/wifimap/config.py b/wifimap/config.py
new file mode 100644 (file)
index 0000000..6279396
--- /dev/null
@@ -0,0 +1,21 @@
+
+import gconf
+
+class Configuration :
+
+    def __init__ ( self ) :
+        self.homedir = None
+        self.dbname = None
+        self.read()
+
+    def read ( self ) :
+        client = gconf.client_get_default()
+        self.homedir = client.get_string( "/apps/wifihood/basedir" )
+        self.dbname = client.get_string( "/apps/wifihood/dbname" )
+
+    def save ( self ) :
+        client = gconf.client_get_default()
+        client.set_string( "/apps/wifihood/basedir" , self.homedir )
+        client.set_string( "/apps/wifihood/dbname" , self.dbname )
+
+
index f6e8ff6..83acfd7 100644 (file)
@@ -3,12 +3,13 @@ import osso
 
 import time
 
-import gps , db
+import config , db , gps
 
 import gobject
 
 import os
-home_dir = "/home/user/MyDocs"
+
+conf = config.Configuration()
 
 class Scanner ( gps.GPSObject ) :
 
@@ -22,7 +23,7 @@ class Scanner ( gps.GPSObject ) :
         self.nfp = 0
         self.scanlist = None
         self.aplist = {}
-        self.db = db.database( os.path.join( home_dir , "wifiscanner.db" ) )
+        self.db = db.database( os.path.join( conf.homedir , conf.dbname ) )
 
     def start ( self ) :
         osso_rpc = osso.Rpc(self.osso_context)
@@ -68,15 +69,15 @@ class Scanner ( gps.GPSObject ) :
             osso.SystemNote(self.osso_context).system_note_infoprint("Found %d APs" % len(scan_out) )
         #    hildon.hildon_banner_show_information( self._parent , "icon_path" , "Found %d APs" % len(scan_out) )
         else :
-            fd = open( os.path.join( home_dir , "wiscan_gui.info" ) , 'a' )
+            fd = open( os.path.join( conf.homedir , "wiscan_gui.info" ) , 'a' )
             fd.write( "%s %s%s\n" % ( timestamp , self.gps_info , out_str ) )
             fd.close()
             if self.satellites :
-                loclist = open( os.path.join( home_dir , "location.info" ) , 'a' )
+                loclist = open( os.path.join( conf.homedir , "location.info" ) , 'a' )
                 loclist.write ( "%s\n" % ( self.satellites ,) )
                 loclist.close()
             if self.cell_info :
-                celllist = open( os.path.join( home_dir , "cell.info" ) , 'a' )
+                celllist = open( os.path.join( conf.homedir , "cell.info" ) , 'a' )
                 celllist.write ( "%s\n" % ( self.cell_info ,) )
                 celllist.close()