test: Also monitor technology changes
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 1 May 2012 08:16:52 +0000 (10:16 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 1 May 2012 08:16:52 +0000 (10:16 +0200)
test/monitor-services

index 015dbd1..9476bf8 100755 (executable)
@@ -47,13 +47,23 @@ def property_changed(name, value, path):
 def services_changed(services, removed):
        for i in services:
                service = i[0][i[0].rfind("/") + 1:]
-               print "[%s] added / update" % (service)
+               print "[%s] changed" % (service)
                for n in i[1].keys():
                        property_changed(n, i[1][n], i[0])
        for i in removed:
                service = i[i.rfind("/") + 1:]
                print "[%s] removed" % (service)
 
+def technology_added(path, properties):
+       technology = path[path.rfind("/") + 1:]
+       print "[%s] added" % (technology)
+       for n in properties.keys():
+               property_changed(n, properties[n], technology)
+
+def technology_removed(path):
+       technology = path[path.rfind("/") + 1:]
+       print "[%s] removed" % (technology)
+
 if __name__ == '__main__':
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 
@@ -61,20 +71,36 @@ if __name__ == '__main__':
 
        bus.add_signal_receiver(property_changed,
                                bus_name="net.connman",
-                               dbus_interface="net.connman.Service",
+                               dbus_interface="net.connman.Manager",
                                signal_name="PropertyChanged",
                                path_keyword="path")
 
-       bus.add_signal_receiver(property_changed,
+       bus.add_signal_receiver(services_changed,
                                bus_name="net.connman",
                                dbus_interface="net.connman.Manager",
+                               signal_name="ServicesChanged")
+
+       bus.add_signal_receiver(property_changed,
+                               bus_name="net.connman",
+                               dbus_interface="net.connman.Service",
                                signal_name="PropertyChanged",
                                path_keyword="path")
 
-       bus.add_signal_receiver(services_changed,
+       bus.add_signal_receiver(technology_added,
                                bus_name="net.connman",
                                dbus_interface="net.connman.Manager",
-                               signal_name="ServicesChanged")
+                               signal_name="TechnologyAdded")
+
+       bus.add_signal_receiver(technology_removed,
+                               bus_name="net.connman",
+                               dbus_interface="net.connman.Manager",
+                               signal_name="TechnologyRemoved")
+
+       bus.add_signal_receiver(property_changed,
+                               bus_name="net.connman",
+                               dbus_interface="net.connman.Technology",
+                               signal_name="PropertyChanged",
+                               path_keyword="path")
 
        mainloop = gobject.MainLoop()
        mainloop.run()