test: Renamed set-ip-method to be consistent with IPv6 script
[platform/upstream/connman.git] / test / simple-agent
index b8e4efc..859d403 100755 (executable)
@@ -8,38 +8,46 @@ import dbus.mainloop.glib
 import sys
 
 class Canceled(dbus.DBusException):
-       _dbus_error_name = "org.moblin.connman.Error.Canceled"
+       _dbus_error_name = "net.connman.Error.Canceled"
 
 class Agent(dbus.service.Object):
        passphrase = ""
 
-       @dbus.service.method("org.moblin.connman.Agent",
+       @dbus.service.method("net.connman.Agent",
                                        in_signature='', out_signature='')
        def Release(self):
                print("Release")
                mainloop.quit()
 
-       @dbus.service.method("org.moblin.connman.Agent",
-                                       in_signature='o', out_signature='')
-       def RequestPassphrase(self, path):
-               print "PassphraseRequested (%s)" % (path)
+       @dbus.service.method("net.connman.Agent",
+                                       in_signature='oa{sv}',
+                                       out_signature='a{sv}')
+       def RequestInput(self, path, fields):
+               print "RequestInput (%s,%s)" % (path, fields)
 
-               service = dbus.Interface(bus.get_object("org.moblin.connman",
-                                                       path),
-                                        "org.moblin.connman.Service")
+               response = {}
+               response["Passphrase"] = self.passphrase
 
-               try:
-                       print "setting passphrase (%s)" % (self.passphrase)
+               print "returning (%s)" % (response)
 
-                       service.SetProperty("Passphrase",
-                                           dbus.String(self.passphrase,
-                                                       variant_level=1))
+               return response
 
-                       service.Connect(timeout=60000)
-               except dbus.DBusException, error:
-                       print "%s: %s" % (error._dbus_error_name, error.message)
+       @dbus.service.method("net.connman.Agent",
+                                       in_signature='os',
+                                       out_signature='')
+       def ReportError(self, path, error):
+               print "ReportError %s, %s" % (path, error)
+               retry = raw_input("Retry service (yes/no): ")
+               if (retry == "yes"):
+                       class Retry(dbus.DBusException):
+                               _dbus_error_name = "net.connman.Agent.Error.Retry"
 
-       @dbus.service.method("org.moblin.connman.Agent",
+                       raise Retry("retry service")
+               else:
+                       return
+
+
+       @dbus.service.method("net.connman.Agent",
                                        in_signature='', out_signature='')
        def Cancel(self):
                print "Cancel"
@@ -54,8 +62,8 @@ if __name__ == '__main__':
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 
        bus = dbus.SystemBus()
-       manager = dbus.Interface(bus.get_object('org.moblin.connman', "/"),
-                                       'org.moblin.connman.Manager')
+       manager = dbus.Interface(bus.get_object('net.connman', "/"),
+                                       'net.connman.Manager')
 
        path = "/test/agent"
        object = Agent(bus, path)