pidgin/pidgin

7ab7d79ac0c5
Parents c22448f50d5d
Children 0bba0ca12b0a
Create a skeleton for the IRCv3 protocol plugin

Testing Done:
Compiled and verified that the new protocol showed up in the protocol chooser in the new account editor.

Reviewed at https://reviews.imfreedom.org/r/1846/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/ircv3/meson.build Wed Sep 28 00:18:12 2022 -0500
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/ircv3/purpleircv3core.c Wed Sep 28 00:18:12 2022 -0500
@@ -0,0 +1,108 @@
+/*
+ * 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;
+ }
+
+ manager = purple_protocol_manager_get_default();
+ if(!purple_protocol_manager_unregister(manager, ircv3_protocol, error)) {
+ return FALSE;
+ }
+
+ g_clear_object(&ircv3_protocol);
+
+ return TRUE;
+}
+
+GPLUGIN_NATIVE_PLUGIN_DECLARE(purple_ircv3)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/ircv3/purpleircv3protocol.c Wed Sep 28 00:18:12 2022 -0500
@@ -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);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/ircv3/purpleircv3protocol.h Wed Sep 28 00:18:12 2022 -0500
@@ -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 */
Binary file libpurple/protocols/ircv3/resources/icons/16x16/apps/im-ircv3.png has changed
Binary file libpurple/protocols/ircv3/resources/icons/22x22/apps/im-ircv3.png has changed
Binary file libpurple/protocols/ircv3/resources/icons/48x48/apps/im-ircv3.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/ircv3/resources/ircv3.gresource.xml Wed Sep 28 00:18:12 2022 -0500
@@ -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>
--- a/libpurple/protocols/meson.build Tue Sep 27 02:44:13 2022 -0500
+++ b/libpurple/protocols/meson.build Wed Sep 28 00:18:12 2022 -0500
@@ -3,6 +3,7 @@
subdir('facebook')
subdir('gg')
subdir('irc')
+subdir('ircv3')
subdir('jabber')
subdir('novell')
subdir('sametime')
--- a/meson.build Tue Sep 27 02:44:13 2022 -0500
+++ b/meson.build Wed Sep 28 00:18:12 2022 -0500
@@ -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')