Commit 0c4dcb44 authored by Pierre Wieser's avatar Pierre Wieser

Test if 'isfile' is set before using it when converting to v3

Fix #651911 3.1.2 treats isdir differently than 2.30.2
parent d3896fad
2011-06-08 Pierre Wieser <pwieser@trychlos.org>
* src/api/na-object-api.h:
* docs/reference/nautilus-actions-sections.txt
(na_object_is_file, na_object_is_dir, na_object_is_multiple):
Macros are moved from the official API as deprecated.
* src/core/na-icontext-factory.c
(ISFILE, ISDIR): No more declare properties for deprecated data.
(SCHEMES): Declare 'file' as the default.
* src/core/na-factory-object.c:
* src/core/na-factory-object.h (na_factory_object_is_set): New function.
* src/core/na-object-action.c (ifactory_object_read_done):
Dump the rough read data.
First create a v2 profile before converting it to last version.
* src/core/na-object-menu.c (ifactory_object_read_done):
Dump the rough read data.
* src/core/na-object-profile.c
(ifactory_object_read_done): Dump the rough read data.
(convert_pre_v3_isfiledir): Test if 'isfile' is set before using it.
* src/io-desktop/nadp-reader.c (nadp_iio_provider_read_items):
* src/io-gconf/nagp-reader.c (nagp_iio_provider_read_items):
* src/io-xml/naxml-reader.c (naxml_reader_import_from_uri):
Dump the whole read item, maybe after conversion.
2011-05-22 Pierre Wieser <pwieser@trychlos.org>
* src/core/na-iimporter.c (na_iimporter_manage_import_mode):
......
......@@ -618,9 +618,6 @@ na_object_attach_profile
na_object_get_path
na_object_get_parameters
na_object_get_working_dir
na_object_is_file
na_object_is_dir
na_object_is_multiple
na_object_get_execution_mode
na_object_get_startup_notify
na_object_get_startup_class
......
......@@ -162,9 +162,6 @@ G_BEGIN_DECLS
#define na_object_get_path( obj ) (( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PATH ))
#define na_object_get_parameters( obj ) (( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PARAMETERS ))
#define na_object_get_working_dir( obj ) (( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_WORKING_DIR ))
#define na_object_is_file( obj ) (( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ISFILE )))
#define na_object_is_dir( obj ) (( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ISDIR )))
#define na_object_is_multiple( obj ) (( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_MULTIPLE )))
#define na_object_get_execution_mode( obj ) (( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_EXECUTION_MODE ))
#define na_object_get_startup_notify( obj ) (( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_STARTUP_NOTIFY )))
#define na_object_get_startup_class( obj ) (( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_STARTUP_WMCLASS ))
......
......@@ -751,10 +751,10 @@ na_factory_object_get_as_value( const NAIFactoryObject *object, const gchar *nam
*
* Returns: the searched value.
*
* If the type of the value is NA_DATA_TYPE_STRING, NA_DATA_TYPE_LOCALE_STRING,
* or NA_DATA_TYPE_STRING_LIST, then the returned value is a newly allocated
* one and should be g_free() (resp. na_core_utils_slist_free()) by the
* caller.
* If the type of the value is NA_DATA_TYPE_STRING or NA_DATA_TYPE_LOCALE_STRING
* (resp. NA_DATA_TYPE_STRING_LIST), then the returned value is a newly allocated
* string (resp. GSList) and should be g_free() (resp. na_core_utils_slist_free())
* by the caller.
*/
void *
na_factory_object_get_as_void( const NAIFactoryObject *object, const gchar *name )
......@@ -774,6 +774,25 @@ na_factory_object_get_as_void( const NAIFactoryObject *object, const gchar *name
return( value );
}
/*
* na_factory_object_is_set:
* @object: this #NAIFactoryObject instance.
* @name: the elementary data whose value is to be tested.
*
* Returns: %TRUE if the value is set (may be %NULL), %FALSE else.
*/
gboolean
na_factory_object_is_set( const NAIFactoryObject *object, const gchar *name )
{
NADataBoxed *boxed;
g_return_val_if_fail( NA_IS_IFACTORY_OBJECT( object ), FALSE );
boxed = na_ifactory_object_get_data_boxed( object, name );
return( boxed != NULL );
}
/*
* na_factory_object_set_from_value:
* @object: this #NAIFactoryObject instance.
......
......@@ -68,6 +68,7 @@ guint na_factory_object_write_item ( NAIFactoryObject *object, cons
void *na_factory_object_get_as_void ( const NAIFactoryObject *object, const gchar *name );
void na_factory_object_get_as_value ( const NAIFactoryObject *object, const gchar *name, GValue *value );
gboolean na_factory_object_is_set ( const NAIFactoryObject *object, const gchar *name );
void na_factory_object_set_from_value ( NAIFactoryObject *object, const gchar *name, const GValue *value );
void na_factory_object_set_from_void ( NAIFactoryObject *object, const gchar *name, const void *data );
......
......@@ -171,7 +171,7 @@ NADataDef data_def_conditions [] = {
{ NAFO_DATA_ISFILE,
TRUE,
FALSE,
TRUE,
FALSE,
N_( "Whether the profile applies to files (deprecated option, see mimetype)" ),
/* i18n: 'true' and 'false' values are taken literally, and should not be translated */
N_( "Set to 'true' if the selection can have files, to 'false' otherwise.\n" \
......@@ -202,7 +202,7 @@ NADataDef data_def_conditions [] = {
{ NAFO_DATA_ISDIR,
TRUE,
FALSE,
TRUE,
FALSE,
N_( "Whether the profile applies to folders (deprecated option, see mimetype)" ),
/* i18n: 'true' and 'false' values are taken literally, and should not be translated */
N_( "Set to 'true' if the selection can have folders, to 'false' otherwise.\n" \
......@@ -284,7 +284,7 @@ NADataDef data_def_conditions [] = {
"or when targeting the special 'x-nautilus-desktop' scheme.\n" \
"Defaults to 'file'." ),
NA_DATA_TYPE_STRING_LIST,
"*",
"file",
FALSE,
TRUE,
TRUE,
......
......@@ -86,8 +86,8 @@ static guint ifactory_object_write_done( NAIFactoryObject *instance, cons
static void icontext_iface_init( NAIContextInterface *iface );
static gboolean icontext_is_candidate( NAIContext *object, guint target, GList *selection );
static gboolean read_done_convert_v1_to_last( NAIFactoryObject *instance );
static void read_done_deals_with_toolbar_label( NAIFactoryObject *instance );
static NAObjectProfile *read_done_convert_v1_to_v2( NAIFactoryObject *instance );
static void read_done_deals_with_toolbar_label( NAIFactoryObject *instance );
static guint write_done_write_profiles( NAIFactoryObject *instance, const NAIFactoryProvider *writer, void *writer_data, GSList **messages );
......@@ -378,24 +378,28 @@ ifactory_object_get_groups( const NAIFactoryObject *instance )
/*
* at this time, we don't yet have read the profiles as this will be
* done in ifactory_provider_read_done - we so just be able to deal with
* triggered by ifactory_provider_read_done - we so just be able to deal with
* action-specific properties (not check for profiles consistency)
*/
static void
ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages )
{
guint iversion;
NAObjectProfile *profile;
g_debug( "na_object_action_ifactory_object_read_done: instance=%p", ( void * ) instance );
na_factory_object_dump( instance );
na_object_item_deals_with_version( NA_OBJECT_ITEM( instance ));
/* may attach a new profile if we detect a pre-v2 action
/* should attach a new profile if we detect a pre-v2 action
* the v1_to_v2 conversion must be followed by a v2_to_v3 one
*/
iversion = na_object_get_iversion( instance );
if( iversion < 2 ){
read_done_convert_v1_to_last( instance );
profile = read_done_convert_v1_to_v2( instance );
na_object_profile_convert_v2_to_last( profile );
}
/* deals with obsoleted data, i.e. data which may have been written in the past
......@@ -407,9 +411,7 @@ ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider
*/
na_icontext_read_done( NA_ICONTEXT( instance ));
na_object_dump( instance );
/* last, set other action defaults
/* last, set action defaults
*/
na_factory_object_set_defaults( instance );
}
......@@ -451,18 +453,17 @@ icontext_is_candidate( NAIContext *object, guint target, GList *selection )
}
/*
* do we have a pre-v2 action ?
* it is be identified by an version = "1.x"
* if we have a pre-v2 action
* any data found in data_def_action_v1 (defined in na-object-action-factory.c)
* is obsoleted and moved to a new profile
* is obsoleted and should be moved to a new profile
*
* actions read from .desktop already have iversion=3 (cf. desktop_read_start)
* and v1 actions may only come from xml or gconf
* so v1 actions may only come from xml or gconf
*
* returns TRUE if this actually was a v1 action which has been converted to v2
* returns the newly defined profile
*/
static gboolean
read_done_convert_v1_to_last( NAIFactoryObject *instance )
static NAObjectProfile *
read_done_convert_v1_to_v2( NAIFactoryObject *instance )
{
static const gchar *thisfn = "na_object_action_read_done_read_done_convert_v1_to_last";
GList *to_move;
......@@ -478,7 +479,7 @@ read_done_convert_v1_to_last( NAIFactoryObject *instance )
def = data_def_action_v1;
while( def->name ){
boxed = na_ifactory_object_get_data_boxed( instance , def->name );
boxed = na_ifactory_object_get_data_boxed( instance, def->name );
if( boxed ){
g_debug( "%s: boxed=%p (%s) marked to be moved from action body to profile",
thisfn, ( void * ) boxed, def->name );
......@@ -487,10 +488,6 @@ read_done_convert_v1_to_last( NAIFactoryObject *instance )
def++;
}
if( !to_move ){
return( FALSE );
}
/* now create a new profile
*/
profile = na_object_profile_new();
......@@ -498,16 +495,12 @@ read_done_convert_v1_to_last( NAIFactoryObject *instance )
na_object_set_label( profile, _( "Profile automatically created from pre-v2 action" ));
na_object_attach_profile( instance, profile );
if( to_move ){
for( ibox = to_move ; ibox ; ibox = ibox->next ){
na_factory_object_move_boxed(
NA_IFACTORY_OBJECT( profile ), instance, NA_DATA_BOXED( ibox->data ));
}
for( ibox = to_move ; ibox ; ibox = ibox->next ){
na_factory_object_move_boxed(
NA_IFACTORY_OBJECT( profile ), instance, NA_DATA_BOXED( ibox->data ));
}
na_factory_object_set_defaults( NA_IFACTORY_OBJECT( profile ));
na_object_profile_convert_v2_to_last( profile );
return( TRUE );
return( profile );
}
/*
......
......@@ -295,13 +295,17 @@ ifactory_object_get_groups( const NAIFactoryObject *instance )
static void
ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages )
{
g_debug( "na_object_menu_ifactory_object_read_done: instance=%p", ( void * ) instance );
na_factory_object_dump( instance );
na_object_item_deals_with_version( NA_OBJECT_ITEM( instance ));
/* prepare the context after the reading
*/
na_icontext_read_done( NA_ICONTEXT( instance ));
/* last, set other menu defaults
/* last, set menu defaults
*/
na_factory_object_set_defaults( instance );
}
......
......@@ -61,6 +61,10 @@ struct _NAObjectProfilePrivate {
#define PROFILE_NAME_PREFIX "profile-"
#define na_object_is_file( obj ) (( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ISFILE )))
#define na_object_is_dir( obj ) (( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ISDIR )))
#define na_object_is_multiple( obj ) (( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_MULTIPLE )))
extern NADataGroup profile_data_groups []; /* defined in na-item-profile-factory.c */
static NAObjectIdClass *st_parent_class = NULL;
......@@ -344,7 +348,9 @@ ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider
NAObjectAction *action;
guint iversion;
g_debug( "%s: profile=%p", thisfn, ( void * ) instance );
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
na_factory_object_dump( instance );
/* converts pre-v3 data
*/
......@@ -354,9 +360,12 @@ ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider
if( iversion < 3 ){
na_object_profile_convert_v2_to_last( NA_OBJECT_PROFILE( instance ));
}
read_done_ending( NA_OBJECT_PROFILE( instance ));
/* must be always called, but is called when converting profile, anyway
*/
} else {
read_done_ending( NA_OBJECT_PROFILE( instance ));
}
}
static guint
......@@ -577,7 +586,13 @@ convert_pre_v3_isfiledir( NAObjectProfile *profile )
mimetypes = NULL;
before_list = na_object_get_mimetypes( profile );
isfile = na_object_is_file( profile );
/* this is needed because na_object_is_file() does not return the default
* value when the data is not set (see #651911)
*/
isfile = TRUE;
if( na_factory_object_is_set( NA_IFACTORY_OBJECT( profile ), NAFO_DATA_ISFILE )){
isfile = na_object_is_file( profile );
}
isdir = na_object_is_dir( profile );
if( isfile ){
......@@ -633,11 +648,17 @@ read_done_ending( NAObjectProfile *profile )
*/
na_icontext_read_done( NA_ICONTEXT( profile ));
/* last, set other action defaults
/* last, set profile defaults
*/
na_factory_object_set_defaults( NA_IFACTORY_OBJECT( profile ));
}
/*
* GConf used to store command path and parameters as two separated fields
* Desktop store them as one field
* NACT displays and edits them as two fields (this let us have Browse and Legend buttons)
* => so we definitively keep them as separated boxed in our internal objects
*/
static void
split_path_parameters( NAObjectProfile *profile )
{
......@@ -757,7 +778,11 @@ na_object_profile_new_with_defaults( void )
* na_object_profile_convert_v2_to_last:
* @profile: the #NAObjectProfile profile to be converted.
*
* Converts to v3 a @profile which has just been created from a pre-v2 action.
* Converts a v2 profile to the last version, setting the defaults as needed.
*
* This is called after having converted a pre-v2 action on the newly created
* profile, or just after having read a v2 profile.
* In all situations, defaults are supposed to have been set.
*
* Since: 2.30
*/
......
......@@ -105,6 +105,7 @@ nadp_iio_provider_read_items( const NAIIOProvider *provider, GSList **messages )
if( item ){
items = g_list_prepend( items, item );
na_object_dump( item );
}
}
......
......@@ -95,6 +95,7 @@ nagp_iio_provider_read_items( const NAIIOProvider *provider, GSList **messages )
item = read_item( self, ( const gchar * ) ip->data, messages );
if( item ){
items_list = g_list_prepend( items_list, item );
na_object_dump( item );
}
}
......@@ -357,11 +358,11 @@ get_boxed_from_path( const NagpGConfProvider *provider, const gchar *path, Reade
gint int_value;
boxed = NULL;
boxed = na_data_boxed_new( def );
have_entry = na_gconf_utils_has_entry( reader_data->entries, def->gconf_entry );
g_debug( "%s: entry=%s, have_entry=%s", thisfn, def->gconf_entry, have_entry ? "True":"False" );
if( have_entry ){
boxed = na_data_boxed_new( def );
gchar *entry_path = gconf_concat_dir_and_key( path, def->gconf_entry );
switch( def->type ){
......
......@@ -352,6 +352,7 @@ naxml_reader_import_from_uri( const NAIImporter *instance, NAIImporterImportFrom
if( code == IMPORTER_CODE_OK ){
publish_undealt_nodes( reader );
na_object_dump( reader->private->parms->imported );
}
g_object_unref( reader );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment