Add support for setting per service domain list
[platform/upstream/connman.git] / test / monitor-services
1 #!/usr/bin/python
2
3 import gobject
4
5 import dbus
6 import dbus.mainloop.glib
7
8 def extract_values(values):
9         val = "{"
10         for key in values.keys():
11                 val += " " + key + "="
12                 val += str(values[key])
13         val += " }"
14         return val
15
16 def extract_list(list):
17         val = "["
18         for i in list:
19                 val += " " + str(i)
20         val += " ]"
21         return val
22
23 def property_changed(name, value, path):
24         service = path[path.rfind("/") + 1:]
25         if name in ["Profiles", "Services", "Providers", "Technologies",
26                                                 "Devices", "Networks"]:
27                 val = "["
28                 for i in value:
29                         val = val + " " + i[i.rfind("/") + 1:]
30                 val = val + " ]"
31         elif name in ["IPv4", "IPv4.Configuration", "Proxy", "Ethernet"]:
32                 val = extract_values(value)
33         elif name in ["Nameservers", "Nameservers.Configuration",
34                                         "Domains", "Domains.Configuration"]:
35                 val = extract_list(value)
36         elif name in ["Strength", "Priority"]:
37                 val = int(value)
38         else:
39                 val = str(value)
40         print "[%s] %s = %s" % (service, name, val)
41
42 if __name__ == '__main__':
43         dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
44
45         bus = dbus.SystemBus()
46
47         bus.add_signal_receiver(property_changed,
48                                 bus_name="org.moblin.connman",
49                                 dbus_interface="org.moblin.connman.Service",
50                                 signal_name = "PropertyChanged",
51                                 path_keyword="path")
52
53         mainloop = gobject.MainLoop()
54         mainloop.run()