[gdm] Move get_primary_session_id to gdm-user.h



commit 1c7f515da36b54a0d7bbb9e9a5f154176bae2e37
Author: Ray Strode <rstrode redhat com>
Date:   Mon Mar 15 13:56:38 2010 -0400

    Move get_primary_session_id to gdm-user.h
    
    It makes more sense there, and this will allow
    us to drop get_sessions eventually.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=610179

 gui/simple-greeter/gdm-user-manager.c |   61 +++++---------------------------
 gui/simple-greeter/gdm-user.c         |   30 ++++++++++++++++
 gui/simple-greeter/gdm-user.h         |    1 +
 3 files changed, 41 insertions(+), 51 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-user-manager.c b/gui/simple-greeter/gdm-user-manager.c
index a6d1fc8..2a63db0 100644
--- a/gui/simple-greeter/gdm-user-manager.c
+++ b/gui/simple-greeter/gdm-user-manager.c
@@ -157,55 +157,6 @@ start_new_login_session (GdmUserManager *manager)
         return res;
 }
 
-/* needs to stay in sync with gdm-slave */
-static char *
-_get_primary_user_session_id (GdmUserManager *manager,
-                              GdmUser        *user)
-{
-        gboolean    can_activate_sessions;
-        GList      *sessions;
-        GList      *l;
-        char       *primary_ssid;
-
-        if (manager->priv->seat_id == NULL || manager->priv->seat_id[0] == '\0') {
-                g_debug ("GdmUserManager: display seat ID is not set; can't switch sessions");
-                return NULL;
-        }
-
-        primary_ssid = NULL;
-        sessions = NULL;
-
-        can_activate_sessions = gdm_user_manager_can_switch (manager);
-
-        if (! can_activate_sessions) {
-                g_debug ("GdmUserManager: seat is unable to activate sessions");
-                goto out;
-        }
-
-        sessions = gdm_user_get_sessions (user);
-        if (sessions == NULL) {
-                g_warning ("unable to determine sessions for user: %s",
-                           gdm_user_get_user_name (user));
-                goto out;
-        }
-
-        for (l = sessions; l != NULL; l = l->next) {
-                const char *ssid;
-
-                ssid = l->data;
-
-                /* FIXME: better way to choose? */
-                if (ssid != NULL) {
-                        primary_ssid = g_strdup (ssid);
-                        break;
-                }
-        }
-
- out:
-
-        return primary_ssid;
-}
-
 static gboolean
 activate_session_id (GdmUserManager *manager,
                      const char     *seat_id,
@@ -446,15 +397,23 @@ gdm_user_manager_activate_user_session (GdmUserManager *manager,
                                         GdmUser        *user)
 {
         gboolean ret;
-        char    *ssid;
+        const char *ssid;
         gboolean res;
 
+        gboolean can_activate_sessions;
         g_return_val_if_fail (GDM_IS_USER_MANAGER (manager), FALSE);
         g_return_val_if_fail (GDM_IS_USER (user), FALSE);
 
         ret = FALSE;
 
-        ssid = _get_primary_user_session_id (manager, user);
+        can_activate_sessions = gdm_user_manager_can_switch (manager);
+
+        if (! can_activate_sessions) {
+                g_debug ("GdmUserManager: seat is unable to activate sessions");
+                goto out;
+        }
+
+        ssid = gdm_user_get_primary_session_id (user);
         if (ssid == NULL) {
                 goto out;
         }
diff --git a/gui/simple-greeter/gdm-user.c b/gui/simple-greeter/gdm-user.c
index 52a2a5f..814280d 100644
--- a/gui/simple-greeter/gdm-user.c
+++ b/gui/simple-greeter/gdm-user.c
@@ -929,3 +929,33 @@ gdm_user_render_icon (GdmUser   *user,
 
         return pixbuf;
 }
+
+G_CONST_RETURN char *
+gdm_user_get_primary_session_id (GdmUser *user)
+{
+        GList *l;
+        const char *primary_ssid;
+
+        primary_ssid = NULL;
+
+        if (!gdm_user_is_logged_in (user)) {
+                g_debug ("User %s is not logged in, so has no primary session",
+                         gdm_user_get_user_name (user));
+                goto out;
+        }
+
+        for (l = user->sessions; l != NULL; l = l->next) {
+                const char *ssid;
+
+                ssid = l->data;
+
+                /* FIXME: better way to choose? */
+                if (ssid != NULL) {
+                        primary_ssid = ssid;
+                        break;
+                }
+        }
+out:
+        return primary_ssid;
+}
+
diff --git a/gui/simple-greeter/gdm-user.h b/gui/simple-greeter/gdm-user.h
index 997b965..4938a51 100644
--- a/gui/simple-greeter/gdm-user.h
+++ b/gui/simple-greeter/gdm-user.h
@@ -48,6 +48,7 @@ guint                 gdm_user_get_num_sessions    (GdmUser   *user);
 GList                *gdm_user_get_sessions        (GdmUser   *user);
 gboolean              gdm_user_is_logged_in        (GdmUser   *user);
 gulong                gdm_user_get_login_frequency (GdmUser   *user);
+G_CONST_RETURN char  *gdm_user_get_primary_session_id (GdmUser *user);
 
 GdkPixbuf            *gdm_user_render_icon         (GdmUser   *user,
                                                     gint       icon_size);



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