/soc/2013/ankitkv/gobjectification: 4ae45b445bb9: Added purple_p...

Ankit Vani a at nevitus.org
Wed Jul 31 19:11:17 EDT 2013


Changeset: 4ae45b445bb998cfff6d3442f02db8546da517fd
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-01 03:19 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/4ae45b445bb9

Description:

Added purple_plugin_disable()

diffstat:

 libpurple/plugins.c |  23 ++++++++++++++++++-----
 libpurple/plugins.h |  10 ++++++++++
 2 files changed, 28 insertions(+), 5 deletions(-)

diffs (76 lines):

diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -52,7 +52,8 @@ static GPluginPluginInfoClass *parent_cl
 /**************************************************************************
  * Globals
  **************************************************************************/
-static GList *loaded_plugins = NULL;
+static GList *loaded_plugins     = NULL;
+static GList *plugins_to_disable = NULL;
 
 /**************************************************************************
  * Plugin API
@@ -105,7 +106,8 @@ purple_plugin_unload(GPluginPlugin *plug
 
 	purple_signals_disconnect_by_handle(plugin);
 
-	loaded_plugins = g_list_remove(loaded_plugins, plugin);
+	loaded_plugins     = g_list_remove(loaded_plugins, plugin);
+	plugins_to_disable = g_list_remove(plugins_to_disable, plugin);
 
 	purple_signal_emit(purple_plugins_get_handle(), "plugin-unload", plugin);
 
@@ -147,6 +149,15 @@ purple_plugin_add_action(GPluginPlugin *
 	g_object_unref(plugin_info);
 }
 
+void
+purple_plugin_disable(GPluginPlugin *plugin)
+{
+	g_return_if_fail(plugin != NULL);
+
+	if (!g_list_find(plugins_to_disable, plugin))
+		plugins_to_disable = g_list_prepend(plugins_to_disable, plugin);
+}
+
 /**************************************************************************
  * GObject code for PurplePluginInfo
  **************************************************************************/
@@ -373,11 +384,13 @@ purple_plugins_save_loaded(const char *k
 
 	for (pl = purple_plugins_get_loaded(); pl != NULL; pl = pl->next) {
 		GPluginPlugin *plugin = GPLUGIN_PLUGIN(pl->data);
-		GPluginPluginInfo *plugin_info = gplugin_plugin_get_info(plugin);
+		if (!g_list_find(plugins_to_disable, plugin)) {
 
-		ids = g_list_append(ids, (gchar *)gplugin_plugin_info_get_id(plugin_info));
+			GPluginPluginInfo *plugin_info = gplugin_plugin_get_info(plugin);
+			ids = g_list_append(ids, (gchar *)gplugin_plugin_info_get_id(plugin_info));
 
-		g_object_unref(plugin_info);
+			g_object_unref(plugin_info);
+		}
 	}
 
 	purple_prefs_set_string_list(key, ids);
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -134,6 +134,16 @@ gboolean purple_plugin_is_loaded(const G
 void purple_plugin_add_action(GPluginPlugin *plugin, const char* label,
                               PurplePluginActionCallback callback);
 
+/**
+ * Disable a plugin.
+ *
+ * This function adds the plugin to a list of plugins to "disable at the next
+ * startup" by excluding said plugins from the list of plugins to save.  The
+ * UI needs to call purple_plugins_save_loaded() after calling this for it
+ * to have any effect.
+ */
+void purple_plugin_disable(GPluginPlugin *plugin);
+
 /*@}*/
 
 /**************************************************************************/



More information about the Commits mailing list