pidgin: f8149bfd: Handle IRC ban lists in-channel. Channe...

elb at pidgin.im elb at pidgin.im
Sat Apr 12 19:05:39 EDT 2008


-----------------------------------------------------------------
Revision: f8149bfd1db9d0f5cdc3635216fddf470e3c2844
Ancestor: 388591dc4d846724377ddc796192ae506f551de9
Author: elb at pidgin.im
Date: 2008-04-12T22:59:33
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/f8149bfd1db9d0f5cdc3635216fddf470e3c2844

Modified files:
        ChangeLog libpurple/protocols/irc/irc.h
        libpurple/protocols/irc/msgs.c
        libpurple/protocols/irc/parse.c

ChangeLog: 

Handle IRC ban lists in-channel.  Channels which are not joined are
still sent to the debug window, but in a bit prettier format.

References #209

-------------- next part --------------
============================================================
--- ChangeLog	5375ed8bbfaffb7da99ab71021d7130d5a25c22f
+++ ChangeLog	efc67391007511af61e45478c048c1d6daa4763d
@@ -4,6 +4,7 @@ version 2.x.x:
 	libpurple:
 	* In MySpaceIM, messages from spambots are discarded (Justin Williams)
 	* Strip mIRC formatting codes from quit and part messages.
+	* IRC now displays ban lists in-channel for joined channels.
 	
 	Pidgin:
 	* The typing notification in the conversation history can be disabled or
============================================================
--- libpurple/protocols/irc/irc.h	49082663654368df5b303822ac5bc8627e3bcd05
+++ libpurple/protocols/irc/irc.h	9ff8aa10d4dad190585971b08adb090e56ac6c29
@@ -118,6 +118,7 @@ void irc_msg_badnick(struct irc_conn *ir
 void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args);
+void irc_msg_ban(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_banfull(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args);
============================================================
--- libpurple/protocols/irc/msgs.c	93bebb730f37d6151c180b868a8124bf0e4003aa
+++ libpurple/protocols/irc/msgs.c	f9874c81d833f53d24add9867978c1dcd61f7cf6
@@ -30,6 +30,7 @@
 #include "irc.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
 static char *irc_mask_nick(const char *mask);
 static char *irc_mask_userhost(const char *mask);
@@ -191,6 +192,49 @@ void irc_msg_badmode(struct irc_conn *ir
 	purple_notify_error(gc, NULL, _("Bad mode"), args[1]);
 }
 
+void irc_msg_ban(struct irc_conn *irc, const char *name, const char *from, char **args)
+{
+	PurpleConversation *convo;
+
+	if (!args || !args[0] || !args[1])
+		return;
+
+	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
+						      args[1], irc->account);
+
+	if (!strcmp(name, "367")) {
+		char *msg = NULL;
+		/* Ban list entry */
+		if (!args[2])
+			return;
+		if (args[3] && args[4]) {
+			/* This is an extended syntax, not in RFC 1459 */
+			int t1 = atoi(args[4]);
+			time_t t2 = time(NULL);
+			msg = g_strdup_printf(_("Ban on %s by %s, set %ld seconds ago"),
+			                      args[2], args[3], t2 - t1);
+		} else {
+			msg = g_strdup_printf(_("Ban on %s"), args[2]);
+		}
+		if (convo) {
+			purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg,
+			                       PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
+			                       time(NULL));
+		} else {
+			purple_debug_info("irc", "%s\n", msg);
+		}
+		g_free(msg);
+	} else if (!strcmp(name, "368")) {
+		if (!convo)
+			return;
+		/* End of ban list */
+		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "",
+		                       _("End of ban list"),
+		                       PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
+		                       time(NULL));
+	}
+}
+
 void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args)
 {
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
============================================================
--- libpurple/protocols/irc/parse.c	b8c32fdcabe7da81bd6d0de8f2f697cf7caa8bfa
+++ libpurple/protocols/irc/parse.c	ccfb71b737275b45901ffe4ebce726870d9a53d8
@@ -75,6 +75,8 @@ static struct _irc_msg {
 	{ "333", "*", irc_msg_ignore },		/* Topic setter stuff		*/
 	{ "353", "nvc:", irc_msg_names },	/* Names list			*/
 	{ "366", "nc:", irc_msg_names },	/* End of names			*/
+	{ "367", "ncnnv", irc_msg_ban },	/* Ban list			*/
+	{ "368", "nc:", irc_msg_ban },		/* End of ban list		*/
 	{ "372", "n:", irc_msg_motd },		/* MOTD				*/
 	{ "375", "n:", irc_msg_motd },		/* Start MOTD			*/
 	{ "376", "n:", irc_msg_motd },		/* End of MOTD			*/


More information about the Commits mailing list