From 7cde1532657a4f7936703002768d3fc92e21be96 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 11 Apr 2013 16:33:54 +0100 Subject: Initial port from ConsoleKit to Logind for session tracking. --- src/Makefile.am | 52 ++-- src/dialog.c | 36 +-- src/gtk-logout-helper.c | 30 +- src/org.freedesktop.ConsoleKit.Manager.xml | 353 ----------------------- src/org.freedesktop.ConsoleKit.Seat.xml | 164 ----------- src/org.freedesktop.ConsoleKit.Session.xml | 435 ----------------------------- src/org.freedesktop.login1.Manager.xml | 199 +++++++++++++ src/org.freedesktop.login1.Seat.xml | 21 ++ src/org.freedesktop.login1.Session.xml | 49 ++++ src/org.freedesktop.login1.User.xml | 56 ++++ src/session-menu-mgr.c | 4 - src/users-service-dbus.c | 354 +++++++++++------------ src/users-service-dbus.h | 5 +- 13 files changed, 563 insertions(+), 1195 deletions(-) delete mode 100644 src/org.freedesktop.ConsoleKit.Manager.xml delete mode 100644 src/org.freedesktop.ConsoleKit.Seat.xml delete mode 100644 src/org.freedesktop.ConsoleKit.Session.xml create mode 100644 src/org.freedesktop.login1.Manager.xml create mode 100644 src/org.freedesktop.login1.Seat.xml create mode 100644 src/org.freedesktop.login1.Session.xml create mode 100644 src/org.freedesktop.login1.User.xml (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index bcc8652..976783f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,34 +43,34 @@ $(dbus_display_manager_sources): display-manager.xml --generate-c-code dbus-display-manager \ $^ -dbus_consolekit_manager_sources = \ - dbus-consolekit-manager.c \ - dbus-consolekit-manager.h +dbus_login1_manager_sources = \ + dbus-login1-manager.c \ + dbus-login1-manager.h -$(dbus_consolekit_manager_sources): org.freedesktop.ConsoleKit.Manager.xml +$(dbus_login1_manager_sources): org.freedesktop.login1.Manager.xml $(AM_V_GEN) gdbus-codegen \ --interface-prefix org.freedesktop \ - --generate-c-code dbus-consolekit-manager \ + --generate-c-code dbus-login1-manager \ $^ -dbus_consolekit_seat_sources = \ - dbus-consolekit-seat.c \ - dbus-consolekit-seat.h +dbus_login1_session_sources = \ + dbus-login1-session.c \ + dbus-login1-session.h -$(dbus_consolekit_seat_sources): org.freedesktop.ConsoleKit.Seat.xml +$(dbus_login1_session_sources): org.freedesktop.login1.Session.xml $(AM_V_GEN) gdbus-codegen \ --interface-prefix org.freedesktop \ - --generate-c-code dbus-consolekit-seat \ + --generate-c-code dbus-login1-session \ $^ -dbus_consolekit_session_sources = \ - dbus-consolekit-session.c \ - dbus-consolekit-session.h +dbus_login1_user_sources = \ + dbus-login1-user.c \ + dbus-login1-user.h -$(dbus_consolekit_session_sources): org.freedesktop.ConsoleKit.Session.xml +$(dbus_login1_user_sources): org.freedesktop.login1.User.xml $(AM_V_GEN) gdbus-codegen \ --interface-prefix org.freedesktop \ - --generate-c-code dbus-consolekit-session \ + --generate-c-code dbus-login1-user \ $^ dbus_accounts_sources = \ @@ -92,7 +92,7 @@ $(dbus_user_sources): org.freedesktop.Accounts.User.xml --interface-prefix org.freedesktop \ --generate-c-code dbus-user \ $^ - + dbus_upower_sources = \ dbus-upower.c \ dbus-upower.h @@ -120,9 +120,9 @@ gen-%.xml.h: %.xml indicator_session_service_SOURCES = \ $(dbus_accounts_sources) \ - $(dbus_consolekit_manager_sources) \ - $(dbus_consolekit_seat_sources) \ - $(dbus_consolekit_session_sources) \ + $(dbus_login1_manager_sources) \ + $(dbus_login1_user_sources) \ + $(dbus_login1_session_sources) \ $(dbus_display_manager_sources) \ $(dbus_upower_sources) \ $(dbus_user_sources) \ @@ -156,7 +156,7 @@ indicator_session_service_LDFLAGS = \ if BUILD_GTKLOGOUTHELPER gtk_logout_helper_SOURCES = \ - $(dbus_consolekit_manager_sources) \ + $(dbus_login1_manager_sources) \ gtk-logout-helper.c \ dialog.c \ dialog.h @@ -185,9 +185,9 @@ endif BUILT_SOURCES = \ $(dbus_accounts_sources) \ - $(dbus_consolekit_manager_sources) \ - $(dbus_consolekit_seat_sources) \ - $(dbus_consolekit_session_sources) \ + $(dbus_login1_manager_sources) \ + $(dbus_login1_user_sources) \ + $(dbus_login1_session_sources) \ $(dbus_display_manager_sources) \ $(dbus_upower_sources) \ $(dbus_user_sources) \ @@ -198,9 +198,9 @@ EXTRA_DIST += \ display-manager.xml \ org.freedesktop.Accounts.User.xml \ org.freedesktop.Accounts.xml \ - org.freedesktop.ConsoleKit.Manager.xml \ - org.freedesktop.ConsoleKit.Seat.xml \ - org.freedesktop.ConsoleKit.Session.xml \ + org.freedesktop.login1.Manager.xml \ + org.freedesktop.login1.Session.xml \ + org.freedesktop.login1.User.xml \ session-dbus.xml \ upower.xml diff --git a/src/dialog.c b/src/dialog.c index eb91f57..f97475e 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -26,7 +26,7 @@ with this program. If not, see . #include -#include "dbus-consolekit-manager.h" +#include "dbus-login1-manager.h" #include "dialog.h" /* Strings */ @@ -133,35 +133,35 @@ check_restart_required (void) return g_file_test("/var/run/reboot-required", G_FILE_TEST_EXISTS); } -/* Checks with console kit to see if we can do what we want */ +/* Checks with logind to see if we can do what we want */ static gboolean -ck_check_allowed (LogoutDialogType type) +logind_check_allowed (LogoutDialogType type) { - gboolean allowed = TRUE; - - ConsoleKitManager * ck_proxy = console_kit_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_NONE, - "org.freedesktop.ConsoleKit", - "/org/freedesktop/ConsoleKit/Manager", - NULL, - NULL); - if (ck_proxy != NULL) + gchar * allowed = NULL; + + Login1Manager * manager_proxy = login1_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + "org.freedesktop.login1", + "/org/freedesktop/login1", + NULL, + NULL); + if (manager_proxy != NULL) { switch (type) { case LOGOUT_DIALOG_TYPE_RESTART: - console_kit_manager_call_can_restart_sync (ck_proxy, &allowed, NULL, NULL); + login1_manager_call_can_reboot_sync (manager_proxy, &allowed, NULL, NULL); break; case LOGOUT_DIALOG_TYPE_SHUTDOWN: - console_kit_manager_call_can_stop_sync (ck_proxy, &allowed, NULL, NULL); + login1_manager_call_can_power_off_sync (manager_proxy, &allowed, NULL, NULL); break; default: break; } - g_object_unref(ck_proxy); + g_object_unref(manager_proxy); } - return allowed; + return g_strcmp0 (allowed, "yes") == 0; } LogoutDialog * @@ -188,9 +188,9 @@ logout_dialog_new (LogoutDialogType type) gboolean allowed = FALSE; if (type == LOGOUT_DIALOG_TYPE_LOG_OUT) { - allowed = ck_check_allowed(LOGOUT_DIALOG_TYPE_RESTART); + allowed = logind_check_allowed(LOGOUT_DIALOG_TYPE_RESTART); } else { - allowed = ck_check_allowed(type); + allowed = logind_check_allowed(type); } gboolean restart_required = FALSE; diff --git a/src/gtk-logout-helper.c b/src/gtk-logout-helper.c index 55db630..12f2198 100644 --- a/src/gtk-logout-helper.c +++ b/src/gtk-logout-helper.c @@ -31,7 +31,7 @@ with this program. If not, see . #include "shared-names.h" static GVariant * -call_console_kit (const gchar *method, GVariant *parameters, GError **error) +call_logind (const gchar *method, GVariant *parameters, GError **error) { GDBusConnection * bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, error); if (!bus) @@ -41,9 +41,9 @@ call_console_kit (const gchar *method, GVariant *parameters, GError **error) } GVariant *result = g_dbus_connection_call_sync(bus, - "org.freedesktop.ConsoleKit", - "/org/freedesktop/ConsoleKit/Manager", - "org.freedesktop.ConsoleKit.Manager", + "org.freedesktop.login1", + "/org/freedesktop/login1", + "org.freedesktop.login1.Manager", method, parameters, NULL, @@ -57,24 +57,24 @@ call_console_kit (const gchar *method, GVariant *parameters, GError **error) } static void -consolekit_fallback (LogoutDialogType action) +logind_fallback (LogoutDialogType action) { GError * error = NULL; GVariant *result = NULL; - g_debug("Falling back to using ConsoleKit for action"); + g_debug("Falling back to using logind for action"); switch (action) { case LOGOUT_DIALOG_TYPE_LOG_OUT: - g_warning("Unable to fallback to ConsoleKit for logout as it's a session issue. We need some sort of session handler."); + g_warning("Unable to fallback to logind for logout as it's a session issue. We need some sort of session handler."); break; case LOGOUT_DIALOG_TYPE_SHUTDOWN: - g_debug("Telling ConsoleKit to 'Stop'"); - result = call_console_kit ("Stop", g_variant_new ("()"), &error); + g_debug("Telling logind to 'PowerOff'"); + result = call_logind ("PowerOff", g_variant_new ("(b)", FALSE), &error); break; case LOGOUT_DIALOG_TYPE_RESTART: - g_debug("Telling ConsoleKit to 'Restart'"); - result = call_console_kit ("Restart", g_variant_new ("()"), &error); + g_debug("Telling logind to 'Reboot'"); + result = call_logind ("Reboot", g_variant_new ("(b)", FALSE), &error); break; default: g_warning("Unknown action"); @@ -83,12 +83,10 @@ consolekit_fallback (LogoutDialogType action) if (!result) { if (error != NULL) { - g_warning ("ConsoleKit action failed: %s", error->message); + g_warning ("logind action failed: %s", error->message); } else { - g_warning ("ConsoleKit action failed: unknown error"); + g_warning ("logind action failed: unknown error"); } - - consolekit_fallback(action); } else g_variant_unref (result); @@ -149,7 +147,7 @@ session_action (LogoutDialogType action) g_warning ("SessionManager action failed: unknown error"); } - consolekit_fallback(action); + logind_fallback(action); } else g_variant_unref (result); diff --git a/src/org.freedesktop.ConsoleKit.Manager.xml b/src/org.freedesktop.ConsoleKit.Manager.xml deleted file mode 100644 index f903b55..0000000 --- a/src/org.freedesktop.ConsoleKit.Manager.xml +++ /dev/null @@ -1,353 +0,0 @@ - - - - - - - - - This method initiates a request to restart (ie. reboot) the computer system. - - - - - - - - - - - - - - This method initiates a request to stop (ie. shutdown) the computer system. - - - - - - - - - - - - - - The secret cookie that is used to identify the new session - - - - - This method requests that a new Session - be created for the calling process. The properties of this new Session are set automatically - from information collected about the calling process. - - This new session exists until the calling process disconnects from the system bus or - calls CloseSession(). - - It is the responsibility of the calling process to set the environment variable - XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only - be made available to child processes of the caller so that they may be identified - as members of this session. - - See this simple example: - - DBusError error; - DBusMessage *message; - DBusMessage *reply; - - message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", - "/org/freedesktop/ConsoleKit/Manager", - "org.freedesktop.ConsoleKit.Manager", - "OpenSession"); - if (message == NULL) { - goto out; - } - - dbus_error_init (&error); - reply = dbus_connection_send_with_reply_and_block (connector->connection, - message, - -1, - &error); - if (reply == NULL) { - goto out; - } - - dbus_error_init (&error); - if (! dbus_message_get_args (reply, - &error, - DBUS_TYPE_STRING, &cookie, - DBUS_TYPE_INVALID)) { - goto out; - } - - - - OpenSessionWithParameters() - - - - - - - An array of sets of property names and values - - - - - The secret cookie that is used to identify the new session - - - - - This method requests that a new Session - be created for the calling process. The properties of this new Session are from the - parameters provided. - - This new session exists until the calling process disconnects from the system bus or - calls CloseSession(). - - It is the responsibility of the calling process to set the environment variable - XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only - be made available to child processes of the caller so that they may be identified - as members of this session. - - See the Session properties for a list of valid parameters. - - org.freedesktop.ConsoleKit.Session - This method is restricted to privileged users by D-Bus policy. - - - - - - - The secret cookie that is used to identify the session - - - - - Whether the session was successfully closed - - - - - This method is used to close the session identified by the supplied cookie. - - The session can only be closed by the same process that opened the session. - - - - - - - - - an array of Seat IDs - - - - - This gets a list of all the Seats - that are currently present on the system. - Each Seat ID is an D-Bus object path for the object that implements the - Seat interface. - - org.freedesktop.ConsoleKit.Seat - - - - - - - an array of Session IDs - - - - - This gets a list of all the Sessions - that are currently present on the system. - Each Session ID is an D-Bus object path for the object that implements the - Session interface. - - org.freedesktop.ConsoleKit.Session - - - - - - - - The secret cookie that is used to identify the session - - - - - The object identifier for the current session - - - - - Returns the session ID that is associated with the specified cookie. - - - - - - - - - The POSIX process ID - - - - - The object identifier for the current session - - - - - Attempts to determine the session ID for the specified - POSIX process ID (pid). - - - - - - - - - The object identifier for the current session - - - - - Attempts to determine the session ID that the caller belongs to. - - See this example of using dbus-send: - - dbus-send --system --dest=org.freedesktop.ConsoleKit \ - --type=method_call --print-reply --reply-timeout=2000 \ - /org/freedesktop/ConsoleKit/Manager \ - org.freedesktop.ConsoleKit.Manager.GetCurrentSession - - - - - - - - - POSIX User identification - - - - - an array of Session IDs - - - - - This gets a list of all the Sessions - that are currently open for the specified user. - Each Session ID is an D-Bus object path for the object that implements the - Session interface. - - - - - - - - User identification - - - - - an array of Session IDs - - - - - This gets a list of all the Sessions - that are currently open for the specified user. - Each Session ID is an D-Bus object path for the object that implements the - Session interface. - - - - - - - - - The value of the system-idle-hint - - - - - Returns TRUE if the idle-hint - property of every open session is TRUE or if there are no open sessions. - - - - - - - - An ISO 8601 format date-type string - - - - - Returns an ISO 8601 date-time string that corresponds to - the time of the last change of the system-idle-hint. - - - - - - - - - The Seat ID for the added seat - - - - - Emitted when a Seat has been added to the system. - - - - - - - - The Seat ID for the removed seat - - - - - Emitted when a Seat has been removed from the system. - - - - - - - - The value of the system-idle-hint - - - - - Emitted when the value of the system-idle-hint has changed. - - - - - - diff --git a/src/org.freedesktop.ConsoleKit.Seat.xml b/src/org.freedesktop.ConsoleKit.Seat.xml deleted file mode 100644 index 58c2ce7..0000000 --- a/src/org.freedesktop.ConsoleKit.Seat.xml +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - - A seat is a collection of sessions and a set of hardware (usually at -least a keyboard and mouse). Only one session may be active on a -seat at a time. - - - - - - - Seat ID - - - - - Returns the ID for Seat. - - - - - - - - an array of Session IDs - - - - - This gets a list of all the Sessions - that are currently attached to this seat. - Each Session ID is an D-Bus object path for the object that implements the - Session interface. - - - - - - - - an array of devices - - - - - This gets a list of all the devices - that are currently associated with this seat. - Each device is an D-Bus structure that represents - the device type and the device id. - - - - - - - - - Session ID - - - - - Gets the Session ID that is currently active on this Seat. - Returns NULL if there is no active session. - - - - - - - - TRUE if seat supports session activation - - - - Used to determine whether the seat supports session activation. - - - - - - - - - Session ID - - - - - Attempt to activate the specified session. In most - cases, if successful, this will cause the session to - become visible and take control of the hardware that is - associated with this seat. - - Activate() - - - - - - - Session ID - - - - - Emitted when the active session has changed. - - - - - - - Session ID - - - - - Emitted when a session has been added to the seat. - - - - - - - Session ID - - - - - Emitted when a session has been removed from the seat. - - - - - - - Device structure - - - - - Emitted when a device has been associated with the seat. - - - - - - - Device structure - - - - - Emitted when a device has been dissociated from the seat. - - - - - diff --git a/src/org.freedesktop.ConsoleKit.Session.xml b/src/org.freedesktop.ConsoleKit.Session.xml deleted file mode 100644 index b6e1cdb..0000000 --- a/src/org.freedesktop.ConsoleKit.Session.xml +++ /dev/null @@ -1,435 +0,0 @@ - - - - - - - Session objects represent and store information - related to a user session. - - The properties associated with the Session - specifically refer to the properties of the "session leader". - - - - - - - Session ID - - - - Returns the ID for Session. - - - - - - - Seat ID - - - - Returns the ID for the Seat the Session is - attached to. - - org.freedesktop.ConsoleKit.Seat - - - - - - Session type - - - - - Returns the type of the session. - Warning: we haven't yet defined the allowed values for this property. - It is probably best to avoid this until we do. - - - session-type - - - - - - User ID - - - - Returns the user that the session belongs to. - - - user - - - - - - POSIX User ID - - - - Returns the POSIX user ID that the session belongs to. - - unix-user - - - - - - The value of the X11 display - - - - Returns the value of the X11 DISPLAY for this session - if one is present. - - x11-display - - - - - - The value of the X11 display device - - - - Returns the value of the display device (aka TTY) that the - X11 display for the session is connected to. If there is no x11-display set then this value - is undefined. - - x11-display-device - - - - - - The value of the display device - - - - Returns the value of the display device (aka TTY) that the - session is connected to. - - display-device - - - - - - The remote host name - - - - Returns the value of the remote host name for the session. - - - remote-host-name - - - - - - The value of the native system login session ID - - - - Returns the value of the login session ID that the - underlying system uses to enforce session boundaries. If there is no login session ID - set then this value is an empty string. - - - - - - - TRUE if the session is active, otherwise FALSE - - - - Returns whether the session is active on the Seat that - it is attached to. - If the session is not attached to a seat this value is undefined. - - - active - - - - - - TRUE if the session is local, otherwise FALSE - - - - Returns whether the session is local - FIXME: we need to come up with a concrete definition for this value. - It was originally used as a way to identify XDMCP sessions that originate - from a remote system. - - - is-local - - - - - - An ISO 8601 format date-type string - - - - - Returns an ISO 8601 date-time string that corresponds to - the time that the session was opened. - - - - - - - - - - Attempt to activate the this session. In most - cases, if successful, this will cause the session to - become visible and become active on the seat that it - is attached to. - - Seat.ActivateSession() - - - - - - - This will cause a Lock - signal to be emitted for this session. - - - This method is restricted to privileged users by D-Bus policy. - Lock signal - - - - - - - This will cause an Unlock - signal to be emitted for this session. - - This can be used by login managers to unlock a session before it is - re-activated during fast-user-switching. - - - This method is restricted to privileged users by D-Bus policy. - Unlock signal - - - - - - - The value of the idle-hint - - - - - Gets the value of the idle-hint - property. - - - idle-hint - - - - - - An ISO 8601 format date-type string - - - - - Returns an ISO 8601 date-time string that corresponds to - the time of the last change of the idle-hint. - - - - - - - - - boolean value to set the idle-hint to - - - - - This may be used by the session to indicate that - it is idle. - - Use of this method is restricted to the user - that owns the session. - - - - - - - - TRUE if the session is active, otherwise FALSE - - - - - Emitted when the active property has changed. - - - - - - - the new value of idle-hint - - - - - Emitted when the idle-hint property has changed. - - - - - - - Emitted in response to a call to the Lock() method. - It is intended that the screensaver for the session should lock the screen in response to this signal. - - - - - - - Emitted in response to a call to the Unlock() method. - It is intended that the screensaver for the session should unlock the screen in response to this signal. - - - - - - - - The user assigned to the session. - - - - - - - The user assigned to the session. - - - - - - - - The type of the session. - Warning: we haven't yet defined the allowed values for this property. - It is probably best to avoid this until we do. - - - - - - - - The remote host name for the session. - - This will be set in situations where the session is - opened and controlled from a remote system. - - For example, this value will be set when the - session is created from an SSH or XDMCP connection. - - - - - - - - The display device (aka TTY) that the - session is connected to. - - - - - - - - Value of the X11 DISPLAY for this session - if one is present. - - - - - - - - - The display device (aka TTY) that the X11 display for the - session is connected to. If there is no x11-display set then - this value is undefined. - - - - - - - - - Whether the session is active on the Seat that - it is attached to. - If the session is not attached to a seat this value is undefined. - - - - - - - - - Whether the session is local - FIXME: we need to come up with a concrete definition for this value. - It was originally used as a way to identify XDMCP sessions that originate - from a remote system. - - - - - - - - - This is a hint used to indicate that the session may be idle. - - - For sessions with a x11-display set (ie. graphical - sessions), it is up to each session to delegate the - responsibility for updating this value. Typically, the - screensaver will set this. - - However, for non-graphical sessions with a display-device set - the Session object itself will periodically update this value based - on the activity detected on the display-device itself. - - - This should not be considered authoritative. - - - - - - - diff --git a/src/org.freedesktop.login1.Manager.xml b/src/org.freedesktop.login1.Manager.xml new file mode 100644 index 0000000..91da5f2 --- /dev/null +++ b/src/org.freedesktop.login1.Manager.xml @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.freedesktop.login1.Seat.xml b/src/org.freedesktop.login1.Seat.xml new file mode 100644 index 0000000..92b62dd --- /dev/null +++ b/src/org.freedesktop.login1.Seat.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.freedesktop.login1.Session.xml b/src/org.freedesktop.login1.Session.xml new file mode 100644 index 0000000..24a6fac --- /dev/null +++ b/src/org.freedesktop.login1.Session.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.freedesktop.login1.User.xml b/src/org.freedesktop.login1.User.xml new file mode 100644 index 0000000..8253706 --- /dev/null +++ b/src/org.freedesktop.login1.User.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/session-menu-mgr.c b/src/session-menu-mgr.c index c7556bc..a41208f 100644 --- a/src/session-menu-mgr.c +++ b/src/session-menu-mgr.c @@ -878,10 +878,6 @@ is_user_switching_allowed (SessionMenuMgr * mgr) } /* maybe the seat doesn't support activation */ - if (!users_service_dbus_can_activate_session (mgr->users_dbus_facade)) - { - return FALSE; - } return TRUE; } diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index f12f47c..00836de 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -30,16 +30,15 @@ #include /* getpwuid() */ #include "dbus-accounts.h" -#include "dbus-consolekit-manager.h" -#include "dbus-consolekit-seat.h" -#include "dbus-consolekit-session.h" +#include "dbus-login1-manager.h" +#include "dbus-login1-session.h" +#include "dbus-login1-user.h" #include "dbus-display-manager.h" #include "dbus-user.h" #include "shared-names.h" #include "users-service-dbus.h" -#define CK_ADDR "org.freedesktop.ConsoleKit" -#define CK_SESSION_IFACE "org.freedesktop.ConsoleKit.Session" +#define LOGIND_ADDR "org.freedesktop.login1" /** *** @@ -57,17 +56,19 @@ static void on_user_deleted (Accounts * o, const gchar * user_object_path, UsersServiceDbus * service); -static void on_session_added (ConsoleKitSeat * seat, - const gchar * ssid, - UsersServiceDbus * service); +static void on_session_added (Login1Manager * proxy, + const gchar * ssid, + const gchar * path, + UsersServiceDbus * service); -static void on_session_removed (ConsoleKitSeat * seat, - const gchar * ssid, - UsersServiceDbus * service); +static void on_session_removed (Login1Manager * proxy, + const gchar * ssid, + const gchar * path, + UsersServiceDbus * service); -static void on_session_list (ConsoleKitSeat * seat, - GAsyncResult * result, - UsersServiceDbus * service); +static void on_session_list (Login1Manager * proxy, + GAsyncResult * result, + UsersServiceDbus * service); /*** **** Priv Struct @@ -85,8 +86,7 @@ struct _UsersServiceDbusPrivate GHashTable * users; GCancellable * cancellable; - ConsoleKitSeat * seat_proxy; - ConsoleKitManager * ck_manager_proxy; + Login1Manager * manager_proxy; Accounts * accounts_proxy; }; @@ -112,8 +112,7 @@ users_service_dbus_dispose (GObject *object) UsersServiceDbusPrivate * priv = USERS_SERVICE_DBUS(object)->priv; g_clear_object (&priv->accounts_proxy); - g_clear_object (&priv->seat_proxy); - g_clear_object (&priv->ck_manager_proxy); + g_clear_object (&priv->manager_proxy); if (priv->cancellable != NULL) { @@ -211,14 +210,14 @@ users_service_dbus_init (UsersServiceDbus *self) g_object_unref); /** - *** create the consolekit manager proxy... + *** create the logind manager proxy... **/ - p->ck_manager_proxy = console_kit_manager_proxy_new_for_bus_sync ( + p->manager_proxy = login1_manager_proxy_new_for_bus_sync ( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, - "org.freedesktop.ConsoleKit", - "/org/freedesktop/ConsoleKit/Manager", + "org.freedesktop.login1", + "/org/freedesktop/login1", NULL, &error); if (error != NULL) @@ -229,36 +228,13 @@ users_service_dbus_init (UsersServiceDbus *self) p->seat = get_seat (self); - /** - *** create the consolekit seat proxy... - **/ + g_signal_connect (p->manager_proxy, "session-new", + G_CALLBACK (on_session_added), self); + g_signal_connect (p->manager_proxy, "session-removed", + G_CALLBACK (on_session_removed), self); - if (p->seat != NULL) - { - ConsoleKitSeat * proxy = console_kit_seat_proxy_new_for_bus_sync ( - G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_NONE, - "org.freedesktop.ConsoleKit", - p->seat, - NULL, - &error); - - if (error != NULL) - { - g_warning ("Failed to connect to the ConsoleKit seat: %s", error->message); - g_clear_error (&error); - } - else - { - g_signal_connect (proxy, "session-added", - G_CALLBACK (on_session_added), self); - g_signal_connect (proxy, "session-removed", - G_CALLBACK (on_session_removed), self); - console_kit_seat_call_get_sessions (proxy, p->cancellable, - (GAsyncReadyCallback)on_session_list, self); - p->seat_proxy = proxy; - } - } + login1_manager_call_list_sessions (p->manager_proxy, p->cancellable, + (GAsyncReadyCallback) on_session_list, self); /** *** create the accounts manager proxy... @@ -311,16 +287,17 @@ emit_guest_login_changed (UsersServiceDbus * self) **** ***/ -static ConsoleKitSession* -create_consolekit_session_proxy (const char * ssid) +static Login1User* +create_login1_user_proxy (const char * path) { + GError * error = NULL; - ConsoleKitSession * p = console_kit_session_proxy_new_for_bus_sync ( + Login1User * p = login1_user_proxy_new_for_bus_sync ( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, - CK_ADDR, - ssid, + LOGIND_ADDR, + path, NULL, &error); if (error != NULL) @@ -332,54 +309,107 @@ create_consolekit_session_proxy (const char * ssid) return p; } -static gchar * -get_seat_from_session_proxy (ConsoleKitSession * session_proxy) +static Login1User * +create_login1_user_proxy_from_uid (UsersServiceDbus * self, + guint64 uid) { - gchar * seat = NULL; + Login1Manager * manager = self->priv->manager_proxy; + Login1User * user_proxy = NULL; + gchar * user_object_path = NULL; + GError * error = NULL; + + login1_manager_call_get_user_sync (manager, uid, &user_object_path, NULL, + &error); + + if (error != NULL) + { + g_warning ("%s: %s", G_STRLOC, error->message); + g_error_free (error); + } + + if (user_object_path != NULL) + user_proxy = create_login1_user_proxy (user_object_path); + + return user_proxy; +} + +static Login1Session * +create_login1_session_proxy (const char * path) +{ GError * error = NULL; - console_kit_session_call_get_seat_id_sync (session_proxy, - &seat, - NULL, - &error); + + Login1Session * p = login1_session_proxy_new_for_bus_sync ( + G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + LOGIND_ADDR, + path, + NULL, + &error); if (error != NULL) { - g_debug ("%s: %s", G_STRLOC, error->message); + g_warning ("%s: %s", G_STRLOC, error->message); g_error_free (error); } + return p; +} + + +static gchar * +get_seat_from_session_proxy (Login1Session * session_proxy) +{ + gchar * seat; + GVariant * seatobj = login1_session_get_seat (session_proxy); + + g_variant_get (seatobj, "(so)", &seat, NULL); + return seat; } +static const gchar * +get_display_from_session_proxy (Login1Session * session_proxy) +{ + const gchar * display; + display = login1_session_get_display (session_proxy); + return display; +} + static gchar * get_seat (UsersServiceDbus *service) { gchar * seat = NULL; - gchar * ssid = NULL; + gchar * path = NULL; GError * error = NULL; UsersServiceDbusPrivate * priv = service->priv; + Login1Session * session_proxy = NULL; + pid_t pid = getpid(); + + login1_manager_call_get_session_by_pid_sync (priv->manager_proxy, + pid, + &path, + NULL, + &error); - console_kit_manager_call_get_current_session_sync (priv->ck_manager_proxy, - &ssid, - NULL, - &error); if (error != NULL) { g_debug ("%s: %s", G_STRLOC, error->message); g_error_free (error); + goto out; } - else - { - ConsoleKitSession * session = create_consolekit_session_proxy (ssid); - if (session != NULL) - { - seat = get_seat_from_session_proxy (session); - g_object_unref (session); - } + session_proxy = create_login1_session_proxy (path); + + if (!session_proxy) + { + g_debug ("%s: Could't get session proxy object", G_STRLOC); } + seat = get_seat_from_session_proxy (session_proxy); + +out: + g_object_unref (session_proxy); return seat; } @@ -434,9 +464,10 @@ user_count_sessions (AccountsUser * user) static void add_user_session (UsersServiceDbus * service, AccountsUser * user, - const gchar * ssid) + const gchar * ssid, + const gchar * path) { - ConsoleKitSession * session_proxy = create_consolekit_session_proxy (ssid); + Login1Session * session_proxy = create_login1_session_proxy (path); if (session_proxy != NULL) { UsersServiceDbusPrivate * priv = service->priv; @@ -446,12 +477,8 @@ add_user_session (UsersServiceDbus * service, if (seat && priv->seat && !g_strcmp0 (seat, priv->seat)) { /* does this session have a display? */ - gchar * display = NULL; - console_kit_session_call_get_x11_display_sync (session_proxy, - &display, - NULL, NULL); - const gboolean has_display = display && *display; - g_free (display); + const gchar * display = get_display_from_session_proxy (session_proxy); + const gboolean has_display = g_strcmp0 ("", display) != 0; if (has_display) { @@ -480,33 +507,30 @@ add_user_sessions (UsersServiceDbus *self, AccountsUser * user) const char * username = accounts_user_get_user_name (user); g_debug ("%s adding %s (%i)", G_STRLOC, username, (int)uid); - GError * error = NULL; - gchar ** sessions = NULL; - console_kit_manager_call_get_sessions_for_unix_user_sync ( - self->priv->ck_manager_proxy, - uid, - &sessions, - NULL, - &error); + GVariant * sessions = NULL; - if (error != NULL) + Login1User * user_proxy = create_login1_user_proxy_from_uid (self, uid); + + if (user_proxy != NULL) { - g_debug ("%s: %s", G_STRLOC, error->message); - g_error_free (error); + sessions = login1_user_get_sessions (user_proxy); } - else if (sessions != NULL) + + if (sessions != NULL) { - int i; + GVariantIter iter; + g_variant_iter_init (&iter, sessions); + gchar * id; + gchar * object_path; - for (i=0; sessions[i]; i++) + while (g_variant_iter_loop (&iter, "(so)", &id, &object_path)) { - const char * const ssid = sessions[i]; - g_debug ("%s adding %s's session %s", G_STRLOC, username, ssid); - add_user_session (self, user, ssid); + g_debug ("%s adding %s's session %s", G_STRLOC, username, id); + add_user_session (self, user, id, object_path); } - - g_strfreev (sessions); } + + g_object_unref (user_proxy); } /* returns true if this property is one we use */ @@ -723,9 +747,10 @@ find_user_from_username (UsersServiceDbus * self, ***/ static void -on_session_removed (ConsoleKitSeat * seat_proxy, - const gchar * ssid, - UsersServiceDbus * service) +on_session_removed (Login1Manager * proxy, + const gchar * ssid, + const gchar * path, + UsersServiceDbus * service) { g_return_if_fail (IS_USERS_SERVICE_DBUS (service)); @@ -757,42 +782,25 @@ on_session_removed (ConsoleKitSeat * seat_proxy, } static gchar* -get_unix_username_from_ssid (UsersServiceDbus * self, - const gchar * ssid) +get_unix_username_from_path (UsersServiceDbus * self, + const gchar * path) { - gchar * username = NULL; - ConsoleKitSession * session_proxy = create_consolekit_session_proxy (ssid); + Login1Session * session_proxy = create_login1_session_proxy (path); if (session_proxy != NULL) { - guint uid = 0; - GError * error = NULL; - console_kit_session_call_get_unix_user_sync (session_proxy, - &uid, - NULL, &error); - if (error != NULL) - { - g_warning ("%s: %s", G_STRLOC, error->message); - g_clear_error (&error); - } - else - { - errno = 0; - const struct passwd * pwent = getpwuid (uid); - if (pwent == NULL) - { - g_warning ("Failed to lookup user id %d: %s", (int)uid, g_strerror(errno)); - } - else - { - username = g_strdup (pwent->pw_name); - } - } + gchar * username = g_strdup (login1_session_get_name (session_proxy)); + + g_debug ("%s Getting username for %s: %s", G_STRLOC, path, username); g_object_unref (session_proxy); - } - return username; + return username; + } + else + { + return NULL; + } } static gboolean @@ -810,13 +818,14 @@ is_guest_username (const char * username) /* If the new session belongs to 'guest', update our guest_ssid. Otherwise, call add_user_session() to update our session tables */ static void -on_session_added (ConsoleKitSeat * seat_proxy G_GNUC_UNUSED, - const gchar * ssid, - UsersServiceDbus * service) +on_session_added (Login1Manager * proxy G_GNUC_UNUSED, + const gchar * ssid, + const gchar * path, + UsersServiceDbus * service) { g_return_if_fail (IS_USERS_SERVICE_DBUS(service)); - gchar * username = get_unix_username_from_ssid (service, ssid); + gchar * username = get_unix_username_from_path (service, path); g_debug ("%s %s() username %s has new session %s", G_STRLOC, G_STRFUNC, username, ssid); if (is_guest_username (username)) @@ -834,45 +843,59 @@ on_session_added (ConsoleKitSeat * seat_proxy G_GNUC_UNUSED, if (user != NULL) { - add_user_session (service, user, ssid); + add_user_session (service, user, ssid, path); emit_user_login_changed (service, user); } } - g_free (username); } /* Receives a list of sessions and calls on_session_added() for each of them */ static void -on_session_list (ConsoleKitSeat * seat_proxy, +on_session_list (Login1Manager * proxy, GAsyncResult * result, UsersServiceDbus * self) { GError * error = NULL; - gchar ** sessions = NULL; + GVariant * sessions; g_debug ("%s bootstrapping the session list", G_STRLOC); - console_kit_seat_call_get_sessions_finish (seat_proxy, - &sessions, - result, - &error); + login1_manager_call_list_sessions_finish (proxy, + &sessions, + result, + &error); if (error != NULL) { g_debug ("%s: %s", G_STRLOC, error->message); g_error_free (error); } - else if (sessions != NULL) + else { - int i; - - for (i=0; sessions[i]; i++) + GVariantIter * iter; + gchar * seat; + gchar * path; + + g_variant_get (sessions, "a(susso)", &iter); + + while (g_variant_iter_loop (iter, + "(susso)", + NULL, + NULL, + NULL, + &seat, + &path)) { - g_debug ("%s adding initial session '%s'", G_STRLOC, sessions[i]); - on_session_added (seat_proxy, sessions[i], self); + if (g_strcmp0 (seat, self->priv->seat) == 0) + { + g_debug ("%s adding initial session '%s'", G_STRLOC, path); + on_session_added (proxy, seat, path, self); + } } - g_strfreev (sessions); + g_variant_iter_free (iter); + g_variant_unref (sessions); + } g_debug ("%s done bootstrapping the session list", G_STRLOC); @@ -1004,27 +1027,6 @@ users_service_dbus_guest_session_enabled (UsersServiceDbus * self) return enabled; } -gboolean -users_service_dbus_can_activate_session (UsersServiceDbus * self) -{ - gboolean can_activate = FALSE; - - g_return_val_if_fail (IS_USERS_SERVICE_DBUS(self), can_activate); - - GError * error = NULL; - console_kit_seat_call_can_activate_sessions_sync (self->priv->seat_proxy, - &can_activate, - NULL, - &error); - if (error != NULL) - { - g_warning ("%s: %s", G_STRLOC, error->message); - g_error_free (error); - } - - return can_activate; -} - gboolean users_service_dbus_is_guest_logged_in (UsersServiceDbus * self) { diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h index 0f082c3..3e5252d 100644 --- a/src/users-service-dbus.h +++ b/src/users-service-dbus.h @@ -52,8 +52,8 @@ typedef struct _UsersServiceDbusPrivate UsersServiceDbusPrivate; * 2. Track which users currently have X sessions. * This is used for the menuitems' USER_ITEM_PROP_LOGGED_IN property. * - * We initially build this list by calling org.freedesktop.ConsoleKit.Seat's - * GetDevices method. We also monitor the seat for SessionAdded and + * We initially build this list by calling org.freedesktop.login1's + * ListSessions method. We also monitor the seat for SessionNew and * SessionRemoved and update the list accordingly. * * 3. Provide an API for user switching and guest sessions. @@ -87,7 +87,6 @@ gboolean users_service_dbus_is_user_logged_in (UsersServiceDbus * self, void users_service_dbus_show_greeter (UsersServiceDbus * self); gboolean users_service_dbus_guest_session_enabled (UsersServiceDbus * self); -gboolean users_service_dbus_can_activate_session (UsersServiceDbus * self); void users_service_dbus_activate_guest_session (UsersServiceDbus * self); void users_service_dbus_activate_user_session (UsersServiceDbus * self, AccountsUser * user); -- cgit v1.2.3 From 2e643e7bd0c3c182a62e7112431ea797e18bf6ed Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Fri, 12 Apr 2013 12:12:34 +0100 Subject: Remove upower usage - these interfaces are being deprecated. There doesn't appear to be any signal in logind for the CanSuspend or CanHibernate properties changing throughout the life of a session, so we don't support this. --- src/Makefile.am | 16 +-- src/session-menu-mgr.c | 125 +++++++------------- src/upower.xml | 309 ------------------------------------------------- 3 files changed, 45 insertions(+), 405 deletions(-) delete mode 100644 src/upower.xml (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 976783f..1ab9b9b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -93,17 +93,6 @@ $(dbus_user_sources): org.freedesktop.Accounts.User.xml --generate-c-code dbus-user \ $^ -dbus_upower_sources = \ - dbus-upower.c \ - dbus-upower.h - -$(dbus_upower_sources): upower.xml - $(AM_V_GEN) gdbus-codegen \ - --interface-prefix org.freedesktop \ - --generate-c-code dbus-upower \ - --c-namespace DBus \ - $^ - gen-%.xml.c: %.xml @echo "Building $@ from $<" @echo "const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<)))) = " > $@ @@ -124,7 +113,6 @@ indicator_session_service_SOURCES = \ $(dbus_login1_user_sources) \ $(dbus_login1_session_sources) \ $(dbus_display_manager_sources) \ - $(dbus_upower_sources) \ $(dbus_user_sources) \ session-service.c \ session-dbus.c \ @@ -189,7 +177,6 @@ BUILT_SOURCES = \ $(dbus_login1_user_sources) \ $(dbus_login1_session_sources) \ $(dbus_display_manager_sources) \ - $(dbus_upower_sources) \ $(dbus_user_sources) \ gen-session-dbus.xml.c \ gen-session-dbus.xml.h @@ -201,7 +188,6 @@ EXTRA_DIST += \ org.freedesktop.login1.Manager.xml \ org.freedesktop.login1.Session.xml \ org.freedesktop.login1.User.xml \ - session-dbus.xml \ - upower.xml + session-dbus.xml CLEANFILES += $(BUILT_SOURCES) diff --git a/src/session-menu-mgr.c b/src/session-menu-mgr.c index a41208f..1d865fc 100644 --- a/src/session-menu-mgr.c +++ b/src/session-menu-mgr.c @@ -29,7 +29,7 @@ with this program. If not, see . #include #include -#include "dbus-upower.h" +#include "dbus-login1-manager.h" #include "session-menu-mgr.h" #include "shared-names.h" #include "users-service-dbus.h" @@ -37,8 +37,8 @@ with this program. If not, see . #define DEBUG_SHOW_ALL FALSE -#define UPOWER_ADDRESS "org.freedesktop.UPower" -#define UPOWER_PATH "/org/freedesktop/UPower" +#define LOGIN1_MANAGER_ADDRESS "org.freedesktop.login1" +#define LOGIN1_MANAGER_PATH "/org/freedesktop/login1" #define CMD_HELP "yelp" #define CMD_INFO "gnome-control-center info" @@ -77,7 +77,7 @@ SwitcherMode; * This is a pretty straightforward class: it creates the menumodel * and listens for events that can affect the model's properties. * - * Simple event sources, such as GSettings and a UPower DBus proxy, + * Simple event sources, such as GSettings and a logind DBus proxy, * are handled here. More involved event sources are delegated to the * UsersServiceDBus facade class. */ @@ -107,15 +107,13 @@ struct _SessionMenuMgr /* cached settings taken from the upower proxy */ gboolean can_hibernate; gboolean can_suspend; - gboolean allow_hibernate; - gboolean allow_suspend; gboolean shell_mode; gboolean greeter_mode; guint shell_name_watcher; GCancellable * cancellable; - DBusUPower * upower_proxy; + Login1Manager * login1_manager_proxy; SessionDbus * session_dbus; UsersServiceDbus * users_dbus_facade; OnlineAccountsMgr * online_accounts_mgr; @@ -224,7 +222,7 @@ session_menu_mgr_dispose (GObject *object) g_clear_object (&mgr->indicator_settings); g_clear_object (&mgr->lockdown_settings); g_clear_object (&mgr->keybinding_settings); - g_clear_object (&mgr->upower_proxy); + g_clear_object (&mgr->login1_manager_proxy); g_clear_object (&mgr->users_dbus_facade); g_clear_object (&mgr->top_mi); g_clear_object (&mgr->session_dbus); @@ -248,47 +246,11 @@ session_menu_mgr_class_init (SessionMenuMgrClass * klass) object_class->dispose = session_menu_mgr_dispose; } -/*** -**** UPower Proxy: -**** -**** 1. While bootstrapping, we invoke the AllowSuspend and AllowHibernate -**** methods to find out whether or not those features are allowed. -**** 2. While bootstrapping, we get the CanSuspend and CanHibernate properties -**** and also listen for property changes. -**** 3. These four values are used to set suspend and hibernate's visibility. -**** -***/ - -static void -on_upower_properties_changed (SessionMenuMgr * mgr) +static gboolean +can_perform_operation (gchar * permission) { - gboolean need_refresh = FALSE; - - if (mgr->upower_proxy != NULL) - { - gboolean b; - - /* suspend */ - b = dbus_upower_get_can_suspend (mgr->upower_proxy); - if (mgr->can_suspend != b) - { - mgr->can_suspend = b; - need_refresh = TRUE; - } - - /* hibernate */ - b = dbus_upower_get_can_hibernate (mgr->upower_proxy); - if (mgr->can_hibernate != b) - { - mgr->can_hibernate = b; - need_refresh = TRUE; - } - } - - if (need_refresh) - { - update_session_menuitems (mgr); - } + return g_strcmp0 ("yes", permission) == 0 || + g_strcmp0 ("allowed", permission) == 0; } static void @@ -297,48 +259,55 @@ init_upower_proxy (SessionMenuMgr * mgr) /* default values */ mgr->can_suspend = TRUE; mgr->can_hibernate = TRUE; - mgr->allow_suspend = TRUE; - mgr->allow_hibernate = TRUE; + + gchar * can_suspend; + gchar * can_hibernate; mgr->cancellable = g_cancellable_new (); GError * error = NULL; - mgr->upower_proxy = dbus_upower_proxy_new_for_bus_sync ( + mgr->login1_manager_proxy = login1_manager_proxy_new_for_bus_sync ( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, - UPOWER_ADDRESS, - UPOWER_PATH, + LOGIN1_MANAGER_ADDRESS, + LOGIN1_MANAGER_PATH, NULL, &error); if (error != NULL) { - g_warning ("Error creating upower proxy: %s", error->message); + g_warning ("Error creating logind proxy: %s", error->message); g_clear_error (&error); } else { - dbus_upower_call_suspend_allowed_sync (mgr->upower_proxy, - &mgr->allow_suspend, - NULL, - &error); + login1_manager_call_can_suspend_sync (mgr->login1_manager_proxy, + &can_suspend, + NULL, + &error); if (error != NULL) { g_warning ("%s: %s", G_STRFUNC, error->message); g_clear_error (&error); } - - dbus_upower_call_hibernate_allowed_sync (mgr->upower_proxy, - &mgr->allow_hibernate, - NULL, - &error); + else + { + mgr->can_suspend = can_perform_operation (can_suspend); + } + + login1_manager_call_can_suspend_sync (mgr->login1_manager_proxy, + &can_hibernate, + NULL, + &error); if (error != NULL) { g_warning ("%s: %s", G_STRFUNC, error->message); g_clear_error (&error); } + else + { + mgr->can_hibernate = can_perform_operation (can_hibernate); + } - g_signal_connect_swapped (mgr->upower_proxy, "changed", - G_CALLBACK(on_upower_properties_changed), mgr); } } @@ -505,13 +474,9 @@ update_session_menuitems (SessionMenuMgr * mgr) && !g_settings_get_boolean (s, "suppress-logout-menuitem"); mi_set_visible (mgr->logout_mi, v); - v = mgr->can_suspend - && mgr->allow_suspend; - mi_set_visible (mgr->suspend_mi, v); + mi_set_visible (mgr->suspend_mi, mgr->can_suspend); - v = mgr->can_hibernate - && mgr->allow_hibernate; - mi_set_visible (mgr->hibernate_mi, v); + mi_set_visible (mgr->hibernate_mi, mgr->can_hibernate); v = (!mgr->shell_mode || g_settings_get_boolean (s, "suppress-logout-restart-shutdown")) && (HAVE_RESTART_CMD || mgr->shell_mode) @@ -1143,9 +1108,10 @@ action_func_suspend (SessionMenuMgr * mgr) { GError * error = NULL; - dbus_upower_call_suspend_sync (mgr->upower_proxy, - mgr->cancellable, - &error); + login1_manager_call_suspend_sync (mgr->login1_manager_proxy, + TRUE, + mgr->cancellable, + &error); if (error != NULL) { @@ -1159,9 +1125,10 @@ action_func_hibernate (SessionMenuMgr * mgr) { GError * error = NULL; - dbus_upower_call_hibernate_sync (mgr->upower_proxy, - mgr->cancellable, - &error); + login1_manager_call_hibernate_sync (mgr->login1_manager_proxy, + TRUE, + mgr->cancellable, + &error); if (error != NULL) { @@ -1346,10 +1313,6 @@ session_menu_mgr_new (SessionDbus * session_dbus, update_user_menuitems (mgr); build_session_menuitems (mgr); - /* After we have the session menu items built we can look to - align them with UPower */ - on_upower_properties_changed (mgr); - return mgr; } diff --git a/src/upower.xml b/src/upower.xml deleted file mode 100644 index 18d5fbd..0000000 --- a/src/upower.xml +++ /dev/null @@ -1,309 +0,0 @@ - - - - - - - - The DeviceKit-power service is available via the system message - bus. To access the service, use - the org.freedesktop.UPower interface on - the /org/freedesktop/UPower object on - the D-Bus system bus service with the well-known - name org.freedesktop.UPower. - - - - -$ dbus-send --print-reply \ - --system \ - --dest=org.freedesktop.UPower \ - /org/freedesktop/UPower \ - org.freedesktop.UPower.EnumerateDevices - -method return sender=:1.386 -> dest=:1.451 reply_serial=2 - array [ - object path "/org/freedesktop/UPower/devices/line_power_AC" - object path "/org/freedesktop/UPower/devices/battery_BAT0" - ] - - - - - - - - - - - - An array of object paths for devices. - - - - - - Enumerate all power objects on the system. - - - - - - - - - - Object path of device that was added. - - - - - - Emitted when a device is added. - - - - - - - - - - Object path of device that was removed. - - - - - - Emitted when a device is removed. - - - - - - - - - - Object path of device that was changed. - - - - - - Emitted when a device changed. - - - - - - - - - - - - Emitted when one or more properties on the object changes. - - - - - - - - - - - - This signal is sent when the session is about to be suspended or - hibernated. - Session and system programs have one second to do anything required - before the sleep action is taken (such as sending out Avahi or - Jabber messages). - - - - - - - - - - - - This signal is sent when the session has just returned from - Suspend() or Hibernate(). - Session and system programs can then do anything required (such as - sending out Avahi or Jabber messages). - - - - - - - - - - - - - This method tells UPower that the Suspend() or Hibernate() method - is about to be called. - This allows UPower to emit the Suspending signal whilst - session activities are happening that have to be done before the - suspend process is started. - - - This method would typically be called by the session power - management daemon, before it locks the screen and waits for the - screen to fade to black. - The session power management component would then call Suspend() or - Hibernate() when these syncronous tasks have completed. - - - If this method is not called than nothing bad will happen and - Suspend() or Hibernate() will block for the required second. - - - - - - - - - - - - - Suspends the computer into a low power state. - System state is not preserved if the power is lost. - - - If AboutToRequestSleep() has not been called then UPower will send - the Sleeping() signal and block for one second. - - - If AboutToRequestSleep() has been called less than one second - before this method is called then UPower will block for the - remaining time to complete one second of delay. - - - - - - - - - - - TRUE if allowed, otherwise FALSE - - - - - Check if the caller has (or can get) the PolicyKit privilege to call - Suspend. - - - - - - - - - - - - - Hibernates the computer into a low power state. - System state is preserved if the power is lost. - - - If AboutToRequestSleep() has not been called then UPower will send - the Sleeping() signal and block for one second. - - - If AboutToRequestSleep() has been called less than one second - before this method is called then UPower will block for the - remaining time to complete one second of delay. - - - - - - - - - - - TRUE if allowed, otherwise FALSE - - - - - Check if the caller has (or can get) the PolicyKit privilege to call - Hibernate. - - - - - - - - - - Version of the running daemon, e.g. 002. - - - - - - Whether the system is able to suspend. - - - - - - Whether the system is able to hibernate. - - - - - - Indicates whether the system is running on battery power. - This property is provided for convenience. - - - - - - Indicates whether the system is running on battery power and if the battery is critically low. - This property is provided for convenience. - - - - - - - - Indicates if the laptop lid is closed where the display cannot be seen. - - - - - - - - - - If the system has a lid device. - - - - - - - - -- cgit v1.2.3 From 40c99158a7f39b9932d531a16fe82eb399dcbf37 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Fri, 12 Apr 2013 12:35:31 +0100 Subject: Allow PolicyKit to interactively ask the user for credentials in gtk-logout-helper --- src/gtk-logout-helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gtk-logout-helper.c b/src/gtk-logout-helper.c index 12f2198..b013a8f 100644 --- a/src/gtk-logout-helper.c +++ b/src/gtk-logout-helper.c @@ -70,11 +70,11 @@ logind_fallback (LogoutDialogType action) break; case LOGOUT_DIALOG_TYPE_SHUTDOWN: g_debug("Telling logind to 'PowerOff'"); - result = call_logind ("PowerOff", g_variant_new ("(b)", FALSE), &error); + result = call_logind ("PowerOff", g_variant_new ("(b)", TRUE), &error); break; case LOGOUT_DIALOG_TYPE_RESTART: g_debug("Telling logind to 'Reboot'"); - result = call_logind ("Reboot", g_variant_new ("(b)", FALSE), &error); + result = call_logind ("Reboot", g_variant_new ("(b)", TRUE), &error); break; default: g_warning("Unknown action"); -- cgit v1.2.3 From 58c80d41f5f7ae1f02d43aba1536416d45d89a8f Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Fri, 19 Apr 2013 10:38:43 +0100 Subject: Only show menu items if we can perform the action without authorisation --- src/session-menu-mgr.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/session-menu-mgr.c b/src/session-menu-mgr.c index 1d865fc..278f191 100644 --- a/src/session-menu-mgr.c +++ b/src/session-menu-mgr.c @@ -104,7 +104,7 @@ struct _SessionMenuMgr GSettings * indicator_settings; GSettings * keybinding_settings; - /* cached settings taken from the upower proxy */ + /* cached settings taken from the logind proxy */ gboolean can_hibernate; gboolean can_suspend; @@ -121,7 +121,7 @@ struct _SessionMenuMgr static SwitcherMode get_switcher_mode (SessionMenuMgr *); -static void init_upower_proxy (SessionMenuMgr *); +static void init_login1_proxy (SessionMenuMgr *); static void init_shell_watcher (SessionMenuMgr *); static void update_screensaver_shortcut (SessionMenuMgr *); @@ -201,7 +201,7 @@ session_menu_mgr_init (SessionMenuMgr *mgr) g_signal_connect (mgr->users_dbus_facade, "guest-logged-in-changed", G_CALLBACK(on_guest_logged_in_changed), mgr); - init_upower_proxy (mgr); + init_login1_proxy (mgr); init_shell_watcher (mgr); /* Online accounts menu item */ @@ -249,12 +249,11 @@ session_menu_mgr_class_init (SessionMenuMgrClass * klass) static gboolean can_perform_operation (gchar * permission) { - return g_strcmp0 ("yes", permission) == 0 || - g_strcmp0 ("allowed", permission) == 0; + return g_strcmp0 ("yes", permission) == 0; } static void -init_upower_proxy (SessionMenuMgr * mgr) +init_login1_proxy (SessionMenuMgr * mgr) { /* default values */ mgr->can_suspend = TRUE; -- cgit v1.2.3 From dfca7304da17c90b8c930b63bff7d5aa4f591406 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Fri, 19 Apr 2013 10:44:36 +0100 Subject: Call can_hibernate instead of can_suspend when checking whether we can hibernate --- src/session-menu-mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/session-menu-mgr.c b/src/session-menu-mgr.c index 278f191..22f70e5 100644 --- a/src/session-menu-mgr.c +++ b/src/session-menu-mgr.c @@ -293,7 +293,7 @@ init_login1_proxy (SessionMenuMgr * mgr) mgr->can_suspend = can_perform_operation (can_suspend); } - login1_manager_call_can_suspend_sync (mgr->login1_manager_proxy, + login1_manager_call_can_hibernate_sync (mgr->login1_manager_proxy, &can_hibernate, NULL, &error); -- cgit v1.2.3 From 38399afa051605a447bd478c7b521048da8223d3 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Fri, 19 Apr 2013 11:08:46 +0100 Subject: Pass 'FALSE' for the PK interactivity argument, to match not checking for 'allowed' any more --- src/gtk-logout-helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gtk-logout-helper.c b/src/gtk-logout-helper.c index b013a8f..12f2198 100644 --- a/src/gtk-logout-helper.c +++ b/src/gtk-logout-helper.c @@ -70,11 +70,11 @@ logind_fallback (LogoutDialogType action) break; case LOGOUT_DIALOG_TYPE_SHUTDOWN: g_debug("Telling logind to 'PowerOff'"); - result = call_logind ("PowerOff", g_variant_new ("(b)", TRUE), &error); + result = call_logind ("PowerOff", g_variant_new ("(b)", FALSE), &error); break; case LOGOUT_DIALOG_TYPE_RESTART: g_debug("Telling logind to 'Reboot'"); - result = call_logind ("Reboot", g_variant_new ("(b)", TRUE), &error); + result = call_logind ("Reboot", g_variant_new ("(b)", FALSE), &error); break; default: g_warning("Unknown action"); -- cgit v1.2.3