[nautilus-actions] Implement NAXMLReader
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Implement NAXMLReader
- Date: Fri, 26 Feb 2010 00:42:32 +0000 (UTC)
commit d30f3f82f944041f0d891130dc181bef7e932d7d
Author: Pierre Wieser <pwieser trychlos org>
Date: Sun Feb 21 01:52:21 2010 +0100
Implement NAXMLReader
ChangeLog | 50 +
po/POTFILES.in | 4 +-
src/api/na-idata-factory-str.h | 35 +-
src/api/na-idata-factory.h | 7 +-
src/api/na-iimporter.h | 29 +
src/api/na-iio-factory.h | 2 +
src/api/na-object-api.h | 58 +-
src/core/Makefile.am | 2 +
src/core/na-data-factory.c | 56 +-
src/core/na-data-factory.h | 6 +-
src/core/na-idata-factory.c | 22 +-
src/core/na-iio-factory.c | 13 +
src/core/na-importer.c | 22 +-
src/core/na-importer.h | 5 +-
src/core/na-io-factory.c | 61 ++-
src/core/na-io-factory.h | 1 +
src/core/na-iprefs.h | 9 -
src/core/na-module.c | 4 +-
src/core/na-object-action-enum.c | 18 +-
src/core/na-object-action.c | 2 +-
src/core/na-object-id-enum.c | 8 +-
src/core/na-object-item-enum.c | 20 +-
src/core/na-object-item.c | 8 +
src/core/na-object-menu-enum.c | 5 +-
src/core/na-object-menu.c | 2 +-
src/core/na-object-profile-enum.c | 24 +-
src/core/na-object-profile.c | 2 +-
src/core/na-pivot.c | 7 +-
src/io-desktop/Makefile.am | 1 +
src/io-gconf/Makefile.am | 1 +
src/io-xml/Makefile.am | 8 +
src/io-xml/nact-xml-reader.h | 77 --
src/io-xml/naxml-keys.c | 53 +
src/io-xml/{na-xml-names.h => naxml-keys.h} | 86 ++-
src/io-xml/naxml-provider.c | 72 +-
src/io-xml/naxml-provider.h | 26 +-
src/io-xml/{nact-xml-reader.c => naxml-reader.c} | 1118 +++++++++++++++++-----
src/io-xml/naxml-reader.h | 76 ++
src/nact/Makefile.am | 1 +
src/nact/nact-assistant-import.c | 31 +-
src/nact/nact-import-ask.c | 17 +-
src/nact/nact-iprefs.c | 11 +-
src/nact/nact-preferences-editor.c | 18 +-
src/nact/nact-tree-model-dnd.c | 10 +-
src/plugin-menu/Makefile.am | 1 +
src/plugin-tracker/Makefile.am | 1 +
src/test/.gitignore | 1 +
src/test/Makefile.am | 11 +
src/test/test-reader.c | 51 +
src/utils/Makefile.am | 1 +
50 files changed, 1632 insertions(+), 522 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f538e85..93e11fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,53 @@
+2009-02-20 Pierre Wieser <pwieser trychlos org>
+
+ * po/POTFILES.in:
+ * src/api/na-idata-factory-str.h:
+ * src/api/na-idata-factory.h:
+ * src/api/na-iimporter.h:
+ * src/api/na-iio-factory.h:
+ * src/api/na-object-api.h:
+ * src/core/Makefile.am:
+ * src/core/na-data-factory.c:
+ * src/core/na-data-factory.h:
+ * src/core/na-idata-factory.c:
+ * src/core/na-iio-factory.c:
+ * src/core/na-importer.c:
+ * src/core/na-importer.h:
+ * src/core/na-io-factory.c:
+ * src/core/na-io-factory.h:
+ * src/core/na-iprefs.h:
+ * src/core/na-module.c:
+ * src/core/na-object-action-enum.c:
+ * src/core/na-object-action.c:
+ * src/core/na-object-id-enum.c:
+ * src/core/na-object-item-enum.c:
+ * src/core/na-object-item.c:
+ * src/core/na-object-menu-enum.c:
+ * src/core/na-object-menu.c:
+ * src/core/na-object-profile-enum.c:
+ * src/core/na-object-profile.c:
+ * src/core/na-pivot.c:
+ * src/io-desktop/Makefile.am:
+ * src/io-gconf/Makefile.am:
+ * src/io-xml/Makefile.am:
+ * src/io-xml/naxml-keys.c:
+ * src/io-xml/naxml-keys.h:
+ * src/io-xml/naxml-provider.c:
+ * src/io-xml/naxml-provider.h:
+ * src/io-xml/naxml-reader.c:
+ * src/io-xml/naxml-reader.h:
+ * src/nact/Makefile.am:
+ * src/nact/nact-assistant-import.c:
+ * src/nact/nact-import-ask.c:
+ * src/nact/nact-iprefs.c:
+ * src/nact/nact-preferences-editor.c:
+ * src/nact/nact-tree-model-dnd.c:
+ * src/plugin-menu/Makefile.am:
+ * src/plugin-tracker/Makefile.am:
+ * src/test/.gitignore:
+ * src/test/Makefile.am:
+ * src/utils/Makefile.am: Implement NAXMLReader.
+
2009-02-18 Pierre Wieser <pwieser trychlos org>
* src/api/na-core-utils.h:
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0a8febe..3e02dfb 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,8 +7,8 @@ src/core/na-object-menu.c
src/core/na-object-profile.c
src/io-desktop/nadp-desktop-provider.c
src/io-gconf/nagp-gconf-provider.c
-src/io-xml/nact-xml-reader.c
-src/io-xml/na-xml-names.h
+src/io-xml/naxml-keys.h
+src/io-xml/naxml-reader.c
src/io-xml/naxml-provider.c
src/nact/base-application.c
src/nact/base-assistant.c
diff --git a/src/api/na-idata-factory-str.h b/src/api/na-idata-factory-str.h
index c341508..0d8670b 100644
--- a/src/api/na-idata-factory-str.h
+++ b/src/api/na-idata-factory-str.h
@@ -71,43 +71,56 @@ enum {
NADF_TYPE_UINT, /* an unsigned integer */
};
+/* attach here a xml document root with the corresponding node for the data
+ */
+typedef struct {
+ gchar *doc_id;
+ gchar *key;
+}
+ NadfDocKey;
+
/**
* The structure which fully describe an elementary data
* Each #NAIDataFactory item definition may include several groups of
* this structure
*/
typedef struct {
- guint id; /* the id of the object data item
+ guint id; /* the id of the object data item
* must only be unique inside of the given group */
- gchar *name; /* canonical name, used when getting/setting properties */
+ gchar *name; /* canonical name, used when getting/setting properties */
- gboolean serializable; /* whether the data is serializable
+ gboolean serializable; /* whether the data is serializable
* if FALSE, then no attempt will be made to read/write it
* and the data will must be set dynamically */
- gchar *short_label; /* short descriptive name, used in GParamSpec */
+ gchar *short_label; /* short descriptive name, used in GParamSpec */
- gchar *long_label; /* long, if not complete, description, used in GParamSpec */
+ gchar *long_label; /* long, if not complete, description, used in GParamSpec */
- guint type; /* the elementary NADF_TYPE_xxx data type */
+ guint type; /* the elementary NADF_TYPE_xxx data type */
- gchar *default_value; /* the default to assign when creating a new object
+ gchar *default_value; /* the default to assign when creating a new object
* this default is also displayed in command-line help
* of nautilus-actions-new utility */
- gboolean copyable; /* whether this data should be automatically copied when
+ gboolean copyable; /* whether this data should be automatically copied when
* we are duplicating an object to another
* in all cases, the implementation is always triggered
* by the copy() interface method */
- gboolean comparable; /* whether this data should be compared when we
+ gboolean comparable; /* whether this data should be compared when we
* are testing two objects for equality */
- gboolean mandatory; /* whether this data must be not null and not empty
+ gboolean mandatory; /* whether this data must be not null and not empty
* when we are testing for validity of an object */
- void ( *free )( void * ); /* a pointer to a function to free the element data
+ gboolean localizable; /* whether this is a localizable data
+ * when serializing or exporting */
+
+ gchar *gconf_entry; /* same entry is also used for GConf-based XML docs */
+
+ void ( *free )( void * ); /* a pointer to a function to free the element data
* a default function is provided for main elementary
* data types:
* - STRING and LOCALE_STRING: g_free
diff --git a/src/api/na-idata-factory.h b/src/api/na-idata-factory.h
index 54a2bdf..f8df432 100644
--- a/src/api/na-idata-factory.h
+++ b/src/api/na-idata-factory.h
@@ -175,11 +175,12 @@ typedef struct {
}
NAIDataFactoryInterface;
-GType na_idata_factory_get_type( void );
+GType na_idata_factory_get_type( void );
-void *na_idata_factory_get( const NAIDataFactory *object, guint data_id );
+void *na_idata_factory_get( const NAIDataFactory *object, guint data_id );
-void na_idata_factory_set( NAIDataFactory *object, guint data_id, const void *data );
+void na_idata_factory_set_from_string( NAIDataFactory *object, guint data_id, const gchar *data );
+void na_idata_factory_set_from_void ( NAIDataFactory *object, guint data_id, const void *data );
G_END_DECLS
diff --git a/src/api/na-iimporter.h b/src/api/na-iimporter.h
index e89de26..f9193b9 100644
--- a/src/api/na-iimporter.h
+++ b/src/api/na-iimporter.h
@@ -54,6 +54,8 @@ typedef struct NAIImporter NAIImporter;
typedef struct NAIImporterInterfacePrivate NAIImporterInterfacePrivate;
+typedef gboolean ( *ImporterCheckFn )( const gchar *, void *fn_data );
+
typedef struct {
GTypeInterface parent;
NAIImporterInterfacePrivate *private;
@@ -67,9 +69,36 @@ typedef struct {
* Defaults to 1.
*/
guint ( *get_version )( const NAIImporter *instance );
+
+ /**
+ * import_uri:
+ * @instance: the #NAIImporter provider.
+ * @uri: the URI of the file to be imported.
+ * @mode: import mode.
+ * @fn: a pointer to the function to be used to check for existancy of
+ * imported id.
+ * @fn_data: data to be passed to @fn.
+ * @messages: a pointer to a #GSList list of strings; the provider
+ * may append messages to this list, but shouldn't reinitialize it.
+ *
+ * Imports an item.
+ *
+ * Returns: a #NAObjectItem-derived object, or %NULL if an error has
+ * been detected.
+ */
+ NAObjectItem * ( *import_uri ) ( const NAIImporter *instance, const gchar *uri, guint mode, ImporterCheckFn fn, void *fn_data, GSList **messages );
}
NAIImporterInterface;
+/* import mode
+ */
+enum {
+ IMPORTER_MODE_NO_IMPORT = 1, /* this is a "do not import anything" mode */
+ IMPORTER_MODE_RENUMBER,
+ IMPORTER_MODE_OVERRIDE,
+ IMPORTER_MODE_ASK
+};
+
GType na_iimporter_get_type( void );
G_END_DECLS
diff --git a/src/api/na-iio-factory.h b/src/api/na-iio-factory.h
index 861c504..364fc95 100644
--- a/src/api/na-iio-factory.h
+++ b/src/api/na-iio-factory.h
@@ -162,6 +162,8 @@ GType na_iio_factory_get_type( void );
NAIDataFactory *na_iio_factory_read_item ( const NAIIOFactory *reader, void *reader_data, GType type, GSList **messages );
void na_iio_factory_write_item( const NAIIOFactory *writer, void *writer_data, NAIDataFactory *serializable, GSList **messages );
+NadfIdType *na_iio_factory_get_idtype_from_gconf_key( const gchar *xml_entry );
+
G_END_DECLS
#endif /* __NAUTILUS_ACTIONS_API_NA_IIO_FACTORY_H__ */
diff --git a/src/api/na-object-api.h b/src/api/na-object-api.h
index 28c9dbf..0fd6d63 100644
--- a/src/api/na-object-api.h
+++ b/src/api/na-object-api.h
@@ -81,9 +81,9 @@ G_BEGIN_DECLS
#define na_object_get_label( obj ) (( gchar * ) na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_LABEL ))
#define na_object_get_parent( obj ) (( NAObjectItem * ) na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_PARENT ))
-#define na_object_set_id( obj, id ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_ID, ( const void * )( id ))
-#define na_object_set_label( obj, label ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_LABEL, ( const void * )( label ))
-#define na_object_set_parent( obj, parent ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_PARENT, ( const void * )( parent ))
+#define na_object_set_id( obj, id ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_ID, ( const void * )( id ))
+#define na_object_set_label( obj, label ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_LABEL, ( const void * )( label ))
+#define na_object_set_parent( obj, parent ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_PARENT, ( const void * )( parent ))
#define na_object_sort_alpha_asc( a, b ) na_object_id_sort_alpha_asc( NA_OBJECT_ID( a ), NA_OBJECT_ID( b ))
#define na_object_sort_alpha_desc( a, b ) na_object_id_sort_alpha_desc( NA_OBJECT_ID( a ), NA_OBJECT_ID( b ))
@@ -104,14 +104,14 @@ G_BEGIN_DECLS
#define na_object_get_provider( obj ) na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_PROVIDER )
#define na_object_get_provider_data( obj ) na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_PROVIDER_DATA )
-#define na_object_set_tooltip( obj, tooltip ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLTIP, ( const void * )( tooltip ))
-#define na_object_set_icon( obj, icon ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_ICON, ( const void * )( icon ))
-#define na_object_set_items( obj, list ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_SUBITEMS, ( const void * )( list ))
-#define na_object_set_items_slist( obj, slist ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_SUBITEMS_SLIST, ( const void * )( slist ))
-#define na_object_set_enabled( obj, enabled ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_ENABLED, ( const void * ) GUINT_TO_POINTER( enabled ))
-#define na_object_set_readonly( obj, readonly ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_READONLY, ( const void * ) GUINT_TO_POINTER( readonly ))
-#define na_object_set_provider( obj, provider ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_PROVIDER, ( const void * )( provider ))
-#define na_object_set_provider_data( obj, data ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_PROVIDER_DATA, ( const void * )( data ))
+#define na_object_set_tooltip( obj, tooltip ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLTIP, ( const void * )( tooltip ))
+#define na_object_set_icon( obj, icon ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_ICON, ( const void * )( icon ))
+#define na_object_set_items( obj, list ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_SUBITEMS, ( const void * )( list ))
+#define na_object_set_items_slist( obj, slist ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_SUBITEMS_SLIST, ( const void * )( slist ))
+#define na_object_set_enabled( obj, enabled ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_ENABLED, ( const void * ) GUINT_TO_POINTER( enabled ))
+#define na_object_set_readonly( obj, readonly ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_READONLY, ( const void * ) GUINT_TO_POINTER( readonly ))
+#define na_object_set_provider( obj, provider ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_PROVIDER, ( const void * )( provider ))
+#define na_object_set_provider_data( obj, data ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_PROVIDER_DATA, ( const void * )( data ))
#define na_object_get_item( obj, id ) na_object_item_get_item( NA_OBJECT_ITEM( obj ),( const gchar * )( id ))
#define na_object_get_position( obj, child ) na_object_item_get_position( NA_OBJECT_ITEM( obj ), NA_OBJECT_ID( child ))
@@ -135,15 +135,15 @@ G_BEGIN_DECLS
#define na_object_is_toolbar_same_label( obj ) (( gboolean ) GPOINTER_TO_UINT( na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLBAR_SAME_LABEL )))
#define na_object_get_last_allocated( obj ) (( guint ) GPOINTER_TO_UINT( na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_LAST_ALLOCATED )))
-#define na_object_set_version( obj, version ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_VERSION, ( const void * )( version ))
-#define na_object_set_target_selection( obj, target ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_TARGET_SELECTION, ( const void * ) GUINT_TO_POINTER( target ))
-#define na_object_set_target_background( obj, target ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_TARGET_BACKGROUND, ( const void * ) GUINT_TO_POINTER( target ))
-#define na_object_set_target_toolbar( obj, target ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_TARGET_TOOLBAR, ( const void * ) GUINT_TO_POINTER( target ))
-#define na_object_set_toolbar_label( obj, label ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLBAR_LABEL, ( const void * )( label ))
-#define na_object_set_toolbar_same_label( obj, same ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLBAR_SAME_LABEL, ( const void * ) GUINT_TO_POINTER( same ))
-#define na_object_set_last_allocated( obj, last ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_LAST_ALLOCATED, ( const void * ) GUINT_TO_POINTER( last ))
+#define na_object_set_version( obj, version ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_VERSION, ( const void * )( version ))
+#define na_object_set_target_selection( obj, target ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_TARGET_SELECTION, ( const void * ) GUINT_TO_POINTER( target ))
+#define na_object_set_target_background( obj, target ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_TARGET_BACKGROUND, ( const void * ) GUINT_TO_POINTER( target ))
+#define na_object_set_target_toolbar( obj, target ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_TARGET_TOOLBAR, ( const void * ) GUINT_TO_POINTER( target ))
+#define na_object_set_toolbar_label( obj, label ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLBAR_LABEL, ( const void * )( label ))
+#define na_object_set_toolbar_same_label( obj, same ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLBAR_SAME_LABEL, ( const void * ) GUINT_TO_POINTER( same ))
+#define na_object_set_last_allocated( obj, last ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_LAST_ALLOCATED, ( const void * ) GUINT_TO_POINTER( last ))
-#define na_object_reset_last_allocated( obj ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_LAST_ALLOCATED, ( const void * ) GUINT_TO_POINTER( 0 ))
+#define na_object_reset_last_allocated( obj ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_LAST_ALLOCATED, ( const void * ) GUINT_TO_POINTER( 0 ))
#define na_object_attach_profile( obj, profile ) na_object_action_attach_profile( NA_OBJECT_ACTION( obj ), NA_OBJECT_PROFILE( profile ))
/* NAObjectProfile
@@ -159,16 +159,16 @@ G_BEGIN_DECLS
#define na_object_get_schemes( obj ) (( GSList * ) na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_SCHEMES ))
#define na_object_get_folders( obj ) (( GSList * ) na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_FOLDERS ))
-#define na_object_set_path( obj, path ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_PATH, ( const void * )( path ))
-#define na_object_set_parameters( obj, parms ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_PARAMETERS, ( const void * )( parms ))
-#define na_object_set_basenames( obj, bnames ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_BASENAMES, ( const void * )( bnames ))
-#define na_object_set_matchcase( obj, match ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_MATCHCASE, ( const void * ) GUINT_TO_POINTER( match ))
-#define na_object_set_mimetypes( obj, types ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_MIMETYPES, ( const void * )( types ))
-#define na_object_set_isfile( obj, isfile ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_ISFILE, ( const void * ) GUINT_TO_POINTER( isfile ))
-#define na_object_set_isdir( obj, isdir ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_ISDIR, ( const void * ) GUINT_TO_POINTER( isdir ))
-#define na_object_set_multiple( obj, multiple ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_MULTIPLE, ( const void * ) GUINT_TO_POINTER( multiple ))
-#define na_object_set_schemes( obj, schemes ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_SCHEMES, ( const void * )( schemes ))
-#define na_object_set_folders( obj, folders ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_FOLDERS, ( const void * )( folders ))
+#define na_object_set_path( obj, path ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_PATH, ( const void * )( path ))
+#define na_object_set_parameters( obj, parms ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_PARAMETERS, ( const void * )( parms ))
+#define na_object_set_basenames( obj, bnames ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_BASENAMES, ( const void * )( bnames ))
+#define na_object_set_matchcase( obj, match ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_MATCHCASE, ( const void * ) GUINT_TO_POINTER( match ))
+#define na_object_set_mimetypes( obj, types ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_MIMETYPES, ( const void * )( types ))
+#define na_object_set_isfile( obj, isfile ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_ISFILE, ( const void * ) GUINT_TO_POINTER( isfile ))
+#define na_object_set_isdir( obj, isdir ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_ISDIR, ( const void * ) GUINT_TO_POINTER( isdir ))
+#define na_object_set_multiple( obj, multiple ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_MULTIPLE, ( const void * ) GUINT_TO_POINTER( multiple ))
+#define na_object_set_schemes( obj, schemes ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_SCHEMES, ( const void * )( schemes ))
+#define na_object_set_folders( obj, folders ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_FOLDERS, ( const void * )( folders ))
#define na_object_set_scheme( obj, scheme, add ) na_object_profile_set_scheme( NA_OBJECT_PROFILE( obj ), ( const gchar * )( scheme ), ( add ))
#define na_object_replace_folder( obj, old, new ) na_object_profile_replace_folder( NA_OBJECT_PROFILE( obj ), ( const gchar * )( old ), ( const gchar * )( new ))
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index db26ed7..b60fc7c 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -30,6 +30,7 @@ pkglib_LTLIBRARIES = libna-core.la
AM_CPPFLAGS += \
-I $(top_srcdir) \
+ -I $(top_srcdir)/src \
-DPKGLIBDIR=\""$(pkglibdir)"\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_CORE}\" \
@@ -58,6 +59,7 @@ libna_core_la_SOURCES = \
na-iexporter.c \
na-iimporter.c \
na-iio-factory.c \
+ na-iio-factory-priv.h \
na-iio-provider.c \
na-io-factory.c \
na-io-factory.h \
diff --git a/src/core/na-data-factory.c b/src/core/na-data-factory.c
index a9f4316..16b4e54 100644
--- a/src/core/na-data-factory.c
+++ b/src/core/na-data-factory.c
@@ -659,27 +659,24 @@ v_write_done( NAIDataFactory *serializable, const NAIIOFactory *writer, void *wr
}
/**
- * na_data_factory_set:
+ * na_data_factory_set_from_string:
* @object: this #NAIDataFactory instance.
- * @data_id: the elementary data whose value is to be set.
- * @data: the value to set.
+ * @property_id: the elementary data id.
+ * @string: the string to be set in the element.
*
- * Set the elementary data with the given value.
+ * Set the @object with the @string.
*/
void
-na_data_factory_set( NAIDataFactory *object, guint data_id, const void *data )
+na_data_factory_set_from_string( NAIDataFactory *object, guint data_id, const gchar *string )
{
- static const gchar *thisfn = "na_data_factory_set";
+ static const gchar *thisfn = "na_data_factory_set_from_string";
NADataElement *element;
- /*g_debug( "%s: object=%p (%s), data_id=%d, data=%p",
- thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ), data_id, ( void * ) data );*/
-
g_return_if_fail( NA_IS_IDATA_FACTORY( object ));
element = data_element_from_id( object, data_id );
if( element ){
- na_data_element_set_from_void( element, data );
+ na_data_element_set_from_string( element, string );
} else {
g_warning( "%s: unknown property id %d", thisfn, data_id );
@@ -687,11 +684,10 @@ na_data_factory_set( NAIDataFactory *object, guint data_id, const void *data )
}
/**
- * na_data_factory_get_value:
+ * na_data_factory_set_from_value:
* @object: this #NAIDataFactory instance.
* @property_id: the elementary data id.
* @value: the #GValue whose content is to be got.
- * @spec: the #GParamSpec which describes this data.
*
* Get from the @value the content to be set in the #NADataElement
* attached to @property_id.
@@ -699,19 +695,47 @@ na_data_factory_set( NAIDataFactory *object, guint data_id, const void *data )
* This is to be readen as "set data element from value".
*/
void
-na_data_factory_get_value( NAIDataFactory *object, guint property_id, const GValue *value, GParamSpec *spec )
+na_data_factory_set_from_value( NAIDataFactory *object, guint data_id, const GValue *value )
{
- static const gchar *thisfn = "na_data_factory_get_value";
+ static const gchar *thisfn = "na_data_factory_set_from_value";
NADataElement *element;
g_return_if_fail( NA_IS_IDATA_FACTORY( object ));
- element = data_element_from_id( object, property_id );
+ element = data_element_from_id( object, data_id );
if( element ){
na_data_element_set_from_value( element, value );
} else {
- g_warning( "%s: unknown property id %d", thisfn, property_id );
+ g_warning( "%s: unknown property id %d", thisfn, data_id );
+ }
+}
+
+/**
+ * na_data_factory_set_from_void:
+ * @object: this #NAIDataFactory instance.
+ * @data_id: the elementary data whose value is to be set.
+ * @data: the value to set.
+ *
+ * Set the elementary data with the given value.
+ */
+void
+na_data_factory_set_from_void( NAIDataFactory *object, guint data_id, const void *data )
+{
+ static const gchar *thisfn = "na_data_factory_set_from_void";
+ NADataElement *element;
+
+ /*g_debug( "%s: object=%p (%s), data_id=%d, data=%p",
+ thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ), data_id, ( void * ) data );*/
+
+ g_return_if_fail( NA_IS_IDATA_FACTORY( object ));
+
+ element = data_element_from_id( object, data_id );
+ if( element ){
+ na_data_element_set_from_void( element, data );
+
+ } else {
+ g_warning( "%s: unknown property id %d", thisfn, data_id );
}
}
diff --git a/src/core/na-data-factory.h b/src/core/na-data-factory.h
index 6f4cfe6..6723098 100644
--- a/src/core/na-data-factory.h
+++ b/src/core/na-data-factory.h
@@ -54,8 +54,10 @@ void na_data_factory_finalize ( NAIDataFactory *object );
void na_data_factory_read ( NAIDataFactory *object, const NAIIOFactory *reader, void *reader_data, GSList **messages );
void na_data_factory_write ( NAIDataFactory *object, const NAIIOFactory *writer, void *writer_data, GSList **messages );
-void na_data_factory_set ( NAIDataFactory *object, guint data_id, const void *data );
-void na_data_factory_get_value ( NAIDataFactory *object, guint property_id, const GValue *value, GParamSpec *spec );
+void na_data_factory_set_from_string( NAIDataFactory *object, guint data_id, const gchar *data );
+void na_data_factory_set_from_value ( NAIDataFactory *object, guint data_id, const GValue *value );
+void na_data_factory_set_from_void ( NAIDataFactory *object, guint data_id, const void *data );
+
void *na_data_factory_get ( const NAIDataFactory *object, guint data_id );
void na_data_factory_set_value ( const NAIDataFactory *object, guint property_id, GValue *value, GParamSpec *spec );
diff --git a/src/core/na-idata-factory.c b/src/core/na-idata-factory.c
index 79b3685..0ffda7e 100644
--- a/src/core/na-idata-factory.c
+++ b/src/core/na-idata-factory.c
@@ -160,7 +160,7 @@ na_idata_factory_get( const NAIDataFactory *object, guint data_id )
}
/**
- * na_idata_factory_set:
+ * na_idata_factory_set_from_string:
* @object: this #NAIDataFactory instance.
* @data_id: the elementary data whose value is to be set.
* @data: the value to set.
@@ -168,9 +168,25 @@ na_idata_factory_get( const NAIDataFactory *object, guint data_id )
* Set the elementary data with the given value.
*/
void
-na_idata_factory_set( NAIDataFactory *object, guint data_id, const void *data )
+na_idata_factory_set_from_string( NAIDataFactory *object, guint data_id, const gchar *data )
{
g_return_if_fail( NA_IS_IDATA_FACTORY( object ));
- na_data_factory_set( object, data_id, data );
+ na_data_factory_set_from_string( object, data_id, data );
+}
+
+/**
+ * na_idata_factory_set_from_void:
+ * @object: this #NAIDataFactory instance.
+ * @data_id: the elementary data whose value is to be set.
+ * @data: the value to set.
+ *
+ * Set the elementary data with the given value.
+ */
+void
+na_idata_factory_set_from_void( NAIDataFactory *object, guint data_id, const void *data )
+{
+ g_return_if_fail( NA_IS_IDATA_FACTORY( object ));
+
+ na_data_factory_set_from_void( object, data_id, data );
}
diff --git a/src/core/na-iio-factory.c b/src/core/na-iio-factory.c
index 8589b51..d87e501 100644
--- a/src/core/na-iio-factory.c
+++ b/src/core/na-iio-factory.c
@@ -210,6 +210,19 @@ na_iio_factory_write_item( const NAIIOFactory *writer, void *writer_data, NAIDat
}
}
+/**
+ * na_iio_factory_get_idtype_from_gconf_key:
+ * @entry: the name of the node we are searching for.
+ *
+ * Returns: the definition of the data which is exported as @entry in GConf,
+ * or %NULL if not found.
+ */
+NadfIdType *
+na_iio_factory_get_idtype_from_gconf_key( const gchar *entry )
+{
+ return( na_io_factory_get_idtype_from_gconf_key( entry ));
+}
+
static void
v_io_factory_read_start( const NAIIOFactory *reader, void *reader_data, NAIDataFactory *serializable, GSList **messages )
{
diff --git a/src/core/na-importer.c b/src/core/na-importer.c
index 22eba74..3c50dc5 100644
--- a/src/core/na-importer.c
+++ b/src/core/na-importer.c
@@ -39,27 +39,39 @@ extern gboolean iimporter_finalized; /* defined in na-iimporter.c */
/**
* na_importer_import:
- * @items: a #GList of already loaded items.
+ * @pivot: the #NAPivot pivot for this application.
* @uri: the source filename URI.
* @mode: the import mode.
+ * @fn: a function to check the existance of the imported item.
+ * @fn_data: function data
* @messages: a pointer to a #GSList list of strings; the provider
* may append messages to this list, but shouldn't reinitialize it.
*
- * Exports the specified @item to the target @uri in the required
- * @format.
- *
* Returns: a newly allocated #NAObjectItem-derived object, or %NULL
* if an error has been detected.
*/
NAObjectItem *
-na_importer_import( GList *items, const gchar *uri, guint mode, GSList **messages )
+na_importer_import( const NAPivot *pivot, const gchar *uri, guint mode, ImporterCheckFn fn, void *fn_data, GSList **messages )
{
+ static const gchar *thisfn = "na_importer_import";
NAObjectItem *item;
+ GList *modules;
+
+ g_debug( "%s: pivot=%p, uri=%s, mode=%d, fn=%p, fn_data=%p, messages=%p",
+ thisfn, ( void * ) pivot, uri, mode, ( void * ) fn, ( void * ) fn_data, ( void * ) messages );
item = NULL;
if( iimporter_initialized && !iimporter_finalized ){
+ modules = na_pivot_get_providers( pivot, NA_IIMPORTER_TYPE );
+ g_debug( "na_importer_import: modules_count=%d", g_list_length( modules ));
+ if( g_list_length( modules )){
+ if( NA_IIMPORTER_GET_INTERFACE( NA_IIMPORTER( modules->data ))->import_uri ){
+ item = NA_IIMPORTER_GET_INTERFACE( NA_IIMPORTER( modules->data ))->import_uri( NA_IIMPORTER( modules->data ), uri, mode, fn, fn_data, messages );
+ }
+ }
+ na_pivot_free_providers( modules );
}
return( item );
diff --git a/src/core/na-importer.h b/src/core/na-importer.h
index 0e37a61..1ae1284 100644
--- a/src/core/na-importer.h
+++ b/src/core/na-importer.h
@@ -38,10 +38,13 @@
*/
#include <api/na-object-item.h>
+#include <api/na-iimporter.h>
+
+#include <core/na-pivot.h>
G_BEGIN_DECLS
-NAObjectItem *na_importer_import( GList *items, const gchar *uri, guint mode, GSList **messages );
+NAObjectItem *na_importer_import( const NAPivot *pivot, const gchar *uri, guint mode, ImporterCheckFn fn, void *fn_data, GSList **messages );
G_END_DECLS
diff --git a/src/core/na-io-factory.c b/src/core/na-io-factory.c
index fb83b60..17d6f91 100644
--- a/src/core/na-io-factory.c
+++ b/src/core/na-io-factory.c
@@ -32,6 +32,8 @@
#include <config.h>
#endif
+#include <string.h>
+
#include "na-iio-factory-priv.h"
#include "na-io-factory.h"
@@ -57,7 +59,8 @@ na_io_factory_register( GType type, const NadfIdGroup *groups )
if( iio_factory_initialized && !iio_factory_finalized ){
- g_debug( "%s: type=%lu, groups=%p", thisfn, ( unsigned long ) type, ( void * ) groups );
+ g_debug( "%s: type=%lu, groups=%p",
+ thisfn, ( unsigned long ) type, ( void * ) groups );
g_return_if_fail( groups != NULL );
@@ -102,6 +105,62 @@ na_io_factory_get_groups( GType type )
}
/**
+ * na_io_factory_get_idtype_from_gconf_key:
+ * @entry: the name of the GConf entry we are searching for.
+ *
+ * Returns: the definition of the data which is exported as @entry in GConf,
+ * or %NULL if not found.
+ */
+NadfIdType *
+na_io_factory_get_idtype_from_gconf_key( const gchar *entry )
+{
+ static const gboolean debug = FALSE;
+ GList *imp;
+
+ if( iio_factory_initialized && !iio_factory_finalized ){
+
+ if( debug ){
+ g_debug( "na_io_factory_get_idtype_from_gconf_key: entry=%s", entry );
+ }
+
+ for( imp = iio_factory_klass->private->registered ; imp ; imp = imp->next ){
+
+ NadfImplement *implement = ( NadfImplement * ) imp->data;
+ if( debug ){
+ g_debug( "implement=%p, type=%lu, groups=%p",
+ ( void * ) implement, ( gulong ) implement->type, ( void * ) implement->groups );
+ }
+
+ NadfIdGroup *group = implement->groups;
+ while( group->idgroup ){
+ if( debug ){
+ g_debug( "group=%p, idgroup=%d, iddefs=%p", ( void * ) group, group->idgroup, ( void * ) group->iddef );
+ }
+
+ NadfIdType *iddef = group->iddef;
+ if( iddef ){
+ while( iddef->id ){
+ if( debug ){
+ g_debug( "iddef=%p, id=%d, gconf_entry=%s", ( void * ) iddef, iddef->id, iddef->gconf_entry );
+ }
+
+ if( iddef->gconf_entry && !strcmp( iddef->gconf_entry, entry )){
+ return( iddef );
+ }
+
+ iddef++;
+ }
+ }
+
+ group++;
+ }
+ }
+ }
+
+ return( NULL );
+}
+
+/**
* na_io_factory_read_value:
* @reader: the instance which implements this #NAIIOFactory interface.
* @reader_data: instance data.
diff --git a/src/core/na-io-factory.h b/src/core/na-io-factory.h
index 0f84e0e..1b5a481 100644
--- a/src/core/na-io-factory.h
+++ b/src/core/na-io-factory.h
@@ -43,6 +43,7 @@ G_BEGIN_DECLS
void na_io_factory_register ( GType type, const NadfIdGroup *groups );
NadfIdGroup *na_io_factory_get_groups( GType type );
+NadfIdType *na_io_factory_get_idtype_from_gconf_key( const gchar *entry );
GValue *na_io_factory_read_value( const NAIIOFactory *reader, void *reader_data, const NadfIdType *iddef, GSList **messages );
diff --git a/src/core/na-iprefs.h b/src/core/na-iprefs.h
index 2dc1adc..9cb1fdc 100644
--- a/src/core/na-iprefs.h
+++ b/src/core/na-iprefs.h
@@ -110,15 +110,6 @@ enum {
IPREFS_ORDER_MANUAL
};
-/* import mode
- */
-enum {
- IPREFS_IMPORT_NO_IMPORT = 1,
- IPREFS_IMPORT_RENUMBER,
- IPREFS_IMPORT_OVERRIDE,
- IPREFS_IMPORT_ASK
-};
-
GType na_iprefs_get_type( void );
gint na_iprefs_get_order_mode( NAIPrefs *instance );
diff --git a/src/core/na-module.c b/src/core/na-module.c
index 41ef6b5..03c8faf 100644
--- a/src/core/na-module.c
+++ b/src/core/na-module.c
@@ -463,9 +463,7 @@ na_module_get_extensions_for_type( GList *modules, GType type )
}
}
- willing_to = g_list_reverse( willing_to );
-
- return( willing_to );
+ return( g_list_reverse( willing_to ));
}
/**
diff --git a/src/core/na-object-action-enum.c b/src/core/na-object-action-enum.c
index b657961..097af2d 100644
--- a/src/core/na-object-action-enum.c
+++ b/src/core/na-object-action-enum.c
@@ -50,6 +50,8 @@ static NadfIdType action_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "version",
NULL },
{ NADF_DATA_TARGET_SELECTION,
@@ -62,6 +64,8 @@ static NadfIdType action_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "target-selection",
NULL },
{ NADF_DATA_TARGET_BACKGROUND,
@@ -74,6 +78,8 @@ static NadfIdType action_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "target-background",
NULL },
{ NADF_DATA_TARGET_TOOLBAR,
@@ -88,6 +94,8 @@ static NadfIdType action_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "target-toolbar",
NULL },
{ NADF_DATA_TOOLBAR_LABEL,
@@ -101,6 +109,8 @@ static NadfIdType action_iddef [] = {
TRUE,
TRUE,
FALSE,
+ TRUE,
+ "toolbar-label",
NULL },
{ NADF_DATA_TOOLBAR_SAME_LABEL,
@@ -113,6 +123,8 @@ static NadfIdType action_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "toolbar-same-label",
NULL },
{ NADF_DATA_LAST_ALLOCATED,
@@ -126,9 +138,11 @@ static NadfIdType action_iddef [] = {
TRUE,
FALSE,
FALSE,
+ FALSE,
+ NULL,
NULL },
- { 0, NULL, FALSE, NULL, NULL, 0, NULL, FALSE, FALSE, FALSE, NULL },
+ { 0 },
};
NadfIdGroup action_id_groups [] = {
@@ -136,5 +150,5 @@ NadfIdGroup action_id_groups [] = {
{ NA_DATA_FACTORY_ITEM_GROUP, item_iddef },
{ NA_DATA_FACTORY_ACTION_GROUP, action_iddef },
{ NA_DATA_FACTORY_CONDITIONS_GROUP, NULL },
- { 0, NULL }
+ { 0 }
};
diff --git a/src/core/na-object-action.c b/src/core/na-object-action.c
index b4a2fa6..34551e1 100644
--- a/src/core/na-object-action.c
+++ b/src/core/na-object-action.c
@@ -195,7 +195,7 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
if( !NA_OBJECT_ACTION( object )->private->dispose_has_run ){
- na_data_factory_get_value( NA_IDATA_FACTORY( object ), property_id, value, spec );
+ na_data_factory_set_from_value( NA_IDATA_FACTORY( object ), property_id, value );
}
}
diff --git a/src/core/na-object-id-enum.c b/src/core/na-object-id-enum.c
index 4641581..70f7ce7 100644
--- a/src/core/na-object-id-enum.c
+++ b/src/core/na-object-id-enum.c
@@ -49,6 +49,8 @@ NadfIdType id_iddef [] = {
TRUE,
TRUE,
TRUE,
+ FALSE,
+ NULL,
NULL },
{ NADF_DATA_LABEL,
@@ -62,6 +64,8 @@ NadfIdType id_iddef [] = {
TRUE,
TRUE,
FALSE,
+ TRUE,
+ "label",
NULL },
{ NADF_DATA_PARENT,
@@ -74,7 +78,9 @@ NadfIdType id_iddef [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
+ NULL,
NULL },
- { 0, NULL, FALSE, NULL, NULL, 0, NULL, FALSE, FALSE },
+ { 0 },
};
diff --git a/src/core/na-object-item-enum.c b/src/core/na-object-item-enum.c
index 6b092c6..c455091 100644
--- a/src/core/na-object-item-enum.c
+++ b/src/core/na-object-item-enum.c
@@ -49,6 +49,8 @@ NadfIdType item_iddef [] = {
TRUE,
TRUE,
FALSE,
+ TRUE,
+ "tooltip",
NULL },
{ NADF_DATA_ICON,
@@ -62,6 +64,8 @@ NadfIdType item_iddef [] = {
TRUE,
TRUE,
FALSE,
+ TRUE,
+ "icon",
NULL },
{ NADF_DATA_DESCRIPTION,
@@ -75,6 +79,8 @@ NadfIdType item_iddef [] = {
TRUE,
TRUE,
FALSE,
+ TRUE,
+ "description",
NULL },
{ NADF_DATA_SUBITEMS,
@@ -87,6 +93,8 @@ NadfIdType item_iddef [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
+ NULL,
free_items_list },
{ NADF_DATA_SUBITEMS_SLIST,
@@ -100,6 +108,8 @@ NadfIdType item_iddef [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
+ "items",
NULL },
{ NADF_DATA_ENABLED,
@@ -114,6 +124,8 @@ NadfIdType item_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "enabled",
NULL },
{ NADF_DATA_READONLY,
@@ -131,6 +143,8 @@ NadfIdType item_iddef [] = {
TRUE,
FALSE,
FALSE,
+ FALSE,
+ NULL,
NULL },
{ NADF_DATA_PROVIDER,
@@ -143,6 +157,8 @@ NadfIdType item_iddef [] = {
TRUE,
FALSE,
FALSE,
+ FALSE,
+ NULL,
NULL },
{ NADF_DATA_PROVIDER_DATA,
@@ -155,9 +171,11 @@ NadfIdType item_iddef [] = {
TRUE,
FALSE,
FALSE,
+ FALSE,
+ NULL,
NULL },
- { 0, NULL, FALSE, NULL, NULL, 0, NULL, FALSE, FALSE, FALSE, NULL },
+ { 0 },
};
static void
diff --git a/src/core/na-object-item.c b/src/core/na-object-item.c
index 183e75c..0d20604 100644
--- a/src/core/na-object-item.c
+++ b/src/core/na-object-item.c
@@ -154,6 +154,7 @@ instance_dispose( GObject *object )
{
static const gchar *thisfn = "na_object_item_instance_dispose";
NAObjectItem *self;
+ GList *items, *it;
g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
@@ -165,6 +166,13 @@ instance_dispose( GObject *object )
self->private->dispose_has_run = TRUE;
+ items = na_object_get_items( self );
+ for( it = items ; it ; it = it->next ){
+ g_object_unref( it->data );
+ }
+ g_list_free( items );
+ na_object_set_items( self, NULL );
+
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
G_OBJECT_CLASS( st_parent_class )->dispose( object );
diff --git a/src/core/na-object-menu-enum.c b/src/core/na-object-menu-enum.c
index 17a4cab..8c9cdfe 100644
--- a/src/core/na-object-menu-enum.c
+++ b/src/core/na-object-menu-enum.c
@@ -39,8 +39,7 @@ extern NadfIdType id_iddef []; /* defined in na-object-id-enum.c */
extern NadfIdType item_iddef []; /* defined in na-object-item-enum.c */
static NadfIdType menu_iddef [] = {
-
- { 0, NULL, FALSE, NULL, NULL, 0, NULL, FALSE, FALSE, FALSE, NULL },
+ { 0 },
};
NadfIdGroup menu_id_groups [] = {
@@ -48,5 +47,5 @@ NadfIdGroup menu_id_groups [] = {
{ NA_DATA_FACTORY_ITEM_GROUP, item_iddef },
{ NA_DATA_FACTORY_MENU_GROUP, menu_iddef },
{ NA_DATA_FACTORY_CONDITIONS_GROUP, NULL },
- { 0, NULL }
+ { 0 }
};
diff --git a/src/core/na-object-menu.c b/src/core/na-object-menu.c
index 7a57ca4..59f2738 100644
--- a/src/core/na-object-menu.c
+++ b/src/core/na-object-menu.c
@@ -195,7 +195,7 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
if( !NA_OBJECT_MENU( object )->private->dispose_has_run ){
- na_data_factory_get_value( NA_IDATA_FACTORY( object ), property_id, value, spec );
+ na_data_factory_set_from_value( NA_IDATA_FACTORY( object ), property_id, value );
}
}
diff --git a/src/core/na-object-profile-enum.c b/src/core/na-object-profile-enum.c
index 8f9628f..0eba135 100644
--- a/src/core/na-object-profile-enum.c
+++ b/src/core/na-object-profile-enum.c
@@ -49,6 +49,8 @@ static NadfIdType profile_iddef [] = {
TRUE,
TRUE,
TRUE,
+ FALSE,
+ "path",
NULL },
{ NADF_DATA_PARAMETERS,
@@ -61,6 +63,8 @@ static NadfIdType profile_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "parameters",
NULL },
{ NADF_DATA_BASENAMES,
@@ -74,6 +78,8 @@ static NadfIdType profile_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "basenames",
NULL },
{ NADF_DATA_MATCHCASE,
@@ -87,6 +93,8 @@ static NadfIdType profile_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "matchcase",
NULL },
{ NADF_DATA_MIMETYPES,
@@ -100,6 +108,8 @@ static NadfIdType profile_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "mimetypes",
NULL },
{ NADF_DATA_ISFILE,
@@ -113,6 +123,8 @@ static NadfIdType profile_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "isfile",
NULL },
{ NADF_DATA_ISDIR,
@@ -126,6 +138,8 @@ static NadfIdType profile_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "isdir",
NULL },
{ NADF_DATA_MULTIPLE,
@@ -139,6 +153,8 @@ static NadfIdType profile_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "accept-multiple-files",
NULL },
{ NADF_DATA_SCHEMES,
@@ -152,6 +168,8 @@ static NadfIdType profile_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "schemes",
NULL },
{ NADF_DATA_FOLDERS,
@@ -165,14 +183,16 @@ static NadfIdType profile_iddef [] = {
TRUE,
TRUE,
FALSE,
+ FALSE,
+ "folders",
NULL },
- { 0, NULL, FALSE, NULL, NULL, 0, NULL, FALSE, FALSE, FALSE, NULL },
+ { 0 },
};
NadfIdGroup profile_id_groups [] = {
{ NA_DATA_FACTORY_ID_GROUP, id_iddef },
{ NA_DATA_FACTORY_PROFILE_GROUP, profile_iddef },
{ NA_DATA_FACTORY_CONDITIONS_GROUP, NULL },
- { 0, NULL }
+ { 0 }
};
diff --git a/src/core/na-object-profile.c b/src/core/na-object-profile.c
index 019ea80..fbf164a 100644
--- a/src/core/na-object-profile.c
+++ b/src/core/na-object-profile.c
@@ -228,7 +228,7 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
if( !NA_OBJECT_PROFILE( object )->private->dispose_has_run ){
- na_data_factory_get_value( NA_IDATA_FACTORY( object ), property_id, value, spec );
+ na_data_factory_set_from_value( NA_IDATA_FACTORY( object ), property_id, value );
}
}
diff --git a/src/core/na-pivot.c b/src/core/na-pivot.c
index aad33ba..ae3bc1f 100644
--- a/src/core/na-pivot.c
+++ b/src/core/na-pivot.c
@@ -240,6 +240,11 @@ instance_constructed( GObject *object )
monitor_runtime_preferences( self );
+ /* force class initialization and io-factory registration
+ */
+ g_object_unref( na_object_action_new_with_profile());
+ g_object_unref( na_object_menu_new());
+
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->constructed ){
G_OBJECT_CLASS( st_parent_class )->constructed( object );
@@ -434,7 +439,7 @@ na_pivot_get_providers( const NAPivot *pivot, GType type )
static const gchar *thisfn = "na_pivot_get_providers";
GList *list = NULL;
- g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
+ g_debug( "%s: pivot=%p, type=%lu (%s)", thisfn, ( void * ) pivot, ( unsigned long ) type, g_type_name( type ));
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NULL );
if( !pivot->private->dispose_has_run ){
diff --git a/src/io-desktop/Makefile.am b/src/io-desktop/Makefile.am
index 3390092..08d00c1 100644
--- a/src/io-desktop/Makefile.am
+++ b/src/io-desktop/Makefile.am
@@ -30,6 +30,7 @@ pkglib_LTLIBRARIES = libna-io-desktop.la
AM_CPPFLAGS += \
-I $(top_srcdir) \
+ -I $(top_srcdir)/src \
$(NAUTILUS_ACTIONS_CFLAGS) \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_IO_DESKTOP}\" \
$(NULL)
diff --git a/src/io-gconf/Makefile.am b/src/io-gconf/Makefile.am
index 45f11d5..40af993 100644
--- a/src/io-gconf/Makefile.am
+++ b/src/io-gconf/Makefile.am
@@ -30,6 +30,7 @@ pkglib_LTLIBRARIES = libna-io-gconf.la
AM_CPPFLAGS += \
-I $(top_srcdir) \
+ -I $(top_srcdir)/src \
$(NAUTILUS_ACTIONS_CFLAGS) \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_IO_GCONF}\" \
$(NULL)
diff --git a/src/io-xml/Makefile.am b/src/io-xml/Makefile.am
index b159b8c..fbeb150 100644
--- a/src/io-xml/Makefile.am
+++ b/src/io-xml/Makefile.am
@@ -30,6 +30,7 @@ pkglib_LTLIBRARIES = libna-io-xml.la
AM_CPPFLAGS += \
-I $(top_srcdir) \
+ -I $(top_srcdir)/src \
$(NAUTILUS_ACTIONS_CFLAGS) \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_IO_XML}\" \
$(NULL)
@@ -38,8 +39,15 @@ libna_io_xml_la_SOURCES = \
naxml-module.c \
naxml-provider.c \
naxml-provider.h \
+ naxml-keys.c \
+ naxml-keys.h \
+ naxml-reader.c \
+ naxml-reader.h \
$(NULL)
+#na-xml-writer.c
+#na-xml-writer.h
+
libna_io_xml_la_LIBADD = \
$(top_builddir)/src/core/libna-core.la \
$(NULL)
diff --git a/src/io-xml/naxml-keys.c b/src/io-xml/naxml-keys.c
new file mode 100644
index 0000000..8235782
--- /dev/null
+++ b/src/io-xml/naxml-keys.c
@@ -0,0 +1,53 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010 Pierre Wieser and others (see AUTHORS)
+ *
+ * This Program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "naxml-keys.h"
+
+NAXMLKeyStr naxml_schema_key_schema_str [] = {
+ { NAXML_KEY_SCHEMA_NODE_KEY, TRUE, FALSE },
+ { NAXML_KEY_SCHEMA_NODE_APPLYTO, TRUE, FALSE },
+ { NAXML_KEY_SCHEMA_NODE_OWNER, FALSE, FALSE },
+ { NAXML_KEY_SCHEMA_NODE_TYPE, TRUE, FALSE },
+ { NAXML_KEY_SCHEMA_NODE_LISTTYPE, TRUE, FALSE },
+ { NAXML_KEY_SCHEMA_NODE_LOCALE, TRUE, FALSE },
+ { NAXML_KEY_SCHEMA_NODE_DEFAULT, TRUE, FALSE },
+ { NULL }
+};
+
+NAXMLKeyStr naxml_schema_key_locale_str [] = {
+ { NAXML_KEY_SCHEMA_NODE_LOCALE_DEFAULT, TRUE, FALSE },
+ { NAXML_KEY_SCHEMA_NODE_LOCALE_SHORT, FALSE, FALSE },
+ { NAXML_KEY_SCHEMA_NODE_LOCALE_LONG, FALSE, FALSE },
+ { NULL }
+};
diff --git a/src/io-xml/na-xml-names.h b/src/io-xml/naxml-keys.h
similarity index 85%
rename from src/io-xml/na-xml-names.h
rename to src/io-xml/naxml-keys.h
index a2d3392..cd5f6a9 100644
--- a/src/io-xml/na-xml-names.h
+++ b/src/io-xml/naxml-keys.h
@@ -28,53 +28,77 @@
* ... and many others (see AUTHORS)
*/
-#ifndef __NA_COMMON_XML_NAMES_H__
-#define __NA_COMMON_XML_NAMES_H__
+#ifndef __NAXML_KEYS_H__
+#define __NAXML_KEYS_H__
#include <glib/gi18n.h>
+#include <api/na-idata-factory-str.h>
+
G_BEGIN_DECLS
/* XML element names (GConf schema)
- * used in FORMAT_GCONF_SCHEMA_V1 and FORMAT_GCONF_SCHEMA_V2
- */
-#define NACT_GCONF_SCHEMA_ROOT "gconfschemafile"
-#define NACT_GCONF_SCHEMA_LIST "schemalist"
-#define NACT_GCONF_SCHEMA_ENTRY "schema"
-#define NACT_GCONF_SCHEMA_KEY "key"
-#define NACT_GCONF_SCHEMA_APPLYTO "applyto"
-#define NACT_GCONF_SCHEMA_TYPE "type"
-#define NACT_GCONF_SCHEMA_LIST_TYPE "list_type"
-#define NACT_GCONF_SCHEMA_LOCALE "locale"
-#define NACT_GCONF_SCHEMA_DEFAULT "default"
-
-/* Previouly used keys
+ * used in GCONF_SCHEMA_V1 and GCONF_SCHEMA_V2
*
* Up to v 1.10, export used to contain a full schema description,
* while import only checked for applyto keys (along with locale
* and default)
*
* Starting with 1.11, we have introduced a lighter export schema
- * (mainly without owner and short and long descriptions)
- *
- * only used in FORMAT_GCONF_SCHEMA_V1
+ * (without owner and short and long descriptions)
+ */
+#define NAXML_KEY_SCHEMA_ROOT "gconfschemafile"
+#define NAXML_KEY_SCHEMA_LIST "schemalist"
+#define NAXML_KEY_SCHEMA_NODE "schema"
+
+#define NAXML_KEY_SCHEMA_NODE_KEY "key"
+#define NAXML_KEY_SCHEMA_NODE_APPLYTO "applyto"
+#define NAXML_KEY_SCHEMA_NODE_OWNER "owner" /* v1 only */
+#define NAXML_KEY_SCHEMA_NODE_TYPE "type"
+#define NAXML_KEY_SCHEMA_NODE_LISTTYPE "list_type"
+#define NAXML_KEY_SCHEMA_NODE_LOCALE "locale"
+#define NAXML_KEY_SCHEMA_NODE_DEFAULT "default"
+
+#define NAXML_KEY_SCHEMA_NODE_LOCALE_DEFAULT "default"
+#define NAXML_KEY_SCHEMA_NODE_LOCALE_SHORT "short" /* v1 only */
+#define NAXML_KEY_SCHEMA_NODE_LOCALE_LONG "long" /* v1 only */
+
+/* this structure is statically allocated (cf. naxml-keys.c)
+ * and let us check the validity of each element node
*/
-#define NACT_GCONF_SCHEMA_OWNER "owner"
-#define NACT_GCONF_SCHEMA_SHORT "short"
-#define NACT_GCONF_SCHEMA_LONG "long"
+typedef struct {
+ gchar *key; /* static data */
+ gboolean v2;
+
+ gboolean reader_found; /* dynamic data */
+}
+ NAXMLKeyStr;
+
+/* this structure is allocated once for each element readen
+ * and kept in a GList for interpretation in the second run
+ */
+typedef struct {
+ gchar *key_path;
+ gchar *key_value;
+ NadfIdType *iddef;
+}
+ NAXMLElementStr;
/* XML element names (GConf dump)
* used in FORMAT_GCONF_ENTRY
*/
-#define NACT_GCONF_DUMP_ROOT "gconfentryfile"
-#define NACT_GCONF_DUMP_ENTRYLIST "entrylist"
-#define NACT_GCONF_DUMP_ENTRYLIST_BASE "base"
-#define NACT_GCONF_DUMP_ENTRY "entry"
-#define NACT_GCONF_DUMP_KEY "key"
-#define NACT_GCONF_DUMP_VALUE "value"
-#define NACT_GCONF_DUMP_STRING "string"
-#define NACT_GCONF_DUMP_LIST "list"
-#define NACT_GCONF_DUMP_LIST_TYPE "type"
+#define NAXML_KEY_DUMP_ROOT "gconfentryfile"
+#define NAXML_KEY_DUMP_LIST "entrylist"
+#define NAXML_KEY_DUMP_NODE "entry"
+
+#define NAXML_KEY_DUMP_LIST_PARM_BASE "base"
+
+#define NAXML_KEY_DUMP_NODE_KEY "key"
+#define NAXML_KEY_DUMP_NODE_VALUE "value"
+
+#define NAXML_KEY_DUMP_NODE_VALUE_TYPE_STRING "string"
+#define NAXML_KEY_DUMP_NODE_VALUE_LIST "list"
+#define NAXML_KEY_DUMP_NODE_VALUE_LIST_PARM_TYPE "type"
/* GConf schema descriptions
*/
@@ -188,4 +212,4 @@ G_BEGIN_DECLS
G_END_DECLS
-#endif /* __NA_COMMON_XML_NAMES_H__ */
+#endif /* __NAXML_KEYS_H__ */
diff --git a/src/io-xml/naxml-provider.c b/src/io-xml/naxml-provider.c
index 0c2eb54..3d4bcd3 100644
--- a/src/io-xml/naxml-provider.c
+++ b/src/io-xml/naxml-provider.c
@@ -36,18 +36,20 @@
#include <api/na-iio-factory.h>
#include <api/na-iexporter.h>
+#include <api/na-iimporter.h>
#include "naxml-provider.h"
+#include "naxml-reader.h"
/* private class data
*/
-struct NaxmlProviderClassPrivate {
+struct NAXMLProviderClassPrivate {
void *empty; /* so that gcc -pedantic is happy */
};
/* private instance data
*/
-struct NaxmlProviderPrivate {
+struct NAXMLProviderPrivate {
gboolean dispose_has_run;
};
@@ -92,17 +94,20 @@ static NAExporterStr st_formats[] = {
static GType st_module_type = 0;
static GObjectClass *st_parent_class = NULL;
-static void class_init( NaxmlProviderClass *klass );
+static void class_init( NAXMLProviderClass *klass );
static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *object );
static void instance_finalize( GObject *object );
+static void iimporter_iface_init( NAIImporterInterface *iface );
+static guint iimporter_get_version( const NAIImporter *importer );
+
static void iexporter_iface_init( NAIExporterInterface *iface );
-static guint iexporter_get_version( const NAIExporter *provider );
-static const NAExporterStr *iexporter_get_formats( const NAIExporter *instance );
+static guint iexporter_get_version( const NAIExporter *exporter );
+static const NAExporterStr *iexporter_get_formats( const NAIExporter *exporter );
static void iio_factory_iface_init( NAIIOFactoryInterface *iface );
-static guint iio_factory_get_version( const NAIIOFactory *provider );
+static guint iio_factory_get_version( const NAIIOFactory *factory );
GType
naxml_provider_get_type( void )
@@ -116,17 +121,23 @@ naxml_provider_register_type( GTypeModule *module )
static const gchar *thisfn = "naxml_provider_register_type";
static GTypeInfo info = {
- sizeof( NaxmlProviderClass ),
+ sizeof( NAXMLProviderClass ),
NULL,
NULL,
( GClassInitFunc ) class_init,
NULL,
NULL,
- sizeof( NaxmlProvider ),
+ sizeof( NAXMLProvider ),
0,
( GInstanceInitFunc ) instance_init
};
+ static const GInterfaceInfo iimporter_iface_info = {
+ ( GInterfaceInitFunc ) iimporter_iface_init,
+ NULL,
+ NULL
+ };
+
static const GInterfaceInfo iexporter_iface_info = {
( GInterfaceInitFunc ) iexporter_iface_init,
NULL,
@@ -141,7 +152,9 @@ naxml_provider_register_type( GTypeModule *module )
g_debug( "%s", thisfn );
- st_module_type = g_type_module_register_type( module, G_TYPE_OBJECT, "NaxmlProvider", &info, 0 );
+ st_module_type = g_type_module_register_type( module, G_TYPE_OBJECT, "NAXMLProvider", &info, 0 );
+
+ g_type_module_add_interface( module, st_module_type, NA_IIMPORTER_TYPE, &iimporter_iface_info );
g_type_module_add_interface( module, st_module_type, NA_IEXPORTER_TYPE, &iexporter_iface_info );
@@ -149,7 +162,7 @@ naxml_provider_register_type( GTypeModule *module )
}
static void
-class_init( NaxmlProviderClass *klass )
+class_init( NAXMLProviderClass *klass )
{
static const gchar *thisfn = "naxml_provider_class_init";
GObjectClass *object_class;
@@ -162,21 +175,21 @@ class_init( NaxmlProviderClass *klass )
object_class->dispose = instance_dispose;
object_class->finalize = instance_finalize;
- klass->private = g_new0( NaxmlProviderClassPrivate, 1 );
+ klass->private = g_new0( NAXMLProviderClassPrivate, 1 );
}
static void
instance_init( GTypeInstance *instance, gpointer klass )
{
static const gchar *thisfn = "naxml_provider_instance_init";
- NaxmlProvider *self;
+ NAXMLProvider *self;
g_debug( "%s: instance=%p (%s), klass=%p",
thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ), ( void * ) klass );
- g_return_if_fail( NAGP_IS_GCONF_PROVIDER( instance ));
+ g_return_if_fail( NA_IS_XML_PROVIDER( instance ));
self = NAXML_PROVIDER( instance );
- self->private = g_new0( NaxmlProviderPrivate, 1 );
+ self->private = g_new0( NAXMLProviderPrivate, 1 );
self->private->dispose_has_run = FALSE;
}
@@ -185,10 +198,10 @@ static void
instance_dispose( GObject *object )
{
static const gchar *thisfn = "naxml_provider_instance_dispose";
- NaxmlProvider *self;
+ NAXMLProvider *self;
g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
- g_return_if_fail( NAGP_IS_GCONF_PROVIDER( object ));
+ g_return_if_fail( NA_IS_XML_PROVIDER( object ));
self = NAXML_PROVIDER( object );
if( !self->private->dispose_has_run ){
@@ -205,9 +218,9 @@ instance_dispose( GObject *object )
static void
instance_finalize( GObject *object )
{
- NaxmlProvider *self;
+ NAXMLProvider *self;
- g_assert( NAGP_IS_GCONF_PROVIDER( object ));
+ g_assert( NA_IS_XML_PROVIDER( object ));
self = NAXML_PROVIDER( object );
g_free( self->private );
@@ -219,6 +232,23 @@ instance_finalize( GObject *object )
}
static void
+iimporter_iface_init( NAIImporterInterface *iface )
+{
+ static const gchar *thisfn = "naxml_provider_iimporter_iface_init";
+
+ g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
+
+ iface->get_version = iimporter_get_version;
+ iface->import_uri = naxml_reader_import_uri;
+}
+
+static guint
+iimporter_get_version( const NAIImporter *importer )
+{
+ return( 1 );
+}
+
+static void
iexporter_iface_init( NAIExporterInterface *iface )
{
static const gchar *thisfn = "naxml_provider_iexporter_iface_init";
@@ -232,13 +262,13 @@ iexporter_iface_init( NAIExporterInterface *iface )
}
static guint
-iexporter_get_version( const NAIExporter *provider )
+iexporter_get_version( const NAIExporter *exporter )
{
return( 1 );
}
static const NAExporterStr *
-iexporter_get_formats( const NAIExporter *instance )
+iexporter_get_formats( const NAIExporter *exporter )
{
return( st_formats );
}
@@ -260,7 +290,7 @@ iio_factory_iface_init( NAIIOFactoryInterface *iface )
}
static guint
-iio_factory_get_version( const NAIIOFactory *provider )
+iio_factory_get_version( const NAIIOFactory *factory )
{
return( 1 );
}
diff --git a/src/io-xml/naxml-provider.h b/src/io-xml/naxml-provider.h
index 0f2b490..d116372 100644
--- a/src/io-xml/naxml-provider.h
+++ b/src/io-xml/naxml-provider.h
@@ -33,7 +33,7 @@
/**
* SECTION: naxml_provider
- * @short_description: #NaxmlProvider class definition.
+ * @short_description: #NAXMLProvider class definition.
* @include: naxml-provider.h
*
* This class manages I/O in XML formats.
@@ -43,28 +43,28 @@
G_BEGIN_DECLS
-#define NAXML_PROVIDER_TYPE ( naxml_provider_get_type())
-#define NAXML_PROVIDER( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NAXML_PROVIDER_TYPE, NaxmlProvider ))
-#define NAXML_PROVIDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NAXML_PROVIDER_TYPE, NaxmlProviderClass ))
-#define NAGP_IS_GCONF_PROVIDER( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NAXML_PROVIDER_TYPE ))
-#define NAGP_IS_GCONF_PROVIDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NAXML_PROVIDER_TYPE ))
-#define NAXML_PROVIDER_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NAXML_PROVIDER_TYPE, NaxmlProviderClass ))
+#define NAXML_PROVIDER_TYPE ( naxml_provider_get_type())
+#define NAXML_PROVIDER( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NAXML_PROVIDER_TYPE, NAXMLProvider ))
+#define NAXML_PROVIDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NAXML_PROVIDER_TYPE, NAXMLProviderClass ))
+#define NA_IS_XML_PROVIDER( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NAXML_PROVIDER_TYPE ))
+#define NA_IS_XML_PROVIDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NAXML_PROVIDER_TYPE ))
+#define NAXML_PROVIDER_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NAXML_PROVIDER_TYPE, NAXMLProviderClass ))
-typedef struct NaxmlProviderPrivate NaxmlProviderPrivate;
+typedef struct NAXMLProviderPrivate NAXMLProviderPrivate;
typedef struct {
GObject parent;
- NaxmlProviderPrivate *private;
+ NAXMLProviderPrivate *private;
}
- NaxmlProvider;
+ NAXMLProvider;
-typedef struct NaxmlProviderClassPrivate NaxmlProviderClassPrivate;
+typedef struct NAXMLProviderClassPrivate NAXMLProviderClassPrivate;
typedef struct {
GObjectClass parent;
- NaxmlProviderClassPrivate *private;
+ NAXMLProviderClassPrivate *private;
}
- NaxmlProviderClass;
+ NAXMLProviderClass;
GType naxml_provider_get_type ( void );
void naxml_provider_register_type( GTypeModule *module );
diff --git a/src/io-xml/nact-xml-reader.c b/src/io-xml/naxml-reader.c
similarity index 50%
rename from src/io-xml/nact-xml-reader.c
rename to src/io-xml/naxml-reader.c
index a46f255..601ed94 100644
--- a/src/io-xml/nact-xml-reader.c
+++ b/src/io-xml/naxml-reader.c
@@ -34,47 +34,53 @@
#include <glib/gi18n.h>
#include <libxml/tree.h>
-#include <stdarg.h>
#include <string.h>
-#include <uuid/uuid.h>
+#include <api/na-core-utils.h>
+#include <api/na-iio-factory.h>
#include <api/na-object-api.h>
-#include <io-provider-gconf/nagp-keys.h>
+#include <io-gconf/nagp-keys.h>
-#include <runtime/na-gconf-utils.h>
-#include <runtime/na-iprefs.h>
-#include <runtime/na-utils.h>
-#include <runtime/na-xml-names.h>
-
-#include "nact-application.h"
-#include "nact-main-window.h"
-#include "nact-assistant-import-ask.h"
-#include "nact-xml-reader.h"
+#include "naxml-keys.h"
+#include "naxml-reader.h"
/* private class data
*/
-struct NactXMLReaderClassPrivate {
+struct NAXMLReaderClassPrivate {
void *empty; /* so that gcc -pedantic is happy */
};
/* private instance data
- * we allocate one instance for each imported file, and each imported
- * file should contain one and only one action
- * follow here the import flow
+ * main naxml_reader_import_uri() function is called once for each file
+ * to import. We thus have one NAXMLReader object per import operation.
*/
-struct NactXMLReaderPrivate {
- gboolean dispose_has_run;
- BaseWindow *window;
- gint import_mode;
- const gchar *uri;
- GList *auxiliaries;
- NAObjectAction *action; /* the action that we will return, or NULL */
- GSList *messages;
- gboolean uuid_set; /* set at first uuid, then checked against */
-
- /* following values are reset at each schema/entry node
+struct NAXMLReaderPrivate {
+ gboolean dispose_has_run;
+
+ /* data provided by the caller
+ */
+ const gchar *uri;
+ gint mode;
+
+ /* data dynamically set during the import operation
+ */
+ gchar *xml_root;
+ NAObjectItem *item;
+ GSList *messages;
+ gboolean type_found;
+ GList *elements;
+
+ /* following values are reset and reused while iterating on each
+ * element nodes of the imported item (cf. reset_element_data())
*/
+ gboolean ok;
+ gchar *applyto_key;
+ gchar *applyto_value;
+ NadfIdType *iddef;
+
+ /* --- */
+
NAObjectProfile *profile; /* profile */
gboolean locale_waited; /* does this require a locale ? */
gboolean profile_waited; /* does this entry apply to a profile ? */
@@ -84,6 +90,54 @@ struct NactXMLReaderPrivate {
GSList *list_value;
};
+#define PATH_ID_IDX 4 /* index of item id in a GConf key path */
+
+extern NAXMLKeyStr naxml_schema_key_schema_str[];
+
+static GObjectClass *st_parent_class = NULL;
+
+static GType register_type( void );
+static void class_init( NAXMLReaderClass *klass );
+static void instance_init( GTypeInstance *instance, gpointer klass );
+static void instance_dispose( GObject *object );
+static void instance_finalize( GObject *object );
+
+/* the association of a document root node key and the functions
+ */
+typedef struct {
+ gchar *root_key;
+ gchar *list_key;
+ gchar *element_key;
+ void ( *fn_root_parms ) ( NAXMLReader *, xmlNode * );
+ void ( *fn_list_parms ) ( NAXMLReader *, xmlNode * );
+ void ( *fn_element_parms ) ( NAXMLReader *, xmlNode * );
+ void ( *fn_element_content )( NAXMLReader *, xmlNode * );
+}
+ RootNodeStr;
+
+static void reader_parse_schema_schema_content( NAXMLReader *reader, xmlNode *node );
+static void reader_parse_dump_list_parms( NAXMLReader *reader, xmlNode *node );
+static void reader_parse_dump_entry_content( NAXMLReader *reader, xmlNode *node );
+
+static RootNodeStr st_root_node_str[] = {
+ { NAXML_KEY_SCHEMA_ROOT,
+ NAXML_KEY_SCHEMA_LIST,
+ NAXML_KEY_SCHEMA_NODE,
+ NULL,
+ NULL,
+ NULL,
+ reader_parse_schema_schema_content },
+ { NAXML_KEY_DUMP_ROOT,
+ NAXML_KEY_DUMP_LIST,
+ NAXML_KEY_DUMP_NODE,
+ NULL,
+ reader_parse_dump_list_parms,
+ NULL,
+ reader_parse_dump_entry_content },
+ { NULL }
+};
+
+#if 0
typedef struct {
char *entry;
gboolean entry_found;
@@ -119,11 +173,20 @@ static GConfReaderStruct reader_str[] = {
{ ACTION_FOLDERS_ENTRY , FALSE, FALSE, TRUE, TRUE },
{ NULL, FALSE, FALSE, FALSE, FALSE },
};
+#endif
-#define ERR_UNABLE_PARSE_XML_FILE _( "Unable to parse XML file: %s." )
-#define ERR_ROOT_ELEMENT _( "Invalid XML root element: waited for '%s' or '%s', found '%s' at line %d." )
-#define ERR_WAITED_IGNORED_NODE _( "Waited for '%s' node, found (ignored) '%s' at line %d." )
-#define ERR_IGNORED_NODE _( "Unexpected (ignored) '%s' node found at line %d." )
+#define ERR_XMLDOC_UNABLE_TOPARSE _( "Unable to parse XML file: %s." )
+#define ERR_ROOT_UNKNOWN _( "Invalid XML root element %s found at line %d while waiting for %s." )
+#define ERR_NODE_UNKNOWN _( "Unknown element %s found at line %d while waiting for %s." )
+#define ERR_NODE_ALREADY_FOUND _( "Element %s at line %d already found, ignored." )
+/* i18n: do not translate keywords 'Action' nor 'Menu' */
+#define ERR_NODE_UNKNOWN_TYPE _( "Unknown type %s found at line %d, while waiting for Action or Menu." )
+#define ERR_PATH_LENGTH _( "Too many elements in key path %s." )
+#define ERR_MENU_UNWAITED _( "Unwaited key path %s while importing a menu." )
+#define ERR_ID_NOT_FOUND _( "Item ID not found." )
+#define ERR_ITEM_LABEL_NOT_FOUND _( "Item label not found." )
+
+#if 0
#define ERR_IGNORED_SCHEMA _( "Schema is ignored at line %d." )
#define ERR_UNEXPECTED_NODE _( "Unexpected '%s' node found at line %d." )
#define ERR_UNEXPECTED_ENTRY _( "Unexpected '%s' entry found at line %d." )
@@ -134,50 +197,59 @@ static GConfReaderStruct reader_str[] = {
#define ERR_NOT_AN_UUID _( "Invalid UUID %s found at line %d." )
#define ERR_UUID_ALREADY_EXISTS _( "Already existing action (UUID: %s)." )
#define ERR_VALUE_ALREADY_SET _( "Value '%s' already set: new value ignored at line %d." )
-#define ERR_UUID_NOT_FOUND _( "UUID not found." )
-#define ERR_ACTION_LABEL_NOT_FOUND _( "Action label not found." )
+#endif
-static GObjectClass *st_parent_class = NULL;
+static NAXMLReader *reader_new( void );
+
+static void reader_parse_xmldoc( NAXMLReader *reader );
+static void add_message( NAXMLReader *reader, const gchar *format, ... );
+static gchar *build_root_node_list( void );
+static gchar *build_key_node_list( NAXMLKeyStr *strlist );
+static gchar *get_default_value( xmlNode *node );
+static gchar *get_locale_default_value( xmlNode *node );
+static void iter_on_root_children( NAXMLReader *reader, xmlNode *root, RootNodeStr *str );
+static void iter_on_list_children( NAXMLReader *reader, xmlNode *first, RootNodeStr *str );
+static void iter_on_list_children_run( NAXMLReader *reader, xmlNode *list, RootNodeStr *str );
+static void iter_on_elements_list( NAXMLReader *reader );
+static void reset_element_data( NAXMLReader *reader );
+static void reset_item_data( NAXMLReader *reader );
+static void set_schema_applyto_value( NAXMLReader *reader, xmlNode *node, const gchar *entry );
+static void free_naxml_element_str( NAXMLElementStr *str, void *data );
+static xmlNode *search_for_child_node( xmlNode *node, const gchar *key );
+static int strxcmp( const xmlChar *a, const char *b );
+
+
+#if 0
+static void reader_parse_schemalist( NAXMLReader *reader, xmlNode *schemalist );
+static gboolean reader_parse_schema( NAXMLReader *reader, xmlNode *schema );
+static gboolean reader_parse_applyto( NAXMLReader *reader, xmlNode *node );
+static gboolean reader_check_for_entry( NAXMLReader *reader, xmlNode *node, const char *entry );
+static gboolean reader_parse_locale( NAXMLReader *reader, xmlNode *node );
+static void reader_parse_default( NAXMLReader *reader, xmlNode *node );
+static gchar *get_profile_name_from_schema_key( const gchar *key, const gchar *uuid );
+
+static void reader_parse_entrylist( NAXMLReader *reader, xmlNode *entrylist );
+static gboolean reader_parse_entry( NAXMLReader *reader, xmlNode *entry );
+static gboolean reader_parse_dump_key( NAXMLReader *reader, xmlNode *key );
+static void reader_parse_dump_value( NAXMLReader *reader, xmlNode *key );
+static void reader_parse_dump_value_list( NAXMLReader *reader, xmlNode *key );
+static gchar *get_profile_name_from_dump_key( const gchar *key );
+
+static void apply_values( NAXMLReader *reader );
+static gchar *get_uuid_from_key( NAXMLReader *reader, const gchar *key, guint line );
+static gboolean is_uuid_valid( const gchar *uuid );
+static gchar *get_entry_from_key( const gchar *key );
-static GType register_type( void );
-static void class_init( NactXMLReaderClass *klass );
-static void instance_init( GTypeInstance *instance, gpointer klass );
-static void instance_dispose( GObject *object );
-static void instance_finalize( GObject *object );
-
-static NactXMLReader *gconf_reader_new( void );
-
-static void gconf_reader_parse_schema_root( NactXMLReader *reader, xmlNode *root );
-static void gconf_reader_parse_schemalist( NactXMLReader *reader, xmlNode *schemalist );
-static gboolean gconf_reader_parse_schema( NactXMLReader *reader, xmlNode *schema );
-static gboolean gconf_reader_parse_applyto( NactXMLReader *reader, xmlNode *node );
-static gboolean gconf_reader_check_for_entry( NactXMLReader *reader, xmlNode *node, const char *entry );
-static gboolean gconf_reader_parse_locale( NactXMLReader *reader, xmlNode *node );
-static void gconf_reader_parse_default( NactXMLReader *reader, xmlNode *node );
-static gchar *get_profile_name_from_schema_key( const gchar *key, const gchar *uuid );
-
-static void gconf_reader_parse_dump_root( NactXMLReader *reader, xmlNode *root );
-static void gconf_reader_parse_entrylist( NactXMLReader *reader, xmlNode *entrylist );
-static gboolean gconf_reader_parse_entry( NactXMLReader *reader, xmlNode *entry );
-static gboolean gconf_reader_parse_dump_key( NactXMLReader *reader, xmlNode *key );
-static void gconf_reader_parse_dump_value( NactXMLReader *reader, xmlNode *key );
-static void gconf_reader_parse_dump_value_list( NactXMLReader *reader, xmlNode *key );
-static gchar *get_profile_name_from_dump_key( const gchar *key );
-
-static void apply_values( NactXMLReader *reader );
-static void add_message( NactXMLReader *reader, const gchar *format, ... );
-static int strxcmp( const xmlChar *a, const char *b );
-static gchar *get_uuid_from_key( NactXMLReader *reader, const gchar *key, guint line );
-static gboolean is_uuid_valid( const gchar *uuid );
-static gchar *get_entry_from_key( const gchar *key );
-static void free_reader_values( NactXMLReader *reader );
-static gboolean manage_import_mode( NactXMLReader *reader );
-static void propagate_default_values( NactXMLReader *reader );
-static NAObjectItem *search_in_auxiliaries( NactXMLReader *reader, const gchar *uuid );
-static void relabel( NactXMLReader *reader );
+#endif
+static gboolean manage_import_mode( NAXMLReader *reader );
+#if 0
+static void propagate_default_values( NAXMLReader *reader );
+static NAObjectItem *search_in_auxiliaries( NAXMLReader *reader, const gchar *uuid );
+static void relabel( NAXMLReader *reader );
+#endif
GType
-nact_xml_reader_get_type( void )
+naxml_reader_get_type( void )
{
static GType object_type = 0;
@@ -191,32 +263,32 @@ nact_xml_reader_get_type( void )
static GType
register_type( void )
{
- static const gchar *thisfn = "nact_xml_reader_register_type";
+ static const gchar *thisfn = "naxml_reader_register_type";
GType type;
static GTypeInfo info = {
- sizeof( NactXMLReaderClass ),
+ sizeof( NAXMLReaderClass ),
NULL,
NULL,
( GClassInitFunc ) class_init,
NULL,
NULL,
- sizeof( NactXMLReader ),
+ sizeof( NAXMLReader ),
0,
( GInstanceInitFunc ) instance_init
};
g_debug( "%s", thisfn );
- type = g_type_register_static( G_TYPE_OBJECT, "NactXMLReader", &info, 0 );
+ type = g_type_register_static( G_TYPE_OBJECT, "NAXMLReader", &info, 0 );
return( type );
}
static void
-class_init( NactXMLReaderClass *klass )
+class_init( NAXMLReaderClass *klass )
{
- static const gchar *thisfn = "nact_xml_reader_class_init";
+ static const gchar *thisfn = "naxml_reader_class_init";
GObjectClass *object_class;
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
@@ -227,25 +299,31 @@ class_init( NactXMLReaderClass *klass )
object_class->dispose = instance_dispose;
object_class->finalize = instance_finalize;
- klass->private = g_new0( NactXMLReaderClassPrivate, 1 );
+ klass->private = g_new0( NAXMLReaderClassPrivate, 1 );
}
static void
instance_init( GTypeInstance *instance, gpointer klass )
{
- static const gchar *thisfn = "nact_xml_reader_instance_init";
- NactXMLReader *self;
+ static const gchar *thisfn = "naxml_reader_instance_init";
+ NAXMLReader *self;
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
- g_return_if_fail( NACT_IS_XML_READER( instance ));
- self = NACT_XML_READER( instance );
+ g_return_if_fail( NAXML_IS_READER( instance ));
+ self = NAXML_READER( instance );
- self->private = g_new0( NactXMLReaderPrivate, 1 );
+ self->private = g_new0( NAXMLReaderPrivate, 1 );
self->private->dispose_has_run = FALSE;
- self->private->action = NULL;
+ self->private->uri = NULL;
+ self->private->mode = 0;
+ self->private->item = NULL;
self->private->messages = NULL;
- self->private->uuid_set = FALSE;
+ self->private->type_found = FALSE;
+ self->private->elements = NULL;
+
+ reset_item_data( self );
+
self->private->profile = NULL;
self->private->locale_waited = FALSE;
self->private->entry = NULL;
@@ -255,22 +333,27 @@ instance_init( GTypeInstance *instance, gpointer klass )
static void
instance_dispose( GObject *object )
{
- static const gchar *thisfn = "nact_xml_reader_instance_dispose";
- NactXMLReader *self;
+ static const gchar *thisfn = "naxml_reader_instance_dispose";
+ NAXMLReader *self;
g_debug( "%s: object=%p", thisfn, ( void * ) object );
- g_return_if_fail( NACT_IS_XML_READER( object ));
- self = NACT_XML_READER( object );
+ g_return_if_fail( NAXML_IS_READER( object ));
+ self = NAXML_READER( object );
if( !self->private->dispose_has_run ){
self->private->dispose_has_run = TRUE;
- if( self->private->action ){
- g_return_if_fail( NA_IS_OBJECT_ACTION( self->private->action ));
- g_object_unref( self->private->action );
+ g_free( self->private->xml_root );
+
+ if( self->private->item ){
+ g_return_if_fail( NA_IS_OBJECT_ITEM( self->private->item ));
+ na_object_unref( self->private->item );
}
+ g_list_foreach( self->private->elements, ( GFunc ) free_naxml_element_str, NULL );
+ g_list_free( self->private->elements );
+
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
G_OBJECT_CLASS( st_parent_class )->dispose( object );
@@ -281,15 +364,14 @@ instance_dispose( GObject *object )
static void
instance_finalize( GObject *object )
{
- static const gchar *thisfn = "nact_xml_reader_instance_finalize";
- NactXMLReader *self;
+ static const gchar *thisfn = "naxml_reader_instance_finalize";
+ NAXMLReader *self;
g_debug( "%s: object=%p", thisfn, ( void * ) object );
- g_return_if_fail( NACT_IS_XML_READER( object ));
- self = NACT_XML_READER( object );
+ g_return_if_fail( NAXML_IS_READER( object ));
+ self = NAXML_READER( object );
- na_utils_free_string_list( self->private->messages );
- free_reader_values( self );
+ na_core_utils_slist_free( self->private->messages );
g_free( self->private );
@@ -299,108 +381,169 @@ instance_finalize( GObject *object )
}
}
-static NactXMLReader *
-gconf_reader_new( void )
+static NAXMLReader *
+reader_new( void )
{
- return( g_object_new( NACT_XML_READER_TYPE, NULL ));
+ return( g_object_new( NAXML_READER_TYPE, NULL ));
}
/**
- * nact_xml_reader_import:
- * @window: the #NactAssistantImport instance.
- * @items: an auxiliary list of NAObjectItems in which the existancy of
- * the imported action could be checked ; this typically correspond to
- * actions which were previously imported in the assistant
- * @uri: the uri of the file to import.
- * @import_mode: the import mode.
- * @msg: a list of error messages which may be set by this function.
+ * naxml_reader_import_uri:
+ * @instance: the #NAIImporter provider.
+ * @uri: the URI of the file to be imported.
+ * @mode: the import mode.
+ * @fn: a pointer to the function to be used to check for existancy of
+ * imported id.
+ * @fn_data: data to be passed to @fn.
+ * @messages: a pointer to a #GSList list of strings; the provider
+ * may append messages to this list, but shouldn't reinitialize it.
*
- * Import the specified file as an NAAction XML description.
+ * Imports an item.
*
- * Returns: the imported action, or NULL.
+ * Returns: a #NAObjectItem-derived object, or %NULL if an error has
+ * been detected.
*/
-NAObjectAction *
-nact_xml_reader_import( BaseWindow *window, GList *items, const gchar *uri, gint import_mode, GSList **msg )
+NAObjectItem *
+naxml_reader_import_uri( const NAIImporter *instance, const gchar *uri, guint mode, ImporterCheckFn fn, void *fn_data, GSList **messages )
{
- static const gchar *thisfn = "nact_xml_reader_import";
- NAObjectAction *action = NULL;
- NactXMLReader *reader;
- xmlDoc *doc;
+ static const gchar *thisfn = "naxml_reader_import_uri";
+ NAObjectItem *item;
+ NAXMLReader *reader;
+ GSList *im;
- g_debug( "%s: window=%p, uri=%s, msg=%p", thisfn, ( void * ) window, uri, ( void * ) msg );
- g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+ g_debug( "%s: instance=%p, uri=%s, mode=%d, fn=%p, fn_data=%p, messages=%p",
+ thisfn, ( void * ) instance, uri, mode, ( void * ) fn, ( void * ) fn_data, ( void * ) messages );
- reader = gconf_reader_new();
- reader->private->window = window;
- reader->private->import_mode = import_mode;
+ g_return_val_if_fail( NA_IS_IIMPORTER( instance ), NULL );
+
+ reader = reader_new();
reader->private->uri = uri;
- reader->private->auxiliaries = items;
+ reader->private->mode = mode;
+
+ reader_parse_xmldoc( reader );
- g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+ item = NULL;
+ if( reader->private->item ){
+ g_assert( NA_IS_OBJECT_ITEM( reader->private->item ));
+#if 0
+ propagate_default_values( reader );
+#endif
+ if( manage_import_mode( reader )){
+ item = NA_OBJECT_ITEM( na_object_ref( reader->private->item ));
+ }
+ }
- doc = xmlParseFile( uri );
+ if( messages ){
+ for( im = reader->private->messages ; im ; im = im->next ){
+ *messages = g_slist_append( *messages, g_strdup(( const gchar * ) im->data ));
+ }
+ }
+
+ g_object_unref( reader );
+
+ return( item );
+}
+
+/*
+ * check that the file is a valid XML document
+ * and that the root node can be identified as a schema or a dump
+ */
+static void
+reader_parse_xmldoc( NAXMLReader *reader )
+{
+ RootNodeStr *istr;
+ gboolean found;
+
+ xmlDoc *doc = xmlParseFile( reader->private->uri );
if( !doc ){
xmlErrorPtr error = xmlGetLastError();
add_message( reader,
- ERR_UNABLE_PARSE_XML_FILE, error->message );
+ ERR_XMLDOC_UNABLE_TOPARSE, error->message );
xmlResetError( error );
} else {
xmlNode *root_node = xmlDocGetRootElement( doc );
- if( strxcmp( root_node->name, NACT_GCONF_SCHEMA_ROOT ) &&
- strxcmp( root_node->name, NACT_GCONF_DUMP_ROOT )){
- add_message( reader,
- ERR_ROOT_ELEMENT,
- NACT_GCONF_SCHEMA_ROOT, NACT_GCONF_DUMP_ROOT, ( const char * ) root_node->name, root_node->line );
+ istr = st_root_node_str;
+ found = FALSE;
- } else if( !strxcmp( root_node->name, NACT_GCONF_SCHEMA_ROOT )){
- gconf_reader_parse_schema_root( reader, root_node );
+ while( istr->root_key ){
+ if( !strxcmp( root_node->name, istr->root_key )){
+ found = TRUE;
+ iter_on_root_children( reader, root_node, istr );
+ }
+ istr++;
+ }
- } else {
- g_assert( !strxcmp( root_node->name, NACT_GCONF_DUMP_ROOT ));
- gconf_reader_parse_dump_root( reader, root_node );
+ if( !found ){
+ gchar *node_list = build_root_node_list();
+ add_message( reader,
+ ERR_ROOT_UNKNOWN,
+ ( const char * ) root_node->name, root_node->line, node_list );
+ g_free( node_list );
}
xmlFreeDoc (doc);
}
xmlCleanupParser();
+}
- if( reader->private->action ){
- g_assert( NA_IS_OBJECT_ACTION( reader->private->action ));
- propagate_default_values( reader );
- if( manage_import_mode( reader )){
- action = g_object_ref( reader->private->action );
+static gchar *
+build_root_node_list( void )
+{
+ RootNodeStr *next;
+
+ RootNodeStr *istr = st_root_node_str;
+ GString *string = g_string_new( "" );
+
+ while( istr->root_key ){
+ next = istr+1;
+ if( string->len ){
+ if( next->root_key ){
+ string = g_string_append( string, ", " );
+ } else {
+ string = g_string_append( string, " or " );
+ }
}
+ string = g_string_append( string, istr->root_key );
+ istr++;
}
- *msg = na_utils_duplicate_string_list( reader->private->messages );
- g_object_unref( reader );
-
- return( action );
+ return( g_string_free( string, FALSE ));
}
+#if 0
+/*
+ * parse a XML schema
+ * root = "gconfschemafile" (already tested)
+ * +- have one descendant node "schemalist"
+ * | +- have one descendant node per key "schema"
+ */
static void
-gconf_reader_parse_schema_root( NactXMLReader *reader, xmlNode *root )
+reader_parse_schema_root( NAXMLReader *reader, xmlNode *root )
{
- static const gchar *thisfn = "gconf_reader_parse_schema_root";
+ static const gchar *thisfn = "naxml_reader_parse_schema_root";
xmlNodePtr iter;
gboolean found = FALSE;
g_debug( "%s: reader=%p, root=%p", thisfn, ( void * ) reader, ( void * ) root );
+ iter_on_tree_nodes(
+ reader, root,
+ NAXML_KEY_SCHEMA_LIST, NAXML_KEY_SCHEMA_ENTRY, reader_parse_schema_schema );
+
for( iter = root->children ; iter ; iter = iter->next ){
if( iter->type != XML_ELEMENT_NODE ){
continue;
}
- if( strxcmp( iter->name, NACT_GCONF_SCHEMA_LIST )){
+ if( strxcmp( iter->name, NAXML_KEY_SCHEMA_LIST )){
add_message( reader,
ERR_WAITED_IGNORED_NODE,
- NACT_GCONF_SCHEMA_LIST, ( const char * ) iter->name, iter->line );
+ NAXML_KEY_SCHEMA_LIST, ( const char * ) iter->name, iter->line );
continue;
}
@@ -410,19 +553,471 @@ gconf_reader_parse_schema_root( NactXMLReader *reader, xmlNode *root )
}
found = TRUE;
- gconf_reader_parse_schemalist( reader, iter );
+ reader_parse_schemalist( reader, iter );
+ }
+}
+#endif
+
+/*
+ * parse a XML tree
+ * - must have one child on the named 'first_child' key (others are warned)
+ * - then iter on child nodes of this previous first named which must ne 'next_child'
+ */
+static void
+iter_on_root_children( NAXMLReader *reader, xmlNode *root, RootNodeStr *str )
+{
+ static const gchar *thisfn = "naxml_reader_iter_on_root_children";
+ xmlNodePtr iter;
+ gboolean found;
+
+ g_debug( "%s: reader=%p, root=%p, str=%p",
+ thisfn, ( void * ) reader, ( void * ) root, ( void * ) str );
+
+ reader->private->xml_root = g_strdup(( const gchar * ) root->name );
+
+ /* deal with properties attached to the root node
+ */
+ if( str->fn_root_parms ){
+ ( *str->fn_root_parms )( reader, root );
+ }
+
+ /* iter through the first level of children (list)
+ * we must have only one occurrence of this first 'list' child
+ */
+ found = FALSE;
+ for( iter = root->children ; iter ; iter = iter->next ){
+
+ if( iter->type != XML_ELEMENT_NODE ){
+ continue;
+ }
+
+ if( strxcmp( iter->name, str->list_key )){
+ add_message( reader,
+ ERR_NODE_UNKNOWN,
+ ( const char * ) iter->name, iter->line, str->list_key );
+ continue;
+ }
+
+ if( found ){
+ add_message( reader, ERR_NODE_ALREADY_FOUND, ( const char * ) iter->name, iter->line );
+ continue;
+ }
+
+ found = TRUE;
+ iter_on_list_children( reader, iter, str );
}
}
/*
+ * iter on 'schema' element nodes
+ * each node should correspond to an elementary data of the imported item
+ * other nodes are warned (and ignored)
+ *
+ * we have to iterate a first time through all schemas to be sure to find
+ * a potential 'type' indication - this is needed in order to allocate an
+ * action or a menu - if not found at the end of this first pass, we default
+ * to allocate an action
+ *
+ * this first pass is also used to check schemas
+ *
+ * - for each schema, check that
+ * > 'schema' childs are in the list of known schema child nodes
+ * > 'schema' childs appear only once per schema
+ * -> this requires a per-node 'found' flag which is reset for each schema
+ * > has an 'applyto' child node
+ * -> only checkable at the end of the schema
+ *
+ * - check that each data, identified by the 'applyto' value, appears only once
+ * applyto node -> elementary data + id item + (optionally) id profile
+ * elementary data -> group (action, menu, profile)
+ * -> this requires a 'found' flag for each group+data reset at item level
+ * as the item may not be allocated yet, we cannot check that data
+ * is actually relevant with the to-be-imported item
+ *
+ * - search for type, and allocate the object
+ * default value (allocating an Action) is set between the two runs
+ *
+ * each schema 'applyto' node let us identify a data and its value
+ */
+static void
+iter_on_list_children( NAXMLReader *reader, xmlNode *list, RootNodeStr *str )
+{
+ static const gchar *thisfn = "naxml_reader_iter_on_list_children";
+ gboolean ok;
+
+ g_debug( "%s: reader=%p, list=%p, str=%p",
+ thisfn, ( void * ) reader, ( void * ) list, ( void * ) str );
+
+ /* deal with properties attached to the list node
+ */
+ if( str->fn_list_parms ){
+ ( *str->fn_list_parms )( reader, list );
+ }
+
+ /* each occurrence should correspond to an elementary data
+ * we run twice:
+ * - first to determine the type, and allocate the object
+ * - second (if ok), to actually read data
+ */
+ ok = FALSE;
+ iter_on_list_children_run( reader, list, str );
+
+ /* if type not found, then suppose that we have an action
+ */
+ if( !reader->private->type_found ){
+ reader->private->item = NA_OBJECT_ITEM( na_object_action_new());
+ }
+
+ /* now load the data
+ */
+ if( reader->private->item ){
+
+ ok = TRUE;
+ iter_on_elements_list( reader );
+
+ if( ok ){
+ gchar *id = na_object_get_id( reader->private->item );
+ if( !id || !strlen( id )){
+ ok = FALSE;
+ add_message( reader, ERR_ID_NOT_FOUND );
+ }
+ g_free( id );
+ }
+
+ if( ok ){
+ gchar *label = na_object_get_label( reader->private->item );
+ if( !label || !g_utf8_strlen( label, -1 )){
+ ok = FALSE;
+ add_message( reader, ERR_ITEM_LABEL_NOT_FOUND );
+ }
+ g_free( label );
+ }
+
+ if( !ok ){
+ g_object_unref( reader->private->item );
+ reader->private->item = NULL;
+ }
+ }
+}
+
+/*
+ * iter on list child nodes
+ * each 'schema' node should correspond to an elementary data of the imported item
+ * other nodes are warned (and ignored)
+ */
+static void
+iter_on_list_children_run( NAXMLReader *reader, xmlNode *list, RootNodeStr *str )
+{
+ xmlNode *iter;
+
+ for( iter = list->children ; iter ; iter = iter->next ){
+
+ if( iter->type != XML_ELEMENT_NODE ){
+ continue;
+ }
+
+ if( strxcmp( iter->name, str->element_key )){
+ add_message( reader,
+ ERR_NODE_UNKNOWN,
+ ( const char * ) iter->name, iter->line, str->element_key );
+ continue;
+ }
+
+ reset_element_data( reader );
+
+ if( str->fn_element_parms ){
+ ( *str->fn_element_parms )( reader, iter );
+ }
+
+ if( str->fn_element_content ){
+ ( *str->fn_element_content )( reader, iter );
+ }
+
+ if( !reader->private->applyto_key || !reader->private->iddef ){
+ reader->private->ok = FALSE;
+ }
+
+ if( reader->private->ok ){
+
+ NAXMLElementStr *str = g_new0( NAXMLElementStr, 1 );
+ str->key_path = g_strdup( reader->private->applyto_key );
+ str->key_value = g_strdup( reader->private->applyto_value );
+ str->iddef = reader->private->iddef;
+ reader->private->elements = g_list_prepend( reader->private->elements, str );
+ }
+ }
+}
+
+static void
+iter_on_elements_list( NAXMLReader *reader )
+{
+ GList *ielt;
+ gboolean idset;
+ gboolean err;
+
+ idset = FALSE;
+ err = FALSE;
+
+ for( ielt = reader->private->elements ; ielt && !err ; ielt = ielt->next ){
+
+ NAXMLElementStr *str = ( NAXMLElementStr * ) ielt->data;
+ GSList *path_slist = na_core_utils_slist_from_split( str->key_path, "/" );
+ gchar **path_elts = g_strsplit( str->key_path, "/", -1 );
+ guint path_length = g_slist_length( path_slist );
+ g_debug( "path=%s, length=%d", str->key_path, path_length );
+ /* path=/apps/nautilus-actions/configurations/0af5a47e-96d9-441c-a3b8-d1185ced0351/version, length=6 */
+ /* path=/apps/nautilus-actions/configurations/0af5a47e-96d9-441c-a3b8-d1185ced0351/profile-main/schemes, length=7 */
+
+ if( !idset ){
+ na_object_set_id( reader->private->item, path_elts[ PATH_ID_IDX ] );
+ idset = TRUE;
+ gchar *id = na_object_get_id( reader->private->item );
+ g_debug( "id=%s", id );
+ g_free( id );
+ }
+
+ g_debug( "iddef=%p, name=%s, value=%s",
+ ( void * ) str->iddef, str->iddef ? str->iddef->name : "(null)", str->key_value );
+
+ /* this is for the action or menu body
+ */
+ if( path_length == 2+PATH_ID_IDX ){
+ na_idata_factory_set_from_string( NA_IDATA_FACTORY( reader->private->item ), str->iddef->id, str->key_value );
+
+ /* this is for a profile
+ */
+ } else {
+ if( path_length != 3+PATH_ID_IDX ){
+ add_message( reader, ERR_PATH_LENGTH, str->key_path );
+ err = TRUE;
+
+ } else if( !NA_IS_OBJECT_ACTION( reader->private->item )){
+ add_message( reader, ERR_MENU_UNWAITED, str->key_path );
+ err = TRUE;
+
+ } else {
+ gchar *profile_name = g_strdup( path_elts[ 1+PATH_ID_IDX] );
+ NAObjectProfile *profile = ( NAObjectProfile * ) na_object_get_item( reader->private->item, profile_name );
+ if( !profile ){
+ profile = na_object_profile_new();
+ na_object_set_id( profile, profile_name );
+ na_object_action_attach_profile( NA_OBJECT_ACTION( reader->private->item ), profile );
+ }
+ na_idata_factory_set_from_string( NA_IDATA_FACTORY( profile ), str->iddef->id, str->key_value );
+ g_free( profile_name );
+ }
+ }
+
+ na_core_utils_slist_free( path_slist );
+ g_strfreev( path_elts );
+ }
+
+ if( err ){
+ g_object_unref( reader->private->item );
+ reader->private->item = NULL;
+ }
+}
+
+/*
+ * first run: only search for a 'Type' key, and allocate the item
+ * this suppose that the entry 'key' is found _before_ the 'applyto' one
+ * second run: load data
+ */
+static void
+reader_parse_schema_schema_content( NAXMLReader *reader, xmlNode *schema )
+{
+ xmlNode *iter;
+ NAXMLKeyStr *str;
+ int i;
+
+ for( iter = schema->children ; iter && reader->private->ok ; iter = iter->next ){
+
+ if( iter->type != XML_ELEMENT_NODE ){
+ continue;
+ }
+
+ str = NULL;
+ for( i = 0 ; naxml_schema_key_schema_str[i].key && !str ; ++i ){
+ if( !strxcmp( iter->name, naxml_schema_key_schema_str[i].key )){
+ str = naxml_schema_key_schema_str+i;
+ }
+ }
+
+ if( str ){
+ if( str->reader_found ){
+ add_message( reader,
+ ERR_NODE_ALREADY_FOUND,
+ ( const char * ) iter->name, iter->line );
+ reader->private->ok = FALSE;
+
+ } else {
+ str->reader_found = TRUE;
+
+ if( !strxcmp( iter->name, NAXML_KEY_SCHEMA_NODE_APPLYTO )){
+ xmlChar *text = xmlNodeGetContent( iter );
+ reader->private->applyto_key = g_strdup(( const gchar * ) text );
+ xmlFree( text );
+
+ gchar *entry = g_path_get_basename( reader->private->applyto_key );
+
+ if( !strcmp( entry, NAGP_ENTRY_TYPE )){
+ reader->private->type_found = TRUE;
+ gchar *type = get_default_value( iter->parent );
+
+ if( !strcmp( type, NAGP_VALUE_TYPE_ACTION )){
+ reader->private->item = NA_OBJECT_ITEM( na_object_action_new());
+
+ } else if( !strcmp( type, NAGP_VALUE_TYPE_MENU )){
+ reader->private->item = NA_OBJECT_ITEM( na_object_menu_new());
+
+ } else {
+ add_message( reader, ERR_NODE_UNKNOWN_TYPE, type, iter->line );
+ reader->private->ok = FALSE;
+ }
+ g_free( type );
+ }
+
+ set_schema_applyto_value( reader, iter->parent, entry );
+
+ g_free( entry );
+ }
+ }
+
+ } else {
+ gchar *node_list = build_key_node_list( naxml_schema_key_schema_str );
+ add_message( reader,
+ ERR_NODE_UNKNOWN,
+ ( const char * ) iter->name, iter->line, node_list );
+ g_free( node_list );
+ reader->private->ok = FALSE;
+ }
+ }
+}
+
+static void
+set_schema_applyto_value( NAXMLReader *reader, xmlNode *node, const gchar *entry )
+{
+ gchar *value;
+
+ NadfIdType *iddef = na_iio_factory_get_idtype_from_gconf_key( entry );
+ if( iddef ){
+ reader->private->iddef = iddef;
+ g_debug( "%s: localizable=%s", iddef->name, iddef->localizable ? "True":"False" );
+ if( iddef->localizable ){
+ value = get_locale_default_value( node );
+ } else {
+ value = get_default_value( node );
+ }
+ reader->private->applyto_value = value;
+ }
+}
+
+static gchar *
+get_default_value( xmlNode *node )
+{
+ gchar *value = NULL;
+
+ xmlNode *default_node = search_for_child_node( node, NAXML_KEY_SCHEMA_NODE_DEFAULT );
+ if( default_node ){
+ xmlChar *default_value = xmlNodeGetContent( default_node );
+ if( default_value ){
+ value = g_strdup(( const char * ) default_value );
+ xmlFree( default_value );
+ }
+ }
+
+ return( value );
+}
+
+static gchar *
+get_locale_default_value( xmlNode *node )
+{
+ gchar *value = NULL;
+
+ xmlNode *locale = search_for_child_node( node, NAXML_KEY_SCHEMA_NODE_LOCALE );
+ if( locale ){
+ xmlNode *default_node = search_for_child_node( locale, NAXML_KEY_SCHEMA_NODE_LOCALE_DEFAULT );
+ if( default_node ){
+ xmlChar *default_value = xmlNodeGetContent( default_node );
+ if( default_value ){
+ value = g_strdup(( const char * ) default_value );
+ xmlFree( default_value );
+ }
+ }
+ }
+
+ return( value );
+}
+
+static xmlNode *
+search_for_child_node( xmlNode *node, const gchar *key )
+{
+ xmlNode *iter;
+
+ for( iter = node->children ; iter ; iter = iter->next ){
+ if( iter->type == XML_ELEMENT_NODE ){
+ if( !strxcmp( iter->name, key )){
+ return( iter );
+ }
+ }
+ }
+
+ return( NULL );
+}
+
+static gchar *
+build_key_node_list( NAXMLKeyStr *strlist )
+{
+ NAXMLKeyStr *next;
+
+ NAXMLKeyStr *istr = strlist;
+ GString *string = g_string_new( "" );
+
+ while( istr->key ){
+ next = istr+1;
+ if( string->len ){
+ if( next->key ){
+ string = g_string_append( string, ", " );
+ } else {
+ string = g_string_append( string, " or " );
+ }
+ }
+ string = g_string_append( string, istr->key );
+ istr++;
+ }
+
+ return( g_string_free( string, FALSE ));
+}
+
+/*
+ * first run: do nothing
+ * second run: get the id
+ */
+static void
+reader_parse_dump_list_parms( NAXMLReader *reader, xmlNode *node )
+{
+
+}
+
+/*
+ * first_run: only search for a 'Type' key, and allocate the item
+ * second run: load data
+ */
+static void
+reader_parse_dump_entry_content( NAXMLReader *reader, xmlNode *node )
+{
+}
+
+#if 0
+/*
* iter points to the 'schemalist' node (already checked)
* children should only be 'schema' nodes ; other nodes are warned,
* but not fatal
*/
static void
-gconf_reader_parse_schemalist( NactXMLReader *reader, xmlNode *schema )
+reader_parse_schemalist( NAXMLReader *reader, xmlNode *schema )
{
- static const gchar *thisfn = "gconf_reader_parse_schemalist";
+ static const gchar *thisfn = "reader_parse_schemalist";
xmlNode *iter;
gboolean ok = TRUE;
@@ -437,14 +1032,14 @@ gconf_reader_parse_schemalist( NactXMLReader *reader, xmlNode *schema )
continue;
}
- if( strxcmp( iter->name, NACT_GCONF_SCHEMA_ENTRY )){
+ if( strxcmp( iter->name, NAXML_KEY_SCHEMA_ENTRY )){
add_message( reader,
ERR_WAITED_IGNORED_NODE,
- NACT_GCONF_SCHEMA_ENTRY, ( const char * ) iter->name, iter->line );
+ NAXML_KEY_SCHEMA_ENTRY, ( const char * ) iter->name, iter->line );
continue;
}
- if( !gconf_reader_parse_schema( reader, iter )){
+ if( !reader_parse_schema( reader, iter )){
add_message( reader, ERR_IGNORED_SCHEMA, iter->line );
}
}
@@ -491,9 +1086,9 @@ gconf_reader_parse_schemalist( NactXMLReader *reader, xmlNode *schema )
* Returns TRUE if the node has been successfully parsed, FALSE else.
*/
static gboolean
-gconf_reader_parse_schema( NactXMLReader *reader, xmlNode *schema )
+reader_parse_schema( NAXMLReader *reader, xmlNode *schema )
{
- static const gchar *thisfn = "gconf_reader_parse_schema";
+ static const gchar *thisfn = "reader_parse_schema";
xmlNode *iter;
gboolean ret = TRUE;
gboolean applyto = FALSE;
@@ -514,23 +1109,23 @@ gconf_reader_parse_schema( NactXMLReader *reader, xmlNode *schema )
continue;
}
- if( strxcmp( iter->name, NACT_GCONF_SCHEMA_KEY ) &&
- strxcmp( iter->name, NACT_GCONF_SCHEMA_APPLYTO ) &&
- strxcmp( iter->name, NACT_GCONF_SCHEMA_OWNER ) &&
- strxcmp( iter->name, NACT_GCONF_SCHEMA_TYPE ) &&
- strxcmp( iter->name, NACT_GCONF_SCHEMA_LIST_TYPE ) &&
- strxcmp( iter->name, NACT_GCONF_SCHEMA_LOCALE ) &&
- strxcmp( iter->name, NACT_GCONF_SCHEMA_DEFAULT )){
+ if( strxcmp( iter->name, NAXML_KEY_SCHEMA_KEY ) &&
+ strxcmp( iter->name, NAXML_KEY_SCHEMA_APPLYTO ) &&
+ strxcmp( iter->name, NAXML_KEY_SCHEMA_OWNER ) &&
+ strxcmp( iter->name, NAXML_KEY_SCHEMA_TYPE ) &&
+ strxcmp( iter->name, NAXML_KEY_SCHEMA_LIST_TYPE ) &&
+ strxcmp( iter->name, NAXML_KEY_SCHEMA_LOCALE ) &&
+ strxcmp( iter->name, NAXML_KEY_SCHEMA_DEFAULT )){
add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
ret = FALSE;
continue;
}
- if( !strxcmp( iter->name, NACT_GCONF_SCHEMA_KEY ) ||
- !strxcmp( iter->name, NACT_GCONF_SCHEMA_OWNER ) ||
- !strxcmp( iter->name, NACT_GCONF_SCHEMA_TYPE ) ||
- !strxcmp( iter->name, NACT_GCONF_SCHEMA_LIST_TYPE )){
+ if( !strxcmp( iter->name, NAXML_KEY_SCHEMA_KEY ) ||
+ !strxcmp( iter->name, NAXML_KEY_SCHEMA_OWNER ) ||
+ !strxcmp( iter->name, NAXML_KEY_SCHEMA_TYPE ) ||
+ !strxcmp( iter->name, NAXML_KEY_SCHEMA_LIST_TYPE )){
pre_v1_11 = TRUE;
continue;
@@ -555,7 +1150,7 @@ gconf_reader_parse_schema( NactXMLReader *reader, xmlNode *schema )
continue;
}
- if( !strxcmp( iter->name, NACT_GCONF_SCHEMA_APPLYTO )){
+ if( !strxcmp( iter->name, NAXML_KEY_SCHEMA_APPLYTO )){
if( applyto ){
add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
@@ -563,13 +1158,13 @@ gconf_reader_parse_schema( NactXMLReader *reader, xmlNode *schema )
}
applyto = TRUE;
- ret = gconf_reader_parse_applyto( reader, iter );
+ ret = reader_parse_applyto( reader, iter );
}
}
if( !applyto ){
g_assert( ret );
- add_message( reader, ERR_NODE_NOT_FOUND, NACT_GCONF_SCHEMA_APPLYTO );
+ add_message( reader, ERR_NODE_NOT_FOUND, NAXML_KEY_SCHEMA_APPLYTO );
ret = FALSE;
}
@@ -586,7 +1181,7 @@ gconf_reader_parse_schema( NactXMLReader *reader, xmlNode *schema )
continue;
}
- if( !strxcmp( iter->name, NACT_GCONF_SCHEMA_LOCALE )){
+ if( !strxcmp( iter->name, NAXML_KEY_SCHEMA_LOCALE )){
if( locale_found ){
add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
@@ -595,11 +1190,11 @@ gconf_reader_parse_schema( NactXMLReader *reader, xmlNode *schema )
} else {
locale_found = TRUE;
if( reader->private->locale_waited ){
- ret = gconf_reader_parse_locale( reader, iter );
+ ret = reader_parse_locale( reader, iter );
}
}
- } else if( !strxcmp( iter->name, NACT_GCONF_SCHEMA_DEFAULT )){
+ } else if( !strxcmp( iter->name, NAXML_KEY_SCHEMA_DEFAULT )){
if( default_found ){
add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
@@ -609,7 +1204,7 @@ gconf_reader_parse_schema( NactXMLReader *reader, xmlNode *schema )
default_found = TRUE;
if( !reader->private->locale_waited ||
( pre_v1_11 && !strcmp( reader->private->entry, ACTION_PROFILE_LABEL_ENTRY ))){
- gconf_reader_parse_default( reader, iter );
+ reader_parse_default( reader, iter );
}
}
}
@@ -629,9 +1224,9 @@ gconf_reader_parse_schema( NactXMLReader *reader, xmlNode *schema )
}
static gboolean
-gconf_reader_parse_applyto( NactXMLReader *reader, xmlNode *node )
+reader_parse_applyto( NAXMLReader *reader, xmlNode *node )
{
- static const gchar *thisfn = "gconf_reader_parse_applyto";
+ static const gchar *thisfn = "reader_parse_applyto";
gboolean ret = TRUE;
xmlChar *text;
gchar *uuid;
@@ -678,7 +1273,7 @@ gconf_reader_parse_applyto( NactXMLReader *reader, xmlNode *node )
entry = get_entry_from_key(( const gchar * ) text );
g_assert( entry && strlen( entry ));
- ret = gconf_reader_check_for_entry( reader, node, entry );
+ ret = reader_check_for_entry( reader, node, entry );
}
g_free( entry );
@@ -690,9 +1285,9 @@ gconf_reader_parse_applyto( NactXMLReader *reader, xmlNode *node )
}
static gboolean
-gconf_reader_check_for_entry( NactXMLReader *reader, xmlNode *node, const char *entry )
+reader_check_for_entry( NAXMLReader *reader, xmlNode *node, const char *entry )
{
- static const gchar *thisfn = "gconf_reader_check_for_entry";
+ static const gchar *thisfn = "reader_check_for_entry";
gboolean ret = TRUE;
gboolean found = FALSE;
int i;
@@ -733,9 +1328,9 @@ gconf_reader_check_for_entry( NactXMLReader *reader, xmlNode *node, const char *
* this node
*/
static gboolean
-gconf_reader_parse_locale( NactXMLReader *reader, xmlNode *locale )
+reader_parse_locale( NAXMLReader *reader, xmlNode *locale )
{
- static const gchar *thisfn = "gconf_reader_parse_locale";
+ static const gchar *thisfn = "reader_parse_locale";
gboolean ret = TRUE;
xmlNode *iter;
gboolean default_found = FALSE;
@@ -748,17 +1343,17 @@ gconf_reader_parse_locale( NactXMLReader *reader, xmlNode *locale )
continue;
}
- if( strxcmp( iter->name, NACT_GCONF_SCHEMA_SHORT ) &&
- strxcmp( iter->name, NACT_GCONF_SCHEMA_LONG ) &&
- strxcmp( iter->name, NACT_GCONF_SCHEMA_DEFAULT )){
+ if( strxcmp( iter->name, NAXML_KEY_SCHEMA_SHORT ) &&
+ strxcmp( iter->name, NAXML_KEY_SCHEMA_LONG ) &&
+ strxcmp( iter->name, NAXML_KEY_SCHEMA_DEFAULT )){
add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
ret = FALSE;
continue;
}
- if( !strxcmp( iter->name, NACT_GCONF_SCHEMA_SHORT ) ||
- !strxcmp( iter->name, NACT_GCONF_SCHEMA_LONG )){
+ if( !strxcmp( iter->name, NAXML_KEY_SCHEMA_SHORT ) ||
+ !strxcmp( iter->name, NAXML_KEY_SCHEMA_LONG )){
continue;
}
@@ -770,14 +1365,14 @@ gconf_reader_parse_locale( NactXMLReader *reader, xmlNode *locale )
g_assert( ret );
default_found = TRUE;
- gconf_reader_parse_default( reader, iter );
+ reader_parse_default( reader, iter );
}
return( ret );
}
static void
-gconf_reader_parse_default( NactXMLReader *reader, xmlNode *node )
+reader_parse_default( NAXMLReader *reader, xmlNode *node )
{
xmlChar *text;
gchar *value;
@@ -799,7 +1394,7 @@ gconf_reader_parse_default( NactXMLReader *reader, xmlNode *node )
}
xmlFree( text );
- /*g_debug( "gconf_reader_parse_default: set value=%s", reader->private->value );*/
+ /*g_debug( "reader_parse_default: set value=%s", reader->private->value );*/
}
/*
@@ -824,10 +1419,16 @@ get_profile_name_from_schema_key( const gchar *key, const gchar *uuid )
return( profile_name );
}
+/*
+ * parse a XML gconf dump
+ * root = "gconfentryfile" (already tested)
+ * +- have one descendant node "entrylist"
+ * | +- have one descendant node per key "entry"
+ */
static void
-gconf_reader_parse_dump_root( NactXMLReader *reader, xmlNode *root )
+reader_parse_dump_root( NAXMLReader *reader, xmlNode *root )
{
- static const gchar *thisfn = "gconf_reader_parse_dump_root";
+ static const gchar *thisfn = "reader_parse_dump_root";
xmlNodePtr iter;
gboolean found = FALSE;
@@ -838,10 +1439,10 @@ gconf_reader_parse_dump_root( NactXMLReader *reader, xmlNode *root )
if( iter->type != XML_ELEMENT_NODE ){
continue;
}
- if( strxcmp( iter->name, NACT_GCONF_DUMP_ENTRYLIST )){
+ if( strxcmp( iter->name, NAXML_KEY_DUMP_ENTRYLIST )){
add_message( reader,
ERR_WAITED_IGNORED_NODE,
- NACT_GCONF_DUMP_ENTRYLIST, ( const char * ) iter->name, iter->line );
+ NAXML_KEY_DUMP_ENTRYLIST, ( const char * ) iter->name, iter->line );
continue;
}
if( found ){
@@ -850,7 +1451,7 @@ gconf_reader_parse_dump_root( NactXMLReader *reader, xmlNode *root )
}
found = TRUE;
- gconf_reader_parse_entrylist( reader, iter );
+ reader_parse_entrylist( reader, iter );
}
}
@@ -860,9 +1461,9 @@ gconf_reader_parse_dump_root( NactXMLReader *reader, xmlNode *root )
* but not fatal
*/
static void
-gconf_reader_parse_entrylist( NactXMLReader *reader, xmlNode *entrylist )
+reader_parse_entrylist( NAXMLReader *reader, xmlNode *entrylist )
{
- static const gchar *thisfn = "gconf_reader_parse_entrylist";
+ static const gchar *thisfn = "reader_parse_entrylist";
xmlChar *path;
gchar *uuid, *label;
gboolean ok;
@@ -870,7 +1471,7 @@ gconf_reader_parse_entrylist( NactXMLReader *reader, xmlNode *entrylist )
g_debug( "%s: reader=%p, entrylist=%p", thisfn, ( void * ) reader, ( void * ) entrylist );
reader->private->action = na_object_action_new();
- path = xmlGetProp( entrylist, ( const xmlChar * ) NACT_GCONF_DUMP_ENTRYLIST_BASE );
+ path = xmlGetProp( entrylist, ( const xmlChar * ) NAXML_KEY_DUMP_ENTRYLIST_BASE );
uuid = na_gconf_utils_path_to_key(( const gchar * ) path );
/*g_debug( "%s: uuid=%s", thisfn, uuid );*/
@@ -894,14 +1495,14 @@ gconf_reader_parse_entrylist( NactXMLReader *reader, xmlNode *entrylist )
continue;
}
- if( strxcmp( iter->name, NACT_GCONF_DUMP_ENTRY )){
+ if( strxcmp( iter->name, NAXML_KEY_DUMP_ENTRY )){
add_message( reader,
ERR_WAITED_IGNORED_NODE,
- NACT_GCONF_DUMP_ENTRY, ( const char * ) iter->name, iter->line );
+ NAXML_KEY_DUMP_ENTRY, ( const char * ) iter->name, iter->line );
continue;
}
- if( !gconf_reader_parse_entry( reader, iter )){
+ if( !reader_parse_entry( reader, iter )){
add_message( reader, ERR_IGNORED_SCHEMA, iter->line );
}
}
@@ -920,9 +1521,9 @@ gconf_reader_parse_entrylist( NactXMLReader *reader, xmlNode *entrylist )
}
static gboolean
-gconf_reader_parse_entry( NactXMLReader *reader, xmlNode *entry )
+reader_parse_entry( NAXMLReader *reader, xmlNode *entry )
{
- static const gchar *thisfn = "gconf_reader_parse_entry";
+ static const gchar *thisfn = "reader_parse_entry";
xmlNode *iter;
gboolean ret = TRUE;
gboolean key_found = FALSE;
@@ -940,8 +1541,8 @@ gconf_reader_parse_entry( NactXMLReader *reader, xmlNode *entry )
if( iter->type != XML_ELEMENT_NODE ){
continue;
}
- if( strxcmp( iter->name, NACT_GCONF_DUMP_KEY ) &&
- strxcmp( iter->name, NACT_GCONF_DUMP_VALUE )){
+ if( strxcmp( iter->name, NAXML_KEY_DUMP_KEY ) &&
+ strxcmp( iter->name, NAXML_KEY_DUMP_VALUE )){
add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
ret = FALSE;
@@ -959,7 +1560,7 @@ gconf_reader_parse_entry( NactXMLReader *reader, xmlNode *entry )
if( iter->type != XML_ELEMENT_NODE ){
continue;
}
- if( !strxcmp( iter->name, NACT_GCONF_DUMP_KEY )){
+ if( !strxcmp( iter->name, NAXML_KEY_DUMP_KEY )){
if( key_found ){
add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
@@ -967,14 +1568,14 @@ gconf_reader_parse_entry( NactXMLReader *reader, xmlNode *entry )
} else {
key_found = TRUE;
- ret = gconf_reader_parse_dump_key( reader, iter );
+ ret = reader_parse_dump_key( reader, iter );
}
}
}
if( !key_found ){
g_assert( ret );
- add_message( reader, ERR_NODE_NOT_FOUND, NACT_GCONF_DUMP_KEY );
+ add_message( reader, ERR_NODE_NOT_FOUND, NAXML_KEY_DUMP_KEY );
ret = FALSE;
}
@@ -989,7 +1590,7 @@ gconf_reader_parse_entry( NactXMLReader *reader, xmlNode *entry )
if( iter->type != XML_ELEMENT_NODE ){
continue;
}
- if( !strxcmp( iter->name, NACT_GCONF_DUMP_VALUE )){
+ if( !strxcmp( iter->name, NAXML_KEY_DUMP_VALUE )){
if( value_found ){
add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
@@ -997,7 +1598,7 @@ gconf_reader_parse_entry( NactXMLReader *reader, xmlNode *entry )
} else {
value_found = TRUE;
- gconf_reader_parse_dump_value( reader, iter );
+ reader_parse_dump_value( reader, iter );
}
}
}
@@ -1016,9 +1617,9 @@ gconf_reader_parse_entry( NactXMLReader *reader, xmlNode *entry )
}
static gboolean
-gconf_reader_parse_dump_key( NactXMLReader *reader, xmlNode *node )
+reader_parse_dump_key( NAXMLReader *reader, xmlNode *node )
{
- static const gchar *thisfn = "gconf_reader_parse_dump_key";
+ static const gchar *thisfn = "reader_parse_dump_key";
gboolean ret = TRUE;
xmlChar *text;
gchar *profile = NULL;
@@ -1044,7 +1645,7 @@ gconf_reader_parse_dump_key( NactXMLReader *reader, xmlNode *node )
entry = get_entry_from_key(( const gchar * ) text );
g_assert( entry && strlen( entry ));
- ret = gconf_reader_check_for_entry( reader, node, entry );
+ ret = reader_check_for_entry( reader, node, entry );
}
g_free( entry );
@@ -1055,7 +1656,7 @@ gconf_reader_parse_dump_key( NactXMLReader *reader, xmlNode *node )
}
static void
-gconf_reader_parse_dump_value( NactXMLReader *reader, xmlNode *node )
+reader_parse_dump_value( NAXMLReader *reader, xmlNode *node )
{
xmlNode *iter;
for( iter = node->children ; iter ; iter = iter->next ){
@@ -1063,13 +1664,13 @@ gconf_reader_parse_dump_value( NactXMLReader *reader, xmlNode *node )
if( iter->type != XML_ELEMENT_NODE ){
continue;
}
- if( strxcmp( iter->name, NACT_GCONF_DUMP_LIST ) &&
- strxcmp( iter->name, NACT_GCONF_DUMP_STRING )){
+ if( strxcmp( iter->name, NAXML_KEY_DUMP_LIST ) &&
+ strxcmp( iter->name, NAXML_KEY_DUMP_STRING )){
add_message( reader,
ERR_IGNORED_NODE, ( const char * ) iter->name, iter->line );
continue;
}
- if( !strxcmp( iter->name, NACT_GCONF_DUMP_STRING )){
+ if( !strxcmp( iter->name, NAXML_KEY_DUMP_STRING )){
xmlChar *text = xmlNodeGetContent( iter );
@@ -1082,12 +1683,12 @@ gconf_reader_parse_dump_value( NactXMLReader *reader, xmlNode *node )
xmlFree( text );
continue;
}
- gconf_reader_parse_dump_value_list( reader, iter );
+ reader_parse_dump_value_list( reader, iter );
}
}
static void
-gconf_reader_parse_dump_value_list( NactXMLReader *reader, xmlNode *list_node )
+reader_parse_dump_value_list( NAXMLReader *reader, xmlNode *list_node )
{
xmlNode *iter;
for( iter = list_node->children ; iter ; iter = iter->next ){
@@ -1095,12 +1696,12 @@ gconf_reader_parse_dump_value_list( NactXMLReader *reader, xmlNode *list_node )
if( iter->type != XML_ELEMENT_NODE ){
continue;
}
- if( strxcmp( iter->name, NACT_GCONF_DUMP_VALUE )){
+ if( strxcmp( iter->name, NAXML_KEY_DUMP_VALUE )){
add_message( reader,
ERR_IGNORED_NODE, ( const char * ) iter->name, iter->line );
continue;
}
- gconf_reader_parse_dump_value( reader, iter );
+ reader_parse_dump_value( reader, iter );
}
}
@@ -1123,9 +1724,9 @@ get_profile_name_from_dump_key( const gchar *key )
}
static void
-apply_values( NactXMLReader *reader )
+apply_values( NAXMLReader *reader )
{
- static const gchar *thisfn = "nact_xml_reader_apply_values";
+ static const gchar *thisfn = "naxml_reader_apply_values";
g_debug( "%s: reader=%p, entry=%s, value=%s",
thisfn, ( void * ) reader, reader->private->entry, reader->private->value );
@@ -1211,14 +1812,15 @@ apply_values( NactXMLReader *reader )
}
}
}
+#endif
static void
-add_message( NactXMLReader *reader, const gchar *format, ... )
+add_message( NAXMLReader *reader, const gchar *format, ... )
{
va_list va;
gchar *tmp;
- g_debug( "nact_xml_reader_add_message: format=%s", format );
+ g_debug( "naxml_reader_add_message: format=%s", format );
va_start( va, format );
tmp = g_markup_vprintf_escaped( format, va );
@@ -1241,8 +1843,9 @@ strxcmp( const xmlChar *a, const char *b )
return( ret );
}
+#if 0
static gchar *
-get_uuid_from_key( NactXMLReader *reader, const gchar *key, guint line )
+get_uuid_from_key( NAXMLReader *reader, const gchar *key, guint line )
{
gchar *uuid, *pos;
@@ -1281,38 +1884,59 @@ get_entry_from_key( const gchar *key )
gchar *entry = pos ? g_strdup( pos+1 ) : g_strdup( key );
return( entry );
}
+#endif
+/*
+ * data are reset before first run on nodes for an item
+ */
static void
-free_reader_values( NactXMLReader *reader )
+reset_element_data( NAXMLReader *reader )
{
int i;
- reader->private->profile = NULL;
- reader->private->locale_waited = FALSE;
+ for( i=0 ; naxml_schema_key_schema_str[i].key ; ++i ){
+ naxml_schema_key_schema_str[i].reader_found = FALSE;
+ }
- g_free( reader->private->entry );
- reader->private->entry = NULL;
+ reader->private->ok = TRUE;
- g_free( reader->private->value );
- reader->private->value = NULL;
+ g_free( reader->private->applyto_key );
+ reader->private->applyto_key = NULL;
- na_utils_free_string_list( reader->private->list_value );
- reader->private->list_value = NULL;
+ g_free( reader->private->applyto_value );
+ reader->private->applyto_value = NULL;
- for( i=0 ; reader_str[i].entry ; ++i ){
- reader_str[i].entry_found = FALSE;
- }
+ reader->private->iddef = NULL;
+}
+
+/*
+ * reset here static data which should be reset before each object
+ * (so, obviously, not reader data as a new reader is reallocated
+ * for each import operation)
+ */
+static void
+reset_item_data( NAXMLReader *reader )
+{
+}
+
+static void
+free_naxml_element_str( NAXMLElementStr *str, void *data )
+{
+ g_free( str->key_path );
+ g_free( str->key_value );
+ g_free( str );
}
/*
* returns TRUE if we can safely insert the action
- * - the uuid doesn't already exist
- * - the uuid already exist, but import mode is renumber
- * - the uuid already exists, but import mode is override
+ * - the id doesn't already exist
+ * - the id already exist, but import mode is renumber
+ * - the id already exists, but import mode is override
*/
static gboolean
-manage_import_mode( NactXMLReader *reader )
+manage_import_mode( NAXMLReader *reader )
{
+#if 0
NAObjectItem *exists;
gchar *uuid;
BaseApplication *appli;
@@ -1368,10 +1992,13 @@ manage_import_mode( NactXMLReader *reader )
g_free( uuid );
return( ret );
+#endif
+ return( TRUE );
}
+#if 0
static void
-propagate_default_values( NactXMLReader *reader )
+propagate_default_values( NAXMLReader *reader )
{
gchar *action_label, *toolbar_label;
gboolean same_label;
@@ -1392,7 +2019,7 @@ propagate_default_values( NactXMLReader *reader )
}
static NAObjectItem *
-search_in_auxiliaries( NactXMLReader *reader, const gchar *uuid )
+search_in_auxiliaries( NAXMLReader *reader, const gchar *uuid )
{
NAObjectItem *action;
gchar *aux_uuid;
@@ -1413,7 +2040,7 @@ search_in_auxiliaries( NactXMLReader *reader, const gchar *uuid )
* set a new label because the action has been renumbered
*/
static void
-relabel( NactXMLReader *reader )
+relabel( NAXMLReader *reader )
{
gchar *label, *tmp;
@@ -1427,3 +2054,4 @@ relabel( NactXMLReader *reader )
g_free( tmp );
g_free( label );
}
+#endif
diff --git a/src/io-xml/naxml-reader.h b/src/io-xml/naxml-reader.h
new file mode 100644
index 0000000..657ad39
--- /dev/null
+++ b/src/io-xml/naxml-reader.h
@@ -0,0 +1,76 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010 Pierre Wieser and others (see AUTHORS)
+ *
+ * This Program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifndef __NAXML_READER_H__
+#define __NAXML_READER_H__
+
+/**
+ * SECTION: naxml_reader
+ * @short_description: #NAXMLReader class definition.
+ * @include: naxml-reader.h
+ *
+ * This is the base class for importing items from XML files.
+ */
+
+#include <api/na-iimporter.h>
+#include <api/na-object-item.h>
+
+G_BEGIN_DECLS
+
+#define NAXML_READER_TYPE ( naxml_reader_get_type())
+#define NAXML_READER( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NAXML_READER_TYPE, NAXMLReader ))
+#define NAXML_READER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NAXML_READER_TYPE, NAXMLReaderClass ))
+#define NAXML_IS_READER( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NAXML_READER_TYPE ))
+#define NAXML_IS_READER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NAXML_READER_TYPE ))
+#define NAXML_READER_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NAXML_READER_TYPE, NAXMLReaderClass ))
+
+typedef struct NAXMLReaderPrivate NAXMLReaderPrivate;
+
+typedef struct {
+ GObject parent;
+ NAXMLReaderPrivate *private;
+}
+ NAXMLReader;
+
+typedef struct NAXMLReaderClassPrivate NAXMLReaderClassPrivate;
+
+typedef struct {
+ GObjectClass parent;
+ NAXMLReaderClassPrivate *private;
+}
+ NAXMLReaderClass;
+
+GType naxml_reader_get_type( void );
+
+NAObjectItem *naxml_reader_import_uri( const NAIImporter *instance, const gchar *uri, guint mode, ImporterCheckFn fn, void *fn_data, GSList **messages );
+
+G_END_DECLS
+
+#endif /* __NAXML_READER_H__ */
diff --git a/src/nact/Makefile.am b/src/nact/Makefile.am
index f85e94f..72ef636 100644
--- a/src/nact/Makefile.am
+++ b/src/nact/Makefile.am
@@ -34,6 +34,7 @@ egg_platform_defines = -DEGG_SM_CLIENT_BACKEND_XSMP
AM_CPPFLAGS += \
-I $(top_srcdir) \
+ -I $(top_srcdir)/src \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DPKGDATADIR=\"$(pkgdatadir)\" \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_NACT}\" \
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index 3e30723..7a739d1 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -482,22 +482,22 @@ set_import_mode( NactAssistantImport *window, gint mode )
GtkToggleButton *button;
switch( mode ){
- case IPREFS_IMPORT_ASK:
+ case IMPORTER_MODE_ASK:
button = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "AskButton" ));
gtk_toggle_button_set_active( button, TRUE );
break;
- case IPREFS_IMPORT_RENUMBER:
+ case IMPORTER_MODE_RENUMBER:
button = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "RenumberButton" ));
gtk_toggle_button_set_active( button, TRUE );
break;
- case IPREFS_IMPORT_OVERRIDE:
+ case IMPORTER_MODE_OVERRIDE:
button = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "OverrideButton" ));
gtk_toggle_button_set_active( button, TRUE );
break;
- case IPREFS_IMPORT_NO_IMPORT:
+ case IMPORTER_MODE_NO_IMPORT:
default:
button = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "NoImportButton" ));
gtk_toggle_button_set_active( button, TRUE );
@@ -580,13 +580,13 @@ get_import_mode( NactAssistantImport *window )
override_button = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "OverrideButton" ));
ask_button = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "AskButton" ));
- mode = IPREFS_IMPORT_NO_IMPORT;
+ mode = IMPORTER_MODE_NO_IMPORT;
if( gtk_toggle_button_get_active( renumber_button )){
- mode = IPREFS_IMPORT_RENUMBER;
+ mode = IMPORTER_MODE_RENUMBER;
} else if( gtk_toggle_button_get_active( override_button )){
- mode = IPREFS_IMPORT_OVERRIDE;
+ mode = IMPORTER_MODE_OVERRIDE;
} else if( gtk_toggle_button_get_active( ask_button )){
- mode = IPREFS_IMPORT_ASK;
+ mode = IMPORTER_MODE_ASK;
}
return( mode );
@@ -605,22 +605,22 @@ add_import_mode( NactAssistantImport *window, const gchar *text )
result = NULL;
switch( mode ){
- case IPREFS_IMPORT_NO_IMPORT:
+ case IMPORTER_MODE_NO_IMPORT:
label1 = g_strdup( gtk_button_get_label( GTK_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "NoImportButton" ))));
label2 = g_strdup( gtk_label_get_text( GTK_LABEL( base_window_get_widget( BASE_WINDOW( window ), "NoImportLabel"))));
break;
- case IPREFS_IMPORT_RENUMBER:
+ case IMPORTER_MODE_RENUMBER:
label1 = g_strdup( gtk_button_get_label( GTK_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "RenumberButton" ))));
label2 = g_strdup( gtk_label_get_text( GTK_LABEL( base_window_get_widget( BASE_WINDOW( window ), "RenumberLabel"))));
break;
- case IPREFS_IMPORT_OVERRIDE:
+ case IMPORTER_MODE_OVERRIDE:
label1 = g_strdup( gtk_button_get_label( GTK_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "OverrideButton" ))));
label2 = g_strdup( gtk_label_get_text( GTK_LABEL( base_window_get_widget( BASE_WINDOW( window ), "OverrideLabel"))));
break;
- case IPREFS_IMPORT_ASK:
+ case IMPORTER_MODE_ASK:
label1 = g_strdup( gtk_button_get_label( GTK_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "AskButton" ))));
label2 = g_strdup( gtk_label_get_text( GTK_LABEL( base_window_get_widget( BASE_WINDOW( window ), "AskLabel"))));
break;
@@ -656,6 +656,8 @@ assistant_apply( BaseAssistant *wnd, GtkAssistant *assistant )
GList *items;
BaseWindow *mainwnd;
gint mode;
+ NactApplication *application;
+ NAUpdater *updater;
g_debug( "%s: window=%p, assistant=%p", thisfn, ( void * ) wnd, ( void * ) assistant );
g_assert( NACT_IS_ASSISTANT_IMPORT( wnd ));
@@ -667,6 +669,9 @@ assistant_apply( BaseAssistant *wnd, GtkAssistant *assistant )
g_object_get( G_OBJECT( wnd ), BASE_WINDOW_PROP_PARENT, &mainwnd, NULL );
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( wnd )));
+ updater = nact_application_get_updater( application );
+
/* import actions
* getting results in the same order than uris
* simultaneously building the actions list
@@ -675,7 +680,7 @@ assistant_apply( BaseAssistant *wnd, GtkAssistant *assistant )
for( is = uris ; is ; is = is->next ){
msg = NULL;
- item = na_importer_import( items, ( const gchar * ) is->data, mode, &msg );
+ item = na_importer_import( NA_PIVOT( updater ), ( const gchar * ) is->data, mode, NULL, NULL, &msg );
str = g_new0( ImportUriStruct, 1 );
str->uri = g_strdup(( const gchar * ) is->data );
diff --git a/src/nact/nact-import-ask.c b/src/nact/nact-import-ask.c
index d4ba257..9f6e802 100644
--- a/src/nact/nact-import-ask.c
+++ b/src/nact/nact-import-ask.c
@@ -35,6 +35,7 @@
#include <glib/gi18n.h>
#include <api/na-object-api.h>
+#include <api/na-iimporter.h>
#include <core/na-iprefs.h>
@@ -243,7 +244,7 @@ nact_import_ask_user( NactMainWindow *parent, const gchar *uri, NAObjectItem *it
gint mode;
g_debug( "%s: parent=%p", thisfn, ( void * ) parent );
- g_return_val_if_fail( BASE_IS_WINDOW( parent ), IPREFS_IMPORT_NO_IMPORT );
+ g_return_val_if_fail( BASE_IS_WINDOW( parent ), IMPORTER_MODE_NO_IMPORT );
editor = import_ask_new( BASE_WINDOW( parent ));
editor->private->parent = parent;
@@ -307,15 +308,15 @@ on_base_runtime_init_dialog( NactImportAsk *editor, gpointer user_data )
g_free( label );
switch( editor->private->mode ){
- case IPREFS_IMPORT_RENUMBER:
+ case IMPORTER_MODE_RENUMBER:
button = base_window_get_widget( BASE_WINDOW( editor ), "AskRenumberButton" );
break;
- case IPREFS_IMPORT_OVERRIDE:
+ case IMPORTER_MODE_OVERRIDE:
button = base_window_get_widget( BASE_WINDOW( editor ), "AskOverrideButton" );
break;
- case IPREFS_IMPORT_NO_IMPORT:
+ case IMPORTER_MODE_NO_IMPORT:
default:
button = base_window_get_widget( BASE_WINDOW( editor ), "AskNoImportButton" );
break;
@@ -368,14 +369,14 @@ get_mode( NactImportAsk *editor )
GtkWidget *button;
gboolean keep;
- import_mode = IPREFS_IMPORT_NO_IMPORT;
+ import_mode = IMPORTER_MODE_NO_IMPORT;
button = base_window_get_widget( BASE_WINDOW( editor ), "AskRenumberButton" );
if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ))){
- import_mode = IPREFS_IMPORT_RENUMBER;
+ import_mode = IMPORTER_MODE_RENUMBER;
} else {
button = base_window_get_widget( BASE_WINDOW( editor ), "AskOverrideButton" );
if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ))){
- import_mode = IPREFS_IMPORT_OVERRIDE;
+ import_mode = IMPORTER_MODE_OVERRIDE;
}
}
@@ -404,7 +405,7 @@ base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
case GTK_RESPONSE_CLOSE:
case GTK_RESPONSE_CANCEL:
- editor->private->mode = IPREFS_IMPORT_NO_IMPORT;
+ editor->private->mode = IMPORTER_MODE_NO_IMPORT;
return( TRUE );
break;
diff --git a/src/nact/nact-iprefs.c b/src/nact/nact-iprefs.c
index 95dcb35..0ee856a 100644
--- a/src/nact/nact-iprefs.c
+++ b/src/nact/nact-iprefs.c
@@ -34,6 +34,7 @@
#endif
#include <api/na-gconf-utils.h>
+#include <api/na-iimporter.h>
#include <core/na-iprefs.h>
@@ -46,14 +47,14 @@ struct NactIPrefsInterfacePrivate {
GConfClient *client;
};
-#define DEFAULT_IMPORT_MODE_INT IPREFS_IMPORT_NO_IMPORT
+#define DEFAULT_IMPORT_MODE_INT IMPORTER_MODE_NO_IMPORT
#define DEFAULT_IMPORT_MODE_STR "NoImport"
static GConfEnumStringPair import_mode_table[] = {
- { IPREFS_IMPORT_NO_IMPORT, DEFAULT_IMPORT_MODE_STR },
- { IPREFS_IMPORT_RENUMBER, "Renumber" },
- { IPREFS_IMPORT_OVERRIDE, "Override" },
- { IPREFS_IMPORT_ASK, "Ask" },
+ { IMPORTER_MODE_NO_IMPORT, DEFAULT_IMPORT_MODE_STR },
+ { IMPORTER_MODE_RENUMBER, "Renumber" },
+ { IMPORTER_MODE_OVERRIDE, "Override" },
+ { IMPORTER_MODE_ASK, "Ask" },
{ 0, NULL }
};
diff --git a/src/nact/nact-preferences-editor.c b/src/nact/nact-preferences-editor.c
index 2208f58..1e05641 100644
--- a/src/nact/nact-preferences-editor.c
+++ b/src/nact/nact-preferences-editor.c
@@ -32,6 +32,8 @@
#include <config.h>
#endif
+#include <api/na-iimporter.h>
+
#include <core/na-iprefs.h>
#include "nact-application.h"
@@ -369,19 +371,19 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
*/
import_mode = nact_iprefs_get_import_mode( BASE_WINDOW( editor ), IPREFS_IMPORT_ITEMS_IMPORT_MODE );
switch( import_mode ){
- case IPREFS_IMPORT_ASK:
+ case IMPORTER_MODE_ASK:
button = base_window_get_widget( BASE_WINDOW( editor ), "PrefsAskButton" );
break;
- case IPREFS_IMPORT_RENUMBER:
+ case IMPORTER_MODE_RENUMBER:
button = base_window_get_widget( BASE_WINDOW( editor ), "PrefsRenumberButton" );
break;
- case IPREFS_IMPORT_OVERRIDE:
+ case IMPORTER_MODE_OVERRIDE:
button = base_window_get_widget( BASE_WINDOW( editor ), "PrefsOverrideButton" );
break;
- case IPREFS_IMPORT_NO_IMPORT:
+ case IMPORTER_MODE_NO_IMPORT:
default:
button = base_window_get_widget( BASE_WINDOW( editor ), "PrefsNoImportButton" );
break;
@@ -525,18 +527,18 @@ save_preferences( NactPreferencesEditor *editor )
/* third tab: import tool
*/
- import_mode = IPREFS_IMPORT_NO_IMPORT;
+ import_mode = IMPORTER_MODE_NO_IMPORT;
button = base_window_get_widget( BASE_WINDOW( editor ), "PrefsRenumberButton" );
if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ))){
- import_mode = IPREFS_IMPORT_RENUMBER;
+ import_mode = IMPORTER_MODE_RENUMBER;
} else {
button = base_window_get_widget( BASE_WINDOW( editor ), "PrefsOverrideButton" );
if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ))){
- import_mode = IPREFS_IMPORT_OVERRIDE;
+ import_mode = IMPORTER_MODE_OVERRIDE;
} else {
button = base_window_get_widget( BASE_WINDOW( editor ), "PrefsAskButton" );
if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ))){
- import_mode = IPREFS_IMPORT_ASK;
+ import_mode = IMPORTER_MODE_ASK;
}
}
}
diff --git a/src/nact/nact-tree-model-dnd.c b/src/nact/nact-tree-model-dnd.c
index db2e128..de6e0be 100644
--- a/src/nact/nact-tree-model-dnd.c
+++ b/src/nact/nact-tree-model-dnd.c
@@ -748,13 +748,15 @@ drop_uri_list( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData *selec
gboolean drop_done = FALSE;
GSList *uri_list, *is, *msg;
NactApplication *application;
+ NAUpdater *updater;
gint import_mode;
NAObjectItem *item;
NactMainWindow *main_window;
- GList *object_list;
GtkTreePath *new_dest;
+ GList *object_list;
application = NACT_APPLICATION( base_window_get_application( model->private->window ));
+ updater = nact_application_get_updater( application );
main_window = NACT_MAIN_WINDOW( base_application_get_main_window( BASE_APPLICATION( application )));
model->private->drag_has_profiles = FALSE;
@@ -765,14 +767,16 @@ drop_uri_list( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData *selec
uri_list = g_slist_reverse( na_core_utils_slist_from_split(( const gchar * ) selection_data->data, "\n" ));
import_mode = nact_iprefs_get_import_mode( BASE_WINDOW( main_window ), IPREFS_IMPORT_ITEMS_IMPORT_MODE );
-
object_list = NULL;
+
for( is = uri_list ; is ; is = is->next ){
item = na_importer_import(
- object_list,
+ NA_PIVOT( updater ),
( const gchar * ) is->data,
import_mode,
+ NULL,
+ NULL,
&msg );
if( msg ){
diff --git a/src/plugin-menu/Makefile.am b/src/plugin-menu/Makefile.am
index 2390777..caaa763 100644
--- a/src/plugin-menu/Makefile.am
+++ b/src/plugin-menu/Makefile.am
@@ -28,6 +28,7 @@
AM_CPPFLAGS += \
-I $(top_srcdir) \
+ -I $(top_srcdir)/src \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_PLUGIN}\" \
$(NAUTILUS_ACTIONS_CFLAGS) \
$(NULL)
diff --git a/src/plugin-tracker/Makefile.am b/src/plugin-tracker/Makefile.am
index 229075e..f121d48 100644
--- a/src/plugin-tracker/Makefile.am
+++ b/src/plugin-tracker/Makefile.am
@@ -28,6 +28,7 @@
AM_CPPFLAGS += \
-I $(top_srcdir) \
+ -I $(top_srcdir)/src \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_TRACKER}\" \
$(NAUTILUS_ACTIONS_CFLAGS) \
$(NULL)
diff --git a/src/test/.gitignore b/src/test/.gitignore
index e68d8df..03dd33a 100644
--- a/src/test/.gitignore
+++ b/src/test/.gitignore
@@ -1,5 +1,6 @@
test-include
test-parse-uris
+test-reader
test-virtuals
test-virtuals-without-test
test-iface
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index 9408117..874d83b 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -27,6 +27,7 @@
# ... and many others (see AUTHORS)
noinst_PROGRAMS = \
+ test-reader \
test-iface \
test-include \
test-parse-uris \
@@ -36,11 +37,21 @@ noinst_PROGRAMS = \
AM_CPPFLAGS += \
-I $(top_srcdir) \
+ -I $(top_srcdir)/src \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_TEST}\" \
$(NAUTILUS_ACTIONS_CFLAGS) \
$(NULL)
+test_reader_SOURCES = \
+ test-reader.c \
+ $(NULL)
+
+test_reader_LDADD = \
+ $(top_builddir)/src/core/libna-core.la \
+ $(NAUTILUS_ACTIONS_LIBS) \
+ $(NULL)
+
test_iface_SOURCES = \
test-iface.c \
test-iface-iface.c \
diff --git a/src/test/test-reader.c b/src/test/test-reader.c
new file mode 100755
index 0000000..8b48310
--- /dev/null
+++ b/src/test/test-reader.c
@@ -0,0 +1,51 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010 Pierre Wieser and others (see AUTHORS)
+ *
+ * This Program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#include <api/na-core-utils.h>
+
+#include <core/na-pivot.h>
+#include <core/na-importer.h>
+
+int
+main( int argc, char **argv )
+{
+ g_type_init();
+
+ NAPivot *pivot = na_pivot_new( PIVOT_LOAD_NONE );
+ GSList *msg = NULL;
+ gchar *uri = "file:///net/pierre/eclipse/nautilus-actions/exports/config_0af5a47e-96d9-441c-a3b8-d1185ced0351.schemas";
+ NAObjectItem *item = na_importer_import( pivot, uri, IMPORTER_MODE_ASK, NULL, NULL, &msg );
+ if( item ){
+ na_object_dump( item );
+ g_object_unref( item );
+ }
+ na_core_utils_slist_dump( msg );
+ return( 0 );
+}
diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am
index 6193b2d..2d1607b 100644
--- a/src/utils/Makefile.am
+++ b/src/utils/Makefile.am
@@ -34,6 +34,7 @@ bin_PROGRAMS = \
AM_CPPFLAGS += \
-I $(top_srcdir) \
+ -I $(top_srcdir)/src \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_UTILS}\" \
$(NAUTILUS_ACTIONS_CFLAGS) \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]