# HG changeset patch # User Mikael Berthe # Date 1223118222 -7200 # Node ID 4b4b3948420ced35bf69cfefba9266a4ecd057e6 # Parent ac87eef9050f674ad4980397270a7962ec2e5e43 MUC fix: the topic couldn't be cleared diff -r ac87eef9050f -r 4b4b3948420c mcabber/src/commands.c --- a/mcabber/src/commands.c Thu Oct 02 22:05:10 2008 +0200 +++ b/mcabber/src/commands.c Sat Oct 04 13:03:42 2008 +0200 @@ -2584,9 +2584,14 @@ return; } + // If arg is "-", let's clear the topic + if (!strcmp(arg, "-")) + arg = NULL; + arg = to_utf8(arg); // Set the topic - jb_send_msg(buddy_getjid(bud), NULL, ROSTER_TYPE_ROOM, arg, NULL, NULL, NULL); + jb_send_msg(buddy_getjid(bud), NULL, ROSTER_TYPE_ROOM, arg ? arg : "", + NULL, NULL, NULL); g_free(arg); } diff -r ac87eef9050f -r 4b4b3948420c mcabber/src/jabglue.c --- a/mcabber/src/jabglue.c Thu Oct 02 22:05:10 2008 +0200 +++ b/mcabber/src/jabglue.c Sat Oct 04 13:03:42 2008 +0200 @@ -2594,13 +2594,20 @@ enc = p; p = xmlnode_get_tag_data(xmldata, "subject"); - if (p != NULL) { + + if (xmlnode_get_tag(xmldata, "subject")) { if (!type || strcmp(type, TMSG_GROUPCHAT)) { // Chat message subject = p; } else { // Room topic GSList *roombuddy; gchar *mbuf; gchar *subj = p; + + // In a groupchat message, the subject can be NULL when + // the topic is cleared! + if (!p) + p = ""; + // Get the room (s) and the nickname (r) s = g_strdup(from); r = strchr(s, JID_RESOURCE_SEPARATOR); @@ -2613,9 +2620,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);