/soc/2013/ankitkv/gobjectification: 54ebd3dcae16: Simplified exa...

Ankit Vani a at nevitus.org
Mon Sep 23 04:39:43 EDT 2013


Changeset: 54ebd3dcae16311fc6531f4b0ac16c7733a40dce
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-23 14:03 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/54ebd3dcae16

Description:

Simplified example plugins by including purple.h

diffstat:

 doc/C-HOWTO.dox                    |  26 ++++++--------------------
 libpurple/plugins/debug_example.c  |  32 ++------------------------------
 libpurple/plugins/helloworld.c     |  27 ++-------------------------
 libpurple/plugins/notify_example.c |  28 ++--------------------------
 4 files changed, 12 insertions(+), 101 deletions(-)

diffs (170 lines):

diff --git a/doc/C-HOWTO.dox b/doc/C-HOWTO.dox
--- a/doc/C-HOWTO.dox
+++ b/doc/C-HOWTO.dox
@@ -14,20 +14,15 @@
 
   All plugins must have @c PURPLE_PLUGINS defined and the definition must be
   before including any libpurple, Pidgin, or Finch header files.  Failure to do
-  so can lead to strange errors that are hard to diagnose.  Just don't forget!
+  so can lead to strange errors that are hard to diagnose.  Including purple.h
+  will define this for you.
 
  @section hello_world Hello World!
   I know every tutorial has a hello world, so why should libpurple be any
   different?
 
   @code
-#define PURPLE_PLUGINS
-
-#include <glib.h>
-
-#include "notify.h"
-#include "plugin.h"
-#include "version.h"
+#include <purple.h>
 
 static gboolean
 plugin_load(PurplePlugin *plugin) {
@@ -80,18 +75,9 @@ PURPLE_INIT_PLUGIN(hello_world, init_plu
 
   @endcode
 
-  Okay, so what does all this mean?  We start off by defining @c PURPLE_PLUGINS
-  like described before.  Next we include glib.h, mainly for gboolean and the
-  glib wrappers of the standard C types.
-
-  Next, we include plugin.h which has all the plugin specific stuff that we
-  need.  For example: @c PurplePlugin, @c PurplePluginInfo,
-  @c PURPLE_PLUGIN_MAGIC, and @c PURPLE_INIT_PLUGIN().
-
-  Our last include is version.h which defines @c PURPLE_MAJOR_VERSION, and
-  @c PURPLE_MINOR_VERSION.  There is not much you need to know about these,
-  except that they are required and will stop your plugin from crashing Pidgin
-  when something has changed that your plugin does not know about yet.
+  Okay, so what does all this mean?  We start off by including purple.h.  This
+  file defines @c PURPLE_PLUGINS as described before so that we don't have to
+  manually define it.  It also includes all the libpurple header files.
 
   @c plugin_load is not required.  It is called when the plugin is loaded so
   that you can initialize any variables and so on.  In this plugin we'll just
diff --git a/libpurple/plugins/debug_example.c b/libpurple/plugins/debug_example.c
--- a/libpurple/plugins/debug_example.c
+++ b/libpurple/plugins/debug_example.c
@@ -20,36 +20,8 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-/* We're including glib.h again for the gboolean type. */
-#include <glib.h>
-
-/* This will prevent compiler errors in some instances and is better explained in the
- * how-to documents on the wiki */
-#ifndef G_GNUC_NULL_TERMINATED
-# if __GNUC__ >= 4
-#  define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
-# else
-#  define G_GNUC_NULL_TERMINATED
-# endif
-#endif
-
-/* This is the required definition of PURPLE_PLUGINS as required for a plugin,
- * but we protect it with an #ifndef because config.h may define it for us
- * already and this would cause an unneeded compiler warning. */
-#ifndef PURPLE_PLUGINS
-# define PURPLE_PLUGINS
-#endif
-
-/* Here we're including the necessary libpurple headers for this plugin.  Note
- * that we're including them in alphabetical order.  This isn't necessary but
- * we do this throughout our source for consistency. */
-#include "debug.h"
-#include "plugin.h"
-#include "version.h"
+/* This file defines PURPLE_PLUGINS and includes all the libpurple headers */
+#include <purple.h>
 
 /* It's more convenient to type PLUGIN_ID all the time than it is to type
  * "core-debugexample", so define this convenience macro. */
diff --git a/libpurple/plugins/helloworld.c b/libpurple/plugins/helloworld.c
--- a/libpurple/plugins/helloworld.c
+++ b/libpurple/plugins/helloworld.c
@@ -21,31 +21,8 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-/* config.h may define PURPLE_PLUGINS; protect the definition here so that we
- * don't get complaints about redefinition when it's not necessary. */
-#ifndef PURPLE_PLUGINS
-# define PURPLE_PLUGINS
-#endif
-
-#include <glib.h>
-
-/* This will prevent compiler errors in some instances and is better explained in the
- * how-to documents on the wiki */
-#ifndef G_GNUC_NULL_TERMINATED
-# if __GNUC__ >= 4
-#  define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
-# else
-#  define G_GNUC_NULL_TERMINATED
-# endif
-#endif
-
-#include <notify.h>
-#include <plugin.h>
-#include <version.h>
+/* This file defines PURPLE_PLUGINS and includes all the libpurple headers */
+#include <purple.h>
 
 /* This function is the callback for the plugin action we added. All we're
  * doing here is displaying a message. When the user selects the plugin
diff --git a/libpurple/plugins/notify_example.c b/libpurple/plugins/notify_example.c
--- a/libpurple/plugins/notify_example.c
+++ b/libpurple/plugins/notify_example.c
@@ -20,36 +20,12 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-
-/* This will prevent compiler errors in some instances and is better explained in the
- * how-to documents on the wiki */
-#ifndef G_GNUC_NULL_TERMINATED
-# if __GNUC__ >= 4
-#  define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
-# else
-#  define G_GNUC_NULL_TERMINATED
-# endif
-#endif
-
-/* This is the required definition of PURPLE_PLUGINS as required for a plugin,
- * but we protect it with an #ifndef because config.h may define it for us
- * already and this would cause an unneeded compiler warning. */
-#ifndef PURPLE_PLUGINS
-# define PURPLE_PLUGINS
-#endif
+/* This file defines PURPLE_PLUGINS and includes all the libpurple headers */
+#include <purple.h>
 
 #define PLUGIN_ID "core-notifyexample"
 #define PLUGIN_AUTHOR "John Bailey <rekkanoryo at cpw.pidgin.im>"
 
-#include <notify.h>
-#include <plugin.h>
-#include <version.h>
-
 /* The next four functions and the calls within them should cause dialog boxes to appear
  * when you select the plugin action from the Tools->Notify Example menu */
 static void



More information about the Commits mailing list