1 #ifndef GO_PLUGIN_SERVICE_H
2 #define GO_PLUGIN_SERVICE_H
3 
4 #include <goffice/app/goffice-app.h>
5 #include <goffice/app/go-plugin.h>
6 #include <glib.h>
7 #include <gmodule.h>
8 #include <libxml/tree.h>
9 
10 G_BEGIN_DECLS
11 
12 #define GO_TYPE_PLUGIN_SERVICE         (go_plugin_service_get_type ())
13 #define GO_PLUGIN_SERVICE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_TYPE_PLUGIN_SERVICE, GOPluginService))
14 #define GO_IS_PLUGIN_SERVICE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_TYPE_PLUGIN_SERVICE))
15 
16 GType go_plugin_service_get_type (void);
17 
18 #define GO_TYPE_PLUGIN_SERVICE_GENERAL  (go_plugin_service_general_get_type ())
19 #define GO_PLUGIN_SERVICE_GENERAL(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_TYPE_PLUGIN_SERVICE_GENERAL, GOPluginServiceGeneral))
20 #define GO_IS_PLUGIN_SERVICE_GENERAL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_TYPE_PLUGIN_SERVICE_GENERAL))
21 
22 GType go_plugin_service_general_get_type (void);
23 typedef struct _GOPluginServiceGeneral GOPluginServiceGeneral;
24 typedef struct {
25 	void (*plugin_func_init) (GOPluginService *service, GOErrorInfo **ret_error);
26 	void (*plugin_func_cleanup) (GOPluginService *service, GOErrorInfo **ret_error);
27 } GOPluginServiceGeneralCallbacks;
28 
29 #define GO_TYPE_PLUGIN_SERVICE_RESOURCE  (go_plugin_service_resource_get_type ())
30 #define GO_PLUGIN_SERVICE_RESOURCE(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_TYPE_PLUGIN_SERVICE_RESOURCE, GOPluginServiceResource))
31 #define GO_IS_PLUGIN_SERVICE_RESOURCE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_TYPE_PLUGIN_SERVICE_RESOURCE))
32 
33 GType go_plugin_service_resource_get_type (void);
34 typedef struct _GOPluginServiceResource GOPluginServiceResource;
35 
36 #define GO_TYPE_PLUGIN_SERVICE_FILE_OPENER  (go_plugin_service_file_opener_get_type ())
37 #define GO_PLUGIN_SERVICE_FILE_OPENER(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_TYPE_PLUGIN_SERVICE_FILE_OPENER, GOPluginServiceFileOpener))
38 #define GO_IS_PLUGIN_SERVICE_FILE_OPENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_TYPE_PLUGIN_SERVICE_FILE_OPENER))
39 
40 GType go_plugin_service_file_opener_get_type (void);
41 typedef struct _GOPluginServiceFileOpener GOPluginServiceFileOpener;
42 typedef struct {
43 	/* plugin_func_file_probe may be NULL */
44 	gboolean (*plugin_func_file_probe) (
45 	         GOFileOpener const *fo, GOPluginService *service,
46 	         GsfInput *input, GOFileProbeLevel pl);
47 	void     (*plugin_func_file_open) (
48 	         GOFileOpener const *fo, GOPluginService *service,
49 	         GOIOContext *io_context, GoView *view,
50 		 GsfInput *input, char const *enc);
51 } GOPluginServiceFileOpenerCallbacks;
52 
53 
54 #define GO_TYPE_PLUGIN_SERVICE_FILE_SAVER  (go_plugin_service_file_saver_get_type ())
55 #define GO_PLUGIN_SERVICE_FILE_SAVER(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_TYPE_PLUGIN_SERVICE_FILE_SAVER, GOPluginServiceFileSaver))
56 #define GO_IS_PLUGIN_SERVICE_FILE_SAVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_TYPE_PLUGIN_SERVICE_FILE_SAVER))
57 
58 GType go_plugin_service_file_saver_get_type (void);
59 typedef struct _GOPluginServiceFileSaver GOPluginServiceFileSaver;
60 typedef struct {
61 	void  (*plugin_func_file_save) (
62 	      GOFileSaver const *fs, GOPluginService *service,
63 	      GOIOContext *io_context, GoView const *view,
64 	      GsfOutput *output);
65 } GOPluginServiceFileSaverCallbacks;
66 
67 #define GO_TYPE_PLUGIN_SERVICE_PLUGIN_LOADER  (go_plugin_service_plugin_loader_get_type ())
68 #define GO_PLUGIN_SERVICE_PLUGIN_LOADER(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_TYPE_PLUGIN_SERVICE_PLUGIN_LOADER, GOPluginServicePluginLoader))
69 #define GO_IS_PLUGIN_SERVICE_PLUGIN_LOADER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_TYPE_PLUGIN_SERVICE_PLUGIN_LOADER))
70 
71 GType go_plugin_service_plugin_loader_get_type (void);
72 typedef struct _GOPluginServicePluginLoader GOPluginServicePluginLoader;
73 typedef struct {
74 	GType (*plugin_func_get_loader_type) (
75 	      GOPluginService *service, GOErrorInfo **ret_error);
76 } GOPluginServicePluginLoaderCallbacks;
77 
78 GType go_plugin_service_plugin_loader_generate_type (GOPluginService *service,
79 						     GOErrorInfo **ret_error);
80 
81 /****************************************************************************/
82 
83 #define GO_TYPE_PLUGIN_SERVICE_GOBJECT_LOADER  (go_plugin_service_gobject_loader_get_type ())
84 #define GO_PLUGIN_SERVICE_GOBJECT_LOADER(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_TYPE_PLUGIN_SERVICE_GOBJECT_LOADER, GOPluginServiceGObjectLoader))
85 #define GO_IS_PLUGIN_SERVICE_GOBJECT_LOADER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_TYPE_PLUGIN_SERVICE_GOBJECT_LOADER))
86 
87 GType go_plugin_service_gobject_loader_get_type (void);
88 typedef struct _GOPluginServiceGObjectLoader GOPluginServiceGObjectLoader;
89 
90 /****************************************************************************/
91 #define GO_TYPE_PLUGIN_SERVICE_SIMPLE  (go_plugin_service_simple_get_type ())
92 #define GO_PLUGIN_SERVICE_SIMPLE(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_TYPE_PLUGIN_SERVICE_SIMPLE, GOPluginServiceSimple))
93 #define GO_IS_PLUGIN_SERVICE_SIMPLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_TYPE_PLUGIN_SERVICE_SIMPLE))
94 
95 GType go_plugin_service_simple_get_type (void);
96 typedef struct _GOPluginServiceSimple GOPluginServiceSimple;
97 
98 /****************************************************************************/
99 
100 GOPluginService  *go_plugin_service_new (GOPlugin *plugin, xmlNode *tree, GOErrorInfo **ret_error);
101 char const     *go_plugin_service_get_id (const GOPluginService *service);
102 char const     *go_plugin_service_get_description (GOPluginService *service);
103 GOPlugin      *go_plugin_service_get_plugin (GOPluginService *service);
104 gpointer	go_plugin_service_get_cbs (GOPluginService *service);
105 void		go_plugin_service_activate (GOPluginService *service, GOErrorInfo **ret_error);
106 void		go_plugin_service_deactivate (GOPluginService *service, GOErrorInfo **ret_error);
107 void		go_plugin_service_load   (GOPluginService *service, GOErrorInfo **ret_error);
108 void		go_plugin_service_unload (GOPluginService *service, GOErrorInfo **ret_error);
109 
110 typedef GType (*GOPluginServiceCreate) (void);
111 void _go_plugin_services_init     (void);
112 void go_plugin_services_shutdown (void);
113 void go_plugin_service_define    (char const *type_str,
114 				  GOPluginServiceCreate ctor);
115 
116 G_END_DECLS
117 
118 #endif /* GO_PLUGIN_SERVICE_H */
119