Exemplo n.º 1
0
void
LoadBaseConfig(void (*read_base_options_func) (const char *))
{
	if( read_base_options_func == NULL ) 
		return ;

	if( Session == NULL )
	{
		show_error("Session has not been properly initialized. Exiting");
		exit(1);
	}

	if (Session->overriding_file == NULL )
	{
		char *configfile = make_session_file(Session, BASE_FILE, False/* no longer use #bpp in filenames */ );
		if( configfile != NULL )
		{
			read_base_options_func (configfile);
			show_progress("BASE configuration loaded from \"%s\" ...", configfile);
			free( configfile );
		}else
		{
			show_warning("BASE configuration file cannot be found");
		}
	}else
		read_base_options_func (Session->overriding_file);
}
Exemplo n.º 2
0
void
LoadConfig (char *config_file_name,
						void (*read_options_func) (const char *))
{
	if (Session == NULL) {
		show_error ("Session has not been properly initialized. Exiting");
		exit (1);
	}
	if (Session->overriding_file == NULL) {
		char *configfile;
		const char *const_configfile;

		configfile = make_session_file (Session, config_file_name, False);
		if (configfile != NULL) {
			read_options_func (configfile);
			show_progress ("configuration loaded from \"%s\" ...", configfile);
			free (configfile);
		} else {
			show_warning ("configuration file \"%s\" cannot be found",
										config_file_name);
		}

		if ((const_configfile =
				 get_session_file (Session, 0, F_CHANGE_THEME, False)) != NULL) {
			read_options_func (const_configfile);
			show_progress ("THEME configuration loaded from \"%s\" ...",
										 const_configfile);
			if ((configfile =
					 make_session_data_file (Session, False, R_OK,
																	 THEME_OVERRIDE_FILE, NULL)) != NULL) {
				read_options_func (configfile);
				show_progress
						("THEME OVERRIDES configuration loaded from \"%s\" ...",
						 configfile);
				free (configfile);
			}
		}
	} else
		read_options_func (Session->overriding_file);
}
Exemplo n.º 3
0
Bool
ReloadASEnvironment (ASImageManager ** old_imageman,
										 ASFontManager ** old_fontman,
										 BaseConfig ** config_return, Bool flush_images,
										 Bool support_shared_images)
{
	char *old_pixmap_path = NULL;
	char *old_font_path = NULL;
	char *configfile = NULL;
	BaseConfig *config = NULL;
	ASEnvironment *e = NULL;
	ScreenInfo *scr = get_current_screen ();

	if (Environment != NULL) {
		old_pixmap_path = Environment->pixmap_path;
		Environment->pixmap_path = NULL;
		old_font_path = Environment->font_path;
		Environment->font_path = NULL;
	}

	configfile = Session->overriding_file;
	if (configfile == NULL)
		configfile =
				make_session_file (Session, BASE_FILE,
													 False /* no longer use #bpp in filenames */ );
	if (configfile != NULL) {
		config = ParseBaseOptions (configfile, MyName);
		if (config != NULL)
			show_progress ("BASE configuration loaded from \"%s\" ...",
										 configfile);
		else
			show_progress ("BASE could not be loaded from \"%s\" ...",
										 configfile);
		if (configfile != Session->overriding_file)
			free (configfile);
	} else
		show_warning ("BASE configuration file cannot be found");

	if (config == NULL) {
		if (Environment != NULL) {
			Environment->pixmap_path = old_pixmap_path;
			Environment->font_path = old_font_path;
			return False;
		}
		/* otherwise we should use default values  - Environment should never be NULL */
		Environment = make_default_environment ();
	} else {
		BaseConfig2ASEnvironment (config, &Environment);
		if (config_return)
			*config_return = config;
		else
			DestroyBaseConfig (config);
	}

	e = Environment;
	/* Save base filename to pass to modules */
	if (mystrcmp (old_pixmap_path, e->pixmap_path) == 0 ||
			(e->pixmap_path != NULL && scr->image_manager == NULL)
			|| flush_images) {
		reload_screen_image_manager (scr, old_imageman);
	}
	if (old_pixmap_path && old_pixmap_path != e->pixmap_path)
		free (old_pixmap_path);

	if (mystrcmp (old_font_path, e->font_path) == 0
			|| (e->font_path != NULL && scr->font_manager == NULL)) {
		if (old_fontman) {
			*old_fontman = scr->font_manager;
		} else if (scr->font_manager)
			destroy_font_manager (scr->font_manager, False);

		scr->font_manager = create_font_manager (dpy, e->font_path, NULL);
		set_xml_font_manager (scr->font_manager);
		show_progress ("Font Path changed to \"%s\" ...",
									 e->font_path ? e->font_path : "");
	}
	if (old_font_path && old_font_path != e->font_path)
		free (old_font_path);

	if (e->desk_pages_h > 0) {
		if (e->desk_pages_h <= 100)
			scr->VxMax = (e->desk_pages_h - 1) * scr->MyDisplayWidth;
		else {
			scr->VxMax =
					MAX (e->desk_pages_h, scr->MyDisplayWidth) - scr->MyDisplayWidth;
			e->desk_pages_h =
					(e->desk_pages_h + scr->MyDisplayWidth -
					 1) / scr->MyDisplayWidth;
		}
	} else
		scr->VxMax = 0;
	if (e->desk_pages_v > 0) {
		if (e->desk_pages_v <= 100)
			scr->VyMax = (e->desk_pages_v - 1) * scr->MyDisplayHeight;
		else {
			scr->VyMax =
					MAX (e->desk_pages_v,
							 scr->MyDisplayHeight) - scr->MyDisplayHeight;
			e->desk_pages_v =
					(e->desk_pages_v + scr->MyDisplayHeight -
					 1) / scr->MyDisplayHeight;
		}
	} else
		scr->VyMax = 0;

	scr->VScale = e->desk_scale;
	if (scr->VScale <= 1)
		scr->VScale = 2;
	else if (scr->VScale >= scr->MyDisplayHeight / 2)
		scr->VScale = scr->MyDisplayHeight / 2;

#ifdef XSHMIMAGE
	if (support_shared_images) {
		if (get_flags (e->flags, ASE_NoSharedMemory))
			disable_shmem_images ();
		else
			enable_shmem_images ();
	}
	SHOW_CHECKPOINT;
#endif


	return (config != NULL);
}
Exemplo n.º 4
0
void
Done (Bool restart, char *command )
{
    int restart_screen = get_flags( AfterStepState, ASS_SingleScreen)?Scr.screen:-1;
	Bool restart_self = False ; 
    char *local_command = NULL ;
	{
		static int already_dead = False ; 
		if( already_dead ) 	return;/* non-reentrant function ! */
		already_dead = True ;
	}

    /* lets duplicate the string so we don't accidental;y delete it while closing self down */
    if( restart )
	{
		int my_name_len = strlen(MyName);
		if( command ) 
		{
			if( strncmp(command, MyName, my_name_len )==0 )
				restart_self = (command[my_name_len] == ' '|| command[my_name_len] == '\0');
			local_command = mystrdup(command);
		}else 
		{		  
        	local_command = mystrdup(MyName);
			restart_self = True ;
	    }
		if (!is_executable_in_path(local_command))
		{
			if (!restart_self || MyArgs.saved_argv[0] == NULL)
			{
				show_error("Cannot restart with command \"%s\" - application is not in PATH!", local_command);
				return;
			}
			free(local_command);
			if (command)
			{
				local_command = safemalloc(strlen(command) + 1+ strlen(MyArgs.saved_argv[0])+1);
				sprintf( local_command, "%s %s", MyArgs.saved_argv[0], command + my_name_len);
			}else
				local_command = mystrdup(MyArgs.saved_argv[0]);
		}
	}


#ifdef XSHMIMAGE
	/* may not need to do that as server may still have some of the shared 
	 * memory and work in it */
	flush_shm_cache();
#endif

LOCAL_DEBUG_CALLER_OUT( "%s restart, cmd=\"%s\"", restart?"Do":"Don't", command?command:"");

	XSelectInput( dpy, Scr.Root, 0 );	   
	SendPacket (-1, M_SHUTDOWN, 0);
	FlushAllQueues(); 
	sleep_a_millisec(1000);

	LOCAL_DEBUG_OUT( "local_command = \"%s\", restart_self = %s", local_command, restart_self?"Yes":"No"); 
    set_flags( AfterStepState, ASS_Shutdown );
    if( restart )
        set_flags( AfterStepState, ASS_Restarting );
    clear_flags( AfterStepState, ASS_NormalOperation );
#ifndef NO_VIRTUAL
    MoveViewport (0, 0, False);
#endif
#ifndef NO_SAVEWINDOWS
	if (!restart)
    {
        char *fname = make_session_file( Session, AFTER_SAVE, False );
        save_aswindow_list( Scr.Windows, NULL );
        free( fname );
    }
#endif

	/* Close all my pipes */
    ShutdownModules(False);

    desktop_cover_cleanup();
    
	/* remove window frames */
    CleanupScreen();
    /* Really make sure that the connection is closed and cleared! */
    XSync (dpy, 0);

	if (ASDBus_fd>=0)
		asdbus_shutdown();

#ifdef XSHMIMAGE
	flush_shm_cache();
#endif
	if (restart)
	{
		set_flags( MyArgs.flags, ASS_Restarting );
        spawn_child( local_command, -1, restart_screen, original_DISPLAY_string,
                     None, C_NO_CONTEXT, False, restart_self, NULL );
    } else
	{

	    XCloseDisplay (dpy);
		dpy = NULL ;

		/* freeing up memory */
		DestroyPendingFunctionsQueue();
		DestroyCategories();

	    cleanup_default_balloons();
		destroy_asdatabase();
    	destroy_assession( Session );
		destroy_asenvironment( &Environment );
    	/* pixmap references */
    	build_xpm_colormap (NULL);

		free_scratch_ids_vector();
		free_scratch_layers_vector();		
        clientprops_cleanup ();
        wmprops_cleanup ();

        free_func_hash();
		flush_keyword_ids();
        purge_asimage_registry();
	
		asxml_var_cleanup();
		custom_color_cleanup(); 

        free_as_app_args();
		free( ASDefaultScr );

		flush_default_asstorage();
        flush_asbidirlist_memory_pool();
        flush_ashash_memory_pool();
#ifdef DEBUG_ALLOCS
        print_unfreed_mem ();
#endif /*DEBUG_ALLOCS */
#ifdef XSHMIMAGE
		flush_shm_cache();
#endif
    
	}
    exit(0);
}