gnome-session r4807 - in branches/dbus_based: . gnome-session



Author: mccann
Date: Thu Jul 17 06:05:43 2008
New Revision: 4807
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4807&view=rev

Log:
2008-07-17  William Jon McCann  <jmccann redhat com>

	* gnome-session/gsm-manager.c (on_xsmp_client_register_request),
	(inhibitor_has_client_id), (generate_cookie),
	(_generate_unique_cookie), (on_client_end_session_response),
	(on_store_client_added), (gsm_manager_register_client):
	* gnome-session/gsm-xsmp-client.c (gsm_xsmp_client_class_init),
	(save_yourself_phase2_request_callback),
	(interact_request_callback), (interact_done_callback),
	(save_yourself_done_callback), (close_connection_callback),
	(gsm_xsmp_client_connect):
	Start hooking up XSMP bit of query-end-session.



Modified:
   branches/dbus_based/ChangeLog
   branches/dbus_based/gnome-session/gsm-manager.c
   branches/dbus_based/gnome-session/gsm-xsmp-client.c

Modified: branches/dbus_based/gnome-session/gsm-manager.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-manager.c	(original)
+++ branches/dbus_based/gnome-session/gsm-manager.c	Thu Jul 17 06:05:43 2008
@@ -757,18 +757,6 @@
 
         g_debug ("GsmManager: Adding new client %s to session", new_id);
 
-#if 0
-        g_signal_connect (client, "saved_state",
-                          G_CALLBACK (client_saved_state), session);
-        g_signal_connect (client, "request_phase2",
-                          G_CALLBACK (client_request_phase2), session);
-        g_signal_connect (client, "request_interaction",
-                          G_CALLBACK (client_request_interaction), session);
-        g_signal_connect (client, "interaction_done",
-                          G_CALLBACK (client_interaction_done), session);
-        g_signal_connect (client, "save_yourself_done",
-                          G_CALLBACK (client_save_yourself_done), session);
-#endif
         g_signal_connect (client,
                           "disconnected",
                           G_CALLBACK (on_client_disconnected),
@@ -797,6 +785,82 @@
         return handled;
 }
 
+static gboolean
+inhibitor_has_client_id (gpointer      key,
+                         GsmInhibitor *inhibitor,
+                         const char   *client_id_a)
+{
+        gboolean    matches;
+        const char *client_id_b;
+
+        client_id_b = gsm_inhibitor_get_client_id (inhibitor);
+
+        matches = FALSE;
+        if (client_id_a != NULL && client_id_b != NULL) {
+                matches = (strcmp (client_id_a, client_id_b) == 0);
+                if (matches) {
+                        g_debug ("GsmManager: removing JIT inhibitor for %s for reason '%s'",
+                                 gsm_inhibitor_get_client_id (inhibitor),
+                                 gsm_inhibitor_get_reason (inhibitor));
+                }
+        }
+
+        return matches;
+}
+
+static guint32
+generate_cookie (void)
+{
+        guint32 cookie;
+
+        cookie = (guint32)g_random_int_range (1, G_MAXINT32);
+
+        return cookie;
+}
+
+static guint32
+_generate_unique_cookie (GsmManager *manager)
+{
+        guint32 cookie;
+
+        do {
+                cookie = generate_cookie ();
+        } while (gsm_inhibitor_store_lookup (manager->priv->inhibitors, cookie) != NULL);
+
+        return cookie;
+}
+
+static void
+on_client_end_session_response (GsmClient  *client,
+                                gboolean    is_ok,
+                                const char *reason,
+                                GsmManager *manager)
+{
+        g_debug ("GsmManager: Response from end session request: is-ok=%d reason=%s", is_ok, reason);
+
+        manager->priv->query_clients = g_slist_remove (manager->priv->query_clients, client);
+
+        if (! is_ok) {
+                guint         cookie;
+                GsmInhibitor *inhibitor;
+
+                /* FIXME: do we support updating the reason? */
+
+                cookie = _generate_unique_cookie (manager);
+                inhibitor = gsm_inhibitor_new_for_client (gsm_client_get_id (client),
+                                                          gsm_client_get_app_id (client),
+                                                          GSM_INHIBITOR_FLAG_LOGOUT,
+                                                          reason,
+                                                          cookie);
+                gsm_inhibitor_store_add (manager->priv->inhibitors, inhibitor);
+                g_object_unref (inhibitor);
+        } else {
+                gsm_inhibitor_store_foreach_remove (manager->priv->inhibitors,
+                                                    (GsmInhibitorStoreFunc)inhibitor_has_client_id,
+                                                    (gpointer)gsm_client_get_id (client));
+        }
+}
+
 static void
 on_store_client_added (GsmClientStore *store,
                        const char     *id,
@@ -816,6 +880,11 @@
                                   manager);
         }
 
+        g_signal_connect (client,
+                          "end-session-response",
+                          G_CALLBACK (on_client_end_session_response),
+                          manager);
+
         /* FIXME: disconnect signal handler */
 }
 
@@ -1776,81 +1845,6 @@
 
 }
 
-static gboolean
-inhibitor_has_client_id (gpointer      key,
-                         GsmInhibitor *inhibitor,
-                         const char   *client_id_a)
-{
-        gboolean    matches;
-        const char *client_id_b;
-
-        client_id_b = gsm_inhibitor_get_client_id (inhibitor);
-
-        matches = FALSE;
-        if (client_id_a != NULL && client_id_b != NULL) {
-                matches = (strcmp (client_id_a, client_id_b) == 0);
-                if (matches) {
-                        g_debug ("GsmManager: removing JIT inhibitor for %s for reason '%s'",
-                                 gsm_inhibitor_get_client_id (inhibitor),
-                                 gsm_inhibitor_get_reason (inhibitor));
-                }
-        }
-
-        return matches;
-}
-
-static guint32
-generate_cookie (void)
-{
-        guint32 cookie;
-
-        cookie = (guint32)g_random_int_range (1, G_MAXINT32);
-
-        return cookie;
-}
-
-static guint32
-_generate_unique_cookie (GsmManager *manager)
-{
-        guint32 cookie;
-
-        do {
-                cookie = generate_cookie ();
-        } while (gsm_inhibitor_store_lookup (manager->priv->inhibitors, cookie) != NULL);
-
-        return cookie;
-}
-
-static void
-on_client_end_session_response (GsmClient  *client,
-                                gboolean    is_ok,
-                                const char *reason,
-                                GsmManager *manager)
-{
-        g_debug ("GsmManager: Response from end session request: is-ok=%d reason=%s", is_ok, reason);
-
-        manager->priv->query_clients = g_slist_remove (manager->priv->query_clients, client);
-
-        if (! is_ok) {
-                guint         cookie;
-                GsmInhibitor *inhibitor;
-
-                /* FIXME: do we support updating the reason? */
-
-                cookie = _generate_unique_cookie (manager);
-                inhibitor = gsm_inhibitor_new_for_client (gsm_client_get_id (client),
-                                                          gsm_client_get_app_id (client),
-                                                          GSM_INHIBITOR_FLAG_LOGOUT,
-                                                          reason,
-                                                          cookie);
-                gsm_inhibitor_store_add (manager->priv->inhibitors, inhibitor);
-                g_object_unref (inhibitor);
-        } else {
-                gsm_inhibitor_store_foreach_remove (manager->priv->inhibitors,
-                                                    (GsmInhibitorStoreFunc)inhibitor_has_client_id,
-                                                    (gpointer)gsm_client_get_id (client));
-        }
-}
 
 static gboolean
 on_query_end_session_timeout (GsmManager *manager)
@@ -2245,11 +2239,6 @@
 
         gsm_client_store_add (manager->priv->store, client);
 
-        g_signal_connect (client,
-                          "end-session-response",
-                          G_CALLBACK (on_client_end_session_response),
-                          manager);
-
         if (app != NULL) {
                 gsm_client_set_app_id (client, gsm_app_get_id (app));
                 gsm_app_registered (app);

Modified: branches/dbus_based/gnome-session/gsm-xsmp-client.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-xsmp-client.c	(original)
+++ branches/dbus_based/gnome-session/gsm-xsmp-client.c	Thu Jul 17 06:05:43 2008
@@ -29,6 +29,8 @@
 #include <time.h>
 #include <unistd.h>
 
+#include <glib/gi18n.h>
+
 #include "gsm-xsmp-client.h"
 #include "gsm-marshal.h"
 
@@ -62,12 +64,6 @@
 enum {
         REGISTER_REQUEST,
         LOGOUT_REQUEST,
-        SAVED_STATE,
-        REQUEST_PHASE2,
-        REQUEST_INTERACTION,
-        INTERACTION_DONE,
-        SAVE_YOURSELF_DONE,
-        DISCONNECTED,
         LAST_SIGNAL
 };
 
@@ -419,22 +415,6 @@
         return ((unsigned char *)prop->vals[0].value)[0] == SmRestartImmediately;
 }
 
-static gboolean
-xsmp_restart (GsmClient *client,
-              GError   **error)
-{
-        char    *restart_cmd;
-        gboolean res;
-
-        restart_cmd = xsmp_get_restart_command (client);
-
-        res = g_spawn_command_line_async (restart_cmd, error);
-
-        g_free (restart_cmd);
-
-        return res;
-}
-
 static void
 do_save_yourself (GsmXSMPClient *client,
                   int            save_type)
@@ -508,17 +488,6 @@
         SmsInteract (xsmp->priv->conn);
 }
 
-
-static void
-xsmp_shutdown_cancelled (GsmClient *client)
-{
-        GsmXSMPClient *xsmp = (GsmXSMPClient *) client;
-
-        g_debug ("GsmXSMPClient: xsmp_shutdown_cancelled ('%s')", xsmp->priv->description);
-
-        SmsShutdownCancelled (xsmp->priv->conn);
-}
-
 static gboolean
 xsmp_stop (GsmClient *client,
            GError   **error)
@@ -671,56 +640,6 @@
                               G_TYPE_NONE,
                               1, G_TYPE_BOOLEAN);
 
-        signals[SAVED_STATE] =
-                g_signal_new ("saved_state",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmXSMPClientClass, saved_state),
-                              NULL, NULL,
-                              g_cclosure_marshal_VOID__VOID,
-                              G_TYPE_NONE,
-                              0);
-
-        signals[REQUEST_PHASE2] =
-                g_signal_new ("request_phase2",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmXSMPClientClass, request_phase2),
-                              NULL, NULL,
-                              g_cclosure_marshal_VOID__VOID,
-                              G_TYPE_NONE,
-                              0);
-
-        signals[REQUEST_INTERACTION] =
-                g_signal_new ("request_interaction",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmXSMPClientClass, request_interaction),
-                              NULL, NULL,
-                              g_cclosure_marshal_VOID__VOID,
-                              G_TYPE_NONE,
-                              0);
-
-        signals[INTERACTION_DONE] =
-                g_signal_new ("interaction_done",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmXSMPClientClass, interaction_done),
-                              NULL, NULL,
-                              g_cclosure_marshal_VOID__BOOLEAN,
-                              G_TYPE_NONE,
-                              1, G_TYPE_BOOLEAN);
-
-        signals[SAVE_YOURSELF_DONE] =
-                g_signal_new ("save_yourself_done",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmXSMPClientClass, save_yourself_done),
-                              NULL, NULL,
-                              g_cclosure_marshal_VOID__VOID,
-                              G_TYPE_NONE,
-                              0);
-
         g_object_class_install_property (object_class,
                                          PROP_ICE_CONNECTION,
                                          g_param_spec_pointer ("ice-connection",
@@ -871,17 +790,10 @@
 {
         GsmXSMPClient *client = manager_data;
 
-        g_debug ("Client '%s' received SaveYourselfPhase2Request",
+        g_debug ("GsmXSMPClient: Client '%s' received SaveYourselfPhase2Request",
                  client->priv->description);
 
-        if (client->priv->current_save_yourself == SmSaveLocal) {
-                /* WTF? Anyway, if it's checkpointing, it doesn't have to wait
-                 * for anyone else.
-                 */
-                SmsSaveYourselfPhase2 (client->priv->conn);
-        } else {
-                g_signal_emit (client, signals[REQUEST_PHASE2], 0);
-        }
+        /* FIXME: change priority so this client runs at the end */
 }
 
 static void
@@ -891,11 +803,15 @@
 {
         GsmXSMPClient *client = manager_data;
 
-        g_debug ("Client '%s' received InteractRequest(%s)",
+        g_debug ("GsmXSMPClient: Client '%s' received InteractRequest(%s)",
                  client->priv->description,
                  dialog_type == SmInteractStyleAny ? "Any" : "Errors");
 
-        g_signal_emit (client, signals[REQUEST_INTERACTION], 0);
+        gdm_client_end_session_response (GSM_CLIENT (client),
+                                         FALSE,
+                                         _("Requesting user input"));
+
+        xsmp_interact (GSM_CLIENT (client));
 }
 
 static void
@@ -905,11 +821,13 @@
 {
         GsmXSMPClient *client = manager_data;
 
-        g_debug ("Client '%s' received InteractDone(cancel_shutdown = %s)",
+        g_debug ("GsmXSMPClient: Client '%s' received InteractDone(cancel_shutdown = %s)",
                  client->priv->description,
                  cancel_shutdown ? "True" : "False");
 
-        g_signal_emit (client, signals[INTERACTION_DONE], 0, cancel_shutdown);
+        gdm_client_end_session_response (GSM_CLIENT (client),
+                                         TRUE,
+                                         NULL);
 }
 
 static void
@@ -919,19 +837,21 @@
 {
         GsmXSMPClient *client = manager_data;
 
-        g_debug ("Client '%s' received SaveYourselfDone(success = %s)",
+        g_debug ("GsmXSMPClient: Client '%s' received SaveYourselfDone(success = %s)",
                  client->priv->description,
                  success ? "True" : "False");
 
         if (client->priv->current_save_yourself == SmSaveLocal) {
                 client->priv->current_save_yourself = -1;
                 SmsSaveComplete (client->priv->conn);
-                g_signal_emit (client, signals[SAVED_STATE], 0);
         } else {
                 client->priv->current_save_yourself = -1;
-                g_signal_emit (client, signals[SAVE_YOURSELF_DONE], 0);
         }
 
+        gdm_client_end_session_response (GSM_CLIENT (client),
+                                         TRUE,
+                                         NULL);
+
         if (client->priv->next_save_yourself) {
                 int save_type = client->priv->next_save_yourself;
 
@@ -949,9 +869,9 @@
         GsmXSMPClient *client = manager_data;
         int            i;
 
-        g_debug ("Client '%s' received CloseConnection", client->priv->description);
+        g_debug ("GsmXSMPClient: Client '%s' received CloseConnection", client->priv->description);
         for (i = 0; i < count; i++) {
-                g_debug (" close reason: '%s'", reason_msgs[i]);
+                g_debug ("GsmXSMPClient:  close reason: '%s'", reason_msgs[i]);
         }
         SmFreeReasons (count, reason_msgs);
 
@@ -971,7 +891,7 @@
                 client->priv->protocol_timeout = 0;
         }
 
-        g_debug ("Initializing client %s", client->priv->description);
+        g_debug ("GsmXSMPClient: Initializing client %s", client->priv->description);
 
         *mask_ret = 0;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]