diff mcabber/src/screen.c @ 521:cc8c969ab6e5

"/status" changes - No hardcoded status message - If there is no user-defined status message, the current message is kept - "/status $status -" clears the status message - Auto-away improvement
author Mikael Berthe <mikael@lilotux.net>
date Sat, 19 Nov 2005 16:30:49 +0100
parents 9480a76471b6
children ffdfddd351b8
line wrap: on
line diff
--- a/mcabber/src/screen.c	Mon Nov 14 22:15:25 2005 +0100
+++ b/mcabber/src/screen.c	Sat Nov 19 16:30:49 2005 +0100
@@ -840,17 +840,30 @@
 void inline set_autoaway(bool setaway)
 {
   static enum imstatus oldstatus;
+  static char *oldmsg;
   Autoaway = setaway;
 
   if (setaway) {
-    const char *msg;
+    const char *msg, *prevmsg;
     oldstatus = jb_getstatus();
+    if (oldmsg) {
+      g_free(oldmsg);
+      oldmsg = NULL;
+    }
+    prevmsg = jb_getstatusmsg();
     msg = settings_opt_get("message_autoaway");
-    if (!msg) msg = MSG_AUTOAWAY;
+    if (!msg)
+      msg = prevmsg;
+    if (prevmsg)
+      oldmsg = g_strdup(prevmsg);
     jb_setstatus(away, NULL, msg);
   } else {
     // Back
-    jb_setstatus(oldstatus, NULL, NULL);
+    jb_setstatus(oldstatus, NULL, (oldmsg ? oldmsg : ""));
+    if (oldmsg) {
+      g_free(oldmsg);
+      oldmsg = NULL;
+    }
   }
 }