X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=blobdiff_plain;f=account.pyx;h=d720910c894d29457a221eb1933dd56cee59e883;hp=cafdf0704136c64ab1924d1cc10161f0ba05702e;hb=6ad4afacade908a5195e9b0e12c118d62e8a53ae;hpb=7f9bbfa5e0f087ba5a5c1367ab1bea72f53573d0 diff --git a/account.pyx b/account.pyx index cafdf07..d720910 100644 --- a/account.pyx +++ b/account.pyx @@ -17,52 +17,57 @@ # along with this program. If not, see . # -class ProxyType: - def __init__(self): - self.PROXY_USE_GLOBAL = -1 - self.PROXY_NONE = 0 - self.PROXY_HTTP = 1 - self.PROXY_SOCKS4 = 2 - self.PROXY_SOCKS5 = 3 - self.PROXY_USE_ENVVAR = 4 - - -class StatusPrimitive: - def __init__(self): - self.STAUTS_UNSET = 0 - self.STATUS_OFFLINE = 1 - self.STATUS_AVAILABLE = 2 - self.STATUS_UNAVAILABLE = 3 - self.STATUS_INVISIBLE = 4 - self.STATUS_AWAY = 5 - self.STATUS_EXTENDED_AWAY = 6 - self.STATUS_MOBILE = 7 - self.STATUS_TUNE = 8 - self.STATUS_NUN_PRIMITIVE = 9 +cimport purple cdef class Account: """ Account class """ - cdef PurpleAccount *__account - cdef PurpleSavedStatus *__sstatus + cdef account.PurpleAccount *__account + cdef savedstatuses.PurpleSavedStatus *__sstatus - def __cinit__(self, const_char_ptr username, const_char_ptr protocol_id): - self.__account = c_purple_account_new(username, protocol_id) + def __init__(self, char *username, char *protocol_id): + self.__account = account.c_purple_account_new(username, protocol_id) def set_password(self, password): - c_purple_account_set_password(self.__account, password) + account.c_purple_account_set_password(self.__account, password) def set_enabled(self, ui, value): - c_purple_account_set_enabled(self.__account, ui, value) + account.c_purple_account_set_enabled(self.__account, ui, value) def get_acc_username(self): if self.__account: - return c_purple_account_get_username(self.__account) + return account.c_purple_account_get_username(self.__account) def get_password(self): if self.__account: - return c_purple_account_get_password(self.__account) + return account.c_purple_account_get_password(self.__account) def set_status(self): - self.__sstatus = c_purple_savedstatus_new(NULL, StatusPrimitive().STATUS_AVAILABLE) - c_purple_savedstatus_activate(self.__sstatus) + self.__sstatus = savedstatuses.c_purple_savedstatus_new(NULL, status.PURPLE_STATUS_AVAILABLE) + savedstatuses.c_purple_savedstatus_activate(self.__sstatus) + + def get_buddies_online(self): + cdef glib.GSList *iter + cdef blist.PurpleBuddy *buddy + buddies = [] + iter = blist.c_purple_find_buddies(self.__account, NULL) + while iter: + buddy = iter.data + if buddy and \ + account.c_purple_account_is_connected(blist.c_purple_buddy_get_account(buddy)) and \ + status.c_purple_presence_is_online(blist.c_purple_buddy_get_presence(buddy)): + buddies += [buddy.name] + 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)