/soc/2013/ankitkv/gobjectification: f5d2c9da9ea0: Added purple_p...
Ankit Vani
a at nevitus.org
Thu Aug 1 07:11:34 EDT 2013
Changeset: f5d2c9da9ea00fca21bfc899ecd36e9cd8e66de1
Author: Ankit Vani <a at nevitus.org>
Date: 2013-08-01 15:51 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/f5d2c9da9ea0
Description:
Added purple_plugins_find_by_filename()
diffstat:
libpurple/plugins.c | 48 +++++++++++++++++++++++++++++-------------------
libpurple/plugins.h | 9 +++++++++
2 files changed, 38 insertions(+), 19 deletions(-)
diffs (111 lines):
diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -376,59 +376,69 @@ purple_plugins_get_loaded(void)
return loaded_plugins;
}
+GPluginPlugin *
+purple_plugins_find_by_filename(const char *filename)
+{
+ GList *l;
+
+ for (l = purple_plugins_get_all(); l != NULL; l = l->next) {
+ GPluginPlugin *plugin = GPLUGIN_PLUGIN(l->data);
+
+ if (purple_strequal(gplugin_plugin_get_filename(plugin), filename))
+ return plugin;
+ }
+
+ return NULL;
+}
+
void
purple_plugins_save_loaded(const char *key)
{
GList *pl;
- GList *ids = NULL;
+ GList *files = NULL;
for (pl = purple_plugins_get_loaded(); pl != NULL; pl = pl->next) {
GPluginPlugin *plugin = GPLUGIN_PLUGIN(pl->data);
- if (!g_list_find(plugins_to_disable, plugin)) {
-
- 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);
- }
+ if (!g_list_find(plugins_to_disable, plugin))
+ files = g_list_append(files, (gchar *)gplugin_plugin_get_filename(plugin));
}
- purple_prefs_set_string_list(key, ids);
- g_list_free(ids);
+ purple_prefs_set_string_list(key, files);
+ g_list_free(files);
}
void
purple_plugins_load_saved(const char *key)
{
- GList *l, *ids;
+ GList *l, *files;
g_return_if_fail(key != NULL);
- ids = purple_prefs_get_string_list(key);
+ files = purple_prefs_get_string_list(key);
- for (l = ids; l; l = l->next)
+ for (l = files; l; l = l->next)
{
- char *id;
+ char *file;
GPluginPlugin *plugin;
if (l->data == NULL)
continue;
- id = l->data;
- plugin = gplugin_plugin_manager_find_plugin(id);
+ file = l->data;
+ plugin = purple_plugins_find_by_filename(file);
if (plugin) {
- purple_debug_info("plugins", "Loading saved plugin %s\n", id);
+ purple_debug_info("plugins", "Loading saved plugin %s\n", file);
purple_plugin_load(plugin);
g_object_unref(plugin);
} else {
- purple_debug_error("plugins", "Unable to find saved plugin %s\n", id);
+ purple_debug_error("plugins", "Unable to find saved plugin %s\n", file);
}
g_free(l->data);
}
- g_list_free(ids);
+ g_list_free(files);
}
void
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -221,6 +221,15 @@ GList *purple_plugins_get_all(void);
GList *purple_plugins_get_loaded(void);
/**
+ * Finds a plugin with the specified filename (filename with a path).
+ *
+ * @param filename The plugin filename.
+ *
+ * @return The plugin if found, or @c NULL if not found.
+ */
+GPluginPlugin *purple_plugins_find_by_filename(const char *filename);
+
+/**
* Saves the list of loaded plugins to the specified preference key
*
* @param key The preference key to save the list of plugins to.
More information about the Commits
mailing list