From 3317112f6f04d1fdc7b338b947f18e811c9b9e7e Mon Sep 17 00:00:00 2001 From: Ragner Magalhaes Date: Tue, 2 Dec 2008 20:19:12 +0000 Subject: [PATCH] Get buddies function Get buddies function Signed-off-by: Dinorah Monteiro git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1294 596f6dd7-e928-0410-a184-9e12fd12cf7e --- account.pxd | 13 +++++++++++++ nullclient.py | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/account.pxd b/account.pxd index cafdf07..b5c765f 100644 --- a/account.pxd +++ b/account.pxd @@ -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 = 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 diff --git a/nullclient.py b/nullclient.py index c9e1953..2b7dd70 100644 --- a/nullclient.py +++ b/nullclient.py @@ -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() -- 1.7.9.5