Updated add_buddy on Account class.
[python-purple] / account.pyx
index 427d2bd..5656405 100644 (file)
@@ -133,9 +133,10 @@ cdef class Account:
 
                 str_value = <char *> accountopt.purple_account_option_get_default_string(option)
 
-                # Google Talk default domain hackery!
-                if str_value == NULL and str(<char *> label_name) == "Connect server":
-                    str_value = "talk.google.com"
+                # Hack to set string "" as default value to Account options when
+                # the default value of the protocol is NULL
+                if str_value == NULL:
+                    str_value = ""
                 str_value = <char *> account.purple_account_get_string(c_account, setting, str_value)
 
                 val = str(<char *> str_value)
@@ -391,27 +392,24 @@ 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_account(self, username, protocol_id):
-               """
-        Removes as existing account.
 
-        @return True if successful, False if account doesnt exists
+    def remove(self):
         """
-               who = account.purple_accounts_find(username, protocol_id)
-               
-               if who == NULL:
-                       return False
-               else
-                       account.purple_accounts_remove( who )
-                       return True
+        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):
         """
@@ -471,6 +469,10 @@ cdef class Account:
 
             blist.purple_blist_add_buddy(c_buddy, NULL, c_group, NULL)
             account.purple_account_add_buddy(self._get_structure(), c_buddy)
+            if c_alias:
+                blist.purple_blist_alias_buddy(c_buddy, c_alias)
+                server.serv_alias_buddy(c_buddy)
+
             return True
 
         else:
@@ -530,3 +532,11 @@ cdef class Account:
             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)