Mercurial > pidgin
annotate src/plugin.h @ 5944:158196b2db19
[gaim-migrate @ 6385]
Added #ifdef __cplusplus lines so that things will link right with C++.
Also added some doxygen comment blocks that didn't previously exist.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Mon, 23 Jun 2003 06:40:13 +0000 |
| parents | 8f5ccf9e590a |
| children | 90d0849abd3c |
| rev | line source |
|---|---|
| 5205 | 1 /** |
| 2 * @file plugin.h Plugin API | |
| 3 * @ingroup core | |
| 4 * | |
| 5 * gaim | |
| 6 * | |
| 7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
| 8 * | |
| 9 * This program is free software; you can redistribute it and/or modify | |
| 10 * it under the terms of the GNU General Public License as published by | |
| 11 * the Free Software Foundation; either version 2 of the License, or | |
| 12 * (at your option) any later version. | |
| 13 * | |
| 14 * This program is distributed in the hope that it will be useful, | |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 * GNU General Public License for more details. | |
| 18 * | |
| 19 * You should have received a copy of the GNU General Public License | |
| 20 * along with this program; if not, write to the Free Software | |
| 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 */ | |
| 23 #ifndef _GAIM_PLUGIN_H_ | |
| 24 #define _GAIM_PLUGIN_H_ | |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
25 |
|
5224
5160333a80df
[gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5205
diff
changeset
|
26 #include <gmodule.h> |
| 5205 | 27 |
| 28 typedef struct _GaimPlugin GaimPlugin; /**< GaimPlugin */ | |
| 29 typedef struct _GaimPluginInfo GaimPluginInfo; /**< GaimPluginInfo */ | |
| 30 typedef struct _GaimPluginLoaderInfo GaimPluginLoaderInfo; | |
| 31 | |
| 32 typedef int GaimPluginPriority; /**< Plugin priority. */ | |
| 33 | |
| 34 #include "event.h" | |
| 35 | |
| 36 /** | |
| 37 * Plugin types. | |
| 38 */ | |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
39 typedef enum |
| 5205 | 40 { |
| 41 GAIM_PLUGIN_UNKNOWN = -1, /**< Unknown type. */ | |
| 42 GAIM_PLUGIN_STANDARD = 0, /**< Standard plugin. */ | |
| 43 GAIM_PLUGIN_LOADER, /**< Loader plugin. */ | |
| 44 GAIM_PLUGIN_PROTOCOL /**< Protocol plugin. */ | |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
45 |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
46 } GaimPluginType; |
| 5205 | 47 |
| 48 #define GAIM_PRIORITY_DEFAULT 0 | |
| 49 #define GAIM_PRIORITY_HIGHEST 9999 | |
| 50 #define GAIM_PRIORITY_LOWEST -9999 | |
| 51 | |
| 52 #define GAIM_PLUGIN_ID_UNSET { 0, 0, 0, 0 } | |
| 53 | |
| 54 /** | |
| 55 * Detailed information about a plugin. | |
| 56 * | |
| 57 * This is used in the version 2.0 API and up. | |
| 58 */ | |
| 59 struct _GaimPluginInfo | |
| 60 { | |
| 61 unsigned int api_version; | |
| 62 GaimPluginType type; | |
| 63 char *ui_requirement; | |
| 64 unsigned long flags; | |
| 65 GList *dependencies; | |
| 66 GaimPluginPriority priority; | |
| 67 | |
| 68 char *id; | |
| 69 char *name; | |
| 70 char *version; | |
| 71 char *summary; | |
| 72 char *description; | |
| 73 char *author; | |
| 74 char *homepage; | |
| 75 | |
| 76 gboolean (*load)(GaimPlugin *plugin); | |
| 77 gboolean (*unload)(GaimPlugin *plugin); | |
| 78 void (*destroy)(GaimPlugin *plugin); | |
| 79 | |
| 80 void *ui_info; | |
| 81 void *extra_info; | |
| 82 }; | |
| 83 | |
| 84 /** | |
| 85 * Extra information for loader plugins. | |
| 86 */ | |
| 87 struct _GaimPluginLoaderInfo | |
| 88 { | |
| 89 GList *exts; | |
| 90 | |
| 91 gboolean (*probe)(GaimPlugin *plugin); | |
| 92 gboolean (*load)(GaimPlugin *plugin); | |
| 93 gboolean (*unload)(GaimPlugin *plugin); | |
| 94 void (*destroy)(GaimPlugin *plugin); | |
| 95 | |
| 96 GaimSignalBroadcastFunc broadcast; | |
| 97 }; | |
| 98 | |
| 99 /** | |
| 100 * A plugin handle. | |
| 101 */ | |
| 102 struct _GaimPlugin | |
| 103 { | |
| 104 gboolean native_plugin; /**< Native C plugin. */ | |
| 105 gboolean loaded; /**< The loaded state. */ | |
| 106 void *handle; /**< The module handle. */ | |
| 107 char *path; /**< The path to the plugin. */ | |
| 108 GaimPluginInfo *info; /**< The plugin information. */ | |
| 109 char *error; | |
| 110 void *extra; /**< Plugin-specific data. */ | |
| 111 }; | |
| 112 | |
| 113 #define GAIM_PLUGIN_LOADER_INFO(plugin) \ | |
| 114 ((GaimPluginLoaderInfo *)(plugin)->info->extra_info) | |
| 115 | |
| 116 /** | |
| 117 * Handles the initialization of modules. | |
| 118 */ | |
| 5449 | 119 #ifndef GAIM_PLUGINS |
| 5205 | 120 # define GAIM_INIT_PLUGIN(pluginname, initfunc, plugininfo) \ |
| 121 gboolean gaim_init_##pluginname##_plugin(void) { \ | |
| 122 GaimPlugin *plugin = gaim_plugin_new(TRUE, NULL); \ | |
| 123 plugin->info = &(plugininfo); \ | |
| 124 initfunc((plugin)); \ | |
| 125 return gaim_plugin_register(plugin); \ | |
| 126 } | |
| 5449 | 127 #else /* GAIM_PLUGINS */ |
| 5205 | 128 # define GAIM_INIT_PLUGIN(pluginname, initfunc, plugininfo) \ |
|
5224
5160333a80df
[gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5205
diff
changeset
|
129 G_MODULE_EXPORT gboolean gaim_init_plugin(GaimPlugin *plugin) { \ |
| 5205 | 130 plugin->info = &(plugininfo); \ |
| 131 initfunc((plugin)); \ | |
| 132 return gaim_plugin_register(plugin); \ | |
| 133 } | |
| 134 #endif | |
| 135 | |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
136 #ifdef __cplusplus |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
137 extern "C" { |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
138 #endif |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
139 |
| 5205 | 140 /**************************************************************************/ |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
141 /** @name Plugin API */ |
| 5205 | 142 /**************************************************************************/ |
| 143 /*@{*/ | |
| 144 | |
| 145 /** | |
| 146 * Creates a new plugin structure. | |
| 147 * | |
| 148 * @param native Whether or not the plugin is native. | |
| 149 * @param path The path to the plugin, or @c NULL if statically compiled. | |
| 150 * | |
| 151 * @return A new GaimPlugin structure. | |
| 152 */ | |
| 153 GaimPlugin *gaim_plugin_new(gboolean native, const char *path); | |
| 154 | |
| 155 /** | |
| 156 * Probes a plugin, retrieving the information on it and adding it to the | |
| 157 * list of available plugins. | |
| 158 * | |
| 159 * @param filename The plugin's filename. | |
| 160 * | |
| 161 * @return The plugin handle. | |
| 162 * | |
| 163 * @see gaim_plugin_load() | |
| 164 * @see gaim_plugin_destroy() | |
| 165 */ | |
| 166 GaimPlugin *gaim_plugin_probe(const char *filename); | |
| 167 | |
| 168 /** | |
| 169 * Registers a plugin and prepares it for loading. | |
| 170 * | |
| 171 * This shouldn't be called by anything but the internal module code. | |
| 172 * | |
| 173 * @param plugin The plugin to register. | |
| 174 */ | |
| 175 gboolean gaim_plugin_register(GaimPlugin *plugin); | |
| 176 | |
| 177 /** | |
| 178 * Attempts to load a previously probed plugin. | |
| 179 * | |
| 180 * @param filename The plugin's filename. | |
| 181 * | |
| 182 * @return @c TRUE if successful, or @c FALSE otherwise. | |
| 183 * | |
| 184 * @see gaim_plugin_reload() | |
| 185 * @see gaim_plugin_unload() | |
| 186 */ | |
| 187 gboolean gaim_plugin_load(GaimPlugin *plugin); | |
| 188 | |
| 189 /** | |
| 190 * Unloads the specified plugin. | |
| 191 * | |
| 192 * @param plugin The plugin handle. | |
| 193 * | |
| 194 * @return @c TRUE if successful, or @c FALSE otherwise. | |
| 195 * | |
| 196 * @see gaim_plugin_load() | |
| 197 * @see gaim_plugin_reload() | |
| 198 */ | |
| 199 gboolean gaim_plugin_unload(GaimPlugin *plugin); | |
| 200 | |
| 201 /** | |
| 202 * Reloads a plugin. | |
| 203 * | |
| 204 * @param plugin The old plugin handle. | |
| 205 * | |
| 206 * @return @c TRUE if successful, or @c FALSE otherwise. | |
| 207 * | |
| 208 * @see gaim_plugin_load() | |
| 209 * @see gaim_plugin_unload() | |
| 210 */ | |
| 211 gboolean gaim_plugin_reload(GaimPlugin *plugin); | |
| 212 | |
| 213 /** | |
| 214 * Unloads a plugin and destroys the structure from memory. | |
| 215 * | |
| 216 * @param plugin The plugin handle. | |
| 217 */ | |
| 218 void gaim_plugin_destroy(GaimPlugin *plugin); | |
| 219 | |
| 220 /** | |
| 221 * Returns whether or not a plugin is currently loaded. | |
| 222 * | |
| 223 * @param plugin The plugin. | |
| 224 * | |
| 225 * @return TRUE if loaded, or FALSE otherwise. | |
| 226 */ | |
| 227 gboolean gaim_plugin_is_loaded(const GaimPlugin *plugin); | |
| 228 | |
| 229 /*@}*/ | |
| 230 | |
| 231 /**************************************************************************/ | |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
232 /** @name Plugins API */ |
| 5205 | 233 /**************************************************************************/ |
| 234 /*@{*/ | |
| 235 | |
| 236 /** | |
| 237 * Sets the search paths for plugins. | |
| 238 * | |
| 239 * @param count The number of search paths. | |
| 240 * @param paths The search paths. | |
| 241 */ | |
| 242 void gaim_plugins_set_search_paths(size_t count, char **paths); | |
| 243 | |
| 244 /** | |
|
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5224
diff
changeset
|
245 * Unloads all loaded plugins. |
| 5205 | 246 */ |
| 247 void gaim_plugins_unload_all(void); | |
| 248 | |
|
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5224
diff
changeset
|
249 |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5224
diff
changeset
|
250 /** |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5224
diff
changeset
|
251 * Destroys all registered plugins. |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5224
diff
changeset
|
252 */ |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5224
diff
changeset
|
253 void gaim_plugins_destroy_all(void); |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5224
diff
changeset
|
254 |
| 5205 | 255 /** |
| 5838 | 256 * Attempts to load all the plugins that were loaded when gaim last quit |
| 257 */ | |
| 5840 | 258 void gaim_plugins_load_saved(void); |
| 5838 | 259 |
| 260 /** | |
| 5205 | 261 * Probes for plugins in the registered module paths. |
| 262 * | |
| 263 * @param ext The extension type to probe for, or @c NULL for all. | |
| 264 * | |
| 265 * @see gaim_plugin_set_probe_path() | |
| 266 */ | |
| 267 void gaim_plugins_probe(const char *ext); | |
| 268 | |
| 269 /** | |
| 270 * Returns whether or not plugin support is enabled. | |
| 271 * | |
| 272 * @return TRUE if plugin support is enabled, or FALSE otherwise. | |
| 273 */ | |
| 274 gboolean gaim_plugins_enabled(void); | |
| 275 | |
| 276 /** | |
| 277 * Registers a function that will be called when probing is finished. | |
| 278 * | |
| 279 * @param func The callback function. | |
| 280 * @param data Data to pass to the callback. | |
| 281 */ | |
| 282 void gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data); | |
| 283 | |
| 284 /** | |
| 285 * Unregisters a function that would be called when probing is finished. | |
| 286 * | |
| 287 * @param func The callback function. | |
| 288 */ | |
| 289 void gaim_plugins_unregister_probe_notify_cb(void (*func)(void *)); | |
| 290 | |
| 291 /** | |
| 292 * Registers a function that will be called when a plugin is loaded. | |
| 293 * | |
| 294 * @param func The callback functino. | |
| 295 * @param data Data to pass to the callback. | |
| 296 */ | |
| 297 void gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *), | |
| 298 void *data); | |
| 299 | |
| 300 /** | |
| 301 * Unregisters a function that would be called when a plugin is loaded. | |
| 302 * | |
| 303 * @param func The callback functino. | |
| 304 */ | |
| 305 void gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *)); | |
| 306 | |
| 307 /** | |
| 308 * Registers a function that will be called when a plugin is unloaded. | |
| 309 * | |
| 310 * @param func The callback functino. | |
| 311 * @param data Data to pass to the callback. | |
| 312 */ | |
| 313 void gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *), | |
| 314 void *data); | |
| 315 | |
| 316 /** | |
| 317 * Unregisters a function that would be called when a plugin is unloaded. | |
| 318 * | |
| 319 * @param func The callback functino. | |
| 320 */ | |
| 321 void gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *, | |
| 322 void *)); | |
| 323 | |
| 324 /** | |
| 325 * Finds a plugin with the specified name. | |
| 326 * | |
| 327 * @param name The plugin name. | |
| 328 * | |
| 329 * @return The plugin if found, or @c NULL if not found. | |
| 330 */ | |
| 331 GaimPlugin *gaim_plugins_find_with_name(const char *name); | |
| 332 | |
| 333 /** | |
| 334 * Finds a plugin with the specified filename. | |
| 335 * | |
| 336 * @param filename The plugin filename. | |
| 337 * | |
| 338 * @return The plugin if found, or @c NULL if not found. | |
| 339 */ | |
| 340 GaimPlugin *gaim_plugins_find_with_filename(const char *filename); | |
| 341 | |
| 342 /** | |
| 343 * Finds a plugin with the specified plugin ID. | |
| 344 * | |
| 345 * @param id The plugin ID. | |
| 346 * | |
| 347 * @return The plugin if found, or @c NULL if not found. | |
| 348 */ | |
| 349 GaimPlugin *gaim_plugins_find_with_id(const char *id); | |
| 350 | |
| 351 /** | |
| 352 * Returns a list of all loaded plugins. | |
| 353 * | |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5449
diff
changeset
|
354 * @return A list of all loaded plugins. |
| 5205 | 355 */ |
| 356 GList *gaim_plugins_get_loaded(void); | |
| 357 | |
| 358 /** | |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5449
diff
changeset
|
359 * Returns a list of all protocol plugins. |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5449
diff
changeset
|
360 * |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5449
diff
changeset
|
361 * @return A list of all protocol plugins. |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5449
diff
changeset
|
362 */ |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5449
diff
changeset
|
363 GList *gaim_plugins_get_protocols(void); |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5449
diff
changeset
|
364 |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5449
diff
changeset
|
365 /** |
| 5205 | 366 * Returns a list of all plugins, whether loaded or not. |
| 367 * | |
| 368 * @return A list of all plugins. | |
| 369 */ | |
| 370 GList *gaim_plugins_get_all(void); | |
| 371 | |
| 372 /*@}*/ | |
| 373 | |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
374 #ifdef __cplusplus |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
375 } |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
376 #endif |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
377 |
| 5205 | 378 #endif /* _GAIM_PLUGIN_H_ */ |
