/* Read-load all the glob patterns. * Note: calls filer_update_all. */ void reread_mime_files(void) { //gtk_icon_theme_rescan_if_needed(icon_theme); xdg_mime_shutdown(); }
/* Called in every public function. It reloads the hash function if need be. */ static void xdg_mime_init (void) { if (xdg_check_time_and_dirs ()) { xdg_mime_shutdown (); } if (need_reread) { global_hash = _xdg_glob_hash_new (); global_magic = _xdg_mime_magic_new (); alias_list = _xdg_mime_alias_list_new (); parent_list = _xdg_mime_parent_list_new (); icon_list = _xdg_mime_icon_list_new (); generic_icon_list = _xdg_mime_icon_list_new (); xdg_run_command_on_dirs ((XdgDirectoryFunc) xdg_mime_init_from_directory, NULL); need_reread = FALSE; } }
void ShutDownLibCitadel(void) { ShutDownLibCitadelMime(); WildFireShutdown(); xdg_mime_shutdown(); }
/** Main function. Parses options and calls helper function for any heavy lifting. */ int main (int argc, char *argv[]) { int input_type=FILEDATA; int output_type=MIMETYPE; const char *mimetype; char *output=0; int i; hash_table_t launch_hash; locale_init(); /* Parse options */ while( 1 ) { static struct option long_options[] = { { "input-file-data", no_argument, 0, 't' } , { "input-filename", no_argument, 0, 'f' } , { "input-mime", no_argument, 0, 'i' } , { "output-mime", no_argument, 0, 'm' } , { "output-description", no_argument, 0, 'd' } , { "output-action", no_argument, 0, 'a' } , { "help", no_argument, 0, 'h' } , { "version", no_argument, 0, 'v' } , { "launch", no_argument, 0, 'l' } , { 0, 0, 0, 0 } } ; int opt_index = 0; int opt = getopt_long( argc, argv, GETOPT_STRING, long_options, &opt_index ); if( opt == -1 ) break; switch( opt ) { case 0: break; case 't': input_type=FILEDATA; break; case 'f': input_type=FILENAME; break; case 'i': input_type=MIMETYPE; break; case 'm': output_type=MIMETYPE; break; case 'd': output_type=DESCRIPTION; break; case 'a': output_type=ACTION; break; case 'l': output_type=LAUNCH; break; case 'h': print_help( argv[0], 1 ); exit(0); case 'v': printf( _("%s, version %s\n"), MIMEDB, PACKAGE_VERSION ); exit( 0 ); case '?': return 1; } } if( ( output_type == LAUNCH )&&(input_type==MIMETYPE)) { fprintf( stderr, _("%s: Can not launch a mimetype\n"), MIMEDB ); print_help( argv[0], 2 ); exit(1); } if( output_type == LAUNCH ) hash_init( &launch_hash, &hash_str_func, &hash_str_cmp ); /* Loop over all non option arguments and do the specified lookup */ //fprintf( stderr, "Input %d, output %d\n", input_type, output_type ); for (i = optind; (i < argc)&&(!error); i++) { /* Convert from filename to mimetype, if needed */ if( input_type == FILENAME ) { mimetype = xdg_mime_get_mime_type_from_file_name(argv[i]); } else if( input_type == FILEDATA ) { mimetype = xdg_mime_get_mime_type_for_file(argv[i]); } else mimetype = xdg_mime_is_valid_mime_type(argv[i])?argv[i]:0; mimetype = xdg_mime_unalias_mime_type (mimetype); if( !mimetype ) { fprintf( stderr, _( "%s: Could not parse mimetype from argument '%s'\n"), MIMEDB, argv[i] ); error=1; return 1; } /* Convert from mimetype to whatever, if needed */ switch( output_type ) { case MIMETYPE: { output = (char *)mimetype; break; } case DESCRIPTION: { output = get_description( mimetype ); if( !output ) output = strdup( _("Unknown") ); break; } case ACTION: { output = get_action( mimetype ); break; } case LAUNCH: { /* There may be more files using the same launcher, we add them all up in little array_list_ts and launched them together after all the arguments have been parsed. */ array_list_t *l= (array_list_t *)hash_get( &launch_hash, mimetype ); output = 0; if( !l ) { l = my_malloc( sizeof( array_list_t ) ); if( l == 0 ) { break; } al_init( l ); hash_put( &launch_hash, mimetype, l ); } al_push( l, argv[i] ); } } /* Print the glorious result */ if( output ) { printf( "%s\n", output ); if( output != mimetype ) free( output ); } output = 0; } /* Perform the actual launching */ if( output_type == LAUNCH && !error ) { int i; array_list_t mimes; al_init( &mimes ); hash_get_keys( &launch_hash, &mimes ); for( i=0; i<al_get_count( &mimes ); i++ ) { char *mimetype = (char *)al_get( &mimes, i ); array_list_t *files = (array_list_t *)hash_get( &launch_hash, mimetype ); if( !files ) { fprintf( stderr, _( "%s: Unknown error\n"), MIMEDB ); error=1; break; } char *launcher = get_action( mimetype ); if( launcher ) { launch( launcher, files, 0 ); free( launcher ); } } hash_foreach( &launch_hash, &clear_entry ); hash_destroy( &launch_hash ); al_destroy( &mimes ); } if( launch_buff ) free( launch_buff ); if( start_re ) { regfree( start_re ); regfree( stop_re ); free( start_re ); free( stop_re ); } xdg_mime_shutdown(); return error; }
MimeType::~MimeType() { xdg_mime_shutdown(); }
/** Main function. Parses options and calls helper function for any heavy lifting. */ int main (int argc, char *argv[]) { int input_type=FILEDATA; int output_type=MIMETYPE; const char *mimetype; char *output=0; int i; typedef std::map<std::string, string_list_t> launch_hash_t; launch_hash_t launch_hash; locale_init(); /* Parse options */ while( 1 ) { static struct option long_options[] = { { "input-file-data", no_argument, 0, 't' } , { "input-filename", no_argument, 0, 'f' } , { "input-mime", no_argument, 0, 'i' } , { "output-mime", no_argument, 0, 'm' } , { "output-description", no_argument, 0, 'd' } , { "output-action", no_argument, 0, 'a' } , { "help", no_argument, 0, 'h' } , { "version", no_argument, 0, 'v' } , { "launch", no_argument, 0, 'l' } , { 0, 0, 0, 0 } } ; int opt_index = 0; int opt = getopt_long( argc, argv, GETOPT_STRING, long_options, &opt_index ); if( opt == -1 ) break; switch( opt ) { case 0: break; case 't': input_type=FILEDATA; break; case 'f': input_type=FILENAME; break; case 'i': input_type=MIMETYPE; break; case 'm': output_type=MIMETYPE; break; case 'd': output_type=DESCRIPTION; break; case 'a': output_type=ACTION; break; case 'l': output_type=LAUNCH; break; case 'h': print_help( argv[0], 1 ); exit(0); case 'v': printf( _("%s, version %s\n"), MIMEDB, PACKAGE_VERSION ); exit( 0 ); case '?': return 1; } } if( ( output_type == LAUNCH )&&(input_type==MIMETYPE)) { fprintf( stderr, _("%s: Can not launch a mimetype\n"), MIMEDB ); print_help( argv[0], 2 ); exit(1); } /* Loop over all non option arguments and do the specified lookup */ //fprintf( stderr, "Input %d, output %d\n", input_type, output_type ); for (i = optind; (i < argc)&&(!error); i++) { /* Convert from filename to mimetype, if needed */ if( input_type == FILENAME ) { mimetype = xdg_mime_get_mime_type_from_file_name(argv[i]); } else if( input_type == FILEDATA ) { mimetype = xdg_mime_get_mime_type_for_file(argv[i]); } else mimetype = xdg_mime_is_valid_mime_type(argv[i])?argv[i]:0; mimetype = xdg_mime_unalias_mime_type (mimetype); if( !mimetype ) { fprintf( stderr, _( "%s: Could not parse mimetype from argument '%s'\n"), MIMEDB, argv[i] ); error=1; return 1; } /* Convert from mimetype to whatever, if needed */ switch( output_type ) { case MIMETYPE: { output = (char *)mimetype; break; } case DESCRIPTION: { output = get_description( mimetype ); if( !output ) output = strdup( _("Unknown") ); break; } case ACTION: { output = get_action( mimetype ); break; } case LAUNCH: { /* There may be more files using the same launcher, we add them all up in little array_list_ts and launched them together after all the arguments have been parsed. */ output = 0; string_list_t &l = launch_hash[mimetype]; l.push_back(argv[i]); } } /* Print the glorious result */ if( output ) { printf( "%s\n", output ); if( output != mimetype ) free( output ); } output = 0; } /* Perform the actual launching */ if( output_type == LAUNCH && !error ) { for( launch_hash_t::iterator iter = launch_hash.begin(); iter != launch_hash.end(); ++iter) { const char *mimetype = iter->first.c_str(); string_list_t &files = iter->second; char *launcher = get_action( mimetype ); if( launcher ) { launch( launcher, files, 0 ); free( launcher ); } } } if( launch_buff ) free( launch_buff ); if( start_re ) { regfree( start_re ); regfree( stop_re ); free( start_re ); free( stop_re ); } xdg_mime_shutdown(); return error; }
static PyObject *shutdown (PyObject *self, PyObject *args) { xdg_mime_shutdown(); Py_RETURN_NONE; }