X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=blobdiff_plain;f=proxy.pyx;h=cb248230666527804a1eff14cfd6aba25dec038b;hp=2948e159b81955cd8ba34be262cfadc65061a4c8;hb=950aceade8cf4d56fe405e29fefbb28204a7592c;hpb=b9ad0ad08cdd1ddd60d74570d222aa9c47e439d4 diff --git a/proxy.pyx b/proxy.pyx index 2948e15..cb24823 100644 --- a/proxy.pyx +++ b/proxy.pyx @@ -95,7 +95,7 @@ cdef class ProxyInfo: def set_info(self, acc, info): ''' @param acc Tuple (username, protocol id) ''' ''' @param info Dictionary {'type': "HTTP", 'port': "1234", ''' - ''' 'username': "foo", 'passworld': "foo123"} ''' + ''' 'host': "1.2.3.4", 'username': "foo", 'passworld': "foo123"} ''' cdef account.PurpleAccount *c_account cdef proxy.PurpleProxyInfo *c_proxyinfo @@ -106,24 +106,30 @@ cdef class ProxyInfo: return False c_proxyinfo = account.c_purple_account_get_proxy_info(c_account) + if c_proxyinfo == NULL: + c_proxyinfo = proxy.c_purple_proxy_info_new() + account.c_purple_account_set_proxy_info(c_account, c_proxyinfo) - if info.has_key('type'): + if info.has_key('type') 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 + type = 'HTTP' proxy.c_purple_proxy_info_set_type(c_proxyinfo, self.types[type]) - if info.has_key('port'): + if info.has_key('host') and info['host']: + host = info['host'] + proxy.c_purple_proxy_info_set_host(c_proxyinfo, host) + + if info.has_key('port') and info['port']: port = int(info['port']) proxy.c_purple_proxy_info_set_port(c_proxyinfo, port) - if info.has_key('username'): + if info.has_key('username') and info['username']: username = info['username'] proxy.c_purple_proxy_info_set_username(c_proxyinfo, username) - if info.has_key('password'): + if info.has_key('password') and info['password']: password = info['password'] proxy.c_purple_proxy_info_set_password(c_proxyinfo, password) - + return True