Remove guards around GPlugin functions and libpurple plugin API

Tue, 15 Jan 2019 16:28:32 -0600

author
Mike Ruprecht <cmaiku@gmail.com>
date
Tue, 15 Jan 2019 16:28:32 -0600
changeset 39411
b1272e3a1c55
parent 39410
88678727cf16
child 39412
d3c91a4e6f56

Remove guards around GPlugin functions and libpurple plugin API

This patch drops #ifdef PURPLE_PLUGINS guards around GPlugin functions
and libpurple API now that GPlugin and libpurple plugin support are
both required.

finch/libfinch.c file | annotate | diff | comparison | revisions
libpurple/plugins.c file | annotate | diff | comparison | revisions
libpurple/plugins.h file | annotate | diff | comparison | revisions
pidgin/libpidgin.c file | annotate | diff | comparison | revisions
--- a/finch/libfinch.c	Tue Jan 15 17:03:20 2019 -0600
+++ b/finch/libfinch.c	Tue Jan 15 16:28:32 2019 -0600
@@ -168,9 +168,7 @@
 	g_option_context_add_main_entries(context, option_entries, PACKAGE);
 
 	g_option_context_add_group(context, purple_get_option_group());
-#ifdef PURPLE_PLUGINS
 	g_option_context_add_group(context, gplugin_get_option_group());
-#endif
 
 #ifdef G_OS_WIN32
 	/* Handle Unicode filenames on Windows. See GOptionContext docs. */
--- a/libpurple/plugins.c	Tue Jan 15 17:03:20 2019 -0600
+++ b/libpurple/plugins.c	Tue Jan 15 16:28:32 2019 -0600
@@ -67,25 +67,17 @@
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE(PurplePluginInfo, purple_plugin_info,
-#ifdef PURPLE_PLUGINS
-		GPLUGIN_TYPE_PLUGIN_INFO
-#else
-		G_TYPE_OBJECT
-#endif
-		);
+		GPLUGIN_TYPE_PLUGIN_INFO);
 
 /**************************************************************************
  * Globals
  **************************************************************************/
-#ifdef PURPLE_PLUGINS
 static GList *loaded_plugins     = NULL;
 static GList *plugins_to_disable = NULL;
-#endif
 
 /**************************************************************************
  * Plugin API
  **************************************************************************/
-#ifdef PURPLE_PLUGINS
 static gboolean
 plugin_loading_cb(GObject *manager, PurplePlugin *plugin, GError **error,
                   gpointer data)
@@ -180,12 +172,10 @@
 
 	purple_prefs_disconnect_by_handle(plugin);
 }
-#endif /* PURPLE_PLUGINS */
 
 gboolean
 purple_plugin_load(PurplePlugin *plugin, GError **error)
 {
-#ifdef PURPLE_PLUGINS
 	GError *err = NULL;
 
 	g_return_val_if_fail(plugin != NULL, FALSE);
@@ -206,17 +196,11 @@
 	}
 
 	return TRUE;
-
-#else
-	g_set_error(error, PURPLE_PLUGINS_DOMAIN, 0, "Plugin support is disabled.");
-	return FALSE;
-#endif /* PURPLE_PLUGINS */
 }
 
 gboolean
 purple_plugin_unload(PurplePlugin *plugin, GError **error)
 {
-#ifdef PURPLE_PLUGINS
 	GError *err = NULL;
 
 	g_return_val_if_fail(plugin != NULL, FALSE);
@@ -237,43 +221,27 @@
 	}
 
 	return TRUE;
-
-#else
-	g_set_error(error, PURPLE_PLUGINS_DOMAIN, 0, "Plugin support is disabled.");
-	return FALSE;
-#endif /* PURPLE_PLUGINS */
 }
 
 gboolean
 purple_plugin_is_loaded(const PurplePlugin *plugin)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(plugin != NULL, FALSE);
 
 	return (gplugin_plugin_get_state(plugin) == GPLUGIN_PLUGIN_STATE_LOADED);
-
-#else
-	return FALSE;
-#endif
 }
 
 const gchar *
 purple_plugin_get_filename(const PurplePlugin *plugin)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(plugin != NULL, NULL);
 
 	return gplugin_plugin_get_filename(plugin);
-
-#else
-	return NULL;
-#endif
 }
 
 PurplePluginInfo *
 purple_plugin_get_info(const PurplePlugin *plugin)
 {
-#ifdef PURPLE_PLUGINS
 	GPluginPluginInfo *info;
 
 	g_return_val_if_fail(plugin != NULL, NULL);
@@ -290,20 +258,15 @@
 		return PURPLE_PLUGIN_INFO(info);
 	else
 		return NULL;
-#else
-	return NULL;
-#endif
 }
 
 void
 purple_plugin_disable(PurplePlugin *plugin)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_if_fail(plugin != NULL);
 
 	if (!g_list_find(plugins_to_disable, plugin))
 		plugins_to_disable = g_list_prepend(plugins_to_disable, plugin);
-#endif
 }
 
 GType
@@ -311,15 +274,10 @@
                             const gchar *name, const GTypeInfo *info,
                             GTypeFlags flags)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(GPLUGIN_IS_NATIVE_PLUGIN(plugin), G_TYPE_INVALID);
 
 	return gplugin_native_plugin_register_type(GPLUGIN_NATIVE_PLUGIN(plugin),
 	                                           parent, name, info, flags);
-
-#else
-	return G_TYPE_INVALID;
-#endif
 }
 
 void
@@ -327,13 +285,11 @@
                             GType interface_type,
                             const GInterfaceInfo *interface_info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_if_fail(GPLUGIN_IS_NATIVE_PLUGIN(plugin));
 
 	gplugin_native_plugin_add_interface(GPLUGIN_NATIVE_PLUGIN(plugin),
 	                                    instance_type, interface_type,
 	                                    interface_info);
-#endif
 }
 
 gboolean
@@ -355,12 +311,7 @@
 purple_plugin_get_dependent_plugins(const PurplePlugin *plugin)
 {
 #warning TODO: Implement this when GPlugin can return dependent plugins.
-
-#ifdef PURPLE_PLUGINS
 	return NULL;
-#else
-	return NULL;
-#endif
 }
 
 /**************************************************************************
@@ -570,183 +521,113 @@
 const gchar *
 purple_plugin_info_get_id(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_id(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 const gchar *
 purple_plugin_info_get_name(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_name(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 const gchar *
 purple_plugin_info_get_version(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_version(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 const gchar *
 purple_plugin_info_get_category(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_category(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 const gchar *
 purple_plugin_info_get_summary(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_summary(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 const gchar *
 purple_plugin_info_get_description(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_description(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 const gchar * const *
 purple_plugin_info_get_authors(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_authors(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 const gchar *
 purple_plugin_info_get_website(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_website(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 const gchar *
 purple_plugin_info_get_icon(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_icon(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 const gchar *
 purple_plugin_info_get_license_id(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_license_id(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 const gchar *
 purple_plugin_info_get_license_text(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_license_text(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 const gchar *
 purple_plugin_info_get_license_url(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_license_url(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 const gchar * const *
 purple_plugin_info_get_dependencies(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, NULL);
 
 	return gplugin_plugin_info_get_dependencies(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return NULL;
-#endif
 }
 
 guint32
 purple_plugin_info_get_abi_version(const PurplePluginInfo *info)
 {
-#ifdef PURPLE_PLUGINS
 	g_return_val_if_fail(info != NULL, 0);
 
 	return gplugin_plugin_info_get_abi_version(GPLUGIN_PLUGIN_INFO(info));
-
-#else
-	return 0;
-#endif
 }
 
 PurplePluginActionsCb
@@ -886,7 +767,6 @@
 GList *
 purple_plugins_find_all(void)
 {
-#ifdef PURPLE_PLUGINS
 	GList *ret = NULL, *ids, *l;
 	GSList *plugins, *ll;
 
@@ -906,34 +786,23 @@
 	g_list_free(ids);
 
 	return ret;
-
-#else
-	return NULL;
-#endif
 }
 
 GList *
 purple_plugins_get_loaded(void)
 {
-#ifdef PURPLE_PLUGINS
 	return loaded_plugins;
-#else
-	return NULL;
-#endif
 }
 
 void
 purple_plugins_add_search_path(const gchar *path)
 {
-#ifdef PURPLE_PLUGINS
 	gplugin_manager_append_path(path);
-#endif
 }
 
 void
 purple_plugins_refresh(void)
 {
-#ifdef PURPLE_PLUGINS
 	GList *plugins, *l;
 
 	gplugin_manager_refresh();
@@ -959,13 +828,11 @@
 	}
 
 	g_list_free(plugins);
-#endif
 }
 
 PurplePlugin *
 purple_plugins_find_plugin(const gchar *id)
 {
-#ifdef PURPLE_PLUGINS
 	PurplePlugin *plugin;
 
 	g_return_val_if_fail(id != NULL && *id != '\0', NULL);
@@ -982,10 +849,6 @@
 	g_object_unref(plugin);
 
 	return plugin;
-
-#else
-	return NULL;
-#endif
 }
 
 PurplePlugin *
@@ -1013,7 +876,6 @@
 void
 purple_plugins_save_loaded(const char *key)
 {
-#ifdef PURPLE_PLUGINS
 	GList *pl;
 	GList *files = NULL;
 
@@ -1035,13 +897,11 @@
 
 	purple_prefs_set_path_list(key, files);
 	g_list_free(files);
-#endif
 }
 
 void
 purple_plugins_load_saved(const char *key)
 {
-#ifdef PURPLE_PLUGINS
 	GList *l, *files;
 
 	g_return_if_fail(key != NULL && *key != '\0');
@@ -1070,7 +930,6 @@
 	}
 
 	g_list_free(files);
-#endif /* PURPLE_PLUGINS */
 }
 
 /**************************************************************************
@@ -1088,9 +947,7 @@
 purple_plugins_init(void)
 {
 	void *handle = purple_plugins_get_handle();
-#ifdef PURPLE_PLUGINS
 	const gchar *search_path;
-#endif
 
 	purple_signal_register(handle, "plugin-load",
 	                       purple_marshal_VOID__POINTER,
@@ -1099,7 +956,6 @@
 	                       purple_marshal_VOID__POINTER,
 	                       G_TYPE_NONE, 1, PURPLE_TYPE_PLUGIN);
 
-#ifdef PURPLE_PLUGINS
 	gplugin_init();
 
 	search_path = g_getenv("PURPLE_PLUGIN_PATH");
@@ -1133,7 +989,6 @@
 	                 G_CALLBACK(plugin_unloaded_cb), NULL);
 
 	purple_plugins_refresh();
-#endif
 }
 
 void
@@ -1141,16 +996,12 @@
 {
 	void *handle = purple_plugins_get_handle();
 
-#ifdef PURPLE_PLUGINS
 	purple_debug_info("plugins", "Unloading all plugins\n");
 	while (loaded_plugins != NULL)
 		purple_plugin_unload(loaded_plugins->data, NULL);
-#endif
 
 	purple_signals_disconnect_by_handle(handle);
 	purple_signals_unregister_by_instance(handle);
 
-#ifdef PURPLE_PLUGINS
 	gplugin_uninit();
-#endif
 }
--- a/libpurple/plugins.h	Tue Jan 15 17:03:20 2019 -0600
+++ b/libpurple/plugins.h	Tue Jan 15 16:28:32 2019 -0600
@@ -31,20 +31,13 @@
  *     <link linkend="chapter-plugin-i18n">Third Party Plugin Translation</link>
  */
 
-#ifdef PURPLE_PLUGINS
 #include <gplugin.h>
 #include <gplugin-native.h>
-#else
-#include <glib.h>
-#include <glib-object.h>
-#endif
 
 #include "version.h"
 
 #define PURPLE_PLUGINS_DOMAIN          (g_quark_from_static_string("plugins"))
 
-#ifdef PURPLE_PLUGINS
-
 #define PURPLE_TYPE_PLUGIN             GPLUGIN_TYPE_PLUGIN
 #define PURPLE_PLUGIN(obj)             GPLUGIN_PLUGIN(obj)
 #define PURPLE_PLUGIN_CLASS(klass)     GPLUGIN_PLUGIN_CLASS(klass)
@@ -62,20 +55,6 @@
 
 typedef GPluginPluginClass PurplePluginClass;
 
-#else /* !defined(PURPLE_PLUGINS) */
-
-#define PURPLE_TYPE_PLUGIN             G_TYPE_OBJECT
-#define PURPLE_PLUGIN(obj)             G_OBJECT(obj)
-#define PURPLE_PLUGIN_CLASS(klass)     G_OBJECT_CLASS(klass)
-#define PURPLE_IS_PLUGIN(obj)          G_IS_OBJECT(obj)
-#define PURPLE_IS_PLUGIN_CLASS(klass)  G_IS_OBJECT_CLASS(klass)
-#define PURPLE_PLUGIN_GET_CLASS(obj)   G_OBJECT_GET_CLASS(obj)
-
-typedef GObject PurplePlugin;
-typedef GObjectClass PurplePluginClass;
-
-#endif /* PURPLE_PLUGINS */
-
 #define PURPLE_TYPE_PLUGIN_INFO             (purple_plugin_info_get_type())
 #define PURPLE_PLUGIN_INFO(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PLUGIN_INFO, PurplePluginInfo))
 #define PURPLE_PLUGIN_INFO_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_PLUGIN_INFO, PurplePluginInfoClass))
@@ -162,22 +141,14 @@
  * Holds information about a plugin.
  */
 struct _PurplePluginInfo {
-#ifdef PURPLE_PLUGINS
 	GPluginPluginInfo parent;
-#else
-	GObject parent;
-#endif
 
 	/*< public >*/
 	gpointer ui_data;
 };
 
 struct _PurplePluginInfoClass {
-#ifdef PURPLE_PLUGINS
 	GPluginPluginInfoClass parent_class;
-#else
-	GObjectClass parent_class;
-#endif
 
 	/*< private >*/
 	void (*_purple_reserved1)(void);
@@ -239,7 +210,6 @@
  *
  * Defines the plugin's entry points.
  */
-#ifdef PURPLE_PLUGINS
 #define PURPLE_PLUGIN_INIT(pluginname,pluginquery,pluginload,pluginunload) \
 	G_MODULE_EXPORT GPluginPluginInfo *gplugin_query(GError **e); \
 	G_MODULE_EXPORT GPluginPluginInfo *gplugin_query(GError **e) { \
@@ -253,7 +223,6 @@
 	G_MODULE_EXPORT gboolean gplugin_unload(GPluginNativePlugin *p, GError **e) { \
 		return pluginunload(PURPLE_PLUGIN(p), e); \
 	}
-#endif
 
 /**
  * PURPLE_DEFINE_TYPE:
@@ -266,10 +235,8 @@
  * function. You must define an instance initialization function *_init()
  * and a class initialization function *_class_init() for the type.
  */
-#ifdef PURPLE_PLUGINS
 #define PURPLE_DEFINE_TYPE(TN, t_n, T_P) \
 	PURPLE_DEFINE_DYNAMIC_TYPE(TN, t_n, T_P)
-#endif
 
 /**
  * PURPLE_DEFINE_TYPE_EXTENDED:
@@ -282,10 +249,8 @@
  * A more general version of PURPLE_DEFINE_TYPE() which allows you to
  * specify #GTypeFlags and custom code.
  */
-#ifdef PURPLE_PLUGINS
 #define PURPLE_DEFINE_TYPE_EXTENDED \
 	PURPLE_DEFINE_DYNAMIC_TYPE_EXTENDED
-#endif
 
 /**
  * PURPLE_IMPLEMENT_INTERFACE_STATIC:
@@ -312,10 +277,8 @@
  * of PURPLE_DEFINE_TYPE_EXTENDED(). You should use this macro if the
  * interface lives in the plugin.
  */
-#ifdef PURPLE_PLUGINS
 #define PURPLE_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) \
 	PURPLE_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init)
-#endif
 
 /**
  * PURPLE_DEFINE_DYNAMIC_TYPE:
--- a/pidgin/libpidgin.c	Tue Jan 15 17:03:20 2019 -0600
+++ b/pidgin/libpidgin.c	Tue Jan 15 16:28:32 2019 -0600
@@ -741,9 +741,7 @@
 
 	g_application_add_main_option_entries(app, option_entries);
 	g_application_add_option_group(app, purple_get_option_group());
-#ifdef PURPLE_PLUGINS
 	g_application_add_option_group(app, gplugin_get_option_group());
-#endif
 
 	g_object_set(app, "register-session", TRUE, NULL);
 

mercurial