/soc/2013/ankitkv/gobjectification: 0898810f4e9c: Removed Purple...

Ankit Vani a at nevitus.org
Mon Jul 29 02:34:28 EDT 2013


Changeset: 0898810f4e9c4e146687e8f5de0f0170b95426ec
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-29 12:04 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/0898810f4e9c

Description:

Removed PurplePlugin and added PurplePluginInfo, which inherits GPluginPluginInfo

diffstat:

 libpurple/plugins.c |  77 ++++++++++++++++++++++------------------------------
 libpurple/plugins.h |  49 +++++++++++++++-----------------
 2 files changed, 56 insertions(+), 70 deletions(-)

diffs (268 lines):

diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -21,31 +21,29 @@
  */
 #include "plugins.h"
 
-#define PURPLE_PLUGIN_GET_PRIVATE(obj) \
-	(G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_PLUGIN, PurplePluginPrivate))
+#define PURPLE_PLUGIN_INFO_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_PLUGIN_INFO, PurplePluginInfoPrivate))
 
-/** @copydoc _PurplePluginPrivate */
-typedef struct _PurplePluginPrivate  PurplePluginPrivate;
+/** @copydoc _PurplePluginInfoPrivate */
+typedef struct _PurplePluginInfoPrivate  PurplePluginInfoPrivate;
 
 /**************************************************************************
  * Private data
  **************************************************************************/
-struct _PurplePluginPrivate {
-	gboolean unloadable;
+struct _PurplePluginInfoPrivate {
 };
 
-/* Plugin property enums */
+/* Plugin info property enums */
 enum
 {
 	PROP_0,
-	PROP_UNLOADABLE,
 	PROP_LAST
 };
 
-static GPluginPluginImplementationClass *parent_class;
+static GPluginPluginInfoClass *parent_class;
 
 /**************************************************************************
- * Plugin API
+ * PluginInfo API
  **************************************************************************/
 
 
@@ -53,17 +51,17 @@ static GPluginPluginImplementationClass 
  * GObject code
  **************************************************************************/
 /* GObject Property names */
-#define PROP_UNLOADABLE_S  "unloadable"
+#define PROP_S  ""
 
 /* Set method for GObject properties */
 static void
-purple_plugin_set_property(GObject *obj, guint param_id, const GValue *value,
+purple_plugin_info_set_property(GObject *obj, guint param_id, const GValue *value,
 		GParamSpec *pspec)
 {
-	PurplePlugin *plugin = PURPLE_PLUGIN(obj);
+	PurplePluginInfo *plugin_info = PURPLE_PLUGIN_INFO(obj);
 
 	switch (param_id) {
-		case PROP_UNLOADABLE:
+		case PROP_0: /* TODO remove */
 			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -73,13 +71,13 @@ purple_plugin_set_property(GObject *obj,
 
 /* Get method for GObject properties */
 static void
-purple_plugin_get_property(GObject *obj, guint param_id, GValue *value,
+purple_plugin_info_get_property(GObject *obj, guint param_id, GValue *value,
 		GParamSpec *pspec)
 {
-	PurplePlugin *plugin = PURPLE_PLUGIN(obj);
+	PurplePluginInfo *plugin = PURPLE_PLUGIN_INFO(obj);
 
 	switch (param_id) {
-		case PROP_UNLOADABLE:
+		case PROP_0: /* TODO remove */
 			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -89,65 +87,56 @@ purple_plugin_get_property(GObject *obj,
 
 /* GObject initialization function */
 static void
-purple_plugin_init(GTypeInstance *instance, gpointer klass)
+purple_plugin_info_init(GTypeInstance *instance, gpointer klass)
 {
-	PurplePluginPrivate *priv = PURPLE_PLUGIN_GET_PRIVATE(instance);
-
-	priv->unloadable = TRUE;
 }
 
 /* GObject dispose function */
 static void
-purple_plugin_dispose(GObject *object)
+purple_plugin_info_dispose(GObject *object)
 {
 	G_OBJECT_CLASS(parent_class)->dispose(object);
 }
 
 /* GObject finalize function */
 static void
-purple_plugin_finalize(GObject *object)
+purple_plugin_info_finalize(GObject *object)
 {
 	G_OBJECT_CLASS(parent_class)->finalize(object);
 }
 
 /* Class initializer function */
-static void purple_plugin_class_init(PurplePluginClass *klass)
+static void purple_plugin_info_class_init(PurplePluginInfoClass *klass)
 {
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
 
 	parent_class = g_type_class_peek_parent(klass);
 
-	g_type_class_add_private(klass, sizeof(PurplePluginPrivate));
+	g_type_class_add_private(klass, sizeof(PurplePluginInfoPrivate));
 
-	obj_class->dispose = purple_plugin_dispose;
-	obj_class->finalize = purple_plugin_finalize;
+	obj_class->dispose = purple_plugin_info_dispose;
+	obj_class->finalize = purple_plugin_info_finalize;
 
 	/* Setup properties */
-	obj_class->get_property = purple_plugin_get_property;
-	obj_class->set_property = purple_plugin_set_property;
-
-	g_object_class_install_property(obj_class, PROP_UNLOADABLE,
-			g_param_spec_boolean(PROP_UNLOADABLE_S, _("Unloadable"),
-				_("Whether the plugin can be unloaded or not."), TRUE,
-				G_PARAM_READWRITE)
-			);
+	obj_class->get_property = purple_plugin_info_get_property;
+	obj_class->set_property = purple_plugin_info_set_property;
 }
 
 GType
-purple_plugin_get_type(void)
+purple_plugin_info_get_type(void)
 {
 	static GType type = 0;
 
 	if (G_UNLIKELY(type == 0)) {
 		static const GTypeInfo info = {
-			.class_size = sizeof(PurplePluginClass),
-			.class_init = (GClassInitFunc)purple_plugin_class_init,
-			.instance_size = sizeof(PurplePlugin),
-			.instance_init = (GInstanceInitFunc)purple_plugin_init,
+			.class_size = sizeof(PurplePluginInfoClass),
+			.class_init = (GClassInitFunc)purple_plugin_info_class_init,
+			.instance_size = sizeof(PurplePluginInfo),
+			.instance_init = (GInstanceInitFunc)purple_plugin_info_init,
 		};
 
-		type = g_type_register_static(GPLUGIN_TYPE_PLUGIN_IMPLEMENTATION,
-		                              "PurplePlugin", &info, 0);
+		type = g_type_register_static(GPLUGIN_TYPE_PLUGIN_INFO,
+		                              "PurplePluginInfo", &info, 0);
 	}
 
 	return type;
@@ -175,10 +164,10 @@ purple_plugins_init(void) {
 	        the new plugin API is properly established */
 	purple_signal_register(handle, "plugin-load",
 						 purple_marshal_VOID__POINTER,
-						 G_TYPE_NONE, 1, PURPLE_TYPE_PLUGIN);
+						 G_TYPE_NONE, 1, PURPLE_TYPE_PLUGIN_INFO);
 	purple_signal_register(handle, "plugin-unload",
 						 purple_marshal_VOID__POINTER,
-						 G_TYPE_NONE, 1, PURPLE_TYPE_PLUGIN);
+						 G_TYPE_NONE, 1, PURPLE_TYPE_PLUGIN_INFO);
 }
 
 void
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -23,44 +23,41 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  */
-#ifndef _PURPLE_PLUGIN_H_
-#define _PURPLE_PLUGIN_H_
+#ifndef _PURPLE_PLUGINS_H_
+#define _PURPLE_PLUGINS_H_
 
 #include <gplugin.h>
 
-#define PURPLE_TYPE_PLUGIN             (purple_plugin_get_type())
-#define PURPLE_PLUGIN(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PLUGIN, PurplePlugin))
-#define PURPLE_PLUGIN_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_PLUGIN, PurplePluginClass))
-#define PURPLE_IS_PLUGIN(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PLUGIN))
-#define PURPLE_IS_PLUGIN_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_PLUGIN))
-#define PURPLE_PLUGIN_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_PLUGIN, PurplePluginClass))
+#define PURPLE_TYPE_PLUGIN_INFO             (purple_plugin_info_get_type())
+#define PURPLE_PLUGIN_INFO(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PLUGIN_INFO, PurplePluginInfo))
+#define PURPLE_PLUGIN_INFO_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_PLUGIN_INFO, PurplePluginInfoClass))
+#define PURPLE_IS_PLUGIN_INFO(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PLUGIN_INFO))
+#define PURPLE_IS_PLUGIN_INFO_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_PLUGIN_INFO))
+#define PURPLE_PLUGIN_INFO_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_PLUGIN_INFO, PurplePluginInfoClass))
 
-/** @copydoc _PurplePlugin */
-typedef struct _PurplePlugin PurplePlugin;
-/** @copydoc _PurplePluginClass */
-typedef struct _PurplePluginClass PurplePluginClass;
+/** @copydoc _PurplePluginInfo */
+typedef struct _PurplePluginInfo PurplePluginInfo;
+/** @copydoc _PurplePluginInfoClass */
+typedef struct _PurplePluginInfoClass PurplePluginInfoClass;
 
 #include "pluginpref.h"
 
 /**
- * Represents a plugin that can be loaded/unloaded by libpurple.
- *
- * #PurplePlugin inherits #GPluginPluginImplementation, which holds the
- * low-level details about the plugin in a #GPluginPlugin instance.
+ * Detailed information about a plugin.
  */
-struct _PurplePlugin {
+struct _PurplePluginInfo {
 	/*< private >*/
-	GPluginPluginImplementation parent;
+	GPluginPluginInfo parent;
 };
 
 /**
- * PurplePluginClass:
+ * PurplePluginInfoClass:
  *
- * The base class for all #PurplePlugin's.
+ * The base class for all #PurplePluginInfo's.
  */
-struct _PurplePluginClass {
+struct _PurplePluginInfoClass {
 	/*< private >*/
-	GPluginPluginImplementationClass parent_class;
+	GPluginPluginInfoClass parent_class;
 
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
@@ -71,14 +68,14 @@ struct _PurplePluginClass {
 G_BEGIN_DECLS
 
 /**************************************************************************/
-/** @name Plugin API                                                      */
+/** @name PluginInfo API                                                      */
 /**************************************************************************/
 /*@{*/
 
 /**
- * Returns the GType for the PurplePlugin object.
+ * Returns the GType for the PurplePluginInfo object.
  */
-GType purple_plugin_get_type(void);
+GType purple_plugin_info_get_type(void);
 
 /*@}*/
 
@@ -108,4 +105,4 @@ void purple_plugins_uninit(void);
 
 G_END_DECLS
 
-#endif /* _PURPLE_PLUGIN_H_ */
+#endif /* _PURPLE_PLUGINS_H_ */



More information about the Commits mailing list