## e-data-server-module

e-data-server-module — Backend module loader

## Synopsis

    gboolean            e_data_server_module_init           (const gchar *module_path,
                                                             GError **error);
    GList *             e_data_server_get_extensions_for_type
                                                            (GType type);
    void                e_data_server_extension_list_free   (GList *extensions);
    void                e_data_server_module_remove_unused  (void);
    void                e_data_server_module_add_type       (GType type);
    void                eds_module_initialize               (GTypeModule *module);
    void                eds_module_shutdown                 (void);
    void                eds_module_list_types               (const GType **types,
                                                             gint *num_types);

## Description

An EDataServerModule loads backend modules from the directory given in `e_data_server_module_init()`. Each backend module must export three functions. The first two -- `eds_module_initialize()` and `eds_module_list_types()` -- are called immediately after the backend module is loaded. The last one -- `eds_module_shutdown()` -- is called when the backend module is unloaded.

## Details

### e_data_server_module_init ()

    gboolean            e_data_server_module_init           (const gchar *module_path,
                                                             GError **error);

Loads all backend modules in `module_path`. If an error occurs, the function sets `error` and returns `FALSE`.

`module_path` : | directory of backend modules
`error` : | return location for a GError, or `NULL`
Returns : | `TRUE` on success, `FALSE` on failure

### e_data_server_get_extensions_for_type ()

    GList *             e_data_server_get_extensions_for_type
                                                            (GType type);

Returns a list of objects derived from `type` which have been registered through `eds_module_list_types()` or `e_data_server_module_add_type()`.

Free the returned list using `e_data_server_extension_list_free()`.

`type` : | a GType
Returns : | a list of extension objects

### e_data_server_extension_list_free ()

    void                e_data_server_extension_list_free   (GList *extensions);

Frees a list of objects returned by `e_data_server_get_extensions_for_type()`.

`extensions` : | a list of extension objects

### e_data_server_module_remove_unused ()

    void                e_data_server_module_remove_unused  (void);

Unrefs all loaded modules, so that unused modules are unloaded from the system.

### e_data_server_module_add_type ()

    void                e_data_server_module_add_type       (GType type);

Creates an instance of `type` and adds the instance to an internal list which can be queried using `e_data_server_get_extensions_for_type()`.

`type` : | a GType

### eds_module_initialize ()

    void                eds_module_initialize               (GTypeModule *module);

Each backend module must define this function. The module should call `g_type_module_register_type()` to register all dynamically-loaded types.

`module` : | a GTypeModule

### eds_module_shutdown ()

    void                eds_module_shutdown                 (void);

Each backend module must define this function. The module should release resources and perform any necessary cleanup actions prior to the service being shut down.

### eds_module_list_types ()

    void                eds_module_list_types               (const GType **types,
                                                             gint *num_types);

Each backend module must define this function. The module should point `types` to a list of types registered in `eds_module_initialize()` and also set `num_types` to the length of that list.

`types` : | return location for a GType list
`num_types` : | the length of the GType list