Perform some cleanup
authorjaviplx <javiplx@gmail.com>
Fri, 29 Apr 2011 22:30:41 +0000 (22:30 +0000)
committerjaviplx <javiplx@gmail.com>
Fri, 29 Apr 2011 22:30:41 +0000 (22:30 +0000)
git-svn-id: file:///svnroot/wifihood/trunk@83 c51dfc6a-5949-4919-9c8e-f207a149c383

wifiscanner/wifimap/db.py
wifiscanner/wifimap/gps.py
wifiscanner/wifimap/osso_wrapper.py

index 31e7ec6..92fd45b 100644 (file)
@@ -1,8 +1,6 @@
 
 import sqlite3
 
-import config
-
 create_db = """
     CREATE TABLE ap (
         mac TEXT PRIMARY KEY UNIQUE NOT NULL,
@@ -20,12 +18,9 @@ create_db = """
 
 class database :
 
-    def __init__ ( self , dbname=None ) :
-        self.setfilename( dbname )
-        self.db = None
-
-    def setfilename ( self , dbname ) :
+    def __init__ ( self , dbname ) :
         self.dbname = dbname
+        self.db = None
 
     def open ( self ) :
 
index 409400c..e83e7b1 100644 (file)
@@ -2,10 +2,6 @@
 
 import location
 
-try :
-    import hildon
-except :
-    hildon = False
 import gobject
 
 class GPSObject ( gobject.GObject ) :
@@ -15,9 +11,9 @@ class GPSObject ( gobject.GObject ) :
         self._parent = widget
         self._debug = False
         self.control = location.GPSDControl.get_default()
+        self.device = location.GPSDevice()
         # properties : maincontext_pointer preferred_interval preferred_method
         self.method = location.METHOD_GNSS
-        self.device = None
         self.gps_state = False
         self.gps_info = "NO_FIX 0 0 NaN NaN NaN NaN NaN NaN NaN"
         self.update_handler = None
@@ -49,15 +45,13 @@ class GPSObject ( gobject.GObject ) :
             self.interval = location.INTERVAL_60S
         elif interval == "120" :
             self.interval = location.INTERVAL_120S
+        else :
+            self.interval = location.INTERVAL_DEFAULT
 
     def do_start ( self ) :
-        if not self.device :
-            self.control.set_properties(preferred_method=self.method)
-            self.device = location.GPSDevice()
-        if self.update_handler :
-            if hildon :
-                hildon.hildon_banner_show_information( self._parent , "icon_path" , "GPS already started" )
-        else :
+        self.control.set_properties(preferred_method=self.method,                                                  
+                                    preferred_interval=self.interval)                                              
+        if not self.update_handler :
             self.update_handler = self.device.connect_object("changed", GPSObject.do_update , self)
             self.control.start()
 
@@ -67,42 +61,24 @@ class GPSObject ( gobject.GObject ) :
             # FIXME : Is this removal OK?
             del self.update_handler
             self.update_handler = None
-        self.device.stop()
         self.control.stop()
 
     def do_update ( self ) :
 
         if self.device :
             if self.device.status == location.GPS_DEVICE_STATUS_NO_FIX :
-            #    if self.gps_state == "FIX" or self.gps_state == "DGPS" :
-            #      if hildon :
-            #        banner = hildon.hildon_banner_show_information( self._parent , "icon_path" , "Lost GPS fix" )
-            #        banner.set_timeout( 1500 )
                 self.gps_state = "NO_FIX"
             elif self.device.status == location.GPS_DEVICE_STATUS_FIX :
-            #    if self.gps_state == "NO_FIX" :
-            #      if hildon :
-            #        banner = hildon.hildon_banner_show_information( self._parent , "icon_path" , "Got GPS fix" )
-            #        banner.set_timeout( 1500 )
                 self.gps_state = "FIX"
                 self.ngps += 1
                 self.refresh_infowin()
             elif self.device.status == location.GPS_DEVICE_STATUS_DGPS_FIX :
-            #    if self.gps_state == "NO_FIX" :
-            #      if hildon :
-            #        banner = hildon.hildon_banner_show_information( self._parent , "icon_path" , "Got differential GPS fix" )
-            #        banner.set_timeout( 1500 )
                 self.gps_state = "DGPS"
 
             self.gps_info = "%s %d %d %s %s %s %s %s %s %s" % ( self.gps_state , self.device.satellites_in_use , self.device.satellites_in_view , self.device.fix[2] , self.device.fix[4] , self.device.fix[5] , self.device.fix[7] , self.device.fix[9] , self.device.fix[11] , self.device.fix[13] )
             self.satellites = self.device.satellites
             self.cell_info = self.device.cell_info
 
-        #    if self._debug :
-        #      if hildon :
-        #        banner = hildon.hildon_banner_show_information( self._parent , "icon_path" , "GPS info : %s" % self.gps_info )
-        #        banner.set_timeout( 300 )
-
     def set_infowin ( self , statuswin ) :
         self.status = statuswin
 
index 4f85cbd..fa4bbca 100644 (file)
@@ -16,16 +16,6 @@ class Rpc :
     def __init__ ( self , context ) :
         self.context = context
 
-#    def cosa ( self ) :
-#        gps.GPSObject.__init__( self , widget )
-#    #    self.osso_context = osso.Context("wifi_scanner", "2.0", False)
-#    #    osso_rpc = osso.Rpc(self.osso_context)
-#    #    scan_out = osso_rpc.rpc_run("org.javiplx.wifiscan", "/org/javiplx/wifiscan", "org.javiplx.wifiscan", "wakeup", wait_reply = True)
-#        scan_out = rpc_run("org.javiplx.wifiscan", "/org/javiplx/wifiscan", "org.javiplx.wifiscan", "wakeup", wait_reply = True)
-#        self._timer = None
-#        self._info = None
-#        self._status = None
-
     def rpc_run ( self , object_name , object_path , object_iface , method , wait_reply=False ) :
         connection = self.context.get_connection()
         proxy = connection.get_object( object_name , object_path )