[nautilus-actions] Refactoring: rename src/core/na-object-profile-class.h to src/api/na-object-profile.h



commit e7b4683f13b07c0b521a334d20b692e37ac0df6e
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Feb 15 17:47:26 2010 +0100

    Refactoring: rename src/core/na-object-profile-class.h to src/api/na-object-profile.h

 ChangeLog                                          |    1 +
 src/api/Makefile.am                                |    1 +
 .../na-object-profile.h}                           |   36 +-
 src/core/Makefile.am                               |    1 +
 src/core/na-object-profile.c                       | 1616 ++++----------------
 5 files changed, 344 insertions(+), 1311 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7beab25..70b7eb6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2009-02-15 Pierre Wieser <pwieser trychlos org>
 
+	Rename src/core/na-object-profile-class.h to src/api/na-object-profile.h
 	Rename src/core/na-object-action-class.h to src/api/na-object-action.h
 	Rename src/core/na-object-item-class.h to src/api/na-object-item.h
 	Rename src/core/na-object-id-class.h to src/api/na-object-id.h
diff --git a/src/api/Makefile.am b/src/api/Makefile.am
index 12d4608..fad7334 100644
--- a/src/api/Makefile.am
+++ b/src/api/Makefile.am
@@ -43,5 +43,6 @@ api_include_HEADERS = \
 	na-object-id.h										\
 	na-object-item.h									\
 	na-object-action.h									\
+	na-object-profile.h									\
 	na-gconf-keys.h										\
 	$(NULL)
diff --git a/src/core/na-object-profile-class.h b/src/api/na-object-profile.h
similarity index 69%
rename from src/core/na-object-profile-class.h
rename to src/api/na-object-profile.h
index a11d73e..d491ae2 100644
--- a/src/core/na-object-profile-class.h
+++ b/src/api/na-object-profile.h
@@ -28,22 +28,19 @@
  *   ... and many others (see AUTHORS)
  */
 
-#ifndef __NAUTILUS_ACTIONS_NA_PRIVATE_OBJECT_PROFILE_CLASS_H__
-#define __NAUTILUS_ACTIONS_NA_PRIVATE_OBJECT_PROFILE_CLASS_H__
+#ifndef __NAUTILUS_ACTIONS_API_NA_OBJECT_PROFILE_H__
+#define __NAUTILUS_ACTIONS_API_NA_OBJECT_PROFILE_H__
 
 /**
  * SECTION: na_object_profile
  * @short_description: #NAObjectProfile class definition.
- * @include: nautilus-actions/private/na-object-profile-class.h
+ * @include: nautilus-actions/na-object-item.h
  *
- * This is a companion class of NAObjectAction. It embeds the profile
- * definition of an action.
- *
- * As NAObjectAction itself, NAObjectProfile class is derived from
- * NAObject class, which takes care of IDuplicable interface management.
+ * This is a pure virtual class, i.e. not an instantiatable one, but
+ * serves as the base class for #NAObjectAction and #NAObjectMenu.
  */
 
-#include "na-object-id-class.h"
+#include "na-object-id.h"
 
 G_BEGIN_DECLS
 
@@ -54,7 +51,7 @@ G_BEGIN_DECLS
 #define NA_IS_OBJECT_PROFILE_CLASS( klass )		( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_OBJECT_PROFILE_TYPE ))
 #define NA_OBJECT_PROFILE_GET_CLASS( object )	( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_OBJECT_PROFILE_TYPE, NAObjectProfileClass ))
 
-typedef struct NAObjectProfilePrivate NAObjectProfilePrivate;
+typedef struct NAObjectProfilePrivate      NAObjectProfilePrivate;
 
 typedef struct {
 	NAObjectId              parent;
@@ -70,17 +67,16 @@ typedef struct {
 }
 	NAObjectProfileClass;
 
-GType na_object_profile_get_type( void );
+GType            na_object_profile_get_type( void );
 
-/* a structure used by the org.nautilus_actions.DBus service,
- * in its Tracker.Status interface
- */
-typedef struct {
-	gchar *uri;
-	gchar *mimetype;
-}
-	NATrackedItem;
+NAObjectProfile *na_object_profile_new( void );
+
+gboolean         na_object_profile_is_candidate                ( const NAObjectProfile *profile, gint target, GList *files );
+gboolean         na_object_profile_is_candidate_for_tracked    ( const NAObjectProfile *profile, GList *tracked );
+
+gchar           *na_object_profile_parse_parameters            ( const NAObjectProfile *profile, gint target, GList *files );
+gchar           *na_object_profile_parse_parameters_for_tracked( const NAObjectProfile *profile, GList *tracked );
 
 G_END_DECLS
 
-#endif /* __NAUTILUS_ACTIONS_NA_PRIVATE_OBJECT_PROFILE_CLASS_H__ */
+#endif /* __NAUTILUS_ACTIONS_API_NA_OBJECT_PROFILE_H__ */
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 55f634a..115275e 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -46,6 +46,7 @@ libna_core_la_SOURCES = \
 	na-object-id.c										\
 	na-object-item.c									\
 	na-object-action.c									\
+	na-object-profile.c									\
 	\
 	na-iabout.c											\
 	na-iabout.h											\
diff --git a/src/core/na-object-profile.c b/src/core/na-object-profile.c
index e91267e..9dd9c1a 100644
--- a/src/core/na-object-profile.c
+++ b/src/core/na-object-profile.c
@@ -34,85 +34,67 @@
 
 #include <string.h>
 
+#include <glib/gi18n.h>
+
 #include <libnautilus-extension/nautilus-file-info.h>
 
+#include <api/na-core-utils.h>
+#include <api/na-idata-factory.h>
 #include <api/na-object-api.h>
 
-#include <runtime/na-utils.h>
-
-#include "na-iduplicable.h"
-#include "na-object-profile-priv.h"
+#include "na-io-factory.h"
+#include "na-data-factory.h"
+#include "na-dbus.h"
 #include "na-gnome-vfs-uri.h"
 
 /* private class data
  */
 struct NAObjectProfileClassPrivate {
-	void *empty;						/* so that gcc -pedantic is happy */
+	void *empty;							/* so that gcc -pedantic is happy */
 };
 
-/* profile properties
+/* private instance data
  */
-enum {
-	NAPROFILE_PROP_PATH_ID = 1,
-	NAPROFILE_PROP_PARAMETERS_ID,
-	NAPROFILE_PROP_BASENAMES_ID,
-	NAPROFILE_PROP_MATCHCASE_ID,
-	NAPROFILE_PROP_MIMETYPES_ID,
-	NAPROFILE_PROP_ISFILE_ID,
-	NAPROFILE_PROP_ISDIR_ID,
-	NAPROFILE_PROP_ACCEPT_MULTIPLE_ID,
-	NAPROFILE_PROP_SCHEMES_ID,
-	NAPROFILE_PROP_FOLDERS_ID
+struct NAObjectProfilePrivate {
+	gboolean dispose_has_run;
 };
 
-#define NAPROFILE_PROP_PATH					"na-profile-path"
-#define NAPROFILE_PROP_PARAMETERS			"na-profile-parameters"
-#define NAPROFILE_PROP_BASENAMES			"na-profile-basenames"
-#define NAPROFILE_PROP_MATCHCASE			"na-profile-matchcase"
-#define NAPROFILE_PROP_MIMETYPES			"na-profile-mimetypes"
-#define NAPROFILE_PROP_ISFILE				"na-profile-isfile"
-#define NAPROFILE_PROP_ISDIR				"na-profile-isdir"
-#define NAPROFILE_PROP_ACCEPT_MULTIPLE		"na-profile-accept-multiple"
-#define NAPROFILE_PROP_SCHEMES				"na-profile-schemes"
-#define NAPROFILE_PROP_FOLDERS				"na-profile-folders"
-
-static NAObjectClass *st_parent_class = NULL;
-
-static GType     register_type( void );
-static void      class_init( NAObjectProfileClass *klass );
-static void      instance_init( GTypeInstance *instance, gpointer klass );
-static void      instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
-static void      instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
-static void      instance_dispose( GObject *object );
-static void      instance_finalize( GObject *object );
-
-static gboolean  is_target_background_candidate( const NAObjectProfile *profile, NautilusFileInfo *current_folder );
-static gboolean  is_target_toolbar_candidate( const NAObjectProfile *profile, NautilusFileInfo *current_folder );
-static gboolean  is_current_folder_inside( const NAObjectProfile *profile, NautilusFileInfo *current_folder );
-static gboolean  is_target_selection_candidate( const NAObjectProfile *profile, GList *files, gboolean from_nautilus );
-static gboolean  tracked_is_directory( void *iter, gboolean from_nautilus );
-static gchar    *tracked_to_basename( void *iter, gboolean from_nautilus );
-static GFile    *tracked_to_location( void *iter, gboolean from_nautilus );
-static gchar    *tracked_to_scheme( void *iter, gboolean from_nautilus );
-static gchar    *tracked_to_mimetype( void *iter, gboolean from_nautilus );
-static gchar    *tracked_to_uri( void *iter, gboolean from_nautilus );
-static int       validate_schemes( GSList *schemes2test, void *iter, gboolean from_nautilus );
-static gchar    *parse_parameters( const NAObjectProfile *profile, gint target, GList* files, gboolean from_nautilus );
-
-static void      object_dump( const NAObject *profile );
-static void      object_dump_list( const gchar *thisfn, const gchar *label, GSList *list );
-static NAObject *object_new( const NAObject *profile );
-static void      object_copy( NAObject *target, const NAObject *source );
-static gboolean  object_are_equal( const NAObject *a, const NAObject *b );
-static gboolean  object_is_valid( const NAObject *profile );
-static gboolean  is_valid_path_parameters( const NAObjectProfile *profile );
-static gboolean  is_valid_filenames( const NAObjectProfile *profile );
-static gboolean  is_valid_mimetypes( const NAObjectProfile *profile );
-static gboolean  is_valid_isfiledir( const NAObjectProfile *profile );
-static gboolean  is_valid_schemes( const NAObjectProfile *profile );
-static gboolean  is_valid_folders( const NAObjectProfile *profile );
-
-static gchar    *object_id_new_id( const NAObjectId *object, const NAObjectId *new_parent );
+											/* i18n: default label for a new profile */
+#define DEFAULT_PROFILE						N_( "Default profile" )
+
+#define PROFILE_NAME_PREFIX					"profile-"
+
+extern NadfIdGroup profile_id_groups [];	/* defined in na-item-profile-enum.c */
+
+static NAObjectIdClass *st_parent_class = NULL;
+
+static GType    register_type( void );
+static void     class_init( NAObjectProfileClass *klass );
+static void     instance_init( GTypeInstance *instance, gpointer klass );
+static void     instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
+static void     instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
+static void     instance_dispose( GObject *object );
+static void     instance_finalize( GObject *object );
+
+static void     idata_factory_iface_init( NAIDataFactoryInterface *iface );
+static guint    idata_factory_get_version( const NAIDataFactory *instance );
+static gchar   *idata_factory_get_default( const NAIDataFactory *instance, const NadfIdType *iddef );
+static void     idata_factory_read_done( NAIDataFactory *instance, const NAIIOFactory *reader, void *reader_data, GSList **messages );
+static void     idata_factory_write_done( NAIDataFactory *instance, const NAIIOFactory *writer, void *writer_data, GSList **messages );
+
+static gboolean is_target_background_candidate( const NAObjectProfile *profile, NautilusFileInfo *current_folder );
+static gboolean is_target_toolbar_candidate( const NAObjectProfile *profile, NautilusFileInfo *current_folder );
+static gboolean is_current_folder_inside( const NAObjectProfile *profile, NautilusFileInfo *current_folder );
+static gboolean is_target_selection_candidate( const NAObjectProfile *profile, GList *files, gboolean from_nautilus );
+
+static gchar   *parse_parameters( const NAObjectProfile *profile, gint target, GList* files, gboolean from_nautilus );
+static gboolean tracked_is_directory( void *iter, gboolean from_nautilus );
+static gchar   *tracked_to_basename( void *iter, gboolean from_nautilus );
+static GFile   *tracked_to_location( void *iter, gboolean from_nautilus );
+static gchar   *tracked_to_mimetype( void *iter, gboolean from_nautilus );
+static gchar   *tracked_to_scheme( void *iter, gboolean from_nautilus );
+static gchar   *tracked_to_uri( void *iter, gboolean from_nautilus );
+static int      validate_schemes( GSList *schemes2test, void *iter, gboolean from_nautilus );
 
 GType
 na_object_profile_get_type( void )
@@ -130,6 +112,7 @@ static GType
 register_type( void )
 {
 	static const gchar *thisfn = "na_object_profile_register_type";
+	GType type;
 
 	static GTypeInfo info = {
 		sizeof( NAObjectProfileClass ),
@@ -143,9 +126,21 @@ register_type( void )
 		( GInstanceInitFunc ) instance_init
 	};
 
+	static const GInterfaceInfo idata_factory_iface_info = {
+		( GInterfaceInitFunc ) idata_factory_iface_init,
+		NULL,
+		NULL
+	};
+
 	g_debug( "%s", thisfn );
 
-	return( g_type_register_static( NA_OBJECT_ID_TYPE, "NAObjectProfile", &info, 0 ));
+	type = g_type_register_static( NA_OBJECT_ID_TYPE, "NAObjectProfile", &info, 0 );
+
+	g_type_add_interface_static( type, NA_IDATA_FACTORY_TYPE, &idata_factory_iface_info );
+
+	na_io_factory_register( type, profile_id_groups );
+
+	return( type );
 }
 
 static void
@@ -153,7 +148,6 @@ class_init( NAObjectProfileClass *klass )
 {
 	static const gchar *thisfn = "na_object_profile_class_init";
 	GObjectClass *object_class;
-	GParamSpec *spec;
 	NAObjectClass *naobject_class;
 
 	g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
@@ -161,259 +155,76 @@ class_init( NAObjectProfileClass *klass )
 	st_parent_class = g_type_class_peek_parent( klass );
 
 	object_class = G_OBJECT_CLASS( klass );
-	object_class->dispose = instance_dispose;
-	object_class->finalize = instance_finalize;
 	object_class->set_property = instance_set_property;
 	object_class->get_property = instance_get_property;
+	object_class->dispose = instance_dispose;
+	object_class->finalize = instance_finalize;
 
-	spec = g_param_spec_string(
-			NAPROFILE_PROP_PATH,
-			"Command path",
-			"Command path", "",
-			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
-	g_object_class_install_property( object_class, NAPROFILE_PROP_PATH_ID, spec );
-
-	spec = g_param_spec_string(
-			NAPROFILE_PROP_PARAMETERS,
-			"Command parameters",
-			"Command parameters", "",
-			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
-	g_object_class_install_property( object_class, NAPROFILE_PROP_PARAMETERS_ID, spec );
-
-	spec = g_param_spec_pointer(
-			NAPROFILE_PROP_BASENAMES,
-			"Filenames mask",
-			"Filenames mask",
-			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
-	g_object_class_install_property( object_class, NAPROFILE_PROP_BASENAMES_ID, spec );
-
-	spec = g_param_spec_boolean(
-			NAPROFILE_PROP_MATCHCASE,
-			"Match case",
-			"Whether the filenames are case sensitive", TRUE,
-			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
-	g_object_class_install_property( object_class, NAPROFILE_PROP_MATCHCASE_ID, spec );
-
-	spec = g_param_spec_pointer(
-			NAPROFILE_PROP_MIMETYPES,
-			"Mimetypes",
-			"List of selectable mimetypes",
-			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
-	g_object_class_install_property( object_class, NAPROFILE_PROP_MIMETYPES_ID, spec );
-
-	spec = g_param_spec_boolean(
-			NAPROFILE_PROP_ISFILE,
-			"Only files",
-			"Whether apply when only files are selected", TRUE,
-			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
-	g_object_class_install_property( object_class, NAPROFILE_PROP_ISFILE_ID, spec );
-
-	spec = g_param_spec_boolean(
-			NAPROFILE_PROP_ISDIR,
-			"Only dirs",
-			"Whether apply when only dirs are selected", FALSE,
-			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
-	g_object_class_install_property( object_class, NAPROFILE_PROP_ISDIR_ID, spec );
-
-	spec = g_param_spec_boolean(
-			NAPROFILE_PROP_ACCEPT_MULTIPLE,
-			"Accept multiple selection",
-			"Whether apply when multiple files or folders are selected", TRUE,
-			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
-	g_object_class_install_property( object_class, NAPROFILE_PROP_ACCEPT_MULTIPLE_ID, spec );
-
-	spec = g_param_spec_pointer(
-			NAPROFILE_PROP_SCHEMES,
-			"Schemes",
-			"List of selectable schemes",
-			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
-	g_object_class_install_property( object_class, NAPROFILE_PROP_SCHEMES_ID, spec );
-
-	spec = g_param_spec_pointer(
-			NAPROFILE_PROP_FOLDERS,
-			"Folders",
-			"List of folders to which the item applies",
-			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
-	g_object_class_install_property( object_class, NAPROFILE_PROP_FOLDERS_ID, spec );
+	naobject_class = NA_OBJECT_CLASS( klass );
+	naobject_class->dump = NULL;
+	naobject_class->copy = NULL;
+	naobject_class->are_equal = NULL;
+	naobject_class->is_valid = NULL;
 
 	klass->private = g_new0( NAObjectProfileClassPrivate, 1 );
 
-	naobject_class = NA_OBJECT_CLASS( klass );
-	naobject_class->dump = object_dump;
-	naobject_class->new = object_new;
-	naobject_class->copy = object_copy;
-	naobject_class->are_equal = object_are_equal;
-	naobject_class->is_valid = object_is_valid;
-	naobject_class->get_childs = NULL;
-	naobject_class->ref = NULL;
-	naobject_class->unref = NULL;
-
-	NA_OBJECT_ID_CLASS( klass )->new_id = object_id_new_id;
+	na_data_factory_properties( object_class );
 }
 
 static void
 instance_init( GTypeInstance *instance, gpointer klass )
 {
-	/*static const gchar *thisfn = "na_object_profile_instance_init";*/
+	static const gchar *thisfn = "na_object_profile_instance_init";
 	NAObjectProfile *self;
 
-	/*g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );*/
+	g_debug( "%s: instance=%p (%s), klass=%p",
+			thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ), ( void * ) klass );
+
 	g_return_if_fail( NA_IS_OBJECT_PROFILE( instance ));
+
 	self = NA_OBJECT_PROFILE( instance );
 
 	self->private = g_new0( NAObjectProfilePrivate, 1 );
 
 	self->private->dispose_has_run = FALSE;
 
-	/* initialize suitable default values
-	 */
-	self->private->path = g_strdup( "" );
-	self->private->parameters = g_strdup( "" );
-	self->private->basenames = g_slist_append( NULL, g_strdup( "*" ));
-	self->private->match_case = TRUE;
-	self->private->mimetypes = g_slist_append( NULL, g_strdup( "*/*" ));
-	self->private->is_file = TRUE;
-	self->private->is_dir = FALSE;
-	self->private->accept_multiple = FALSE;
-	self->private->schemes = g_slist_append( NULL, g_strdup( "file" ));
-	self->private->folders = g_slist_append( NULL, g_strdup( "*" ));
+	na_data_factory_init( NA_IDATA_FACTORY( instance ));
 }
 
 static void
 instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec )
 {
-	NAObjectProfile *self;
-	GSList *list;
-
 	g_return_if_fail( NA_IS_OBJECT_PROFILE( object ));
-	self = NA_OBJECT_PROFILE( object );
-
-	if( !self->private->dispose_has_run ){
-
-		switch( property_id ){
-			case NAPROFILE_PROP_PATH_ID:
-				g_value_set_string( value, self->private->path );
-				break;
-
-			case NAPROFILE_PROP_PARAMETERS_ID:
-				g_value_set_string( value, self->private->parameters );
-				break;
-
-			case NAPROFILE_PROP_BASENAMES_ID:
-				list = na_utils_duplicate_string_list( self->private->basenames );
-				g_value_set_pointer( value, list );
-				break;
-
-			case NAPROFILE_PROP_MATCHCASE_ID:
-				g_value_set_boolean( value, self->private->match_case );
-				break;
+	g_return_if_fail( NA_IS_IDATA_FACTORY( object ));
 
-			case NAPROFILE_PROP_MIMETYPES_ID:
-				list = na_utils_duplicate_string_list( self->private->mimetypes );
-				g_value_set_pointer( value, list );
-				break;
-
-			case NAPROFILE_PROP_ISFILE_ID:
-				g_value_set_boolean( value, self->private->is_file );
-				break;
+	if( !NA_OBJECT_PROFILE( object )->private->dispose_has_run ){
 
-			case NAPROFILE_PROP_ISDIR_ID:
-				g_value_set_boolean( value, self->private->is_dir );
-				break;
-
-			case NAPROFILE_PROP_ACCEPT_MULTIPLE_ID:
-				g_value_set_boolean( value, self->private->accept_multiple );
-				break;
-
-			case NAPROFILE_PROP_SCHEMES_ID:
-				list = na_utils_duplicate_string_list( self->private->schemes );
-				g_value_set_pointer( value, list );
-				break;
-
-			case NAPROFILE_PROP_FOLDERS_ID:
-				list = na_utils_duplicate_string_list( self->private->folders );
-				g_value_set_pointer( value, list );
-				break;
-
-			default:
-				G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
-				break;
-		}
+		na_data_factory_set_value( NA_IDATA_FACTORY( object ), property_id, value, spec );
 	}
 }
 
 static void
 instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec )
 {
-	NAObjectProfile *self;
-
 	g_return_if_fail( NA_IS_OBJECT_PROFILE( object ));
-	self = NA_OBJECT_PROFILE( object );
-
-	if( !self->private->dispose_has_run ){
-
-		switch( property_id ){
-			case NAPROFILE_PROP_PATH_ID:
-				g_free( self->private->path );
-				self->private->path = g_value_dup_string( value );
-				break;
-
-			case NAPROFILE_PROP_PARAMETERS_ID:
-				g_free( self->private->parameters );
-				self->private->parameters = g_value_dup_string( value );
-				break;
-
-			case NAPROFILE_PROP_BASENAMES_ID:
-				na_utils_free_string_list( self->private->basenames );
-				self->private->basenames = na_utils_duplicate_string_list( g_value_get_pointer( value ));
-				break;
-
-			case NAPROFILE_PROP_MATCHCASE_ID:
-				self->private->match_case = g_value_get_boolean( value );
-				break;
-
-			case NAPROFILE_PROP_MIMETYPES_ID:
-				na_utils_free_string_list( self->private->mimetypes );
-				self->private->mimetypes = na_utils_duplicate_string_list( g_value_get_pointer( value ));
-				break;
-
-			case NAPROFILE_PROP_ISFILE_ID:
-				self->private->is_file = g_value_get_boolean( value );
-				break;
+	g_return_if_fail( NA_IS_IDATA_FACTORY( object ));
 
-			case NAPROFILE_PROP_ISDIR_ID:
-				self->private->is_dir = g_value_get_boolean( value );
-				break;
-
-			case NAPROFILE_PROP_ACCEPT_MULTIPLE_ID:
-				self->private->accept_multiple = g_value_get_boolean( value );
-				break;
+	if( !NA_OBJECT_PROFILE( object )->private->dispose_has_run ){
 
-			case NAPROFILE_PROP_SCHEMES_ID:
-				na_utils_free_string_list( self->private->schemes );
-				self->private->schemes = na_utils_duplicate_string_list( g_value_get_pointer( value ));
-				break;
-
-			case NAPROFILE_PROP_FOLDERS_ID:
-				na_utils_free_string_list( self->private->folders );
-				self->private->folders = na_utils_duplicate_string_list( g_value_get_pointer( value ));
-				break;
-
-			default:
-				G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
-				break;
-		}
+		na_data_factory_get_value( NA_IDATA_FACTORY( object ), property_id, value, spec );
 	}
 }
 
 static void
 instance_dispose( GObject *object )
 {
-	/*static const gchar *thisfn = "na_object_profile_instance_dispose";*/
+	static const gchar *thisfn = "na_object_profile_instance_dispose";
 	NAObjectProfile *self;
 
-	/*g_debug( "%s: object=%p", thisfn, ( void * ) object );*/
+	g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
+
 	g_return_if_fail( NA_IS_OBJECT_PROFILE( object ));
+
 	self = NA_OBJECT_PROFILE( object );
 
 	if( !self->private->dispose_has_run ){
@@ -430,581 +241,94 @@ instance_dispose( GObject *object )
 static void
 instance_finalize( GObject *object )
 {
-	/*static const gchar *thisfn = "na_object_profile_instance_finalize";*/
+	static const gchar *thisfn = "na_object_profile_instance_finalize";
 	NAObjectProfile *self;
 
-	/*g_debug( "%s: object=%p", thisfn, (void * ) object );*/
+	g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
+
 	g_return_if_fail( NA_IS_OBJECT_PROFILE( object ));
-	self = NA_OBJECT_PROFILE( object );
 
-	g_free( self->private->path );
-	g_free( self->private->parameters );
-	na_utils_free_string_list( self->private->basenames );
-	na_utils_free_string_list( self->private->mimetypes );
-	na_utils_free_string_list( self->private->schemes );
-	na_utils_free_string_list( self->private->folders );
+	self = NA_OBJECT_PROFILE( object );
 
 	g_free( self->private );
 
+	na_data_factory_finalize( NA_IDATA_FACTORY( object ));
+
 	/* chain call to parent class */
 	if( G_OBJECT_CLASS( st_parent_class )->finalize ){
 		G_OBJECT_CLASS( st_parent_class )->finalize( object );
 	}
 }
 
-/**
- * na_object_profile_new:
- *
- * Allocates a new profile of the given name.
- *
- * Returns: the newly allocated #NAObjectProfile profile.
- */
-NAObjectProfile *
-na_object_profile_new( void )
-{
-	NAObjectProfile *profile = g_object_new( NA_OBJECT_PROFILE_TYPE, NULL );
-
-	na_object_set_id( profile, OBJECT_PROFILE_PREFIX "zero" );
-
-	/* i18n: default label for a new profile */
-	na_object_set_label( profile, NA_OBJECT_PROFILE_DEFAULT_LABEL );
-
-	return( profile );
-}
-
-/**
- * na_object_profile_get_path:
- * @profile: the #NAObjectProfile to be requested.
- *
- * Returns the path of the command attached to the profile.
- *
- * Returns: the command path as a newly allocated string. The returned
- * string must be g_free() by the caller.
- */
-gchar *
-na_object_profile_get_path( const NAObjectProfile *profile )
-{
-	gchar *path = NULL;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
-
-	if( !profile->private->dispose_has_run ){
-		g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_PATH, &path, NULL );
-	}
-
-	return( path );
-}
-
-/**
- * na_object_profile_get_parameters:
- * @profile: the #NAObjectProfile to be requested.
- *
- * Returns the parameters of the command attached to the profile.
- *
- * Returns: the command parameters as a newly allocated string. The
- * returned string must be g_free() by the caller.
- */
-gchar *
-na_object_profile_get_parameters( const NAObjectProfile *profile )
-{
-	gchar *parameters = NULL;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
-
-	if( !profile->private->dispose_has_run ){
-		g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_PARAMETERS, &parameters, NULL );
-	}
-
-	return( parameters );
-}
-
-/**
- * na_object_profile_get_basenames:
- * @profile: the #NAObjectProfile to be requested.
- *
- * Returns the basenames of the files to which the profile applies.
- *
- * Returns: a GSList of newly allocated strings. The list must be
- * na_utils_free_string_list() by the caller.
- *
- * See na_object_profile_set_basenames() for some rationale about
- * basenames.
- */
-GSList *
-na_object_profile_get_basenames( const NAObjectProfile *profile )
-{
-	GSList *basenames = NULL;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
-
-	if( !profile->private->dispose_has_run ){
-		g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_BASENAMES, &basenames, NULL );
-	}
-
-	return( basenames );
-}
-
-/**
- * na_object_profile_get_matchcase:
- * @profile: the #NAObjectProfile to be requested.
- *
- * Are specified basenames case sensitive ?
- *
- * Returns: %TRUE if the provided filenames are case sensitive, %FALSE
- * else.
- *
- * See na_object_profile_set_matchcase() for some rationale about case
- * sensitivity.
- */
-gboolean
-na_object_profile_get_matchcase( const NAObjectProfile *profile )
-{
-	gboolean matchcase = FALSE;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
-
-	if( !profile->private->dispose_has_run ){
-		g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_MATCHCASE, &matchcase, NULL );
-	}
-
-	return( matchcase );
-}
-
-/**
- * na_object_profile_get_mimetypes:
- * @profile: the #NAObjectProfile to be requested.
- *
- * Returns the list of mimetypes this profile applies to.
- *
- * Returns: a GSList of newly allocated strings. The list must be
- * na_utils_free_string_list() by the caller.
- *
- * See na_object_profile_set_mimetypes() for some rationale about
- * mimetypes.
- */
-GSList *
-na_object_profile_get_mimetypes( const NAObjectProfile *profile )
-{
-	GSList *mimetypes = NULL;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
-
-	if( !profile->private->dispose_has_run ){
-		g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_MIMETYPES, &mimetypes, NULL );
-	}
-
-	return( mimetypes );
-}
-
-/**
- * na_object_profile_get_is_file:
- * @profile: the #NAObjectProfile to be requested.
- *
- * Does this profile apply if the selection contains files ?
- *
- * Returns: %TRUE if it applies, %FALSE else.
- *
- * See na_object_profile_set_isfiledir() for some rationale about file
- * selection.
- */
-gboolean
-na_object_profile_get_is_file( const NAObjectProfile *profile )
-{
-	gboolean isfile = FALSE;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
-
-	if( !profile->private->dispose_has_run ){
-		g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_ISFILE, &isfile, NULL );
-	}
-
-	return( isfile );
-}
-
-/**
- * na_object_profile_get_is_dir:
- * @profile: the #NAObjectProfile to be requested.
- *
- * Does this profile apply if the selection contains folders ?
- *
- * Returns: %TRUE if it applies, %FALSE else.
- *
- * See na_object_profile_set_isfiledir() for some rationale about file
- * selection.
- */
-gboolean
-na_object_profile_get_is_dir( const NAObjectProfile *profile )
-{
-	gboolean isdir = FALSE;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
-
-	if( !profile->private->dispose_has_run ){
-		g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_ISDIR, &isdir, NULL );
-	}
-
-	return( isdir );
-}
-
-/**
- * na_object_profile_get_multiple:
- * @profile: the #NAObjectProfile to be requested.
- *
- * Does this profile apply if selection contains multiple files or
- * folders ?
- *
- * Returns: %TRUE if it applies, %FALSE else.
- *
- * See na_object_profile_set_multiple() for some rationale about
- * multiple selection.
- */
-gboolean
-na_object_profile_get_multiple( const NAObjectProfile *profile )
-{
-	gboolean multiple = FALSE;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
-
-	if( !profile->private->dispose_has_run ){
-		g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_ACCEPT_MULTIPLE, &multiple, NULL );
-	}
-
-	return( multiple );
-}
-
-/**
- * na_object_profile_get_schemes:
- * @profile: the #NAObjectProfile to be requested.
- *
- * Returns the list of schemes this profile applies to.
- *
- * Returns: a GSList of newly allocated strings. The list must be
- * na_utils_free_string_list() by the caller.
- *
- * See na_object_profile_set_schemes() for some rationale about
- * schemes.
- */
-GSList *
-na_object_profile_get_schemes( const NAObjectProfile *profile )
-{
-	GSList *schemes = NULL;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
-
-	if( !profile->private->dispose_has_run ){
-		g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_SCHEMES, &schemes, NULL );
-	}
-
-	return( schemes );
-}
-
-/**
- * na_object_profile_get_folders:
- * @profile: the #NAObjectProfile to be requested.
- *
- * Returns the list of folders this item applies to.
- *
- * Returns: a GSList of newly allocated strings. The list must be
- * na_utils_free_string_list() by the caller.
- *
- * See na_object_profile_set_folders() for some rationale about
- * folders.
- */
-GSList *
-na_object_profile_get_folders( const NAObjectProfile *profile )
-{
-	GSList *folders = NULL;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
-
-	if( !profile->private->dispose_has_run ){
-
-		g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_FOLDERS, &folders, NULL );
-	}
-
-	return( folders );
-}
-
-/**
- * na_object_profile_set_path:
- * @profile: the #NAObjectProfile to be updated.
- * @path: the command path to be set.
- *
- * Sets the path of the command for this profile.
- *
- * #NAObjectProfile takes a copy of the provided path. This later may
- * so be g_free() by the caller after this function returns.
- */
-void
-na_object_profile_set_path( NAObjectProfile *profile, const gchar *path )
-{
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
-
-	if( !profile->private->dispose_has_run ){
-		g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_PATH, path, NULL );
-	}
-}
-
-/**
- * na_object_profile_set_parameters:
- * @profile: the #NAObjectProfile to be updated.
- * @parameters : the command parameters to be set.
- *
- * Sets the parameters of the command for this profile.
- *
- * #NAObjectProfile takes a copy of the provided parameters. This later
- * may so be g_free() by the caller after this function returns.
- */
-void
-na_object_profile_set_parameters( NAObjectProfile *profile, const gchar *parameters )
-{
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
-
-	if( !profile->private->dispose_has_run ){
-		g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_PARAMETERS, parameters, NULL );
-	}
-}
-
-/**
- * na_object_profile_set_basenames:
- * @profile: the #NAObjectProfile to be updated.
- * @basenames : the basenames to be set.
- *
- * Sets the basenames of the elements on which this profile applies.
- *
- * #NAObjectProfile takes a copy of the provided basenames. This later
- * may so be na_utils_free_string_list() by the caller after this
- * function returns.
- *
- * The basenames list defaults to the single element "*", which means
- * that the profile will apply to all basenames.
- */
-void
-na_object_profile_set_basenames( NAObjectProfile *profile, GSList *basenames )
+static void
+idata_factory_iface_init( NAIDataFactoryInterface *iface )
 {
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
+	static const gchar *thisfn = "na_object_menu_idata_factory_iface_init";
 
-	if( !profile->private->dispose_has_run ){
-		g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_BASENAMES, basenames, NULL );
-	}
-}
+	g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
 
-/**
- * na_object_profile_set_matchcase:
- * @profile: the #NAObjectProfile to be updated.
- * @matchcase : whether the basenames are case sensitive or not.
- *
- * Sets the 'match_case' flag, indicating if specified basename
- * patterns are, or not, case sensitive.
- *
- * This value defaults to %TRUE, which means that basename patterns
- * default to be case sensitive.
- */
-void
-na_object_profile_set_matchcase( NAObjectProfile *profile, gboolean matchcase )
-{
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
-
-	if( !profile->private->dispose_has_run ){
-		g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_MATCHCASE, matchcase, NULL );
-	}
+	iface->get_version = idata_factory_get_version;
+	iface->get_default = idata_factory_get_default;
+	iface->copy = NULL;
+	iface->are_equal = NULL;
+	iface->read_done = idata_factory_read_done;
+	iface->write_done = idata_factory_write_done;
 }
 
-/**
- * na_object_profile_set_mimetypes:
- * @profile: the #NAObjectProfile to be updated.
- * @mimetypes: list of mimetypes to be matched.
- *
- * Sets the mimetypes on which this profile applies.
- *
- * #NAObjectProfile takes a copy of the provided mimetypes. This later
- * may so be na_utils_free_string_list() by the caller after this
- * function returns.
- *
- * The mimetypes list defaults to the single element "* / *", which
- * means that the profile will apply to all types of files.
- */
-void
-na_object_profile_set_mimetypes( NAObjectProfile *profile, GSList *mimetypes )
+static guint
+idata_factory_get_version( const NAIDataFactory *instance )
 {
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
-
-	if( !profile->private->dispose_has_run ){
-		g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_MIMETYPES, mimetypes, NULL );
-	}
+	return( 1 );
 }
 
-/**
- * na_object_profile_set_isfile:
- * @profile: the #NAObjectProfile to be updated.
- * @isfile: whether the profile applies only to files.
- *
- * Sets the 'isfile' flag on which this profile applies.
- */
-void
-na_object_profile_set_isfile( NAObjectProfile *profile, gboolean isfile )
+static gchar *
+idata_factory_get_default( const NAIDataFactory *instance, const NadfIdType *iddef )
 {
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
+	gchar *value;
 
-	if( !profile->private->dispose_has_run ){
-		g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ISFILE, isfile, NULL );
-	}
-}
+	value = NULL;
 
-/**
- * na_object_profile_set_isdir:
- * @profile: the #NAObjectProfile to be updated.
- * @isdir: the profile applies only to folders.
- *
- * Sets the 'isdir' flag on which this profile applies.
- */
-void
-na_object_profile_set_isdir( NAObjectProfile *profile, gboolean isdir )
-{
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
+	switch( iddef->id ){
 
-	if( !profile->private->dispose_has_run ){
-		g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ISDIR, isdir, NULL );
-	}
-}
-
-/**
- * na_object_profile_set_isfiledir:
- * @profile: the #NAObjectProfile to be updated.
- * @isfile: whether the profile applies only to files.
- * @isdir: the profile applies only to folders.
- *
- * Sets the 'isfile' and 'isdir' flags on which this profile applies.
- *
- * File selection defaults to %TRUE.
- *
- * Folder selection defaults to %FALSE, which means that this profile will
- * not apply if the selection contains folders.
- */
-void
-na_object_profile_set_isfiledir( NAObjectProfile *profile, gboolean isfile, gboolean isdir )
-{
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
+		case NADF_DATA_ID:
+			value = g_strdup( PROFILE_NAME_PREFIX "zero" );
+			break;
 
-	if( !profile->private->dispose_has_run ){
-		g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ISFILE, isfile, NAPROFILE_PROP_ISDIR, isdir, NULL );
+		case NADF_DATA_LABEL:
+			value = g_strdup( DEFAULT_PROFILE );
+			break;
 	}
-}
-
-/**
- * na_object_profile_set_multiple:
- * @profile: the #NAObjectProfile to be updated.
- * @multiple: TRUE if it does.
- *
- * Sets if this profile accept multiple selection ?
- *
- * This value defaults to %FALSE, which means that this profile will
- * not apply if the selection contains more than one element.
- */
-void
-na_object_profile_set_multiple( NAObjectProfile *profile, gboolean multiple )
-{
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
 
-	if( !profile->private->dispose_has_run ){
-		g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ACCEPT_MULTIPLE, multiple, NULL );
-	}
+	return( value );
 }
 
-/**
- * na_object_profile_set_scheme:
- * @profile: the #NAObjectProfile to be updated.
- * @scheme: name of the scheme.
- * @selected: whether this scheme is candidate to this profile.
- *
- * Sets the status of a scheme relative to this profile.
- */
-void
-na_object_profile_set_scheme( NAObjectProfile *profile, const gchar *scheme, gboolean selected )
+static void
+idata_factory_read_done( NAIDataFactory *instance, const NAIIOFactory *reader, void *reader_data, GSList **messages )
 {
-	/*static const gchar *thisfn = "na_object_profile_set_scheme";*/
-	gboolean exist;
-
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
 
-	if( !profile->private->dispose_has_run ){
-
-		exist = na_utils_find_in_list( profile->private->schemes, scheme );
-		/*g_debug( "%s: scheme=%s exist=%s", thisfn, scheme, exist ? "True":"False" );*/
-
-		if( selected && !exist ){
-			profile->private->schemes = g_slist_prepend( profile->private->schemes, g_strdup( scheme ));
-		}
-		if( !selected && exist ){
-			profile->private->schemes = na_utils_remove_ascii_from_string_list( profile->private->schemes, scheme );
-		}
-	}
 }
 
-/**
- * na_object_profile_set_schemes:
- * @profile: the #NAObjectProfile to be updated.
- * @schemes: list of schemes which apply.
- *
- * Sets the schemes on which this profile applies.
- *
- * #NAObjectProfile takes a copy of the provided schemes. This later
- * may so be na_utils_free_string_list() by the caller after this
- * function returns.
- *
- * The schemes list defaults to the single element "file", which means
- * that the profile will only apply to local files.
- */
-void
-na_object_profile_set_schemes( NAObjectProfile *profile, GSList *schemes )
+static void
+idata_factory_write_done( NAIDataFactory *instance, const NAIIOFactory *writer, void *writer_data, GSList **messages )
 {
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
 
-	if( !profile->private->dispose_has_run ){
-		g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_SCHEMES, schemes, NULL );
-	}
 }
 
 /**
- * na_object_profile_set_folders:
- * @profile: the #NAObjectProfile to be updated.
- * @folders: list of folders which apply.
- *
- * Sets the folders on which this profile applies.
+ * na_object_profile_new:
  *
- * #NAObjectProfile takes a copy of the provided folders. This later
- * may so be na_utils_free_string_list() by the caller after this
- * function returns.
- */
-void
-na_object_profile_set_folders( NAObjectProfile *profile, GSList *folders )
-{
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
-
-	if( !profile->private->dispose_has_run ){
-
-		g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_FOLDERS, folders, NULL );
-	}
-}
-
-/**
- * na_object_profile_replace_folder_uri:
- * @profile: the #NAObjectProfile to be updated.
- * @old: the old uri.
- * @new: the new uri.
+ * Allocates a new profile.
  *
- * Replaces the @old URI by the @new one.
+ * Returns: the newly allocated #NAObjectProfile profile.
  */
-void
-na_object_profile_replace_folder_uri( NAObjectProfile *profile, const gchar *old, const gchar *new )
+NAObjectProfile *
+na_object_profile_new( void )
 {
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
+	NAObjectProfile *profile;
 
-	if( !profile->private->dispose_has_run ){
+	profile = g_object_new( NA_OBJECT_PROFILE_TYPE, NULL );
 
-		profile->private->folders = na_utils_remove_from_string_list( profile->private->folders, old );
-		profile->private->folders = g_slist_append( profile->private->folders, ( gpointer ) g_strdup( new ));
-	}
+	return( profile );
 }
 
 /**
@@ -1037,6 +361,8 @@ na_object_profile_is_candidate( const NAObjectProfile *profile, gint target, GLi
 		return( FALSE );
 	}
 
+	is_candidate = FALSE;
+
 	switch( target ){
 		case ITEM_TARGET_BACKGROUND:
 			is_candidate = is_target_background_candidate( profile, ( NautilusFileInfo * ) files->data );
@@ -1054,6 +380,39 @@ na_object_profile_is_candidate( const NAObjectProfile *profile, gint target, GLi
 	return( is_candidate );
 }
 
+/**
+ * na_object_profile_is_candidate_for_tracked:
+ * @profile: the #NAObjectProfile to be checked.
+ * @files: the currently selected items, as a list of uris.
+ *
+ * Determines if the given profile is candidate to be displayed in the
+ * Nautilus context menu, regarding the list of currently selected
+ * items.
+ *
+ * Returns: %TRUE if this profile succeeds to all tests and is so a
+ * valid candidate to be displayed in Nautilus context menu, %FALSE
+ * else.
+ *
+ * The case where we only have URIs for target files is when we have
+ * got this list through the org.nautilus_actions.DBus service (or
+ * another equivalent) - typically for use in a command-line tool.
+ */
+gboolean
+na_object_profile_is_candidate_for_tracked( const NAObjectProfile *profile, GList *tracked_items )
+{
+	gboolean is_candidate;
+
+	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
+
+	if( !na_object_is_valid( profile )){
+		return( FALSE );
+	}
+
+	is_candidate = is_target_selection_candidate( profile, tracked_items, FALSE );
+
+	return( is_candidate );
+}
+
 static gboolean
 is_target_background_candidate( const NAObjectProfile *profile, NautilusFileInfo *current_folder )
 {
@@ -1078,14 +437,15 @@ static gboolean
 is_current_folder_inside( const NAObjectProfile *profile, NautilusFileInfo *current_folder )
 {
 	gboolean is_inside;
-	GSList *ifold;
+	GSList *folders, *ifold;
 	const gchar *path;
 	gchar *current_folder_uri;
 
 	is_inside = FALSE;
 	current_folder_uri = nautilus_file_info_get_uri( current_folder );
+	folders = na_object_get_folders( profile );
 
-	for( ifold = profile->private->folders ; ifold && !is_inside ; ifold = ifold->next ){
+	for( ifold = folders ; ifold && !is_inside ; ifold = ifold->next ){
 		path = ( const gchar * ) ifold->data;
 		if( path && g_utf8_strlen( path, -1 )){
 			if( !strcmp( path, "*" )){
@@ -1097,48 +457,18 @@ is_current_folder_inside( const NAObjectProfile *profile, NautilusFileInfo *curr
 		}
 	}
 
+	na_core_utils_slist_free( folders );
 	g_free( current_folder_uri );
 
 	return( is_inside );
 }
 
-/**
- * na_object_profile_is_candidate_for_tracked:
- * @profile: the #NAObjectProfile to be checked.
- * @files: the currently selected items, as a list of uris.
- *
- * Determines if the given profile is candidate to be displayed in the
- * Nautilus context menu, regarding the list of currently selected
- * items.
- *
- * Returns: %TRUE if this profile succeeds to all tests and is so a
- * valid candidate to be displayed in Nautilus context menu, %FALSE
- * else.
- *
- * The case where we only have URIs for target files is when we have
- * got this list through the org.nautilus_actions.DBus service (or
- * another equivalent) - typically for use in a command-line tool.
- */
-gboolean
-na_object_profile_is_candidate_for_tracked( const NAObjectProfile *profile, GList *tracked_items )
-{
-	gboolean is_candidate;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
-
-	if( !na_object_is_valid( profile )){
-		return( FALSE );
-	}
-
-	is_candidate = is_target_selection_candidate( profile, tracked_items, FALSE );
-
-	return( is_candidate );
-}
-
 static gboolean
 is_target_selection_candidate( const NAObjectProfile *profile, GList *files, gboolean from_nautilus )
 {
 	gboolean retv = FALSE;
+	GSList *basenames, *mimetypes, *schemes;
+	gboolean matchcase, multiple, isdir, isfile;
 	gboolean test_multiple_file = FALSE;
 	gboolean test_file_type = FALSE;
 	gboolean test_scheme = FALSE;
@@ -1165,51 +495,52 @@ is_target_selection_candidate( const NAObjectProfile *profile, GList *files, gbo
 		return( FALSE );
 	}
 
-	if (profile->private->basenames && profile->private->basenames->next != NULL &&
-			g_ascii_strcasecmp ((gchar*)(profile->private->basenames->data), "*") == 0)
-	{
+	basenames = na_object_get_basenames( profile );
+	matchcase = na_object_is_matchcase( profile );
+	multiple = na_object_is_multiple( profile );
+	isdir = na_object_is_dir( profile );
+	isfile = na_object_is_file( profile );
+	mimetypes = na_object_get_mimetypes( profile );
+	schemes = na_object_get_schemes( profile );
+
+	if( basenames && basenames->next != NULL &&
+			g_ascii_strcasecmp(( gchar * )( basenames->data ), "*" ) == 0 ){
 		/* if the only pattern is '*' then all files will match, so it
 		 * is not necessary to make the test for each of them
 		 */
 		test_basename = TRUE;
-	}
-	else
-	{
-		for (iter = profile->private->basenames; iter; iter = iter->next)
-		{
-			tmp_pattern = (gchar*)iter->data;
-			if (!profile->private->match_case)
-			{
+
+	} else {
+		for (iter = basenames ; iter ; iter = iter->next ){
+
+			tmp_pattern = ( gchar * ) iter->data;
+			if( !matchcase ){
 				/* --> if case-insensitive asked, lower all the string
 				 * since the pattern matching function don't manage it
 				 * itself.
 				 */
-				tmp_pattern = g_ascii_strdown ((gchar*)iter->data, strlen ((gchar*)iter->data));
+				tmp_pattern = g_ascii_strdown(( gchar * ) iter->data, strlen(( gchar * ) iter->data ));
 			}
 
-			glob_patterns = g_list_append (glob_patterns, g_pattern_spec_new (tmp_pattern));
+			glob_patterns = g_list_append( glob_patterns, g_pattern_spec_new( tmp_pattern ));
 
-			if (!profile->private->match_case)
-			{
-				g_free (tmp_pattern);
+			if( !matchcase ){
+				g_free( tmp_pattern );
 			}
 		}
 	}
 
-	if (profile->private->mimetypes && profile->private->mimetypes->next != NULL &&
-			(g_ascii_strcasecmp ((gchar*)(profile->private->mimetypes->data), "*") == 0 ||
-			 g_ascii_strcasecmp ((gchar*)(profile->private->mimetypes->data), "*/*") == 0))
-	{
+	if( mimetypes && mimetypes->next != NULL &&
+			( g_ascii_strcasecmp(( gchar * )( mimetypes->data ), "*" ) == 0 ||
+			  g_ascii_strcasecmp(( gchar * )( mimetypes->data), "*/*") == 0 )){
 		/* if the only pattern is '*' or * / * then all mimetypes will
 		 * match, so it is not necessary to make the test for each of them
 		 */
 		test_mimetype = TRUE;
-	}
-	else
-	{
-		for (iter = profile->private->mimetypes; iter; iter = iter->next)
-		{
-			glob_mime_patterns = g_list_append (glob_mime_patterns, g_pattern_spec_new ((gchar*)iter->data));
+
+	} else {
+		for( iter = mimetypes ; iter ; iter = iter->next ){
+			glob_mime_patterns = g_list_append( glob_mime_patterns, g_pattern_spec_new(( gchar * ) iter->data ));
 		}
 	}
 
@@ -1217,24 +548,22 @@ is_target_selection_candidate( const NAObjectProfile *profile, GList *files, gbo
 
 		tmp_filename = tracked_to_basename( iter1->data, from_nautilus );
 
-		if (tmp_filename)
-		{
+		if( tmp_filename ){
 			tmp_mimetype = tracked_to_mimetype( iter1->data, from_nautilus );
 
-			if (!profile->private->match_case)
-			{
+			if( !matchcase ){
 				/* --> if case-insensitive asked, lower all the string
 				 * since the pattern matching function don't manage it
 				 * itself.
 				 */
-				tmp_filename2 = g_ascii_strdown (tmp_filename, strlen (tmp_filename));
-				g_free (tmp_filename);
+				tmp_filename2 = g_ascii_strdown( tmp_filename, strlen( tmp_filename ));
+				g_free( tmp_filename );
 				tmp_filename = tmp_filename2;
 			}
 
 			/* --> for the moment we deal with all mimetypes case-insensitively */
-			tmp_mimetype2 = g_ascii_strdown (tmp_mimetype, strlen (tmp_mimetype));
-			g_free (tmp_mimetype);
+			tmp_mimetype2 = g_ascii_strdown( tmp_mimetype, strlen( tmp_mimetype ));
+			g_free( tmp_mimetype );
 			tmp_mimetype = tmp_mimetype2;
 
 			if( tracked_is_directory( iter1->data, from_nautilus )){
@@ -1243,108 +572,83 @@ is_target_selection_candidate( const NAObjectProfile *profile, GList *files, gbo
 				file_count++;
 			}
 
-			scheme_ok_count += validate_schemes( profile->private->schemes, iter1->data, from_nautilus );
+			scheme_ok_count += validate_schemes( schemes, iter1->data, from_nautilus );
 
-			if (!test_basename) /* if it is already ok, skip the test to improve performance */
-			{
+			if( !test_basename ){ /* if it is already ok, skip the test to improve performance */
 				basename_match_ok = FALSE;
 				iter2 = glob_patterns;
-				while (iter2 && !basename_match_ok)
-				{
-					if (g_pattern_match_string ((GPatternSpec*)iter2->data, tmp_filename))
-					{
+				while( iter2 && !basename_match_ok ){
+					if( g_pattern_match_string(( GPatternSpec * ) iter2->data, tmp_filename )){
 						basename_match_ok = TRUE;
 					}
 					iter2 = iter2->next;
 				}
 
-				if (basename_match_ok)
-				{
+				if( basename_match_ok ){
 					glob_ok_count++;
 				}
 			}
 
-			if (!test_mimetype) /* if it is already ok, skip the test to improve performance */
-			{
+			if( !test_mimetype ){ /* if it is already ok, skip the test to improve performance */
 				mimetype_match_ok = FALSE;
 				iter2 = glob_mime_patterns;
-				while (iter2 && !mimetype_match_ok)
-				{
-					if (g_pattern_match_string ((GPatternSpec*)iter2->data, tmp_mimetype))
-					{
+				while( iter2 && !mimetype_match_ok ){
+					if (g_pattern_match_string(( GPatternSpec * ) iter2->data, tmp_mimetype )){
 						mimetype_match_ok = TRUE;
 					}
 					iter2 = iter2->next;
 				}
 
-				if (mimetype_match_ok)
-				{
+				if( mimetype_match_ok ){
 					mime_glob_ok_count++;
 				}
 			}
 
-			g_free (tmp_mimetype);
-			g_free (tmp_filename);
+			g_free( tmp_mimetype );
+			g_free( tmp_filename );
 		}
 
 		total_count++;
 	}
 
-	if ((files != NULL) && (files->next == NULL) && (!profile->private->accept_multiple))
-	{
+	if(( files != NULL ) && ( files->next == NULL ) && ( !multiple )){
 		test_multiple_file = TRUE;
-	}
-	else if (profile->private->accept_multiple)
-	{
+
+	} else if( multiple ){
 		test_multiple_file = TRUE;
 	}
 
-	if (profile->private->is_dir && profile->private->is_file)
-	{
-		if (dir_count > 0 || file_count > 0)
-		{
+	if( isdir && isfile ){
+		if( dir_count > 0 || file_count > 0 ){
 			test_file_type = TRUE;
 		}
-	}
-	else if (profile->private->is_dir && !profile->private->is_file)
-	{
-		if (file_count == 0)
-		{
+	} else if( isdir && !isfile ){
+		if( file_count == 0 ){
 			test_file_type = TRUE;
 		}
-	}
-	else if (!profile->private->is_dir && profile->private->is_file)
-	{
-		if (dir_count == 0)
-		{
+	} else if( !isdir && isfile ){
+		if( dir_count == 0 ){
 			test_file_type = TRUE;
 		}
 	}
 
-	if (scheme_ok_count == total_count)
-	{
+	if( scheme_ok_count == total_count ){
 		test_scheme = TRUE;
 	}
 
-
-	if (!test_basename) /* if not already tested */
-	{
-		if (glob_ok_count == total_count)
-		{
+	if( !test_basename ){ /* if not already tested */
+		if( glob_ok_count == total_count ){
 			test_basename = TRUE;
 		}
 	}
 
-	if (!test_mimetype) /* if not already tested */
-	{
-		if (mime_glob_ok_count == total_count)
-		{
+	if( !test_mimetype ){ /* if not already tested */
+		if( mime_glob_ok_count == total_count ){
 			test_mimetype = TRUE;
 		}
 	}
 
-	if (test_basename && test_mimetype && test_file_type && test_scheme && test_multiple_file)
-	{
+	if( test_basename && test_mimetype && test_file_type && test_scheme && test_multiple_file ){
 		retv = TRUE;
 	}
 
@@ -1352,146 +656,9 @@ is_target_selection_candidate( const NAObjectProfile *profile, GList *files, gbo
 	g_list_free (glob_patterns);
 	g_list_foreach (glob_mime_patterns, (GFunc) g_pattern_spec_free, NULL);
 	g_list_free (glob_mime_patterns);
-
-	return retv;
-}
-
-static gboolean
-tracked_is_directory( void *iter, gboolean from_nautilus )
-{
-	gboolean is_dir;
-	GFile *file;
-	GFileType type;
-
-	if( from_nautilus ){
-		is_dir = nautilus_file_info_is_directory(( NautilusFileInfo * ) iter );
-
-	} else {
-		file = g_file_new_for_uri((( NATrackedItem * ) iter )->uri );
-		type = g_file_query_file_type( file, G_FILE_QUERY_INFO_NONE, NULL );
-		is_dir = ( type == G_FILE_TYPE_DIRECTORY );
-		g_object_unref( file );
-	}
-
-	return( is_dir );
-}
-
-static gchar *
-tracked_to_basename( void *iter, gboolean from_nautilus )
-{
-	gchar *bname;
-	GFile *file;
-
-	if( from_nautilus ){
-		bname = nautilus_file_info_get_name(( NautilusFileInfo * ) iter );
-	} else {
-		file = g_file_new_for_uri((( NATrackedItem * ) iter )->uri );
-		bname = g_file_get_basename( file );
-		g_object_unref( file );
-	}
-
-	return( bname );
-}
-
-static GFile *
-tracked_to_location( void *iter, gboolean from_nautilus )
-{
-	GFile *file;
-
-	if( from_nautilus ){
-		file = nautilus_file_info_get_location(( NautilusFileInfo * ) iter );
-	} else {
-		file = g_file_new_for_uri((( NATrackedItem * ) iter )->uri );
-	}
-
-	return( file );
-}
-
-static gchar *
-tracked_to_mimetype( void *iter, gboolean from_nautilus )
-{
-	gchar *type;
-	NATrackedItem *tracked;
-	GFile *file;
-	GFileInfo *info;
-
-	type = NULL;
-	if( from_nautilus ){
-		type = nautilus_file_info_get_mime_type(( NautilusFileInfo * ) iter );
-
-	} else {
-		tracked = ( NATrackedItem * ) iter;
-		if( tracked->mimetype ){
-			type = g_strdup( tracked->mimetype );
-
-		} else {
-			file = g_file_new_for_uri((( NATrackedItem * ) iter )->uri );
-			info = g_file_query_info( file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL );
-			if( info ){
-				type = g_strdup( g_file_info_get_content_type( info ));
-				g_object_unref( info );
-			}
-			g_object_unref( file );
-		}
-	}
-
-	return( type );
-}
-
-static gchar *
-tracked_to_scheme( void *iter, gboolean from_nautilus )
-{
-	gchar *scheme;
-	NAGnomeVFSURI *vfs;
-
-	if( from_nautilus ){
-		scheme = nautilus_file_info_get_uri_scheme(( NautilusFileInfo * ) iter );
-
-	} else {
-		vfs = g_new0( NAGnomeVFSURI, 1 );
-		na_gnome_vfs_uri_parse( vfs, (( NATrackedItem * ) iter )->uri );
-		scheme = g_strdup( vfs->scheme );
-		na_gnome_vfs_uri_free( vfs );
-	}
-
-	return( scheme );
-}
-
-static gchar *
-tracked_to_uri( void *iter, gboolean from_nautilus )
-{
-	gchar *uri;
-
-	if( from_nautilus ){
-		uri = nautilus_file_info_get_uri(( NautilusFileInfo * ) iter );
-	} else {
-		uri = g_strdup((( NATrackedItem * ) iter )->uri );
-	}
-
-	return( uri );
-}
-
-static int
-validate_schemes( GSList* schemes2test, void* tracked_iter, gboolean from_nautilus )
-{
-	int retv = 0;
-	GSList* iter;
-	gboolean found = FALSE;
-	gchar *scheme;
-
-	iter = schemes2test;
-	while( iter && !found ){
-
-		scheme = tracked_to_scheme( tracked_iter, from_nautilus );
-
-		if( g_ascii_strncasecmp( scheme, ( gchar * ) iter->data, strlen(( gchar * ) iter->data )) == 0 ){
-			found = TRUE;
-			retv = 1;
-		}
-
-		g_free( scheme );
-		iter = iter->next;
-	}
+	na_core_utils_slist_free( schemes );
+	na_core_utils_slist_free( mimetypes );
+	na_core_utils_slist_free( basenames );
 
 	return retv;
 }
@@ -1617,7 +784,7 @@ parse_parameters( const NAObjectProfile *profile, gint target, GList* files, gbo
 		g_free( iuri );
 	}
 
-	iter = g_strdup( profile->private->parameters );
+	iter = na_object_get_parameters( profile );
 	old_iter = iter;
 
 	while(( iter = g_strstr_len( iter, strlen( iter ), "%" ))){
@@ -1718,276 +885,143 @@ parse_parameters( const NAObjectProfile *profile, gint target, GList* files, gbo
 	return( parsed );
 }
 
-static void
-object_dump( const NAObject *object )
+static gboolean
+tracked_is_directory( void *iter, gboolean from_nautilus )
 {
-	static const gchar *thisfn = "na_object_profile_object_dump";
-	NAObjectProfile *self;
-
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( object ));
-	self = NA_OBJECT_PROFILE( object );
+	gboolean is_dir;
+	GFile *file;
+	GFileType type;
 
-	if( !self->private->dispose_has_run ){
+	if( from_nautilus ){
+		is_dir = nautilus_file_info_is_directory(( NautilusFileInfo * ) iter );
 
-		g_debug( "%s:            path='%s'", thisfn, self->private->path );
-		g_debug( "%s:      parameters='%s'", thisfn, self->private->parameters );
-		g_debug( "%s: accept_multiple='%s'", thisfn, self->private->accept_multiple ? "True" : "False" );
-		g_debug( "%s:          is_dir='%s'", thisfn, self->private->is_dir ? "True" : "False" );
-		g_debug( "%s:         is_file='%s'", thisfn, self->private->is_file ? "True" : "False" );
-		g_debug( "%s:      match_case='%s'", thisfn, self->private->match_case ? "True" : "False" );
-		object_dump_list( thisfn, "basenames", self->private->basenames );
-		object_dump_list( thisfn, "mimetypes", self->private->mimetypes );
-		object_dump_list( thisfn, "  schemes", self->private->schemes );
-		object_dump_list( thisfn, "  folders", self->private->folders );
+	} else {
+		file = g_file_new_for_uri((( NATrackedItem * ) iter )->uri );
+		type = g_file_query_file_type( file, G_FILE_QUERY_INFO_NONE, NULL );
+		is_dir = ( type == G_FILE_TYPE_DIRECTORY );
+		g_object_unref( file );
 	}
-}
 
-static void
-object_dump_list( const gchar *thisfn, const gchar *label, GSList *list )
-{
-	gchar *string = na_utils_gslist_to_schema( list );
-	g_debug( "%s:       %s=%s", thisfn, label, string );
-	g_free( string );
+	return( is_dir );
 }
 
-static NAObject *
-object_new( const NAObject *profile )
+static gchar *
+tracked_to_basename( void *iter, gboolean from_nautilus )
 {
-	return( NA_OBJECT( na_object_profile_new()));
-}
+	gchar *bname;
+	GFile *file;
 
-static void
-object_copy( NAObject *target, const NAObject *source )
-{
-	gchar *path, *parameters;
-	gboolean matchcase, isfile, isdir, multiple;
-	GSList *basenames, *mimetypes, *schemes;
-	GSList *folders;
-
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( target ));
-	g_return_if_fail( NA_IS_OBJECT_PROFILE( source ));
-
-	if( !NA_OBJECT_PROFILE( target )->private->dispose_has_run &&
-		!NA_OBJECT_PROFILE( source )->private->dispose_has_run ){
-
-		g_object_get( G_OBJECT( source ),
-				NAPROFILE_PROP_PATH, &path,
-				NAPROFILE_PROP_PARAMETERS, &parameters,
-				NAPROFILE_PROP_BASENAMES, &basenames,
-				NAPROFILE_PROP_MATCHCASE, &matchcase,
-				NAPROFILE_PROP_MIMETYPES, &mimetypes,
-				NAPROFILE_PROP_ISFILE, &isfile,
-				NAPROFILE_PROP_ISDIR, &isdir,
-				NAPROFILE_PROP_ACCEPT_MULTIPLE, &multiple,
-				NAPROFILE_PROP_SCHEMES, &schemes,
-				NAPROFILE_PROP_FOLDERS, &folders,
-				NULL );
-
-		g_object_set( G_OBJECT( target ),
-				NAPROFILE_PROP_PATH, path,
-				NAPROFILE_PROP_PARAMETERS, parameters,
-				NAPROFILE_PROP_BASENAMES, basenames,
-				NAPROFILE_PROP_MATCHCASE, matchcase,
-				NAPROFILE_PROP_MIMETYPES, mimetypes,
-				NAPROFILE_PROP_ISFILE, isfile,
-				NAPROFILE_PROP_ISDIR, isdir,
-				NAPROFILE_PROP_ACCEPT_MULTIPLE, multiple,
-				NAPROFILE_PROP_SCHEMES, schemes,
-				NAPROFILE_PROP_FOLDERS, folders,
-				NULL );
-
-		g_free( path );
-		g_free( parameters );
-		na_utils_free_string_list( basenames );
-		na_utils_free_string_list( mimetypes );
-		na_utils_free_string_list( schemes );
+	if( from_nautilus ){
+		bname = nautilus_file_info_get_name(( NautilusFileInfo * ) iter );
+
+	} else {
+		file = g_file_new_for_uri((( NATrackedItem * ) iter )->uri );
+		bname = g_file_get_basename( file );
+		g_object_unref( file );
 	}
+
+	return( bname );
 }
 
-static gboolean
-object_are_equal( const NAObject *a, const NAObject *b )
+static GFile *
+tracked_to_location( void *iter, gboolean from_nautilus )
 {
-	NAObjectProfile *first = NA_OBJECT_PROFILE( a );
-	NAObjectProfile *second = NA_OBJECT_PROFILE( b );
-	gboolean equal = TRUE;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( a ), FALSE );
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( b ), FALSE );
-
-	if( !NA_OBJECT_PROFILE( a )->private->dispose_has_run &&
-		!NA_OBJECT_PROFILE( b )->private->dispose_has_run ){
-
-		if( equal ){
-			equal =
-				( g_utf8_collate( first->private->path, second->private->path ) == 0 ) &&
-				( g_utf8_collate( first->private->parameters, second->private->parameters ) == 0 );
-		}
-
-		if( equal ){
-			equal = (( first->private->accept_multiple && second->private->accept_multiple ) ||
-					( !first->private->accept_multiple && !second->private->accept_multiple ));
-		}
-
-		if( equal ){
-			equal = (( first->private->is_dir && second->private->is_dir ) ||
-					( !first->private->is_dir && !second->private->is_dir ));
-		}
-
-		if( equal ){
-			equal = (( first->private->is_file && second->private->is_file ) ||
-					( !first->private->is_file && !second->private->is_file ));
-		}
-
-		if( equal ){
-			equal = na_utils_string_lists_are_equal( first->private->basenames, second->private->basenames ) &&
-					na_utils_string_lists_are_equal( first->private->mimetypes, second->private->mimetypes ) &&
-					na_utils_string_lists_are_equal( first->private->schemes, second->private->schemes ) &&
-					na_utils_string_lists_are_equal( first->private->folders, second->private->folders );
-		}
+	GFile *file;
 
-#if NA_IDUPLICABLE_EDITION_STATUS_DEBUG
-		g_debug( "na_object_profile_object_are_equal: a=%p (%s), b=%p (%s), are_equal=%s",
-				( void * ) a, G_OBJECT_TYPE_NAME( a ),
-				( void * ) b, G_OBJECT_TYPE_NAME( b ),
-				equal ? "True":"False" );
-#endif
+	if( from_nautilus ){
+		file = nautilus_file_info_get_location(( NautilusFileInfo * ) iter );
+	} else {
+		file = g_file_new_for_uri((( NATrackedItem * ) iter )->uri );
 	}
 
-	return( equal );
+	return( file );
 }
 
-/*
- * a valid NAObjectProfile requires :
- * - the first word of path+parameters should be an executable file
- * - filenames list of pseudo-regexp is not empty
- * - mimetypes list is not empty
- * - at least one of is_file, is_dir is set
- * - schemes list is not empty
- */
-static gboolean
-object_is_valid( const NAObject *profile )
+static gchar *
+tracked_to_mimetype( void *iter, gboolean from_nautilus )
 {
-	gboolean is_valid = FALSE;
-	NAObjectItem *parent;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
-
-	if( !NA_OBJECT_PROFILE( profile )->private->dispose_has_run ){
+	gchar *type;
+	NATrackedItem *tracked;
+	GFile *file;
+	GFileInfo *info;
 
-		is_valid = TRUE;
-		parent = na_object_get_parent( profile );
+	type = NULL;
+	if( from_nautilus ){
+		type = nautilus_file_info_get_mime_type(( NautilusFileInfo * ) iter );
 
-		if( is_valid ){
-			if( na_object_action_is_target_background( NA_OBJECT_ACTION( parent )) ||
-				na_object_action_is_target_toolbar( NA_OBJECT_ACTION( parent ))){
-				is_valid =
-					is_valid_path_parameters( NA_OBJECT_PROFILE( profile )) &&
-					is_valid_folders( NA_OBJECT_PROFILE( profile ));
-			}
-		}
+	} else {
+		tracked = ( NATrackedItem * ) iter;
+		if( tracked->mimetype ){
+			type = g_strdup( tracked->mimetype );
 
-		if( is_valid ){
-			if( na_object_action_is_target_selection( NA_OBJECT_ACTION( parent ))){
-				is_valid =
-					is_valid_path_parameters( NA_OBJECT_PROFILE( profile )) &&
-					is_valid_filenames( NA_OBJECT_PROFILE( profile )) &&
-					is_valid_mimetypes( NA_OBJECT_PROFILE( profile )) &&
-					is_valid_isfiledir( NA_OBJECT_PROFILE( profile )) &&
-					is_valid_schemes( NA_OBJECT_PROFILE( profile ));
+		} else {
+			file = g_file_new_for_uri((( NATrackedItem * ) iter )->uri );
+			info = g_file_query_info( file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL );
+			if( info ){
+				type = g_strdup( g_file_info_get_content_type( info ));
+				g_object_unref( info );
 			}
+			g_object_unref( file );
 		}
 	}
 
-	return( is_valid );
-}
-
-static gboolean
-is_valid_path_parameters( const NAObjectProfile *profile )
-{
-	gboolean valid;
-	gchar *command;
-	gchar *exe;
-
-	command = g_strdup_printf( "%s %s", profile->private->path, profile->private->parameters );
-	exe = na_utils_get_first_word( command );
-
-	valid =
-		g_file_test( exe, G_FILE_TEST_EXISTS ) &&
-		g_file_test( exe, G_FILE_TEST_IS_EXECUTABLE ) &&
-		!g_file_test( exe, G_FILE_TEST_IS_DIR );
-
-	g_free( exe );
-	g_free( command );
-
-	return( valid );
-}
-
-static gboolean
-is_valid_filenames( const NAObjectProfile *profile )
-{
-	gboolean valid;
-
-	valid = g_slist_length( profile->private->basenames ) > 0;
-
-	return( valid );
+	return( type );
 }
 
-static gboolean
-is_valid_mimetypes( const NAObjectProfile *profile )
+static gchar *
+tracked_to_scheme( void *iter, gboolean from_nautilus )
 {
-	gboolean valid;
-
-	valid = g_slist_length( profile->private->mimetypes ) > 0;
-
-	return( valid );
-}
+	gchar *scheme;
+	NAGnomeVFSURI *vfs;
 
-static gboolean
-is_valid_isfiledir( const NAObjectProfile *profile )
-{
-	gboolean valid;
+	if( from_nautilus ){
+		scheme = nautilus_file_info_get_uri_scheme(( NautilusFileInfo * ) iter );
 
-	valid = profile->private->is_file || profile->private->is_dir;
+	} else {
+		vfs = g_new0( NAGnomeVFSURI, 1 );
+		na_gnome_vfs_uri_parse( vfs, (( NATrackedItem * ) iter )->uri );
+		scheme = g_strdup( vfs->scheme );
+		na_gnome_vfs_uri_free( vfs );
+	}
 
-	return( valid );
+	return( scheme );
 }
 
-static gboolean
-is_valid_schemes( const NAObjectProfile *profile )
+static gchar *
+tracked_to_uri( void *iter, gboolean from_nautilus )
 {
-	gboolean valid;
+	gchar *uri;
 
-	valid = g_slist_length( profile->private->schemes ) > 0;
+	if( from_nautilus ){
+		uri = nautilus_file_info_get_uri(( NautilusFileInfo * ) iter );
+	} else {
+		uri = g_strdup((( NATrackedItem * ) iter )->uri );
+	}
 
-	return( valid );
+	return( uri );
 }
 
-static gboolean
-is_valid_folders( const NAObjectProfile *profile )
+static int
+validate_schemes( GSList* schemes2test, void* tracked_iter, gboolean from_nautilus )
 {
-	gboolean valid;
-
-	valid = g_slist_length( profile->private->folders ) > 0;
-
-	return( valid );
-}
+	int retv = 0;
+	GSList* iter;
+	gboolean found = FALSE;
+	gchar *scheme;
 
-/*
- * new_parent is specifically set to be able to allocate a new id for
- * the current profile into the target parent
- */
-static gchar *
-object_id_new_id( const NAObjectId *item, const NAObjectId *new_parent )
-{
-	gchar *id = NULL;
+	iter = schemes2test;
+	while( iter && !found ){
 
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( item ), NULL );
-	g_return_val_if_fail( new_parent && NA_IS_OBJECT_ACTION( new_parent ), NULL );
+		scheme = tracked_to_scheme( tracked_iter, from_nautilus );
 
-	if( !NA_OBJECT_PROFILE( item )->private->dispose_has_run ){
+		if( g_ascii_strncasecmp( scheme, ( gchar * ) iter->data, strlen(( gchar * ) iter->data )) == 0 ){
+			found = TRUE;
+			retv = 1;
+		}
 
-		id = na_object_action_get_new_profile_name( NA_OBJECT_ACTION( new_parent ));
+		g_free( scheme );
+		iter = iter->next;
 	}
 
-	return( id );
+	return retv;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]