Add class ProxyInfo
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:23:39 +0000 (20:23 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:10 +0000 (17:11 -0400)
Add new class ProxyInfo to allow you config the account's proxy

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@1299 596f6dd7-e928-0410-a184-9e12fd12cf7e

libpurple/proxy.pxd
proxy.pyx [new file with mode: 0644]
purple.pyx

index 4644913..24c655f 100644 (file)
 #
 
 cdef extern from "libpurple/proxy.h":
 #
 
 cdef extern from "libpurple/proxy.h":
-    cdef struct PurpleProxyInfo
 
 
-    ctypedef int PurpleProxyType
+    ctypedef enum PurpleProxyType:
+        PURPLE_PROXY_USE_GLOBAL
+        PURPLE_PROXY_NONE
+        PURPLE_PROXY_HTTP
+        PURPLE_PROXY_SOCKS4
+        PURPLE_PROXY_SOCKS5
+        PURPLE_PROXY_USE_ENVVAR
+
+    ctypedef struct PurpleProxyInfo:
+        char *host
+        int   port
+        char *username
+        char *password
 
     PurpleProxyInfo *c_purple_proxy_info_new "purple_proxy_info_new" ()
 
     PurpleProxyInfo *c_purple_proxy_info_new "purple_proxy_info_new" ()
-    void c_purple_proxy_info_set_type "purple_proxy_info_set_type" (PurpleProxyInfo *info, PurpleProxyType type)
-    void c_purple_proxy_info_set_host "purple_proxy_info_set_host" (char *host)
-    void c_purple_proxy_info_set_port "purple_proxy_info_set_port" (char *port)
+    void c_purple_proxy_info_destroy "purple_proxy_info_destroy"        \
+    (PurpleProxyInfo *info)
+    void c_purple_proxy_info_set_type "purple_proxy_info_set_type"      \
+    (PurpleProxyInfo *info, PurpleProxyType type)
+    PurpleProxyType c_purple_proxy_info_get_type "purple_proxy_info_get_type" \
+    (PurpleProxyInfo *info)
+    void c_purple_proxy_info_set_host "purple_proxy_info_set_host"      \
+    (PurpleProxyInfo *info, char *host)
+    void c_purple_proxy_info_set_port "purple_proxy_info_set_port"      \
+    (PurpleProxyInfo *info, int port)
+    void c_purple_proxy_info_set_username "purple_proxy_info_set_username" \
+    (PurpleProxyInfo *info, char *username)
+    void c_purple_proxy_info_set_password "purple_proxy_info_set_password" \
+    (PurpleProxyInfo *info, char *password)
+
diff --git a/proxy.pyx b/proxy.pyx
new file mode 100644 (file)
index 0000000..6ae7287
--- /dev/null
+++ b/proxy.pyx
@@ -0,0 +1,70 @@
+#
+#  Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
+#
+#  This file is part of python-purple.
+#
+#  python-purple is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  python-purple is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+cimport proxy
+
+cdef class ProxyInfoType:
+
+    cdef proxy.PurpleProxyType c_proxyinfotype
+
+    def __init__(self):
+        self.c_proxyinfotype = proxy.PURPLE_PROXY_NONE
+
+    def USE_GLOBAL(self):
+        self.c_proxyinfotype = proxy.PURPLE_PROXY_USE_GLOBAL
+        return self
+
+    def HTTP(self):
+        self.c_proxyinfotype = proxy.PURPLE_PROXY_HTTP
+        return self
+
+    def SOCKS4(self):
+        self.c_proxyinfotype = proxy.PURPLE_PROXY_SOCKS4
+        return self
+
+    def SOCKS5(self):
+        self.c_proxyinfotype = proxy.PURPLE_PROXY_SOCKS5
+        return self
+
+    def USE_ENVVAR(self):
+        self.c_proxyinfotype = proxy.PURPLE_PROXY_USE_ENVVAR
+        return self
+
+cdef class ProxyInfo:
+
+    cdef proxy.PurpleProxyInfo *c_proxyinfo
+
+    def __init__(self):
+        self.c_proxyinfo = proxy.c_purple_proxy_info_new()
+
+    def set_type(self, ProxyInfoType type):
+        proxy.c_purple_proxy_info_set_type(self.c_proxyinfo, type.c_proxyinfotype)
+
+    def set_host(self, char *host):
+        proxy.c_purple_proxy_info_set_host(self.c_proxyinfo, host)
+
+    def set_port(self, int port):
+        proxy.c_purple_proxy_info_set_port(self.c_proxyinfo, port)
+
+    def set_username(self, char *username):
+        proxy.c_purple_proxy_info_set_username(self.c_proxyinfo, username)
+
+    def set_password(self, char *password):
+        proxy.c_purple_proxy_info_set_password(self.c_proxyinfo, password)
+
index 29594c0..79e553a 100644 (file)
@@ -158,6 +158,7 @@ cdef class Purple:
         conn = Connection()
         conn.connect()
 
         conn = Connection()
         conn.connect()
 
+include "proxy.pyx"
 include "account.pyx"
 include "buddy.pyx"
 include "connection.pyx"
 include "account.pyx"
 include "buddy.pyx"
 include "connection.pyx"