/* * search for the action in the repository */ static NAObjectAction * get_action( const gchar *id ) { NAPivot *pivot; NAObjectAction *action; action = NULL; pivot = na_pivot_new(); na_pivot_set_loadable( pivot, !PIVOT_LOAD_DISABLED & !PIVOT_LOAD_INVALID ); na_pivot_load_items( pivot ); action = ( NAObjectAction * ) na_pivot_get_item( pivot, id ); if( !action ){ g_printerr( _( "Error: action '%s' doesn't exist.\n" ), id ); } else { if( !na_object_is_enabled( action )){ g_printerr( _( "Error: action '%s' is disabled.\n" ), id ); g_object_unref( action ); action = NULL; } if( !na_object_is_valid( action )){ g_printerr( _( "Error: action '%s' is not valid.\n" ), id ); g_object_unref( action ); action = NULL; } } return( action ); }
/* * search for the action in the repository */ static NAObjectItem * get_item( const gchar *id ) { NAObjectItem *item = NULL; pivot = na_pivot_new(); na_pivot_set_loadable( pivot, PIVOT_LOAD_ALL ); na_pivot_load_items( pivot ); item = na_pivot_get_item( pivot, id ); if( !item ){ g_printerr( _( "Error: item '%s' doesn't exist.\n" ), id ); } return( item ); }
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 ); }