From 635c64efa9425970354a56d9e63fbb73f525da2b Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Wed, 5 Dec 2012 13:11:41 +0200 Subject: test: simple-agent must monitor vpn status simple-agent needs to monitor vpnd status as vpnd can stop if there are no vpn configured. When vpnd quits we must not quit the agent as then wifi questions would not be asked from the user any more. --- test/simple-agent | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/simple-agent b/test/simple-agent index f501b1e5..ebb44c57 100755 --- a/test/simple-agent +++ b/test/simple-agent @@ -180,7 +180,6 @@ class VpnAgent(dbus.service.Object): in_signature='', out_signature='') def Release(self): print("Release VPN agent") - mainloop.quit() def input_cookie(self): response = {} @@ -267,6 +266,21 @@ class VpnAgent(dbus.service.Object): def Cancel(self): print "Cancel" +def vpnNameOwnerChanged(proxy): + if proxy: + print("vpnd is connected to system bus") + try: + path = "/test/vpn_agent" + vpn_manager = dbus.Interface(bus.get_object('net.connman.vpn', + "/"), + 'net.connman.vpn.Manager') + vpn_manager.RegisterAgent(path) + except: + print "vpn agent registered" + else: + print("vpnd is disconnected from system bus") + vpn_manager = None + def print_usage(): print "Usage:" print "For hidden service:" @@ -328,6 +342,8 @@ if __name__ == '__main__': vpn_manager.RegisterAgent(path) + bus.watch_name_owner('net.connman.vpn', vpnNameOwnerChanged) + mainloop = gobject.MainLoop() mainloop.run() -- cgit v1.2.3