12f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley#!/usr/bin/python
22f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley
32f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wileyimport gobject
42f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley
52f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wileyimport dbus
62f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wileyimport dbus.mainloop.glib
72f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley
82f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wileydef property_changed(name, value, path, interface):
92f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley    iface = interface[interface.rfind(".") + 1:]
102f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley    ipath = path[path.rfind("/") + 1:]
112f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley    if iface not in ["Service"]:
122f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley        return
132f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley    if name in ["Profiles", "Services",
142f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley                "Devices", "Networks"]:
152f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley        val = "["
162f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley        for i in value:
172f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley            val = val + " " + i[i.rfind("/") + 1:]
182f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley        val = val + " ]"
192f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley    elif name in ["Strength", "Priority"]:
202f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley        val = int(value)
212f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley    else:
222f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley        val = str(value)
232f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley    print "{%s} [%s] %s = %s" % (iface, ipath, name, val)
242f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley
252f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wileyif __name__ == '__main__':
262f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
272f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley
282f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley    bus = dbus.SystemBus()
292f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley
302f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley    bus.add_signal_receiver(property_changed,
312f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley                            bus_name="org.chromium.flimflam",
322f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley                            signal_name = "PropertyChanged",
332f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley                            path_keyword="path",
342f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley                            interface_keyword="interface")
352f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley
362f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley    mainloop = gobject.MainLoop()
372f48d9572459c2c90d68e8b017b86eb843fe2a74Christopher Wiley    mainloop.run()
38