From 99cf3b6bbc863da93dc5af464e0211217d280ccb Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 26 Feb 2008 07:21:55 +0100 Subject: [PATCH] Add example for a simple agent --- test/Makefile.am | 2 +- test/simple-agent | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 test/simple-agent diff --git a/test/Makefile.am b/test/Makefile.am index ca88b98..8f8214f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -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 index 0000000..47a61f6 --- /dev/null +++ b/test/simple-agent @@ -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) -- 1.7.9.5