SIP: A stubbed out SIP protocol plugin

Fri, 25 Apr 2025 01:08:11 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 25 Apr 2025 01:08:11 -0500
changeset 43245
b83427aa2c38
parent 43244
83f2cdc7ee6b
child 43246
0e9bbe9b4da8

SIP: A stubbed out SIP protocol plugin

Testing Done:
Launched in a devenv and verified that the protocol showed up with its icon in the add account dialog. Also called in the turtles.

Reviewed at https://reviews.imfreedom.org/r/3988/

meson.build file | annotate | diff | comparison | revisions
protocols/meson.build file | annotate | diff | comparison | revisions
protocols/sip/meson.build file | annotate | diff | comparison | revisions
protocols/sip/purplesipplugin.c file | annotate | diff | comparison | revisions
protocols/sip/purplesipplugin.h file | annotate | diff | comparison | revisions
protocols/sip/purplesipprotocol.c file | annotate | diff | comparison | revisions
protocols/sip/purplesipprotocol.h file | annotate | diff | comparison | revisions
protocols/sip/resources/icons/16x16/apps/im-purple-sip.png file | annotate | diff | comparison | revisions
protocols/sip/resources/icons/22x22/apps/im-purple-sip.png file | annotate | diff | comparison | revisions
protocols/sip/resources/icons/48x48/apps/im-purple-sip.png file | annotate | diff | comparison | revisions
protocols/sip/resources/icons/scalable/apps/im-purple-sip.svg file | annotate | diff | comparison | revisions
protocols/sip/resources/purplesip.gresource.xml file | annotate | diff | comparison | revisions
--- a/meson.build	Fri Apr 25 01:06:06 2025 -0500
+++ b/meson.build	Fri Apr 25 01:08:11 2025 -0500
@@ -250,7 +250,7 @@
 
 dependency('shoes', required : false)
 
-DEFAULT_PRPLS = ['demo', 'ircv3', 'xmpp']
+DEFAULT_PRPLS = ['demo', 'ircv3', 'sip', 'xmpp']
 
 dynamic_list = get_option('dynamic-prpls').split(',')
 if dynamic_list == ['all']
@@ -262,6 +262,8 @@
 		# The list was empty; do nothing.
 	elif prpl == 'xmpp' and not xeme_dep.found()
 		# Do nothing.
+	elif prpl == 'sip' and host_machine.system() == 'windows'
+		# Disable the plugin on windows as we don't have the dependency right now.
 	else
 		DYNAMIC_PRPLS += [prpl]
 	endif
@@ -269,6 +271,7 @@
 
 DYNAMIC_DEMO = DYNAMIC_PRPLS.contains('demo')
 DYNAMIC_IRCV3 = DYNAMIC_PRPLS.contains('ircv3')
+DYNAMIC_SIP = DYNAMIC_PRPLS.contains('sip')
 DYNAMIC_XMPP = DYNAMIC_PRPLS.contains('xmpp')
 
 add_project_arguments(
--- a/protocols/meson.build	Fri Apr 25 01:06:06 2025 -0500
+++ b/protocols/meson.build	Fri Apr 25 01:08:11 2025 -0500
@@ -1,4 +1,5 @@
 subdir('bonjour')
 subdir('demo')
 subdir('ircv3')
+subdir('sip')
 subdir('xmpp')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/protocols/sip/meson.build	Fri Apr 25 01:08:11 2025 -0500
@@ -0,0 +1,26 @@
+SIP_SOURCES = [
+	'purplesipplugin.c',
+	'purplesipplugin.h',
+	'purplesipprotocol.c',
+	'purplesipprotocol.h',
+]
+
+if DYNAMIC_SIP
+	sofia_sip_ua_dep = dependency('sofia-sip-ua', version : '>=1.12.11')
+	sofia_sip_ua_glib_dep = dependency('sofia-sip-ua-glib', version : '>=1.12.11')
+
+	sip_resources = gnome.compile_resources('purplesipresource',
+		'resources/purplesip.gresource.xml',
+		source_dir : 'resources',
+		c_name : 'purple_sip')
+	SIP_SOURCES += sip_resources
+
+	shared_library('sip', SIP_SOURCES,
+		c_args : ['-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="Purple-Sip"'],
+		gnu_symbol_visibility : 'hidden',
+		dependencies : [glib, libpurple_dep, sofia_sip_ua_dep, sofia_sip_ua_glib_dep],
+		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/protocols/sip/purplesipplugin.c	Fri Apr 25 01:08:11 2025 -0500
@@ -0,0 +1,110 @@
+/*
+ * Purple - Internet Messaging Library
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; 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 "purplesipplugin.h"
+
+#include "purplesipprotocol.h"
+
+/******************************************************************************
+ * Globals
+ *****************************************************************************/
+static PurpleProtocol *sip_protocol = NULL;
+
+/******************************************************************************
+ * GPlugin Implementation
+ *****************************************************************************/
+static GPluginPluginInfo *
+purple_sip_plugin_query(G_GNUC_UNUSED GError **error) {
+	const gchar *authors[] = {
+		"Pidgin Developers <devel@pidgin.im>",
+		NULL
+	};
+
+	return purple_plugin_info_new(
+		"id", "prpl-sip",
+		"name", "SIP Protocol Plugin",
+		"authors", authors,
+		"version", PURPLE_VERSION,
+		"category", N_("Protocol"),
+		"summary", N_("A protocol plugin for SIP."),
+		"description", N_("A protocol plugin for SIP/SIMPLE contacts."),
+		"website", PURPLE_WEBSITE,
+		"abi-version", PURPLE_ABI_VERSION,
+		"flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL |
+		         PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD,
+		NULL
+	);
+}
+
+static gboolean
+purple_sip_plugin_load(GPluginPlugin *plugin, GError **error) {
+	PurpleProtocolManager *manager = NULL;
+
+	if(PURPLE_IS_PROTOCOL(sip_protocol)) {
+		g_set_error_literal(error, PURPLE_SIP_DOMAIN, 0,
+		                    "plugin was not cleaned up properly");
+
+		return FALSE;
+	}
+
+	purple_sip_protocol_register(GPLUGIN_NATIVE_PLUGIN(plugin));
+
+	manager = purple_protocol_manager_get_default();
+
+	sip_protocol = purple_sip_protocol_new();
+	if(!purple_protocol_manager_add(manager, sip_protocol, error)) {
+		g_clear_object(&sip_protocol);
+
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static gboolean
+purple_sip_plugin_unload(G_GNUC_UNUSED GPluginPlugin *plugin,
+                         G_GNUC_UNUSED gboolean shutdown,
+                         GError **error)
+{
+	PurpleProtocolManager *manager = purple_protocol_manager_get_default();
+
+	if(!PURPLE_IS_PROTOCOL(sip_protocol)) {
+		g_set_error_literal(error, PURPLE_SIP_DOMAIN, 0,
+		                    "plugin was not setup properly");
+
+		return FALSE;
+	}
+
+	if(!purple_protocol_manager_remove(manager, sip_protocol, error)) {
+		return FALSE;
+	}
+
+	g_clear_object(&sip_protocol);
+
+	return TRUE;
+}
+
+GPLUGIN_NATIVE_PLUGIN_DECLARE(purple_sip_plugin)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/protocols/sip/purplesipplugin.h	Fri Apr 25 01:08:11 2025 -0500
@@ -0,0 +1,29 @@
+/*
+ * Purple - Internet Messaging Library
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+#ifndef PURPLE_SIP_PLUGIN_H
+#define PURPLE_SIP_PLUGIN_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define PURPLE_SIP_DOMAIN (g_quark_from_static_string("sip-plugin"))
+
+G_END_DECLS
+
+#endif /* PURPLE_SIP_PLUGIN_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/protocols/sip/purplesipprotocol.c	Fri Apr 25 01:08:11 2025 -0500
@@ -0,0 +1,70 @@
+/*
+ * Purple - Internet Messaging Library
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n-lib.h>
+
+#include "purplesipprotocol.h"
+
+struct _PurpleSipProtocol {
+	PurpleProtocol parent;
+};
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+G_DEFINE_DYNAMIC_TYPE_EXTENDED(
+	PurpleSipProtocol,
+	purple_sip_protocol,
+	PURPLE_TYPE_PROTOCOL,
+	G_TYPE_FLAG_FINAL,
+	{})
+
+static void
+purple_sip_protocol_init(G_GNUC_UNUSED PurpleSipProtocol *protocol) {
+}
+
+static void
+purple_sip_protocol_class_finalize(G_GNUC_UNUSED PurpleSipProtocolClass *klass) {
+}
+
+static void
+purple_sip_protocol_class_init(PurpleSipProtocolClass *klass) {
+	PurpleProtocolClass *protocol_class = PURPLE_PROTOCOL_CLASS(klass);
+}
+
+/******************************************************************************
+ * Local Exports
+ *****************************************************************************/
+void
+purple_sip_protocol_register(GPluginNativePlugin *plugin) {
+	purple_sip_protocol_register_type(G_TYPE_MODULE(plugin));
+}
+
+PurpleProtocol *
+purple_sip_protocol_new(void) {
+	return g_object_new(
+		PURPLE_SIP_TYPE_PROTOCOL,
+		"id", "prpl-sip",
+		"name", "SIP",
+		"description", _("Session Initiation Protocol which is used in "
+		                 "internet telephony."),
+		"icon-name", "im-purple-sip",
+		"icon-resource-path", "/im/pidgin/libpurple/protocols/sip/icons",
+		"options", OPT_PROTO_NO_PASSWORD,
+		NULL);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/protocols/sip/purplesipprotocol.h	Fri Apr 25 01:08:11 2025 -0500
@@ -0,0 +1,41 @@
+/*
+ * Purple - Internet Messaging Library
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef PURPLE_SIP_PROTOCOL_H
+#define PURPLE_SIP_PROTOCOL_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gplugin-native.h>
+
+#include <purple.h>
+
+G_BEGIN_DECLS
+
+#define PURPLE_SIP_TYPE_PROTOCOL (purple_sip_protocol_get_type())
+G_DECLARE_FINAL_TYPE(PurpleSipProtocol, purple_sip_protocol, PURPLE_SIP,
+                     PROTOCOL, PurpleProtocol)
+
+G_GNUC_INTERNAL void purple_sip_protocol_register(GPluginNativePlugin *plugin);
+
+G_GNUC_INTERNAL PurpleProtocol *purple_sip_protocol_new(void);
+
+G_END_DECLS
+
+#endif /* PURPLE_SIP_PROTOCOL_H */
Binary file protocols/sip/resources/icons/16x16/apps/im-purple-sip.png has changed
Binary file protocols/sip/resources/icons/22x22/apps/im-purple-sip.png has changed
Binary file protocols/sip/resources/icons/48x48/apps/im-purple-sip.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/protocols/sip/resources/icons/scalable/apps/im-purple-sip.svg	Fri Apr 25 01:08:11 2025 -0500
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg id="svg2" width="96" height="96" version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs id="defs4">
+  <linearGradient id="linearGradient2233" x1="25.016" x2="25.016" y1="8.8962" y2="21.734" gradientUnits="userSpaceOnUse">
+   <stop id="stop2229" stop-color="#fff" offset="0"/>
+   <stop id="stop2231" stop-color="#fff" stop-opacity="0" offset="1"/>
+  </linearGradient>
+ </defs>
+ <metadata id="metadata7">
+  <rdf:RDF>
+   <cc:Work rdf:about="">
+    <dc:format>image/svg+xml</dc:format>
+    <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+   </cc:Work>
+  </rdf:RDF>
+ </metadata>
+ <g id="layer1">
+  <g id="g1" transform="matrix(2.0234 0 0 2.0497 -.49769 -.70299)">
+   <path id="rect2212" d="m2.4375 10.5v12h11.312v4h-11.312v4h15.062v-12h-11.281v-4h11.281v-4zm19.031 0v20h4.0312v-20zm8.0312 0v20h4v-8h12v-12zm4 4h8v4.0625h-8z" fill="#729fcf" stroke="#3465a4" stroke-width=".49104"/>
+   <path id="path1352" d="m3.4805 11.543v9.9141h10.27a1.0426 1.0426 0 0 1 1.043 1.043v4a1.0426 1.0426 0 0 1-1.043 1.043h-10.27v1.9141h12.977v-9.9141h-10.238a1.0426 1.0426 0 0 1-1.043-1.043v-4a1.0426 1.0426 0 0 1 1.043-1.043h10.238v-1.9141zm19.031 0v17.914h1.9453v-17.914zm8.0312 0v17.914h1.9141v-6.957a1.0426 1.0426 0 0 1 1.043-1.043h10.957v-9.9141zm2.957 1.9141h8a1.0426 1.0426 0 0 1 1.043 1.043v4.0625a1.0426 1.0426 0 0 1-1.043 1.043h-8a1.0426 1.0426 0 0 1-1.043-1.043v-4.0625a1.0426 1.0426 0 0 1 1.043-1.043z" fill="url(#linearGradient2233)" opacity=".35" stroke="#fff" stroke-width=".49104" xlink:href="#rect2212"/>
+  </g>
+ </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/protocols/sip/resources/purplesip.gresource.xml	Fri Apr 25 01:08:11 2025 -0500
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/im/pidgin/libpurple/protocols/sip">
+    <file>icons/16x16/apps/im-purple-sip.png</file>
+    <file>icons/22x22/apps/im-purple-sip.png</file>
+    <file>icons/48x48/apps/im-purple-sip.png</file>
+    <file>icons/scalable/apps/im-purple-sip.svg</file>
+  </gresource>
+</gresources>

mercurial