| 12 also want to develop against the code in our Mercurial repository if you need |
12 also want to develop against the code in our Mercurial repository if you need |
| 13 to use a new feature. Please do not abuse our Mercurial repository, however. |
13 to use a new feature. Please do not abuse our Mercurial repository, however. |
| 14 |
14 |
| 15 All plugins must have @c PURPLE_PLUGINS defined and the definition must be |
15 All plugins must have @c PURPLE_PLUGINS defined and the definition must be |
| 16 before including any libpurple, Pidgin, or Finch header files. Failure to do |
16 before including any libpurple, Pidgin, or Finch header files. Failure to do |
| 17 so can lead to strange errors that are hard to diagnose. Just don't forget! |
17 so can lead to strange errors that are hard to diagnose. Including purple.h |
| |
18 will define this for you. |
| 18 |
19 |
| 19 @section hello_world Hello World! |
20 @section hello_world Hello World! |
| 20 I know every tutorial has a hello world, so why should libpurple be any |
21 I know every tutorial has a hello world, so why should libpurple be any |
| 21 different? |
22 different? |
| 22 |
23 |
| 23 @code |
24 @code |
| 24 #define PURPLE_PLUGINS |
25 #include <purple.h> |
| 25 |
|
| 26 #include <glib.h> |
|
| 27 |
|
| 28 #include "notify.h" |
|
| 29 #include "plugins.h" |
|
| 30 |
26 |
| 31 static PurplePluginInfo * |
27 static PurplePluginInfo * |
| 32 plugin_query(GError **error) |
28 plugin_query(GError **error) |
| 33 { |
29 { |
| 34 const gchar * const authors[] = { |
30 const gchar * const authors[] = { |
| 69 |
65 |
| 70 PURPLE_PLUGIN_INIT(hello_world, plugin_query, plugin_load, plugin_unload); |
66 PURPLE_PLUGIN_INIT(hello_world, plugin_query, plugin_load, plugin_unload); |
| 71 |
67 |
| 72 @endcode |
68 @endcode |
| 73 |
69 |
| 74 Okay, so what does all this mean? We start off by defining @c PURPLE_PLUGINS |
70 Okay, so what does all this mean? We start off by including purple.h. This |
| 75 like described before. Next we include glib.h, mainly for gboolean and the |
71 file defines @c PURPLE_PLUGINS as described before so that we don't have to |
| 76 glib wrappers of the standard C types. |
72 manually define it. It also includes all the libpurple header files. |
| 77 |
|
| 78 Next, we include plugins.h which has all the plugin specific stuff that we |
|
| 79 need. For example: @c #PurplePlugin, @c #PurplePluginInfo, |
|
| 80 and @c PURPLE_PLUGIN_INIT(). |
|
| 81 |
73 |
| 82 @c plugin_query, @c plugin_load and @c plugin_unload must be implemented in |
74 @c plugin_query, @c plugin_load and @c plugin_unload must be implemented in |
| 83 every plugin. Each of these functions can return an error on failure by using |
75 every plugin. Each of these functions can return an error on failure by using |
| 84 @c g_set_error on the @c error argument. |
76 @c g_set_error on the @c error argument. |
| 85 |
77 |