Add script for setting a passphrase
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 3 Dec 2008 12:34:33 +0000 (13:34 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 3 Dec 2008 12:34:33 +0000 (13:34 +0100)
test/Makefile.am
test/set-passphrase [new file with mode: 0755]

index fe11939..e0be1bc 100644 (file)
@@ -1,7 +1,7 @@
 
 EXTRA_DIST = list-profiles list-elements monitor-elements monitor-state \
-               get-state select-network disable-network monitor-networks \
-               enable-device disable-device start-scanning simple-agent \
-               show-introspection test-compat test-supplicant
+               get-state set-passphrase select-network disable-network \
+               monitor-networks enable-device disable-device start-scanning \
+               simple-agent show-introspection test-compat test-supplicant
 
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/test/set-passphrase b/test/set-passphrase
new file mode 100755 (executable)
index 0000000..db39554
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+if (len(sys.argv) < 3):
+       print "Usage: %s <network> <passphrase>" % (sys.argv[0])
+       sys.exit(1)
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
+                                       "org.moblin.connman.Manager")
+
+properties = manager.GetProperties()
+
+for path in properties["Devices"]:
+       device = dbus.Interface(bus.get_object("org.moblin.connman", path),
+                                               "org.moblin.connman.Device")
+
+       properties = device.GetProperties()
+
+       for path in properties["Networks"]:
+               network = dbus.Interface(bus.get_object("org.moblin.connman", path),
+                                               "org.moblin.connman.Network")
+
+               properties = network.GetProperties()
+
+               if (properties["WiFi.Name"] == sys.argv[1]):
+                       print "Setting passphrase for %s" % (path)
+                       network.SetProperty("WiFi.Passphrase", sys.argv[2])