Updated remove_account
[python-purple] / account.pyx
index 407dc4e..0ae93fd 100644 (file)
@@ -391,13 +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 as existing account.
+
+        @return True if successful, False if account doesnt exists
+        """
+               if self.__exists:
+                       account.purple_accounts_remove(self._get_structure())
+                       
+                       self__exists = False
+                       return True
+               else:
+                       return False
 
     def connect(self):
         """
@@ -505,13 +517,13 @@ cdef class Account:
                                 blist.purple_buddy_get_presence(c_buddy)):
                     name = <char *> blist.purple_buddy_get_name(c_buddy)
 
+                    new_buddy = Buddy(name, self)
+
                     c_alias = <char *> 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: