/soc/2013/ankitkv/gobjectification: 6e948576476e: Refactored nul...

Ankit Vani a at nevitus.org
Sun Sep 8 02:42:07 EDT 2013


Changeset: 6e948576476eef8238749cee62abcbd647aa4f83
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-08 12:06 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/6e948576476e

Description:

Refactored nullprotocol to use the new macro

diffstat:

 libpurple/protocols/null/nullprotocol.c |  22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diffs (43 lines):

diff --git a/libpurple/protocols/null/nullprotocol.c b/libpurple/protocols/null/nullprotocol.c
--- a/libpurple/protocols/null/nullprotocol.c
+++ b/libpurple/protocols/null/nullprotocol.c
@@ -1148,6 +1148,18 @@ null_protocol_interface_init(PurpleProto
   iface->offline_message          = null_offline_message;
 }
 
+/*
+ * define the null protocol type. this macro defines
+ * null_protocol_register_type(PurplePlugin *) which is called in plugin_load()
+ * to register this type with the type system, and null_protocol_get_type()
+ * which returns the registered GType.
+ */
+PURPLE_DEFINE_TYPE_EXTENDED(
+  NullProtocol, null_protocol, PURPLE_TYPE_PROTOCOL, 0,
+  PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_INTERFACE,
+                                    null_protocol_interface_init)
+);
+
 static PurplePluginInfo *
 plugin_query(GError **error)
 {
@@ -1174,6 +1186,10 @@ plugin_load(PurplePlugin *plugin, GError
 {
   PurpleCmdId id;
 
+  /* register the NULL_TYPE_PROTOCOL type in the type system. this function
+   * is defined by PURPLE_DEFINE_TYPE_EXTENDED. */
+  null_protocol_register_type(plugin);
+
   /* add the protocol to the core */
   my_protocol = purple_protocols_add(NULL_TYPE_PROTOCOL, error);
   if (!my_protocol)
@@ -1222,7 +1238,5 @@ plugin_unload(PurplePlugin *plugin, GErr
   return TRUE;
 }
 
-static PurplePlugin *my_plugin;
-PURPLE_PROTOCOL_DEFINE(my_plugin, NullProtocol, null_protocol);
-PURPLE_PLUGIN_INIT_VAL(my_plugin, null, plugin_query, plugin_load,
-                       plugin_unload);
+/* initialize the plugin */
+PURPLE_PLUGIN_INIT(null, plugin_query, plugin_load, plugin_unload);



More information about the Commits mailing list