X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=blobdiff_plain;f=account.pyx;h=5935ba914268f4d140c41d984086ae840060262b;hp=1c21884088e9fb776fced2be9bfd2e30e727d9da;hb=7752e0f4a14a32ede02b8b86c83d9510338a59ed;hpb=b6228086f86fb49fb290e50f7a143a687b7d3fff diff --git a/account.pyx b/account.pyx index 1c21884..5935ba9 100644 --- a/account.pyx +++ b/account.pyx @@ -228,8 +228,8 @@ cdef class Account: cdef char *id = NULL cdef char *name = NULL + status_types = [] if self.__exists: - status_types = [] iter = account.purple_account_get_status_types(self._get_structure()) while iter: c_statustype = iter.data @@ -237,9 +237,8 @@ cdef class Account: name = status.purple_status_type_get_name(c_statustype) status_types.append((id, name)) iter = iter.next - return status_types - else: - return None + + return status_types status_types = property(__get_status_types) @@ -328,7 +327,7 @@ cdef class Account: sett = str( setting) - if not po.has_key(sett): + if sett not in po: iter = iter.next continue @@ -552,11 +551,11 @@ cdef class Account: cdef blist.PurpleBuddy *c_buddy = NULL cdef char *c_alias = NULL + buddies_list = [] if self.__exists and \ account.purple_account_is_connected(self._get_structure()): iter = blist.purple_find_buddies(self._get_structure(), NULL) - buddies_list = [] while iter: c_alias = NULL c_buddy = iter.data @@ -573,9 +572,36 @@ cdef class Account: buddies_list.append(new_buddy) iter = iter.next - return buddies_list - else: - return None + + return buddies_list + + 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 + + buddies_list = [] + if self.__exists: + iter = blist.purple_find_buddies(self._get_structure(), NULL) + + 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 def request_add_buddy(self, buddy_username, buddy_alias): if buddy_alias: