/pidgin/main: 3780e4cb9738: Print topic setter information at ch...

Ethan Blanton elb at pidgin.im
Sat Dec 1 14:53:56 EST 2012


Changeset: 3780e4cb973845764c0094a48ec7e920961ac622
Author:	 Ethan Blanton <elb at pidgin.im>
Date:	 2012-12-01 14:52 -0500
Branch:	 release-2.x.y
URL: http://hg.pidgin.im/pidgin/main/rev/3780e4cb9738

Description:

Print topic setter information at channel join.

Fixes #13317

diffstat:

 ChangeLog                       |   1 +
 libpurple/protocols/irc/irc.h   |   1 +
 libpurple/protocols/irc/msgs.c  |  32 ++++++++++++++++++++++++++++++++
 libpurple/protocols/irc/parse.c |   2 +-
 4 files changed, 35 insertions(+), 1 deletions(-)

diffs (76 lines):

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,6 +19,7 @@ version 2.10.7:
 	IRC:
 	* Support for SASL authentication.  (Thijs Alkemade, Andy Spencer)
 	  (#13270)
+	* Print topic setter information at channel join. (#13317)
 
 	MSN:
 	* Fix a crash when removing a user before its icon is loaded. (Mark
diff --git a/libpurple/protocols/irc/irc.h b/libpurple/protocols/irc/irc.h
--- a/libpurple/protocols/irc/irc.h
+++ b/libpurple/protocols/irc/irc.h
@@ -173,6 +173,7 @@ void irc_msg_quit(struct irc_conn *irc, 
 void irc_msg_regonly(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args);
+void irc_msg_topicinfo(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_unavailable(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args);
diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
--- a/libpurple/protocols/irc/msgs.c
+++ b/libpurple/protocols/irc/msgs.c
@@ -646,6 +646,38 @@ void irc_msg_topic(struct irc_conn *irc,
 	g_free(topic);
 }
 
+void irc_msg_topicinfo(struct irc_conn *irc, const char *name, const char *from, char **args)
+{
+	PurpleConversation *convo;
+	struct tm *tm;
+	time_t t;
+	char *msg, *timestamp, *datestamp;
+	
+	if (!args || !args[1] || !args[2] || !args[3])
+		return;
+
+	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
+	if (!convo) {
+		purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got topic info for %s, which doesn't exist\n", args[1]);
+		return;
+	}
+
+	t = (time_t)atol(args[3]);
+	if (t == 0) {
+		purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got apparently nonsensical topic timestamp %s\n", args[3]);
+		return;
+	}
+	tm = localtime(&t);
+
+	timestamp = g_strdup(purple_time_format(tm));
+	datestamp = g_strdup(purple_date_format_short(tm));
+	msg = g_strdup_printf("Topic for %s set by %s at %s on %s", args[1], args[2], timestamp, datestamp);
+	purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LINKIFY, time(NULL));
+	g_free(timestamp);
+	g_free(datestamp);
+	g_free(msg);
+}
+
 void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args)
 {
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
diff --git a/libpurple/protocols/irc/parse.c b/libpurple/protocols/irc/parse.c
--- a/libpurple/protocols/irc/parse.c
+++ b/libpurple/protocols/irc/parse.c
@@ -73,7 +73,7 @@ static struct _irc_msg {
 	{ "324", "ncv:", irc_msg_chanmode },	/* Channel modes		*/
 	{ "331", "nc:",	irc_msg_topic },	/* No channel topic		*/
 	{ "332", "nc:", irc_msg_topic },	/* Channel topic		*/
-	{ "333", "*", irc_msg_ignore },		/* Topic setter stuff		*/
+	{ "333", "ncvv", irc_msg_topicinfo },	/* Topic setter stuff		*/
 	{ "352", "ncvvvnv:", irc_msg_who },	/* Channel WHO			*/
 	{ "353", "nvc:", irc_msg_names },	/* Names list			*/
 	{ "366", "nc:", irc_msg_names },	/* End of names			*/



More information about the Commits mailing list