aboutsummaryrefslogtreecommitdiff
path: root/src/backend-dbus/actions.c
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2014-04-10 03:52:50 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2014-04-10 03:52:50 +0200
commita302870b4955b0f20573fc4ddb12f4fa3aded911 (patch)
tree7186fbab94457ece04d9aaaa2d81de3440824d34 /src/backend-dbus/actions.c
parentf8373fd85b5969a83aaf7de2580cb8872dc68615 (diff)
downloadayatana-indicator-session-a302870b4955b0f20573fc4ddb12f4fa3aded911.tar.gz
ayatana-indicator-session-a302870b4955b0f20573fc4ddb12f4fa3aded911.tar.bz2
ayatana-indicator-session-a302870b4955b0f20573fc4ddb12f4fa3aded911.zip
Actions: add Unity session proxy, and use to lock the screen if available
Diffstat (limited to 'src/backend-dbus/actions.c')
-rw-r--r--src/backend-dbus/actions.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c
index b1fa8ac..d99f81f 100644
--- a/src/backend-dbus/actions.c
+++ b/src/backend-dbus/actions.c
@@ -25,6 +25,7 @@
#include "dbus-webcredentials.h"
#include "gnome-screen-saver.h"
#include "gnome-session-manager.h"
+#include "unity-session.h"
#include "actions.h"
@@ -43,6 +44,7 @@ struct _IndicatorSessionActionsDbusPriv
GSettings * indicator_settings;
GnomeScreenSaver * screen_saver;
GnomeSessionManager * session_manager;
+ UnitySession * unity_session;
Login1Manager * login1_manager;
GCancellable * login1_manager_cancellable;
Login1Seat * login1_seat;
@@ -197,6 +199,23 @@ on_screensaver_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpoin
}
static void
+on_unity_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer gself)
+{
+ GError * err;
+ UnitySession * us;
+
+ err = NULL;
+ us = unity_session_proxy_new_for_bus_finish (res, &err);
+ if (err == NULL)
+ {
+ INDICATOR_SESSION_ACTIONS_DBUS(gself)->priv->unity_session = us;
+
+ }
+
+ log_and_clear_error (&err, G_STRLOC, G_STRFUNC);
+}
+
+static void
on_can_suspend_ready (GObject * o, GAsyncResult * res, gpointer gself)
{
char * str;
@@ -759,9 +778,30 @@ my_about (IndicatorSessionActions * self G_GNUC_UNUSED)
***/
static void
-lock_current_session (IndicatorSessionActions * self)
+lock_current_session (IndicatorSessionActions * self, gboolean immediate)
{
priv_t * p = INDICATOR_SESSION_ACTIONS_DBUS(self)->priv;
+ gchar * name_owner;
+
+ if (G_IS_DBUS_PROXY (p->unity_session))
+ {
+ name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (p->unity_session));
+
+ if (name_owner)
+ {
+ if (immediate)
+ {
+ unity_session_call_prompt_lock (p->unity_session, p->cancellable, NULL, NULL);
+ }
+ else
+ {
+ unity_session_call_lock (p->unity_session, p->cancellable, NULL, NULL);
+ }
+
+ g_free (name_owner);
+ return;
+ }
+ }
g_return_if_fail (p->screen_saver != NULL);
@@ -771,7 +811,7 @@ lock_current_session (IndicatorSessionActions * self)
static void
my_switch_to_screensaver (IndicatorSessionActions * self)
{
- lock_current_session (self);
+ lock_current_session (self, FALSE);
}
static void
@@ -793,7 +833,7 @@ my_switch_to_guest (IndicatorSessionActions * self)
g_return_if_fail (p->dm_seat != NULL);
- lock_current_session (self);
+ lock_current_session (self, TRUE);
display_manager_seat_call_switch_to_guest (p->dm_seat, "",
p->dm_seat_cancellable,
@@ -850,6 +890,7 @@ my_dispose (GObject * o)
g_clear_object (&p->screen_saver);
g_clear_object (&p->session_manager);
+ g_clear_object (&p->unity_session);
set_dm_seat (self, NULL);
set_login1_manager (self, NULL);
set_login1_seat (self, NULL);
@@ -952,6 +993,14 @@ indicator_session_actions_dbus_init (IndicatorSessionActionsDbus * self)
on_screensaver_proxy_ready,
self);
+ unity_session_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ "com.canonical.Unity",
+ "/com/canonical/Unity/Session",
+ p->cancellable,
+ on_unity_proxy_ready,
+ self);
+
gnome_session_manager_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
"org.gnome.SessionManager",