6 import dbus.mainloop.glib
8 def extract_values(values):
10 for key in values.keys():
11 val += " " + key + "="
12 if key in ["Servers", "Excludes"]:
13 val += extract_list(values[key])
15 val += str(values[key])
19 def extract_list(list):
26 def property_changed(name, value, path):
27 service = path[path.rfind("/") + 1:]
28 if name in ["Services"]:
31 val = val + " " + i[i.rfind("/") + 1:]
33 elif name in ["IPv4", "IPv4.Configuration",
34 "IPv6", "IPv6.Configuration",
35 "Proxy", "Proxy.Configuration", "Ethernet", "Provider"]:
36 val = extract_values(value)
37 elif name in ["Nameservers", "Nameservers.Configuration",
38 "Domains", "Domains.Configuration",
39 "Timeservers", "Timeservers.Configuration", "Security"]:
40 val = extract_list(value)
41 elif name in ["Strength", "Priority"]:
45 print "[%s] %s = %s" % (service, name, val)
47 def services_changed(services, removed):
49 service = i[0][i[0].rfind("/") + 1:]
50 print "[%s] changed" % (service)
52 property_changed(n, i[1][n], i[0])
54 service = i[i.rfind("/") + 1:]
55 print "[%s] removed" % (service)
57 def technology_added(path, properties):
58 technology = path[path.rfind("/") + 1:]
59 print "[%s] added" % (technology)
60 for n in properties.keys():
61 property_changed(n, properties[n], technology)
63 def technology_removed(path):
64 technology = path[path.rfind("/") + 1:]
65 print "[%s] removed" % (technology)
67 if __name__ == '__main__':
68 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
70 bus = dbus.SystemBus()
72 bus.add_signal_receiver(property_changed,
73 bus_name="net.connman",
74 dbus_interface="net.connman.Manager",
75 signal_name="PropertyChanged",
78 bus.add_signal_receiver(services_changed,
79 bus_name="net.connman",
80 dbus_interface="net.connman.Manager",
81 signal_name="ServicesChanged")
83 bus.add_signal_receiver(property_changed,
84 bus_name="net.connman",
85 dbus_interface="net.connman.Service",
86 signal_name="PropertyChanged",
89 bus.add_signal_receiver(technology_added,
90 bus_name="net.connman",
91 dbus_interface="net.connman.Manager",
92 signal_name="TechnologyAdded")
94 bus.add_signal_receiver(technology_removed,
95 bus_name="net.connman",
96 dbus_interface="net.connman.Manager",
97 signal_name="TechnologyRemoved")
99 bus.add_signal_receiver(property_changed,
100 bus_name="net.connman",
101 dbus_interface="net.connman.Technology",
102 signal_name="PropertyChanged",
105 mainloop = gobject.MainLoop()