[gnome-screensaver] Don't user name owner proxies for SessionManager
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-screensaver] Don't user name owner proxies for SessionManager
- Date: Mon, 21 Jun 2010 19:37:35 +0000 (UTC)
commit d0b09165b8fb4af6a59308665f38438aa657aae2
Author: Ross Burton <ross linux intel com>
Date: Fri Feb 26 18:15:39 2010 +0000
Don't user name owner proxies for SessionManager
Using proxies based on the name owner will fail if the name owner changes, for
example if gnome-session is started after the screensaver or if gnome-session is
restarted.
https://bugzilla.gnome.org/show_bug.cgi?id=611207
src/gs-watcher-x11.c | 164 ++++++++++++++++++++++----------------------------
1 files changed, 73 insertions(+), 91 deletions(-)
---
diff --git a/src/gs-watcher-x11.c b/src/gs-watcher-x11.c
index 7145448..ec63552 100644
--- a/src/gs-watcher-x11.c
+++ b/src/gs-watcher-x11.c
@@ -388,112 +388,94 @@ on_presence_status_text_changed (DBusGProxy *presence_proxy,
set_status_text (watcher, status_text);
}
-static gboolean
+static void
connect_presence_watcher (GSWatcher *watcher)
{
- DBusGConnection *bus;
- GError *error;
- gboolean ret;
-
- ret = FALSE;
+ DBusGConnection *bus;
+ GError *error;
+ DBusGProxy *proxy;
+ guint status;
+ const char *status_text;
+ GValue value = { 0, };
error = NULL;
bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (bus == NULL) {
g_warning ("Unable to get session bus: %s", error->message);
g_error_free (error);
- goto done;
+ return;
}
+ watcher->priv->presence_proxy = dbus_g_proxy_new_for_name (bus,
+ "org.gnome.SessionManager",
+ "/org/gnome/SessionManager/Presence",
+ "org.gnome.SessionManager.Presence");
+
+ dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
+ "StatusChanged",
+ G_TYPE_UINT,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
+ "StatusChanged",
+ G_CALLBACK (on_presence_status_changed),
+ watcher,
+ NULL);
+ dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
+ "StatusTextChanged",
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
+ "StatusTextChanged",
+ G_CALLBACK (on_presence_status_text_changed),
+ watcher,
+ NULL);
+
+ proxy = dbus_g_proxy_new_from_proxy (watcher->priv->presence_proxy,
+ "org.freedesktop.DBus.Properties",
+ "/org/gnome/SessionManager/Presence");
+
+ status = 0;
+ status_text = NULL;
+
error = NULL;
- watcher->priv->presence_proxy = dbus_g_proxy_new_for_name_owner (bus,
- "org.gnome.SessionManager",
- "/org/gnome/SessionManager/Presence",
- "org.gnome.SessionManager.Presence",
- &error);
- if (watcher->priv->presence_proxy != NULL) {
- DBusGProxy *proxy;
-
- dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
- "StatusChanged",
- G_TYPE_UINT,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
- "StatusChanged",
- G_CALLBACK (on_presence_status_changed),
- watcher,
- NULL);
- dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
- "StatusTextChanged",
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
- "StatusTextChanged",
- G_CALLBACK (on_presence_status_text_changed),
- watcher,
- NULL);
-
- proxy = dbus_g_proxy_new_from_proxy (watcher->priv->presence_proxy,
- "org.freedesktop.DBus.Properties",
- "/org/gnome/SessionManager/Presence");
- if (proxy != NULL) {
- guint status;
- const char *status_text;
- GValue value = { 0, };
-
- status = 0;
- status_text = NULL;
-
- error = NULL;
- dbus_g_proxy_call (proxy,
- "Get",
- &error,
- G_TYPE_STRING, "org.gnome.SessionManager.Presence",
- G_TYPE_STRING, "status",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID);
-
- if (error != NULL) {
- g_warning ("Couldn't get presence status: %s", error->message);
- g_error_free (error);
- goto done;
- } else {
- status = g_value_get_uint (&value);
- }
-
- g_value_unset (&value);
-
- error = NULL;
- dbus_g_proxy_call (proxy,
- "Get",
- &error,
- G_TYPE_STRING, "org.gnome.SessionManager.Presence",
- G_TYPE_STRING, "status-text",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID);
-
- if (error != NULL) {
- g_warning ("Couldn't get presence status text: %s", error->message);
- g_error_free (error);
- } else {
- status_text = g_value_get_string (&value);
- }
-
- set_status (watcher, status);
- set_status_text (watcher, status_text);
- }
- } else {
- g_warning ("Failed to get session presence proxy: %s", error->message);
+ dbus_g_proxy_call (proxy,
+ "Get",
+ &error,
+ G_TYPE_STRING, "org.gnome.SessionManager.Presence",
+ G_TYPE_STRING, "status",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE, &value,
+ G_TYPE_INVALID);
+
+ if (error != NULL) {
+ g_warning ("Couldn't get presence status: %s", error->message);
g_error_free (error);
- goto done;
+ return;
+ } else {
+ status = g_value_get_uint (&value);
}
- ret = TRUE;
+ g_value_unset (&value);
+
+ error = NULL;
+ dbus_g_proxy_call (proxy,
+ "Get",
+ &error,
+ G_TYPE_STRING, "org.gnome.SessionManager.Presence",
+ G_TYPE_STRING, "status-text",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE, &value,
+ G_TYPE_INVALID);
+
+ if (error != NULL) {
+ g_warning ("Couldn't get presence status text: %s", error->message);
+ g_error_free (error);
+ } else {
+ status_text = g_value_get_string (&value);
+ }
- done:
- return ret;
+ set_status (watcher, status);
+ set_status_text (watcher, status_text);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]