Add example for a simple agent
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 26 Feb 2008 06:21:55 +0000 (07:21 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 26 Feb 2008 06:21:55 +0000 (07:21 +0100)
test/Makefile.am
test/simple-agent [new file with mode: 0755]

index ca88b98..8f8214f 100644 (file)
@@ -1,4 +1,4 @@
 
-EXTRA_DIST = list-interfaces start-scanning
+EXTRA_DIST = list-interfaces start-scanning simple-agent
 
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/test/simple-agent b/test/simple-agent
new file mode 100755 (executable)
index 0000000..47a61f6
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+
+import gobject
+
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+
+class Agent(dbus.service.Object):
+       @dbus.service.method("org.freedesktop.connman.Agent",
+                                       in_signature='', out_signature='')
+       def Release(self):
+               print("Release")
+               mainloop.quit()
+
+if __name__ == '__main__':
+       dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+       bus = dbus.SystemBus()
+       manager = dbus.Interface(bus.get_object('org.freedesktop.connman', "/"),
+                                       'org.freedesktop.connman.Manager')
+
+       path = "/test/agent"
+       object = Agent(bus, path)
+
+       manager.RegisterAgent(path)
+
+       mainloop = gobject.MainLoop()
+       mainloop.run()
+
+       #manager.UnregisterAgent(path)