dnsproxy: Only one copy of the relevant buffers will be made to a TCP request
[framework/connectivity/connman.git] / test / test-connman
index 4336e2d..67b0c85 100755 (executable)
@@ -5,38 +5,43 @@ import dbus
 
 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")
 
 if len(sys.argv) < 2:
        print "Usage: %s <command>" % (sys.argv[0])
        print ""
        print "  state"
        print "  services"
-       print "  apn <service> [apn]"
-       print "  passphrase <service> [passphrase]"
        print "  autoconnect <service> [autoconnect]"
        print "  connect <service>"
        print "  disconnect <service>"
        print "  remove <service>"
        print ""
-       print "  scan [type]"
+       print "  scan <type>"
        print "  enable <type>"
        print "  disable <type>"
        print "  offlinemode [on|off]"
        sys.exit(1)
 
 def print_services(services):
-       for path in services:
-               service = dbus.Interface(bus.get_object("org.moblin.connman", path),
-                                               "org.moblin.connman.Service")
-
-               properties = service.GetProperties()
-
+       for path, properties in services:
                identifier = path[path.rfind("/") + 1:]
+               state = " "
+               autoconnect = "  "
 
                if properties["Favorite"] == dbus.Boolean(1):
                        favorite = "*"
+
+                       if properties["AutoConnect"] == dbus.Boolean(1):
+                               autoconnect = " A"
+                       else:
+                               autoconnect = "  "
+
+                       if properties["State"] == "ready":
+                               state = "R"
+                       elif properties["State"] == "online":
+                               state = "O"
                else:
                        favorite = " "
 
@@ -45,7 +50,8 @@ def print_services(services):
                else:
                        name = "{" + properties["Type"] + "}"
 
-               print "%s %-26s { %s }" % (favorite, name, identifier)
+               print "%s%s%s %-26s { %s }" % (favorite, autoconnect, state,
+                                              name, identifier)
 
 if sys.argv[1] == "state":
        properties = manager.GetProperties()
@@ -53,81 +59,17 @@ if sys.argv[1] == "state":
        print "System is %s" % (properties["State"])
 
 elif sys.argv[1] in ["services", "list", "show"]:
-       properties = manager.GetProperties()
-
-       print_services(properties["Services"])
-
-elif sys.argv[1] in ["apn"]:
-       if (len(sys.argv) < 3):
-               print "Need at least service parameter"
-               sys.exit(1)
-
-       path = "/profile/default/" + sys.argv[2]
-
-       service = dbus.Interface(bus.get_object("org.moblin.connman", path),
-                                               "org.moblin.connman.Service")
-
-       if (len(sys.argv) > 3):
-               apn = sys.argv[3]
-
-               service.SetProperty("APN", apn);
-
-               print "APN %s set for %s" % (apn, sys.argv[2])
-       else:
-               properties = service.GetProperties()
-
-               if "Name" in properties.keys():
-                       name = properties["Name"]
-               else:
-                       name = "{" + properties["Type"] + "}"
-
-               if "APN" in properties.keys():
-                       apn = properties["APN"]
-               else:
-                       apn = "not set"
-
-               print "APN for %s is %s" % (name, apn)
-
-elif sys.argv[1] in ["passphrase", "pass"]:
-       if (len(sys.argv) < 3):
-               print "Need at least service parameter"
-               sys.exit(1)
-
-       path = "/profile/default/" + sys.argv[2]
-
-       service = dbus.Interface(bus.get_object("org.moblin.connman", path),
-                                               "org.moblin.connman.Service")
-
-       if (len(sys.argv) > 3):
-               passphrase = sys.argv[3]
-
-               service.SetProperty("Passphrase", passphrase);
-
-               print "Passphrase %s set for %s" % (passphrase, sys.argv[2])
-       else:
-               properties = service.GetProperties()
-
-               if "Name" in properties.keys():
-                       name = properties["Name"]
-               else:
-                       name = "{" + properties["Type"] + "}"
-
-               if "Passphrase" in properties.keys():
-                       passphrase = properties["Passphrase"]
-               else:
-                       passphrase = "not set"
-
-               print "Passphrase for %s is %s" % (name, passphrase)
+       print_services(manager.GetServices())
 
 elif sys.argv[1] in ["autoconnect", "autoconn"]:
        if (len(sys.argv) < 3):
                print "Need at least service parameter"
                sys.exit(1)
 
-       path = "/profile/default/" + sys.argv[2]
+       path = "/net/connman/service/" + sys.argv[2]
 
-       service = dbus.Interface(bus.get_object("org.moblin.connman", path),
-                                               "org.moblin.connman.Service")
+       service = dbus.Interface(bus.get_object("net.connman", path),
+                                               "net.connman.Service")
 
        if (len(sys.argv) > 3):
                flag = sys.argv[3].strip().lower()
@@ -156,10 +98,10 @@ elif sys.argv[1] in ["connect", "conn"]:
                print "Need at least service parameter"
                sys.exit(1)
 
-       path = "/profile/default/" + sys.argv[2]
+       path = "/net/connman/service/" + sys.argv[2]
 
-       service = dbus.Interface(bus.get_object("org.moblin.connman", path),
-                                               "org.moblin.connman.Service")
+       service = dbus.Interface(bus.get_object("net.connman", path),
+                                               "net.connman.Service")
 
        try:
                service.Connect(timeout=60000)
@@ -171,10 +113,10 @@ elif sys.argv[1] in ["disconnect", "disc"]:
                print "Need at least service parameter"
                sys.exit(1)
 
-       path = "/profile/default/" + sys.argv[2]
+       path = "/net/connman/service/" + sys.argv[2]
 
-       service = dbus.Interface(bus.get_object("org.moblin.connman", path),
-                                               "org.moblin.connman.Service")
+       service = dbus.Interface(bus.get_object("net.connman", path),
+                                               "net.connman.Service")
 
        try:
                service.Disconnect()
@@ -186,10 +128,10 @@ elif sys.argv[1] in ["remove"]:
                print "Need at least service parameter"
                sys.exit(1)
 
-       path = "/profile/default/" + sys.argv[2]
+       path = "/net/connman/service/" + sys.argv[2]
 
-       service = dbus.Interface(bus.get_object("org.moblin.connman", path),
-                                               "org.moblin.connman.Service")
+       service = dbus.Interface(bus.get_object("net.connman", path),
+                                               "net.connman.Service")
 
        properties = service.GetProperties()
 
@@ -204,21 +146,24 @@ elif sys.argv[1] in ["remove"]:
 
 elif sys.argv[1] == "scan":
        if len(sys.argv) > 2:
-               manager.RequestScan(sys.argv[2])
-       else:
-               manager.RequestScan("")
+               path = "/net/connman/technology/" + sys.argv[2]
+               technology = dbus.Interface(bus.get_object("net.connman", path),
+                                               "net.connman.Technology")
+               technology.Scan()
 
 elif sys.argv[1] == "enable":
        if len(sys.argv) > 2:
-               manager.EnableTechnology(sys.argv[2])
-       else:
-               manager.EnableTechnology("")
+               path = "/net/connman/technology/" + sys.argv[2]
+               technology = dbus.Interface(bus.get_object("net.connman", path),
+                                           "net.connman.Technology")
+               technology.SetProperty("Powered", True)
 
 elif sys.argv[1] == "disable":
        if len(sys.argv) > 2:
-               manager.DisableTechnology(sys.argv[2])
-       else:
-               manager.DisableTechnology("")
+               path = "/net/connman/technology/" + sys.argv[2]
+               technology = dbus.Interface(bus.get_object("net.connman", path),
+                                           "net.connman.Technology")
+               technology.SetProperty("Powered", False)
 
 elif sys.argv[1] in ["offlinemode", "flightmode"]:
        if len(sys.argv) > 2: