Mercurial > hg
changeset 1896:c5ab9cf3819a
[MUC] Fix handling of empty room topic
lm_message_node_get_child_value() didn't make any difference between a missing
node and an empty one. With this patch it will return "" if the node exists but
has no value.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 12 Apr 2010 20:50:19 +0200 |
parents | 7043542b3565 |
children | efd7c4c34ff2 |
files | mcabber/mcabber/xmpp.c mcabber/mcabber/xmpp_helper.c |
diffstat | 2 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mcabber/mcabber/xmpp.c Sun Apr 11 20:02:16 2010 +0200 +++ b/mcabber/mcabber/xmpp.c Mon Apr 12 20:50:19 2010 +0200 @@ -1239,9 +1239,15 @@ // Display inside the room window if (r == s) { // No specific resource (this is certainly history) - mbuf = g_strdup_printf("The topic has been set to: %s", subj); + if (*subj) + mbuf = g_strdup_printf("The topic has been set to: %s", subj); + else + mbuf = g_strdup_printf("The topic has been cleared"); } else { - mbuf = g_strdup_printf("%s has set the topic to: %s", r, subj); + if (*subj) + mbuf = g_strdup_printf("%s has set the topic to: %s", r, subj); + else + mbuf = g_strdup_printf("%s has cleared the topic", r); } scr_WriteIncomingMessage(s, mbuf, 0, HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0);
--- a/mcabber/mcabber/xmpp_helper.c Sun Apr 11 20:02:16 2010 +0200 +++ b/mcabber/mcabber/xmpp_helper.c Mon Apr 12 20:50:19 2010 +0200 @@ -109,9 +109,11 @@ { LmMessageNode *tmp; tmp = lm_message_node_find_child(node, child); - if (tmp) - return lm_message_node_get_value(tmp); - else return NULL; + if (tmp) { + const gchar *val = lm_message_node_get_value(tmp); + return (val ? val : ""); + } + return NULL; } static LmMessageNode *hidden = NULL;