diff options
author | yetist <[email protected]> | 2018-11-13 19:10:13 +0800 |
---|---|---|
committer | raveit65 <[email protected]> | 2018-11-26 13:00:30 +0100 |
commit | f3e8cce5adf6a73c9eb44885014b6872979f4704 (patch) | |
tree | 2711676a563b882c37491101b1e2c982a499b9c1 | |
parent | 6934f934da478bb23fc85cf83d8ba5d620ec7995 (diff) | |
download | mate-session-manager-f3e8cce5adf6a73c9eb44885014b6872979f4704.tar.bz2 mate-session-manager-f3e8cce5adf6a73c9eb44885014b6872979f4704.tar.xz |
Avoid compile warning for g_type_class_add_private
Fixes the issue with GLib >= 2.58, list of modified files:
- mate-session/gsm-manager.c
- mate-session/gsm-manager.h
-rw-r--r-- | mate-session/gsm-manager.c | 805 | ||||
-rw-r--r-- | mate-session/gsm-manager.h | 27 |
2 files changed, 516 insertions, 316 deletions
diff --git a/mate-session/gsm-manager.c b/mate-session/gsm-manager.c index 96205b1..5cd7771 100644 --- a/mate-session/gsm-manager.c +++ b/mate-session/gsm-manager.c @@ -113,8 +113,7 @@ typedef enum GSM_MANAGER_LOGOUT_SHUTDOWN_MDM } GsmManagerLogoutType; -struct GsmManagerPrivate -{ +typedef struct { gboolean failsafe; GsmStore *clients; GsmStore *inhibitors; @@ -147,7 +146,7 @@ struct GsmManagerPrivate DBusGProxy *bus_proxy; DBusGConnection *connection; -}; +} GsmManagerPrivate; enum { PROP_0, @@ -187,7 +186,7 @@ static void maybe_save_session (GsmManager *manager); static gpointer manager_object = NULL; -G_DEFINE_TYPE (GsmManager, gsm_manager, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GsmManager, gsm_manager, G_TYPE_OBJECT) GQuark gsm_manager_error_quark (void) @@ -239,7 +238,9 @@ _debug_client (const char *id, static void debug_clients (GsmManager *manager) { - gsm_store_foreach (manager->priv->clients, + GsmManagerPrivate *priv; + priv = gsm_manager_get_instance_private (manager); + gsm_store_foreach (priv->clients, (GsmStoreFunc)_debug_client, manager); } @@ -260,7 +261,10 @@ _debug_inhibitor (const char *id, static void debug_inhibitors (GsmManager *manager) { - gsm_store_foreach (manager->priv->inhibitors, + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); + gsm_store_foreach (priv->inhibitors, (GsmStoreFunc)_debug_inhibitor, manager); } @@ -298,12 +302,15 @@ app_condition_changed (GsmApp *app, GsmManager *manager) { GsmClient *client; + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); g_debug ("GsmManager: app:%s condition changed condition:%d", gsm_app_peek_id (app), condition); - client = (GsmClient *)gsm_store_find (manager->priv->clients, + client = (GsmClient *)gsm_store_find (priv->clients, (GsmStoreFunc)_find_by_startup_id, (char *)gsm_app_peek_startup_id (app)); @@ -331,8 +338,8 @@ app_condition_changed (GsmApp *app, /* Kill client in case condition if false and make sure it won't * be automatically restarted by adding the client to * condition_clients */ - manager->priv->condition_clients = - g_slist_prepend (manager->priv->condition_clients, client); + priv->condition_clients = + g_slist_prepend (priv->condition_clients, client); g_debug ("GsmManager: stopping client %s for app", gsm_client_peek_id (client)); @@ -445,14 +452,16 @@ static void gsm_manager_quit (GsmManager *manager) { GsmConsolekit *consolekit; + GsmManagerPrivate *priv; #ifdef HAVE_SYSTEMD GsmSystemd *systemd; #endif + priv = gsm_manager_get_instance_private (manager); /* See the comment in request_reboot() for some more details about how * this works. */ - switch (manager->priv->logout_type) { + switch (priv->logout_type) { case GSM_MANAGER_LOGOUT_LOGOUT: gtk_main_quit (); break; @@ -523,26 +532,29 @@ gsm_manager_quit (GsmManager *manager) static void end_phase (GsmManager *manager) { + GsmManagerPrivate *priv; gboolean start_next_phase = TRUE; + priv = gsm_manager_get_instance_private (manager); + g_debug ("GsmManager: ending phase %s\n", - phase_num_to_name (manager->priv->phase)); + phase_num_to_name (priv->phase)); - g_slist_free (manager->priv->pending_apps); - manager->priv->pending_apps = NULL; + g_slist_free (priv->pending_apps); + priv->pending_apps = NULL; - g_slist_free (manager->priv->query_clients); - manager->priv->query_clients = NULL; + g_slist_free (priv->query_clients); + priv->query_clients = NULL; - g_slist_free (manager->priv->next_query_clients); - manager->priv->next_query_clients = NULL; + g_slist_free (priv->next_query_clients); + priv->next_query_clients = NULL; - if (manager->priv->phase_timeout_id > 0) { - g_source_remove (manager->priv->phase_timeout_id); - manager->priv->phase_timeout_id = 0; + if (priv->phase_timeout_id > 0) { + g_source_remove (priv->phase_timeout_id); + priv->phase_timeout_id = 0; } - switch (manager->priv->phase) { + switch (priv->phase) { case GSM_MANAGER_PHASE_STARTUP: case GSM_MANAGER_PHASE_INITIALIZATION: case GSM_MANAGER_PHASE_WINDOW_MANAGER: @@ -572,22 +584,25 @@ end_phase (GsmManager *manager) } if (start_next_phase) { - manager->priv->phase++; + priv->phase++; start_phase (manager); - } + } } static void app_registered (GsmApp *app, GsmManager *manager) { - manager->priv->pending_apps = g_slist_remove (manager->priv->pending_apps, app); + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); + priv->pending_apps = g_slist_remove (priv->pending_apps, app); g_signal_handlers_disconnect_by_func (app, app_registered, manager); - if (manager->priv->pending_apps == NULL) { - if (manager->priv->phase_timeout_id > 0) { - g_source_remove (manager->priv->phase_timeout_id); - manager->priv->phase_timeout_id = 0; + if (priv->pending_apps == NULL) { + if (priv->phase_timeout_id > 0) { + g_source_remove (priv->phase_timeout_id); + priv->phase_timeout_id = 0; } end_phase (manager); @@ -607,17 +622,19 @@ static gboolean on_phase_timeout (GsmManager *manager) { GSList *a; + GsmManagerPrivate *priv; - manager->priv->phase_timeout_id = 0; + priv = gsm_manager_get_instance_private (manager); + priv->phase_timeout_id = 0; - switch (manager->priv->phase) { + switch (priv->phase) { case GSM_MANAGER_PHASE_STARTUP: case GSM_MANAGER_PHASE_INITIALIZATION: case GSM_MANAGER_PHASE_WINDOW_MANAGER: case GSM_MANAGER_PHASE_PANEL: case GSM_MANAGER_PHASE_DESKTOP: case GSM_MANAGER_PHASE_APPLICATION: - for (a = manager->priv->pending_apps; a; a = a->next) { + for (a = priv->pending_apps; a; a = a->next) { g_warning ("Application '%s' failed to register before timeout", gsm_app_peek_app_id (a->data)); g_signal_handlers_disconnect_by_func (a->data, app_registered, manager); @@ -630,7 +647,7 @@ on_phase_timeout (GsmManager *manager) case GSM_MANAGER_PHASE_END_SESSION: break; case GSM_MANAGER_PHASE_EXIT: - gsm_store_foreach (manager->priv->clients, + gsm_store_foreach (priv->clients, (GsmStoreFunc)_client_failed_to_stop, NULL); break; @@ -676,8 +693,11 @@ _start_app (const char *id, GError *error; gboolean res; int delay; + GsmManagerPrivate *priv; - if (gsm_app_peek_phase (app) != manager->priv->phase) { + priv = gsm_manager_get_instance_private (manager); + + if (gsm_app_peek_phase (app) != priv->phase) { goto out; } @@ -716,7 +736,7 @@ _start_app (const char *id, goto out; } - if (manager->priv->phase < GSM_MANAGER_PHASE_APPLICATION) { + if (priv->phase < GSM_MANAGER_PHASE_APPLICATION) { g_signal_connect (app, "exited", G_CALLBACK (app_registered), @@ -725,7 +745,7 @@ _start_app (const char *id, "registered", G_CALLBACK (app_registered), manager); - manager->priv->pending_apps = g_slist_prepend (manager->priv->pending_apps, app); + priv->pending_apps = g_slist_prepend (priv->pending_apps, app); } out: return FALSE; @@ -734,15 +754,18 @@ _start_app (const char *id, static void do_phase_startup (GsmManager *manager) { - gsm_store_foreach (manager->priv->apps, + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); + gsm_store_foreach (priv->apps, (GsmStoreFunc)_start_app, manager); - if (manager->priv->pending_apps != NULL) { - if (manager->priv->phase < GSM_MANAGER_PHASE_APPLICATION) { - manager->priv->phase_timeout_id = g_timeout_add_seconds (GSM_MANAGER_PHASE_TIMEOUT, - (GSourceFunc)on_phase_timeout, - manager); + if (priv->pending_apps != NULL) { + if (priv->phase < GSM_MANAGER_PHASE_APPLICATION) { + priv->phase_timeout_id = g_timeout_add_seconds (GSM_MANAGER_PHASE_TIMEOUT, + (GSourceFunc)on_phase_timeout, + manager); } } else { end_phase (manager); @@ -761,6 +784,9 @@ _client_end_session (GsmClient *client, { gboolean ret; GError *error; + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (data->manager); error = NULL; ret = gsm_client_end_session (client, data->flags, &error); @@ -770,8 +796,8 @@ _client_end_session (GsmClient *client, /* FIXME: what should we do if we can't communicate with client? */ } else { g_debug ("GsmManager: adding client to end-session clients: %s", gsm_client_peek_id (client)); - data->manager->priv->query_clients = g_slist_prepend (data->manager->priv->query_clients, - client); + priv->query_clients = g_slist_prepend (priv->query_clients, + client); } return FALSE; @@ -789,28 +815,30 @@ static void do_phase_end_session (GsmManager *manager) { ClientEndSessionData data; + GsmManagerPrivate *priv; data.manager = manager; data.flags = 0; + priv = gsm_manager_get_instance_private (manager); - if (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { + if (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { data.flags |= GSM_CLIENT_END_SESSION_FLAG_FORCEFUL; } if (auto_save_is_enabled (manager)) { data.flags |= GSM_CLIENT_END_SESSION_FLAG_SAVE; } - if (manager->priv->phase_timeout_id > 0) { - g_source_remove (manager->priv->phase_timeout_id); - manager->priv->phase_timeout_id = 0; + if (priv->phase_timeout_id > 0) { + g_source_remove (priv->phase_timeout_id); + priv->phase_timeout_id = 0; } - if (gsm_store_size (manager->priv->clients) > 0) { - manager->priv->phase_timeout_id = g_timeout_add_seconds (GSM_MANAGER_PHASE_TIMEOUT, - (GSourceFunc)on_phase_timeout, - manager); + if (gsm_store_size (priv->clients) > 0) { + priv->phase_timeout_id = g_timeout_add_seconds (GSM_MANAGER_PHASE_TIMEOUT, + (GSourceFunc)on_phase_timeout, + manager); - gsm_store_foreach (manager->priv->clients, + gsm_store_foreach (priv->clients, (GsmStoreFunc)_client_end_session_helper, &data); } else { @@ -822,11 +850,13 @@ static void do_phase_end_session_part_2 (GsmManager *manager) { ClientEndSessionData data; + GsmManagerPrivate *priv; data.manager = manager; data.flags = 0; + priv = gsm_manager_get_instance_private (manager); - if (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { + if (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { data.flags |= GSM_CLIENT_END_SESSION_FLAG_FORCEFUL; } if (auto_save_is_enabled (manager)) { @@ -837,13 +867,13 @@ do_phase_end_session_part_2 (GsmManager *manager) /* keep the timeout that was started at the beginning of the * GSM_MANAGER_PHASE_END_SESSION phase */ - if (g_slist_length (manager->priv->next_query_clients) > 0) { - g_slist_foreach (manager->priv->next_query_clients, + if (g_slist_length (priv->next_query_clients) > 0) { + g_slist_foreach (priv->next_query_clients, (GFunc)_client_end_session, &data); - g_slist_free (manager->priv->next_query_clients); - manager->priv->next_query_clients = NULL; + g_slist_free (priv->next_query_clients); + priv->next_query_clients = NULL; } else { end_phase (manager); } @@ -873,12 +903,15 @@ _client_stop (const char *id, static void do_phase_exit (GsmManager *manager) { - if (gsm_store_size (manager->priv->clients) > 0) { - manager->priv->phase_timeout_id = g_timeout_add_seconds (GSM_MANAGER_EXIT_PHASE_TIMEOUT, - (GSourceFunc)on_phase_timeout, - manager); + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); + if (gsm_store_size (priv->clients) > 0) { + priv->phase_timeout_id = g_timeout_add_seconds (GSM_MANAGER_EXIT_PHASE_TIMEOUT, + (GSourceFunc)on_phase_timeout, + manager); - gsm_store_foreach (manager->priv->clients, + gsm_store_foreach (priv->clients, (GsmStoreFunc)_client_stop, NULL); } else { @@ -893,6 +926,9 @@ _client_query_end_session (const char *id, { gboolean ret; GError *error; + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (data->manager); error = NULL; ret = gsm_client_query_end_session (client, data->flags, &error); @@ -902,8 +938,7 @@ _client_query_end_session (const char *id, /* FIXME: what should we do if we can't communicate with client? */ } else { g_debug ("GsmManager: adding client to query clients: %s", gsm_client_peek_id (client)); - data->manager->priv->query_clients = g_slist_prepend (data->manager->priv->query_clients, - client); + priv->query_clients = g_slist_prepend (priv->query_clients, client); } return FALSE; @@ -928,12 +963,15 @@ static gboolean gsm_manager_is_logout_inhibited (GsmManager *manager) { GsmInhibitor *inhibitor; + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); - if (manager->priv->inhibitors == NULL) { + if (priv->inhibitors == NULL) { return FALSE; } - inhibitor = (GsmInhibitor *)gsm_store_find (manager->priv->inhibitors, + inhibitor = (GsmInhibitor *)gsm_store_find (priv->inhibitors, (GsmStoreFunc)inhibitor_has_flag, GUINT_TO_POINTER (GSM_INHIBITOR_FLAG_LOGOUT)); if (inhibitor == NULL) { @@ -946,12 +984,15 @@ static gboolean gsm_manager_is_idle_inhibited (GsmManager *manager) { GsmInhibitor *inhibitor; + GsmManagerPrivate *priv; - if (manager->priv->inhibitors == NULL) { + priv = gsm_manager_get_instance_private (manager); + + if (priv->inhibitors == NULL) { return FALSE; } - inhibitor = (GsmInhibitor *)gsm_store_find (manager->priv->inhibitors, + inhibitor = (GsmInhibitor *)gsm_store_find (priv->inhibitors, (GsmStoreFunc)inhibitor_has_flag, GUINT_TO_POINTER (GSM_INHIBITOR_FLAG_IDLE)); if (inhibitor == NULL) { @@ -996,8 +1037,11 @@ inhibitor_is_jit (gpointer key, static void cancel_end_session (GsmManager *manager) { + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); /* just ignore if received outside of shutdown */ - if (manager->priv->phase < GSM_MANAGER_PHASE_QUERY_END_SESSION) { + if (priv->phase < GSM_MANAGER_PHASE_QUERY_END_SESSION) { return; } @@ -1007,23 +1051,23 @@ cancel_end_session (GsmManager *manager) /* remove the dialog before we remove the inhibitors, else the dialog * will activate itself automatically when the last inhibitor will be * removed */ - if (manager->priv->inhibit_dialog) - gtk_widget_destroy (GTK_WIDGET (manager->priv->inhibit_dialog)); - manager->priv->inhibit_dialog = NULL; + if (priv->inhibit_dialog) + gtk_widget_destroy (GTK_WIDGET (priv->inhibit_dialog)); + priv->inhibit_dialog = NULL; /* clear all JIT inhibitors */ - gsm_store_foreach_remove (manager->priv->inhibitors, + gsm_store_foreach_remove (priv->inhibitors, (GsmStoreFunc)inhibitor_is_jit, (gpointer)manager); - gsm_store_foreach (manager->priv->clients, + gsm_store_foreach (priv->clients, (GsmStoreFunc)_client_cancel_end_session, NULL); gsm_manager_set_phase (manager, GSM_MANAGER_PHASE_RUNNING); - manager->priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL; + priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL; - manager->priv->logout_type = GSM_MANAGER_LOGOUT_NONE; + priv->logout_type = GSM_MANAGER_LOGOUT_NONE; mdm_set_logout_action (MDM_LOGOUT_ACTION_NONE); start_phase (manager); @@ -1085,8 +1129,8 @@ manager_switch_user (GsmManager *manager) else if (process_is_running("gdm") || process_is_running("gdm3") || process_is_running("gdm-binary")) { /* GDM */ command = g_strdup_printf ("%s %s", - GDM_FLEXISERVER_COMMAND, - GDM_FLEXISERVER_ARGS); + GDM_FLEXISERVER_COMMAND, + GDM_FLEXISERVER_ARGS); error = NULL; res = g_spawn_command_line_sync (command, NULL, NULL, NULL, &error); @@ -1132,8 +1176,11 @@ manager_switch_user (GsmManager *manager) static gboolean sleep_lock_is_enabled (GsmManager *manager) { - if (manager->priv->settings_screensaver != NULL) - return g_settings_get_boolean (manager->priv->settings_screensaver, + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); + if (priv->settings_screensaver != NULL) + return g_settings_get_boolean (priv->settings_screensaver, KEY_SLEEP_LOCK); else return FALSE; @@ -1227,6 +1274,9 @@ static void do_inhibit_dialog_action (GsmManager *manager, int action) { + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); switch (action) { case GSM_LOGOUT_ACTION_SWITCH_USER: manager_switch_user (manager); @@ -1240,7 +1290,7 @@ do_inhibit_dialog_action (GsmManager *manager, case GSM_LOGOUT_ACTION_SHUTDOWN: case GSM_LOGOUT_ACTION_REBOOT: case GSM_LOGOUT_ACTION_LOGOUT: - manager->priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_FORCE; + priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_FORCE; end_phase (manager); break; default: @@ -1255,15 +1305,17 @@ inhibit_dialog_response (GsmInhibitDialog *dialog, GsmManager *manager) { int action; + GsmManagerPrivate *priv; g_debug ("GsmManager: Inhibit dialog response: %d", response_id); + priv = gsm_manager_get_instance_private (manager); /* must destroy dialog before cancelling since we'll remove JIT inhibitors and we don't want to trigger action. */ g_object_get (dialog, "action", &action, NULL); gtk_widget_destroy (GTK_WIDGET (dialog)); - manager->priv->inhibit_dialog = NULL; + priv->inhibit_dialog = NULL; /* In case of dialog cancel, switch user, hibernate and * suspend, we just perform the respective action and return, @@ -1292,14 +1344,17 @@ static void query_end_session_complete (GsmManager *manager) { GsmLogoutAction action; + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); g_debug ("GsmManager: query end session complete"); /* Remove the timeout since this can be called from outside the timer * and we don't want to have it called twice */ - if (manager->priv->query_timeout_id > 0) { - g_source_remove (manager->priv->query_timeout_id); - manager->priv->query_timeout_id = 0; + if (priv->query_timeout_id > 0) { + g_source_remove (priv->query_timeout_id); + priv->query_timeout_id = 0; } if (! gsm_manager_is_logout_inhibited (manager)) { @@ -1307,13 +1362,13 @@ query_end_session_complete (GsmManager *manager) return; } - if (manager->priv->inhibit_dialog != NULL) { + if (priv->inhibit_dialog != NULL) { g_debug ("GsmManager: inhibit dialog already up"); - gtk_window_present (GTK_WINDOW (manager->priv->inhibit_dialog)); + gtk_window_present (GTK_WINDOW (priv->inhibit_dialog)); return; } - switch (manager->priv->logout_type) { + switch (priv->logout_type) { case GSM_MANAGER_LOGOUT_LOGOUT: action = GSM_LOGOUT_ACTION_LOGOUT; break; @@ -1329,7 +1384,7 @@ query_end_session_complete (GsmManager *manager) break; default: g_warning ("Unexpected logout type %d when creating inhibit dialog", - manager->priv->logout_type); + priv->logout_type); action = GSM_LOGOUT_ACTION_LOGOUT; break; } @@ -1338,15 +1393,15 @@ query_end_session_complete (GsmManager *manager) * actually handled the same way as GSM_LOGOUT_ACTION_LOGOUT in the * inhibit dialog; the action, if the button is clicked, will be to * simply go to the next phase. */ - manager->priv->inhibit_dialog = gsm_inhibit_dialog_new (manager->priv->inhibitors, - manager->priv->clients, - action); + priv->inhibit_dialog = gsm_inhibit_dialog_new (priv->inhibitors, + priv->clients, + action); - g_signal_connect (manager->priv->inhibit_dialog, + g_signal_connect (priv->inhibit_dialog, "response", G_CALLBACK (inhibit_dialog_response), manager); - gtk_widget_show (manager->priv->inhibit_dialog); + gtk_widget_show (priv->inhibit_dialog); } @@ -1364,10 +1419,13 @@ static guint32 _generate_unique_cookie (GsmManager *manager) { guint32 cookie; + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); do { cookie = generate_cookie (); - } while (gsm_store_find (manager->priv->inhibitors, (GsmStoreFunc)_find_by_cookie, &cookie) != NULL); + } while (gsm_store_find (priv->inhibitors, (GsmStoreFunc)_find_by_cookie, &cookie) != NULL); return cookie; } @@ -1376,12 +1434,15 @@ static gboolean _on_query_end_session_timeout (GsmManager *manager) { GSList *l; + GsmManagerPrivate *priv; - manager->priv->query_timeout_id = 0; + priv = gsm_manager_get_instance_private (manager); + + priv->query_timeout_id = 0; g_debug ("GsmManager: query end session timed out"); - for (l = manager->priv->query_clients; l != NULL; l = l->next) { + for (l = priv->query_clients; l != NULL; l = l->next) { guint cookie; GsmInhibitor *inhibitor; const char *bus_name; @@ -1392,7 +1453,7 @@ _on_query_end_session_timeout (GsmManager *manager) /* Don't add "not responding" inhibitors if logout is forced */ - if (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { + if (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { continue; } @@ -1418,12 +1479,12 @@ _on_query_end_session_timeout (GsmManager *manager) bus_name, cookie); g_free (app_id); - gsm_store_add (manager->priv->inhibitors, gsm_inhibitor_peek_id (inhibitor), G_OBJECT (inhibitor)); + gsm_store_add (priv->inhibitors, gsm_inhibitor_peek_id (inhibitor), G_OBJECT (inhibitor)); g_object_unref (inhibitor); } - g_slist_free (manager->priv->query_clients); - manager->priv->query_clients = NULL; + g_slist_free (priv->query_clients); + priv->query_clients = NULL; query_end_session_complete (manager); @@ -1434,11 +1495,13 @@ static void do_phase_query_end_session (GsmManager *manager) { ClientEndSessionData data; + GsmManagerPrivate *priv; data.manager = manager; data.flags = 0; + priv = gsm_manager_get_instance_private (manager); - if (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { + if (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { data.flags |= GSM_CLIENT_END_SESSION_FLAG_FORCEFUL; } /* We only query if an app is ready to log out, so we don't use @@ -1447,53 +1510,59 @@ do_phase_query_end_session (GsmManager *manager) debug_clients (manager); g_debug ("GsmManager: sending query-end-session to clients (logout mode: %s)", - manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_NORMAL? "normal" : - manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE? "forceful": + priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_NORMAL? "normal" : + priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE? "forceful": "no confirmation"); - gsm_store_foreach (manager->priv->clients, + gsm_store_foreach (priv->clients, (GsmStoreFunc)_client_query_end_session, &data); /* This phase doesn't time out unless logout is forced. Typically, this * separate timer is only used to show UI. */ - manager->priv->query_timeout_id = g_timeout_add_seconds (1, (GSourceFunc)_on_query_end_session_timeout, manager); + priv->query_timeout_id = g_timeout_add_seconds (1, (GSourceFunc)_on_query_end_session_timeout, manager); } static void update_idle (GsmManager *manager) { + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); if (gsm_manager_is_idle_inhibited (manager)) { - gsm_presence_set_idle_enabled (manager->priv->presence, FALSE); + gsm_presence_set_idle_enabled (priv->presence, FALSE); } else { - gsm_presence_set_idle_enabled (manager->priv->presence, TRUE); + gsm_presence_set_idle_enabled (priv->presence, TRUE); } } static void start_phase (GsmManager *manager) { + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); g_debug ("GsmManager: starting phase %s\n", - phase_num_to_name (manager->priv->phase)); + phase_num_to_name (priv->phase)); /* reset state */ - g_slist_free (manager->priv->pending_apps); - manager->priv->pending_apps = NULL; - g_slist_free (manager->priv->query_clients); - manager->priv->query_clients = NULL; - g_slist_free (manager->priv->next_query_clients); - manager->priv->next_query_clients = NULL; + g_slist_free (priv->pending_apps); + priv->pending_apps = NULL; + g_slist_free (priv->query_clients); + priv->query_clients = NULL; + g_slist_free (priv->next_query_clients); + priv->next_query_clients = NULL; - if (manager->priv->query_timeout_id > 0) { - g_source_remove (manager->priv->query_timeout_id); - manager->priv->query_timeout_id = 0; + if (priv->query_timeout_id > 0) { + g_source_remove (priv->query_timeout_id); + priv->query_timeout_id = 0; } - if (manager->priv->phase_timeout_id > 0) { - g_source_remove (manager->priv->phase_timeout_id); - manager->priv->phase_timeout_id = 0; + if (priv->phase_timeout_id > 0) { + g_source_remove (priv->phase_timeout_id); + priv->phase_timeout_id = 0; } - switch (manager->priv->phase) { + switch (priv->phase) { case GSM_MANAGER_PHASE_STARTUP: case GSM_MANAGER_PHASE_INITIALIZATION: case GSM_MANAGER_PHASE_WINDOW_MANAGER: @@ -1548,11 +1617,14 @@ static void debug_app_summary (GsmManager *manager) { guint phase; + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); g_debug ("GsmManager: App startup summary"); for (phase = GSM_MANAGER_PHASE_INITIALIZATION; phase < GSM_MANAGER_PHASE_RUNNING; phase++) { g_debug ("GsmManager: Phase %s", phase_num_to_name (phase)); - gsm_store_foreach (manager->priv->apps, + gsm_store_foreach (priv->apps, (GsmStoreFunc)_debug_app_for_phase, GUINT_TO_POINTER (phase)); } @@ -1586,7 +1658,10 @@ find_app_for_app_id (GsmManager *manager, const char *app_id) { GsmApp *app; - app = (GsmApp *)gsm_store_find (manager->priv->apps, + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); + app = (GsmApp *)gsm_store_find (priv->apps, (GsmStoreFunc)_app_has_app_id, (char *)app_id); return app; @@ -1637,14 +1712,16 @@ find_app_for_startup_id (GsmManager *manager, { GsmApp *found_app; GSList *a; + GsmManagerPrivate *priv; found_app = NULL; + priv = gsm_manager_get_instance_private (manager); /* If we're starting up the session, try to match the new client * with one pending apps for the current phase. If not, try to match * with any of the autostarted apps. */ - if (manager->priv->phase < GSM_MANAGER_PHASE_APPLICATION) { - for (a = manager->priv->pending_apps; a != NULL; a = a->next) { + if (priv->phase < GSM_MANAGER_PHASE_APPLICATION) { + for (a = priv->pending_apps; a != NULL; a = a->next) { GsmApp *app = GSM_APP (a->data); if (strcmp (startup_id, gsm_app_peek_startup_id (app)) == 0) { @@ -1655,7 +1732,7 @@ find_app_for_startup_id (GsmManager *manager, } else { GsmApp *app; - app = (GsmApp *)gsm_store_find (manager->priv->apps, + app = (GsmApp *)gsm_store_find (priv->apps, (GsmStoreFunc)_app_has_startup_id, (char *)startup_id); if (app != NULL) { @@ -1679,6 +1756,7 @@ _disconnect_client (GsmManager *manager, const char *startup_id; gboolean app_restart; GsmClientRestartStyle client_restart_hint; + GsmManagerPrivate *priv; g_debug ("GsmManager: disconnect client: %s", gsm_client_peek_id (client)); @@ -1688,14 +1766,15 @@ _disconnect_client (GsmManager *manager, gsm_client_set_status (client, GSM_CLIENT_FINISHED); is_condition_client = FALSE; - if (g_slist_find (manager->priv->condition_clients, client)) { - manager->priv->condition_clients = g_slist_remove (manager->priv->condition_clients, client); + priv = gsm_manager_get_instance_private (manager); + if (g_slist_find (priv->condition_clients, client)) { + priv->condition_clients = g_slist_remove (priv->condition_clients, client); is_condition_client = TRUE; } /* remove any inhibitors for this client */ - gsm_store_foreach_remove (manager->priv->inhibitors, + gsm_store_foreach_remove (priv->inhibitors, (GsmStoreFunc)inhibitor_has_client_id, (gpointer)gsm_client_peek_id (client)); @@ -1717,7 +1796,7 @@ _disconnect_client (GsmManager *manager, } } - if (manager->priv->phase == GSM_MANAGER_PHASE_QUERY_END_SESSION) { + if (priv->phase == GSM_MANAGER_PHASE_QUERY_END_SESSION) { /* Instead of answering our end session query, the client just exited. * Treat that as an "okay, end the session" answer. * @@ -1740,7 +1819,7 @@ _disconnect_client (GsmManager *manager, goto out; } - if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) { + if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) { g_debug ("GsmManager: in shutdown, not restarting application"); goto out; } @@ -1807,17 +1886,19 @@ remove_clients_for_connection (GsmManager *manager, const char *service_name) { RemoveClientData data; + GsmManagerPrivate *priv; data.service_name = service_name; data.manager = manager; + priv = gsm_manager_get_instance_private (manager); /* disconnect dbus clients for name */ - gsm_store_foreach_remove (manager->priv->clients, + gsm_store_foreach_remove (priv->clients, (GsmStoreFunc)_disconnect_dbus_client, &data); - if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION - && gsm_store_size (manager->priv->clients) == 0) { + if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION + && gsm_store_size (priv->clients) == 0) { g_debug ("GsmManager: last client disconnected - exiting"); end_phase (manager); } @@ -1853,13 +1934,15 @@ remove_inhibitors_for_connection (GsmManager *manager, { guint UNUSED_VARIABLE n_removed; RemoveClientData data; + GsmManagerPrivate *priv; data.service_name = service_name; data.manager = manager; + priv = gsm_manager_get_instance_private (manager); debug_inhibitors (manager); - n_removed = gsm_store_foreach_remove (manager->priv->inhibitors, + n_removed = gsm_store_foreach_remove (priv->inhibitors, (GsmStoreFunc)inhibitor_has_bus_name, &data); } @@ -1889,10 +1972,13 @@ static gboolean register_manager (GsmManager *manager) { GError *error = NULL; + GsmManagerPrivate *priv; error = NULL; - manager->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (manager->priv->connection == NULL) { + priv = gsm_manager_get_instance_private (manager); + + priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (priv->connection == NULL) { if (error != NULL) { g_critical ("error getting session bus: %s", error->message); g_error_free (error); @@ -1900,23 +1986,23 @@ register_manager (GsmManager *manager) exit (1); } - manager->priv->bus_proxy = dbus_g_proxy_new_for_name (manager->priv->connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - dbus_g_proxy_add_signal (manager->priv->bus_proxy, + priv->bus_proxy = dbus_g_proxy_new_for_name (priv->connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (manager->priv->bus_proxy, + dbus_g_proxy_connect_signal (priv->bus_proxy, "NameOwnerChanged", G_CALLBACK (bus_name_owner_changed), manager, NULL); - dbus_g_connection_register_g_object (manager->priv->connection, GSM_MANAGER_DBUS_PATH, G_OBJECT (manager)); + dbus_g_connection_register_g_object (priv->connection, GSM_MANAGER_DBUS_PATH, G_OBJECT (manager)); return TRUE; } @@ -1925,9 +2011,13 @@ static void gsm_manager_set_failsafe (GsmManager *manager, gboolean enabled) { + GsmManagerPrivate *priv; + g_return_if_fail (GSM_IS_MANAGER (manager)); - manager->priv->failsafe = enabled; + priv = gsm_manager_get_instance_private (manager); + + priv->failsafe = enabled; } static gboolean @@ -1950,11 +2040,16 @@ static void on_client_disconnected (GsmClient *client, GsmManager *manager) { + GsmManagerPrivate *priv; + g_debug ("GsmManager: disconnect client"); + + priv = gsm_manager_get_instance_private (manager); + _disconnect_client (manager, client); - gsm_store_remove (manager->priv->clients, gsm_client_peek_id (client)); - if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION - && gsm_store_size (manager->priv->clients) == 0) { + gsm_store_remove (priv->clients, gsm_client_peek_id (client)); + if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION + && gsm_store_size (priv->clients) == 0) { g_debug ("GsmManager: last client disconnected - exiting"); end_phase (manager); } @@ -1968,11 +2063,13 @@ on_xsmp_client_register_request (GsmXSMPClient *client, gboolean handled; char *new_id; GsmApp *app; + GsmManagerPrivate *priv; handled = TRUE; new_id = NULL; + priv = gsm_manager_get_instance_private (manager); - if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) { + if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) { goto out; } @@ -1981,7 +2078,7 @@ on_xsmp_client_register_request (GsmXSMPClient *client, } else { GsmClient *client; - client = (GsmClient *)gsm_store_find (manager->priv->clients, + client = (GsmClient *)gsm_store_find (priv->clients, (GsmStoreFunc)_client_has_startup_id, *id); /* We can't have two clients with the same id. */ @@ -2025,7 +2122,10 @@ on_xsmp_client_register_request (GsmXSMPClient *client, static gboolean auto_save_is_enabled (GsmManager *manager) { - return g_settings_get_boolean (manager->priv->settings_session, + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); + return g_settings_get_boolean (priv->settings_session, KEY_AUTOSAVE); } @@ -2038,6 +2138,7 @@ maybe_save_session (GsmManager *manager) #endif char *session_type; GError *error; + GsmManagerPrivate *priv; #ifdef HAVE_SYSTEMD if (LOGIND_RUNNING()) { @@ -2060,15 +2161,16 @@ maybe_save_session (GsmManager *manager) } #endif + priv = gsm_manager_get_instance_private (manager); /* We only allow session saving when session is running or when * logging out */ - if (manager->priv->phase != GSM_MANAGER_PHASE_RUNNING && - manager->priv->phase != GSM_MANAGER_PHASE_END_SESSION) { + if (priv->phase != GSM_MANAGER_PHASE_RUNNING && + priv->phase != GSM_MANAGER_PHASE_END_SESSION) { goto out; } error = NULL; - gsm_session_save (manager->priv->clients, &error); + gsm_session_save (priv->clients, &error); if (error) { g_warning ("Error saving session: %s", error->message); @@ -2093,8 +2195,11 @@ _handle_client_end_session_response (GsmManager *manager, gboolean cancel, const char *reason) { + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); /* just ignore if received outside of shutdown */ - if (manager->priv->phase < GSM_MANAGER_PHASE_QUERY_END_SESSION) { + if (priv->phase < GSM_MANAGER_PHASE_QUERY_END_SESSION) { return; } @@ -2105,9 +2210,9 @@ _handle_client_end_session_response (GsmManager *manager, return; } - manager->priv->query_clients = g_slist_remove (manager->priv->query_clients, client); + priv->query_clients = g_slist_remove (priv->query_clients, client); - if (! is_ok && manager->priv->logout_mode != GSM_MANAGER_LOGOUT_MODE_FORCE) { + if (! is_ok && priv->logout_mode != GSM_MANAGER_LOGOUT_MODE_FORCE) { guint cookie; GsmInhibitor *inhibitor; char *app_id; @@ -2137,37 +2242,37 @@ _handle_client_end_session_response (GsmManager *manager, bus_name, cookie); g_free (app_id); - gsm_store_add (manager->priv->inhibitors, gsm_inhibitor_peek_id (inhibitor), G_OBJECT (inhibitor)); + gsm_store_add (priv->inhibitors, gsm_inhibitor_peek_id (inhibitor), G_OBJECT (inhibitor)); g_object_unref (inhibitor); } else { - gsm_store_foreach_remove (manager->priv->inhibitors, + gsm_store_foreach_remove (priv->inhibitors, (GsmStoreFunc)inhibitor_has_client_id, (gpointer)gsm_client_peek_id (client)); } - if (manager->priv->phase == GSM_MANAGER_PHASE_QUERY_END_SESSION) { - if (manager->priv->query_clients == NULL) { + if (priv->phase == GSM_MANAGER_PHASE_QUERY_END_SESSION) { + if (priv->query_clients == NULL) { query_end_session_complete (manager); } - } else if (manager->priv->phase == GSM_MANAGER_PHASE_END_SESSION) { + } else if (priv->phase == GSM_MANAGER_PHASE_END_SESSION) { if (do_last) { /* This only makes sense if we're in part 1 of * GSM_MANAGER_PHASE_END_SESSION. Doing this in part 2 * can only happen because of a buggy client that loops * wanting to be last again and again. The phase * timeout will take care of this issue. */ - manager->priv->next_query_clients = g_slist_prepend (manager->priv->next_query_clients, - client); + priv->next_query_clients = g_slist_prepend (priv->next_query_clients, + client); } /* we can continue to the next step if all clients have replied * and if there's no inhibitor */ - if (manager->priv->query_clients != NULL + if (priv->query_clients != NULL || gsm_manager_is_logout_inhibited (manager)) { return; } - if (manager->priv->next_query_clients != NULL) { + if (priv->next_query_clients != NULL) { do_phase_end_session_part_2 (manager); } else { end_phase (manager); @@ -2259,34 +2364,37 @@ static void gsm_manager_set_client_store (GsmManager *manager, GsmStore *store) { + GsmManagerPrivate *priv; + g_return_if_fail (GSM_IS_MANAGER (manager)); + priv = gsm_manager_get_instance_private (manager); if (store != NULL) { g_object_ref (store); } - if (manager->priv->clients != NULL) { - g_signal_handlers_disconnect_by_func (manager->priv->clients, + if (priv->clients != NULL) { + g_signal_handlers_disconnect_by_func (priv->clients, on_store_client_added, manager); - g_signal_handlers_disconnect_by_func (manager->priv->clients, + g_signal_handlers_disconnect_by_func (priv->clients, on_store_client_removed, manager); - g_object_unref (manager->priv->clients); + g_object_unref (priv->clients); } g_debug ("GsmManager: setting client store %p", store); - manager->priv->clients = store; + priv->clients = store; - if (manager->priv->clients != NULL) { - g_signal_connect (manager->priv->clients, + if (priv->clients != NULL) { + g_signal_connect (priv->clients, "added", G_CALLBACK (on_store_client_added), manager); - g_signal_connect (manager->priv->clients, + g_signal_connect (priv->clients, "removed", G_CALLBACK (on_store_client_removed), manager); @@ -2323,15 +2431,17 @@ gsm_manager_get_property (GObject *object, GParamSpec *pspec) { GsmManager *self; + GsmManagerPrivate *priv; self = GSM_MANAGER (object); + priv = gsm_manager_get_instance_private (self); switch (prop_id) { case PROP_FAILSAFE: - g_value_set_boolean (value, self->priv->failsafe); + g_value_set_boolean (value, priv->failsafe); break; case PROP_CLIENT_STORE: - g_value_set_object (value, self->priv->clients); + g_value_set_object (value, priv->clients); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -2383,56 +2493,59 @@ on_store_inhibitor_removed (GsmStore *store, static void gsm_manager_dispose (GObject *object) { + GsmManagerPrivate *priv; GsmManager *manager = GSM_MANAGER (object); g_debug ("GsmManager: disposing manager"); - if (manager->priv->clients != NULL) { - g_signal_handlers_disconnect_by_func (manager->priv->clients, + priv = gsm_manager_get_instance_private (manager); + + if (priv->clients != NULL) { + g_signal_handlers_disconnect_by_func (priv->clients, on_store_client_added, manager); - g_signal_handlers_disconnect_by_func (manager->priv->clients, + g_signal_handlers_disconnect_by_func (priv->clients, on_store_client_removed, manager); - g_object_unref (manager->priv->clients); - manager->priv->clients = NULL; + g_object_unref (priv->clients); + priv->clients = NULL; } - if (manager->priv->apps != NULL) { - g_object_unref (manager->priv->apps); - manager->priv->apps = NULL; + if (priv->apps != NULL) { + g_object_unref (priv->apps); + priv->apps = NULL; } - if (manager->priv->inhibitors != NULL) { - g_signal_handlers_disconnect_by_func (manager->priv->inhibitors, + if (priv->inhibitors != NULL) { + g_signal_handlers_disconnect_by_func (priv->inhibitors, on_store_inhibitor_added, manager); - g_signal_handlers_disconnect_by_func (manager->priv->inhibitors, + g_signal_handlers_disconnect_by_func (priv->inhibitors, on_store_inhibitor_removed, manager); - g_object_unref (manager->priv->inhibitors); - manager->priv->inhibitors = NULL; + g_object_unref (priv->inhibitors); + priv->inhibitors = NULL; } - if (manager->priv->presence != NULL) { - g_object_unref (manager->priv->presence); - manager->priv->presence = NULL; + if (priv->presence != NULL) { + g_object_unref (priv->presence); + priv->presence = NULL; } - if (manager->priv->settings_session) { - g_object_unref (manager->priv->settings_session); - manager->priv->settings_session = NULL; + if (priv->settings_session) { + g_object_unref (priv->settings_session); + priv->settings_session = NULL; } - if (manager->priv->settings_lockdown) { - g_object_unref (manager->priv->settings_lockdown); - manager->priv->settings_lockdown = NULL; + if (priv->settings_lockdown) { + g_object_unref (priv->settings_lockdown); + priv->settings_lockdown = NULL; } - if (manager->priv->settings_screensaver) { - g_object_unref (manager->priv->settings_screensaver); - manager->priv->settings_screensaver = NULL; + if (priv->settings_screensaver) { + g_object_unref (priv->settings_screensaver); + priv->settings_screensaver = NULL; } G_OBJECT_CLASS (gsm_manager_parent_class)->dispose (object); } @@ -2535,8 +2648,6 @@ gsm_manager_class_init (GsmManagerClass *klass) GSM_TYPE_STORE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - g_type_class_add_private (klass, sizeof (GsmManagerPrivate)); - dbus_g_object_type_install_info (GSM_TYPE_MANAGER, &dbus_glib_gsm_manager_object_info); dbus_g_error_domain_register (GSM_MANAGER_ERROR, NULL, GSM_MANAGER_TYPE_ERROR); } @@ -2545,9 +2656,12 @@ static void load_idle_delay_from_gsettings (GsmManager *manager) { glong value; - value = g_settings_get_int (manager->priv->settings_session, + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); + value = g_settings_get_int (priv->settings_session, KEY_IDLE_DELAY); - gsm_presence_set_idle_timeout (manager->priv->presence, value * 60000); + gsm_presence_set_idle_timeout (priv->presence, value * 60000); } static void @@ -2555,10 +2669,13 @@ on_gsettings_key_changed (GSettings *settings, gchar *key, GsmManager *manager) { + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (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); + gsm_presence_set_idle_timeout (priv->presence, delay * 60000); } else if (g_strcmp0 (key, KEY_LOCK_DISABLE) == 0) { /* ??? */ gboolean UNUSED_VARIABLE disabled; @@ -2603,11 +2720,12 @@ gsm_manager_init (GsmManager *manager) const char * const *schemas; gboolean schema_exists; guint i; + GsmManagerPrivate *priv; - manager->priv = GSM_MANAGER_GET_PRIVATE (manager); + priv = gsm_manager_get_instance_private (manager); - manager->priv->settings_session = g_settings_new (SESSION_SCHEMA); - manager->priv->settings_lockdown = g_settings_new (LOCKDOWN_SCHEMA); + priv->settings_session = g_settings_new (SESSION_SCHEMA); + priv->settings_lockdown = g_settings_new (LOCKDOWN_SCHEMA); /* check if mate-screensaver is installed */ schemas = g_settings_list_schemas (); @@ -2619,32 +2737,32 @@ gsm_manager_init (GsmManager *manager) } } if (schema_exists == TRUE) - manager->priv->settings_screensaver = g_settings_new (SCREENSAVER_SCHEMA); + priv->settings_screensaver = g_settings_new (SCREENSAVER_SCHEMA); else - manager->priv->settings_screensaver = NULL; + priv->settings_screensaver = NULL; - manager->priv->inhibitors = gsm_store_new (); - g_signal_connect (manager->priv->inhibitors, + priv->inhibitors = gsm_store_new (); + g_signal_connect (priv->inhibitors, "added", G_CALLBACK (on_store_inhibitor_added), manager); - g_signal_connect (manager->priv->inhibitors, + g_signal_connect (priv->inhibitors, "removed", G_CALLBACK (on_store_inhibitor_removed), manager); - manager->priv->apps = gsm_store_new (); + priv->apps = gsm_store_new (); - manager->priv->presence = gsm_presence_new (); - g_signal_connect (manager->priv->presence, + priv->presence = gsm_presence_new (); + g_signal_connect (priv->presence, "status-changed", G_CALLBACK (on_presence_status_changed), manager); - g_signal_connect (manager->priv->settings_session, + g_signal_connect (priv->settings_session, "changed", G_CALLBACK (on_gsettings_key_changed), manager); - g_signal_connect (manager->priv->settings_lockdown, + g_signal_connect (priv->settings_lockdown, "changed", G_CALLBACK (on_gsettings_key_changed), manager); @@ -2656,13 +2774,15 @@ static void gsm_manager_finalize (GObject *object) { GsmManager *manager; + GsmManagerPrivate *priv; g_return_if_fail (object != NULL); g_return_if_fail (GSM_IS_MANAGER (object)); manager = GSM_MANAGER (object); + priv = gsm_manager_get_instance_private (manager); - g_return_if_fail (manager->priv != NULL); + g_return_if_fail (priv != NULL); G_OBJECT_CLASS (gsm_manager_parent_class)->finalize (object); } @@ -2699,9 +2819,12 @@ gsm_manager_setenv (GsmManager *manager, const char *value, GError **error) { + GsmManagerPrivate *priv; + g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); - if (manager->priv->phase > GSM_MANAGER_PHASE_INITIALIZATION) { + priv = gsm_manager_get_instance_private (manager); + if (priv->phase > GSM_MANAGER_PHASE_INITIALIZATION) { g_set_error (error, GSM_MANAGER_ERROR, GSM_MANAGER_ERROR_NOT_IN_INITIALIZATION, @@ -2720,9 +2843,12 @@ gsm_manager_initialization_error (GsmManager *manager, gboolean fatal, GError **error) { + GsmManagerPrivate *priv; g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); - if (manager->priv->phase > GSM_MANAGER_PHASE_INITIALIZATION) { + priv = gsm_manager_get_instance_private (manager); + + if (priv->phase > GSM_MANAGER_PHASE_INITIALIZATION) { g_set_error (error, GSM_MANAGER_ERROR, GSM_MANAGER_ERROR_NOT_IN_INITIALIZATION, @@ -2739,12 +2865,15 @@ static gboolean gsm_manager_is_switch_user_inhibited (GsmManager *manager) { GsmInhibitor *inhibitor; + GsmManagerPrivate *priv; - if (manager->priv->inhibitors == NULL) { + priv = gsm_manager_get_instance_private (manager); + + if (priv->inhibitors == NULL) { return FALSE; } - inhibitor = (GsmInhibitor *)gsm_store_find (manager->priv->inhibitors, + inhibitor = (GsmInhibitor *)gsm_store_find (priv->inhibitors, (GsmStoreFunc)inhibitor_has_flag, GUINT_TO_POINTER (GSM_INHIBITOR_FLAG_SWITCH_USER)); if (inhibitor == NULL) { @@ -2757,12 +2886,15 @@ static gboolean gsm_manager_is_suspend_inhibited (GsmManager *manager) { GsmInhibitor *inhibitor; + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); - if (manager->priv->inhibitors == NULL) { + if (priv->inhibitors == NULL) { return FALSE; } - inhibitor = (GsmInhibitor *)gsm_store_find (manager->priv->inhibitors, + inhibitor = (GsmInhibitor *)gsm_store_find (priv->inhibitors, (GsmStoreFunc)inhibitor_has_flag, GUINT_TO_POINTER (GSM_INHIBITOR_FLAG_SUSPEND)); if (inhibitor == NULL) { @@ -2778,6 +2910,9 @@ request_reboot_privileges_completed_consolekit (GsmConsolekit *consolekit, GError *error, GsmManager *manager) { + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); /* make sure we disconnect the signal handler so that it's not called * again next time the event is fired -- this can happen if the reboot * is cancelled. */ @@ -2789,9 +2924,9 @@ request_reboot_privileges_completed_consolekit (GsmConsolekit *consolekit, if (success) { if (ask_later) { - manager->priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_INTERACT; + priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_INTERACT; } else { - manager->priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT; + priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT; } end_phase (manager); @@ -2806,6 +2941,9 @@ request_reboot_privileges_completed_systemd (GsmSystemd *systemd, GError *error, GsmManager *manager) { + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); /* make sure we disconnect the signal handler so that it's not called * again next time the event is fired -- this can happen if the reboot * is cancelled. */ @@ -2817,9 +2955,9 @@ request_reboot_privileges_completed_systemd (GsmSystemd *systemd, if (success) { if (ask_later) { - manager->priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_INTERACT; + priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_INTERACT; } else { - manager->priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT; + priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT; } end_phase (manager); @@ -2835,9 +2973,12 @@ request_reboot (GsmManager *manager) GsmSystemd *systemd; #endif gboolean success; + GsmManagerPrivate *priv; g_debug ("GsmManager: requesting reboot"); + priv = gsm_manager_get_instance_private (manager); + /* We request the privileges before doing anything. There are a few * different cases here: * @@ -2875,7 +3016,7 @@ request_reboot (GsmManager *manager) manager); g_object_unref (systemd); - manager->priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_MDM; + priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_MDM; end_phase (manager); } } @@ -2894,7 +3035,7 @@ request_reboot (GsmManager *manager) manager); g_object_unref (consolekit); - manager->priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_MDM; + priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_MDM; end_phase (manager); } #ifdef HAVE_SYSTEMD @@ -2909,6 +3050,9 @@ request_shutdown_privileges_completed_consolekit (GsmConsolekit *consolekit, GError *error, GsmManager *manager) { + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); /* make sure we disconnect the signal handler so that it's not called * again next time the event is fired -- this can happen if the reboot * is cancelled. */ @@ -2920,9 +3064,9 @@ request_shutdown_privileges_completed_consolekit (GsmConsolekit *consolekit, if (success) { if (ask_later) { - manager->priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT; + priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT; } else { - manager->priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN; + priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN; } end_phase (manager); @@ -2937,6 +3081,9 @@ request_shutdown_privileges_completed_systemd (GsmSystemd *systemd, GError *error, GsmManager *manager) { + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); /* make sure we disconnect the signal handler so that it's not called * again next time the event is fired -- this can happen if the reboot * is cancelled. */ @@ -2948,9 +3095,9 @@ request_shutdown_privileges_completed_systemd (GsmSystemd *systemd, if (success) { if (ask_later) { - manager->priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT; + priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT; } else { - manager->priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN; + priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN; } end_phase (manager); @@ -2966,9 +3113,12 @@ request_shutdown (GsmManager *manager) GsmSystemd *systemd; #endif gboolean success; + GsmManagerPrivate *priv; g_debug ("GsmManager: requesting shutdown"); + priv = gsm_manager_get_instance_private (manager); + /* See the comment in request_reboot() for some more details about how * this works. */ @@ -2987,7 +3137,7 @@ request_shutdown (GsmManager *manager) manager); g_object_unref (systemd); - manager->priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_MDM; + priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_MDM; end_phase (manager); } } @@ -3006,7 +3156,7 @@ request_shutdown (GsmManager *manager) manager); g_object_unref (consolekit); - manager->priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_MDM; + priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_MDM; end_phase (manager); } #ifdef HAVE_SYSTEMD @@ -3017,6 +3167,8 @@ request_shutdown (GsmManager *manager) static void request_suspend (GsmManager *manager) { + GsmManagerPrivate *priv; + g_debug ("GsmManager: requesting suspend"); if (! gsm_manager_is_suspend_inhibited (manager)) { @@ -3024,26 +3176,29 @@ request_suspend (GsmManager *manager) return; } - if (manager->priv->inhibit_dialog != NULL) { + priv = gsm_manager_get_instance_private (manager); + if (priv->inhibit_dialog != NULL) { g_debug ("GsmManager: inhibit dialog already up"); - gtk_window_present (GTK_WINDOW (manager->priv->inhibit_dialog)); + gtk_window_present (GTK_WINDOW (priv->inhibit_dialog)); return; } - manager->priv->inhibit_dialog = gsm_inhibit_dialog_new (manager->priv->inhibitors, - manager->priv->clients, - GSM_LOGOUT_ACTION_SLEEP); + priv->inhibit_dialog = gsm_inhibit_dialog_new (priv->inhibitors, + priv->clients, + GSM_LOGOUT_ACTION_SLEEP); - g_signal_connect (manager->priv->inhibit_dialog, + g_signal_connect (priv->inhibit_dialog, "response", G_CALLBACK (inhibit_dialog_response), manager); - gtk_widget_show (manager->priv->inhibit_dialog); + gtk_widget_show (priv->inhibit_dialog); } static void request_hibernate (GsmManager *manager) { + GsmManagerPrivate *priv; + g_debug ("GsmManager: requesting hibernate"); /* hibernate uses suspend inhibit */ @@ -3052,21 +3207,22 @@ request_hibernate (GsmManager *manager) return; } - if (manager->priv->inhibit_dialog != NULL) { + priv = gsm_manager_get_instance_private (manager); + if (priv->inhibit_dialog != NULL) { g_debug ("GsmManager: inhibit dialog already up"); - gtk_window_present (GTK_WINDOW (manager->priv->inhibit_dialog)); + gtk_window_present (GTK_WINDOW (priv->inhibit_dialog)); return; } - manager->priv->inhibit_dialog = gsm_inhibit_dialog_new (manager->priv->inhibitors, - manager->priv->clients, - GSM_LOGOUT_ACTION_HIBERNATE); + priv->inhibit_dialog = gsm_inhibit_dialog_new (priv->inhibitors, + priv->clients, + GSM_LOGOUT_ACTION_HIBERNATE); - g_signal_connect (manager->priv->inhibit_dialog, + g_signal_connect (priv->inhibit_dialog, "response", G_CALLBACK (inhibit_dialog_response), manager); - gtk_widget_show (manager->priv->inhibit_dialog); + gtk_widget_show (priv->inhibit_dialog); } @@ -3074,10 +3230,14 @@ static void request_logout (GsmManager *manager, GsmManagerLogoutMode mode) { + GsmManagerPrivate *priv; + g_debug ("GsmManager: requesting logout"); - manager->priv->logout_mode = mode; - manager->priv->logout_type = GSM_MANAGER_LOGOUT_LOGOUT; + priv = gsm_manager_get_instance_private (manager); + + priv->logout_mode = mode; + priv->logout_type = GSM_MANAGER_LOGOUT_LOGOUT; end_phase (manager); } @@ -3085,6 +3245,8 @@ request_logout (GsmManager *manager, static void request_switch_user (GsmManager *manager) { + GsmManagerPrivate *priv; + g_debug ("GsmManager: requesting user switch"); /* See comment in manager_switch_user() to understand why we do this in @@ -3099,21 +3261,22 @@ request_switch_user (GsmManager *manager) return; } - if (manager->priv->inhibit_dialog != NULL) { + priv = gsm_manager_get_instance_private (manager); + if (priv->inhibit_dialog != NULL) { g_debug ("GsmManager: inhibit dialog already up"); - gtk_window_present (GTK_WINDOW (manager->priv->inhibit_dialog)); + gtk_window_present (GTK_WINDOW (priv->inhibit_dialog)); return; } - manager->priv->inhibit_dialog = gsm_inhibit_dialog_new (manager->priv->inhibitors, - manager->priv->clients, - GSM_LOGOUT_ACTION_SWITCH_USER); + priv->inhibit_dialog = gsm_inhibit_dialog_new (priv->inhibitors, + priv->clients, + GSM_LOGOUT_ACTION_SWITCH_USER); - g_signal_connect (manager->priv->inhibit_dialog, + g_signal_connect (priv->inhibit_dialog, "response", G_CALLBACK (inhibit_dialog_response), manager); - gtk_widget_show (manager->priv->inhibit_dialog); + gtk_widget_show (priv->inhibit_dialog); } static void @@ -3121,10 +3284,13 @@ logout_dialog_response (GsmLogoutDialog *logout_dialog, guint response_id, GsmManager *manager) { + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); /* We should only be here if mode has already have been set from * show_fallback_shutdown/logout_dialog */ - g_assert (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_NORMAL); + g_assert (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_NORMAL); g_debug ("GsmManager: Logout dialog response: %d", response_id); @@ -3173,13 +3339,15 @@ static void show_shutdown_dialog (GsmManager *manager) { GtkWidget *dialog; + GsmManagerPrivate *priv; - if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) { + priv = gsm_manager_get_instance_private (manager); + if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) { /* Already shutting down, nothing more to do */ return; } - manager->priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL; + priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL; dialog = gsm_get_shutdown_dialog (gdk_screen_get_default (), gtk_get_current_event_time ()); @@ -3197,13 +3365,15 @@ static void show_logout_dialog (GsmManager *manager) { GtkWidget *dialog; + GsmManagerPrivate *priv; - if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) { + priv = gsm_manager_get_instance_private (manager); + if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) { /* Already shutting down, nothing more to do */ return; } - manager->priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL; + priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL; dialog = gsm_get_logout_dialog (gdk_screen_get_default (), gtk_get_current_event_time ()); @@ -3222,14 +3392,17 @@ user_logout (GsmManager *manager, GsmManagerLogoutMode mode) { gboolean logout_prompt; + GsmManagerPrivate *priv; - if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) { + priv = gsm_manager_get_instance_private (manager); + + if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) { /* Already shutting down, nothing more to do */ return; } logout_prompt = - g_settings_get_boolean (manager->priv->settings_session, + g_settings_get_boolean (priv->settings_session, "logout-prompt"); /* If the shell isn't running, and this isn't a non-interative logout request, @@ -3254,8 +3427,12 @@ gboolean gsm_manager_set_phase (GsmManager *manager, GsmManagerPhase phase) { + GsmManagerPrivate *priv; + g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); - manager->priv->phase = phase; + + priv = gsm_manager_get_instance_private (manager); + priv->phase = phase; return (TRUE); } @@ -3263,11 +3440,13 @@ gboolean gsm_manager_request_shutdown (GsmManager *manager, GError **error) { + GsmManagerPrivate *priv; g_debug ("GsmManager: RequestShutdown called"); g_return_val_if_fail(GSM_IS_MANAGER (manager), FALSE); - if (manager->priv->phase != GSM_MANAGER_PHASE_RUNNING) { + priv = gsm_manager_get_instance_private (manager); + if (priv->phase != GSM_MANAGER_PHASE_RUNNING) { g_set_error (error, GSM_MANAGER_ERROR, GSM_MANAGER_ERROR_NOT_IN_RUNNING, @@ -3284,11 +3463,14 @@ gboolean gsm_manager_request_reboot (GsmManager *manager, GError **error) { + GsmManagerPrivate *priv; + g_debug ("GsmManager: RequestReboot called"); g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); - if (manager->priv->phase != GSM_MANAGER_PHASE_RUNNING) { + priv = gsm_manager_get_instance_private (manager); + if (priv->phase != GSM_MANAGER_PHASE_RUNNING) { g_set_error (error, GSM_MANAGER_ERROR, GSM_MANAGER_ERROR_NOT_IN_RUNNING, @@ -3304,14 +3486,21 @@ gsm_manager_request_reboot (GsmManager *manager, static gboolean _log_out_is_locked_down (GsmManager *manager) { - return g_settings_get_boolean (manager->priv->settings_lockdown, + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); + + return g_settings_get_boolean (priv->settings_lockdown, KEY_LOG_OUT_DISABLE); } static gboolean _switch_user_is_locked_down (GsmManager *manager) { - return g_settings_get_boolean (manager->priv->settings_lockdown, + GsmManagerPrivate *priv; + + priv = gsm_manager_get_instance_private (manager); + return g_settings_get_boolean (priv->settings_lockdown, KEY_USER_SWITCH_DISABLE); } @@ -3319,11 +3508,13 @@ gboolean gsm_manager_shutdown (GsmManager *manager, GError **error) { + GsmManagerPrivate *priv; g_debug ("GsmManager: Shutdown called"); g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); - if (manager->priv->phase != GSM_MANAGER_PHASE_RUNNING) { + priv = gsm_manager_get_instance_private (manager); + if (priv->phase != GSM_MANAGER_PHASE_RUNNING) { g_set_error (error, GSM_MANAGER_ERROR, GSM_MANAGER_ERROR_NOT_IN_RUNNING, @@ -3387,11 +3578,13 @@ gsm_manager_logout (GsmManager *manager, guint logout_mode, GError **error) { + GsmManagerPrivate *priv; g_debug ("GsmManager: Logout called"); g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); - if (manager->priv->phase != GSM_MANAGER_PHASE_RUNNING) { + priv = gsm_manager_get_instance_private (manager); + if (priv->phase != GSM_MANAGER_PHASE_RUNNING) { g_set_error (error, GSM_MANAGER_ERROR, GSM_MANAGER_ERROR_NOT_IN_RUNNING, @@ -3437,6 +3630,7 @@ gsm_manager_register_client (GsmManager *manager, char *sender; GsmClient *client; GsmApp *app; + GsmManagerPrivate *priv; g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); @@ -3445,7 +3639,8 @@ gsm_manager_register_client (GsmManager *manager, g_debug ("GsmManager: RegisterClient %s", startup_id); - if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) { + priv = gsm_manager_get_instance_private (manager); + if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) { GError *new_error; g_debug ("Unable to register client: shutting down"); @@ -3462,7 +3657,7 @@ gsm_manager_register_client (GsmManager *manager, new_startup_id = gsm_util_generate_startup_id (); } else { - client = (GsmClient *)gsm_store_find (manager->priv->clients, + client = (GsmClient *)gsm_store_find (priv->clients, (GsmStoreFunc)_client_has_startup_id, (char *)startup_id); /* We can't have two clients with the same startup id. */ @@ -3508,7 +3703,7 @@ gsm_manager_register_client (GsmManager *manager, return FALSE; } - gsm_store_add (manager->priv->clients, gsm_client_peek_id (client), G_OBJECT (client)); + gsm_store_add (priv->clients, gsm_client_peek_id (client), G_OBJECT (client)); /* the store will own the ref */ g_object_unref (client); @@ -3537,12 +3732,14 @@ gsm_manager_unregister_client (GsmManager *manager, DBusGMethodInvocation *context) { GsmClient *client; + GsmManagerPrivate *priv; g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); g_debug ("GsmManager: UnregisterClient %s", client_id); - client = (GsmClient *)gsm_store_lookup (manager->priv->clients, client_id); + priv = gsm_manager_get_instance_private (manager); + client = (GsmClient *)gsm_store_lookup (priv->clients, client_id); if (client == NULL) { GError *new_error; @@ -3575,6 +3772,7 @@ gsm_manager_inhibit (GsmManager *manager, { GsmInhibitor *inhibitor; guint cookie; + GsmManagerPrivate *priv; g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); @@ -3584,7 +3782,8 @@ gsm_manager_inhibit (GsmManager *manager, reason, flags); - if (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { + priv = gsm_manager_get_instance_private (manager); + if (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { GError *new_error; new_error = g_error_new (GSM_MANAGER_ERROR, @@ -3639,7 +3838,7 @@ gsm_manager_inhibit (GsmManager *manager, reason, dbus_g_method_get_sender (context), cookie); - gsm_store_add (manager->priv->inhibitors, gsm_inhibitor_peek_id (inhibitor), G_OBJECT (inhibitor)); + gsm_store_add (priv->inhibitors, gsm_inhibitor_peek_id (inhibitor), G_OBJECT (inhibitor)); g_object_unref (inhibitor); dbus_g_method_return (context, cookie); @@ -3653,12 +3852,14 @@ gsm_manager_uninhibit (GsmManager *manager, DBusGMethodInvocation *context) { GsmInhibitor *inhibitor; + GsmManagerPrivate *priv; g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); g_debug ("GsmManager: Uninhibit %u", cookie); - inhibitor = (GsmInhibitor *)gsm_store_find (manager->priv->inhibitors, + priv = gsm_manager_get_instance_private (manager); + inhibitor = (GsmInhibitor *)gsm_store_find (priv->inhibitors, (GsmStoreFunc)_find_by_cookie, &cookie); if (inhibitor == NULL) { @@ -3680,7 +3881,7 @@ gsm_manager_uninhibit (GsmManager *manager, gsm_inhibitor_peek_flags (inhibitor), gsm_inhibitor_peek_bus_name (inhibitor)); - gsm_store_remove (manager->priv->inhibitors, gsm_inhibitor_peek_id (inhibitor)); + gsm_store_remove (priv->inhibitors, gsm_inhibitor_peek_id (inhibitor)); dbus_g_method_return (context); @@ -3694,16 +3895,18 @@ gsm_manager_is_inhibited (GsmManager *manager, GError *error) { GsmInhibitor *inhibitor; + GsmManagerPrivate *priv; g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); - if (manager->priv->inhibitors == NULL - || gsm_store_size (manager->priv->inhibitors) == 0) { + priv = gsm_manager_get_instance_private (manager); + if (priv->inhibitors == NULL + || gsm_store_size (priv->inhibitors) == 0) { *is_inhibited = FALSE; return TRUE; } - inhibitor = (GsmInhibitor *) gsm_store_find (manager->priv->inhibitors, + inhibitor = (GsmInhibitor *) gsm_store_find (priv->inhibitors, (GsmStoreFunc)inhibitor_has_flag, GUINT_TO_POINTER (flags)); if (inhibitor == NULL) { @@ -3730,6 +3933,7 @@ gsm_manager_get_clients (GsmManager *manager, GPtrArray **clients, GError **error) { + GsmManagerPrivate *priv; g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); if (clients == NULL) { @@ -3737,7 +3941,8 @@ gsm_manager_get_clients (GsmManager *manager, } *clients = g_ptr_array_new (); - gsm_store_foreach (manager->priv->clients, (GsmStoreFunc)listify_store_ids, clients); + priv = gsm_manager_get_instance_private (manager); + gsm_store_foreach (priv->clients, (GsmStoreFunc)listify_store_ids, clients); return TRUE; } @@ -3747,6 +3952,8 @@ gsm_manager_get_inhibitors (GsmManager *manager, GPtrArray **inhibitors, GError **error) { + GsmManagerPrivate *priv; + g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); if (inhibitors == NULL) { @@ -3754,7 +3961,8 @@ gsm_manager_get_inhibitors (GsmManager *manager, } *inhibitors = g_ptr_array_new (); - gsm_store_foreach (manager->priv->inhibitors, + priv = gsm_manager_get_instance_private (manager); + gsm_store_foreach (priv->inhibitors, (GsmStoreFunc) listify_store_ids, inhibitors); @@ -3783,10 +3991,12 @@ gsm_manager_is_autostart_condition_handled (GsmManager *manager, GError **error) { GsmApp *app; + GsmManagerPrivate *priv; g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); - app = (GsmApp *) gsm_store_find (manager->priv->apps,( + priv = gsm_manager_get_instance_private (manager); + app = (GsmApp *) gsm_store_find (priv->apps,( GsmStoreFunc) _app_has_autostart_condition, (char *)condition); @@ -3806,6 +4016,7 @@ append_app (GsmManager *manager, const char *id; const char *app_id; GsmApp *dup; + GsmManagerPrivate *priv; id = gsm_app_peek_id (app); if (IS_STRING_EMPTY (id)) { @@ -3813,7 +4024,8 @@ append_app (GsmManager *manager, return; } - dup = (GsmApp *)gsm_store_lookup (manager->priv->apps, id); + priv = gsm_manager_get_instance_private (manager); + dup = (GsmApp *)gsm_store_lookup (priv->apps, id); if (dup != NULL) { g_debug ("GsmManager: not adding app: already added"); return; @@ -3831,7 +4043,7 @@ append_app (GsmManager *manager, return; } - gsm_store_add (manager->priv->apps, id, G_OBJECT (app)); + gsm_store_add (priv->apps, id, G_OBJECT (app)); } gboolean @@ -3840,15 +4052,17 @@ gsm_manager_add_autostart_app (GsmManager *manager, const char *provides) { GsmApp *app; + GsmManagerPrivate *priv; g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); g_return_val_if_fail (path != NULL, FALSE); + priv = gsm_manager_get_instance_private (manager); /* first check to see if service is already provided */ if (provides != NULL) { GsmApp *dup; - dup = (GsmApp *)gsm_store_find (manager->priv->apps, + dup = (GsmApp *)gsm_store_find (priv->apps, (GsmStoreFunc)_find_app_provides, (char *)provides); if (dup != NULL) { @@ -3909,8 +4123,11 @@ gsm_manager_is_session_running (GsmManager *manager, gboolean *running, GError **error) { + GsmManagerPrivate *priv; + g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); - *running = (manager->priv->phase == GSM_MANAGER_PHASE_RUNNING); + priv = gsm_manager_get_instance_private (manager); + *running = (priv->phase == GSM_MANAGER_PHASE_RUNNING); return TRUE; } diff --git a/mate-session/gsm-manager.h b/mate-session/gsm-manager.h index 4422f59..73e637e 100644 --- a/mate-session/gsm-manager.h +++ b/mate-session/gsm-manager.h @@ -27,26 +27,12 @@ #include "gsm-store.h" -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define GSM_TYPE_MANAGER (gsm_manager_get_type ()) -#define GSM_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSM_TYPE_MANAGER, GsmManager)) -#define GSM_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSM_TYPE_MANAGER, GsmManagerClass)) -#define GSM_IS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSM_TYPE_MANAGER)) -#define GSM_IS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSM_TYPE_MANAGER)) -#define GSM_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSM_TYPE_MANAGER, GsmManagerClass)) +G_DECLARE_DERIVABLE_TYPE (GsmManager, gsm_manager, GSM, MANAGER, GObject) -typedef struct GsmManagerPrivate GsmManagerPrivate; - -typedef struct -{ - GObject parent; - GsmManagerPrivate *priv; -} GsmManager; - -typedef struct +struct _GsmManagerClass { GObjectClass parent_class; @@ -65,7 +51,7 @@ typedef struct const char *id); void (* inhibitor_removed) (GsmManager *manager, const char *id); -} GsmManagerClass; +}; //GsmManagerClass; typedef enum { /* gsm's own startup/initialization phase */ @@ -112,7 +98,6 @@ GType gsm_manager_error_get_type (void); #define GSM_MANAGER_TYPE_ERROR (gsm_manager_error_get_type ()) GQuark gsm_manager_error_quark (void); -GType gsm_manager_get_type (void); GsmManager * gsm_manager_new (GsmStore *client_store, gboolean failsafe); @@ -194,8 +179,6 @@ gboolean gsm_manager_is_session_running (GsmManager *mana gboolean *running, GError **error); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_MANAGER_H */ |