cdef plugin.PurplePlugin *c_plugin
cdef prpl.PurplePluginProtocolInfo *c_prpl_info
cdef plugin.PurplePluginInfo *c_plugin_info
-
cdef savedstatuses.PurpleSavedStatus *__sstatus
+ cdef ProxyInfo __proxy
def __init__(self, char *username, char *protocol_id):
+ cdef proxy.PurpleProxyInfo *c_proxyinfo
self.__account = account.c_purple_account_new(username, protocol_id)
self.c_plugin = plugin.c_purple_plugins_find_with_id(protocol_id)
self.c_prpl_info = plugin.c_PURPLE_PLUGIN_PROTOCOL_INFO(self.c_plugin)
+ c_proxyinfo = account.c_purple_account_get_proxy_info(self.__account)
+ if c_proxyinfo == NULL:
+ c_proxyinfo = proxy.c_purple_proxy_info_new()
+ proxy.c_purple_proxy_info_set_type(c_proxyinfo, proxy.PURPLE_PROXY_NONE)
+ account.c_purple_account_set_proxy_info(self.__account, c_proxyinfo)
+ self.__proxy = ProxyInfo()
+ self.__proxy.c_proxyinfo = c_proxyinfo
+
def set_password(self, password):
account.c_purple_account_set_password(self.__account, password)
self.__sstatus = savedstatuses.c_purple_savedstatus_new(NULL, status.PURPLE_STATUS_AVAILABLE)
savedstatuses.c_purple_savedstatus_activate(self.__sstatus)
+ def get_proxy(self):
+ return self.__proxy
+
+ proxy = property(get_proxy)
+
def get_buddies_online(self):
cdef glib.GSList *iter
cdef blist.PurpleBuddy *buddy
iter = iter.next
return buddies
- def get_proxyinfo(self):
- cdef proxy.PurpleProxyInfo *c_proxyinfo
- c_proxyinfo = account.c_purple_account_get_proxy_info(self.__account)
- if c_proxyinfo == NULL:
- return None
- cdef ProxyInfo proxyinfo
- proxyinfo = proxy.ProxyInfo()
- proxyinfo.c_proxyinfo = c_proxyinfo
- return proxyinfo
-
- def set_proxyinfo(self, ProxyInfo proxyinf):
- account.c_purple_account_set_proxy_info(self.__account, proxyinf.c_proxyinfo)
-
def get_protocol_options(self):
''' FIXME: It is just a hack, to set the XMPP's options. '''
cdef glib.GList *iter
self.account = purple.Account(username, protocol.get_id())
self.account.set_password(password)
- proxy = self.account.get_proxyinfo()
- if proxy is None:
- print "None"
- proxy = purple.ProxyInfo()
- proxy.cnew()
-
- proxy.set_type(purple.ProxyInfoType().HTTP())
- proxy.set_host("172.18.216.211")
- proxy.set_port(8080)
-
- self.account.set_proxyinfo(proxy)
+ self.account.proxy.set_type(purple.ProxyInfoType().HTTP)
+ self.account.proxy.set_host("172.18.216.211")
+ self.account.proxy.set_port(8080)
self.account.get_protocol_options()
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:
def __init__(self):
self.c_proxyinfo = NULL
- def cnew(self):
- if self.c_proxyinfo == NULL:
- self.c_proxyinfo = proxy.c_purple_proxy_info_new()
-
def set_type(self, ProxyInfoType type):
if self.c_proxyinfo:
- proxy.c_purple_proxy_info_set_type(self.c_proxyinfo, type.c_proxyinfotype)
+ proxy.c_purple_proxy_info_set_type(self.c_proxyinfo, type.c_type)
def set_host(self, char *host):
if self.c_proxyinfo: