tethering: Fix for default interface string double free
[platform/upstream/connman.git] / test / simple-agent
1 #!/usr/bin/python
2
3 import gobject
4
5 import dbus
6 import dbus.service
7 import dbus.mainloop.glib
8 import sys
9
10 class Canceled(dbus.DBusException):
11         _dbus_error_name = "org.moblin.connman.Error.Canceled"
12
13 class Agent(dbus.service.Object):
14         passphrase = ""
15
16         @dbus.service.method("org.moblin.connman.Agent",
17                                         in_signature='', out_signature='')
18         def Release(self):
19                 print("Release")
20                 mainloop.quit()
21
22         @dbus.service.method("org.moblin.connman.Agent",
23                                         in_signature='oa{sv}',
24                                         out_signature='a{sv}')
25         def RequestInput(self, path, fields):
26                 print "RequestInput (%s,%s)" % (path, fields)
27
28                 response = {}
29                 response["Passphrase"] = self.passphrase
30
31                 print "returning (%s)" % (response)
32
33                 return response
34
35         @dbus.service.method("org.moblin.connman.Agent",
36                                         in_signature='', out_signature='')
37         def Cancel(self):
38                 print "Cancel"
39
40
41
42 if __name__ == '__main__':
43         if len(sys.argv) < 2:
44                 print "Usage: %s <passphrase>" % (sys.argv[0])
45                 sys.exit(1)
46
47         dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
48
49         bus = dbus.SystemBus()
50         manager = dbus.Interface(bus.get_object('org.moblin.connman', "/"),
51                                         'org.moblin.connman.Manager')
52
53         path = "/test/agent"
54         object = Agent(bus, path)
55         object.passphrase = sys.argv[1]
56
57         manager.RegisterAgent(path)
58
59         mainloop = gobject.MainLoop()
60         mainloop.run()
61
62         #manager.UnregisterAgent(path)