X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=blobdiff_plain;f=proxy.pyx;h=f02cd9784abe2ef8d77dda3970ab035fcda6ca0d;hp=49e83d2b28d4103f80b05c305d7b4398fc46aae8;hb=refs%2Fheads%2Fmaster;hpb=021d4a85455e3ba21d843f8f7917ae49b69a7cdd;ds=sidebyside diff --git a/proxy.pyx b/proxy.pyx index 49e83d2..f02cd97 100644 --- a/proxy.pyx +++ b/proxy.pyx @@ -17,7 +17,8 @@ # along with this program. If not, see . # -cimport purple +cimport account +cimport proxy cdef class ProxyInfoType: cdef proxy.PurpleProxyType c_type @@ -99,34 +100,36 @@ cdef class ProxyInfo: cdef account.PurpleAccount *c_account cdef proxy.PurpleProxyInfo *c_proxyinfo - c_account = account.c_purple_accounts_find(acc[0], acc[1]) + c_account = account.purple_accounts_find(acc[0], acc[1]) if c_account == NULL: #FIXME: Message error or call a callback handle to error return False - c_proxyinfo = account.c_purple_account_get_proxy_info(c_account) + c_proxyinfo = account.purple_account_get_proxy_info(c_account) + if c_proxyinfo == NULL: + c_proxyinfo = proxy.c_purple_proxy_info_new() + account.purple_account_set_proxy_info(c_account, c_proxyinfo) - if info.has_key('type'): + if 'type' in info and info['type']: type = info['type'] - if not type in self.types.keys(): - #FIXME: Message error or call a callback handle to error - return False + if not type in self.types: + type = 'HTTP' proxy.c_purple_proxy_info_set_type(c_proxyinfo, self.types[type]) - if info.has_key('host'): + if 'host' in info and info['host']: host = info['host'] proxy.c_purple_proxy_info_set_host(c_proxyinfo, host) - if info.has_key('port'): + if 'port' in info and info['port']: port = int(info['port']) proxy.c_purple_proxy_info_set_port(c_proxyinfo, port) - if info.has_key('username'): + if 'username' in info and info['username']: username = info['username'] proxy.c_purple_proxy_info_set_username(c_proxyinfo, username) - if info.has_key('password'): + if 'password' in info and info['password']: password = info['password'] proxy.c_purple_proxy_info_set_password(c_proxyinfo, password)