Mercurial > hg
changeset 1899:decf94827efe
More lm_message_node_get_child_value() return value checks
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 12 Apr 2010 23:40:14 +0200 |
parents | e25cec543da1 |
children | 5dc0fd8225e3 |
files | mcabber/mcabber/xmpp.c mcabber/mcabber/xmpp_iqrequest.c mcabber/mcabber/xmpp_muc.c |
diffstat | 3 files changed, 13 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mcabber/mcabber/xmpp.c Mon Apr 12 23:24:20 2010 +0200 +++ b/mcabber/mcabber/xmpp.c Mon Apr 12 23:40:14 2010 +0200 @@ -1402,6 +1402,8 @@ ust = offline; ustmsg = lm_message_node_get_child_value(m->node, "status"); + if (ustmsg && !*ustmsg) + ustmsg = NULL; // Timestamp? timestamp = lm_message_node_get_timestamp(m->node);
--- a/mcabber/mcabber/xmpp_iqrequest.c Mon Apr 12 23:24:20 2010 +0200 +++ b/mcabber/mcabber/xmpp_iqrequest.c Mon Apr 12 23:40:14 2010 +0200 @@ -241,21 +241,21 @@ // Get result data... p = lm_message_node_get_child_value(ansqry, "name"); - if (p) { + if (p && *p) { buf = g_strdup_printf("Name: %s", p); scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); g_free(buf); } p = lm_message_node_get_child_value(ansqry, "version"); - if (p) { + if (p && *p) { buf = g_strdup_printf("Version: %s", p); scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); g_free(buf); } p = lm_message_node_get_child_value(ansqry, "os"); - if (p) { + if (p && *p) { buf = g_strdup_printf("OS: %s", p); scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); @@ -306,21 +306,21 @@ // Get result data... p = lm_message_node_get_child_value(ansqry, "utc"); - if (p) { + if (p && *p) { buf = g_strdup_printf("UTC: %s", p); scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); g_free(buf); } p = lm_message_node_get_child_value(ansqry, "tz"); - if (p) { + if (p && *p) { buf = g_strdup_printf("TZ: %s", p); scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); g_free(buf); } p = lm_message_node_get_child_value(ansqry, "display"); - if (p) { + if (p && *p) { buf = g_strdup_printf("Time: %s", p); scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); @@ -406,7 +406,7 @@ { char *buf; - if (!text || !bjid || !label) + if (!text || !*text || !bjid || !label) return; buf = g_strdup_printf("%s: %s%s%s%s%s%s%s%s%s%s", label,
--- a/mcabber/mcabber/xmpp_muc.c Mon Apr 12 23:24:20 2010 +0200 +++ b/mcabber/mcabber/xmpp_muc.c Mon Apr 12 23:40:14 2010 +0200 @@ -325,6 +325,8 @@ *mbnick = lm_message_node_get_attribute(y, "nick"); // For kick/ban, there can be actor and reason tags *reason = lm_message_node_get_child_value(y, "reason"); + if (*reason && !**reason) + *reason = NULL; z = lm_message_node_find_child(y, "actor"); if (z) *actorjid = lm_message_node_get_attribute(z, "jid"); @@ -543,8 +545,8 @@ LmMessageNode *destroynode = lm_message_node_find_child(xmldata, "destroy"); if (destroynode) { - if ((reason = lm_message_node_get_child_value(destroynode, - "reason"))) { + reason = lm_message_node_get_child_value(destroynode, "reason"); + if (reason && *reason) { mbuf = g_strdup_printf("You have left %s, " "the room has been destroyed: %s", roomjid, reason);