aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-07-24 13:52:45 -0500
committerTed Gould <ted@canonical.com>2009-07-24 13:52:45 -0500
commit7892498e5af9af135aab6268ec875384ecf47109 (patch)
treef6b2e6fa23c7639cf80a21f26f64c4e37c5d181f /src
parent73a077d2efd6a5465f3927a8b151371315faf041 (diff)
downloadayatana-indicator-session-7892498e5af9af135aab6268ec875384ecf47109.tar.gz
ayatana-indicator-session-7892498e5af9af135aab6268ec875384ecf47109.tar.bz2
ayatana-indicator-session-7892498e5af9af135aab6268ec875384ecf47109.zip
Setting up change, and issuing a response
Diffstat (limited to 'src')
-rw-r--r--src/session-service.c76
1 files changed, 72 insertions, 4 deletions
diff --git a/src/session-service.c b/src/session-service.c
index 30bb5de..50e0f13 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -18,6 +18,9 @@ static GMainLoop * mainloop = NULL;
static DBusGProxy * dkp_main_proxy = NULL;
static DBusGProxy * dkp_prop_proxy = NULL;
+static DBusGProxyCall * suspend_call = NULL;
+static DBusGProxyCall * hibernate_call = NULL;
+
/* Let's put this machine to sleep, with some info on how
it should sleep. */
static void
@@ -37,6 +40,63 @@ sleep (DbusmenuMenuitem * mi, gpointer userdata)
return;
}
+static void
+suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata)
+{
+ suspend_call = NULL;
+
+}
+
+static void
+hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata)
+{
+ hibernate_call = NULL;
+
+}
+
+/* A signal that we need to recheck to ensure we can still
+ hibernate and/or suspend */
+static void
+dpk_changed_cb (DBusGProxy * proxy, gpointer user_data)
+{
+ /* Start Async call to see if we can hibernate */
+ if (suspend_call == NULL) {
+ suspend_call = dbus_g_proxy_begin_call(dkp_prop_proxy,
+ "Get",
+ suspend_prop_cb,
+ NULL,
+ NULL,
+ G_TYPE_STRING,
+ DKP_INTERFACE,
+ G_TYPE_STRING,
+ "can-suspend",
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN,
+ G_TYPE_INVALID);
+
+ }
+
+ /* Start Async call to see if we can suspend */
+ if (hibernate_call == NULL) {
+ hibernate_call = dbus_g_proxy_begin_call(dkp_prop_proxy,
+ "Get",
+ hibernate_prop_cb,
+ NULL,
+ NULL,
+ G_TYPE_STRING,
+ DKP_INTERFACE,
+ G_TYPE_STRING,
+ "can-hibernate",
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN,
+ G_TYPE_INVALID);
+
+
+ }
+
+ return;
+}
+
/* This function goes through and sets up what we need for
DKp checking. We're even setting up the calls for the props
we need */
@@ -62,10 +122,18 @@ setup_dkp (void) {
g_return_if_fail(dkp_prop_proxy != NULL);
/* Connect to changed signal */
-
- /* Start Async call to see if we can hibernate */
-
- /* Start Async call to see if we can suspend */
+ dbus_g_proxy_add_signal(dkp_main_proxy,
+ "Changed",
+ G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal(dkp_main_proxy,
+ "Changed",
+ G_CALLBACK(dpk_changed_cb),
+ NULL,
+ NULL);
+
+ /* Force an original "changed" event */
+ dpk_changed_cb(dkp_main_proxy, NULL);
return;
}