| 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 "plugin.h" |
|
| 30 #include "version.h" |
|
| 31 |
26 |
| 32 static gboolean |
27 static gboolean |
| 33 plugin_load(PurplePlugin *plugin) { |
28 plugin_load(PurplePlugin *plugin) { |
| 34 purple_notify_message(plugin, PURPLE_NOTIFY_MSG_INFO, "Hello World!", |
29 purple_notify_message(plugin, PURPLE_NOTIFY_MSG_INFO, "Hello World!", |
| 35 "This is the Hello World! plugin :)", |
30 "This is the Hello World! plugin :)", |
| 78 |
73 |
| 79 PURPLE_INIT_PLUGIN(hello_world, init_plugin, info); |
74 PURPLE_INIT_PLUGIN(hello_world, init_plugin, info); |
| 80 |
75 |
| 81 @endcode |
76 @endcode |
| 82 |
77 |
| 83 Okay, so what does all this mean? We start off by defining @c PURPLE_PLUGINS |
78 Okay, so what does all this mean? We start off by including purple.h. This |
| 84 like described before. Next we include glib.h, mainly for gboolean and the |
79 file defines @c PURPLE_PLUGINS as described before so that we don't have to |
| 85 glib wrappers of the standard C types. |
80 manually define it. It also includes all the libpurple header files. |
| 86 |
|
| 87 Next, we include plugin.h which has all the plugin specific stuff that we |
|
| 88 need. For example: @c PurplePlugin, @c PurplePluginInfo, |
|
| 89 @c PURPLE_PLUGIN_MAGIC, and @c PURPLE_INIT_PLUGIN(). |
|
| 90 |
|
| 91 Our last include is version.h which defines @c PURPLE_MAJOR_VERSION, and |
|
| 92 @c PURPLE_MINOR_VERSION. There is not much you need to know about these, |
|
| 93 except that they are required and will stop your plugin from crashing Pidgin |
|
| 94 when something has changed that your plugin does not know about yet. |
|
| 95 |
81 |
| 96 @c plugin_load is not required. It is called when the plugin is loaded so |
82 @c plugin_load is not required. It is called when the plugin is loaded so |
| 97 that you can initialize any variables and so on. In this plugin we'll just |
83 that you can initialize any variables and so on. In this plugin we'll just |
| 98 use it to display a message. |
84 use it to display a message. |
| 99 |
85 |