/soc/2013/ankitkv/gobjectification: 7f8921ef1bfc: Moved PurplePl...
Ankit Vani
a at nevitus.org
Sat Aug 3 12:50:49 EDT 2013
Changeset: 7f8921ef1bfc64fb603e68ca0f3dc15c4cbc08fd
Author: Ankit Vani <a at nevitus.org>
Date: 2013-08-03 22:08 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/7f8921ef1bfc
Description:
Moved PurplePluginInfo's get_actions(), is_loadable(), get_error(), get_dependent_plugins() API to PurplePlugin
diffstat:
libpurple/plugins.c | 109 +++++++++++++++++++++++++++++----------------------
libpurple/plugins.h | 106 +++++++++++++++++++++++++-------------------------
2 files changed, 115 insertions(+), 100 deletions(-)
diffs (truncated from 301 to 300 lines):
diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -69,24 +69,21 @@ static GList *plugins_to_disable = NULL;
gboolean
purple_plugin_load(PurplePlugin *plugin)
{
- PurplePluginInfo *info;
GError *error = NULL;
g_return_val_if_fail(plugin != NULL, FALSE);
- info = purple_plugin_get_info(plugin);
-
if (purple_plugin_is_loaded(plugin))
return TRUE;
- if (!info) {
+ if (!purple_plugin_get_info(plugin)) {
purple_debug_error("plugins",
"Failed to load plugin %s: Plugin does not return a PluginInfo",
purple_plugin_get_filename(plugin));
return FALSE;
}
- if (!purple_plugin_info_is_loadable(info))
+ if (!purple_plugin_is_loadable(plugin))
return FALSE;
if (!gplugin_plugin_manager_load_plugin(plugin, &error)) {
@@ -167,6 +164,15 @@ purple_plugin_get_info(const PurplePlugi
}
void
+purple_plugin_disable(PurplePlugin *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);
+}
+
+void
purple_plugin_add_action(PurplePlugin *plugin, const char* label,
PurplePluginActionCallback callback)
{
@@ -187,13 +193,59 @@ purple_plugin_add_action(PurplePlugin *p
priv->actions = g_list_append(priv->actions, action);
}
-void
-purple_plugin_disable(PurplePlugin *plugin)
+GList *
+purple_plugin_get_actions(const PurplePlugin *plugin)
{
- g_return_if_fail(plugin != NULL);
+ PurplePluginInfo *info;
+ PurplePluginInfoPrivate *priv;
- if (!g_list_find(plugins_to_disable, plugin))
- plugins_to_disable = g_list_prepend(plugins_to_disable, plugin);
+ g_return_val_if_fail(plugin != NULL, NULL);
+
+ info = purple_plugin_get_info(plugin);
+ priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
+
+ g_return_val_if_fail(priv != NULL, NULL);
+
+ return priv->actions;
+}
+
+gboolean
+purple_plugin_is_loadable(const PurplePlugin *plugin)
+{
+ PurplePluginInfo *info;
+ PurplePluginInfoPrivate *priv;
+
+ g_return_val_if_fail(plugin != NULL, FALSE);
+
+ info = purple_plugin_get_info(plugin);
+ priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
+
+ g_return_val_if_fail(priv != NULL, FALSE);
+
+ return priv->loadable;
+}
+
+gchar *
+purple_plugin_get_error(const PurplePlugin *plugin)
+{
+ PurplePluginInfo *info;
+ PurplePluginInfoPrivate *priv;
+
+ g_return_val_if_fail(plugin != NULL, NULL);
+
+ info = purple_plugin_get_info(plugin);
+ priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
+
+ g_return_val_if_fail(priv != NULL, NULL);
+
+ return priv->error;
+}
+
+GSList *
+purple_plugin_get_dependent_plugins(const PurplePlugin *plugin)
+{
+#warning TODO: Implement this when GPlugin can return dependent plugins.
+ return NULL;
}
/**************************************************************************
@@ -461,36 +513,6 @@ purple_plugin_info_get_abi_version(const
return gplugin_plugin_info_get_abi_version(GPLUGIN_PLUGIN_INFO(info));
}
-GList *
-purple_plugin_info_get_actions(const PurplePluginInfo *info)
-{
- PurplePluginInfoPrivate *priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
-
- g_return_val_if_fail(priv != NULL, NULL);
-
- return priv->actions;
-}
-
-gboolean
-purple_plugin_info_is_loadable(const PurplePluginInfo *info)
-{
- PurplePluginInfoPrivate *priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
-
- g_return_val_if_fail(priv != NULL, FALSE);
-
- return priv->loadable;
-}
-
-gchar *
-purple_plugin_info_get_error(const PurplePluginInfo *info)
-{
- PurplePluginInfoPrivate *priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
-
- g_return_val_if_fail(priv != NULL, NULL);
-
- return priv->error;
-}
-
GSList *
purple_plugin_info_get_dependencies(const PurplePluginInfo *info)
{
@@ -499,13 +521,6 @@ purple_plugin_info_get_dependencies(cons
return gplugin_plugin_info_get_dependencies(GPLUGIN_PLUGIN_INFO(info));
}
-GSList *
-purple_plugin_info_get_dependent_plugins(const PurplePluginInfo *info)
-{
-#warning TODO: Implement this when GPlugin can return dependent plugins.
- return NULL;
-}
-
void
purple_plugin_info_set_pref_frame_callback(PurplePluginInfo *info,
PurplePluginPrefFrameCallback callback)
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -169,6 +169,16 @@ const gchar *purple_plugin_get_filename(
PurplePluginInfo *purple_plugin_get_info(const PurplePlugin *plugin);
/**
+ * 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(PurplePlugin *plugin);
+
+/**
* Adds a new action to a plugin.
*
* @param plugin The plugin to add the action to.
@@ -179,14 +189,51 @@ void purple_plugin_add_action(PurplePlug
PurplePluginActionCallback callback);
/**
- * Disable a plugin.
+ * Returns a list of actions that a plugin can perform.
*
- * 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.
+ * @param plugin The plugin to get the actions from.
+ *
+ * @constreturn A list of #PurplePluginAction instances corresponding to the
+ * actions a plugin can perform.
+ *
+ * @see purple_plugin_add_action()
*/
-void purple_plugin_disable(PurplePlugin *plugin);
+GList *purple_plugin_get_actions(const PurplePlugin *plugin);
+
+/**
+ * Returns whether or not a plugin is loadable.
+ *
+ * If this returns @c FALSE, the plugin is guaranteed to not
+ * be loadable. However, a return value of @c TRUE does not
+ * guarantee the plugin is loadable.
+ * An error is set if the plugin is not loadable.
+ *
+ * @param plugin The plugin.
+ *
+ * @return @c TRUE if the plugin may be loadable, @c FALSE if the plugin is not
+ * loadable.
+ *
+ * @see purple_plugin_get_error()
+ */
+gboolean purple_plugin_is_loadable(const PurplePlugin *plugin);
+
+/**
+ * If a plugin is not loadable, this returns the reason.
+ *
+ * @param plugin The plugin.
+ *
+ * @return The reason why the plugin is not loadable.
+ */
+gchar *purple_plugin_get_error(const PurplePlugin *plugin);
+
+/**
+ * Returns a list of plugins that depend on a particular plugin.
+ *
+ * @param plugin The plugin whose dependent plugins are returned.
+ *
+ * @constreturn The list of a plugins that depend on the specified plugin.
+ */
+GSList *purple_plugin_get_dependent_plugins(const PurplePlugin *plugin);
/*@}*/
@@ -300,44 +347,6 @@ const gchar *purple_plugin_info_get_lice
guint32 purple_plugin_info_get_abi_version(const PurplePluginInfo *info);
/**
- * Returns a list of actions that a plugin can perform.
- *
- * @param info The plugin info to get the actions from.
- *
- * @constreturn A list of #PurplePluginAction instances corresponding to the
- * actions a plugin can perform.
- *
- * @see purple_plugin_add_action()
- */
-GList *purple_plugin_info_get_actions(const PurplePluginInfo *info);
-
-/**
- * Returns whether or not a plugin is loadable.
- *
- * If this returns @c FALSE, the plugin is guaranteed to not
- * be loadable. However, a return value of @c TRUE does not
- * guarantee the plugin is loadable.
- * An error is set if the plugin is not loadable.
- *
- * @param info The plugin info of the plugin.
- *
- * @return @c TRUE if the plugin may be loadable, @c FALSE if the plugin is not
- * loadable.
- *
- * @see purple_plugin_info_get_error()
- */
-gboolean purple_plugin_info_is_loadable(const PurplePluginInfo *info);
-
-/**
- * If a plugin is not loadable, this returns the reason.
- *
- * @param info The plugin info of the plugin.
- *
- * @return The reason why the plugin is not loadable.
- */
-gchar *purple_plugin_info_get_error(const PurplePluginInfo *info);
-
-/**
* Returns a list of plugins that a particular plugin depends on.
*
* @param info The plugin's info instance.
@@ -347,15 +356,6 @@ gchar *purple_plugin_info_get_error(cons
GSList *purple_plugin_info_get_dependencies(const PurplePluginInfo *info);
/**
- * Returns a list of plugins that depend on a particular plugin.
- *
- * @param info The plugin info of the plugin whos dependent plugins are needed.
- *
- * @constreturn The list of a plugins that depend on the specified plugin.
- */
-GSList *purple_plugin_info_get_dependent_plugins(const PurplePluginInfo *info);
-
-/**
* Sets a callback to be invoked to retrieve the preferences frame for a plugin.
*
More information about the Commits
mailing list