comparison src/plugin.h @ 6822:7dba3e17cb21

[gaim-migrate @ 7366] Added plugin IPC. Its use is shown in plugins/ipc-test-server.c and plugins/ipc-test-client.c. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 13 Sep 2003 09:31:03 +0000
parents 41120df7ed94
children 6ed0a1c045b4
comparison
equal deleted inserted replaced
6821:636b5215552e 6822:7dba3e17cb21
22 */ 22 */
23 #ifndef _GAIM_PLUGIN_H_ 23 #ifndef _GAIM_PLUGIN_H_
24 #define _GAIM_PLUGIN_H_ 24 #define _GAIM_PLUGIN_H_
25 25
26 #include <gmodule.h> 26 #include <gmodule.h>
27 #include "signals.h"
28 #include "value.h"
27 29
28 typedef struct _GaimPlugin GaimPlugin; /**< GaimPlugin */ 30 typedef struct _GaimPlugin GaimPlugin; /**< GaimPlugin */
29 typedef struct _GaimPluginInfo GaimPluginInfo; /**< GaimPluginInfo */ 31 typedef struct _GaimPluginInfo GaimPluginInfo; /**< GaimPluginInfo */
30 typedef struct _GaimPluginLoaderInfo GaimPluginLoaderInfo; 32 typedef struct _GaimPluginLoaderInfo GaimPluginLoaderInfo;
31 33
86 88
87 gboolean (*probe)(GaimPlugin *plugin); 89 gboolean (*probe)(GaimPlugin *plugin);
88 gboolean (*load)(GaimPlugin *plugin); 90 gboolean (*load)(GaimPlugin *plugin);
89 gboolean (*unload)(GaimPlugin *plugin); 91 gboolean (*unload)(GaimPlugin *plugin);
90 void (*destroy)(GaimPlugin *plugin); 92 void (*destroy)(GaimPlugin *plugin);
91
92 /* XXX GaimSignalBroadcastFunc broadcast; */
93 }; 93 };
94 94
95 /** 95 /**
96 * A plugin handle. 96 * A plugin handle.
97 */ 97 */
101 gboolean loaded; /**< The loaded state. */ 101 gboolean loaded; /**< The loaded state. */
102 void *handle; /**< The module handle. */ 102 void *handle; /**< The module handle. */
103 char *path; /**< The path to the plugin. */ 103 char *path; /**< The path to the plugin. */
104 GaimPluginInfo *info; /**< The plugin information. */ 104 GaimPluginInfo *info; /**< The plugin information. */
105 char *error; 105 char *error;
106 void *ipc_data; /**< IPC data. */
106 void *extra; /**< Plugin-specific data. */ 107 void *extra; /**< Plugin-specific data. */
107 }; 108 };
108 109
109 #define GAIM_PLUGIN_LOADER_INFO(plugin) \ 110 #define GAIM_PLUGIN_LOADER_INFO(plugin) \
110 ((GaimPluginLoaderInfo *)(plugin)->info->extra_info) 111 ((GaimPluginLoaderInfo *)(plugin)->info->extra_info)
223 gboolean gaim_plugin_is_loaded(const GaimPlugin *plugin); 224 gboolean gaim_plugin_is_loaded(const GaimPlugin *plugin);
224 225
225 /*@}*/ 226 /*@}*/
226 227
227 /**************************************************************************/ 228 /**************************************************************************/
229 /** @name Plugin IPC API */
230 /**************************************************************************/
231 /*@{*/
232
233 /**
234 * Registers an IPC command in a plugin.
235 *
236 * @param plugin The plugin to register the command with.
237 * @param command The name of the command.
238 * @param func The function to execute.
239 * @param marshal The marshalling function.
240 * @param ret_value The return value type.
241 * @param num_values The number of parameters.
242 * @param ... The parameter types.
243 *
244 * @return TRUE if the function was registered successfully, or
245 * FALSE otherwise.
246 */
247 gboolean gaim_plugin_ipc_register(GaimPlugin *plugin, const char *command,
248 GaimCallback func,
249 GaimSignalMarshalFunc marshal,
250 GaimValue *ret_value, int num_params, ...);
251
252 /**
253 * Unregisters an IPC command in a plugin.
254 *
255 * @param plugin The plugin to unregister the command from.
256 * @param command The name of the command.
257 */
258 void gaim_plugin_ipc_unregister(GaimPlugin *plugin, const char *command);
259
260 /**
261 * Unregisters all IPC commands in a plugin.
262 *
263 * @param plugin The plugin to unregister the commands from.
264 */
265 void gaim_plugin_ipc_unregister_all(GaimPlugin *plugin);
266
267 /**
268 * Returns a list of value types used for an IPC command.
269 *
270 * @param plugin The plugin.
271 * @param command The name of the command.
272 * @param ret_value The returned return value.
273 * @param num_params The returned number of parameters.
274 * @param params The returned list of parameters.
275 *
276 * @return TRUE if the command was found, or FALSE otherwise.
277 */
278 gboolean gaim_plugin_ipc_get_params(GaimPlugin *plugin, const char *command,
279 GaimValue **ret_value, int *num_params,
280 GaimValue ***params);
281
282 /**
283 * Executes an IPC command.
284 *
285 * @param plugin The plugin to execute the command on.
286 * @param command The name of the command.
287 * @param ok TRUE if the call was successful, or FALSE otherwise.
288 * @param ... The parameters to pass.
289 *
290 * @return The return value, which will be NULL if the command doesn't
291 * return a value.
292 */
293 void *gaim_plugin_ipc_call(GaimPlugin *plugin, const char *command,
294 gboolean *ok, ...);
295
296 /*@}*/
297
298 /**************************************************************************/
228 /** @name Plugins API */ 299 /** @name Plugins API */
229 /**************************************************************************/ 300 /**************************************************************************/
230 /*@{*/ 301 /*@{*/
231 302
232 /** 303 /**