/soc/2013/ankitkv/gobjectification: 28ec73fbb37d: Added purple_p...

Ankit Vani a at nevitus.org
Mon Jul 29 18:36:40 EDT 2013


Changeset: 28ec73fbb37d022c3fc018eec250706091c95c63
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-30 03:54 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/28ec73fbb37d

Description:

Added purple_plugins_save_loaded() and purple_plugins_load_saved()

diffstat:

 libpurple/plugins.c |  48 ++++++++++++++++++++++++++++++++++++++++++++++++
 libpurple/plugins.h |  15 +++++++++++++++
 2 files changed, 63 insertions(+), 0 deletions(-)

diffs (83 lines):

diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -245,6 +245,54 @@ purple_plugins_get_loaded(void)
 }
 
 void
+purple_plugins_save_loaded(const char *key)
+{
+	GList *pl;
+	GList *ids = NULL;
+
+	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);
+
+		ids = g_list_append(ids, (gchar *)gplugin_plugin_info_get_id(plugin_info));
+	}
+
+	purple_prefs_set_string_list(key, ids);
+	g_list_free(ids);
+}
+
+void
+purple_plugins_load_saved(const char *key)
+{
+	GList *l, *ids;
+
+	g_return_if_fail(key != NULL);
+
+	ids = purple_prefs_get_string_list(key);
+
+	for (l = ids; l; l = l->next)
+	{
+		char *id;
+		GPluginPlugin *plugin;
+
+		if (l->data == NULL)
+			continue;
+
+		id = l->data;
+		plugin = gplugin_plugin_manager_find_plugin(id);
+
+		if (plugin) {
+			purple_debug_info("plugins", "Loading saved plugin %s\n", id);
+			purple_plugin_load(plugin);
+		} else {
+			purple_debug_error("plugins", "Unable to find saved plugin %s\n", id);
+		}
+	}
+
+	g_list_free_full(ids, (GDestroyNotify)g_free);
+}
+
+void
 purple_plugins_unload_all(void)
 {
 	while (loaded_plugins != NULL)
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -137,6 +137,21 @@ GList *purple_plugins_get_all(void);
 GList *purple_plugins_get_loaded(void);
 
 /**
+ * Saves the list of loaded plugins to the specified preference key
+ *
+ * @param key The preference key to save the list of plugins to.
+ */
+void purple_plugins_save_loaded(const char *key);
+
+/**
+ * Attempts to load all the plugins in the specified preference key
+ * that were loaded when purple last quit.
+ *
+ * @param key The preference key containing the list of plugins.
+ */
+void purple_plugins_load_saved(const char *key);
+
+/**
  * Unloads all loaded plugins.
  */
 void purple_plugins_unload_all(void);



More information about the Commits mailing list