7 import dbus.mainloop.glib
10 class Canceled(dbus.DBusException):
11 _dbus_error_name = "net.connman.Error.Canceled"
13 class Agent(dbus.service.Object):
17 @dbus.service.method("net.connman.Agent",
18 in_signature='', out_signature='')
23 @dbus.service.method("net.connman.Agent",
24 in_signature='oa{sv}',
25 out_signature='a{sv}')
26 def RequestInput(self, path, fields):
27 print "RequestInput (%s,%s)" % (path, fields)
29 if not self.passphrase and not self.wpspin:
30 args = raw_input('Answer: ')
34 for arg in args.split():
35 if arg.startswith("Passphrase="):
36 passphrase = arg.replace("Passphrase=", "", 1)
37 response["Passphrase"] = passphrase
39 if arg.startswith("WPS="):
40 wpspin = arg.replace("WPS=", "", 1)
41 response["WPS"] = wpspin
45 response["Passphrase"] = self.passphrase
47 response["WPS"] = self.wpspin
49 print "returning (%s)" % (response)
53 @dbus.service.method("net.connman.Agent",
56 def ReportError(self, path, error):
57 print "ReportError %s, %s" % (path, error)
58 retry = raw_input("Retry service (yes/no): ")
60 class Retry(dbus.DBusException):
61 _dbus_error_name = "net.connman.Agent.Error.Retry"
63 raise Retry("retry service")
68 @dbus.service.method("net.connman.Agent",
69 in_signature='', out_signature='')
74 print "Usage: %s Passphrase=<passphrase> WPS=<wpspin>" % (sys.argv[0])
75 print "Help: %s help" % (sys.ar[0])
78 if __name__ == '__main__':
79 if len(sys.argv) == 2 and sys.argv[1] == "help":
82 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
84 bus = dbus.SystemBus()
85 manager = dbus.Interface(bus.get_object('net.connman', "/"),
86 'net.connman.Manager')
89 object = Agent(bus, path)
91 if len(sys.argv) >= 2:
92 for arg in sys.argv[1:]:
93 if arg.startswith("Passphrase="):
94 object.passphrase = arg.replace("Passphrase=", "", 1)
95 elif arg.startswith("WPS="):
96 object.wpspin = arg.replace("WPS=", "", 1)
100 manager.RegisterAgent(path)
102 mainloop = gobject.MainLoop()
105 #manager.UnregisterAgent(path)