Refactored nullprotocol to use the new macro soc.2013.gobjectification.plugins

Sun, 08 Sep 2013 12:06:44 +0530

author
Ankit Vani <a@nevitus.org>
date
Sun, 08 Sep 2013 12:06:44 +0530
branch
soc.2013.gobjectification.plugins
changeset 36700
6e948576476e
parent 36699
a8217d8aafc2
child 36701
5acd461707ae

Refactored nullprotocol to use the new macro

libpurple/protocols/null/nullprotocol.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/null/nullprotocol.c	Sun Sep 08 12:06:16 2013 +0530
+++ b/libpurple/protocols/null/nullprotocol.c	Sun Sep 08 12:06:44 2013 +0530
@@ -1148,6 +1148,18 @@
   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 @@
 {
   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 @@
   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);

mercurial