/soc/2013/ankitkv/gobjectification: 70047858a8fd: Merged soc.201...

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


Changeset: 70047858a8fd56452cb1c4cca78fed852e9de5e0
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-23 14:09 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/70047858a8fd

Description:

Merged soc.2013.gobjectification branch

diffstat:

 doc/C-HOWTO.dox                    |  20 +++++------------
 libpurple/plugins/debug_example.c  |  32 +--------------------------
 libpurple/plugins/helloworld.c     |  26 +---------------------
 libpurple/plugins/notify_example.c |  43 ++++++-------------------------------
 4 files changed, 17 insertions(+), 104 deletions(-)

diffs (215 lines):

diff --git a/doc/C-HOWTO.dox b/doc/C-HOWTO.dox
--- a/doc/C-HOWTO.dox
+++ b/doc/C-HOWTO.dox
@@ -14,19 +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 "plugins.h"
+#include <purple.h>
 
 static PurplePluginInfo *
 plugin_query(GError **error)
@@ -71,13 +67,9 @@ PURPLE_PLUGIN_INIT(hello_world, plugin_q
 
   @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 plugins.h which has all the plugin specific stuff that we
-  need.  For example: @c #PurplePlugin, @c #PurplePluginInfo,
-  and @c PURPLE_PLUGIN_INIT().
+  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_query, @c plugin_load and @c plugin_unload must be implemented in
   every plugin.  Each of these functions can return an error on failure by using
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 "plugins.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,30 +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 <plugins.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,65 +20,39 @@
  *
  */
 
-#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_AUTHORS { "John Bailey <rekkanoryo at cpw.pidgin.im>", NULL }
 
-#include <notify.h>
-#include <plugins.h>
-#include <version.h>
-
-static PurplePlugin *notify_example = NULL;
-
 /* 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
 notify_error_cb(PurplePluginAction *action)
 {
-	purple_notify_error(notify_example, "Test Notification", "Test Notification",
+	purple_notify_error(action->plugin, "Test Notification", "Test Notification",
 		"This is a test error notification", NULL);
 }
 
 static void
 notify_info_cb(PurplePluginAction *action)
 {
-	purple_notify_info(notify_example, "Test Notification", "Test Notification",
+	purple_notify_info(action->plugin, "Test Notification", "Test Notification",
 		"This is a test informative notification", NULL);
 }
 
 static void
 notify_warn_cb(PurplePluginAction *action)
 {
-	purple_notify_warning(notify_example, "Test Notification", "Test Notification",
+	purple_notify_warning(action->plugin, "Test Notification", "Test Notification",
 		"This is a test warning notification", NULL);
 }
 
 static void
 notify_format_cb(PurplePluginAction *action)
 {
-	purple_notify_formatted(notify_example, "Test Notification", "Test Notification",
+	purple_notify_formatted(action->plugin, "Test Notification", "Test Notification",
 		"Test Notification",
 		"<I>This is a test notification with formatted text.</I>", NULL, NULL);
 }
@@ -87,7 +61,7 @@ static void
 notify_uri_cb(PurplePluginAction *action)
 {
 	/* This one should open your web browser of choice. */
-	purple_notify_uri(notify_example, "https://www.pidgin.im/");
+	purple_notify_uri(action->plugin, "https://www.pidgin.im/");
 }
 
 static GList *
@@ -137,9 +111,6 @@ plugin_query(GError **error)
 static gboolean
 plugin_load(PurplePlugin *plugin, GError **error)
 {
-	/* we need a handle for all the notify calls */
-	notify_example = plugin;
-
 	return TRUE;
 }
 



More information about the Commits mailing list