changeset 13533:95f4372e63aa

[gaim-migrate @ 15910] If someone changes the topic to the empty string, make the notice say "USER has cleared the topic." instead of "USER has changed the topic to: " Also, only print a message if the topic has actually changed. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Tue, 21 Mar 2006 00:47:33 +0000
parents 153434dc60ad
children 1685dcd6b3a5
files src/protocols/irc/msgs.c
diffstat 1 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/irc/msgs.c	Mon Mar 20 21:52:43 2006 +0000
+++ b/src/protocols/irc/msgs.c	Tue Mar 21 00:47:33 2006 +0000
@@ -315,15 +315,22 @@
 	tmp2 = gaim_markup_linkify(tmp);
 	g_free(tmp);
 	if (!strcmp(name, "topic")) {
-		char *nick_esc;
-		nick = irc_mask_nick(from);
-		nick_esc = g_markup_escape_text(nick, -1);
-		gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), nick, topic);
-		msg = g_strdup_printf(_("%s has changed the topic to: %s"), nick_esc, tmp2);
-		g_free(nick_esc);
-		g_free(nick);
-		gaim_conv_chat_write(GAIM_CONV_CHAT(convo), from, msg, GAIM_MESSAGE_SYSTEM, time(NULL));
-		g_free(msg);
+		const char *current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(convo));
+		if (!(current_topic != NULL && strcmp(tmp2, current_topic) == 0))
+		{
+			char *nick_esc;
+			nick = irc_mask_nick(from);
+			nick_esc = g_markup_escape_text(nick, -1);
+			gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), nick, topic);
+			if (*tmp2)
+				msg = g_strdup_printf(_("%s has changed the topic to: %s"), nick_esc, tmp2);
+			else
+				msg = g_strdup_printf(_("%s has cleared the topic."), nick_esc);
+			g_free(nick_esc);
+			g_free(nick);
+			gaim_conv_chat_write(GAIM_CONV_CHAT(convo), from, msg, GAIM_MESSAGE_SYSTEM, time(NULL));
+			g_free(msg);
+		}
 	} else {
 		char *chan_esc = g_markup_escape_text(chan, -1);
 		msg = g_strdup_printf(_("The topic for %s is: %s"), chan_esc, tmp2);