示例#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 );
}
示例#2
0
int
main( int argc, char **argv )
{
	NAImporterParms parms;
	GList *import_results;
	NAImporterResult *result;

#if !GLIB_CHECK_VERSION( 2,36, 0 )
	g_type_init();
#endif

	GOptionContext *context = init_options();
	check_options( argc, argv, context );

	NAPivot *pivot = na_pivot_new();
	na_pivot_set_loadable( pivot, !PIVOT_LOAD_DISABLED & !PIVOT_LOAD_INVALID );
	na_pivot_load_items( pivot );

	parms.uris = g_slist_prepend( NULL, uri );
	parms.check_fn = NULL;
	parms.check_fn_data = NULL;
	parms.preferred_mode = IMPORTER_MODE_ASK;
	parms.parent_toplevel = NULL;

	import_results = na_importer_import_from_uris( pivot, &parms );

	result = import_results->data;
	if( result->imported ){
		na_object_dump( result->imported );
		g_object_unref( result->imported );
	}

	na_core_utils_slist_dump( NULL, result->messages );
	na_core_utils_slist_free( result->messages );

	return( 0 );
}