README: add deprecation notice
[nautilus-actions.git] / src / io-xml / fma-xml-provider.c
blob426066d936e048810dca2188a87c0f71aecd3a89
1 /*
2 * FileManager-Actions
3 * A file-manager extension which offers configurable context menu actions.
5 * Copyright (C) 2005 The GNOME Foundation
6 * Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
7 * Copyright (C) 2009-2015 Pierre Wieser and others (see AUTHORS)
9 * FileManager-Actions is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * FileManager-Actions is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with FileManager-Actions; see the file COPYING. If not, see
21 * <http://www.gnu.org/licenses/>.
23 * Authors:
24 * Frederic Ruaudel <grumz@grumz.net>
25 * Rodrigo Moya <rodrigo@gnome-db.org>
26 * Pierre Wieser <pwieser@trychlos.org>
27 * ... and many others (see AUTHORS)
30 #ifdef HAVE_CONFIG_H
31 #include <config.h>
32 #endif
34 #include <api/fma-ifactory-provider.h>
35 #include <api/fma-iexporter.h>
36 #include <api/fma-iimporter.h>
38 #include "fma-xml-provider.h"
39 #include "fma-xml-formats.h"
40 #include "fma-xml-reader.h"
41 #include "fma-xml-writer.h"
43 /* private class data
45 struct _FMAXMLProviderClassPrivate {
46 void *empty; /* so that gcc -pedantic is happy */
49 /* private instance data
51 struct _FMAXMLProviderPrivate {
52 gboolean dispose_has_run;
55 static GType st_module_type = 0;
56 static GObjectClass *st_parent_class = NULL;
58 static void class_init( FMAXMLProviderClass *klass );
59 static void instance_init( GTypeInstance *instance, gpointer klass );
60 static void instance_dispose( GObject *object );
61 static void instance_finalize( GObject *object );
63 static void iimporter_iface_init( FMAIImporterInterface *iface );
64 static guint iimporter_get_version( const FMAIImporter *importer );
66 static void iexporter_iface_init( FMAIExporterInterface *iface );
67 static guint iexporter_get_version( const FMAIExporter *exporter );
68 static gchar *iexporter_get_name( const FMAIExporter *exporter );
69 static void *iexporter_get_formats( const FMAIExporter *exporter );
70 static void iexporter_free_formats( const FMAIExporter *exporter, GList *format_list );
72 static void ifactory_provider_iface_init( FMAIFactoryProviderInterface *iface );
73 static guint ifactory_provider_get_version( const FMAIFactoryProvider *factory );
75 GType
76 fma_xml_provider_get_type( void )
78 return( st_module_type );
81 void
82 fma_xml_provider_register_type( GTypeModule *module )
84 static const gchar *thisfn = "fma_xml_provider_register_type";
86 static GTypeInfo info = {
87 sizeof( FMAXMLProviderClass ),
88 NULL,
89 NULL,
90 ( GClassInitFunc ) class_init,
91 NULL,
92 NULL,
93 sizeof( FMAXMLProvider ),
95 ( GInstanceInitFunc ) instance_init
98 static const GInterfaceInfo iimporter_iface_info = {
99 ( GInterfaceInitFunc ) iimporter_iface_init,
100 NULL,
101 NULL
104 static const GInterfaceInfo iexporter_iface_info = {
105 ( GInterfaceInitFunc ) iexporter_iface_init,
106 NULL,
107 NULL
110 static const GInterfaceInfo ifactory_provider_iface_info = {
111 ( GInterfaceInitFunc ) ifactory_provider_iface_init,
112 NULL,
113 NULL
116 g_debug( "%s", thisfn );
118 st_module_type = g_type_module_register_type( module, G_TYPE_OBJECT, "FMAXMLProvider", &info, 0 );
120 g_type_module_add_interface( module, st_module_type, FMA_TYPE_IIMPORTER, &iimporter_iface_info );
122 g_type_module_add_interface( module, st_module_type, FMA_TYPE_IEXPORTER, &iexporter_iface_info );
124 g_type_module_add_interface( module, st_module_type, FMA_TYPE_IFACTORY_PROVIDER, &ifactory_provider_iface_info );
127 static void
128 class_init( FMAXMLProviderClass *klass )
130 static const gchar *thisfn = "fma_xml_provider_class_init";
131 GObjectClass *object_class;
133 g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
135 st_parent_class = g_type_class_peek_parent( klass );
137 object_class = G_OBJECT_CLASS( klass );
138 object_class->dispose = instance_dispose;
139 object_class->finalize = instance_finalize;
141 klass->private = g_new0( FMAXMLProviderClassPrivate, 1 );
144 static void
145 instance_init( GTypeInstance *instance, gpointer klass )
147 static const gchar *thisfn = "fma_xml_provider_instance_init";
148 FMAXMLProvider *self;
150 g_return_if_fail( FMA_IS_XML_PROVIDER( instance ));
152 g_debug( "%s: instance=%p (%s), klass=%p",
153 thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ), ( void * ) klass );
155 self = FMA_XML_PROVIDER( instance );
157 self->private = g_new0( FMAXMLProviderPrivate, 1 );
159 self->private->dispose_has_run = FALSE;
162 static void
163 instance_dispose( GObject *object )
165 static const gchar *thisfn = "fma_xml_provider_instance_dispose";
166 FMAXMLProvider *self;
168 g_return_if_fail( FMA_IS_XML_PROVIDER( object ));
170 self = FMA_XML_PROVIDER( object );
172 if( !self->private->dispose_has_run ){
174 g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
176 self->private->dispose_has_run = TRUE;
178 /* chain up to the parent class */
179 if( G_OBJECT_CLASS( st_parent_class )->dispose ){
180 G_OBJECT_CLASS( st_parent_class )->dispose( object );
185 static void
186 instance_finalize( GObject *object )
188 static const gchar *thisfn = "fma_xml_provider_instance_finalize";
189 FMAXMLProvider *self;
191 g_return_if_fail( FMA_IS_XML_PROVIDER( object ));
193 g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
195 self = FMA_XML_PROVIDER( object );
197 g_free( self->private );
199 /* chain call to parent class */
200 if( G_OBJECT_CLASS( st_parent_class )->finalize ){
201 G_OBJECT_CLASS( st_parent_class )->finalize( object );
205 static void
206 iimporter_iface_init( FMAIImporterInterface *iface )
208 static const gchar *thisfn = "fma_xml_provider_iimporter_iface_init";
210 g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
212 iface->get_version = iimporter_get_version;
213 iface->import_from_uri = fma_xml_reader_import_from_uri;
216 static guint
217 iimporter_get_version( const FMAIImporter *importer )
219 return( 2 );
222 static void
223 iexporter_iface_init( FMAIExporterInterface *iface )
225 static const gchar *thisfn = "fma_xml_provider_iexporter_iface_init";
227 g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
229 iface->get_version = iexporter_get_version;
230 iface->get_name = iexporter_get_name;
231 iface->get_formats = iexporter_get_formats;
232 iface->free_formats = iexporter_free_formats;
233 iface->to_file = fma_xml_writer_export_to_file;
234 iface->to_buffer = fma_xml_writer_export_to_buffer;
237 static guint
238 iexporter_get_version( const FMAIExporter *exporter )
240 return( 2 );
243 static gchar *
244 iexporter_get_name( const FMAIExporter *exporter )
246 return( g_strdup( "NAXML Exporter" ));
249 static void *
250 iexporter_get_formats( const FMAIExporter *exporter )
252 return(( void * ) fma_xml_formats_get_formats( exporter ));
255 static void
256 iexporter_free_formats( const FMAIExporter *exporter, GList *format_list )
258 fma_xml_formats_free_formats( format_list );
261 static void
262 ifactory_provider_iface_init( FMAIFactoryProviderInterface *iface )
264 static const gchar *thisfn = "fma_xml_provider_ifactory_provider_iface_init";
266 g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
268 iface->get_version = ifactory_provider_get_version;
269 iface->read_start = fma_xml_reader_read_start;
270 iface->read_data = fma_xml_reader_read_data;
271 iface->read_done = fma_xml_reader_read_done;
272 iface->write_start = fma_xml_writer_write_start;
273 iface->write_data = fma_xml_writer_write_data;
274 iface->write_done = fma_xml_writer_write_done;
277 static guint
278 ifactory_provider_get_version( const FMAIFactoryProvider *factory )
280 return( 1 );