Adding function accounts_get_all() to Purple class
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 21:08:54 +0000 (21:08 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:18 +0000 (17:11 -0400)
Adding function accounts_get_all() to Purple class to return
all accounts

Signed-off-by: Ragner Magalhaes <ragner.magalhaes@indt.org.br>
Acked-by: Bruno Abinader <bruno.abinader@indt.org.br>
Acked-by: Dinorah Monteiro <dinorah.monteiro@indt.org.br>

git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1412 596f6dd7-e928-0410-a184-9e12fd12cf7e

purple.pyx

index 96a5241..6a269cd 100644 (file)
@@ -352,6 +352,28 @@ cdef class Purple:
         else:
             return None
 
         else:
             return None
 
+    def accounts_get_all(self):
+        cdef glib.GList *iter
+        cdef account.PurpleAccount *acc
+        cdef char *username
+        cdef char *protocol_id
+
+        iter = account.purple_accounts_get_all()
+        account_list = []
+
+        while iter:
+            acc = <account.PurpleAccount *> iter.data
+
+            if <account.PurpleAccount *>acc:
+                username = <char *> account.purple_account_get_username(acc)
+                protocol_id = <char *> account.purple_account_get_protocol_id(acc)
+
+                if username != NULL and protocol_id != NULL:
+                    account_list.append(Account(username, protocol_id))
+            iter = iter.next
+
+        return account_list
+
 include "plugin.pyx"
 include "proxy.pyx"
 #include "protocol.pyx"
 include "plugin.pyx"
 include "proxy.pyx"
 #include "protocol.pyx"