From: Ragner Magalhaes Date: Wed, 10 Dec 2008 21:29:17 +0000 (+0000) Subject: Adding function get_buddies() X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=commitdiff_plain;h=8c7b1dcaae72cbb229ac09139c7ee7b475276540 Adding function get_buddies() Adding function get_buddies() to return account's buddies list. Signed-off-by: Ragner Magalhaes git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1683 596f6dd7-e928-0410-a184-9e12fd12cf7e --- diff --git a/account.pyx b/account.pyx index 1c21884..85d12d6 100644 --- a/account.pyx +++ b/account.pyx @@ -577,6 +577,35 @@ cdef class Account: else: return None + def get_buddies(self): + """ + @return Account's buddies list + """ + cdef glib.GSList *iter = NULL + cdef blist.PurpleBuddy *c_buddy = NULL + cdef char *c_alias = NULL + + if self.__exists: + iter = blist.purple_find_buddies(self._get_structure(), NULL) + + buddies_list = [] + while iter: + c_alias = NULL + c_buddy = iter.data + + name = blist.purple_buddy_get_name(c_buddy) + new_buddy = Buddy(name, self) + + c_alias = blist.purple_buddy_get_alias_only(c_buddy) + if c_alias: + new_buddy.set_alias(c_alias) + + buddies_list.append(new_buddy) + iter = iter.next + return buddies_list + else: + return None + def request_add_buddy(self, buddy_username, buddy_alias): if buddy_alias: blist.purple_blist_request_add_buddy(self._get_structure(), \