aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-15 17:15:16 -0500
committerTed Gould <ted@gould.cx>2010-03-15 17:15:16 -0500
commit28ef20a9ad4b4b5e931b6eb4833accf44c65951f (patch)
tree53bd41e6d5189d769b6e82deabb00b2e3d137f3c /src
parent05cd0a2405c81a1147ae519b9fa89e0579284abe (diff)
downloadayatana-indicator-session-28ef20a9ad4b4b5e931b6eb4833accf44c65951f.tar.gz
ayatana-indicator-session-28ef20a9ad4b4b5e931b6eb4833accf44c65951f.tar.bz2
ayatana-indicator-session-28ef20a9ad4b4b5e931b6eb4833accf44c65951f.zip
Use the upower allowed interface to check to see if PK is blocking suspend and hibernate
Diffstat (limited to 'src')
-rw-r--r--src/session-service.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/session-service.c b/src/session-service.c
index a915884..9dd50bf 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -47,6 +47,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "session-dbus.h"
#include "users-service-dbus.h"
#include "lock-helper.h"
+#include "upower-client.h"
#define UP_ADDRESS "org.freedesktop.UPower"
#define UP_OBJECT "/org/freedesktop/UPower"
@@ -254,6 +255,20 @@ up_changed_cb (DBusGProxy * proxy, gpointer user_data)
return;
}
+/* Handle the callback from the allow functions to check and
+ see if we're changing the value, and if so, rebuilding the
+ menus based on that info. */
+static void
+allowed_cb (DBusGProxy *proxy, gboolean OUT_allowed, GError *error, gpointer userdata)
+{
+ gboolean * can_do = (gboolean *)userdata;
+
+ if (OUT_allowed != *can_do) {
+ *can_do = OUT_allowed;
+ rebuild_items (root_menuitem, dbus_interface);
+ }
+}
+
/* 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 */
@@ -292,6 +307,14 @@ setup_up (void) {
/* Force an original "changed" event */
up_changed_cb(up_main_proxy, NULL);
+ /* Check to see if these are getting blocked by PolicyKit */
+ org_freedesktop_UPower_suspend_allowed_async(up_main_proxy,
+ allowed_cb,
+ &allow_suspend);
+ org_freedesktop_UPower_hibernate_allowed_async(up_main_proxy,
+ allowed_cb,
+ &allow_hibernate);
+
return;
}