--- a/libpurple/protocols/ircv3/meson.build Thu Nov 16 03:53:39 2023 -0600
+++ b/libpurple/protocols/ircv3/meson.build Thu Nov 16 20:26:13 2023 -0600
@@ -14,6 +14,7 @@
'purpleircv3capabilities.h',
'purpleircv3connection.h',
+ 'purpleircv3constants.h', 'purpleircv3messagehandlers.h',
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/ircv3/purpleircv3constants.h Thu Nov 16 20:26:13 2023 -0600
@@ -0,0 +1,53 @@
+ * Purple - Internet Messaging Library + * Copyright (C) Pidgin Developers <devel@pidgin.im> + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses/>. +#if !defined(PURPLE_IRCV3_GLOBAL_HEADER_INSIDE) && \ + !defined(PURPLE_IRCV3_COMPILATION) +# error "only <libpurple/protocols/ircv3.h> may be included directly" +#ifndef PURPLE_IRCV3_CONSTANTS_H +#define PURPLE_IRCV3_CONSTANTS_H + * PURPLE_IRCV3_MSG_TOPIC: + * A constant for the IRC %TOPIC message. +#define PURPLE_IRCV3_MSG_TOPIC ("TOPIC") + * PURPLE_IRCV3_RPL_NOTOPIC: + * A constant for the IRC %NOTOPIC reply. +#define PURPLE_IRCV3_RPL_NOTOPIC ("331") + * PURPLE_IRCV3_RPL_TOPIC: + * A constant for the IRC %TOPIC reply. +#define PURPLE_IRCV3_RPL_TOPIC ("332") +#endif /* PURPLE_IRCV3_CONSTANTS_H */ --- a/libpurple/protocols/ircv3/purpleircv3messagehandlers.c Thu Nov 16 03:53:39 2023 -0600
+++ b/libpurple/protocols/ircv3/purpleircv3messagehandlers.c Thu Nov 16 20:26:13 2023 -0600
@@ -21,6 +21,7 @@
#include "purpleircv3messagehandlers.h"
#include "purpleircv3connection.h"
+#include "purpleircv3constants.h" #include "purpleircv3core.h"
#include "purpleircv3source.h"
@@ -227,3 +228,74 @@
+purple_ircv3_message_handler_topic(PurpleIRCv3Message *message, + PurpleIRCv3Connection *connection = data; + PurpleConversation *conversation = NULL; + const char *channel = NULL; + const char *command = NULL; + const char *topic = NULL; + command = purple_ircv3_message_get_command(message); + params = purple_ircv3_message_get_params(message); + n_params = g_strv_length(params); + if(purple_strequal(command, PURPLE_IRCV3_MSG_TOPIC)) { + g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, + "received TOPIC with %u parameters, expected 2", + } else if(purple_strequal(command, PURPLE_IRCV3_RPL_NOTOPIC)) { + g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, + "received RPL_NOTOPIC with %u parameters, expected 3", + } else if(purple_strequal(command, PURPLE_IRCV3_RPL_TOPIC)) { + g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, + "received RPL_TOPIC with %u parameters, expected 3", + g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, "unexpected command %s", + conversation = purple_ircv3_connection_find_or_create_conversation(connection, + if(!PURPLE_IS_CONVERSATION(conversation)) { + g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, + "failed to find or create channel '%s'", channel); + purple_conversation_set_topic(conversation, topic); --- a/libpurple/protocols/ircv3/purpleircv3messagehandlers.h Thu Nov 16 03:53:39 2023 -0600
+++ b/libpurple/protocols/ircv3/purpleircv3messagehandlers.h Thu Nov 16 20:26:13 2023 -0600
@@ -55,6 +55,7 @@
G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_status_ignore_param0(PurpleIRCv3Message *message, GError **error, gpointer data);
G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_ping(PurpleIRCv3Message *message, GError **error, gpointer data);
G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_privmsg(PurpleIRCv3Message *message, GError **error, gpointer data);
+G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_topic(PurpleIRCv3Message *message, GError **error, gpointer data); --- a/libpurple/protocols/ircv3/purpleircv3parser.c Thu Nov 16 03:53:39 2023 -0600
+++ b/libpurple/protocols/ircv3/purpleircv3parser.c Thu Nov 16 20:26:13 2023 -0600
@@ -19,6 +19,7 @@
#include "purpleircv3parser.h"
#include "purpleircv3capabilities.h"
+#include "purpleircv3constants.h" #include "purpleircv3core.h"
#include "purpleircv3message.h"
#include "purpleircv3messagehandlers.h"
@@ -442,6 +443,14 @@
purple_ircv3_parser_add_handler(parser, "PRIVMSG",
purple_ircv3_message_handler_privmsg);
+ purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_MSG_TOPIC, + purple_ircv3_message_handler_topic); + purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_RPL_NOTOPIC, + purple_ircv3_message_handler_topic); + purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_RPL_TOPIC, + purple_ircv3_message_handler_topic); /* Post Registration Greetings */
purple_ircv3_parser_add_handlers(parser,
purple_ircv3_message_handler_status_ignore_param0,