/soc/2013/ankitkv/gobjectification: 52aa83c47311: Replaced purpl...
Ankit Vani
a at nevitus.org
Wed Aug 7 10:15:51 EDT 2013
Changeset: 52aa83c473111f3526028d761e1b943e05d39339
Author: Ankit Vani <a at nevitus.org>
Date: 2013-08-07 19:42 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/52aa83c47311
Description:
Replaced purple_plugin_loads_on_query() with purple_plugin_is_internal().
The flags in the "flags" property of PurplePluginInfo:
GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL: Hide plugin from UI plugin lists.
GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY: Auto-load plugin on query.
diffstat:
finch/gntplugin.c | 2 +-
libpurple/plugins.c | 46 +++++++++++++++++++++---------------
libpurple/plugins.h | 32 ++++++++++++++++---------
libpurple/protocols/null/nullprpl.c | 5 ++++
pidgin/gtkplugin.c | 2 +-
5 files changed, 54 insertions(+), 33 deletions(-)
diffs (196 lines):
diff --git a/finch/gntplugin.c b/finch/gntplugin.c
--- a/finch/gntplugin.c
+++ b/finch/gntplugin.c
@@ -509,7 +509,7 @@ void finch_plugins_show_all(void)
{
PurplePlugin *plug = PURPLE_PLUGIN(iter->data);
- if (purple_plugin_loads_on_query(plug))
+ if (purple_plugin_is_internal(plug))
continue;
gnt_tree_add_choice(GNT_TREE(tree), plug,
diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -271,6 +271,23 @@ purple_plugin_get_actions(const PurplePl
}
gboolean
+purple_plugin_is_internal(const PurplePlugin *plugin)
+{
+#ifdef PURPLE_PLUGINS
+ GPluginPluginInfo *info;
+
+ g_return_val_if_fail(plugin != NULL, FALSE);
+
+ info = GPLUGIN_PLUGIN_INFO(purple_plugin_get_info(plugin));
+ return (gplugin_plugin_info_get_flags(info) &
+ GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL);
+
+#else
+ return FALSE;
+#endif
+}
+
+gboolean
purple_plugin_is_loadable(const PurplePlugin *plugin)
{
PurplePluginInfo *info;
@@ -286,23 +303,6 @@ purple_plugin_is_loadable(const PurplePl
return priv->loadable;
}
-gboolean
-purple_plugin_loads_on_query(const PurplePlugin *plugin)
-{
-#ifdef PURPLE_PLUGINS
- GPluginPluginInfo *info;
-
- g_return_val_if_fail(plugin != NULL, FALSE);
-
- info = GPLUGIN_PLUGIN_INFO(purple_plugin_get_info(plugin));
- return (gplugin_plugin_info_get_flags(info) &
- GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY);
-
-#else
- return FALSE;
-#endif
-}
-
gchar *
purple_plugin_get_error(const PurplePlugin *plugin)
{
@@ -790,10 +790,14 @@ purple_plugins_refresh(void)
plugins = purple_plugins_find_all();
for (l = plugins; l != NULL; l = l->next) {
PurplePlugin *plugin = PURPLE_PLUGIN(l->data);
+ GPluginPluginInfo *info;
if (purple_plugin_is_loaded(plugin))
continue;
- if (purple_plugin_loads_on_query(plugin)) {
+ info = GPLUGIN_PLUGIN_INFO(purple_plugin_get_info(plugin));
+
+ if (gplugin_plugin_info_get_flags(info) &
+ GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY) {
purple_debug_info("plugins", "Auto-loading plugin %s\n",
purple_plugin_get_filename(plugin));
purple_plugin_load(plugin);
@@ -855,7 +859,11 @@ purple_plugins_save_loaded(const char *k
for (pl = purple_plugins_get_loaded(); pl != NULL; pl = pl->next) {
PurplePlugin *plugin = PURPLE_PLUGIN(pl->data);
- if (purple_plugin_loads_on_query(plugin))
+ GPluginPluginInfo *info =
+ GPLUGIN_PLUGIN_INFO(purple_plugin_get_info(plugin));
+
+ if (gplugin_plugin_info_get_flags(info) &
+ GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY)
continue;
if (!g_list_find(plugins_to_disable, plugin))
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -70,6 +70,7 @@ typedef GPluginPluginClass PurplePluginC
#define PURPLE_PLUGIN_GET_CLASS(obj) G_OBJECT_GET_CLASS(obj)
#define GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY 0
+#define GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL 0
typedef GObject PurplePlugin;
typedef GObjectClass PurplePluginClass;
@@ -306,6 +307,17 @@ void purple_plugin_add_action(PurplePlug
GList *purple_plugin_get_actions(const PurplePlugin *plugin);
/**
+ * Returns whether a plugin is an internal plugin. Internal plugins provide
+ * required additional functionality to the libpurple core. Examples of such
+ * plugins are in-tree protocol plugins, loaders etc.
+ *
+ * @param plugin The plugin.
+ *
+ * @return @c TRUE if the plugin is an internal plugin, @c FALSE otherwise.
+ */
+gboolean purple_plugin_is_internal(const PurplePlugin *plugin);
+
+/**
* Returns whether or not a plugin is loadable.
*
* If this returns @c FALSE, the plugin is guaranteed to not
@@ -323,16 +335,6 @@ GList *purple_plugin_get_actions(const P
gboolean purple_plugin_is_loadable(const PurplePlugin *plugin);
/**
- * Returns whether a plugin auto-loads on query or not. Plugins that auto-loaded
- * on query are not saved by purple_plugins_save_loaded().
- *
- * @param plugin The plugin.
- *
- * @return @c TRUE if the plugin auto-loads on query, @c FALSE if it doesn't.
- */
-gboolean purple_plugin_loads_on_query(const PurplePlugin *plugin);
-
-/**
* If a plugin is not loadable, this returns the reason.
*
* @param plugin The plugin.
@@ -384,6 +386,12 @@ GType purple_plugin_info_get_type(void);
* "preferences_frame" (PurplePluginPrefFrameCallback) Callback that returns
* a preferences frame for the plugin.
*
+ * Additionally, you can provide a "flags" property if the plugin is to be
+ * distributed with libpurple, the value for which should be a bitwise
+ * combination of: \n
+ * GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL: Internal plugin, not shown in lists. \n
+ * GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY: Auto-load on query. \n
+ *
* @param first_property The first property name
* @param ... The value of the first property, followed optionally by more
* name/value pairs, followed by @c NULL
@@ -559,7 +567,6 @@ void purple_plugins_add_search_path(cons
* that are to be loaded on query.
*
* @see purple_plugins_add_search_path()
- * @see purple_plugin_loads_on_query()
*/
void purple_plugins_refresh(void);
@@ -582,7 +589,8 @@ PurplePlugin *purple_plugins_find_plugin
PurplePlugin *purple_plugins_find_by_filename(const char *filename);
/**
- * Saves the list of loaded plugins to the specified preference key
+ * Saves the list of loaded plugins to the specified preference key.
+ * Plugins that are set to load on query are not saved.
*
* @param key The preference key to save the list of plugins to.
*/
diff --git a/libpurple/protocols/null/nullprpl.c b/libpurple/protocols/null/nullprpl.c
--- a/libpurple/protocols/null/nullprpl.c
+++ b/libpurple/protocols/null/nullprpl.c
@@ -1146,6 +1146,11 @@ plugin_query(void)
"description", N_("Null Protocol Plugin"),
"website", PURPLE_WEBSITE,
"abi_version", PURPLE_ABI_VERSION,
+
+ /* If you're using this as the basis of a protocol plugin that will be
+ * distributed separately from libpurple, do not include these flags.*/
+ "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL |
+ GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY,
NULL
);
}
diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c
--- a/pidgin/gtkplugin.c
+++ b/pidgin/gtkplugin.c
@@ -249,7 +249,7 @@ update_plugin_list(void *data)
plug = PURPLE_PLUGIN(l->data);
info = purple_plugin_get_info(plug);
- if (purple_plugin_loads_on_query(plug))
+ if (purple_plugin_is_internal(plug))
continue;
gtk_list_store_append (ls, &iter);
More information about the Commits
mailing list