summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2018-08-02 14:00:46 -0400
committerRay Strode <halfline@gmail.com>2018-08-02 20:06:36 +0000
commit6574b4f2705ae7e37e7e57d6b57190094c2467c7 (patch)
tree8989badf799606ca03da00520375010675896e1f
parent0e9f09da4897bdc4069298c8a4d189cd7f217f81 (diff)
downloadgdm-6574b4f2705ae7e37e7e57d6b57190094c2467c7.tar.gz
common: dedupe activate_session_id
Right now there are three copies of activate_session_id. This commit consolidates the code to gdm-common.c
-rw-r--r--common/gdm-common.c10
-rw-r--r--common/gdm-common.h6
-rw-r--r--daemon/gdm-manager.c35
3 files changed, 13 insertions, 38 deletions
diff --git a/common/gdm-common.c b/common/gdm-common.c
index 613511c4..d807c019 100644
--- a/common/gdm-common.c
+++ b/common/gdm-common.c
@@ -352,10 +352,10 @@ create_transient_display (GDBusConnection *connection,
return TRUE;
}
-static gboolean
-activate_session_id (GDBusConnection *connection,
- const char *seat_id,
- const char *session_id)
+gboolean
+gdm_activate_session_by_id (GDBusConnection *connection,
+ const char *seat_id,
+ const char *session_id)
{
GError *local_error = NULL;
GVariant *reply;
@@ -529,7 +529,7 @@ goto_login_session (GDBusConnection *connection,
res = gdm_get_login_window_session_id (seat_id, &session_id);
if (res && session_id != NULL) {
- res = activate_session_id (connection, seat_id, session_id);
+ res = gdm_activate_session_by_id (connection, seat_id, session_id);
if (res) {
ret = TRUE;
diff --git a/common/gdm-common.h b/common/gdm-common.h
index bd8ac705..07812b10 100644
--- a/common/gdm-common.h
+++ b/common/gdm-common.h
@@ -22,6 +22,8 @@
#define _GDM_COMMON_H
#include <glib-unix.h>
+#include <gio/gio.h>
+
#include <pwd.h>
#include <errno.h>
@@ -71,6 +73,10 @@ char * gdm_shell_expand (const char *str,
GdmExpandVarFunc expand_func,
gpointer user_data);
+gboolean gdm_activate_session_by_id (GDBusConnection *connection,
+ const char *seat_id,
+ const char *session_id);
+
G_END_DECLS
#endif /* _GDM_COMMON_H */
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index ac30aee9..11945522 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -295,37 +295,6 @@ is_login_session (GdmManager *self,
}
static gboolean
-activate_session_id (GdmManager *manager,
- const char *seat_id,
- const char *session_id)
-{
- GError *error = NULL;
- GVariant *reply;
-
- reply = g_dbus_connection_call_sync (manager->priv->connection,
- "org.freedesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager",
- "ActivateSessionOnSeat",
- g_variant_new ("(ss)", session_id, seat_id),
- NULL, /* expected reply */
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
- if (reply == NULL) {
- g_debug ("GdmManager: logind 'ActivateSessionOnSeat' %s raised:\n %s\n\n",
- g_dbus_error_get_remote_error (error), error->message);
- g_error_free (error);
- return FALSE;
- }
-
- g_variant_unref (reply);
-
- return TRUE;
-}
-
-static gboolean
session_unlock (GdmManager *manager,
const char *ssid)
{
@@ -621,7 +590,7 @@ switch_to_compatible_user_session (GdmManager *manager,
if (existing_session != NULL) {
ssid_to_activate = gdm_session_get_session_id (existing_session);
if (seat_id != NULL) {
- res = activate_session_id (manager, seat_id, ssid_to_activate);
+ res = gdm_activate_session_by_id (manager->priv->connection, seat_id, ssid_to_activate);
if (! res) {
g_debug ("GdmManager: unable to activate session: %s", ssid_to_activate);
goto out;
@@ -1329,7 +1298,7 @@ activate_login_window_session_on_seat (GdmManager *self,
}
if (session_id) {
- activate_session_id (self, seat_id, session_id);
+ gdm_activate_session_by_id (self, seat_id, session_id);
g_free (session_id);
}
}