[gdm/wip/try-harder-to-get-a-login-screen: 4/5] common: dedupe activate_session_id



commit 6574b4f2705ae7e37e7e57d6b57190094c2467c7
Author: Ray Strode <rstrode redhat com>
Date:   Thu Aug 2 14:00:46 2018 -0400

    common: dedupe activate_session_id
    
    Right now there are three copies of activate_session_id.
    
    This commit consolidates the code to gdm-common.c

 common/gdm-common.c  | 10 +++++-----
 common/gdm-common.h  |  6 ++++++
 daemon/gdm-manager.c | 35 ++---------------------------------
 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
@@ -294,37 +294,6 @@ is_login_session (GdmManager  *self,
         return TRUE;
 }
 
-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);
         }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]