7 import dbus.mainloop.glib
11 def get_properties(path):
12 element = dbus.Interface(bus.get_object("org.moblin.connman", path),
13 "org.moblin.connman.Element")
15 return element.GetProperties()
17 def element_added(path):
19 properties = get_properties(path)
20 if (properties["Type"] == "dhcp"):
21 print "Aquiring IP address"
22 if (properties["Type"] == "ipv4"):
23 print "IP address assigned"
24 if (properties["Type"] == "internet"):
26 print "Succesfully connected"
28 def element_updated(path):
29 properties = get_properties(path)
30 if (properties["Type"] == "network" and properties["Connected"] == 1):
31 print "Associated with %s" % (properties["SSID"])
33 def element_removed(path):
35 if (path == internet_path):
37 print "Connection terminated"
39 if __name__ == '__main__':
40 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
42 bus = dbus.SystemBus()
44 bus.add_signal_receiver(element_added,
45 dbus_interface = "org.moblin.connman.Manager",
46 signal_name = "ElementAdded")
48 bus.add_signal_receiver(element_updated,
49 dbus_interface = "org.moblin.connman.Manager",
50 signal_name = "ElementUpdated")
52 bus.add_signal_receiver(element_removed,
53 dbus_interface = "org.moblin.connman.Manager",
54 signal_name = "ElementRemoved")
56 mainloop = gobject.MainLoop()