Adding support to get buddy's active status
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 21:26:21 +0000 (21:26 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:21 +0000 (17:11 -0400)
Adding support to get buddy's active status

Signed-off-by: Ragner Magalhaes <ragner.magalhaes@indt.org.br>
Acked-by: Bruno Abinader <bruno.abinader@openbossa.org>
Acked-by: Dinorah Monteiro <dinorah.monteiro@openbossa.org>
Acked-by: Ricardo Guimaraes <ricardo.guimaraes@indt.org.br>

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

buddy.pyx

index 843069f..be9f2bd 100644 (file)
--- a/buddy.pyx
+++ b/buddy.pyx
@@ -135,6 +135,30 @@ cdef class Buddy:
             return None
     idle = property(__get_idle)
 
             return None
     idle = property(__get_idle)
 
+    def __get_active_status(self):
+        cdef status.PurpleStatus* c_status = NULL
+        cdef char *type = NULL
+        cdef char *name = NULL
+        cdef char *msg = NULL
+        if self.__exists:
+            active = {}
+            c_status = status.purple_presence_get_active_status( \
+                    blist.purple_buddy_get_presence(self._get_structure()))
+            type = <char *> status.purple_status_get_id(c_status)
+            name = <char *> status.purple_status_get_name(c_status)
+            msg = <char *> status.purple_status_get_attr_string(c_status,
+                "message")
+
+            active['type'] = type
+            active['name'] = name
+            if msg:
+                active['message'] = msg
+
+            return active
+        else:
+            return None
+    active_status = property(__get_active_status)
+
     def set_alias(self, alias):
         if self.__exists:
             blist.purple_blist_alias_buddy(self._get_structure(), alias)
     def set_alias(self, alias):
         if self.__exists:
             blist.purple_blist_alias_buddy(self._get_structure(), alias)