7 import dbus.mainloop.glib
10 class Canceled(dbus.DBusException):
11 _dbus_error_name = "net.connman.Error.Canceled"
13 class Agent(dbus.service.Object):
18 @dbus.service.method("net.connman.Agent",
19 in_signature='', out_signature='')
24 @dbus.service.method("net.connman.Agent",
25 in_signature='oa{sv}',
26 out_signature='a{sv}')
27 def RequestInput(self, path, fields):
28 print "RequestInput (%s,%s)" % (path, fields)
32 if not self.identity and not self.passphrase and not self.wpspin:
33 args = raw_input('Answer: ')
35 for arg in args.split():
36 if arg.startswith("Identity="):
37 identity = arg.replace("Identity=", "", 1)
38 response["Identity"] = identity
40 if arg.startswith("Passphrase="):
41 passphrase = arg.replace("Passphrase=", "", 1)
42 response["Passphrase"] = passphrase
44 if arg.startswith("WPS="):
45 wpspin = arg.replace("WPS=", "", 1)
46 response["WPS"] = wpspin
50 response["Identity"] = self.identity
52 response["Passphrase"] = self.passphrase
54 response["WPS"] = self.wpspin
56 print "returning (%s)" % (response)
60 @dbus.service.method("net.connman.Agent",
63 def ReportError(self, path, error):
64 print "ReportError %s, %s" % (path, error)
65 retry = raw_input("Retry service (yes/no): ")
67 class Retry(dbus.DBusException):
68 _dbus_error_name = "net.connman.Agent.Error.Retry"
70 raise Retry("retry service")
75 @dbus.service.method("net.connman.Agent",
76 in_signature='', out_signature='')
81 print "Usage: %s Identity=<identity> Passphrase=<passphrase> WPS=<wpspin>" % (sys.argv[0])
82 print "Help: %s help" % (sys.ar[0])
85 if __name__ == '__main__':
86 if len(sys.argv) == 2 and sys.argv[1] == "help":
89 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
91 bus = dbus.SystemBus()
92 manager = dbus.Interface(bus.get_object('net.connman', "/"),
93 'net.connman.Manager')
96 object = Agent(bus, path)
98 if len(sys.argv) >= 2:
99 for arg in sys.argv[1:]:
100 if arg.startswith("Identity="):
101 object.identity = arg.replace("Identity=", "", 1)
102 elif arg.startswith("Passphrase="):
103 object.passphrase = arg.replace("Passphrase=", "", 1)
104 elif arg.startswith("WPS="):
105 object.wpspin = arg.replace("WPS=", "", 1)
109 manager.RegisterAgent(path)
111 mainloop = gobject.MainLoop()
114 #manager.UnregisterAgent(path)