import dbus
import dbus.mainloop.glib
-def property_changed(name, value, path, interface):
- iface = interface[interface.rfind(".") + 1:]
- ipath = path[path.rfind("/") + 1:]
- if iface not in ["Service"]:
- return
- if name in ["Profiles", "Services", "Providers", "Technologies",
- "Devices", "Networks"]:
+def extract_values(values):
+ val = "{"
+ for key in values.keys():
+ val += " " + key + "="
+ if key in ["Servers", "Excludes"]:
+ val += extract_list(values[key])
+ else:
+ val += str(values[key])
+ val += " }"
+ return val
+
+def extract_list(list):
+ val = "["
+ for i in list:
+ val += " " + str(i)
+ val += " ]"
+ return val
+
+def property_changed(name, value, path):
+ service = path[path.rfind("/") + 1:]
+ if name in ["Profiles", "Services", "Technologies"]:
val = "["
for i in value:
val = val + " " + i[i.rfind("/") + 1:]
val = val + " ]"
+ elif name in ["IPv4", "IPv4.Configuration",
+ "IPv6", "IPv6.Configuration",
+ "Proxy", "Proxy.Configuration", "Ethernet"]:
+ val = extract_values(value)
+ elif name in ["Nameservers", "Nameservers.Configuration",
+ "Domains", "Domains.Configuration"
+ "Security"]:
+ val = extract_list(value)
elif name in ["Strength", "Priority"]:
val = int(value)
else:
val = str(value)
- print "{%s} [%s] %s = %s" % (iface, ipath, name, val)
+ print "[%s] %s = %s" % (service, name, val)
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
bus.add_signal_receiver(property_changed,
- bus_name="org.moblin.connman",
- signal_name = "PropertyChanged",
- path_keyword="path",
- interface_keyword="interface")
+ bus_name="net.connman",
+ dbus_interface="net.connman.Service",
+ signal_name = "PropertyChanged",
+ path_keyword="path")
mainloop = gobject.MainLoop()
mainloop.run()