plugin.h

Go to the documentation of this file.
00001 
00025 #ifndef _GAIM_PLUGIN_H_
00026 #define _GAIM_PLUGIN_H_
00027 
00028 #include <glib/glist.h>
00029 #include <gmodule.h>
00030 #include "signals.h"
00031 #include "value.h"
00032 
00033 typedef struct _GaimPlugin           GaimPlugin;
00034 typedef struct _GaimPluginInfo       GaimPluginInfo;
00035 typedef struct _GaimPluginUiInfo     GaimPluginUiInfo;
00036 typedef struct _GaimPluginLoaderInfo GaimPluginLoaderInfo;
00037 
00038 typedef struct _GaimPluginAction     GaimPluginAction;
00039 
00040 typedef int GaimPluginPriority; 
00042 #include "pluginpref.h"
00043 
00047 typedef enum
00048 {
00049     GAIM_PLUGIN_UNKNOWN  = -1,  
00050     GAIM_PLUGIN_STANDARD = 0,   
00051     GAIM_PLUGIN_LOADER,         
00052     GAIM_PLUGIN_PROTOCOL        
00054 } GaimPluginType;
00055 
00056 #define GAIM_PRIORITY_DEFAULT     0
00057 #define GAIM_PRIORITY_HIGHEST  9999
00058 #define GAIM_PRIORITY_LOWEST  -9999
00059 
00060 #define GAIM_PLUGIN_FLAG_INVISIBLE 0x01
00061 
00062 #define GAIM_PLUGIN_MAGIC 5 /* once we hit 6.0.0, I think we can remove this */
00063 
00069 struct _GaimPluginInfo
00070 {
00071     unsigned int magic;
00072     unsigned int major_version;
00073     unsigned int minor_version;
00074     GaimPluginType type;
00075     char *ui_requirement;
00076     unsigned long flags;
00077     GList *dependencies;
00078     GaimPluginPriority priority;
00079 
00080     char *id;
00081     char *name;
00082     char *version;
00083     char *summary;
00084     char *description;
00085     char *author;
00086     char *homepage;
00087 
00088     gboolean (*load)(GaimPlugin *plugin);
00089     gboolean (*unload)(GaimPlugin *plugin);
00090     void (*destroy)(GaimPlugin *plugin);
00091 
00092     void *ui_info;
00093     void *extra_info;
00094     GaimPluginUiInfo *prefs_info;
00095     GList *(*actions)(GaimPlugin *plugin, gpointer context);
00096 };
00097 
00101 struct _GaimPluginLoaderInfo
00102 {
00103     GList *exts;
00104 
00105     gboolean (*probe)(GaimPlugin *plugin);
00106     gboolean (*load)(GaimPlugin *plugin);
00107     gboolean (*unload)(GaimPlugin *plugin);
00108     void     (*destroy)(GaimPlugin *plugin);
00109 };
00110 
00114 struct _GaimPlugin
00115 {
00116     gboolean native_plugin;                
00117     gboolean loaded;                       
00118     void *handle;                          
00119     char *path;                            
00120     GaimPluginInfo *info;                  
00121     char *error;
00122     void *ipc_data;                        
00123     void *extra;                           
00124 };
00125 
00126 #define GAIM_PLUGIN_LOADER_INFO(plugin) \
00127     ((GaimPluginLoaderInfo *)(plugin)->info->extra_info)
00128 
00129 struct _GaimPluginUiInfo {
00130     GaimPluginPrefFrame *(*get_plugin_pref_frame)(GaimPlugin *plugin);
00131 
00132     void *iter;                                           
00133     GaimPluginPrefFrame *frame;                           
00134 };
00135 
00136 #define GAIM_PLUGIN_HAS_PREF_FRAME(plugin) \
00137     ((plugin)->info != NULL && (plugin)->info->prefs_info != NULL)
00138 
00139 #define GAIM_PLUGIN_UI_INFO(plugin) \
00140     ((GaimPluginUiInfo*)(plugin)->info->prefs_info)
00141 
00142 
00146 struct _GaimPluginAction {
00147     char *label;
00148     void (*callback)(GaimPluginAction *);
00149 
00151     GaimPlugin *plugin;
00152 
00155     gpointer context;
00156 };
00157 
00158 #define GAIM_PLUGIN_HAS_ACTIONS(plugin) \
00159     ((plugin)->info != NULL && (plugin)->info->actions != NULL)
00160 
00161 #define GAIM_PLUGIN_ACTIONS(plugin, context) \
00162     (GAIM_PLUGIN_HAS_ACTIONS(plugin)? \
00163     (plugin)->info->actions(plugin, context): NULL)
00164 
00165 
00169 #if !defined(GAIM_PLUGINS) || defined(GAIM_STATIC_PRPL)
00170 # define GAIM_INIT_PLUGIN(pluginname, initfunc, plugininfo) \
00171     gboolean gaim_init_##pluginname##_plugin(void) { \
00172         GaimPlugin *plugin = gaim_plugin_new(TRUE, NULL); \
00173         plugin->info = &(plugininfo); \
00174         initfunc((plugin)); \
00175         return gaim_plugin_register(plugin); \
00176     }
00177 #else /* GAIM_PLUGINS  && !GAIM_STATIC_PRPL */
00178 # define GAIM_INIT_PLUGIN(pluginname, initfunc, plugininfo) \
00179     G_MODULE_EXPORT gboolean gaim_init_plugin(GaimPlugin *plugin) { \
00180         plugin->info = &(plugininfo); \
00181         initfunc((plugin)); \
00182         return gaim_plugin_register(plugin); \
00183     }
00184 #endif
00185 
00186 
00187 #ifdef __cplusplus
00188 extern "C" {
00189 #endif
00190 
00191 
00192 void *gaim_plugins_get_handle(void);
00193 
00194 
00195 /**************************************************************************/
00197 /**************************************************************************/
00208 GaimPlugin *gaim_plugin_new(gboolean native, const char *path);
00209 
00221 GaimPlugin *gaim_plugin_probe(const char *filename);
00222 
00230 gboolean gaim_plugin_register(GaimPlugin *plugin);
00231 
00242 gboolean gaim_plugin_load(GaimPlugin *plugin);
00243 
00254 gboolean gaim_plugin_unload(GaimPlugin *plugin);
00255 
00266 gboolean gaim_plugin_reload(GaimPlugin *plugin);
00267 
00273 void gaim_plugin_destroy(GaimPlugin *plugin);
00274 
00282 gboolean gaim_plugin_is_loaded(const GaimPlugin *plugin);
00283 
00286 /**************************************************************************/
00288 /**************************************************************************/
00305 gboolean gaim_plugin_ipc_register(GaimPlugin *plugin, const char *command,
00306                                   GaimCallback func,
00307                                   GaimSignalMarshalFunc marshal,
00308                                   GaimValue *ret_value, int num_params, ...);
00309 
00316 void gaim_plugin_ipc_unregister(GaimPlugin *plugin, const char *command);
00317 
00323 void gaim_plugin_ipc_unregister_all(GaimPlugin *plugin);
00324 
00336 gboolean gaim_plugin_ipc_get_params(GaimPlugin *plugin, const char *command,
00337                                     GaimValue **ret_value, int *num_params,
00338                                     GaimValue ***params);
00339 
00351 void *gaim_plugin_ipc_call(GaimPlugin *plugin, const char *command,
00352                            gboolean *ok, ...);
00353 
00356 /**************************************************************************/
00358 /**************************************************************************/
00367 void gaim_plugins_set_search_paths(size_t count, char **paths);
00368 
00372 void gaim_plugins_unload_all(void);
00373 
00377 void gaim_plugins_destroy_all(void);
00378 
00385 void gaim_plugins_load_saved(const char *key);
00386 
00394 void gaim_plugins_probe(const char *ext);
00395 
00401 gboolean gaim_plugins_enabled(void);
00402 
00409 void gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data);
00410 
00416 void gaim_plugins_unregister_probe_notify_cb(void (*func)(void *));
00417 
00424 void gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *),
00425                                           void *data);
00426 
00432 void gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *));
00433 
00440 void gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *),
00441                                             void *data);
00442 
00448 void gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *,
00449                                                            void *));
00450 
00458 GaimPlugin *gaim_plugins_find_with_name(const char *name);
00459 
00467 GaimPlugin *gaim_plugins_find_with_filename(const char *filename);
00468 
00476 GaimPlugin *gaim_plugins_find_with_basename(const char *basename);
00477 
00485 GaimPlugin *gaim_plugins_find_with_id(const char *id);
00486 
00492 GList *gaim_plugins_get_loaded(void);
00493 
00499 GList *gaim_plugins_get_protocols(void);
00500 
00506 GList *gaim_plugins_get_all(void);
00507 
00514 GaimPluginAction *gaim_plugin_action_new(char* label, void (*callback)(GaimPluginAction *));
00515 
00516 #ifdef __cplusplus
00517 }
00518 #endif
00519 
00520 #endif /* _GAIM_PLUGIN_H_ */

Generated on Wed Aug 9 23:40:23 2006 for gaim by  doxygen 1.4.7