/soc/2013/ankitkv/gobjectification: 8c939ea45957: Added purple_p...

Ankit Vani a at nevitus.org
Tue Aug 6 19:05:40 EDT 2013


Changeset: 8c939ea45957e75baaba2d992b89be59e2418e8c
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-07 04:35 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/8c939ea45957

Description:

Added purple_plugin_register_type() and purple_plugin_add_interface()

diffstat:

 libpurple/plugins.c |  32 +++++++++++++++++++++++++++++++-
 libpurple/plugins.h |  29 +++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletions(-)

diffs (97 lines):

diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -59,8 +59,8 @@ static GObjectClass *parent_class;
 /**************************************************************************
  * Globals
  **************************************************************************/
+#ifdef PURPLE_PLUGINS
 static GList *loaded_plugins     = NULL;
-#ifdef PURPLE_PLUGINS
 static GList *plugins_to_disable = NULL;
 #endif
 
@@ -207,6 +207,32 @@ purple_plugin_disable(PurplePlugin *plug
 #endif
 }
 
+GType
+purple_plugin_register_type(PurplePlugin *plugin, GType parent,
+                            const gchar *name, const GTypeInfo *info,
+                            GTypeFlags flags)
+{
+#ifdef PURPLE_PLUGINS
+	return gplugin_native_plugin_register_type(GPLUGIN_NATIVE_PLUGIN(plugin),
+	                                           parent, name, info, flags);
+
+#else
+	return G_TYPE_INVALID;
+#endif
+}
+
+void
+purple_plugin_add_interface(PurplePlugin *plugin, GType instance_type,
+                            GType interface_type,
+                            const GInterfaceInfo *interface_info)
+{
+#ifdef PURPLE_PLUGINS
+	gplugin_native_plugin_add_interface(GPLUGIN_NATIVE_PLUGIN(plugin),
+	                                    instance_type, interface_type,
+	                                    interface_info);
+#endif
+}
+
 void
 purple_plugin_add_action(PurplePlugin *plugin, const char* label,
                          PurplePluginActionCallback callback)
@@ -721,7 +747,11 @@ purple_plugins_find_all(void)
 GList *
 purple_plugins_get_loaded(void)
 {
+#ifdef PURPLE_PLUGINS
 	return loaded_plugins;
+#else
+	return NULL;
+#endif
 }
 
 void
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -253,6 +253,35 @@ PurplePluginInfo *purple_plugin_get_info
 void purple_plugin_disable(PurplePlugin *plugin);
 
 /**
+ * Registers a new dynamic type.
+ *
+ * @param plugin  The plugin that is registering the type.
+ * @param parent  Type from which this type will be derived.
+ * @param name    Name of the new type.
+ * @param info    Information to initialize and destroy a type's classes and
+ *                instances.
+ * @param flags   Bitwise combination of values that determines the nature
+ *                (e.g. abstract or not) of the type.
+ *
+ * @return The new GType, or @c G_TYPE_INVALID if registration failed.
+ */
+GType purple_plugin_register_type(PurplePlugin *plugin, GType parent,
+                                  const gchar *name, const GTypeInfo *info,
+                                  GTypeFlags flags);
+
+/**
+ * Adds a dynamic interface type to an instantiable type.
+ *
+ * @param plugin          The plugin that is adding the interface type.
+ * @param instance_type   The GType of the instantiable type.
+ * @param interface_type  The GType of the interface type.
+ * @param interface_info  Information used to manage the interface type.
+ */
+void purple_plugin_add_interface(PurplePlugin *plugin, GType instance_type,
+                                 GType interface_type,
+                                 const GInterfaceInfo *interface_info);
+
+/**
  * Adds a new action to a plugin.
  *
  * @param plugin   The plugin to add the action to.



More information about the Commits mailing list