From: Ragner Magalhaes Date: Tue, 2 Dec 2008 21:20:30 +0000 (+0000) Subject: Added get/set group. X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=commitdiff_plain;h=9dba02b95bb6bf55147c51fca9477a3d9ae4b3f0 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 --- 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