diff options
author | Marco Trevisan (TreviƱo) <mail@3v1n0.net> | 2014-04-10 17:39:10 +0000 |
---|---|---|
committer | CI bot <ps-jenkins@lists.canonical.com> | 2014-04-10 17:39:10 +0000 |
commit | 36fe650a80739727b9fe10a59196d504c1b8aecd (patch) | |
tree | ed4d9ca250824e0955342d291626f575f2369c64 /src | |
parent | 74352b31c0addac59c36e767096d0ddddf9eee93 (diff) | |
parent | e4b9f042a74b471f0b5992b99701231c3052e3ef (diff) | |
download | ayatana-indicator-session-36fe650a80739727b9fe10a59196d504c1b8aecd.tar.gz ayatana-indicator-session-36fe650a80739727b9fe10a59196d504c1b8aecd.tar.bz2 ayatana-indicator-session-36fe650a80739727b9fe10a59196d504c1b8aecd.zip |
DBusActions: use unity session APIs when unity is running
Use Immediate lock when switching, and rely to standard lock (with fade) in normal cases. Fixes: 1305194
Diffstat (limited to 'src')
-rw-r--r-- | src/backend-dbus/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/backend-dbus/actions.c | 75 | ||||
-rw-r--r-- | src/backend-dbus/com.canonical.Unity.Session.xml | 12 |
3 files changed, 87 insertions, 6 deletions
diff --git a/src/backend-dbus/CMakeLists.txt b/src/backend-dbus/CMakeLists.txt index fa41534..1fb9d7c 100644 --- a/src/backend-dbus/CMakeLists.txt +++ b/src/backend-dbus/CMakeLists.txt @@ -14,7 +14,7 @@ add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-webcredentials add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-accounts org.freedesktop ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.Accounts.xml) - + add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-user org.freedesktop ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.Accounts.User.xml) @@ -43,6 +43,10 @@ add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-end-session-dialog org.gnome.SessionManager ${CMAKE_CURRENT_SOURCE_DIR}/org.gnome.SessionManager.EndSessionDialog.xml) +add_gdbus_codegen (BACKEND_GENERATED_SOURCES unity-session + com.canonical + ${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.Unity.Session.xml) + set (SOURCES actions.c guest.c users.c backend-dbus.c utils.c) # add warnings/coverage info on handwritten files diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c index b1fa8ac..cac7c40 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,22 @@ 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; @@ -758,20 +776,54 @@ my_about (IndicatorSessionActions * self G_GNUC_UNUSED) **** ***/ +static gboolean +have_unity_session (IndicatorSessionActions * self) +{ + 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) + { + g_free (name_owner); + return TRUE; + } + } + + return FALSE; +} + static void -lock_current_session (IndicatorSessionActions * self) +lock_current_session (IndicatorSessionActions * self, gboolean immediate) { priv_t * p = INDICATOR_SESSION_ACTIONS_DBUS(self)->priv; - g_return_if_fail (p->screen_saver != NULL); + if (have_unity_session (self)) + { + 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); + } + } + else + { + g_return_if_fail (p->screen_saver != NULL); - gnome_screen_saver_call_lock (p->screen_saver, p->cancellable, NULL, NULL); + gnome_screen_saver_call_lock (p->screen_saver, p->cancellable, NULL, NULL); + } } static void my_switch_to_screensaver (IndicatorSessionActions * self) { - lock_current_session (self); + lock_current_session (self, FALSE); } static void @@ -781,6 +833,8 @@ my_switch_to_greeter (IndicatorSessionActions * self) g_return_if_fail (p->dm_seat != NULL); + lock_current_session (self, TRUE); + display_manager_seat_call_switch_to_greeter (p->dm_seat, p->dm_seat_cancellable, NULL, NULL); @@ -793,7 +847,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, @@ -807,6 +861,8 @@ my_switch_to_username (IndicatorSessionActions * self, const char * username) g_return_if_fail (p->dm_seat != NULL); + lock_current_session (self, TRUE); + display_manager_seat_call_switch_to_user (p->dm_seat, username, "", p->dm_seat_cancellable, NULL, NULL); @@ -850,6 +906,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 +1009,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", diff --git a/src/backend-dbus/com.canonical.Unity.Session.xml b/src/backend-dbus/com.canonical.Unity.Session.xml new file mode 100644 index 0000000..1dce43e --- /dev/null +++ b/src/backend-dbus/com.canonical.Unity.Session.xml @@ -0,0 +1,12 @@ +<!DOCTYPE node PUBLIC +"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" +"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> + <interface name="com.canonical.Unity.Session"> + <method name="Lock" /> + <method name="PromptLock" /> + <method name="RequestLogout" /> + <method name="RequestReboot" /> + <method name="RequestShutdown" /> + </interface> +</node> |