Get buddies function
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:19:12 +0000 (20:19 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:10 +0000 (17:11 -0400)
Get buddies function

Signed-off-by: Dinorah Monteiro <dinorah.monteiro@indt.org.br>

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

account.pxd
nullclient.py

index cafdf07..b5c765f 100644 (file)
@@ -66,3 +66,16 @@ cdef class Account:
         self.__sstatus = c_purple_savedstatus_new(NULL, StatusPrimitive().STATUS_AVAILABLE)
         c_purple_savedstatus_activate(self.__sstatus)
 
+    def get_buddies_online(self, account):
+        cdef GSList *iter
+        cdef PurpleBuddy *buddy
+        buddies = []
+        iter = c_purple_find_buddies(self.__account, NULL)
+        while iter:
+            buddy = <PurpleBuddy *>iter.data
+            if buddy and \
+                c_purple_account_is_connected(c_purple_buddy_get_account(buddy)) and \
+                c_purple_presence_is_online(c_purple_buddy_get_presence(buddy)):
+                buddies += [buddy.name]
+            iter = iter.next
+        return buddies
index c9e1953..2b7dd70 100644 (file)
@@ -24,6 +24,10 @@ class NullClient:
         self.account.set_password(password)
         self.account.set_enabled("carman-purple-python", True)
 
+    def get_buddies(self, account):
+        buddies = account.get_buddies_online(account)
+        print buddies
+
 def getuser():
     sys.stdout.write("GTalk account: ")
     username = sys.stdin.readline()
@@ -42,4 +46,5 @@ if __name__ == '__main__':
     client.new_account(username, client.protocol, password)
 
     client.p.connect()
+    ecore.timer_add(30, client.get_buddies, client.account)
     ecore.main_loop_begin()