# HG changeset patch
# User thijsalkemade@gmail.com
# Date 1292373310 0
# Node ID 1dcaaa68b245a3d7c1b3c90a2407d2a54f44e40d
# Parent  fa1a0dccd4fa9fd89b2b4aaf4e2c40fa4bbbe13e
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
during signin.

Thanks to Thijs Alkemade for this patch.

Fixes #8649

committer: Ethan Blanton <elb@pidgin.im>

diff -r fa1a0dccd4fa -r 1dcaaa68b245 COPYRIGHT
--- a/COPYRIGHT	Tue Dec 14 06:19:13 2010 +0000
+++ b/COPYRIGHT	Wed Dec 15 00:35:10 2010 +0000
@@ -20,6 +20,7 @@
 Saleem Abdulrasool
 Jakub Adam
 Dave Ahlswede
+Thijs Alkemade
 Manuel Amador
 Matt Amato
 Josef Andrysek
diff -r fa1a0dccd4fa -r 1dcaaa68b245 libpurple/protocols/irc/msgs.c
--- a/libpurple/protocols/irc/msgs.c	Tue Dec 14 06:19:13 2010 +0000
+++ b/libpurple/protocols/irc/msgs.c	Wed Dec 15 00:35:10 2010 +0000
@@ -597,9 +597,6 @@
 	if (!args || !args[0])
 		return;
 
-	if (!irc->motd)
-		irc->motd = g_string_new("");
-
 	if (!strcmp(name, "375")) {
 		if (irc->motd)
 			g_string_free(irc->motd, TRUE);
@@ -610,6 +607,15 @@
 		 * finalize the connection here if it is not already done. */
 		irc_connected(irc, args[0]);
 		return;
+	} else if (!strcmp(name, "422")) {
+		/* in case there is no 251, and no MOTD set, finalize the connection.
+		 * (and clear the motd for good measure). */
+		
+		if (irc->motd)
+			g_string_free(irc->motd, TRUE);
+		
+		irc_connected(irc, args[0]);
+		return;
 	}
 
 	if (!irc->motd) {
diff -r fa1a0dccd4fa -r 1dcaaa68b245 libpurple/protocols/irc/parse.c
--- a/libpurple/protocols/irc/parse.c	Tue Dec 14 06:19:13 2010 +0000
+++ b/libpurple/protocols/irc/parse.c	Wed Dec 15 00:35:10 2010 +0000
@@ -86,6 +86,7 @@
 	{ "403", "nc:", irc_msg_nochan },	/* No such channel		*/
 	{ "404", "nt:", irc_msg_nosend },	/* Cannot send to chan		*/
 	{ "421", "nv:", irc_msg_unknown },	/* Unknown command		*/
+	{ "422", "n:", irc_msg_motd },		/* MOTD file missing		*/
 	{ "432", "vn:", irc_msg_badnick },	/* Erroneous nickname		*/
 	{ "433", "vn:", irc_msg_nickused },	/* Nickname already in use	*/
 	{ "437", "nc:", irc_msg_unavailable },  /* Nick/channel is unavailable */