| 4 C plugins are native plugins. They have complete access to all of the api, |
4 C plugins are native plugins. They have complete access to all of the api, |
| 5 and can do basically whatever they want. All of the protocol plugins, as |
5 and can do basically whatever they want. All of the protocol plugins, as |
| 6 well as the perl and tcl loader plugins are written in C. |
6 well as the perl and tcl loader plugins are written in C. |
| 7 |
7 |
| 8 @section getting_started Getting Started |
8 @section getting_started Getting Started |
| 9 To develop a plugin you need to have the gaim source code. It is generally a |
9 To develop a plugin you need to have the Gaim source code. It is generally a |
| 10 good idea to compile against the same version of gaim that you are running. |
10 good idea to compile against the same version of Gaim that you are running. |
| 11 You may also want to develop against CVS. While we do NOT recomend this for |
11 You may also want to develop against CVS. While we do NOT recomend this for |
| 12 normal users, but there is an exception for developers. A lot tends to |
12 normal users, it makes sense for plugin developers to use CVS to ensure their |
| |
13 plugins works with the most recent changes in Gaim. A lot tends to |
| 13 change between versions and it's much easier to fix your plugin as things |
14 change between versions and it's much easier to fix your plugin as things |
| 14 change rather than waiting until the release. But please do not abuse CVS. |
15 change rather than waiting until the release. But please do not abuse CVS. |
| 15 Gaim puts a lot of strain on Source Forge's servers, and we do not need to |
16 Gaim puts a lot of strain on Source Forge's servers, and we do not need to |
| 16 add anymore to it. |
17 add anymore to it. |
| 17 |
18 |
| 18 If you choose not to head my warnings and develop against a version of gaim |
19 If you choose not to head my warnings and develop against a version of Gaim |
| 19 that is different from what you're running, then you're gaim source must at |
20 that is different from what you're running, then your Gaim source must at |
| 20 the very least be configured. Note that just running configure will |
21 the very least be configured. Note that just running configure will |
| 21 generally set the prefix to /usr/local. This shouldn't be a problem, except |
22 generally set the prefix to /usr/local. This shouldn't be a problem, except |
| 22 that most packages compile and install gaim with /usr as the prefix. |
23 that most packages compile and install Gaim with /usr as the prefix. |
| 23 |
24 |
| 24 All plugins must have @c GAIM_PLUGINS defined. You can choose to include |
25 All plugins must have @c GAIM_PLUGINS defined. You can choose to include |
| 25 @c internal.h to do this, but if you choose to do it this way it must be |
26 @c internal.h to do this, but if you choose to do it this way it must be |
| 26 included before any other gaim files. Likewise, if you choose to manually |
27 included before any other Gaim files. Likewise, if you choose to manually |
| 27 define @c GAIM_PLUGINS, the definition must be before including any gaim |
28 define @c GAIM_PLUGINS, the definition must be before including any Gaim |
| 28 files. Failure to do so will produce the 'plugin foo could not be loaded for |
29 files. Failure to do so will produce the 'plugin foo could not be loaded for |
| 29 an unknown reason'. This is one of the hardest unknown reasons to track |
30 an unknown reason'. This is one of the hardest unknown reasons to track |
| 30 down, so let's try to avoid it at all costs ;) |
31 down, so let's try to avoid it at all costs ;) |
| 31 |
32 |
| 32 @section hello_world Hello World! |
33 @section hello_world Hello World! |
| 33 I know every tutorial has a hello world, so why should gaim be any different? |
34 I know every tutorial has a hello world, so why should Gaim be any different? |
| 34 |
35 |
| 35 @code |
36 @code |
| 36 #define GAIM_PLUGINS |
37 #define GAIM_PLUGINS |
| 37 |
38 |
| 38 #include <glib.h> |
39 #include <glib.h> |
| 87 @endcode |
88 @endcode |
| 88 |
89 |
| 89 Okay, so what does all this mean? We start off by defining @c GAIM_PLUGINS |
90 Okay, so what does all this mean? We start off by defining @c GAIM_PLUGINS |
| 90 like described before. Next we include glib.h, mainly for gboolean and the |
91 like described before. Next we include glib.h, mainly for gboolean and the |
| 91 glib wrappers of the standard c types. We could just use stdio and use |
92 glib wrappers of the standard c types. We could just use stdio and use |
| 92 an int for the gboolean but since gaim uses glib internally, we might as |
93 an int for the gboolean but since Gaim uses glib internally, we might as |
| 93 well do the same. |
94 well do the same. |
| 94 |
95 |
| 95 Next, we include plugin.h which has all the plugin specific stuff that we |
96 Next, we include plugin.h which has all the plugin specific stuff that we |
| 96 need. For example @c GaimPlugin, @c GaimPluginInfo, @c GAIM_PLUGIN_MAGIC, |
97 need. For example @c GaimPlugin, @c GaimPluginInfo, @c GAIM_PLUGIN_MAGIC, |
| 97 and @c GAIM_INIT_PLUGIN(). |
98 and @c GAIM_INIT_PLUGIN(). |
| 98 |
99 |
| 99 Our last include is version.h which defines @c GAIM_MAJOR_VERSION, and |
100 Our last include is version.h which defines @c GAIM_MAJOR_VERSION, and |
| 100 @c GAIM_MINOR_VERSION. Theres not much you need to know about these, except |
101 @c GAIM_MINOR_VERSION. There is not much you need to know about these, |
| 101 that they are required and will stop your plugin from crashing Gaim when |
102 except that they are required and will stop your plugin from crashing Gaim |
| 102 something has changed that you plugin does not know about yet. |
103 when something has changed that you plugin does not know about yet. |
| 103 |
104 |
| 104 plugin_load is not required. It is called when the plugin is loaded, so you |
105 plugin_load is not required. It is called when the plugin is loaded so that |
| 105 can initialize any variables and so on. But in this plugin we'll just use it |
106 you can initialize any variables and so on. But in this plugin we'll just |
| 106 to display a message. |
107 use it to display a message. |
| 107 |
108 |
| 108 Next we have the @c GaimPluginInfo structure. Every plugin MUST have one of |
109 Next we have the @c GaimPluginInfo structure. Every plugin MUST have one of |
| 109 these. Below is a code snipet of the same struct used in @c hello_world with |
110 these. Below is a code snipet of the same struct used in @c hello_world with |
| 110 comments describing what each is. |
111 comments describing what each is. |
| 111 |
112 |
| 112 @code |
113 @code |
| 113 static GaimPluginInfo info = { |
114 static GaimPluginInfo info = { |
| 114 GAIM_PLUGIN_MAGIC, /* Plugin magic, this should always be |
115 GAIM_PLUGIN_MAGIC, /* Plugin magic, this should always be |
| 115 GAIM_PLUGIN_MAGIC. This value gets |
116 GAIM_PLUGIN_MAGIC. This value gets |
| 116 incremented inside of gaim so that plugins |
117 incremented inside of Gaim so that plugins |
| 117 that haven't been updated yet, will fail to |
118 that haven't been updated yet will fail to |
| 118 load and avoid potential crashes while |
119 load and avoid potential crashes while |
| 119 loading old plugins. |
120 loading old plugins. |
| 120 */ |
121 */ |
| 121 GAIM_MAJOR_VERSION, /* This is also define in gaim. It helps |
122 GAIM_MAJOR_VERSION, /* This is also defined in Gaim. It helps |
| 122 Gaim's plugin system tell what version of |
123 Gaim's plugin system determine what version |
| 123 this plugin was compiled for, and whether |
124 of Gaim this plugin was compiled for, and |
| 124 or not loading it will cause problems |
125 whether loading it will cause problems. |
| 125 */ |
126 */ |
| 126 GAIM_MINOR_VERSION, /* See previous */ |
127 GAIM_MINOR_VERSION, /* See previous */ |
| 127 GAIM_PLUGIN_STANDARD, /* GaimPluginType, there are 4 different values |
128 GAIM_PLUGIN_STANDARD, /* GaimPluginType, there are 4 different values |
| 128 for this field. The first is |
129 for this field. The first is |
| 129 GAIM_PLUGIN_UNKNOWN, which should not be |
130 GAIM_PLUGIN_UNKNOWN, which should not be |
| 130 used. The second is GAIM_PLUGIN_STANDARD, |
131 used. The second is GAIM_PLUGIN_STANDARD, |
| 131 this is the value most plugins will use. |
132 this is the value most plugins will use. |
| 132 Next we have GAIM_PLUGIN_LOADER, this is |
133 Next we have GAIM_PLUGIN_LOADER, this is |
| 133 the type you want to load if you're plugin |
134 the type you want to load if your plugin |
| 134 is going to make it possible to load non |
135 is going to make it possible to load non- |
| 135 native plugins. For example, perl and tcl. |
136 native plugins. For example, perl and tcl. |
| 136 Last, we have GAIM_PLUGIN_PROTOCOL. If |
137 Last, we have GAIM_PLUGIN_PROTOCOL. If |
| 137 your plugin is going to allow the user to |
138 your plugin is going to allow the user to |
| 138 connect to another network, this is the |
139 connect to another network, this is the |
| 139 type you'd want to use. |
140 type you'd want to use. |
| 150 this howto. |
151 this howto. |
| 151 */ |
152 */ |
| 152 0, /* This field is for plugin flags. Currently, |
153 0, /* This field is for plugin flags. Currently, |
| 153 the only flag available to plugins is |
154 the only flag available to plugins is |
| 154 invisible (GAIM_PLUGIN_FLAG_INVISIBLE). |
155 invisible (GAIM_PLUGIN_FLAG_INVISIBLE). |
| 155 The only plugins that current use this flag, |
156 This plugin is currently used by the ssl |
| 156 is the ssl plugin. |
157 plugin, the tcl loader, and the perl |
| 157 */ |
158 loaded. It causes the plugin to NOT |
| 158 NULL, /* This is a glist of plugin dependencies. In |
159 appear in the list of plugins in Gaim's |
| 159 other words, a glist of plugin id's that |
160 preferences window. |
| |
161 */ |
| |
162 NULL, /* This is a GList of plugin dependencies. In |
| |
163 other words, a GList of plugin id's that |
| 160 your plugin depends on. If your plugin |
164 your plugin depends on. If your plugin |
| 161 does not have any dependencies, set this |
165 does not have any dependencies, set this |
| 162 value to NULL |
166 value to NULL. |
| 163 */ |
167 */ |
| 164 GAIM_PRIORITY_DEFAULT, /* This is the priority gaim with give your |
168 GAIM_PRIORITY_DEFAULT, /* This is the priority Gaim with give your |
| 165 plugin. There are three possible values |
169 plugin. There are three possible values |
| 166 for this field, GAIM_PRIORITY_DEFAULT, |
170 for this field, GAIM_PRIORITY_DEFAULT, |
| 167 GAIM_PRIORITY_HIGHEST, and |
171 GAIM_PRIORITY_HIGHEST, and |
| 168 GAIM_PRIORITY_LOWEST |
172 GAIM_PRIORITY_LOWEST |
| 169 */ |
173 */ |
| 170 |
174 |
| 171 "core-hello_world", /* This is your plugin's id. There is a whole |
175 "core-hello_world", /* This is your plugin's id. There is a whole |
| 172 page dedicated to this in the |
176 page dedicated to this in the |
| 173 'related-pages' section of the doxygen api. |
177 'related-pages' section of Gaim's API docs. |
| 174 */ |
178 */ |
| 175 "Hello World!", /* This is your plugin name. This is what |
179 "Hello World!", /* This is your plugin name. This is what |
| 176 will be displayed for your plugin in the ui. |
180 will be displayed for your plugin in the ui. |
| 177 */ |
181 */ |
| 178 VERSION, /* This is the version of your plugin. For |
182 1.1, /* This is the version of your plugin. For |
| 179 the sake of simplicity, I'm using the gaim |
183 the sake of simplicity, I'm using the Gaim |
| 180 version. |
184 version. |
| 181 */ |
185 */ |
| 182 |
186 |
| 183 "Hello World Plugin", /* This is the summary of your plugin. It |
187 "Hello World Plugin", /* This is the summary of your plugin. It |
| 184 should be a short little blurb. The ui |
188 should be a short little blurb. The ui |
| 194 email address. (You are the author right?) |
198 email address. (You are the author right?) |
| 195 */ |
199 */ |
| 196 GAIM_WEBSITE, /* This is the website for the plugin. This |
200 GAIM_WEBSITE, /* This is the website for the plugin. This |
| 197 is helpful if users find bugs in your |
201 is helpful if users find bugs in your |
| 198 plugin so they can help to bring them to |
202 plugin so they can help to bring them to |
| 199 your attention |
203 your attention. |
| 200 */ |
204 */ |
| 201 |
205 |
| 202 plugin_load, /* This is a pointer to a function for gaim to |
206 plugin_load, /* This is a pointer to a function for Gaim to |
| 203 call when it is loading your plugin. It |
207 call when it is loading your plugin. It |
| 204 should be in the form of: |
208 should be in the form of: |
| 205 |
209 |
| 206 gboolean function_name(GaimPlugin *plugin) |
210 gboolean function_name(GaimPlugin *plugin) |
| 207 |
211 |
| 208 Returning TRUE will tell gaim to continue |
212 Returning TRUE will tell Gaim to continue |
| 209 loading your plugin, while FALSE will tell |
213 loading your plugin, while FALSE will tell |
| 210 gaim to stop trying to load it. |
214 Gaim to stop trying to load it. |
| 211 */ |
215 */ |
| 212 NULL, /* Same as above except it is called when |
216 NULL, /* Same as above except it is called when |
| 213 gaim tries to unload your plugin. It |
217 Gaim tries to unload your plugin. It |
| 214 should be in the form of: |
218 should be in the form of: |
| 215 |
219 |
| 216 gboolean function_name(GaimPlugin *plugin) |
220 gboolean function_name(GaimPlugin *plugin) |
| 217 |
221 |
| 218 Where returning TRUE will tell gaim to |
222 Where returning TRUE will tell Gaim to |
| 219 continue unloading and false to not continue |
223 continue unloading and false to not continue |
| 220 unloading your plugin. |
224 unloading your plugin. |
| 221 */ |
225 */ |
| 222 NULL, /* Similar to the two above members, except |
226 NULL, /* Similar to the two above members, except |
| 223 this is called when gaim tries to destory |
227 this is called when Gaim tries to destory |
| 224 the plugin. This is generally only called |
228 the plugin. This is generally only called |
| 225 when for some reason or another the plugin |
229 when for some reason or another the plugin |
| 226 fails to probe correctly. It should be in |
230 fails to probe correctly. It should be in |
| 227 the form of: |
231 the form of: |
| 228 |
232 |
| 259 @endcode |
263 @endcode |
| 260 |
264 |
| 261 Finally we have @c init_plugin and @c GAIM_INIT_PLUGIN. @c init_plugin is a |
265 Finally we have @c init_plugin and @c GAIM_INIT_PLUGIN. @c init_plugin is a |
| 262 function that gets called when Gaim probes the plugin. Most plugins will |
266 function that gets called when Gaim probes the plugin. Most plugins will |
| 263 add their preferences to the pref tree here, more about that later. |
267 add their preferences to the pref tree here, more about that later. |
| 264 @GAIM_INIT_PLUGIN is a macro that EVERY plugin MUST have. @GAIM_INIT_PLUGIN |
268 @c GAIM_INIT_PLUGIN is a macro that EVERY plugin MUST have. @c GAIM_INIT_PLUGIN |
| 265 tells gaim some very basic things about your plugin, like what name to use |
269 tells Gaim some very basic things about your plugin, like what name to use |
| 266 if the plugin is compiled staticly, the @c init_plugin function, and |
270 if the plugin is compiled staticly, the @c init_plugin function, and |
| 267 the name of the @c GaimPluginInfo structure. As you may have guess this |
271 the name of the @c GaimPluginInfo structure. As you may have guess this |
| 268 also gets read when Gaim is probing your plugin. If this is missing you |
272 also gets read when Gaim is probing your plugin. If this is missing you |
| 269 will get the infamous "plugin unloadable for unknown reasons", so do not |
273 will get the infamous "plugin unloadable for unknown reasons", so do not |
| 270 forget it. |
274 forget it. |