diff libpurple/protocols/jabber/jabber.c @ 26766:06da00c70eae

Fix XMPP prpl->set_chat_topic with an empty string (or NULL) The slash-command /topic displays the message with no arguments, but the set_chat_topic should not. Closes #8810.
author Paul Aurich <paul@darkrain42.org>
date Sun, 26 Apr 2009 00:06:30 +0000
parents d00a8111e479
children 90d5e3b94a37
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Sat Apr 25 23:33:13 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sun Apr 26 00:06:30 2009 +0000
@@ -2305,7 +2305,25 @@
 	if (!chat)
 		return PURPLE_CMD_RET_FAILED;
 
-	jabber_chat_change_topic(chat, args ? args[0] : NULL);
+	if (args && args[0] && *args[0])
+		jabber_chat_change_topic(chat, args[0]);
+	else {
+		const char *cur = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(conv));
+		char *buf, *tmp, *tmp2;
+
+		if (cur) {
+			tmp = g_markup_escape_text(cur, -1);
+			tmp2 = purple_markup_linkify(tmp);
+			buf = g_strdup_printf(_("current topic is: %s"), tmp2);
+			g_free(tmp);
+			g_free(tmp2);
+		} else
+			buf = g_strdup(_("No topic is set"));
+		purple_conv_chat_write(PURPLE_CONV_CHAT(conv), "", buf,
+				PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
+		g_free(buf);
+	}
+
 	return PURPLE_CMD_RET_OK;
 }