Mercurial > hg
diff mcabber/src/jabglue.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 | 5c338d31de56 |
children | fc6bc26f891e |
line wrap: on
line diff
--- 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,