X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=blobdiff_plain;f=proxy.pyx;h=bb03d6dd0a3325ebc5f0e31c04bf3f24aa2ef372;hp=6ae7287a6b8c7f15ee0b548f432f98db466706a2;hb=8a65818786ccf9442ed68927ddb9922465a424b4;hpb=68f379f4cd2276855a1b0cf9e8c26fd4c09002f1 diff --git a/proxy.pyx b/proxy.pyx index 6ae7287..bb03d6d 100644 --- a/proxy.pyx +++ b/proxy.pyx @@ -20,51 +20,63 @@ cimport proxy cdef class ProxyInfoType: - - cdef proxy.PurpleProxyType c_proxyinfotype + cdef proxy.PurpleProxyType c_type def __init__(self): - self.c_proxyinfotype = proxy.PURPLE_PROXY_NONE + self.c_type = proxy.PURPLE_PROXY_NONE + + def get_NONE(self): + self.c_type = proxy.PURPLE_PROXY_NONE + return self + NONE = property(get_NONE) - def USE_GLOBAL(self): - self.c_proxyinfotype = proxy.PURPLE_PROXY_USE_GLOBAL + def get_USE_GLOBAL(self): + self.c_type = proxy.PURPLE_PROXY_USE_GLOBAL return self + USE_GLOBAL = property(get_USE_GLOBAL) - def HTTP(self): - self.c_proxyinfotype = proxy.PURPLE_PROXY_HTTP + def get_HTTP(self): + self.c_type = proxy.PURPLE_PROXY_HTTP return self + HTTP = property(get_HTTP) - def SOCKS4(self): - self.c_proxyinfotype = proxy.PURPLE_PROXY_SOCKS4 + def get_SOCKS4(self): + self.c_type = proxy.PURPLE_PROXY_SOCKS4 return self - def SOCKS5(self): - self.c_proxyinfotype = proxy.PURPLE_PROXY_SOCKS5 + def get_SOCKS5(self): + self.c_type = proxy.PURPLE_PROXY_SOCKS5 return self - def USE_ENVVAR(self): - self.c_proxyinfotype = proxy.PURPLE_PROXY_USE_ENVVAR + def get_USE_ENVVAR (self): + self.c_type = proxy.PURPLE_PROXY_USE_ENVVAR return self + USE_ENVVAR = property(get_USE_ENVVAR) cdef class ProxyInfo: cdef proxy.PurpleProxyInfo *c_proxyinfo def __init__(self): - self.c_proxyinfo = proxy.c_purple_proxy_info_new() + self.c_proxyinfo = NULL def set_type(self, ProxyInfoType type): - proxy.c_purple_proxy_info_set_type(self.c_proxyinfo, type.c_proxyinfotype) + if self.c_proxyinfo: + proxy.c_purple_proxy_info_set_type(self.c_proxyinfo, type.c_type) def set_host(self, char *host): - proxy.c_purple_proxy_info_set_host(self.c_proxyinfo, host) + if self.c_proxyinfo: + 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) + if self.c_proxyinfo: + 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) + if self.c_proxyinfo: + 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) + if self.c_proxyinfo: + proxy.c_purple_proxy_info_set_password(self.c_proxyinfo, password)