/soc/2013/ankitkv/gobjectification: 4084c34c051d: Override gplug...
Ankit Vani
a at nevitus.org
Mon Sep 2 07:51:18 EDT 2013
Changeset: 4084c34c051d3aeb1f11296de6ff5842fdde77a0
Author: Ankit Vani <a at nevitus.org>
Date: 2013-09-02 17:20 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/4084c34c051d
Description:
Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
diffstat:
libpurple/Makefile.am | 1 +
libpurple/plugins.c | 71 +++++++++++++++++++--------
libpurple/plugins.h | 29 +++++++---
libpurple/plugins/keyrings/gnomekeyring.c | 2 +-
libpurple/plugins/keyrings/internalkeyring.c | 2 +-
libpurple/plugins/keyrings/secretservice.c | 2 +-
libpurple/plugins/keyrings/wincred.c | 2 +-
libpurple/plugins/ssl/ssl-gnutls.c | 2 +-
libpurple/plugins/ssl/ssl-nss.c | 2 +-
libpurple/plugins/ssl/ssl.c | 2 +-
libpurple/protocols/bonjour/bonjour.c | 4 +-
libpurple/protocols/gg/gg.c | 4 +-
libpurple/protocols/irc/irc.c | 4 +-
libpurple/protocols/jabber/libfacebook.c | 4 +-
libpurple/protocols/jabber/libgtalk.c | 4 +-
libpurple/protocols/jabber/libxmpp.c | 4 +-
libpurple/protocols/msn/msn.c | 4 +-
libpurple/protocols/mxit/mxit.c | 4 +-
libpurple/protocols/myspace/myspace.c | 4 +-
libpurple/protocols/novell/novell.c | 4 +-
libpurple/protocols/null/nullprotocol.c | 4 +-
libpurple/protocols/oscar/libaim.c | 4 +-
libpurple/protocols/oscar/libicq.c | 4 +-
libpurple/protocols/sametime/sametime.c | 4 +-
libpurple/protocols/silc/silc.c | 4 +-
libpurple/protocols/simple/simple.c | 4 +-
libpurple/protocols/yahoo/libyahoo.c | 4 +-
libpurple/protocols/yahoo/libyahoojp.c | 4 +-
libpurple/protocols/zephyr/zephyr.c | 4 +-
29 files changed, 115 insertions(+), 76 deletions(-)
diffs (truncated from 597 to 300 lines):
diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -194,6 +194,7 @@ purple_enumheaders = \
connection.h \
conversation.h \
conversationtypes.h \
+ plugins.h \
protocols.h \
status.h
diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -24,6 +24,7 @@
#include "core.h"
#include "debug.h"
#include "dbus-maybe.h"
+#include "enums.h"
#include "plugins.h"
#define PURPLE_PLUGIN_INFO_GET_PRIVATE(obj) \
@@ -39,6 +40,8 @@ struct _PurplePluginInfoPrivate {
char *ui_requirement; /**< ID of UI that is required to load the plugin */
char *error; /**< Why a plugin is not loadable */
+ PurplePluginInfoFlags flags; /**< Flags for the plugin */
+
/** Callback that returns a list of actions the plugin can perform */
PurplePluginGetActionsCallback get_actions;
@@ -56,6 +59,7 @@ enum
PROP_UI_REQUIREMENT,
PROP_GET_ACTIONS,
PROP_PREFERENCES_FRAME,
+ PROP_FLAGS,
PROP_LAST
};
@@ -261,17 +265,18 @@ gboolean
purple_plugin_is_internal(const PurplePlugin *plugin)
{
#ifdef PURPLE_PLUGINS
- GPluginPluginInfo *info;
+ PurplePluginInfo *info;
g_return_val_if_fail(plugin != NULL, FALSE);
- info = GPLUGIN_PLUGIN_INFO(purple_plugin_get_info(plugin));
+ info = purple_plugin_get_info(plugin);
+ if (!info)
+ return TRUE;
- g_return_val_if_fail(info != NULL, FALSE);
-
- return (gplugin_plugin_info_get_flags(info) &
- GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL);
-
+ return ((purple_plugin_info_get_flags(info) &
+ PURPLE_PLUGIN_INFO_FLAGS_INTERNAL) ||
+ (gplugin_plugin_info_get_flags(GPLUGIN_PLUGIN_INFO(info)) &
+ GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL));
#else
return FALSE;
#endif
@@ -296,6 +301,7 @@ purple_plugin_get_dependent_plugins(cons
#define PROP_UI_REQUIREMENT_S "ui-requirement"
#define PROP_GET_ACTIONS_S "get-actions"
#define PROP_PREFERENCES_FRAME_S "preferences-frame"
+#define PROP_FLAGS_S "flags"
/* GObject initialization function */
static void
@@ -322,6 +328,9 @@ purple_plugin_info_set_property(GObject
case PROP_PREFERENCES_FRAME:
priv->get_pref_frame = g_value_get_pointer(value);
break;
+ case PROP_FLAGS:
+ priv->flags = g_value_get_flags(value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
break;
@@ -344,6 +353,9 @@ purple_plugin_info_get_property(GObject
g_value_set_pointer(value,
purple_plugin_info_get_pref_frame_callback(info));
break;
+ case PROP_FLAGS:
+ g_value_set_flags(value, purple_plugin_info_get_flags(info));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
break;
@@ -427,20 +439,27 @@ static void purple_plugin_info_class_ini
g_object_class_install_property(obj_class, PROP_UI_REQUIREMENT,
g_param_spec_string(PROP_UI_REQUIREMENT_S,
- "UI Requirement",
- "ID of UI that is required by this plugin", NULL,
+ _("UI Requirement"),
+ _("ID of UI that is required by this plugin"), NULL,
G_PARAM_WRITABLE));
g_object_class_install_property(obj_class, PROP_GET_ACTIONS,
g_param_spec_pointer(PROP_GET_ACTIONS_S,
- "Plugin actions",
- "Callback that returns list of the plugin's actions",
+ _("Plugin actions"),
+ _("Callback that returns list of plugin's actions"),
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property(obj_class, PROP_PREFERENCES_FRAME,
g_param_spec_pointer(PROP_PREFERENCES_FRAME_S,
- "Preferences frame callback",
- "The callback that returns the preferences frame",
+ _("Preferences frame callback"),
+ _("The callback that returns the preferences frame"),
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property(obj_class, PROP_FLAGS,
+ g_param_spec_flags(PROP_FLAGS_S,
+ _("Plugin flags"),
+ _("The flags for the plugin"),
+ PURPLE_TYPE_PLUGIN_INFO_FLAGS, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
@@ -692,6 +711,16 @@ purple_plugin_info_get_pref_frame_callba
return priv->get_pref_frame;
}
+PurplePluginInfoFlags
+purple_plugin_info_get_flags(const PurplePluginInfo *info)
+{
+ PurplePluginInfoPrivate *priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
+
+ g_return_val_if_fail(priv != NULL, 0);
+
+ return priv->flags;
+}
+
const gchar *
purple_plugin_info_get_error(const PurplePluginInfo *info)
{
@@ -815,20 +844,20 @@ 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;
+ PurplePluginInfo *info;
PurplePluginInfoPrivate *priv;
if (purple_plugin_is_loaded(plugin))
continue;
- info = GPLUGIN_PLUGIN_INFO(purple_plugin_get_info(plugin));
+ info = purple_plugin_get_info(plugin);
if (!info)
continue;
priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
- if (!priv->unloaded && gplugin_plugin_info_get_flags(info) &
- GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY) {
+ if (!priv->unloaded && purple_plugin_info_get_flags(info) &
+ PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD) {
purple_debug_info("plugins", "Auto-loading plugin %s\n",
purple_plugin_get_filename(plugin));
purple_plugin_load(plugin, NULL);
@@ -890,14 +919,12 @@ purple_plugins_save_loaded(const char *k
for (pl = purple_plugins_get_loaded(); pl != NULL; pl = pl->next) {
PurplePlugin *plugin = PURPLE_PLUGIN(pl->data);
- GPluginPluginInfo *info =
- GPLUGIN_PLUGIN_INFO(purple_plugin_get_info(plugin));
-
+ PurplePluginInfo *info = purple_plugin_get_info(plugin);
if (!info)
continue;
- if (gplugin_plugin_info_get_flags(info) &
- GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY)
+ if (purple_plugin_info_get_flags(info) &
+ PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD)
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
@@ -71,9 +71,6 @@ typedef GPluginPluginClass PurplePluginC
#define PURPLE_IS_PLUGIN_CLASS(klass) G_IS_OBJECT_CLASS(klass)
#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;
@@ -103,6 +100,15 @@ typedef GList *(*PurplePluginGetActionsC
typedef PurplePluginPrefFrame *(*PurplePluginPrefFrameCallback)(PurplePlugin *);
/**
+ * Flags that can be used to treat plugins differently.
+ */
+typedef enum /*< flags >*/
+{
+ PURPLE_PLUGIN_INFO_FLAGS_INTERNAL = 1 << 1, /**< Plugin is not shown in UI lists */
+ PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD = 1 << 2, /**< Auto-load the plugin */
+} PurplePluginInfoFlags;
+
+/**
* Holds information about a plugin.
*/
struct _PurplePluginInfo {
@@ -401,12 +407,7 @@ GType purple_plugin_info_get_type(void);
* perform. \n
* "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
+ * "flags" (PurplePluginInfoFlags) The flags for a plugin. \n
*
* @param first_property The first property name
* @param ... The value of the first property, followed optionally by more
@@ -571,6 +572,16 @@ PurplePluginPrefFrameCallback
purple_plugin_info_get_pref_frame_callback(const PurplePluginInfo *info);
/**
+ * Returns the plugin's flags.
+ *
+ * @param info The plugin's info instance.
+ *
+ * @return The flags of the plugin.
+ */
+PurplePluginInfoFlags
+purple_plugin_info_get_flags(const PurplePluginInfo *info);
+
+/**
* Returns an error in the plugin info that would prevent the plugin from being
* loaded.
*
diff --git a/libpurple/plugins/keyrings/gnomekeyring.c b/libpurple/plugins/keyrings/gnomekeyring.c
--- a/libpurple/plugins/keyrings/gnomekeyring.c
+++ b/libpurple/plugins/keyrings/gnomekeyring.c
@@ -395,7 +395,7 @@ plugin_query(GError **error)
"authors", authors,
"website", PURPLE_WEBSITE,
"abi-version", PURPLE_ABI_VERSION,
- "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL,
+ "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL,
NULL
);
}
diff --git a/libpurple/plugins/keyrings/internalkeyring.c b/libpurple/plugins/keyrings/internalkeyring.c
--- a/libpurple/plugins/keyrings/internalkeyring.c
+++ b/libpurple/plugins/keyrings/internalkeyring.c
@@ -970,7 +970,7 @@ plugin_query(GError **error)
"authors", authors,
"website", PURPLE_WEBSITE,
"abi-version", PURPLE_ABI_VERSION,
- "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL,
+ "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL,
NULL
);
}
diff --git a/libpurple/plugins/keyrings/secretservice.c b/libpurple/plugins/keyrings/secretservice.c
--- a/libpurple/plugins/keyrings/secretservice.c
+++ b/libpurple/plugins/keyrings/secretservice.c
@@ -300,7 +300,7 @@ plugin_query(GError **error)
"authors", authors,
"website", PURPLE_WEBSITE,
"abi-version", PURPLE_ABI_VERSION,
- "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL,
+ "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL,
NULL
);
}
diff --git a/libpurple/plugins/keyrings/wincred.c b/libpurple/plugins/keyrings/wincred.c
--- a/libpurple/plugins/keyrings/wincred.c
+++ b/libpurple/plugins/keyrings/wincred.c
@@ -271,7 +271,7 @@ plugin_query(GError **error)
"authors", authors,
"website", PURPLE_WEBSITE,
"abi-version", PURPLE_ABI_VERSION,
- "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL,
+ "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL,
NULL
);
}
diff --git a/libpurple/plugins/ssl/ssl-gnutls.c b/libpurple/plugins/ssl/ssl-gnutls.c
--- a/libpurple/plugins/ssl/ssl-gnutls.c
+++ b/libpurple/plugins/ssl/ssl-gnutls.c
@@ -1297,7 +1297,7 @@ plugin_query(GError **error)
"authors", authors,
More information about the Commits
mailing list