gnome-session r4894 - in branches/dbus_based: . gnome-session
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4894 - in branches/dbus_based: . gnome-session
- Date: Wed, 30 Jul 2008 17:15:32 +0000 (UTC)
Author: mccann
Date: Wed Jul 30 17:15:32 2008
New Revision: 4894
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4894&view=rev
Log:
2008-07-30 William Jon McCann <jmccann redhat com>
* gnome-session/gsm-client.c (gsm_client_set_startup_id),
(gsm_client_set_app_id), (gsm_client_class_init):
* gnome-session/gsm-dbus-client.c (handle_end_session_response):
* gnome-session/gsm-inhibit-dialog.c (add_inhibitor),
(on_store_inhibitor_added):
* gnome-session/gsm-inhibitor.c (gsm_inhibitor_set_bus_name),
(gsm_inhibitor_set_client_id), (gsm_inhibitor_set_reason),
(gsm_inhibitor_get_app_id), (gsm_inhibitor_get_client_id),
(gsm_inhibitor_get_reason), (gsm_inhibitor_class_init):
* gnome-session/gsm-manager.c (_find_by_startup_id),
(_on_query_end_session_timeout), (_disconnect_client),
(_disconnect_dbus_client), (inhibitor_has_bus_name),
(_app_has_startup_id), (_client_has_startup_id),
(on_xsmp_client_register_request), (inhibitor_has_client_id),
(on_client_end_session_response), (append_app),
(append_default_apps), (gsm_manager_register_client),
(gsm_manager_inhibit):
* gnome-session/gsm-xsmp-client.c (register_client_callback):
DBus forces us to not use NULL strings for properties. Would
be nice if the bindings took care of this for us by converting
NULL strings into some "unset" value.
Modified:
branches/dbus_based/ChangeLog
branches/dbus_based/gnome-session/gsm-client.c
branches/dbus_based/gnome-session/gsm-dbus-client.c
branches/dbus_based/gnome-session/gsm-inhibit-dialog.c
branches/dbus_based/gnome-session/gsm-inhibitor.c
branches/dbus_based/gnome-session/gsm-manager.c
branches/dbus_based/gnome-session/gsm-xsmp-client.c
Modified: branches/dbus_based/gnome-session/gsm-client.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-client.c (original)
+++ branches/dbus_based/gnome-session/gsm-client.c Wed Jul 30 17:15:32 2008
@@ -157,7 +157,11 @@
g_free (client->priv->startup_id);
- client->priv->startup_id = g_strdup (startup_id);
+ if (startup_id != NULL) {
+ client->priv->startup_id = g_strdup (startup_id);
+ } else {
+ client->priv->startup_id = g_strdup ("");
+ }
g_object_notify (G_OBJECT (client), "startup-id");
}
@@ -169,7 +173,11 @@
g_free (client->priv->app_id);
- client->priv->app_id = g_strdup (app_id);
+ if (app_id != NULL) {
+ client->priv->app_id = g_strdup (app_id);
+ } else {
+ client->priv->app_id = g_strdup ("");
+ }
g_object_notify (G_OBJECT (client), "app-id");
}
@@ -288,14 +296,14 @@
g_param_spec_string ("startup-id",
"startup-id",
"startup-id",
- NULL,
+ "",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_APP_ID,
g_param_spec_string ("app-id",
"app-id",
"app-id",
- NULL,
+ "",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_STATUS,
Modified: branches/dbus_based/gnome-session/gsm-dbus-client.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-dbus-client.c (original)
+++ branches/dbus_based/gnome-session/gsm-dbus-client.c Wed Jul 30 17:15:32 2008
@@ -42,6 +42,9 @@
#define GSM_DBUS_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_DBUS_CLIENT, GsmDBusClientPrivate))
+#define IS_STRING_EMPTY(x) ((x)==NULL||(x)[0]=='\0')
+
+
#define SM_DBUS_NAME "org.gnome.SessionManager"
#define SM_DBUS_CLIENT_PRIVATE_INTERFACE "org.gnome.SessionManager.ClientPrivate"
@@ -174,7 +177,7 @@
/* make sure it is from our client */
sender = dbus_message_get_sender (message);
if (sender == NULL
- || client->priv->bus_name == NULL
+ || IS_STRING_EMPTY (client->priv->bus_name)
|| strcmp (sender, client->priv->bus_name) != 0) {
raise_error (client->priv->connection,
Modified: branches/dbus_based/gnome-session/gsm-inhibit-dialog.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-inhibit-dialog.c (original)
+++ branches/dbus_based/gnome-session/gsm-inhibit-dialog.c Wed Jul 30 17:15:32 2008
@@ -46,6 +46,8 @@
#define GSM_INHIBIT_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_INHIBIT_DIALOG, GsmInhibitDialogPrivate))
+#define IS_STRING_EMPTY(x) ((x)==NULL||(x)[0]=='\0')
+
#define GLADE_XML_FILE "gsm-inhibit-dialog.glade"
#ifndef DEFAULT_ICON_SIZE
@@ -494,7 +496,7 @@
pixbuf = NULL;
app_id = gsm_inhibitor_peek_app_id (inhibitor);
- if (app_id == NULL || app_id[0] == '\0') {
+ if (IS_STRING_EMPTY (app_id)) {
desktop_filename = NULL;
} else if (! g_str_has_suffix (app_id, ".desktop")) {
desktop_filename = g_strdup_printf ("%s.desktop", app_id);
@@ -552,7 +554,7 @@
}
if (name == NULL) {
- if (app_id != NULL) {
+ if (! IS_STRING_EMPTY (app_id)) {
name = app_id;
} else {
name = _("Unknown");
@@ -638,7 +640,7 @@
return;
}
- inhibitor = gsm_store_lookup (store, id);
+ inhibitor = (GsmInhibitor *)gsm_store_lookup (store, id);
/* Add to model */
if (! find_inhibitor (dialog, id, &iter)) {
Modified: branches/dbus_based/gnome-session/gsm-inhibitor.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-inhibitor.c (original)
+++ branches/dbus_based/gnome-session/gsm-inhibitor.c Wed Jul 30 17:15:32 2008
@@ -131,7 +131,11 @@
g_free (inhibitor->priv->bus_name);
- inhibitor->priv->bus_name = g_strdup (bus_name);
+ if (bus_name != NULL) {
+ inhibitor->priv->bus_name = g_strdup (bus_name);
+ } else {
+ inhibitor->priv->bus_name = g_strdup ("");
+ }
g_object_notify (G_OBJECT (inhibitor), "bus-name");
}
@@ -155,7 +159,11 @@
g_free (inhibitor->priv->client_id);
- inhibitor->priv->client_id = g_strdup (client_id);
+ if (client_id != NULL) {
+ inhibitor->priv->client_id = g_strdup (client_id);
+ } else {
+ inhibitor->priv->client_id = g_strdup ("");
+ }
g_object_notify (G_OBJECT (inhibitor), "client-id");
}
@@ -167,7 +175,11 @@
g_free (inhibitor->priv->reason);
- inhibitor->priv->reason = g_strdup (reason);
+ if (reason != NULL) {
+ inhibitor->priv->reason = g_strdup (reason);
+ } else {
+ inhibitor->priv->reason = g_strdup ("");
+ }
g_object_notify (G_OBJECT (inhibitor), "reason");
}
@@ -222,7 +234,11 @@
{
g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE);
- *id = g_strdup (inhibitor->priv->app_id);
+ if (inhibitor->priv->app_id != NULL) {
+ *id = g_strdup (inhibitor->priv->app_id);
+ } else {
+ *id = g_strdup ("");
+ }
return TRUE;
}
@@ -234,7 +250,11 @@
{
g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE);
- *id = g_strdup (inhibitor->priv->client_id);
+ if (inhibitor->priv->client_id != NULL) {
+ *id = g_strdup (inhibitor->priv->client_id);
+ } else {
+ *id = g_strdup ("");
+ }
return TRUE;
}
@@ -246,7 +266,11 @@
{
g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE);
- *reason = g_strdup (inhibitor->priv->reason);
+ if (inhibitor->priv->reason != NULL) {
+ *reason = g_strdup (inhibitor->priv->reason);
+ } else {
+ *reason = g_strdup ("");
+ }
return TRUE;
}
@@ -436,28 +460,28 @@
g_param_spec_string ("bus-name",
"bus-name",
"bus-name",
- NULL,
+ "",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_APP_ID,
g_param_spec_string ("app-id",
"app-id",
"app-id",
- NULL,
+ "",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_CLIENT_ID,
g_param_spec_string ("client-id",
"client-id",
"client-id",
- NULL,
+ "",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_REASON,
g_param_spec_string ("reason",
"reason",
"reason",
- NULL,
+ "",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_FLAGS,
@@ -487,7 +511,7 @@
0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- dbus_g_object_type_install_info (GSM_TYPE_INHIBITOR, &dbus_glib_gsm_inhibitor_object_info);
+ dbus_g_object_type_install_info (GSM_TYPE_INHIBITOR, &dbus_glib_gsm_inhibitor_object_info);
g_type_class_add_private (klass, sizeof (GsmInhibitorPrivate));
}
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 Wed Jul 30 17:15:32 2008
@@ -73,6 +73,8 @@
#define GDM_FLEXISERVER_COMMAND "gdmflexiserver"
#define GDM_FLEXISERVER_ARGS "--startnew Standard"
+#define IS_STRING_EMPTY(x) ((x)==NULL||(x)[0]=='\0')
+
struct GsmManagerPrivate
{
gboolean failsafe;
@@ -221,7 +223,7 @@
const char *startup_id_b;
startup_id_b = gsm_client_peek_startup_id (client);
- if (startup_id_b == NULL) {
+ if (IS_STRING_EMPTY (startup_id_b)) {
return FALSE;
}
@@ -855,7 +857,7 @@
}
app_id = g_strdup (gsm_client_peek_app_id (l->data));
- if (app_id == NULL || app_id[0] == '\0') {
+ if (IS_STRING_EMPTY (app_id)) {
/* XSMP clients don't give us an app id unless we start them */
app_id = gsm_client_get_app_name (l->data);
}
@@ -1006,7 +1008,7 @@
}
app_id = gsm_client_peek_app_id (client);
- if (app_id == NULL) {
+ if (IS_STRING_EMPTY (app_id)) {
g_debug ("GsmManager: no application associated with client, not restarting application");
goto out;
}
@@ -1068,7 +1070,7 @@
}
name = gsm_dbus_client_get_bus_name (GSM_DBUS_CLIENT (client));
- if (name == NULL) {
+ if (IS_STRING_EMPTY (name)) {
return FALSE;
}
@@ -1112,7 +1114,7 @@
bus_name_b = gsm_inhibitor_peek_bus_name (inhibitor);
matches = FALSE;
- if (data->service_name != NULL && bus_name_b != NULL) {
+ if (! IS_STRING_EMPTY (data->service_name) && ! IS_STRING_EMPTY (bus_name_b)) {
matches = (strcmp (data->service_name, bus_name_b) == 0);
if (matches) {
g_debug ("GsmManager: removing inhibitor from %s for reason '%s' on connection %s",
@@ -1151,7 +1153,7 @@
startup_id_b = gsm_app_get_startup_id (app);
- if (startup_id_b == NULL) {
+ if (IS_STRING_EMPTY (startup_id_b)) {
return FALSE;
}
@@ -1269,7 +1271,7 @@
startup_id_b = gsm_client_peek_startup_id (client);
- if (startup_id_b == NULL) {
+ if (IS_STRING_EMPTY (startup_id_b)) {
return FALSE;
}
@@ -1306,7 +1308,7 @@
goto out;
}
- if (*id == NULL) {
+ if (IS_STRING_EMPTY (*id)) {
new_id = gsm_util_generate_startup_id ();
} else {
GsmClient *client;
@@ -1330,7 +1332,7 @@
manager);
/* If it's a brand new client id, we just accept the client*/
- if (*id == NULL) {
+ if (IS_STRING_EMPTY (*id)) {
goto out;
}
@@ -1363,7 +1365,7 @@
client_id_b = gsm_inhibitor_peek_client_id (inhibitor);
matches = FALSE;
- if (client_id_a != NULL && client_id_b != NULL) {
+ if (! IS_STRING_EMPTY (client_id_a) && ! IS_STRING_EMPTY (client_id_b)) {
matches = (strcmp (client_id_a, client_id_b) == 0);
if (matches) {
g_debug ("GsmManager: removing JIT inhibitor for %s for reason '%s'",
@@ -1406,7 +1408,7 @@
}
app_id = g_strdup (gsm_client_peek_app_id (client));
- if (app_id == NULL || app_id[0] == '\0') {
+ if (IS_STRING_EMPTY (app_id)) {
/* XSMP clients don't give us an app id unless we start them */
app_id = gsm_client_get_app_name (client);
}
@@ -1568,7 +1570,7 @@
GsmApp *dup;
id = gsm_app_get_id (app);
- if (id == NULL) {
+ if (IS_STRING_EMPTY (id)) {
g_debug ("GsmManager: not adding app: no ID");
return;
}
@@ -1609,7 +1611,7 @@
key_file = g_key_file_new ();
- if (a->data == NULL) {
+ if (IS_STRING_EMPTY ((char *)a->data)) {
continue;
}
@@ -2476,6 +2478,9 @@
g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+ app = NULL;
+ client = NULL;
+
g_debug ("GsmManager: RegisterClient %s", startup_id);
if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) {
@@ -2491,8 +2496,7 @@
return FALSE;
}
- if (startup_id == NULL
- || startup_id[0] == '\0') {
+ if (IS_STRING_EMPTY (startup_id)) {
new_startup_id = gsm_util_generate_startup_id ();
} else {
@@ -2518,15 +2522,13 @@
g_debug ("GsmManager: Adding new client %s to session", new_startup_id);
- if ((startup_id == NULL || startup_id[0] == '\0')
- && app_id == NULL) {
+ if (IS_STRING_EMPTY (startup_id) && IS_STRING_EMPTY (app_id)) {
/* just accept the client - we can't associate with an
existing App */
app = NULL;
- } else if (startup_id != NULL
- && startup_id[0] != '\0') {
+ } else if (IS_STRING_EMPTY (startup_id)) {
app = find_app_for_startup_id (manager, startup_id);
- } else if (app_id != NULL) {
+ } else if (IS_STRING_EMPTY (startup_id)) {
/* try to associate this app id with a known app */
app = find_app_for_app_id (manager, app_id);
}
@@ -2623,7 +2625,7 @@
reason,
flags);
- if (app_id == NULL || app_id[0] == '\0') {
+ if (IS_STRING_EMPTY (app_id)) {
GError *new_error;
new_error = g_error_new (GSM_MANAGER_ERROR,
@@ -2635,7 +2637,7 @@
return FALSE;
}
- if (reason == NULL || reason[0] == '\0') {
+ if (IS_STRING_EMPTY (reason)) {
GError *new_error;
new_error = g_error_new (GSM_MANAGER_ERROR,
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 Wed Jul 30 17:15:32 2008
@@ -38,6 +38,9 @@
/* FIXME */
#define GsmDesktopFile "_Gsm_DesktopFile"
+#define IS_STRING_EMPTY(x) ((x)==NULL||(x)[0]=='\0')
+
+
#define GSM_XSMP_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_XSMP_CLIENT, GsmXSMPClientPrivate))
struct GsmXSMPClientPrivate
@@ -790,7 +793,7 @@
return FALSE;
}
- if (id == NULL) {
+ if (IS_STRING_EMPTY (id)) {
g_debug ("GsmXSMPClient: rejected: invalid previous_id");
free (previous_id);
return FALSE;
@@ -804,7 +807,7 @@
SmsRegisterClientReply (conn, id);
- if (previous_id == NULL) {
+ if (IS_STRING_EMPTY (previous_id)) {
/* Send the initial SaveYourself. */
g_debug ("GsmXSMPClient: Sending initial SaveYourself");
SmsSaveYourself (conn, SmSaveLocal, False, SmInteractStyleNone, False);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]