1 #ifndef __MCABBER_MODULES_H__
2 #define __MCABBER_MODULES_H__ 1
3 
4 #include <glib.h>
5 #include <gmodule.h>
6 #include <mcabber/api.h> // MCABBER_BRANCH, MCABBER_API_VERSION
7 
8 // Module loading process looks like this:
9 //   check, if module is loaded
10 //   load module (+ run g_module_check_init)
11 //   check <modulename>_info variable
12 //   check version
13 //   load dependencies
14 //   run initialization callback
15 //   module loaded
16 //   ...
17 //   run uninitialization callback
18 //   unload module (+ run g_module_unload)
19 //   unload dependencies
20 //   module unloaded
21 
22 typedef void (*module_init_t)(void);
23 typedef void (*module_uninit_t)(void);
24 
25 // Structure, that module should provide
26 typedef struct module_info_struct module_info_t;
27 struct module_info_struct {
28   const gchar      *branch;           // Contains mcabber branch name, that this module is written to work with
29   guint             api;              // Mcabber branch api version, that module is supposed to work with
30   const gchar      *version;          // Module version string. Optional.
31   const gchar      *description;      // Module description. Can contain multiple lines.
32   const gchar     **requires;         // NULL-terminated list of module names, that must be loaded before this module
33   module_init_t     init;             // Initialization callback to be called after all dependencies will be loaded
34   module_uninit_t   uninit;           // Uninitialization callback to be called before module unloading
35   module_info_t    *next;             // If module supports multiple branches, it can provide several branch structs.
36 };
37 
38 const gchar *module_load(const gchar *name, gboolean manual, gboolean force);
39 const gchar *module_unload(const gchar *name, gboolean manual, gboolean force);
40 
41 // Grey zone (these symbols are semi-private and are exposed only for compatibility modules)
42 
43 // Information about loaded module
44 typedef struct {
45   guint          refcount;      // Reference count
46   gboolean       locked;        // If true, one of references is manual
47   gchar         *name;          // Module name
48   GModule       *module;        // Module object
49   module_info_t *info;          // Module information struct. May be NULL!
50 } loaded_module_t;
51 
52 // Registry of loaded modules
53 extern GSList *loaded_modules;
54 
55 // Should be considered mcabber private and not a part of api
56 
57 void module_list_print(void);
58 void module_info_print(const gchar *name);
59 
60 void modules_init(void);
61 void modules_deinit(void);
62 
63 #endif
64 
65 /* vim: set et cindent cinoptions=>2\:2(0 ts=2 sw=2:  For Vim users... */
66