gnome-session r4946 - in trunk: . gnome-session
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4946 - in trunk: . gnome-session
- Date: Wed, 13 Aug 2008 19:12:08 +0000 (UTC)
Author: mccann
Date: Wed Aug 13 19:12:07 2008
New Revision: 4946
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4946&view=rev
Log:
2008-08-13 William Jon McCann <jmccann redhat com>
* gnome-session/gsm-client.c (gsm_client_error_quark),
(gsm_client_error_get_type), (gsm_client_cancel_end_session),
(gsm_client_query_end_session), (gsm_client_end_session):
* gnome-session/gsm-client.h:
* gnome-session/gsm-dbus-client.c (dbus_client_query_end_session),
(dbus_client_end_session), (dbus_client_cancel_end_session):
* gnome-session/gsm-manager.c (_client_end_session),
(_client_query_end_session), (_client_cancel_end_session):
* gnome-session/gsm-xsmp-client.c (client_iochannel_watch),
(_client_protocol_timeout), (do_save_yourself),
(xsmp_cancel_end_session), (xsmp_query_end_session),
(xsmp_end_session), (gsm_xsmp_client_disconnect),
(gsm_xsmp_client_finalize), (interact_request_callback),
(close_connection_callback):
Make QES,ES,CES return errors. Check to make sure that
connection is valid before handling same. Set
status and disconnect when disconnected.
Modified:
trunk/ChangeLog
trunk/gnome-session/gsm-client.c
trunk/gnome-session/gsm-client.h
trunk/gnome-session/gsm-dbus-client.c
trunk/gnome-session/gsm-manager.c
trunk/gnome-session/gsm-xsmp-client.c
Modified: trunk/gnome-session/gsm-client.c
==============================================================================
--- trunk/gnome-session/gsm-client.c (original)
+++ trunk/gnome-session/gsm-client.c Wed Aug 13 19:12:07 2008
@@ -58,6 +58,39 @@
G_DEFINE_ABSTRACT_TYPE (GsmClient, gsm_client, G_TYPE_OBJECT)
+GQuark
+gsm_client_error_quark (void)
+{
+ static GQuark ret = 0;
+ if (ret == 0) {
+ ret = g_quark_from_static_string ("gsm_client_error");
+ }
+
+ return ret;
+}
+
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+
+GType
+gsm_client_error_get_type (void)
+{
+ static GType etype = 0;
+
+ if (etype == 0) {
+ static const GEnumValue values[] = {
+ ENUM_ENTRY (GSM_CLIENT_ERROR_GENERAL, "GeneralError"),
+ ENUM_ENTRY (GSM_CLIENT_ERROR_NOT_REGISTERED, "NotRegistered"),
+ { 0, 0, 0 }
+ };
+
+ g_assert (GSM_CLIENT_NUM_ERRORS == G_N_ELEMENTS (values) - 1);
+
+ etype = g_enum_register_static ("GsmClientError", values);
+ }
+
+ return etype;
+}
+
static guint32
get_next_client_serial (void)
{
@@ -428,31 +461,34 @@
return GSM_CLIENT_GET_CLASS (client)->impl_get_app_name (client);
}
-void
-gsm_client_cancel_end_session (GsmClient *client)
+gboolean
+gsm_client_cancel_end_session (GsmClient *client,
+ GError **error)
{
- g_return_if_fail (GSM_IS_CLIENT (client));
+ g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
- GSM_CLIENT_GET_CLASS (client)->impl_cancel_end_session (client);
+ return GSM_CLIENT_GET_CLASS (client)->impl_cancel_end_session (client, error);
}
-void
+gboolean
gsm_client_query_end_session (GsmClient *client,
- guint flags)
+ guint flags,
+ GError **error)
{
- g_return_if_fail (GSM_IS_CLIENT (client));
+ g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
- GSM_CLIENT_GET_CLASS (client)->impl_query_end_session (client, flags);
+ return GSM_CLIENT_GET_CLASS (client)->impl_query_end_session (client, flags, error);
}
-void
+gboolean
gsm_client_end_session (GsmClient *client,
- guint flags)
+ guint flags,
+ GError **error)
{
- g_return_if_fail (GSM_IS_CLIENT (client));
+ g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
- GSM_CLIENT_GET_CLASS (client)->impl_end_session (client, flags);
+ return GSM_CLIENT_GET_CLASS (client)->impl_end_session (client, flags, error);
}
gboolean
Modified: trunk/gnome-session/gsm-client.h
==============================================================================
--- trunk/gnome-session/gsm-client.h (original)
+++ trunk/gnome-session/gsm-client.h Wed Aug 13 19:12:07 2008
@@ -77,15 +77,31 @@
char * (*impl_get_app_name) (GsmClient *client);
GsmClientRestartStyle (*impl_get_restart_style_hint) (GsmClient *client);
guint (*impl_get_unix_process_id) (GsmClient *client);
- void (*impl_query_end_session) (GsmClient *client,
- guint flags);
- void (*impl_end_session) (GsmClient *client,
- guint flags);
- void (*impl_cancel_end_session) (GsmClient *client);
+ gboolean (*impl_query_end_session) (GsmClient *client,
+ guint flags,
+ GError **error);
+ gboolean (*impl_end_session) (GsmClient *client,
+ guint flags,
+ GError **error);
+ gboolean (*impl_cancel_end_session) (GsmClient *client,
+ GError **error);
gboolean (*impl_stop) (GsmClient *client,
GError **error);
};
+typedef enum
+{
+ GSM_CLIENT_ERROR_GENERAL = 0,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ GSM_CLIENT_NUM_ERRORS
+} GsmClientError;
+
+#define GSM_CLIENT_ERROR gsm_client_error_quark ()
+#define GSM_CLIENT_TYPE_ERROR (gsm_client_error_get_type ())
+
+GType gsm_client_error_get_type (void);
+GQuark gsm_client_error_quark (void);
+
GType gsm_client_get_type (void) G_GNUC_CONST;
const char *gsm_client_peek_id (GsmClient *client);
@@ -103,11 +119,14 @@
void gsm_client_set_status (GsmClient *client,
guint status);
-void gsm_client_end_session (GsmClient *client,
- guint flags);
-void gsm_client_query_end_session (GsmClient *client,
- guint flags);
-void gsm_client_cancel_end_session (GsmClient *client);
+gboolean gsm_client_end_session (GsmClient *client,
+ guint flags,
+ GError **error);
+gboolean gsm_client_query_end_session (GsmClient *client,
+ guint flags,
+ GError **error);
+gboolean gsm_client_cancel_end_session (GsmClient *client,
+ GError **error);
void gsm_client_disconnected (GsmClient *client);
Modified: trunk/gnome-session/gsm-dbus-client.c
==============================================================================
--- trunk/gnome-session/gsm-dbus-client.c (original)
+++ trunk/gnome-session/gsm-dbus-client.c Wed Aug 13 19:12:07 2008
@@ -18,9 +18,7 @@
* 02111-1307, USA.
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#include <fcntl.h>
#include <stdio.h>
@@ -463,13 +461,25 @@
return (GSM_DBUS_CLIENT (client)->priv->caller_pid);
}
-static void
+static gboolean
dbus_client_query_end_session (GsmClient *client,
- guint flags)
+ guint flags,
+ GError **error)
{
GsmDBusClient *dbus_client = (GsmDBusClient *) client;
DBusMessage *message;
DBusMessageIter iter;
+ gboolean ret;
+
+ ret = FALSE;
+
+ if (dbus_client->priv->bus_name == NULL) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Client is not registered");
+ return FALSE;
+ }
g_debug ("GsmDBusClient: sending QueryEndSession signal to %s", dbus_client->priv->bus_name);
@@ -478,9 +488,17 @@
SM_DBUS_CLIENT_PRIVATE_INTERFACE,
"QueryEndSession");
if (message == NULL) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Unable to send QueryEndSession message");
goto out;
}
if (!dbus_message_set_destination (message, dbus_client->priv->bus_name)) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Unable to send QueryEndSession message");
goto out;
}
@@ -488,31 +506,51 @@
dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &flags);
if (!dbus_connection_send (dbus_client->priv->connection, message, NULL)) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Unable to send QueryEndSession message");
goto out;
}
+ ret = TRUE;
+
out:
if (message != NULL) {
dbus_message_unref (message);
}
+
+ return ret;
}
-static void
+static gboolean
dbus_client_end_session (GsmClient *client,
- guint flags)
+ guint flags,
+ GError **error)
{
GsmDBusClient *dbus_client = (GsmDBusClient *) client;
DBusMessage *message;
DBusMessageIter iter;
+ gboolean ret;
+
+ ret = FALSE;
/* unicast the signal to only the registered bus name */
message = dbus_message_new_signal (gsm_client_peek_id (client),
SM_DBUS_CLIENT_PRIVATE_INTERFACE,
"EndSession");
if (message == NULL) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Unable to send EndSession message");
goto out;
}
if (!dbus_message_set_destination (message, dbus_client->priv->bus_name)) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Unable to send EndSession message");
goto out;
}
@@ -520,39 +558,65 @@
dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &flags);
if (!dbus_connection_send (dbus_client->priv->connection, message, NULL)) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Unable to send EndSession message");
goto out;
}
+
+ ret = TRUE;
+
out:
if (message != NULL) {
dbus_message_unref (message);
}
+ return ret;
}
-static void
-dbus_client_cancel_end_session (GsmClient *client)
+static gboolean
+dbus_client_cancel_end_session (GsmClient *client,
+ GError **error)
{
GsmDBusClient *dbus_client = (GsmDBusClient *) client;
DBusMessage *message;
+ gboolean ret;
/* unicast the signal to only the registered bus name */
message = dbus_message_new_signal (gsm_client_peek_id (client),
SM_DBUS_CLIENT_PRIVATE_INTERFACE,
"CancelEndSession");
if (message == NULL) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Unable to send CancelEndSession message");
goto out;
}
if (!dbus_message_set_destination (message, dbus_client->priv->bus_name)) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Unable to send CancelEndSession message");
goto out;
}
if (!dbus_connection_send (dbus_client->priv->connection, message, NULL)) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Unable to send CancelEndSession message");
goto out;
}
+ ret = TRUE;
+
out:
if (message != NULL) {
dbus_message_unref (message);
}
+
+ return ret;
}
static void
Modified: trunk/gnome-session/gsm-manager.c
==============================================================================
--- trunk/gnome-session/gsm-manager.c (original)
+++ trunk/gnome-session/gsm-manager.c Wed Aug 13 19:12:07 2008
@@ -500,11 +500,20 @@
GsmClient *client,
ClientEndSessionData *data)
{
- 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);
+ gboolean ret;
+ GError *error;
- gsm_client_end_session (client, data->flags);
+ error = NULL;
+ ret = gsm_client_end_session (client, data->flags, &error);
+ if (! ret) {
+ g_warning ("Unable to query client: %s", error->message);
+ g_error_free (error);
+ /* 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);
+ }
return FALSE;
}
@@ -544,10 +553,20 @@
GsmClient *client,
ClientEndSessionData *data)
{
- 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);
- gsm_client_query_end_session (client, data->flags);
+ gboolean ret;
+ GError *error;
+
+ error = NULL;
+ ret = gsm_client_query_end_session (client, data->flags, &error);
+ if (! ret) {
+ g_warning ("Unable to query client: %s", error->message);
+ g_error_free (error);
+ /* 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);
+ }
return FALSE;
}
@@ -590,7 +609,15 @@
GsmClient *client,
GsmManager *manager)
{
- gsm_client_cancel_end_session (client);
+ gboolean res;
+ GError *error;
+
+ error = NULL;
+ res = gsm_client_cancel_end_session (client, &error);
+ if (! res) {
+ g_warning ("Unable to cancel end session: %s", error->message);
+ g_error_free (error);
+ }
return FALSE;
}
Modified: trunk/gnome-session/gsm-xsmp-client.c
==============================================================================
--- trunk/gnome-session/gsm-xsmp-client.c (original)
+++ trunk/gnome-session/gsm-xsmp-client.c Wed Aug 13 19:12:07 2008
@@ -85,6 +85,7 @@
case IceProcessMessagesIOError:
g_debug ("GsmXSMPClient: IceProcessMessagesIOError on '%s'", client->priv->description);
+ gsm_client_set_status (GSM_CLIENT (client), GSM_CLIENT_FAILED);
gsm_client_disconnected (GSM_CLIENT (client));
return FALSE;
@@ -108,6 +109,7 @@
client->priv->description,
IceConnectionStatus (client->priv->ice_connection));
+ gsm_client_set_status (GSM_CLIENT (client), GSM_CLIENT_FAILED);
gsm_client_disconnected (GSM_CLIENT (client));
return FALSE;
@@ -408,6 +410,8 @@
int save_type,
gboolean forceful)
{
+ g_assert (client->priv->conn != NULL);
+
if (client->priv->next_save_yourself != -1) {
/* Either we're currently doing a shutdown and there's a checkpoint
* queued after it, or vice versa. Either way, the new SaveYourself
@@ -472,14 +476,24 @@
SmsInteract (xsmp->priv->conn);
}
-static void
-xsmp_cancel_end_session (GsmClient *client)
+static gboolean
+xsmp_cancel_end_session (GsmClient *client,
+ GError **error)
{
GsmXSMPClient *xsmp = (GsmXSMPClient *) client;
g_debug ("GsmXSMPClient: xsmp_cancel_end_session ('%s')", xsmp->priv->description);
+ if (xsmp->priv->conn == NULL) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Client is not registered");
+ return FALSE;
+ }
+
SmsShutdownCancelled (xsmp->priv->conn);
+ return TRUE;
}
static gboolean
@@ -495,24 +509,44 @@
return TRUE;
}
-static void
+static gboolean
xsmp_query_end_session (GsmClient *client,
- guint flags)
+ guint flags,
+ GError **error)
{
gboolean forceful;
+ if (GSM_XSMP_CLIENT (client)->priv->conn == NULL) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Client is not registered");
+ return FALSE;
+ }
+
forceful = (flags & GSM_CLIENT_END_SESSION_FLAG_FORCEFUL);
do_save_yourself (GSM_XSMP_CLIENT (client), SmSaveGlobal, forceful);
+ return TRUE;
}
-static void
+static gboolean
xsmp_end_session (GsmClient *client,
- guint flags)
+ guint flags,
+ GError **error)
{
gboolean forceful;
+ if (GSM_XSMP_CLIENT (client)->priv->conn == NULL) {
+ g_set_error (error,
+ GSM_CLIENT_ERROR,
+ GSM_CLIENT_ERROR_NOT_REGISTERED,
+ "Client is not registered");
+ return FALSE;
+ }
+
forceful = (flags & GSM_CLIENT_END_SESSION_FLAG_FORCEFUL);
do_save_yourself (GSM_XSMP_CLIENT (client), SmSaveGlobal, forceful);
+ return TRUE;
}
static char *
@@ -575,12 +609,8 @@
}
static void
-gsm_xsmp_client_finalize (GObject *object)
+gsm_xsmp_client_disconnect (GsmXSMPClient *client)
{
- GsmXSMPClient *client = (GsmXSMPClient *) object;
-
- g_debug ("GsmXSMPClient: xsmp_finalize (%s)", client->priv->description);
-
if (client->priv->watch_id > 0) {
g_source_remove (client->priv->watch_id);
}
@@ -594,6 +624,15 @@
if (client->priv->protocol_timeout > 0) {
g_source_remove (client->priv->protocol_timeout);
}
+}
+
+static void
+gsm_xsmp_client_finalize (GObject *object)
+{
+ GsmXSMPClient *client = (GsmXSMPClient *) object;
+
+ g_debug ("GsmXSMPClient: xsmp_finalize (%s)", client->priv->description);
+ gsm_xsmp_client_disconnect (client);
g_free (client->priv->description);
@@ -902,6 +941,8 @@
int dialog_type)
{
GsmXSMPClient *client = manager_data;
+ gboolean res;
+ GError *error;
g_debug ("GsmXSMPClient: Client '%s' received InteractRequest(%s)",
client->priv->description,
@@ -917,7 +958,11 @@
This grabbing is clearly bullshit and is not supported by
the client spec or protocol spec.
*/
- xsmp_cancel_end_session (GSM_CLIENT (client));
+ res = xsmp_cancel_end_session (GSM_CLIENT (client), &error);
+ if (! res) {
+ g_warning ("Unable to cancel end session: %s", error->message);
+ g_error_free (error);
+ }
}
static void
@@ -987,6 +1032,7 @@
}
SmFreeReasons (count, reason_msgs);
+ gsm_client_set_status (GSM_CLIENT (client), GSM_CLIENT_FINISHED);
gsm_client_disconnected (GSM_CLIENT (client));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]