Replaced purple_plugin_loads_on_query() with purple_plugin_is_internal(). soc.2013.gobjectification.plugins

Wed, 07 Aug 2013 19:42:45 +0530

author
Ankit Vani <a@nevitus.org>
date
Wed, 07 Aug 2013 19:42:45 +0530
branch
soc.2013.gobjectification.plugins
changeset 36467
52aa83c47311
parent 36466
97f632383c41
child 36468
64d359bbe6f6

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.

finch/gntplugin.c file | annotate | diff | comparison | revisions
libpurple/plugins.c file | annotate | diff | comparison | revisions
libpurple/plugins.h file | annotate | diff | comparison | revisions
libpurple/protocols/null/nullprpl.c file | annotate | diff | comparison | revisions
pidgin/gtkplugin.c file | annotate | diff | comparison | revisions
--- a/finch/gntplugin.c	Wed Aug 07 15:55:20 2013 +0530
+++ b/finch/gntplugin.c	Wed Aug 07 19:42:45 2013 +0530
@@ -509,7 +509,7 @@
 	{
 		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,
--- a/libpurple/plugins.c	Wed Aug 07 15:55:20 2013 +0530
+++ b/libpurple/plugins.c	Wed Aug 07 19:42:45 2013 +0530
@@ -271,6 +271,23 @@
 }
 
 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 @@
 	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 @@
 	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 @@
 
 	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))
--- a/libpurple/plugins.h	Wed Aug 07 15:55:20 2013 +0530
+++ b/libpurple/plugins.h	Wed Aug 07 19:42:45 2013 +0530
@@ -70,6 +70,7 @@
 #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 @@
 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 @@
 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 @@
  * "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 @@
  * 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_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.
  */
--- a/libpurple/protocols/null/nullprpl.c	Wed Aug 07 15:55:20 2013 +0530
+++ b/libpurple/protocols/null/nullprpl.c	Wed Aug 07 19:42:45 2013 +0530
@@ -1146,6 +1146,11 @@
     "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
   );
 }
--- a/pidgin/gtkplugin.c	Wed Aug 07 15:55:20 2013 +0530
+++ b/pidgin/gtkplugin.c	Wed Aug 07 19:42:45 2013 +0530
@@ -249,7 +249,7 @@
 		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);

mercurial