Example #1
0
static void
handle_required_components (GKeyFile               *keyfile,
                            gboolean                look_in_saved_session,
                            GsmFillHandleComponent  callback,
                            gpointer                user_data)
{
        char **required_components;
        int    i;

        g_assert (keyfile != NULL);
        g_assert (callback != NULL);

        required_components = g_key_file_get_string_list (keyfile,
                                                          GSM_KEYFILE_SESSION_GROUP,
                                                          GSM_KEYFILE_REQUIRED_COMPONENTS_KEY,
                                                          NULL, NULL);

        if (!required_components)
                return;

        for (i = 0; required_components[i] != NULL; i++) {
                char *app_path;

                app_path = gsm_util_find_desktop_file_for_app_name (required_components[i],
                                                                    look_in_saved_session, TRUE);
                callback (required_components[i], app_path, user_data);
                g_free (app_path);
        }

        g_strfreev (required_components);
}
/* This doesn't contain the required components, so we need to always
 * call append_required_apps() after a call to append_default_apps(). */
static void append_default_apps(GsmManager* manager, const char* default_session_key, char** autostart_dirs)
{
	gint i;
	gchar** default_apps;
	GSettings* settings;

	g_debug("main: *** Adding default apps");

	g_assert(default_session_key != NULL);
	g_assert(autostart_dirs != NULL);

	settings = g_settings_new (GSM_SCHEMA);
	default_apps = g_settings_get_strv (settings, default_session_key);
	g_object_unref(settings);

	for (i = 0; default_apps[i]; i++)
	{
		char* app_path;

		if (IS_STRING_EMPTY((char*) default_apps[i]))
		{
			continue;
		}

		app_path = gsm_util_find_desktop_file_for_app_name(default_apps[i], autostart_dirs);

		if (app_path != NULL)
		{
			gsm_manager_add_autostart_app(manager, app_path, NULL);
			g_free(app_path);
		}
	}

	g_strfreev (default_apps);
}
static void append_accessibility_apps(GsmManager* manager)
{
	GSettings* mobility_settings;
	GSettings* visual_settings;

	g_debug("main: *** Adding accesibility apps");

	mobility_settings = g_settings_new (MOBILITY_SCHEMA);
	visual_settings = g_settings_new (VISUAL_SCHEMA);

	if (g_settings_get_boolean (mobility_settings, MOBILITY_STARTUP_KEY))
	{
		gchar *mobility_exec;
		mobility_exec = g_settings_get_string (mobility_settings, MOBILITY_KEY);
		if (mobility_exec != NULL && mobility_exec[0] != 0)
		{
			char* app_path;
			app_path = gsm_util_find_desktop_file_for_app_name(mobility_exec, NULL);
			if (app_path != NULL)
			{
				gsm_manager_add_autostart_app(manager, app_path, NULL);
				g_free (app_path);
			}
			g_free (mobility_exec);
		}
	}

	if (g_settings_get_boolean (visual_settings, VISUAL_STARTUP_KEY))
	{
		gchar *visual_exec;
		visual_exec = g_settings_get_string (visual_settings, VISUAL_KEY);
		if (visual_exec != NULL && visual_exec[0] != 0)
		{
			char* app_path;
			app_path = gsm_util_find_desktop_file_for_app_name(visual_exec, NULL);
			if (app_path != NULL)
			{
				gsm_manager_add_autostart_app(manager, app_path, NULL);
				g_free (app_path);
			}
			g_free (visual_exec);
		}
	}

	g_object_unref (mobility_settings);
	g_object_unref (visual_settings);
}
static char *
get_desktop_file_path (GsmXSMPClient *client)
{
        SmProp     *prop;
        char       *desktop_file_path = NULL;
        char      **dirs;
        const char *program_name;

        /* XSMP clients using eggsmclient defines a special property
         * pointing to their respective desktop entry file */
        prop = find_property (client, GsmDesktopFile, NULL);

        if (prop) {
                GFile *file = g_file_new_for_uri (prop->vals[0].value);
                desktop_file_path = g_file_get_path (file);
                g_object_unref (file);
                goto out;
        }

        /* If we can't get desktop file from GsmDesktopFile then we
         * try to find the desktop file from its program name */
        prop = find_property (client, SmProgram, NULL);
        program_name = prop->vals[0].value;

        dirs = gsm_util_get_autostart_dirs ();

        desktop_file_path =
                gsm_util_find_desktop_file_for_app_name (program_name,
                                                         dirs);

        g_strfreev (dirs);

out:
        g_debug ("GsmXSMPClient: desktop file for client %s is %s",
                 gsm_client_peek_id (GSM_CLIENT (client)),
                 desktop_file_path ? desktop_file_path : "(null)");

        return desktop_file_path;
}
static void append_required_apps(GsmManager* manager)
{
	gchar** required_components;
	gint i;
	GSettings* settings;
	GSettings* settings_required_components;

	g_debug("main: *** Adding required apps");

	settings = g_settings_new (GSM_SCHEMA);
	settings_required_components = g_settings_new (GSM_REQUIRED_COMPONENTS_SCHEMA);

	required_components = g_settings_get_strv(settings, GSM_REQUIRED_COMPONENTS_LIST_KEY);

	if (required_components == NULL)
	{
		g_warning("No required applications specified");
	}

	for (i = 0; required_components[i]; i++)
	{
			char* default_provider;
			const char* component;

			if (IS_STRING_EMPTY((char*) required_components[i]))
			{
					continue;
			}

			component = required_components[i];

			default_provider = g_settings_get_string (settings_required_components, component);

			g_debug ("main: %s looking for component: '%s'", component, default_provider);

			if (default_provider != NULL)
			{
				char* app_path;

				app_path = gsm_util_find_desktop_file_for_app_name(default_provider, NULL);

				if (app_path != NULL)
				{
					gsm_manager_add_autostart_app(manager, app_path, component);
				}
				else
				{
					g_warning("Unable to find provider '%s' of required component '%s'", default_provider, component);
				}

				g_free(app_path);
			}

			g_free(default_provider);
	}

	g_debug("main: *** Done adding required apps");

	g_strfreev(required_components);

	g_object_unref(settings);
	g_object_unref(settings_required_components);
}