Update ChangeLog
[nautilus-actions.git] / src / io-xml / naxml-provider.c
blob3ced3f7bbaa15502e868c29566f3b2c3eb08349c
1 /*
2 * Nautilus-Actions
3 * A Nautilus extension which offers configurable context menu actions.
5 * Copyright (C) 2005 The GNOME Foundation
6 * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
7 * Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
9 * This Program 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 * This Program 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
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public
20 * License along with this Library; see the file COPYING. If not,
21 * write to the Free Software Foundation, Inc., 59 Temple Place,
22 * Suite 330, Boston, MA 02111-1307, USA.
24 * Authors:
25 * Frederic Ruaudel <grumz@grumz.net>
26 * Rodrigo Moya <rodrigo@gnome-db.org>
27 * Pierre Wieser <pwieser@trychlos.org>
28 * ... and many others (see AUTHORS)
31 #ifdef HAVE_CONFIG_H
32 #include <config.h>
33 #endif
35 #include <api/na-ifactory-provider.h>
36 #include <api/na-iexporter.h>
37 #include <api/na-iimporter.h>
39 #include "naxml-provider.h"
40 #include "naxml-reader.h"
41 #include "naxml-writer.h"
43 /* private class data
45 struct _NAXMLProviderClassPrivate {
46 void *empty; /* so that gcc -pedantic is happy */
49 /* private instance data
51 struct _NAXMLProviderPrivate {
52 gboolean dispose_has_run;
55 extern NAIExporterFormat naxml_formats[];
57 static GType st_module_type = 0;
58 static GObjectClass *st_parent_class = NULL;
60 static void class_init( NAXMLProviderClass *klass );
61 static void instance_init( GTypeInstance *instance, gpointer klass );
62 static void instance_dispose( GObject *object );
63 static void instance_finalize( GObject *object );
65 static void iimporter_iface_init( NAIImporterInterface *iface );
66 static guint iimporter_get_version( const NAIImporter *importer );
68 static void iexporter_iface_init( NAIExporterInterface *iface );
69 static guint iexporter_get_version( const NAIExporter *exporter );
70 static gchar *iexporter_get_name( const NAIExporter *exporter );
71 static const NAIExporterFormat *iexporter_get_formats( const NAIExporter *exporter );
73 static void ifactory_provider_iface_init( NAIFactoryProviderInterface *iface );
74 static guint ifactory_provider_get_version( const NAIFactoryProvider *factory );
76 GType
77 naxml_provider_get_type( void )
79 return( st_module_type );
82 void
83 naxml_provider_register_type( GTypeModule *module )
85 static const gchar *thisfn = "naxml_provider_register_type";
87 static GTypeInfo info = {
88 sizeof( NAXMLProviderClass ),
89 NULL,
90 NULL,
91 ( GClassInitFunc ) class_init,
92 NULL,
93 NULL,
94 sizeof( NAXMLProvider ),
96 ( GInstanceInitFunc ) instance_init
99 static const GInterfaceInfo iimporter_iface_info = {
100 ( GInterfaceInitFunc ) iimporter_iface_init,
101 NULL,
102 NULL
105 static const GInterfaceInfo iexporter_iface_info = {
106 ( GInterfaceInitFunc ) iexporter_iface_init,
107 NULL,
108 NULL
111 static const GInterfaceInfo ifactory_provider_iface_info = {
112 ( GInterfaceInitFunc ) ifactory_provider_iface_init,
113 NULL,
114 NULL
117 g_debug( "%s", thisfn );
119 st_module_type = g_type_module_register_type( module, G_TYPE_OBJECT, "NAXMLProvider", &info, 0 );
121 g_type_module_add_interface( module, st_module_type, NA_IIMPORTER_TYPE, &iimporter_iface_info );
123 g_type_module_add_interface( module, st_module_type, NA_IEXPORTER_TYPE, &iexporter_iface_info );
125 g_type_module_add_interface( module, st_module_type, NA_IFACTORY_PROVIDER_TYPE, &ifactory_provider_iface_info );
128 static void
129 class_init( NAXMLProviderClass *klass )
131 static const gchar *thisfn = "naxml_provider_class_init";
132 GObjectClass *object_class;
134 g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
136 st_parent_class = g_type_class_peek_parent( klass );
138 object_class = G_OBJECT_CLASS( klass );
139 object_class->dispose = instance_dispose;
140 object_class->finalize = instance_finalize;
142 klass->private = g_new0( NAXMLProviderClassPrivate, 1 );
145 static void
146 instance_init( GTypeInstance *instance, gpointer klass )
148 static const gchar *thisfn = "naxml_provider_instance_init";
149 NAXMLProvider *self;
151 g_return_if_fail( NA_IS_XML_PROVIDER( instance ));
153 g_debug( "%s: instance=%p (%s), klass=%p",
154 thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ), ( void * ) klass );
156 self = NAXML_PROVIDER( instance );
158 self->private = g_new0( NAXMLProviderPrivate, 1 );
160 self->private->dispose_has_run = FALSE;
163 static void
164 instance_dispose( GObject *object )
166 static const gchar *thisfn = "naxml_provider_instance_dispose";
167 NAXMLProvider *self;
169 g_return_if_fail( NA_IS_XML_PROVIDER( object ));
171 self = NAXML_PROVIDER( object );
173 if( !self->private->dispose_has_run ){
175 g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
177 self->private->dispose_has_run = TRUE;
179 /* chain up to the parent class */
180 if( G_OBJECT_CLASS( st_parent_class )->dispose ){
181 G_OBJECT_CLASS( st_parent_class )->dispose( object );
186 static void
187 instance_finalize( GObject *object )
189 static const gchar *thisfn = "naxml_provider_instance_finalize";
190 NAXMLProvider *self;
192 g_return_if_fail( NA_IS_XML_PROVIDER( object ));
194 g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
196 self = NAXML_PROVIDER( object );
198 g_free( self->private );
200 /* chain call to parent class */
201 if( G_OBJECT_CLASS( st_parent_class )->finalize ){
202 G_OBJECT_CLASS( st_parent_class )->finalize( object );
206 static void
207 iimporter_iface_init( NAIImporterInterface *iface )
209 static const gchar *thisfn = "naxml_provider_iimporter_iface_init";
211 g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
213 iface->get_version = iimporter_get_version;
214 iface->import_from_uri = naxml_reader_import_from_uri;
217 static guint
218 iimporter_get_version( const NAIImporter *importer )
220 return( 1 );
223 static void
224 iexporter_iface_init( NAIExporterInterface *iface )
226 static const gchar *thisfn = "naxml_provider_iexporter_iface_init";
228 g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
230 iface->get_version = iexporter_get_version;
231 iface->get_name = iexporter_get_name;
232 iface->get_formats = iexporter_get_formats;
233 iface->to_file = naxml_writer_export_to_file;
234 iface->to_buffer = naxml_writer_export_to_buffer;
237 static guint
238 iexporter_get_version( const NAIExporter *exporter )
240 return( 1 );
243 static gchar *
244 iexporter_get_name( const NAIExporter *exporter )
246 return( g_strdup( "NAXML Exporter" ));
249 static const NAIExporterFormat *
250 iexporter_get_formats( const NAIExporter *exporter )
252 return( naxml_formats );
255 static void
256 ifactory_provider_iface_init( NAIFactoryProviderInterface *iface )
258 static const gchar *thisfn = "naxml_provider_ifactory_provider_iface_init";
260 g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
262 iface->get_version = ifactory_provider_get_version;
263 iface->read_start = naxml_reader_read_start;
264 iface->read_data = naxml_reader_read_data;
265 iface->read_done = naxml_reader_read_done;
266 iface->write_start = naxml_writer_write_start;
267 iface->write_data = naxml_writer_write_data;
268 iface->write_done = naxml_writer_write_done;
271 static guint
272 ifactory_provider_get_version( const NAIFactoryProvider *factory )
274 return( 1 );