/soc/2013/ankitkv/gobjectification: 76943492ab1b: Added property...
Ankit Vani
a at nevitus.org
Fri Aug 9 16:23:33 EDT 2013
Changeset: 76943492ab1b24f5058771b87adc6405969724d8
Author: Ankit Vani <a at nevitus.org>
Date: 2013-08-10 01:50 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/76943492ab1b
Description:
Added property "purple-version"
diffstat:
libpurple/plugins.c | 59 ++++++++++++++++++++++++++----------
libpurple/plugins.h | 12 ++++++-
libpurple/protocols/null/nullprpl.c | 21 ++++++------
3 files changed, 65 insertions(+), 27 deletions(-)
diffs (201 lines):
diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -35,23 +35,25 @@ typedef struct _PurplePluginInfoPrivate
* Plugin info private data
**************************************************************************/
struct _PurplePluginInfoPrivate {
- char *category; /**< The category the plugin belongs to */
- char *ui_requirement; /**< ID of UI that is required to load the plugin */
- GList *actions; /**< Actions that the plugin can perform */
- gboolean loadable; /**< Whether the plugin is loadable */
- char *error; /**< Why the plugin is not loadable */
+ guint32 purple_version; /**< The version of purple required by the plugin */
+ char *category; /**< The category the plugin belongs to */
+ char *ui_requirement; /**< ID of UI that is required to load the plugin */
+ GList *actions; /**< Actions that the plugin can perform */
+ gboolean loadable; /**< Whether the plugin is loadable */
+ char *error; /**< Why the plugin is not loadable */
/** Callback that returns a preferences frame for a plugin */
PurplePluginPrefFrameCallback get_pref_frame;
/** TRUE if a plugin has been unloaded at least once. Load-on-query
- * plugins that have been unloaded once will not be auto-loaded again. */
+ * plugins that have been unloaded once will not be auto-loaded again. */
gboolean unloaded;
};
enum
{
PROP_0,
+ PROP_PURPLE_VERSION,
PROP_CATEGORY,
PROP_UI_REQUIREMENT,
PROP_PREFERENCES_FRAME,
@@ -349,6 +351,7 @@ purple_plugin_get_dependent_plugins(cons
* GObject code for PurplePluginInfo
**************************************************************************/
/* GObject Property names */
+#define PROP_PURPLE_VERSION_S "purple-version"
#define PROP_CATEGORY_S "category"
#define PROP_UI_REQUIREMENT_S "ui-requirement"
#define PROP_PREFERENCES_FRAME_S "preferences-frame"
@@ -362,6 +365,9 @@ purple_plugin_info_set_property(GObject
PurplePluginInfoPrivate *priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
switch (param_id) {
+ case PROP_PURPLE_VERSION:
+ priv->purple_version = g_value_get_uint(value);
+ break;
case PROP_CATEGORY:
priv->category = g_strdup(g_value_get_string(value));
break;
@@ -385,6 +391,10 @@ purple_plugin_info_get_property(GObject
PurplePluginInfo *info = PURPLE_PLUGIN_INFO(obj);
switch (param_id) {
+ case PROP_PURPLE_VERSION:
+ g_value_set_uint(value,
+ purple_plugin_info_get_purple_version(info));
+ break;
case PROP_CATEGORY:
g_value_set_string(value, purple_plugin_info_get_category(info));
break;
@@ -405,7 +415,7 @@ purple_plugin_info_constructed(GObject *
PurplePluginInfo *info = PURPLE_PLUGIN_INFO(object);
PurplePluginInfoPrivate *priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
const char *id = purple_plugin_info_get_id(info);
- guint32 abi_version;
+ guint32 version;
parent_class->constructed(object);
@@ -428,17 +438,17 @@ purple_plugin_info_constructed(GObject *
priv->loadable = FALSE;
}
- abi_version = purple_plugin_info_get_abi_version(info);
- if (PURPLE_PLUGIN_ABI_MAJOR_VERSION(abi_version) != PURPLE_MAJOR_VERSION ||
- PURPLE_PLUGIN_ABI_MINOR_VERSION(abi_version) > PURPLE_MINOR_VERSION)
+ version = purple_plugin_info_get_purple_version(info);
+ if (PURPLE_PLUGIN_ABI_MAJOR_VERSION(version) != PURPLE_MAJOR_VERSION ||
+ PURPLE_PLUGIN_ABI_MINOR_VERSION(version) > PURPLE_MINOR_VERSION)
{
- priv->error = g_strdup_printf(_("ABI version mismatch %d.%d.x (need %d.%d.x)"),
- PURPLE_PLUGIN_ABI_MAJOR_VERSION(abi_version),
- PURPLE_PLUGIN_ABI_MINOR_VERSION(abi_version),
+ priv->error = g_strdup_printf(_("libpurple version mismatch %d.%d.x (need %d.%d.x)"),
+ PURPLE_PLUGIN_ABI_MAJOR_VERSION(version),
+ PURPLE_PLUGIN_ABI_MINOR_VERSION(version),
PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION);
- purple_debug_error("plugins", "%s is not loadable: ABI version mismatch %d.%d.x (need %d.%d.x)\n",
- id, PURPLE_PLUGIN_ABI_MAJOR_VERSION(abi_version),
- PURPLE_PLUGIN_ABI_MINOR_VERSION(abi_version),
+ purple_debug_error("plugins", "%s is not loadable: libpurple version mismatch %d.%d.x (need %d.%d.x)\n",
+ id, PURPLE_PLUGIN_ABI_MAJOR_VERSION(version),
+ PURPLE_PLUGIN_ABI_MINOR_VERSION(version),
PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION);
priv->loadable = FALSE;
}
@@ -478,6 +488,13 @@ static void purple_plugin_info_class_ini
obj_class->get_property = purple_plugin_info_get_property;
obj_class->set_property = purple_plugin_info_set_property;
+ g_object_class_install_property(obj_class, PROP_PURPLE_VERSION,
+ g_param_spec_uint(PROP_PURPLE_VERSION_S,
+ "Purple version",
+ "The libpurple ABI version required by the plugin",
+ 0, G_MAXUINT32, 0,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
g_object_class_install_property(obj_class, PROP_CATEGORY,
g_param_spec_string(PROP_CATEGORY_S,
"Category",
@@ -695,6 +712,16 @@ purple_plugin_info_get_license_url(const
#endif
}
+guint32
+purple_plugin_info_get_purple_version(const PurplePluginInfo *info)
+{
+ PurplePluginInfoPrivate *priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
+
+ g_return_val_if_fail(priv != NULL, 0);
+
+ return priv->purple_version;
+}
+
GSList *
purple_plugin_info_get_dependencies(const PurplePluginInfo *info)
{
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -369,7 +369,7 @@ GType purple_plugin_info_get_type(void);
* Creates a new #PurplePluginInfo instance to be returned from
* gplugin_plugin_query() of a plugin, using the provided name/value pairs.
*
- * All properties except "id" and "abi-version" are optional.
+ * All properties except "id", "purple-version", and "abi-version" are optional.
*
* Valid property names are: \n
* "id" (string) The ID of the plugin.
@@ -391,6 +391,7 @@ GType purple_plugin_info_get_type(void);
* unlisted on SPDX. \n
* "license-url" (string) The plugin's license URL, if unlisted on
* SPDX. \n
+ * "purple-version" (guint32) The purple ABI version required by plugin. \n
* "abi-version" (guint32) The GPlugin ABI version of the plugin. \n
* "dependencies" (GSList) List of plugin IDs required by the plugin. \n
* "preferences-frame" (PurplePluginPrefFrameCallback) Callback that returns
@@ -522,6 +523,15 @@ const gchar *purple_plugin_info_get_lice
const gchar *purple_plugin_info_get_license_url(const PurplePluginInfo *info);
/**
+ * Returns the required purple ABI version for a plugin.
+ *
+ * @param info The plugin's info instance.
+ *
+ * @return The required purple ABI version for the plugin.
+ */
+guint32 purple_plugin_info_get_purple_version(const PurplePluginInfo *info);
+
+/**
* Returns a list of plugins that a particular plugin depends on.
*
* @param info The plugin's info instance.
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
@@ -1138,19 +1138,20 @@ static PurplePluginInfo *
plugin_query(void)
{
return purple_plugin_info_new(
- "id", NULLPRPL_ID,
- "name", "Null - Testing Plugin",
- "version", DISPLAY_VERSION,
- "category", "Protocol",
- "summary", N_("Null Protocol Plugin"),
- "description", N_("Null Protocol Plugin"),
- "website", PURPLE_WEBSITE,
- "abi-version", PURPLE_ABI_VERSION,
+ "id", NULLPRPL_ID,
+ "name", "Null - Testing Plugin",
+ "version", DISPLAY_VERSION,
+ "category", N_("Protocol"),
+ "summary", N_("Null Protocol Plugin"),
+ "description", N_("Null Protocol Plugin"),
+ "website", PURPLE_WEBSITE,
+ "purple-version", PURPLE_ABI_VERSION,
+ "abi-version", GPLUGIN_NATIVE_PLUGIN_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,
+ "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL |
+ GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY,
NULL
);
}
More information about the Commits
mailing list