diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-08-04 15:46:48 -0700 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-08-04 15:46:48 -0700 |
commit | 426befc5c790fb87a82e42647fb56d1ae831fcac (patch) | |
tree | 92e465b35a2f335316c138cf2d40467392dd771a /test | |
parent | aac35324deb8c0b57f881338d87cb36b0979e7df (diff) | |
download | connman-426befc5c790fb87a82e42647fb56d1ae831fcac.tar.gz connman-426befc5c790fb87a82e42647fb56d1ae831fcac.tar.bz2 connman-426befc5c790fb87a82e42647fb56d1ae831fcac.zip |
Add support for creating, modifying and removing profiles
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rwxr-xr-x | test/test-profile | 102 |
2 files changed, 103 insertions, 1 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 32bc04c0..1840a01b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2,7 +2,7 @@ EXTRA_DIST = get-state list-profiles list-services connect-service \ list-connections select-connection \ list-devices enable-device disable-device start-scanning \ - list-networks set-passphrase set-address \ + list-networks set-passphrase set-address test-profile \ simple-agent show-introspection test-compat test-manager \ test-connman monitor-connman monitor-services debug-connman diff --git a/test/test-profile b/test/test-profile new file mode 100755 index 00000000..8f659551 --- /dev/null +++ b/test/test-profile @@ -0,0 +1,102 @@ +#!/usr/bin/python + +import sys +import dbus + +bus = dbus.SystemBus() + +manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"), + "org.moblin.connman.Manager") + +if len(sys.argv) < 2: + print "Usage: %s <command>" % (sys.argv[0]) + print "" + print " list" + print " name <profile> [name]" + print "" + print " create <profile> [name]" + print " remove <profile>" + sys.exit(1) + +def print_profiles(profiles, active): + for path in profiles: + profile = dbus.Interface(bus.get_object("org.moblin.connman", path), + "org.moblin.connman.Profile") + + properties = profile.GetProperties() + + identifier = path[path.rfind("/") + 1:] + + if (path == active): + default = "*" + else: + default = " " + + if "Name" in properties.keys(): + name = properties["Name"] + else: + name = "<unnamed>" + + print "%s %-12s %s" % (default, identifier, name) + +if sys.argv[1] in ["list", "show"]: + properties = manager.GetProperties() + + print_profiles(properties["Profiles"], properties["ActiveProfile"]) + +elif sys.argv[1] in ["name"]: + if (len(sys.argv) < 3): + print "Need at least profile parameter" + sys.exit(1) + + path = "/profile/" + sys.argv[2] + + profile = dbus.Interface(bus.get_object("org.moblin.connman", path), + "org.moblin.connman.Profile") + + if (len(sys.argv) > 3): + name = sys.argv[3] + + profile.SetProperty("Name", name); + + print "Name \"%s\" set for %s" % (name, sys.argv[2]) + else: + properties = profile.GetProperties() + + if "Name" in properties.keys(): + name = "\"" + properties["Name"] + "\"" + else: + name = "<unnamed>" + + print "Name for %s is %s" % (sys.argv[2], name) + +elif sys.argv[1] in ["create", "add"]: + if (len(sys.argv) < 3): + print "Profile parameter required" + sys.exit(1) + + path = manager.CreateProfile(sys.argv[2]) + + print "New profile created at %s" % (path) + + profile = dbus.Interface(bus.get_object("org.moblin.connman", path), + "org.moblin.connman.Profile") + + if (len(sys.argv) > 3): + name = sys.argv[3] + + profile.SetProperty("Name", name); + + print "Name \"%s\" set for %s" % (name, sys.argv[2]) + +elif sys.argv[1] in ["remove", "delete", "del"]: + if (len(sys.argv) < 3): + print "Profile parameter required" + sys.exit(1) + + path = "/profile/" + sys.argv[2] + + manager.RemoveProfile(path) + +else: + print "Unknown command" |