"/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
--- a/mcabber/src/jabglue.c Mon Nov 14 22:15:25 2005 +0100
+++ b/mcabber/src/jabglue.c Sat Nov 19 16:30:49 2005 +0100
@@ -321,16 +321,32 @@
strprio, (unsigned) -1);
}
- if (!msg)
- msg = settings_get_status_msg(st);
+ if (msg) {
+ // The status message has been specified. We'll use it, unless it is
+ // "-" which is a special case (option meaning "no status message").
+ if (!strcmp(msg, "-"))
+ msg = "";
+ } else {
+ // No status message specified; we'll use:
+ // a) the default status message (if provided by the user);
+ // b) the current status message;
+ // c) no status message (i.e. an empty one).
+ msg = settings_get_status_msg(st);
+ if (!msg) {
+ if (mystatusmsg)
+ msg = mystatusmsg;
+ else
+ msg = "";
+ }
+ }
utf8_msg = to_utf8(msg);
xmlnode_insert_cdata(xmlnode_insert_tag(x, "status"), utf8_msg,
(unsigned) -1);
jab_send(jc, x);
+ g_free(utf8_msg);
xmlnode_free(x);
- g_free(utf8_msg);
// If we didn't change our _global_ status, we are done
if (recipient) return;
@@ -345,9 +361,14 @@
hk_mystatuschange(0, mystatus, st, msg);
mystatus = st;
- if (mystatusmsg) g_free(mystatusmsg);
- if (msg) mystatusmsg = g_strdup(msg);
- else mystatusmsg = NULL;
+ if (msg != mystatusmsg) {
+ if (mystatusmsg)
+ g_free(mystatusmsg);
+ if (*msg)
+ mystatusmsg = g_strdup(msg);
+ else
+ mystatusmsg = NULL;
+ }
}
void jb_send_msg(const char *jid, const char *text, int type,
--- 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;
+ }
}
}
--- a/mcabber/src/settings.c Mon Nov 14 22:15:25 2005 +0100
+++ b/mcabber/src/settings.c Sat Nov 19 16:30:49 2005 +0100
@@ -298,8 +298,7 @@
// return this message
// - if there is a user-defined message for the given status (and no
// generic user message), it is returned
-// - if no user-defined message is found, return the mcabber default msg
-// - if there is no default (offline, invisible), return an empty string
+// - if no message is found, return NULL
const gchar *settings_get_status_msg(enum imstatus status)
{
const gchar *rstatus = settings_opt_get("message");
@@ -308,32 +307,27 @@
switch(status) {
case available:
- if ((rstatus = settings_opt_get("message_avail")) == NULL)
- rstatus = MSG_AVAIL;
+ rstatus = settings_opt_get("message_avail");
break;
case freeforchat:
- if ((rstatus = settings_opt_get("message_free")) == NULL)
- rstatus = MSG_FREE;
+ rstatus = settings_opt_get("message_free");
break;
case dontdisturb:
- if ((rstatus = settings_opt_get("message_dnd")) == NULL)
- rstatus = MSG_DND;
+ rstatus = settings_opt_get("message_dnd");
break;
case notavail:
- if ((rstatus = settings_opt_get("message_notavail")) == NULL)
- rstatus = MSG_NOTAVAIL;
+ rstatus = settings_opt_get("message_notavail");
break;
case away:
- if ((rstatus = settings_opt_get("message_away")) == NULL)
- rstatus = MSG_AWAY;
+ rstatus = settings_opt_get("message_away");
break;
- default:
- rstatus = "";
+ default: // offline, invisible
+ break;
}
return rstatus;
}
--- a/mcabber/src/settings.h Mon Nov 14 22:15:25 2005 +0100
+++ b/mcabber/src/settings.h Sat Nov 19 16:30:49 2005 +0100
@@ -11,15 +11,6 @@
#endif
-/* Default status messages */
-#define MSG_AVAIL "I'm here!"
-#define MSG_FREE "Free for chat"
-#define MSG_DND "Busy"
-#define MSG_NOTAVAIL "Not available"
-#define MSG_AWAY "Away"
-#define MSG_AUTOAWAY "Auto away status (idle)"
-
-
#define SETTINGS_TYPE_OPTION 1
#define SETTINGS_TYPE_ALIAS 2
#define SETTINGS_TYPE_BINDING 3