import location
-try :
- import hildon
-except :
- hildon = False
import gobject
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
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()
# 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
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 )