giomodule.h 7.88 KB
Newer Older
1
/* GIO - GLib Input, Output and Streaming Library
2
 *
3 4 5 6 7
 * Copyright (C) 2006-2007 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9 10 11 12 13 14 15
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General
16
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 18 19 20
 *
 * Author: Alexander Larsson <alexl@redhat.com>
 */

21 22 23
#ifndef __G_IO_MODULE_H__
#define __G_IO_MODULE_H__

24 25 26 27
#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
#error "Only <gio/gio.h> can be included directly."
#endif

28
#include <gio/giotypes.h>
29 30 31 32
#include <gmodule.h>

G_BEGIN_DECLS

33 34
typedef struct _GIOModuleScope GIOModuleScope;

35
GLIB_AVAILABLE_IN_2_30
36
GIOModuleScope *   g_io_module_scope_new     (GIOModuleScopeFlags  flags);
37
GLIB_AVAILABLE_IN_2_30
38
void               g_io_module_scope_free    (GIOModuleScope      *scope);
39
GLIB_AVAILABLE_IN_2_30
40 41 42
void               g_io_module_scope_block   (GIOModuleScope      *scope,
                                              const gchar         *basename);

43 44 45 46 47 48 49
#define G_IO_TYPE_MODULE         (g_io_module_get_type ())
#define G_IO_MODULE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_IO_TYPE_MODULE, GIOModule))
#define G_IO_MODULE_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), G_IO_TYPE_MODULE, GIOModuleClass))
#define G_IO_IS_MODULE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_IO_TYPE_MODULE))
#define G_IO_IS_MODULE_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), G_IO_TYPE_MODULE))
#define G_IO_MODULE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_IO_TYPE_MODULE, GIOModuleClass))

50 51
/**
 * GIOModule:
52
 *
53 54
 * Opaque module base class for extending GIO.
 **/
55 56
typedef struct _GIOModuleClass GIOModuleClass;

57
GLIB_AVAILABLE_IN_ALL
58
GType              g_io_module_get_type                       (void) G_GNUC_CONST;
59
GLIB_AVAILABLE_IN_ALL
60
GIOModule         *g_io_module_new                            (const gchar       *filename);
61

62
GLIB_AVAILABLE_IN_ALL
63
void               g_io_modules_scan_all_in_directory         (const char        *dirname);
64
GLIB_AVAILABLE_IN_ALL
65
GList             *g_io_modules_load_all_in_directory         (const gchar       *dirname);
66

67
GLIB_AVAILABLE_IN_2_30
68 69
void               g_io_modules_scan_all_in_directory_with_scope   (const gchar       *dirname,
                                                                    GIOModuleScope    *scope);
70
GLIB_AVAILABLE_IN_2_30
71 72 73
GList             *g_io_modules_load_all_in_directory_with_scope   (const gchar       *dirname,
                                                                    GIOModuleScope    *scope);

74
GLIB_AVAILABLE_IN_ALL
75
GIOExtensionPoint *g_io_extension_point_register              (const char        *name);
76
GLIB_AVAILABLE_IN_ALL
77
GIOExtensionPoint *g_io_extension_point_lookup                (const char        *name);
78
GLIB_AVAILABLE_IN_ALL
79 80
void               g_io_extension_point_set_required_type     (GIOExtensionPoint *extension_point,
							       GType              type);
81
GLIB_AVAILABLE_IN_ALL
82
GType              g_io_extension_point_get_required_type     (GIOExtensionPoint *extension_point);
83
GLIB_AVAILABLE_IN_ALL
84
GList             *g_io_extension_point_get_extensions        (GIOExtensionPoint *extension_point);
85
GLIB_AVAILABLE_IN_ALL
86 87
GIOExtension *     g_io_extension_point_get_extension_by_name (GIOExtensionPoint *extension_point,
							       const char        *name);
88
GLIB_AVAILABLE_IN_ALL
89 90 91 92 93
GIOExtension *     g_io_extension_point_implement             (const char        *extension_point_name,
							       GType              type,
							       const char        *extension_name,
							       gint               priority);

94
GLIB_AVAILABLE_IN_ALL
95
GType              g_io_extension_get_type                    (GIOExtension      *extension);
96
GLIB_AVAILABLE_IN_ALL
97
const char *       g_io_extension_get_name                    (GIOExtension      *extension);
98
GLIB_AVAILABLE_IN_ALL
99
gint               g_io_extension_get_priority                (GIOExtension      *extension);
100
GLIB_AVAILABLE_IN_ALL
101 102
GTypeClass*        g_io_extension_ref_class                   (GIOExtension      *extension);

103 104

/* API for the modules to implement */
105

106 107 108
/**
 * g_io_module_load:
 * @module: a #GIOModule.
109 110
 *
 * Required API for GIO modules to implement.
111 112 113 114
 *
 * This function is run after the module has been loaded into GIO,
 * to initialize the module. Typically, this function will call
 * g_io_extension_point_implement().
115 116 117 118 119 120 121 122
 *
 * Since 2.56, this function should be named `g_io_<modulename>_load`, where
 * `modulename` is the plugin’s filename with the `lib` or `libgio` prefix and
 * everything after the first dot removed, and with `-` replaced with `_`
 * throughout. For example, `libgiognutls-helper.so` becomes `gnutls_helper`.
 * Using the new symbol names avoids name clashes when building modules
 * statically. The old symbol names continue to be supported, but cannot be used
 * for static builds.
123
 **/
124
GLIB_AVAILABLE_IN_ALL
125
void   g_io_module_load   (GIOModule *module);
126 127 128 129

/**
 * g_io_module_unload:
 * @module: a #GIOModule.
130 131
 *
 * Required API for GIO modules to implement.
132 133
 *
 * This function is run when the module is being unloaded from GIO,
134
 * to finalize the module.
135 136 137 138 139 140 141 142
 *
 * Since 2.56, this function should be named `g_io_<modulename>_unload`, where
 * `modulename` is the plugin’s filename with the `lib` or `libgio` prefix and
 * everything after the first dot removed, and with `-` replaced with `_`
 * throughout. For example, `libgiognutls-helper.so` becomes `gnutls_helper`.
 * Using the new symbol names avoids name clashes when building modules
 * statically. The old symbol names continue to be supported, but cannot be used
 * for static builds.
143
 **/
144
GLIB_AVAILABLE_IN_ALL
145
void   g_io_module_unload (GIOModule *module);
146

147 148 149 150 151 152 153 154 155 156
/**
 * g_io_module_query:
 *
 * Optional API for GIO modules to implement.
 *
 * Should return a list of all the extension points that may be
 * implemented in this module.
 *
 * This method will not be called in normal use, however it may be
 * called when probing existing modules and recording which extension
Matthias Clasen's avatar
Matthias Clasen committed
157
 * points that this model is used for. This means we won't have to
158
 * load and initialize this module unless its needed.
159 160
 *
 * If this function is not implemented by the module the module will
161 162
 * always be loaded, initialized and then unloaded on application
 * startup so that it can register its extension points during init.
163
 *
164 165 166 167 168
 * Note that a module need not actually implement all the extension
 * points that g_io_module_query() returns, since the exact list of
 * extension may depend on runtime issues. However all extension
 * points actually implemented must be returned by g_io_module_query()
 * (if defined).
169
 *
170
 * When installing a module that implements g_io_module_query() you must
171 172 173
 * run gio-querymodules in order to build the cache files required for
 * lazy loading.
 *
174 175 176 177 178 179 180 181
 * Since 2.56, this function should be named `g_io_<modulename>_query`, where
 * `modulename` is the plugin’s filename with the `lib` or `libgio` prefix and
 * everything after the first dot removed, and with `-` replaced with `_`
 * throughout. For example, `libgiognutls-helper.so` becomes `gnutls_helper`.
 * Using the new symbol names avoids name clashes when building modules
 * statically. The old symbol names continue to be supported, but cannot be used
 * for static builds.
 *
182 183 184
 * Returns: (transfer full): A %NULL-terminated array of strings,
 *     listing the supported extension points of the module. The array
 *     must be suitable for freeing with g_strfreev().
Matthias Clasen's avatar
Matthias Clasen committed
185
 *
186 187
 * Since: 2.24
 **/
188
GLIB_AVAILABLE_IN_ALL
189 190
char **g_io_module_query (void);

191 192
G_END_DECLS

Matthias Clasen's avatar
Matthias Clasen committed
193
#endif /* __G_IO_MODULE_H__ */