Update copyright message
[nautilus-actions.git] / src / io-xml / naxml-provider.c
blob0a424dd7861ec88f325f453451e91ce362e9309a
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_debug( "%s: instance=%p (%s), klass=%p",
152 thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ), ( void * ) klass );
153 g_return_if_fail( NA_IS_XML_PROVIDER( instance ));
154 self = NAXML_PROVIDER( instance );
156 self->private = g_new0( NAXMLProviderPrivate, 1 );
158 self->private->dispose_has_run = FALSE;
161 static void
162 instance_dispose( GObject *object )
164 static const gchar *thisfn = "naxml_provider_instance_dispose";
165 NAXMLProvider *self;
167 g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
168 g_return_if_fail( NA_IS_XML_PROVIDER( object ));
169 self = NAXML_PROVIDER( object );
171 if( !self->private->dispose_has_run ){
173 self->private->dispose_has_run = TRUE;
175 /* chain up to the parent class */
176 if( G_OBJECT_CLASS( st_parent_class )->dispose ){
177 G_OBJECT_CLASS( st_parent_class )->dispose( object );
182 static void
183 instance_finalize( GObject *object )
185 NAXMLProvider *self;
187 g_assert( NA_IS_XML_PROVIDER( object ));
188 self = NAXML_PROVIDER( object );
190 g_free( self->private );
192 /* chain call to parent class */
193 if( G_OBJECT_CLASS( st_parent_class )->finalize ){
194 G_OBJECT_CLASS( st_parent_class )->finalize( object );
198 static void
199 iimporter_iface_init( NAIImporterInterface *iface )
201 static const gchar *thisfn = "naxml_provider_iimporter_iface_init";
203 g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
205 iface->get_version = iimporter_get_version;
206 iface->import_from_uri = naxml_reader_import_from_uri;
209 static guint
210 iimporter_get_version( const NAIImporter *importer )
212 return( 1 );
215 static void
216 iexporter_iface_init( NAIExporterInterface *iface )
218 static const gchar *thisfn = "naxml_provider_iexporter_iface_init";
220 g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
222 iface->get_version = iexporter_get_version;
223 iface->get_name = iexporter_get_name;
224 iface->get_formats = iexporter_get_formats;
225 iface->to_file = naxml_writer_export_to_file;
226 iface->to_buffer = naxml_writer_export_to_buffer;
229 static guint
230 iexporter_get_version( const NAIExporter *exporter )
232 return( 1 );
235 static gchar *
236 iexporter_get_name( const NAIExporter *exporter )
238 return( g_strdup( "NAXML Exporter" ));
241 static const NAIExporterFormat *
242 iexporter_get_formats( const NAIExporter *exporter )
244 return( naxml_formats );
247 static void
248 ifactory_provider_iface_init( NAIFactoryProviderInterface *iface )
250 static const gchar *thisfn = "naxml_provider_ifactory_provider_iface_init";
252 g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
254 iface->get_version = ifactory_provider_get_version;
255 iface->read_start = naxml_reader_read_start;
256 iface->read_data = naxml_reader_read_data;
257 iface->read_done = naxml_reader_read_done;
258 iface->write_start = naxml_writer_write_start;
259 iface->write_data = naxml_writer_write_data;
260 iface->write_done = naxml_writer_write_done;
263 static guint
264 ifactory_provider_get_version( const NAIFactoryProvider *factory )
266 return( 1 );