X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=blobdiff_plain;f=account.pyx;h=7240de2620309b7260ade83fc3aaa29c78c61d1f;hp=407dc4ec8c3c1abd9ae3b6b7f39b3dfb61df4724;hb=e46b731142ce1fc0bad91a0391c1358c5e2d6405;hpb=5f1088fe97ce236fcb720c47d4a1122cb9bca8ec diff --git a/account.pyx b/account.pyx index 407dc4e..7240de2 100644 --- a/account.pyx +++ b/account.pyx @@ -391,14 +391,25 @@ cdef class Account: if self.__exists: return False else: - # FIXME: Using purple_accounts_add(...) to save to xml - # I think we could improve this .. account.purple_accounts_add(account.purple_account_new( \ self.__username, self.__protocol.id)) self.__exists = True return True + def remove(self): + """ + Removes an existing account. + + @return True if successful, False if account doesn't exists + """ + if self.__exists: + account.purple_accounts_delete(self._get_structure()) + self__exists = False + return True + else: + return False + def connect(self): """ Connects to an account. @@ -505,14 +516,22 @@ cdef class Account: blist.purple_buddy_get_presence(c_buddy)): 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 == NULL: - alias = None - else: - alias = c_alias + if c_alias: + new_buddy.set_alias(c_alias) - buddies_list.append((name, 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(), \ + buddy_username, NULL, buddy_alias) + else: + blist.purple_blist_request_add_buddy(self._get_structure(), \ + buddy_username, NULL, NULL)