From b34dc27b7b191e56cbf640a963435d6e68982608 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Tue, 2 Oct 2012 20:05:07 +0200 Subject: migrate to gsettings --- mate-session/Makefile.am | 6 -- mate-session/README | 2 +- mate-session/gsm-autostart-app.c | 104 ++++++++++-------- mate-session/gsm-inhibit-dialog.c | 2 - mate-session/gsm-manager.c | 216 ++++++++++---------------------------- mate-session/gsm-mateconf.c | 143 ------------------------- mate-session/gsm-mateconf.h | 31 ------ mate-session/main.c | 81 ++++++-------- 8 files changed, 147 insertions(+), 438 deletions(-) delete mode 100644 mate-session/gsm-mateconf.c delete mode 100644 mate-session/gsm-mateconf.h (limited to 'mate-session') diff --git a/mate-session/Makefile.am b/mate-session/Makefile.am index ee98a30..b2ddcbd 100644 --- a/mate-session/Makefile.am +++ b/mate-session/Makefile.am @@ -33,8 +33,6 @@ mate_session_SOURCES = \ gs-idle-monitor.c \ gsm-presence.h \ gsm-presence.c \ - gsm-mateconf.c \ - gsm-mateconf.h \ mdm.h \ mdm.c \ mdm-signal-handler.h \ @@ -58,14 +56,11 @@ mate_session_CPPFLAGS = \ $(SM_CFLAGS) \ $(ICE_CFLAGS) \ $(XEXT_CFLAGS) \ - $(MATECONF_CFLAGS) \ -I$(top_srcdir)/egg \ -DLOCALE_DIR=\""$(datadir)/locale"\" \ -DDATA_DIR=\""$(datadir)/mate-session"\" \ -DLIBEXECDIR=\"$(libexecdir)\" \ -DGTKBUILDER_DIR=\""$(pkgdatadir)"\" \ - -DMATECONF_SANITY_CHECK=\""$(MATECONF_SANITY_CHECK)"\" \ - -DMATECONFTOOL_CMD=\"$(MATECONFTOOL)\" \ -DI_KNOW_THE_DEVICEKIT_POWER_API_IS_SUBJECT_TO_CHANGE mate_session_LDADD = \ @@ -77,7 +72,6 @@ mate_session_LDADD = \ $(XTEST_LIBS) \ $(XEXT_LIBS) \ $(MATE_SESSION_LIBS) \ - $(MATECONF_LIBS) \ $(EXECINFO_LIBS) libgsmutil_la_SOURCES = \ diff --git a/mate-session/README b/mate-session/README index 05bfe9d..5b4e67b 100644 --- a/mate-session/README +++ b/mate-session/README @@ -12,7 +12,7 @@ represents an app resumed from the previous saved session.) Startup is divided into 6 phases (GsmSessionPhase): * GSM_SESSION_PHASE_STARTUP covers mate-session's internal - startup, which also includes starting mateconfd and dbus-daemon (if + startup, which also includes starting dbus-daemon (if it's not already running). Mate-session starts up those explicitly because it needs them for its own purposes. diff --git a/mate-session/gsm-autostart-app.c b/mate-session/gsm-autostart-app.c index a696a96..b6272ee 100644 --- a/mate-session/gsm-autostart-app.c +++ b/mate-session/gsm-autostart-app.c @@ -29,8 +29,6 @@ #include #include -#include - #include "gsm-autostart-app.h" #include "gsm-util.h" @@ -62,7 +60,7 @@ struct _GsmAutostartAppPrivate { gboolean autorestart; GFileMonitor *condition_monitor; - guint condition_notify_id; + GSettings *condition_settings; int launch_type; GPid pid; @@ -238,10 +236,9 @@ unless_exists_condition_cb (GFileMonitor *monitor, } static void -mateconf_condition_cb (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - gpointer user_data) +gsettings_condition_cb (GSettings *settings, + const char *key, + gpointer user_data) { GsmApp *app; GsmAutostartAppPrivate *priv; @@ -253,10 +250,7 @@ mateconf_condition_cb (MateConfClient *client, priv = GSM_AUTOSTART_APP (app)->priv; - condition = FALSE; - if (entry->value != NULL && entry->value->type == MATECONF_VALUE_BOOL) { - condition = mateconf_value_get_bool (entry->value); - } + condition = g_settings_get_boolean (settings, key); g_debug ("GsmAutostartApp: app:%s condition changed condition:%d", gsm_app_peek_id (app), @@ -269,6 +263,53 @@ mateconf_condition_cb (MateConfClient *client, } } +static gboolean +setup_gsettings_condition_monitor (GsmAutostartApp *app, + const char *key) +{ + GSettings *settings; + const char * const *schemas; + char **elems; + gboolean schema_exists; + guint i; + gboolean retval; + char *signal; + + elems = g_strsplit (key, " ", 2); + if (elems == NULL) + return FALSE; + if (elems[0] == NULL || elems[1] == NULL) { + g_strfreev (elems); + return FALSE; + } + + schemas = g_settings_list_schemas (); + schema_exists = FALSE; + for (i = 0; schemas[i] != NULL; i++) { + if (g_str_equal (schemas[i], elems[0])) { + schema_exists = TRUE; + break; + } + } + + if (schema_exists == FALSE) + return FALSE; + + settings = g_settings_new (elems[0]); + retval = g_settings_get_boolean (settings, elems[1]); + + signal = g_strdup_printf ("changed::%s", elems[1]); + g_signal_connect (G_OBJECT (settings), signal, + G_CALLBACK (gsettings_condition_cb), app); + g_free (signal); + + app->priv->condition_settings = settings; + + g_strfreev (elems); + + return retval; +} + static void setup_condition_monitor (GsmAutostartApp *app) { @@ -281,12 +322,9 @@ setup_condition_monitor (GsmAutostartApp *app) g_file_monitor_cancel (app->priv->condition_monitor); } - if (app->priv->condition_notify_id > 0) { - MateConfClient *client; - client = mateconf_client_get_default (); - mateconf_client_notify_remove (client, - app->priv->condition_notify_id); - app->priv->condition_notify_id = 0; + if (app->priv->condition_settings != NULL) { + g_object_unref (app->priv->condition_settings); + app->priv->condition_settings = NULL; } if (app->priv->condition_string == NULL) { @@ -344,26 +382,7 @@ setup_condition_monitor (GsmAutostartApp *app) g_object_unref (file); g_free (file_path); } else if (kind == GSM_CONDITION_MATE) { - MateConfClient *client; - char *dir; - - client = mateconf_client_get_default (); - g_assert (MATECONF_IS_CLIENT (client)); - - disabled = !mateconf_client_get_bool (client, key, NULL); - - dir = g_path_get_dirname (key); - - mateconf_client_add_dir (client, - dir, - MATECONF_CLIENT_PRELOAD_NONE, NULL); - g_free (dir); - - app->priv->condition_notify_id = mateconf_client_notify_add (client, - key, - mateconf_condition_cb, - app, NULL, NULL); - g_object_unref (client); + disabled = !setup_gsettings_condition_monitor (app, key); } else { disabled = TRUE; } @@ -641,12 +660,11 @@ is_conditionally_disabled (GsmApp *app) file_path = g_build_filename (g_get_user_config_dir (), key, NULL); disabled = g_file_test (file_path, G_FILE_TEST_EXISTS); g_free (file_path); - } else if (kind == GSM_CONDITION_MATE) { - MateConfClient *client; - client = mateconf_client_get_default (); - g_assert (MATECONF_IS_CLIENT (client)); - disabled = !mateconf_client_get_bool (client, key, NULL); - g_object_unref (client); + } else if (kind == GSM_CONDITION_MATE && priv->condition_settings != NULL) { + char **elems; + elems = g_strsplit (key, " ", 2); + disabled = !g_settings_get_boolean (priv->condition_settings, elems[1]); + g_strfreev (elems); } else { disabled = TRUE; } diff --git a/mate-session/gsm-inhibit-dialog.c b/mate-session/gsm-inhibit-dialog.c index 53b0d08..3587d33 100644 --- a/mate-session/gsm-inhibit-dialog.c +++ b/mate-session/gsm-inhibit-dialog.c @@ -31,8 +31,6 @@ #include #include -#include - #include "gsm-inhibit-dialog.h" #include "gsm-store.h" #include "gsm-client.h" diff --git a/mate-session/gsm-manager.c b/mate-session/gsm-manager.c index 8bdc49e..b0ce46b 100644 --- a/mate-session/gsm-manager.c +++ b/mate-session/gsm-manager.c @@ -41,7 +41,7 @@ #include #include /* for logout dialog */ -#include +#include /* for gsettings */ #include "gsm-manager.h" #include "gsm-manager-glue.h" @@ -76,17 +76,16 @@ #define GDM_FLEXISERVER_ARGS "--startnew Standard" -#define KEY_LOCKDOWN_DIR "/desktop/mate/lockdown" -#define KEY_LOCK_DISABLE KEY_LOCKDOWN_DIR "/disable_lock_screen" -#define KEY_USER_SWITCH_DISABLE KEY_LOCKDOWN_DIR "/disable_user_switching" +#define LOCKDOWN_SCHEMA "org.mate.lockdown" +#define KEY_LOCK_DISABLE "disable-lock-screen" +#define KEY_USER_SWITCH_DISABLE "disable-user-switching" -#define KEY_DESKTOP_DIR "/desktop/mate/session" -#define KEY_IDLE_DELAY KEY_DESKTOP_DIR "/idle_delay" +#define SESSION_SCHEMA "org.mate.session" +#define KEY_IDLE_DELAY "idle-delay" +#define KEY_AUTOSAVE "auto-save-session" -#define KEY_MATE_SESSION_DIR "/apps/mate-session/options" -#define KEY_AUTOSAVE KEY_MATE_SESSION_DIR "/auto_save_session" - -#define KEY_SLEEP_LOCK "/apps/mate-screensaver/lock_enabled" +#define SCREENSAVER_SCHEMA "org.mate.screensaver" +#define KEY_SLEEP_LOCK "lock-enabled" #define IS_STRING_EMPTY(x) ((x)==NULL||(x)[0]=='\0') @@ -130,9 +129,8 @@ struct GsmManagerPrivate * and shouldn't be automatically restarted */ GSList *condition_clients; - MateConfClient *mateconf_client; - guint desktop_notify_id; - guint lockdown_notify_id; + GSettings *settings_session; + GSettings *settings_lockdown; DBusGProxy *bus_proxy; DBusGConnection *connection; @@ -964,23 +962,8 @@ manager_switch_user (GsmManager *manager) static gboolean sleep_lock_is_enabled (GsmManager *manager) { - GError *error; - gboolean enable_lock; - - error = NULL; - enable_lock = mateconf_client_get_bool (manager->priv->mateconf_client, - KEY_SLEEP_LOCK, &error); - - if (error) { - g_warning ("Error retrieving configuration key '%s': %s", - KEY_SLEEP_LOCK, error->message); - g_error_free (error); - - /* If we fail to query mateconf key, just enable locking */ - enable_lock = TRUE; - } - - return enable_lock; + return g_settings_get_boolean (manager->priv->settings_lockdown, + KEY_SLEEP_LOCK); } static void @@ -1823,25 +1806,8 @@ on_xsmp_client_register_request (GsmXSMPClient *client, static gboolean auto_save_is_enabled (GsmManager *manager) { - GError *error; - gboolean auto_save; - - error = NULL; - auto_save = mateconf_client_get_bool (manager->priv->mateconf_client, - KEY_AUTOSAVE, - &error); - - if (error) { - g_warning ("Error retrieving configuration key '%s': %s", - KEY_AUTOSAVE, - error->message); - g_error_free (error); - - /* If we fail to query mateconf key, disable auto save */ - auto_save = FALSE; - } - - return auto_save; + return g_settings_get_boolean (manager->priv->settings_session, + KEY_AUTOSAVE); } static void @@ -2197,26 +2163,14 @@ gsm_manager_dispose (GObject *object) manager->priv->presence = NULL; } - if (manager->priv->mateconf_client) { - if (manager->priv->desktop_notify_id != 0) { - mateconf_client_remove_dir (manager->priv->mateconf_client, - KEY_DESKTOP_DIR, - NULL); - mateconf_client_notify_remove (manager->priv->mateconf_client, - manager->priv->desktop_notify_id); - manager->priv->desktop_notify_id = 0; - } - if (manager->priv->lockdown_notify_id != 0) { - mateconf_client_remove_dir (manager->priv->mateconf_client, - KEY_LOCKDOWN_DIR, - NULL); - mateconf_client_notify_remove (manager->priv->mateconf_client, - manager->priv->lockdown_notify_id); - manager->priv->lockdown_notify_id = 0; - } + if (manager->priv->settings_session) { + g_object_unref (manager->priv->settings_session); + manager->priv->settings_session = NULL; + } - g_object_unref (manager->priv->mateconf_client); - manager->priv->mateconf_client = NULL; + if (manager->priv->settings_lockdown) { + g_object_unref (manager->priv->settings_lockdown); + manager->priv->settings_lockdown = NULL; } if (manager->priv->up_client != NULL) { @@ -2332,83 +2286,29 @@ gsm_manager_class_init (GsmManagerClass *klass) } static void -invalid_type_warning (const char *type) +load_idle_delay_from_gsettings (GsmManager *manager) { - g_warning ("Error retrieving configuration key '%s': Invalid type", - type); -} - -static void -load_idle_delay_from_mateconf (GsmManager *manager) -{ - GError *error; glong value; - - error = NULL; - value = mateconf_client_get_int (manager->priv->mateconf_client, - KEY_IDLE_DELAY, - &error); - if (error == NULL) { - gsm_presence_set_idle_timeout (manager->priv->presence, value * 60000); - } else { - g_warning ("Error retrieving configuration key '%s': %s", - KEY_IDLE_DELAY, - error->message); - g_error_free (error); - } - + value = g_settings_get_int (manager->priv->settings_session, + KEY_IDLE_DELAY); + gsm_presence_set_idle_timeout (manager->priv->presence, value * 60000); } static void -on_mateconf_key_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - GsmManager *manager) -{ - const char *key; - MateConfValue *value; - - key = mateconf_entry_get_key (entry); - - if (! g_str_has_prefix (key, KEY_DESKTOP_DIR) - && ! g_str_has_prefix (key, KEY_LOCKDOWN_DIR)) { - return; - } - - value = mateconf_entry_get_value (entry); - - if (strcmp (key, KEY_IDLE_DELAY) == 0) { - if (value->type == MATECONF_VALUE_INT) { - int delay; - - delay = mateconf_value_get_int (value); - - gsm_presence_set_idle_timeout (manager->priv->presence, delay * 60000); - } else { - invalid_type_warning (key); - } - } else if (strcmp (key, KEY_LOCK_DISABLE) == 0) { - if (value->type == MATECONF_VALUE_BOOL) { - gboolean disabled; - - disabled = mateconf_value_get_bool (value); - - /* FIXME: handle this */ - } else { - invalid_type_warning (key); - } - } else if (strcmp (key, KEY_USER_SWITCH_DISABLE) == 0) { - - if (value->type == MATECONF_VALUE_BOOL) { - gboolean disabled; - - disabled = mateconf_value_get_bool (value); - - /* FIXME: handle this */ - } else { - invalid_type_warning (key); - } - +on_gsettings_key_changed (GSettings *settings, + gchar *key, + GsmManager *manager) +{ + if (g_strcmp0 (key, KEY_IDLE_DELAY) == 0) { + int delay; + delay = g_settings_get_int (settings, key); + gsm_presence_set_idle_timeout (manager->priv->presence, delay * 60000); + } else if (g_strcmp0 (key, KEY_LOCK_DISABLE) == 0) { + gboolean disabled; + disabled = g_settings_get_boolean (settings, key); + } else if (g_strcmp0 (key, KEY_USER_SWITCH_DISABLE) == 0) { + gboolean disabled; + disabled = g_settings_get_boolean (settings, key); } else { g_debug ("Config key not handled: %s", key); } @@ -2432,7 +2332,8 @@ gsm_manager_init (GsmManager *manager) manager->priv = GSM_MANAGER_GET_PRIVATE (manager); - manager->priv->mateconf_client = mateconf_client_get_default (); + manager->priv->settings_session = g_settings_new (SESSION_SCHEMA); + manager->priv->settings_lockdown = g_settings_new (LOCKDOWN_SCHEMA); manager->priv->inhibitors = gsm_store_new (); g_signal_connect (manager->priv->inhibitors, @@ -2454,26 +2355,16 @@ gsm_manager_init (GsmManager *manager) manager->priv->up_client = up_client_new (); - /* MateConf setup */ - mateconf_client_add_dir (manager->priv->mateconf_client, - KEY_DESKTOP_DIR, - MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL); - mateconf_client_add_dir (manager->priv->mateconf_client, - KEY_LOCKDOWN_DIR, - MATECONF_CLIENT_PRELOAD_NONE, NULL); - - manager->priv->desktop_notify_id = mateconf_client_notify_add (manager->priv->mateconf_client, - KEY_DESKTOP_DIR, - (MateConfClientNotifyFunc)on_mateconf_key_changed, - manager, - NULL, NULL); - manager->priv->lockdown_notify_id = mateconf_client_notify_add (manager->priv->mateconf_client, - KEY_LOCKDOWN_DIR, - (MateConfClientNotifyFunc)on_mateconf_key_changed, - manager, - NULL, NULL); + g_signal_connect (manager->priv->settings_session, + "changed", + G_CALLBACK (on_gsettings_key_changed), + manager); + g_signal_connect (manager->priv->settings_lockdown, + "changed", + G_CALLBACK (on_gsettings_key_changed), + manager); - load_idle_delay_from_mateconf (manager); + load_idle_delay_from_gsettings (manager); } static void @@ -2914,9 +2805,8 @@ user_logout (GsmManager *manager, } logout_prompt = - mateconf_client_get_bool (manager->priv->mateconf_client, - "/apps/mate-session/options/logout_prompt", - NULL); + g_settings_get_boolean (manager->priv->settings_session, + "logout-prompt"); /* Global settings overides input parameter in order to disable confirmation * dialog accordingly. If we're shutting down, we always show the confirmation diff --git a/mate-session/gsm-mateconf.c b/mate-session/gsm-mateconf.c deleted file mode 100644 index cd5adc4..0000000 --- a/mate-session/gsm-mateconf.c +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * gsm-mateconf.c - * Copyright (C) 2007 Novell, Inc. - * - * FIXME: (C) on mateconf-sanity-check call, gsm_get_conf_client, - * gsm_shutdown_mateconfd - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include -#include - -#include "gsm-mateconf.h" -#include "gsm-util.h" - -static pid_t gsc_pid; - -static void unset_display_setup (gpointer user_data); - -/** - * gsm_mateconf_init: - * - * Starts mateconfd asynchronously if it is not already running. This - * must be called very soon after startup. It requires no - * initialization beyond g_type_init(). - **/ -void -gsm_mateconf_init (void) -{ - GError *error = NULL; - char *argv[2]; - - /* Run mateconf-sanity-check. As a side effect, this will cause mateconfd - * to be started. (We do this asynchronously so that other GSM - * initialization can happen in parallel.) - */ - - argv[0] = MATECONF_SANITY_CHECK; - argv[1] = NULL; - - g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, - unset_display_setup, NULL, &gsc_pid, &error); - if (error != NULL) { - g_warning ("Failed to run mateconf-sanity-check-2: %s\n", - error->message); - g_error_free (error); - - /* This probably means mateconf-sanity-check wasn't found, which - * really shouldn't happen, but we'll just ignore it for now as - * long as mateconf seems to be working later on... - */ - - gsc_pid = 0; - } -} - -static void -unset_display_setup (gpointer user_data) -{ - /* Unset DISPLAY to make sure mateconf-sanity-check spews errors to - * stderr instead of trying to show a dialog (since it doesn't - * compensate for the fact that a window manager isn't running yet.) - */ - g_unsetenv ("DISPLAY"); -} - -/** - * gsm_mateconf_check: - * - * Verifies that gsm_mateconf_init() succeeded. (Exits with an error - * dialog on failure.) - **/ -void -gsm_mateconf_check (void) -{ - if (gsc_pid) { - int status; - - /* Wait for mateconf-sanity-check to finish */ - while (waitpid (gsc_pid, &status, 0) != gsc_pid) { - ; - } - gsc_pid = 0; - - if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) { - /* FIXME: capture mateconf-sanity-check's stderr */ - gsm_util_init_error (TRUE, - _("There is a problem with the configuration server.\n" - "(%s exited with status %d)"), - MATECONF_SANITY_CHECK, status); - } - } -} - -/** - * gsm_mateconf_shutdown: - * - * Shuts down mateconfd before exiting. - * - * FIXME: does this need to be called even if mateconf-sanity-check fails? - **/ -void -gsm_mateconf_shutdown (void) -{ - GError *error; - char *command; - int status; - - command = g_strjoin (" ", MATECONFTOOL_CMD, "--shutdown", NULL); - - status = 0; - error = NULL; - if (!g_spawn_command_line_sync (command, NULL, NULL, &status, &error)) { - g_warning ("Failed to execute '%s' on logout: %s\n", - command, error->message); - g_error_free (error); - } - - if (status) { - g_warning ("Running '%s' at logout returned an exit status of '%d'", - command, status); - } - - g_free (command); -} diff --git a/mate-session/gsm-mateconf.h b/mate-session/gsm-mateconf.h deleted file mode 100644 index d30d548..0000000 --- a/mate-session/gsm-mateconf.h +++ /dev/null @@ -1,31 +0,0 @@ -/* gsm-mateconf.h - * Copyright (C) 2007 Novell, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __GSM_MATECONF_H__ -#define __GSM_MATECONF_H__ - -#include - -void gsm_mateconf_init (void); -void gsm_mateconf_check (void); -void gsm_mateconf_shutdown (void); - -MateConfClient *gsm_mateconf_get_client (void); - -#endif /* __GSM_MATECONF_H__ */ diff --git a/mate-session/main.c b/mate-session/main.c index 2d7dd64..5b1171a 100644 --- a/mate-session/main.c +++ b/mate-session/main.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -41,15 +42,15 @@ #include "mdm-log.h" #include "gsm-consolekit.h" -#include "gsm-mateconf.h" #include "gsm-util.h" #include "gsm-manager.h" #include "gsm-xsmp-server.h" #include "gsm-store.h" -#define GSM_MATECONF_DEFAULT_SESSION_KEY "/desktop/mate/session/default_session" -#define GSM_MATECONF_REQUIRED_COMPONENTS_DIRECTORY "/desktop/mate/session/required_components" -#define GSM_MATECONF_REQUIRED_COMPONENTS_LIST_KEY "/desktop/mate/session/required_components_list" +#define GSM_SCHEMA "org.mate.session" +#define GSM_DEFAULT_SESSION_KEY "default-session" +#define GSM_REQUIRED_COMPONENTS_SCHEMA GSM_SCHEMA ".required-components" +#define GSM_REQUIRED_COMPONENTS_LIST_KEY "required-components-list" #define GSM_DBUS_NAME "org.mate.SessionManager" @@ -156,29 +157,29 @@ static gboolean acquire_name(void) * 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) { - GSList* default_apps; - GSList* a; - MateConfClient* client; + gint i; + gchar** default_apps; + GSettings* settings; g_debug("main: *** Adding default apps"); g_assert(default_session_key != NULL); g_assert(autostart_dirs != NULL); - client = mateconf_client_get_default(); - default_apps = mateconf_client_get_list(client, default_session_key, MATECONF_VALUE_STRING, NULL); - g_object_unref(client); + settings = g_settings_new (GSM_SCHEMA); + default_apps = g_settings_get_strv (settings, default_session_key); + g_object_unref(settings); - for (a = default_apps; a; a = a->next) + for (i = 0; default_apps[i]; i++) { char* app_path; - if (IS_STRING_EMPTY((char*) a->data)) + if (IS_STRING_EMPTY((char*) default_apps[i])) { continue; } - app_path = gsm_util_find_desktop_file_for_app_name(a->data, autostart_dirs); + app_path = gsm_util_find_desktop_file_for_app_name(default_apps[i], autostart_dirs); if (app_path != NULL) { @@ -187,44 +188,43 @@ static void append_default_apps(GsmManager* manager, const char* default_session } } - g_slist_foreach(default_apps, (GFunc) g_free, NULL); - g_slist_free(default_apps); + g_strfreev (default_apps); } static void append_required_apps(GsmManager* manager) { - GSList* required_components; - GSList* r; - MateConfClient* client; + gchar** required_components; + gint i; + GSettings* settings; + GSettings* settings_required_components; g_debug("main: *** Adding required apps"); - client = mateconf_client_get_default(); - required_components = mateconf_client_get_list(client, GSM_MATECONF_REQUIRED_COMPONENTS_LIST_KEY, MATECONF_VALUE_STRING, NULL); + 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 (r = required_components; r != NULL; r = r->next) + for (i = 0; required_components[i]; i++) { - char* path; char* default_provider; const char* component; - if (IS_STRING_EMPTY((char*) r->data)) + if (IS_STRING_EMPTY((char*) required_components[i])) { continue; } - component = r->data; - - path = g_strdup_printf("%s/%s", GSM_MATECONF_REQUIRED_COMPONENTS_DIRECTORY, component); + component = required_components[i]; - default_provider = mateconf_client_get_string(client, path, NULL); + default_provider = g_settings_get_string (settings_required_components, component); - g_debug ("main: %s looking for component: '%s'", path, default_provider); + g_debug ("main: %s looking for component: '%s'", component, default_provider); if (default_provider != NULL) { @@ -245,15 +245,14 @@ static void append_required_apps(GsmManager* manager) } g_free(default_provider); - g_free(path); } g_debug("main: *** Done adding required apps"); - g_slist_foreach(required_components, (GFunc) g_free, NULL); - g_slist_free(required_components); + g_strfreev(required_components); - g_object_unref(client); + g_object_unref(settings); + g_object_unref(settings_required_components); } static void maybe_load_saved_session_apps(GsmManager* manager) @@ -417,11 +416,9 @@ int main(int argc, char** argv) GsmXsmpServer* xsmp_server; MdmSignalHandler* signal_handler; static char** override_autostart_dirs = NULL; - static char* default_session_key = NULL; static GOptionEntry entries[] = { {"autostart", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &override_autostart_dirs, N_("Override standard autostart directories"), NULL}, - {"default-session-key", 0, 0, G_OPTION_ARG_STRING, &default_session_key, N_("MateConf key used to look up default session"), NULL}, {"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL}, {"failsafe", 'f', 0, G_OPTION_ARG_NONE, &failsafe, N_("Do not load user-specified applications"), NULL}, {"version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL}, @@ -475,16 +472,11 @@ int main(int argc, char** argv) client_store = gsm_store_new(); - - /* Start up mateconfd if not already running. */ - gsm_mateconf_init(); - xsmp_server = gsm_xsmp_server_new(client_store); /* Now make sure they succeeded. (They'll call * gsm_util_init_error() if they failed.) */ - gsm_mateconf_check(); acquire_name(); manager = gsm_manager_new(client_store, failsafe); @@ -504,14 +496,7 @@ int main(int argc, char** argv) } else { - if (!IS_STRING_EMPTY(default_session_key)) - { - load_standard_apps(manager, default_session_key); - } - else - { - load_standard_apps(manager, GSM_MATECONF_DEFAULT_SESSION_KEY); - } + load_standard_apps(manager, GSM_DEFAULT_SESSION_KEY); } gsm_xsmp_server_start(xsmp_server); @@ -535,8 +520,6 @@ int main(int argc, char** argv) g_object_unref(client_store); } - gsm_mateconf_shutdown(); - mdm_log_shutdown(); return 0; -- cgit v1.2.1