| 29 * @see_also: <link linkend="chapter-signals-plugin">Plugin signals</link>, |
29 * @see_also: <link linkend="chapter-signals-plugin">Plugin signals</link>, |
| 30 * <link linkend="chapter-plugin-ids">Plugin IDs</link>, |
30 * <link linkend="chapter-plugin-ids">Plugin IDs</link>, |
| 31 * <link linkend="chapter-plugin-i18n">Third Party Plugin Translation</link> |
31 * <link linkend="chapter-plugin-i18n">Third Party Plugin Translation</link> |
| 32 */ |
32 */ |
| 33 |
33 |
| 34 #ifdef PURPLE_PLUGINS |
|
| 35 #include <gplugin.h> |
34 #include <gplugin.h> |
| 36 #include <gplugin-native.h> |
35 #include <gplugin-native.h> |
| 37 #else |
|
| 38 #include <glib.h> |
|
| 39 #include <glib-object.h> |
|
| 40 #endif |
|
| 41 |
36 |
| 42 #include "version.h" |
37 #include "version.h" |
| 43 |
38 |
| 44 #define PURPLE_PLUGINS_DOMAIN (g_quark_from_static_string("plugins")) |
39 #define PURPLE_PLUGINS_DOMAIN (g_quark_from_static_string("plugins")) |
| 45 |
|
| 46 #ifdef PURPLE_PLUGINS |
|
| 47 |
40 |
| 48 #define PURPLE_TYPE_PLUGIN GPLUGIN_TYPE_PLUGIN |
41 #define PURPLE_TYPE_PLUGIN GPLUGIN_TYPE_PLUGIN |
| 49 #define PURPLE_PLUGIN(obj) GPLUGIN_PLUGIN(obj) |
42 #define PURPLE_PLUGIN(obj) GPLUGIN_PLUGIN(obj) |
| 50 #define PURPLE_PLUGIN_CLASS(klass) GPLUGIN_PLUGIN_CLASS(klass) |
43 #define PURPLE_PLUGIN_CLASS(klass) GPLUGIN_PLUGIN_CLASS(klass) |
| 51 #define PURPLE_IS_PLUGIN(obj) GPLUGIN_IS_PLUGIN(obj) |
44 #define PURPLE_IS_PLUGIN(obj) GPLUGIN_IS_PLUGIN(obj) |
| 60 */ |
53 */ |
| 61 typedef GPluginPlugin PurplePlugin; |
54 typedef GPluginPlugin PurplePlugin; |
| 62 |
55 |
| 63 typedef GPluginPluginClass PurplePluginClass; |
56 typedef GPluginPluginClass PurplePluginClass; |
| 64 |
57 |
| 65 #else /* !defined(PURPLE_PLUGINS) */ |
|
| 66 |
|
| 67 #define PURPLE_TYPE_PLUGIN G_TYPE_OBJECT |
|
| 68 #define PURPLE_PLUGIN(obj) G_OBJECT(obj) |
|
| 69 #define PURPLE_PLUGIN_CLASS(klass) G_OBJECT_CLASS(klass) |
|
| 70 #define PURPLE_IS_PLUGIN(obj) G_IS_OBJECT(obj) |
|
| 71 #define PURPLE_IS_PLUGIN_CLASS(klass) G_IS_OBJECT_CLASS(klass) |
|
| 72 #define PURPLE_PLUGIN_GET_CLASS(obj) G_OBJECT_GET_CLASS(obj) |
|
| 73 |
|
| 74 typedef GObject PurplePlugin; |
|
| 75 typedef GObjectClass PurplePluginClass; |
|
| 76 |
|
| 77 #endif /* PURPLE_PLUGINS */ |
|
| 78 |
|
| 79 #define PURPLE_TYPE_PLUGIN_INFO (purple_plugin_info_get_type()) |
58 #define PURPLE_TYPE_PLUGIN_INFO (purple_plugin_info_get_type()) |
| 80 #define PURPLE_PLUGIN_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PLUGIN_INFO, PurplePluginInfo)) |
59 #define PURPLE_PLUGIN_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PLUGIN_INFO, PurplePluginInfo)) |
| 81 #define PURPLE_PLUGIN_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_PLUGIN_INFO, PurplePluginInfoClass)) |
60 #define PURPLE_PLUGIN_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_PLUGIN_INFO, PurplePluginInfoClass)) |
| 82 #define PURPLE_IS_PLUGIN_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PLUGIN_INFO)) |
61 #define PURPLE_IS_PLUGIN_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PLUGIN_INFO)) |
| 83 #define PURPLE_IS_PLUGIN_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_PLUGIN_INFO)) |
62 #define PURPLE_IS_PLUGIN_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_PLUGIN_INFO)) |
| 160 * field provided to the UIs -- it is not used by the libpurple core. |
139 * field provided to the UIs -- it is not used by the libpurple core. |
| 161 * |
140 * |
| 162 * Holds information about a plugin. |
141 * Holds information about a plugin. |
| 163 */ |
142 */ |
| 164 struct _PurplePluginInfo { |
143 struct _PurplePluginInfo { |
| 165 #ifdef PURPLE_PLUGINS |
|
| 166 GPluginPluginInfo parent; |
144 GPluginPluginInfo parent; |
| 167 #else |
|
| 168 GObject parent; |
|
| 169 #endif |
|
| 170 |
145 |
| 171 /*< public >*/ |
146 /*< public >*/ |
| 172 gpointer ui_data; |
147 gpointer ui_data; |
| 173 }; |
148 }; |
| 174 |
149 |
| 175 struct _PurplePluginInfoClass { |
150 struct _PurplePluginInfoClass { |
| 176 #ifdef PURPLE_PLUGINS |
|
| 177 GPluginPluginInfoClass parent_class; |
151 GPluginPluginInfoClass parent_class; |
| 178 #else |
|
| 179 GObjectClass parent_class; |
|
| 180 #endif |
|
| 181 |
152 |
| 182 /*< private >*/ |
153 /*< private >*/ |
| 183 void (*_purple_reserved1)(void); |
154 void (*_purple_reserved1)(void); |
| 184 void (*_purple_reserved2)(void); |
155 void (*_purple_reserved2)(void); |
| 185 void (*_purple_reserved3)(void); |
156 void (*_purple_reserved3)(void); |
| 237 /** |
208 /** |
| 238 * PURPLE_PLUGIN_INIT: |
209 * PURPLE_PLUGIN_INIT: |
| 239 * |
210 * |
| 240 * Defines the plugin's entry points. |
211 * Defines the plugin's entry points. |
| 241 */ |
212 */ |
| 242 #ifdef PURPLE_PLUGINS |
|
| 243 #define PURPLE_PLUGIN_INIT(pluginname,pluginquery,pluginload,pluginunload) \ |
213 #define PURPLE_PLUGIN_INIT(pluginname,pluginquery,pluginload,pluginunload) \ |
| 244 G_MODULE_EXPORT GPluginPluginInfo *gplugin_query(GError **e); \ |
214 G_MODULE_EXPORT GPluginPluginInfo *gplugin_query(GError **e); \ |
| 245 G_MODULE_EXPORT GPluginPluginInfo *gplugin_query(GError **e) { \ |
215 G_MODULE_EXPORT GPluginPluginInfo *gplugin_query(GError **e) { \ |
| 246 return GPLUGIN_PLUGIN_INFO(pluginquery(e)); \ |
216 return GPLUGIN_PLUGIN_INFO(pluginquery(e)); \ |
| 247 } \ |
217 } \ |
| 251 } \ |
221 } \ |
| 252 G_MODULE_EXPORT gboolean gplugin_unload(GPluginNativePlugin *p, GError **e); \ |
222 G_MODULE_EXPORT gboolean gplugin_unload(GPluginNativePlugin *p, GError **e); \ |
| 253 G_MODULE_EXPORT gboolean gplugin_unload(GPluginNativePlugin *p, GError **e) { \ |
223 G_MODULE_EXPORT gboolean gplugin_unload(GPluginNativePlugin *p, GError **e) { \ |
| 254 return pluginunload(PURPLE_PLUGIN(p), e); \ |
224 return pluginunload(PURPLE_PLUGIN(p), e); \ |
| 255 } |
225 } |
| 256 #endif |
|
| 257 |
226 |
| 258 /** |
227 /** |
| 259 * PURPLE_DEFINE_TYPE: |
228 * PURPLE_DEFINE_TYPE: |
| 260 * @TN: The name of the new type, in Camel case. |
229 * @TN: The name of the new type, in Camel case. |
| 261 * @t_n: The name of the new type, in lowercase, words separated by '_'. |
230 * @t_n: The name of the new type, in lowercase, words separated by '_'. |
| 264 * A convenience macro for type implementations, which defines a *_get_type() |
233 * A convenience macro for type implementations, which defines a *_get_type() |
| 265 * function; and a *_register_type() function for use in your plugin's load |
234 * function; and a *_register_type() function for use in your plugin's load |
| 266 * function. You must define an instance initialization function *_init() |
235 * function. You must define an instance initialization function *_init() |
| 267 * and a class initialization function *_class_init() for the type. |
236 * and a class initialization function *_class_init() for the type. |
| 268 */ |
237 */ |
| 269 #ifdef PURPLE_PLUGINS |
|
| 270 #define PURPLE_DEFINE_TYPE(TN, t_n, T_P) \ |
238 #define PURPLE_DEFINE_TYPE(TN, t_n, T_P) \ |
| 271 PURPLE_DEFINE_DYNAMIC_TYPE(TN, t_n, T_P) |
239 PURPLE_DEFINE_DYNAMIC_TYPE(TN, t_n, T_P) |
| 272 #endif |
|
| 273 |
240 |
| 274 /** |
241 /** |
| 275 * PURPLE_DEFINE_TYPE_EXTENDED: |
242 * PURPLE_DEFINE_TYPE_EXTENDED: |
| 276 * @TN: The name of the new type, in Camel case. |
243 * @TN: The name of the new type, in Camel case. |
| 277 * @t_n: The name of the new type, in lowercase, words separated by '_'. |
244 * @t_n: The name of the new type, in lowercase, words separated by '_'. |
| 280 * @CODE: Custom code that gets inserted in *_get_type(). |
247 * @CODE: Custom code that gets inserted in *_get_type(). |
| 281 * |
248 * |
| 282 * A more general version of PURPLE_DEFINE_TYPE() which allows you to |
249 * A more general version of PURPLE_DEFINE_TYPE() which allows you to |
| 283 * specify #GTypeFlags and custom code. |
250 * specify #GTypeFlags and custom code. |
| 284 */ |
251 */ |
| 285 #ifdef PURPLE_PLUGINS |
|
| 286 #define PURPLE_DEFINE_TYPE_EXTENDED \ |
252 #define PURPLE_DEFINE_TYPE_EXTENDED \ |
| 287 PURPLE_DEFINE_DYNAMIC_TYPE_EXTENDED |
253 PURPLE_DEFINE_DYNAMIC_TYPE_EXTENDED |
| 288 #endif |
|
| 289 |
254 |
| 290 /** |
255 /** |
| 291 * PURPLE_IMPLEMENT_INTERFACE_STATIC: |
256 * PURPLE_IMPLEMENT_INTERFACE_STATIC: |
| 292 * @TYPE_IFACE: The #GType of the interface to add. |
257 * @TYPE_IFACE: The #GType of the interface to add. |
| 293 * @iface_init: The interface init function. |
258 * @iface_init: The interface init function. |
| 310 * |
275 * |
| 311 * A convenience macro to ease interface addition in the CODE section |
276 * A convenience macro to ease interface addition in the CODE section |
| 312 * of PURPLE_DEFINE_TYPE_EXTENDED(). You should use this macro if the |
277 * of PURPLE_DEFINE_TYPE_EXTENDED(). You should use this macro if the |
| 313 * interface lives in the plugin. |
278 * interface lives in the plugin. |
| 314 */ |
279 */ |
| 315 #ifdef PURPLE_PLUGINS |
|
| 316 #define PURPLE_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) \ |
280 #define PURPLE_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) \ |
| 317 PURPLE_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init) |
281 PURPLE_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init) |
| 318 #endif |
|
| 319 |
282 |
| 320 /** |
283 /** |
| 321 * PURPLE_DEFINE_DYNAMIC_TYPE: |
284 * PURPLE_DEFINE_DYNAMIC_TYPE: |
| 322 * |
285 * |
| 323 * A convenience macro for dynamic type implementations. |
286 * A convenience macro for dynamic type implementations. |