# HG changeset patch
# Node ID 5fe0c1cb2936
# Parent  55eff782a478
diff --git a/libpurple/protocols/ircv3/purpleircv3constants.h b/libpurple/protocols/ircv3/purpleircv3constants.h
--- a/libpurple/protocols/ircv3/purpleircv3constants.h
+++ b/libpurple/protocols/ircv3/purpleircv3constants.h
@@ -24,13 +24,211 @@
 #define PURPLE_IRCV3_CONSTANTS_H
 
 /**
+ * PURPLE_IRCV3_ERR_NICKLOCKED:
+ *
+ * A constant for the IRC %NICKLOCKED error.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_ERR_NICKLOCKED ("902") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_ERR_SASLABORTED:
+ *
+ * A constant for the IRC %SASLABORTED error.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_ERR_SASLABORTED ("906") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_ERR_SASLALREADY:
+ *
+ * A constant for the IRC %SASLALREADY error.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_ERR_SASLALREADY ("907") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_ERR_SASLFAIL:
+ *
+ * A constant for the IRC %SASLFAIL error.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_ERR_SASLFAIL ("904") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_ERR_SASLTOOLONG:
+ *
+ * A constant for the IRC %SASLTOOLONG error.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_ERR_SASLTOOLONG ("905") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV_MSG_AUTHENTICATE:
+ *
+ * A constant for the IRC %AUTHENTICATE message.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_MSG_AUTHENTICATE ("AUTHENTICATE") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV_MSG_CAP:
+ *
+ * A constant for the IRC %CAP message.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_MSG_CAP ("CAP") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_MSG_NOTICE:
+ *
+ * A constant for the IRC %TOPIC message.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_MSG_NOTICE ("NOTICE") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_MSG_PING:
+ *
+ * A constant for the IRC %PING message.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_MSG_PING ("PING") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_MSG_PRIVMSG:
+ *
+ * A constant for the IRC %PRIVMSG message.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_MSG_PRIVMSG ("PRIVMSG") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
  * PURPLE_IRCV3_MSG_TOPIC:
  *
  * A constant for the IRC %TOPIC message.
  *
  * Since: 3.0.0
  */
-#define PURPLE_IRCV3_MSG_TOPIC ("TOPIC")
+#define PURPLE_IRCV3_MSG_TOPIC ("TOPIC") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_CREATED:
+ *
+ * A constant for the IRC %CREATED reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_CREATED ("003") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_ENDOFMOTD:
+ *
+ * A constant for the IRC %ENDOFMOTD reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_ENDOFMOTD ("376") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_LOGGEDIN:
+ *
+ * A constant for the IRC %LOGGEDIN reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_LOGGEDIN ("900") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_LOGGEDOUT:
+ *
+ * A constant for the IRC %LOGGEDOUT reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_LOGGEDOUT ("901") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_LUSERCHANNELS:
+ *
+ * A constant for the IRC %LUSERCHANNELS reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_LUSERCHANNELS ("254") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_LUSERCLIENT:
+ *
+ * A constant for the IRC %LUSERCLIENT reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_LUSERCLIENT ("251") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_LUSERME:
+ *
+ * A constant for the IRC %LUSERME reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_LUSERME ("255") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_LUSEROP:
+ *
+ * A constant for the IRC %LUSEROP reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_LUSEROP ("252") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_LUSERUNKNOWN:
+ *
+ * A constant for the IRC %LUSERUNKNOWN reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_LUSERUNKNOWN ("253") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_MYINFO:
+ *
+ * A constant for the IRC %MYINFO reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_MYINFO ("004") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_MOTD:
+ *
+ * A constant for the IRC %MOTD reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_MOTD ("372") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_MOTDSTART:
+ *
+ * A constant for the IRC %MOTDSTART reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_MOTDSTART ("375") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
 
 /**
  * PURPLE_IRCV3_RPL_NOTOPIC:
@@ -39,7 +237,25 @@
  *
  * Since: 3.0.0
  */
-#define PURPLE_IRCV3_RPL_NOTOPIC ("331")
+#define PURPLE_IRCV3_RPL_NOTOPIC ("331") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_SASLMECHS:
+ *
+ * A constant for the IRC %SASLMECHS reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_SASLMECHS ("908") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_SASLSUCCESS:
+ *
+ * A constant for the IRC %SASLSUCCESS reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_SASLSUCCESS ("903") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
 
 /**
  * PURPLE_IRCV3_RPL_TOPIC:
@@ -48,6 +264,24 @@
  *
  * Since: 3.0.0
  */
-#define PURPLE_IRCV3_RPL_TOPIC ("332")
+#define PURPLE_IRCV3_RPL_TOPIC ("332") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_WELCOME:
+ *
+ * A constant for the IRC %WELCOME reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_WELCOME ("001") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
+
+/**
+ * PURPLE_IRCV3_RPL_YOURHOST:
+ *
+ * A constant for the IRC %YOURHOST reply.
+ *
+ * Since: 3.0.0
+ */
+#define PURPLE_IRCV3_RPL_YOURHOST ("002") PURPLE_IRCV3_AVAILABLE_MACRO_IN_3_0
 
 #endif /* PURPLE_IRCV3_CONSTANTS_H */
diff --git a/libpurple/protocols/ircv3/purpleircv3messagehandlers.c b/libpurple/protocols/ircv3/purpleircv3messagehandlers.c
--- a/libpurple/protocols/ircv3/purpleircv3messagehandlers.c
+++ b/libpurple/protocols/ircv3/purpleircv3messagehandlers.c
@@ -188,7 +188,7 @@
 		}
 	}
 
-	if(purple_strequal(command, "NOTICE")) {
+	if(purple_strequal(command, PURPLE_IRCV3_MSG_NOTICE)) {
 		flags |= PURPLE_MESSAGE_NOTIFY;
 	}
 
diff --git a/libpurple/protocols/ircv3/purpleircv3parser.c b/libpurple/protocols/ircv3/purpleircv3parser.c
--- a/libpurple/protocols/ircv3/purpleircv3parser.c
+++ b/libpurple/protocols/ircv3/purpleircv3parser.c
@@ -434,13 +434,13 @@
 	                                         purple_ircv3_message_handler_fallback);
 
 	/* Core functionality. */
-	purple_ircv3_parser_add_handler(parser, "CAP",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_MSG_CAP,
 	                                purple_ircv3_capabilities_message_handler);
-	purple_ircv3_parser_add_handler(parser, "NOTICE",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_MSG_NOTICE,
 	                                purple_ircv3_message_handler_privmsg);
-	purple_ircv3_parser_add_handler(parser, "PING",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_MSG_PING,
 	                                purple_ircv3_message_handler_ping);
-	purple_ircv3_parser_add_handler(parser, "PRIVMSG",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_MSG_PRIVMSG,
 	                                purple_ircv3_message_handler_privmsg);
 
 	/* Topic stuff. */
@@ -454,37 +454,50 @@
 	/* Post Registration Greetings */
 	purple_ircv3_parser_add_handlers(parser,
 	                                 purple_ircv3_message_handler_status_ignore_param0,
-	                                 "001", "002", "003", "004", NULL);
+	                                 PURPLE_IRCV3_RPL_WELCOME,
+	                                 PURPLE_IRCV3_RPL_YOURHOST,
+	                                 PURPLE_IRCV3_RPL_CREATED,
+	                                 PURPLE_IRCV3_RPL_MYINFO,
+	                                 NULL);
 
 	/* Luser's */
 	purple_ircv3_parser_add_handlers(parser,
 	                                 purple_ircv3_message_handler_status_ignore_param0,
-	                                 "251", "252", "253", "254", "255", NULL);
+	                                 PURPLE_IRCV3_RPL_LUSERCLIENT,
+	                                 PURPLE_IRCV3_RPL_LUSEROP,
+	                                 PURPLE_IRCV3_RPL_LUSERUNKNOWN,
+	                                 PURPLE_IRCV3_RPL_LUSERCHANNELS,
+	                                 PURPLE_IRCV3_RPL_LUSERME,
+	                                 NULL);
 
 	/* MOTD */
 	purple_ircv3_parser_add_handlers(parser,
 	                                 purple_ircv3_message_handler_status_ignore_param0,
-	                                 "372", "375", "376", NULL);
+	                                 PURPLE_IRCV3_RPL_MOTD,
+	                                 PURPLE_IRCV3_RPL_MOTDSTART,
+	                                 PURPLE_IRCV3_RPL_ENDOFMOTD,
+	                                 NULL);
 
 	/* SASL stuff. */
-	purple_ircv3_parser_add_handler(parser, "900",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_RPL_LOGGEDIN,
 	                                purple_ircv3_sasl_logged_in);
-	purple_ircv3_parser_add_handler(parser, "901",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_RPL_LOGGEDOUT,
 	                                purple_ircv3_sasl_logged_out);
-	purple_ircv3_parser_add_handler(parser, "902",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_ERR_NICKLOCKED,
 	                                purple_ircv3_sasl_nick_locked);
-	purple_ircv3_parser_add_handler(parser, "903",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_RPL_SASLSUCCESS,
 	                                purple_ircv3_sasl_success);
-	purple_ircv3_parser_add_handler(parser, "904",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_ERR_SASLFAIL,
 	                                purple_ircv3_sasl_failed);
-	purple_ircv3_parser_add_handler(parser, "905",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_ERR_SASLTOOLONG,
 	                                purple_ircv3_sasl_message_too_long);
-	purple_ircv3_parser_add_handler(parser, "906",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_ERR_SASLABORTED,
 	                                purple_ircv3_sasl_aborted);
-	purple_ircv3_parser_add_handler(parser, "907",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_ERR_SASLALREADY,
 	                                purple_ircv3_sasl_already_authed);
-	purple_ircv3_parser_add_handler(parser, "908",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_RPL_SASLMECHS,
 	                                purple_ircv3_sasl_mechanisms);
-	purple_ircv3_parser_add_handler(parser, "AUTHENTICATE",
+	purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_MSG_AUTHENTICATE,
 	                                purple_ircv3_sasl_authenticate);
+
 }
diff --git a/libpurple/protocols/ircv3/purpleircv3sasl.c b/libpurple/protocols/ircv3/purpleircv3sasl.c
--- a/libpurple/protocols/ircv3/purpleircv3sasl.c
+++ b/libpurple/protocols/ircv3/purpleircv3sasl.c
@@ -24,6 +24,7 @@
 
 #include "purpleircv3capabilities.h"
 #include "purpleircv3connection.h"
+#include "purpleircv3constants.h"
 #include "purpleircv3core.h"
 
 #define PURPLE_IRCV3_SASL_DATA_KEY ("sasl-data")
@@ -113,7 +114,8 @@
 
 	g_message("trying SASL '%s' mechanism", next_mechanism);
 
-	purple_ircv3_connection_writef(connection, "AUTHENTICATE %s",
+	purple_ircv3_connection_writef(connection, "%s %s",
+	                               PURPLE_IRCV3_MSG_AUTHENTICATE,
 	                               next_mechanism);
 }
 
@@ -543,11 +545,13 @@
 			encoded = g_base64_encode(client_out, client_out_length);
 			g_clear_pointer(&client_out, g_free);
 
-			purple_ircv3_connection_writef(connection, "AUTHENTICATE %s",
+			purple_ircv3_connection_writef(connection, "%s %s",
+			                               PURPLE_IRCV3_MSG_AUTHENTICATE,
 			                               encoded);
 			g_free(encoded);
 		} else {
-			purple_ircv3_connection_writef(connection, "AUTHENTICATE +");
+			purple_ircv3_connection_writef(connection, "%s +",
+			                               PURPLE_IRCV3_MSG_AUTHENTICATE);
 		}
 	}
 
diff --git a/libpurple/protocols/ircv3/tests/test_ircv3_parser.c b/libpurple/protocols/ircv3/tests/test_ircv3_parser.c
--- a/libpurple/protocols/ircv3/tests/test_ircv3_parser.c
+++ b/libpurple/protocols/ircv3/tests/test_ircv3_parser.c
@@ -20,6 +20,7 @@
 
 #include <purple.h>
 
+#include "../purpleircv3constants.h"
 #include "../purpleircv3message.h"
 #include "../purpleircv3parser.h"
 
@@ -240,7 +241,7 @@
 test_purple_ircv3_parser_with_source_and_trailing_colon(void) {
 	TestPurpleIRCv3ParserData data = {
 		.source = "coolguy",
-		.command = "PRIVMSG",
+		.command = PURPLE_IRCV3_MSG_PRIVMSG,
 		.n_params = 2,
 		.params = {"bar", "lol :) "},
 	};
@@ -383,7 +384,7 @@
 	 */
 	TestPurpleIRCv3ParserData data = {
 		.source = "coolguy!ag@net\x03" "5w\x03" "ork.admin",
-		.command = "PRIVMSG",
+		.command = PURPLE_IRCV3_MSG_PRIVMSG,
 		.n_params = 2,
 		.params = {"foo", "bar baz"},
 	};
@@ -402,7 +403,7 @@
 	 */
 	TestPurpleIRCv3ParserData data = {
 		.source = "coolguy!~ag@n\x02" "et\x03" "05w\x0f" "ork.admin",
-		.command = "PRIVMSG",
+		.command = PURPLE_IRCV3_MSG_PRIVMSG,
 		.n_params = 2,
 		.params = {"foo", "bar baz"},
 	};
@@ -634,7 +635,7 @@
 test_purple_ircv3_parser_message_tags_none(void) {
 	TestPurpleIRCv3ParserData data = {
 		.source = "nick!ident@host.com",
-		.command = "PRIVMSG",
+		.command = PURPLE_IRCV3_MSG_PRIVMSG,
 		.n_params = 2,
 		.params = {"me", "Hello"},
 	};
@@ -649,7 +650,7 @@
 test_purple_ircv3_parser_message_tags_3_tags(void) {
 	TestPurpleIRCv3ParserData data = {
 		.source = "nick!ident@host.com",
-		.command = "PRIVMSG",
+		.command = PURPLE_IRCV3_MSG_PRIVMSG,
 		.n_params = 2,
 		.params = {"me", "Hello"},
 	};
@@ -670,7 +671,7 @@
 test_purple_ircv3_parser_message_tags_client_only(void) {
 	TestPurpleIRCv3ParserData data = {
 		.source = "url_bot!bot@example.com",
-		.command = "PRIVMSG",
+		.command = PURPLE_IRCV3_MSG_PRIVMSG,
 		.n_params = 2,
 		.params = {"#channel", "Example.com: A News Story"},
 	};
