Include a configuration setting to specify the interval among wireless scans
[wifihood] / wifiscand / wifiscand.py
1 #!/usr/bin/python2.5
2
3 import osso
4 import gtk
5
6 introspection = """<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n\
7          \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n\
8 <node name=\"/org/javiplx/wifiscan\">\n\
9   <interface name=\"org.javiplx.wifiscan\">\n\
10     <method name=\"wakeup\">\n\
11       <arg name=\"result\" type=\"s\" direction=\"out\" />\n\
12     </method>\n\
13     <method name=\"start\">\n\
14       <arg name=\"result\" type=\"s\" direction=\"out\" />\n\
15     </method>\n\
16     <method name=\"scan\">\n\
17       <arg name=\"result\" type=\"s\" direction=\"out\" />\n\
18     </method>\n\
19     <method name=\"stop\">\n\
20       <arg name=\"result\" type=\"s\" direction=\"out\" />\n\
21     </method>\n\
22   </interface>\n\
23 </node>\n"""
24
25 __version__ = "1.1"
26
27 name = "wifiscan"
28 service = "org.javiplx." + name
29 object = "/org/javiplx/" + name
30 iface = "org.javiplx." + name
31
32 def dbus_req_handler(interface, method, arguments, user_data):
33     if method == "Introspect" :
34         return introspection
35     if method == "wakeup" :
36         return "WifiScand ready"
37     if method == "start" :
38         return "Interface initialized"
39     if method == "stop" :
40         gtk.main_quit()
41         return
42     if method == "scan" :
43         print "return 00:1C:C0:CB:1A:72:-80"
44         return "00:1C:C0:CB:1A:72:-80"
45     return "Unknown method"
46
47 osso_c = osso.Context(name, __version__, False)
48
49 osso_rpc = osso.Rpc(osso_c)
50 osso_rpc.set_rpc_callback(service, object, iface, dbus_req_handler, ( "wlan0" , osso_c ) )
51 gtk.main()
52