Exemplo n.º 1
0
static void
write_done_write_subitems_list( CappDesktopFile *ndp, NAObjectItem *item )
{
	static const gchar *thisfn = "cadp_writer_write_done_write_subitems_list";
	GSList *subitems;
	GSList *profile_groups, *ip;
	gchar *tmp;

	subitems = na_object_get_items_slist( item );
	tmp = g_strdup_printf( "%s (written subitems)", thisfn );
	na_core_utils_slist_dump( tmp, subitems );
	g_free( tmp );

	cadp_desktop_file_set_string_list(
			ndp,
			CADP_GROUP_DESKTOP,
			NA_IS_OBJECT_ACTION( item ) ? CADP_KEY_PROFILES : CADP_KEY_ITEMS_LIST,
			subitems );

	profile_groups = cadp_desktop_file_get_profiles( ndp );
	tmp = g_strdup_printf( "%s (existing profiles)", thisfn );
	na_core_utils_slist_dump( tmp, profile_groups );
	g_free( tmp );

	for( ip = profile_groups ; ip ; ip = ip->next ){
		if( na_core_utils_slist_count( subitems, ( const gchar * ) ip->data ) == 0 ){
			g_debug( "%s: deleting (removed) profile %s", thisfn, ( const gchar * ) ip->data );
			cadp_desktop_file_remove_profile( ndp, ( const gchar * ) ip->data );
		}
	}

	na_core_utils_slist_free( profile_groups );
	na_core_utils_slist_free( subitems );
}
Exemplo n.º 2
0
/*
 * Read and attach profiles in the specified order
 * - profiles which may exist in .desktop files, but are not referenced
 *   in the 'Profiles' string list are just ignored
 * - profiles which may be referenced in the action string list, but are not
 *   found in the .desktop file are recreated with default values (plus a warning)
 * - ensure that there is at least one profile attached to the action
 */
static void
read_done_action_read_profiles( const NAIFactoryProvider *provider, NAObjectAction *action, NadpReaderData *reader_data, GSList **messages )
{
	static const gchar *thisfn = "nadp_reader_read_done_action_read_profiles";
	GSList *order;
	GSList *ip;
	gchar *profile_id;
	NAObjectId *found;
	NAObjectProfile *profile;

	reader_data->action = action;
	order = na_object_get_items_slist( action );

	for( ip = order ; ip ; ip = ip->next ){
		profile_id = ( gchar * ) ip->data;
		found = na_object_get_item( action, profile_id );
		if( !found ){
			read_done_action_load_profile( provider, reader_data, profile_id, messages );
		}
	}

	na_core_utils_slist_free( order );

	if( !na_object_get_items_count( action )){
		g_warning( "%s: no profile found in .desktop file", thisfn );
		profile = na_object_profile_new_with_defaults();
		na_object_attach_profile( action, profile );
	}
}
Exemplo n.º 3
0
static void
read_done_action_read_profiles( const NAIFactoryProvider *provider, NAObjectAction *action, ReaderData *data, GSList **messages )
{
	static const gchar *thisfn = "nagp_reader_read_done_action_read_profiles";
	GSList *order;
	GSList *list_profiles;
	GSList *ip;
	gchar *profile_id;
	gchar *profile_path;
	NAObjectId *found;
	NAObjectProfile *profile;

	data->parent = NA_OBJECT_ITEM( action );
	order = na_object_get_items_slist( action );
	list_profiles = na_gconf_utils_get_subdirs( NAGP_GCONF_PROVIDER( provider )->private->gconf, data->path );

	/* read profiles in the specified order
	 * as a protection against bugs in NACT, we check that profile has not
	 * already been loaded
	 */
	for( ip = order ; ip ; ip = ip->next ){
		profile_id = ( gchar * ) ip->data;
		found = na_object_get_item( action, profile_id );
		if( !found ){
			g_debug( "nagp_reader_read_done_action: loading profile=%s", profile_id );
			profile_path = gconf_concat_dir_and_key( data->path, profile_id );
			read_done_action_load_profile( provider, data, profile_path, messages );
			g_free( profile_path );
		}
	}

	/* append other profiles
	 * this is mandatory for pre-2.29 actions which introduced order of profiles
	 */
	for( ip = list_profiles ; ip ; ip = ip->next ){
		profile_id = g_path_get_basename(( const gchar * ) ip->data );
		found = na_object_get_item( action, profile_id );
		if( !found ){
			g_debug( "nagp_reader_read_done_action: loading profile=%s", profile_id );
			read_done_action_load_profile( provider, data, ( const gchar * ) ip->data, messages );
		}
		g_free( profile_id );
	}

	/* make sure we have at least one profile
	 */
	if( !na_object_get_items_count( action )){
		g_warning( "%s: no profile found in GConf backend", thisfn );
		profile = na_object_profile_new_with_defaults();
		na_object_attach_profile( action, profile );
	}
}