--- /dev/null
+wifihood (1.0) fremantle; urgency=low
+
+ * First version
+
+ -- Javier Palacios <javiplx@gmail.com> Sat, 8 May 2010 10:50:23 +0200
--- /dev/null
+Source: wifihood
+Priority: optional
+Maintainer: Javier Palacios <javiplx@gmail.com>
+Build-Depends: debhelper (>= 4.0.0)
+Standards-Version: 3.6.1
+
+Package: wifihood-scanner
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: WifiHood Scanner
+
+#Package: wifihood-mapper
+#Architecture: any
+#Depends: ${shlibs:Depends}, ${misc:Depends}
+#Description: WifiHood Mapper
--- /dev/null
+#!/usr/bin/make -f
+
+# workaround to avoid calling Scratchbox python2.3
+PATH := /usr/bin:$(PATH)
+export PATH
+SBOX_REDIRECT_IGNORE = /usr/bin/python
+export SBOX_REDIRECT_IGNORE
+
+DEB_PYTHON_SYSTEM = pycentral
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/python-distutils.mk
+
+# Add here any variable or target overrides you need.
+
+clean::
+ echo rm -f location.c
--- /dev/null
+#!/usr/bin/python
+
+from distutils.core import setup
+from distutils.extension import Extension
+
+# url
+setup(name='wifihood',
+ version='1.0',
+ description='WifiHood scanner application',
+ author='Javier Palacios',
+ author_email='javiplx@gmail.com',
+ scripts=['wifiscanner'],
+ data_files = [
+ ( 'share/applications/hildon' , [ 'wifiscanner.desktop'] )
+ ],
+ packages=['wifimap']
+ )
+
--- /dev/null
+
+from gps import *
+
+from wifiscan import *
+
--- /dev/null
+
+
+import location
+
+import hildon
+import gobject
+
+class GPSObject ( gobject.GObject ) :
+
+ def __init__ ( self , widget=None ) :
+ gobject.GObject.__init__( self )
+ self._parent = widget
+ self._debug = False
+ self.control = location.GPSDControl.get_default()
+ # properties : maincontext_pointer preferred_interval preferred_method
+ self.method = location.METHOD_GNSS
+ self.device = None
+ self.gps_state = False
+ self.gps_info = None
+ self.update_handler = None
+ self.satellites = None
+ self.cell_info = None
+
+ def set_method ( self , method="gps" ) :
+ if method == "agps" :
+ self.method = location.METHOD_GNSS | location.METHOD_AGNSS
+ else :
+ self.method = location.METHOD_GNSS
+
+ def set_interval ( self , interval="1" ) :
+ if interval == "1" :
+ self.interval = location.INTERVAL_1S
+ elif interval == "2" :
+ self.interval = location.INTERVAL_2S
+ elif interval == "5" :
+ self.interval = location.INTERVAL_5S
+ elif interval == "10" :
+ self.interval = location.INTERVAL_10S
+ elif interval == "20" :
+ self.interval = location.INTERVAL_20S
+ elif interval == "30" :
+ self.interval = location.INTERVAL_30S
+ elif interval == "60" :
+ self.interval = location.INTERVAL_60S
+ elif interval == "120" :
+ self.interval = location.INTERVAL_120S
+
+ def do_start ( self ) :
+ if not self.device :
+ self.control.set_properties(preferred_method=self.method)
+ self.device = location.GPSDevice()
+ if self.update_handler :
+ hildon.hildon_banner_show_information( self._parent , "icon_path" , "GPS already started" )
+ else :
+ self.update_handler = self.device.connect_object("changed", GPSObject.do_update , self)
+ self.control.start()
+
+ # FIXME : Stopping does not work, at least while getting fix
+ def do_stop ( self ) :
+ if self.update_handler :
+ # 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" :
+ # 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" :
+ # banner = hildon.hildon_banner_show_information( self._parent , "icon_path" , "Got GPS fix" )
+ # banner.set_timeout( 1500 )
+ self.gps_state = "FIX"
+ elif self.device.status == location.GPS_DEVICE_STATUS_DGPS_FIX :
+ # if self.gps_state == "NO_FIX" :
+ # 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 :
+ # banner = hildon.hildon_banner_show_information( self._parent , "icon_path" , "GPS info : %s" % self.gps_info )
+ # banner.set_timeout( 300 )
+
+
+# mode = device.fix[0]
+# if mode == location.GPS_DEVICE_MODE_NOT_SEEN : # This means ??
+# print "mode is NOSEEN"
+# if mode == location.GPS_DEVICE_MODE_NO_FIX : # This implies device.status == location.GPS_DEVICE_STATUS_NO_FIX
+# # and probably device.fix[1] == location.GPS_DEVICE_NONE_SET
+# print "mode is NOFIX"
+# if mode == location.GPS_DEVICE_MODE_2D :
+# print "mode is 2D"
+# if mode == location.GPS_DEVICE_MODE_3D :
+# print "mode is 3D"
+
+# if flags & location.GPS_DEVICE_SPEED_SET :
+# print "GPS_DEVICE_SPEED_SET"
+# if flags & location.GPS_DEVICE_TRACK_SET :
+# print "GPS_DEVICE_TRACK_SET"
+# if flags & location.GPS_DEVICE_ALTITUDE_SET :
+# print "GPS_DEVICE_ALTITUDE_SET"
+# if flags & location.GPS_DEVICE_CLIMB_SET :
+# print "GPS_DEVICE_CLIMB_SET"
+
+gobject.type_register(GPSObject)
+
--- /dev/null
+
+import osso
+
+import time
+
+import gps
+
+import gobject
+
+class Scanner ( gps.GPSObject ) :
+
+ def __init__ ( self , widget=None , ifname="wlan0" ) :
+ gps.GPSObject.__init__( self , widget )
+ self.osso_context = osso.Context("wifi_scanner", "2.0", False)
+ self._timer = None
+
+ def start ( self ) :
+ osso_rpc = osso.Rpc(self.osso_context)
+ scan_out = osso_rpc.rpc_run("org.javiplx.wifiscan", "/org/javiplx/wifiscan", "org.javiplx.wifiscan", "start")
+ osso.SystemNote(self.osso_context).system_note_infoprint("WifiScand started")
+
+ def stop ( self ) :
+ osso_rpc = osso.Rpc(self.osso_context)
+ scan_out = osso_rpc.rpc_run("org.javiplx.wifiscan", "/org/javiplx/wifiscan", "org.javiplx.wifiscan", "stop")
+ osso.SystemNote(self.osso_context).system_note_infoprint("WifiScand stopped")
+
+ def scan ( self ) :
+ osso_rpc = osso.Rpc(self.osso_context)
+ try :
+ scan_out = osso_rpc.rpc_run("org.javiplx.wifiscan", "/org/javiplx/wifiscan", "org.javiplx.wifiscan", "scan", wait_reply = True)
+ except Exception , ex :
+ osso.SystemNote(self.osso_context).system_note_infoprint("Exception scanning %s" % ex )
+ return True
+ #osso.SystemNote(self.osso_context).system_note_infoprint("Found %d APs" % len(scan_out.split()) )
+ out_str = ""
+ for net in scan_out.split() :
+ items = net.rsplit(":", 1)
+ out_str += " %s %s" % ( items[0] , items[1] )
+ if self._debug :
+ # Use osso or hildon for notes ???
+ 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( "/home/user/MyDocs/wiscan_gui.info" , 'a' )
+ fd.write( "%s %s%s\n" % ( time.time() , self.gps_info , out_str ) )
+ fd.close()
+ if self.satellites :
+ loclist = open( "/home/user/MyDocs/location.info" , 'a' )
+ loclist.write ( "%s\n" % ( self.satellites ,) )
+ loclist.close()
+ if self.cell_info :
+ # osso.SystemNote(self.osso_context).system_note_infoprint("Found Cell : %s" % ( self.cell_info ,) )
+ celllist = open( "/home/user/MyDocs/cell.info" , 'a' )
+ celllist.write ( "%s\n" % ( self.cell_info ,) )
+ celllist.close()
+
+ return True
+
+
+gobject.type_register(Scanner)
+
--- /dev/null
+#!/usr/bin/python
+
+import wifimap
+
+import gtk
+import hildon
+
+import gobject
+
+def hello(widget, data):
+ data.do_start()
+
+def bye(widget, data):
+ data.do_stop()
+
+def enable_agps(widget):
+ if widget.get_active() :
+ print "%s state is active" % widget
+
+def scana(widget, data):
+ if not data._timer :
+ data._timer = gobject.timeout_add( 5000 , data.scan )
+ else :
+ hildon.hildon_banner_show_information( widget , "icon_path" , "Scanning was already active" )
+
+def scano(widget, data):
+ if data._timer :
+ hildon.hildon_banner_show_information( widget , "icon_path" , "Timer was running, stopping it" )
+ gobject.source_remove( data._timer )
+ data._timer = None
+ data.stop()
+ else :
+ hildon.hildon_banner_show_information( widget , "icon_path" , "Scanning is not active" )
+
+def main():
+
+ window = hildon.Window()
+ program = hildon.Program.get_instance()
+ program.add_window(window)
+
+ gpsdev = wifimap.Scanner( window )
+
+ window.connect("delete_event", gtk.main_quit, None)
+
+ vbox = gtk.VBox(homogeneous=False, spacing=0)
+ top_frame = gtk.Frame(label="top")
+ bottom_frame = gtk.Frame(label="bottom")
+
+ # FIXME : Temporary holder !!!
+ table = gtk.Table (2, 2, False)
+
+ # set the spacing to 10 on x and 10 on y
+ table.set_row_spacings(10)
+ table.set_col_spacings(10)
+
+ button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH, hildon.BUTTON_ARRANGEMENT_VERTICAL, "Switch On!")
+ button.connect("clicked", hello, gpsdev)
+ table.attach(button, 0, 1, 0, 1)
+
+ button_off = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH, hildon.BUTTON_ARRANGEMENT_VERTICAL, "Switch Off!")
+ button_off.connect("clicked", bye, gpsdev)
+ table.attach(button_off, 1, 2, 0, 1)
+
+ button_scan = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH, hildon.BUTTON_ARRANGEMENT_VERTICAL, "Start scanning now !!")
+ button_scan.connect("clicked", scana, gpsdev)
+ table.attach(button_scan, 0, 1, 1, 2)
+
+ button_stop = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH, hildon.BUTTON_ARRANGEMENT_VERTICAL, "Stop scanning now !!")
+ button_stop.connect("clicked", scano, gpsdev)
+ table.attach(button_stop, 1, 2, 1, 2)
+
+ bottom_frame.add(table)
+
+ toggle_button = gtk.CheckButton(label="Use Assisted GPS")
+ toggle_button.connect("toggled", enable_agps)
+ top_frame.add(toggle_button)
+
+ vbox.pack_start(top_frame)
+ vbox.pack_end(bottom_frame)
+ window.add(vbox)
+
+ window.show_all()
+
+ gpsdev.start()
+
+ gtk.main()
+
+if __name__ == "__main__":
+ main()
+
--- /dev/null
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Type=Application
+Name=WifiScanner
+Exec=/usr/bin/wifiscanner
+Icon=/usr/share/pixmaps/python2.5.xpm
+Maemo-Display-Name=WifiScanner