# HG changeset patch
# Node ID 7eecdf310e8a
# Parent  74985c7b824d
diff --git a/libpurple/protocols/ircv3/meson.build b/libpurple/protocols/ircv3/meson.build
new file mode 100644
--- /dev/null
+++ b/libpurple/protocols/ircv3/meson.build
@@ -0,0 +1,20 @@
+IRCV3_SOURCES = [
+	'purpleircv3core.c',
+	'purpleircv3protocol.c',
+	'purpleircv3protocol.h',
+]
+
+if DYNAMIC_IRCV3
+	ircv3_resources = gnome.compile_resources('ircv3resource',
+		'resources/ircv3.gresource.xml',
+		source_dir : 'resources',
+		c_name : 'purple_ircv3')
+	IRCV3_SOURCES += ircv3_resources
+
+	ircv3_prpl = shared_library('ircv3', IRCV3_SOURCES,
+	    c_args : ['-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="Purple-IRCv3"'],
+	    dependencies : [sasl, libpurple_dep, glib, gio, ws2_32],
+	    install : true, install_dir : PURPLE_PLUGINDIR)
+
+	devenv.append('PURPLE_PLUGIN_PATH', meson.current_build_dir())
+endif
diff --git a/libpurple/protocols/ircv3/purpleircv3core.c b/libpurple/protocols/ircv3/purpleircv3core.c
new file mode 100644
--- /dev/null
+++ b/libpurple/protocols/ircv3/purpleircv3core.c
@@ -0,0 +1,107 @@
+/*
+ * 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/>.
+ */
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+
+#include <gplugin.h>
+#include <gplugin-native.h>
+
+#include <purple.h>
+
+#include "purpleircv3protocol.h"
+
+/******************************************************************************
+ * Globals
+ *****************************************************************************/
+#define PURPLE_IRCV3_DOMAIN (g_quark_from_static_string("ircv3-plugin"))
+
+static PurpleProtocol *ircv3_protocol = NULL;
+
+/******************************************************************************
+ * GPlugin Exports
+ *****************************************************************************/
+static GPluginPluginInfo *
+purple_ircv3_query(G_GNUC_UNUSED GError **error) {
+	PurplePluginInfoFlags flags = PURPLE_PLUGIN_INFO_FLAGS_INTERNAL |
+	                              PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD;
+	const gchar * const authors[] = {
+		"Pidgin Developers <devel@pidgin.im>",
+		NULL
+	};
+
+	return purple_plugin_info_new(
+		"id", "prpl-ircv3",
+		"name", "IRCv3 Protocol",
+		"authors", authors,
+		"version", DISPLAY_VERSION,
+		"category", N_("Protocol"),
+		"summary", N_("IRCv3 Protocol Plugin"),
+		"description", N_("Modern IRC Support"),
+		"website", PURPLE_WEBSITE,
+		"abi-version", PURPLE_ABI_VERSION,
+		"flags", flags,
+		NULL);
+}
+
+static gboolean
+purple_ircv3_load(GPluginPlugin *plugin, GError **error) {
+	PurpleProtocolManager *manager = NULL;
+
+	if(PURPLE_IS_PROTOCOL(ircv3_protocol)) {
+		g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0,
+		                    "plugin was not cleaned up properly");
+
+		return FALSE;
+	}
+
+	purple_ircv3_protocol_register(GPLUGIN_NATIVE_PLUGIN(plugin));
+
+	manager = purple_protocol_manager_get_default();
+
+	ircv3_protocol = purple_ircv3_protocol_new();
+	if(!purple_protocol_manager_register(manager, ircv3_protocol, error)) {
+		g_clear_object(&ircv3_protocol);
+
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static gboolean
+purple_ircv3_unload(GPluginPlugin *plugin, gboolean shutdown, GError **error) {
+	PurpleProtocolManager *manager = NULL;
+
+	if(!PURPLE_IS_PROTOCOL(ircv3_protocol)) {
+		g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0,
+		                    "plugin was not setup properly");
+
+		return FALSE;
+	}
+
+	if(!purple_protocol_manager_unregister(manager, ircv3_protocol, error)) {
+		return FALSE;
+	}
+
+	g_clear_object(&ircv3_protocol);
+
+	return TRUE;
+}
+
+GPLUGIN_NATIVE_PLUGIN_DECLARE(purple_ircv3)
diff --git a/libpurple/protocols/ircv3/purpleircv3protocol.h b/libpurple/protocols/ircv3/purpleircv3protocol.h
new file mode 100644
--- /dev/null
+++ b/libpurple/protocols/ircv3/purpleircv3protocol.h
@@ -0,0 +1,50 @@
+/*
+ * 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/>.
+ */
+
+#ifndef PURPLE_IRCV3_PROTOCOL_H
+#define PURPLE_IRCV3_PROTOCOL_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gplugin.h>
+#include <gplugin-native.h>
+
+#include <purple.h>
+
+G_BEGIN_DECLS
+
+#define PURPLE_IRCV3_TYPE_PROTOCOL (purple_ircv3_protocol_get_type())
+G_DECLARE_DERIVABLE_TYPE(PurpleIRCv3Protocol, purple_ircv3_protocol,
+                         PURPLE_IRCV3, PROTOCOL, PurpleProtocol)
+
+struct _PurpleIRCv3ProtocolClass {
+	/*< private >*/
+	PurpleProtocolClass parent;
+
+	/*< private >*/
+	gpointer reserved[4];
+};
+
+G_GNUC_INTERNAL void purple_ircv3_protocol_register(GPluginNativePlugin *plugin);
+
+G_GNUC_INTERNAL PurpleProtocol *purple_ircv3_protocol_new(void);
+
+G_END_DECLS
+
+#endif /* PURPLE_IRCV3_PROTOCOL_H */
diff --git a/libpurple/protocols/ircv3/purpleircv3protocol.c b/libpurple/protocols/ircv3/purpleircv3protocol.c
new file mode 100644
--- /dev/null
+++ b/libpurple/protocols/ircv3/purpleircv3protocol.c
@@ -0,0 +1,66 @@
+/*
+ * 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/>.
+ */
+
+#include <glib/gi18n-lib.h>
+
+#include "purpleircv3protocol.h"
+
+typedef struct {
+	gboolean dummy;
+} PurpleIRCv3ProtocolPrivate;
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+G_DEFINE_DYNAMIC_TYPE_EXTENDED(
+	PurpleIRCv3Protocol, purple_ircv3_protocol, PURPLE_TYPE_PROTOCOL, 0,
+	G_ADD_PRIVATE_DYNAMIC(PurpleIRCv3Protocol))
+
+static void
+purple_ircv3_protocol_init(PurpleIRCv3Protocol *protocol) {
+}
+
+static void
+purple_ircv3_protocol_class_finalize(PurpleIRCv3ProtocolClass *klass) {
+}
+
+static void
+purple_ircv3_protocol_class_init(PurpleIRCv3ProtocolClass *klass) {
+}
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+void
+purple_ircv3_protocol_register(GPluginNativePlugin *plugin) {
+	purple_ircv3_protocol_register_type(G_TYPE_MODULE(plugin));
+}
+
+PurpleProtocol *
+purple_ircv3_protocol_new(void) {
+	return g_object_new(
+		PURPLE_IRCV3_TYPE_PROTOCOL,
+		"id", "prpl-irv3",
+		"name", "IRCv3",
+		"description", _("Version 3 of Internet Relay Chat (IRC)."),
+		"icon-name", "im-ircv3",
+		"icon-resource-path", "/im/pidgin/libpurple/ircv3/icons",
+		"options", OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL |
+		           OPT_PROTO_SLASH_COMMANDS_NATIVE,
+		NULL);
+}
diff --git a/libpurple/protocols/ircv3/resources/icons/16x16/apps/im-ircv3.png b/libpurple/protocols/ircv3/resources/icons/16x16/apps/im-ircv3.png
new file mode 100644
index 0000000000000000000000000000000000000000..8ef4047639cef97a01afdd3c4bc00e62d17de856
GIT binary patch
diff --git a/libpurple/protocols/ircv3/resources/icons/22x22/apps/im-ircv3.png b/libpurple/protocols/ircv3/resources/icons/22x22/apps/im-ircv3.png
new file mode 100644
index 0000000000000000000000000000000000000000..58a8e1491c1cc8fb3ae39d847a5cb7772e47c4a0
GIT binary patch
diff --git a/libpurple/protocols/ircv3/resources/icons/48x48/apps/im-ircv3.png b/libpurple/protocols/ircv3/resources/icons/48x48/apps/im-ircv3.png
new file mode 100644
index 0000000000000000000000000000000000000000..fd87818814fa21e921cbd5d0176963b744e68099
GIT binary patch
diff --git a/libpurple/protocols/ircv3/resources/ircv3.gresource.xml b/libpurple/protocols/ircv3/resources/ircv3.gresource.xml
new file mode 100644
--- /dev/null
+++ b/libpurple/protocols/ircv3/resources/ircv3.gresource.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/im/pidgin/libpurple/ircv3">
+    <file>icons/16x16/apps/im-ircv3.png</file>
+    <file>icons/22x22/apps/im-ircv3.png</file>
+    <file>icons/48x48/apps/im-ircv3.png</file>
+  </gresource>
+</gresources>
diff --git a/libpurple/protocols/meson.build b/libpurple/protocols/meson.build
--- a/libpurple/protocols/meson.build
+++ b/libpurple/protocols/meson.build
@@ -3,6 +3,7 @@
 subdir('facebook')
 subdir('gg')
 subdir('irc')
+subdir('ircv3')
 subdir('jabber')
 subdir('novell')
 subdir('sametime')
diff --git a/meson.build b/meson.build
--- a/meson.build
+++ b/meson.build
@@ -385,7 +385,7 @@
 endif
 
 
-DEFAULT_PRPLS = ['bonjour', 'demo', 'facebook', 'gg', 'irc', 'jabber',
+DEFAULT_PRPLS = ['bonjour', 'demo', 'facebook', 'gg', 'irc', 'ircv3', 'jabber',
                  'novell', 'null', 'sametime', 'silc', 'zephyr']
 ALL_PRPLS = DEFAULT_PRPLS + ['null']
 
@@ -417,6 +417,7 @@
 DYNAMIC_FACEBOOK = DYNAMIC_PRPLS.contains('facebook')
 DYNAMIC_GG  = DYNAMIC_PRPLS.contains('gg')
 DYNAMIC_IRC = DYNAMIC_PRPLS.contains('irc')
+DYNAMIC_IRCV3 = DYNAMIC_PRPLS.contains('ircv3')
 DYNAMIC_JABBER = DYNAMIC_PRPLS.contains('jabber')
 DYNAMIC_NOVELL = DYNAMIC_PRPLS.contains('novell')
 DYNAMIC_NULL = DYNAMIC_PRPLS.contains('null')
