---
 Makefile.am    |    2 +-
 test/set-proxy |   44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletions(-)
 create mode 100755 test/set-proxy

diff --git a/Makefile.am b/Makefile.am
index 4e6ecf1..04189d7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -183,7 +183,7 @@ test_scripts = test/get-state test/list-profiles 
test/list-services \
                test/connect-vpn test/disconnect-vpn test/list-providers \
                test/monitor-manager test/test-counter test/set-ip-method \
                test/set-nameservers test/set-domains test/find-service \
-               test/get-services test/get-proxy-autoconfig \
+               test/get-services test/get-proxy-autoconfig test/set-proxy \
                test/enable-tethering test/disable-tethering test/backtrace
 
 if TEST
diff --git a/test/set-proxy b/test/set-proxy
new file mode 100755
index 0000000..6b39cb4
--- /dev/null
+++ b/test/set-proxy
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+if (len(sys.argv) < 2):
+       print "Usage:"
+       print "%s <service> direct" % (sys.argv[0])
+       print "%s <service> manual [servers=uri1,uri2,...] 
[excludes=host1,host2,...]" % (sys.argv[0])
+       print "%s <service> auto url=[pac-url]" % (sys.argv[0])
+       print "Example: %s service0 manual servers=proxy.example.com:8080" % 
sys.argv[0]
+       print "         This would set the proxy uri and the method to manual"
+       sys.exit(1)
+
+bus = dbus.SystemBus()
+path = "/profile/default/" + sys.argv[1]
+service = dbus.Interface(bus.get_object('org.moblin.connman', path),
+                                       'org.moblin.connman.Service')
+
+values = { "Method" : sys.argv[2] }
+
+properties = service.GetProperties()
+
+for arg in sys.argv[3:]:
+       if arg.startswith("url="):
+               url = arg.replace("url=", "", 1)
+               values["URL"] = url
+       if arg.startswith("servers="):
+               try:
+                       servers_uris = arg.replace("servers=","",1).split(",")
+               except:
+                       servers_uris = []
+               values["Servers"] = servers_uris
+       if arg.startswith("excludes="):
+               try:
+                       excludes_uris = arg.replace("excludes=","",1).split(",")
+               except:
+                       excludes_uris = []
+               values["Excludes"] = excludes_uris
+
+try:
+       service.SetProperty("Proxy.Configuration", dbus.Dictionary(values, 
signature='sv'))
+except dbus.exceptions.DBusException, e_msg:
+       print e_msg
-- 
1.7.1

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to