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

diff --git a/Makefile.am b/Makefile.am
index 1bf7207..128d4b8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -179,7 +179,8 @@ test_scripts = test/get-state test/list-profiles 
test/list-services \
                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/enable-tethering test/disable-tethering test/backtrace
+               test/enable-tethering test/disable-tethering test/backtrace \
+               test/set-proxy
 
 if TEST
 testdir = $(pkglibdir)/test
diff --git a/test/set-proxy b/test/set-proxy
new file mode 100755
index 0000000..35a4bf1
--- /dev/null
+++ b/test/set-proxy
@@ -0,0 +1,74 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+if (len(sys.argv) < 2):
+       print "Usage: %s <service> [direct|auto|manual|auto-config] 
[url=pac-url] [http=host:port] [https=host:port] [ftp=host:port] 
[socks=host:port] [rtsp=host:port] [ignore=host1,host2,...]" % (sys.argv[0])
+       print "Example: %s service0 manual http=http.proxy.example.com:8080 
rtsp=" % sys.argv[0]
+       print "         This would set the http proxy and clear the rtsp proxy 
values"
+       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 = {}
+values["Method"] = sys.argv[2]
+
+properties = service.GetProperties()
+
+for arg in sys.argv[3:]:
+       if arg.startswith("url="):
+               url = arg.replace("url=", "", 1)
+               #print "url: %s" % url
+               values["URL"] = url
+       if arg.startswith("http="):
+               try:
+                       (host, port) = arg.replace("http=","",1).split(":")
+               except:
+                       (host, port) = ("", 0)
+               #print "http: %s:%s" % (host, port)
+               values["Http"] = host
+               values["HttpPort"] = dbus.UInt16(port)
+       if arg.startswith("https="):
+               try:
+                       (host, port) = arg.replace("https=","",1).split(":")
+               except:
+                       (host, port) = ("", 0)
+               #print "https: %s:%s" % (host, port)
+               values["Https"] = host
+               values["HttpsPort"] = dbus.UInt16(port)
+       if arg.startswith("ftp="):
+               try:
+                       (host, port) = arg.replace("ftp=","",1).split(":")
+               except:
+                       (host, port) = ("", 0)
+               #print "ftp: %s:%s" % (host, port)
+               values["Ftp"] = host
+               values["FtpPort"] = dbus.UInt16(port)
+       if arg.startswith("socks="):
+               try:
+                       (host, port) = arg.replace("socks=","",1).split(":")
+               except:
+                       (host, port) = ("", 0)
+               #print "socks: %s:%s" % (host, port)
+               values["Socks"] = host
+               values["SocksPort"] = dbus.UInt16(port)
+       if arg.startswith("rtsp="):
+               try:
+                       (host, port) = arg.replace("rtsp=","",1).split(":")
+               except:
+                       (host, port) = ("", 0)
+               #print "rtsp: %s:%s" % (host, port)
+               values["Rtsp"] = host
+               values["RtspPort"] = dbus.UInt16(port)
+       if arg.startswith("ignore="):
+               try:
+                       ignore_hosts = arg.replace("ignore=","",1).split(",")
+               except:
+                       ignore_hosts = []
+               #print "ignore: %s" % ignore_hosts
+               values["Ignore"] = ignore_hosts
+
+service.SetProperty("Proxy.Configuration", dbus.Dictionary(values, signature = 
"sv"))
-- 
1.7.0.4

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to