Adding function get_types to ProxyInfo class
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:54:26 +0000 (20:54 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:14 +0000 (17:11 -0400)
Adding function get_types to ProxyInfo class
to return all proxy types as string

Signed-off-by: Ragner Magalhaes <ragner.magalhaes@indt.org.br>

git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1370 596f6dd7-e928-0410-a184-9e12fd12cf7e

proxy.pyx

index 54fca86..453922c 100644 (file)
--- a/proxy.pyx
+++ b/proxy.pyx
@@ -56,10 +56,19 @@ cdef class ProxyInfoType:
 cdef class ProxyInfo:
 
     cdef proxy.PurpleProxyInfo *c_proxyinfo
 cdef class ProxyInfo:
 
     cdef proxy.PurpleProxyInfo *c_proxyinfo
+    cdef object types
 
     def __init__(self):
         self.c_proxyinfo = NULL
 
 
     def __init__(self):
         self.c_proxyinfo = NULL
 
+        self.types = {"HTTP": proxy.PURPLE_PROXY_HTTP,
+                "USER_GLOBAL": proxy.PURPLE_PROXY_USE_GLOBAL,
+                "USE_ENVVAR": proxy.PURPLE_PROXY_USE_ENVVAR,
+                "SOCKS4": proxy.PURPLE_PROXY_SOCKS4,
+                "SOCKS5": proxy.PURPLE_PROXY_SOCKS5,
+                "NONE": proxy.PURPLE_PROXY_NONE}
+
+
     def set_type(self, ProxyInfoType type):
         if self.c_proxyinfo:
             proxy.c_purple_proxy_info_set_type(self.c_proxyinfo, type.c_type)
     def set_type(self, ProxyInfoType type):
         if self.c_proxyinfo:
             proxy.c_purple_proxy_info_set_type(self.c_proxyinfo, type.c_type)
@@ -80,3 +89,6 @@ cdef class ProxyInfo:
         if self.c_proxyinfo:
             proxy.c_purple_proxy_info_set_password(self.c_proxyinfo, password)
 
         if self.c_proxyinfo:
             proxy.c_purple_proxy_info_set_password(self.c_proxyinfo, password)
 
+    def get_types(self):
+        return self.types.keys()
+