Added get/set group.
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 21:20:30 +0000 (21:20 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:20 +0000 (17:11 -0400)
FIXES:
 - Added get/set group.

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

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

buddy.pyx

index 10e88bf..3ccc100 100644 (file)
--- a/buddy.pyx
+++ b/buddy.pyx
@@ -72,6 +72,15 @@ cdef class Buddy:
             return None
     alias = property(__get_alias)
 
             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 <char *> 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 = <char *> blist.purple_buddy_get_server_alias( \
     def __get_server_alias(self):
         cdef char *c_server_alias = NULL
         c_server_alias = <char *> blist.purple_buddy_get_server_alias( \
@@ -132,3 +141,17 @@ cdef class Buddy:
             return True
         else:
             return False
             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