From 9dba02b95bb6bf55147c51fca9477a3d9ae4b3f0 Mon Sep 17 00:00:00 2001 From: Ragner Magalhaes Date: Tue, 2 Dec 2008 21:20:30 +0000 Subject: [PATCH] Added get/set group. FIXES: - Added get/set group. Signed-off-by: Bruno Abinader Acked-by: Ragner Magalhaes git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1446 596f6dd7-e928-0410-a184-9e12fd12cf7e --- buddy.pyx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/buddy.pyx b/buddy.pyx index 10e88bf..3ccc100 100644 --- a/buddy.pyx +++ b/buddy.pyx @@ -72,6 +72,15 @@ cdef class Buddy: return None alias = property(__get_alias) + def __get_group(self): + cdef blist.PurpleGroup *c_group = NULL + if self.__exists: + c_group = blist.purple_buddy_get_group(self._get_structure()) + return blist.purple_group_get_name(c_group) + else: + return None + group = property(__get_group) + def __get_server_alias(self): cdef char *c_server_alias = NULL c_server_alias = blist.purple_buddy_get_server_alias( \ @@ -132,3 +141,17 @@ cdef class Buddy: return True else: return False + + def set_group(self, group): + cdef blist.PurpleContact *c_contact = NULL + cdef blist.PurpleGroup *c_group = NULL + if self.__exists and group: + c_group = blist.purple_find_group(group) + if c_group == NULL: + c_group = blist.purple_group_new(group) + + c_contact = blist.purple_buddy_get_contact(self._get_structure()) + blist.purple_blist_add_contact(c_contact, c_group, NULL) + return True + else: + return False -- 1.7.9.5