Fixing to use active status when account is idle
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 21:27:37 +0000 (21:27 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:21 +0000 (17:11 -0400)
Fixing to use active status when account is idle

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

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

account.pyx
libpurple/prefs.pxd
libpurple/savedstatuses.pxd

index f70873e..1c21884 100644 (file)
@@ -587,6 +587,7 @@ cdef class Account:
 
     def set_active_status(self, type, msg=None):
         cdef status.PurpleStatusType *c_statustype = NULL
 
     def set_active_status(self, type, msg=None):
         cdef status.PurpleStatusType *c_statustype = NULL
+        cdef savedstatuses.PurpleSavedStatus *c_savedstatus = NULL
 
         if self.__exists:
             if msg:
 
         if self.__exists:
             if msg:
@@ -595,6 +596,22 @@ cdef class Account:
             else:
                 account.purple_account_set_status(self._get_structure(),
                         <char *> type, True, NULL)
             else:
                 account.purple_account_set_status(self._get_structure(),
                         <char *> type, True, NULL)
+
+            # FIXME: We can create only a savedstatus for each statustype
+            c_savedstatus = savedstatuses.purple_savedstatus_find(type)
+            if c_savedstatus == NULL:
+                c_statustype = account.purple_account_get_status_type( \
+                        self._get_structure(), type)
+                c_savedstatus = savedstatuses.purple_savedstatus_new( \
+                        NULL, status.purple_status_type_get_primitive( \
+                                c_statustype))
+                savedstatuses.purple_savedstatus_set_title(c_savedstatus,
+                        type)
+
+            savedstatuses.purple_savedstatus_set_message(c_savedstatus, msg)
+            prefs.purple_prefs_set_int("/purple/savedstatus/idleaway",
+                    savedstatuses.purple_savedstatus_get_creation_time(c_savedstatus))
+
             return True
         else:
             return False
             return True
         else:
             return False
@@ -602,11 +619,27 @@ cdef class Account:
     def set_status_message(self, type, msg):
         cdef status.PurpleStatus* c_status = NULL
         cdef status.PurpleStatusType *c_statustype = NULL
     def set_status_message(self, type, msg):
         cdef status.PurpleStatus* c_status = NULL
         cdef status.PurpleStatusType *c_statustype = NULL
+        cdef savedstatuses.PurpleSavedStatus *c_savedstatus = NULL
 
         if self.__exists and msg:
             c_status = account.purple_account_get_status(self._get_structure(),
                     type)
 
         if self.__exists and msg:
             c_status = account.purple_account_get_status(self._get_structure(),
                     type)
+            if c_status == NULL:
+                return False
             status.purple_status_set_attr_string(c_status, "message", msg)
             status.purple_status_set_attr_string(c_status, "message", msg)
+
+            # FIXME: We can create only a savedstatus for each statustype
+            c_savedstatus = savedstatuses.purple_savedstatus_find(type)
+            if c_savedstatus == NULL:
+                c_statustype = account.purple_account_get_status_type( \
+                        self._get_structure(), type)
+                c_savedstatus = savedstatuses.purple_savedstatus_new( \
+                        NULL, status.purple_status_type_get_primitive( \
+                                c_statustype))
+                savedstatuses.purple_savedstatus_set_title(c_savedstatus,
+                        type)
+
+            savedstatuses.purple_savedstatus_set_message(c_savedstatus, msg)
             return True
         else:
             return False
             return True
         else:
             return False
index 8ad0832..2755518 100644 (file)
@@ -34,3 +34,5 @@ cdef extern from "libpurple/prefs.h":
     void purple_prefs_rename(char *oldname, char *newname)
     char *purple_prefs_get_string(char *name)
     glib.gboolean purple_prefs_load()
     void purple_prefs_rename(char *oldname, char *newname)
     char *purple_prefs_get_string(char *name)
     glib.gboolean purple_prefs_load()
+    void purple_prefs_add_bool(char *name, glib.gboolean value)
+    void purple_prefs_set_int(char *name, int value)
index 7071d2f..3519981 100644 (file)
 #
 
 cimport status
 #
 
 cimport status
+cimport glib
+cimport account
+cimport status
+
+cdef extern from *:
+    ctypedef long int time_t
 
 cdef extern from "libpurple/savedstatuses.h":
     ctypedef struct PurpleSavedStatus:
         pass
 
 
 cdef extern from "libpurple/savedstatuses.h":
     ctypedef struct PurpleSavedStatus:
         pass
 
-    PurpleSavedStatus *c_purple_savedstatus_new "purple_savedstatus_new" (char *title, status.PurpleStatusPrimitive type)
+    PurpleSavedStatus *purple_savedstatus_new(char *title, status.PurpleStatusPrimitive type)
     void c_purple_savedstatus_activate "purple_savedstatus_activate" (PurpleSavedStatus *saved_status)
     void c_purple_savedstatus_activate "purple_savedstatus_activate" (PurpleSavedStatus *saved_status)
+    PurpleSavedStatus *purple_savedstatus_get_current()
+    glib.gboolean purple_savedstatus_is_transient(PurpleSavedStatus *saved_status)
+    void purple_savedstatus_set_substatus(PurpleSavedStatus *status, account.PurpleAccount *account, \
+            status.PurpleStatusType *type, char *message)
+    void purple_savedstatus_set_idleaway(glib.gboolean idleaway)
+    PurpleSavedStatus *purple_savedstatus_find(char *title)
+    PurpleSavedStatus *purple_savedstatus_find_transient_by_type_and_message( \
+            status.PurpleStatusPrimitive type, char *message)
+    void purple_savedstatus_set_message(PurpleSavedStatus *status, char *message)
+    void purple_savedstatus_activate(PurpleSavedStatus *saved_status)
+    void purple_savedstatus_activate_for_account(PurpleSavedStatus *saved_status, \
+            account.PurpleAccount *account)
+    time_t purple_savedstatus_get_creation_time(PurpleSavedStatus *saved_status)
+    void purple_savedstatus_set_title(PurpleSavedStatus *status, char *title)