]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Fixes a bug that prevents session locking if the session was unlocked after changing...
authorJesús González <jgonzalez@gdr-sistemas.com>
Wed, 11 Feb 2015 23:30:00 +0000 (12:30 +1300)
committerRobert Ancell <robert.ancell@canonical.com>
Wed, 11 Feb 2015 23:30:00 +0000 (12:30 +1300)
1  2 
src/seat.c
tests/src/test-runner.c

diff --combined src/seat.c
index 9a56baf26075af40b67db7ae7e7be05a96f8416a,1e813e8b14af712894611712cef6164c265837ec..b847332739fc78c7800060efe699b649ef72c779
@@@ -269,6 -269,57 +269,54 @@@ seat_get_next_session (Seat *seat
      return seat->priv->next_session;
  }
  
 -    {
+ /**
+  * Obtains the active session which lightdm expects to be active.
+  *
+  * This function is different from seat_get_active_session() in that the
+  * later (in the case of xlocal seats) dynamically finds the session that is
+  * really active (based on the active VT), whereas this function returns the
+  * session that lightdm activated last by itself, which may not be the actual
+  * active session (i.e. VT changes).
+  */
+ Session *
+ seat_get_expected_active_session (Seat *seat)
+ {
+     g_return_val_if_fail (seat != NULL, NULL);
+     return seat->priv->active_session;
+ }
+ /**
+  * Sets the active session which lightdm expects to be active.
+  *
+  * This function is different from seat_set_active_session() in that the
+  * later performs an actual session activation, whereas this function just
+  * updates the active session after the session has been activated by some
+  * means external to lightdm (i.e. VT changes).
+  */
+ void
+ seat_set_externally_activated_session (Seat *seat, Session *session)
+ {
+     g_return_if_fail (seat != NULL);
+     if (seat->priv->active_session)
 -    }
+         g_object_unref (seat->priv->active_session);
 -
+     seat->priv->active_session = g_object_ref (session);
+ }
+ Session *
+ seat_find_session_by_login1_id (Seat *seat, const gchar *login1_session_id)
+ {
+     GList *session_link;
++
+     for (session_link = seat->priv->sessions; session_link; session_link = session_link->next)
+     {
+         Session *session = session_link->data;
 -        {
+         if (g_strcmp0 (login1_session_id, session_get_login1_session_id (session)) == 0)
 -        }
+             return session;
+     }
++
+     return NULL;
+ }
  gboolean
  seat_get_can_switch (Seat *seat)
  {
diff --combined tests/src/test-runner.c
index abad48651f72b15185574d40d89aa39b770244cc,4c62e6fa1c08c81bb34cfa109e884b0faa8f6b36..e66dead8f7b8ce1bf2837423b4d7bfaeaf728459
@@@ -110,6 -110,7 +110,7 @@@ typedef struc
      gchar *path;
      gboolean can_graphical;
      gboolean can_multi_session;
+     gchar *active_session;
  } Login1Seat;
  
  static GList *login1_seats = NULL;
@@@ -142,6 -143,7 +143,7 @@@ static void check_status (const gchar *
  static AccountsUser *get_accounts_user_by_uid (guint uid);
  static AccountsUser *get_accounts_user_by_name (const gchar *username);
  static void accounts_user_set_hidden (AccountsUser *user, gboolean hidden, gboolean emit_signal);
+ static Login1Session *find_login1_session (const gchar *id);
  
  static gboolean
  kill_timeout_cb (gpointer data)
@@@ -567,6 -569,13 +569,13 @@@ handle_command (const gchar *command
                  seat->can_multi_session = strcmp (v, "TRUE") == 0;
                  g_variant_builder_add (&invalidated_properties, "s", "CanMultiSession");
              }
+             v = g_hash_table_lookup (params, "ACTIVE-SESSION");
+             if (v)
+             {
+                 g_free (seat->active_session);
+                 seat->active_session = g_strdup (v);
+                 g_variant_builder_add (&invalidated_properties, "s", "ActiveSession");
+             }
  
              g_dbus_connection_emit_signal (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
                                             NULL,
          check_status (status_text);
          g_free (status_text);
      }
+     else if (strcmp (name, "UNLOCK-SESSION") == 0)
+     {
+         gchar *status_text, *id;
+         Login1Session *session;
+         
+         id = g_hash_table_lookup (params, "SESSION");
+         session = find_login1_session (id);
+         if (session)
+         {
+             if (!session->locked)
+                 g_warning ("Session %s is not locked", id);
+             session->locked = FALSE;
+         }
+         else
+             g_warning ("Unknown session %s", id);
+         status_text = g_strdup_printf ("RUNNER UNLOCK-SESSION SESSION=%s", id);
+         check_status (status_text);
+         g_free (status_text);
+     }
      /* Forward to external processes */
      else if (g_str_has_prefix (name, "SESSION-") ||
               g_str_has_prefix (name, "GREETER-") ||
@@@ -962,6 -991,10 +991,6 @@@ run_commands (void
  
          statuses = g_list_append (statuses, g_strdup (line->text));
          line->done = TRUE;
 -        
 -        if (getenv ("DEBUG"))
 -            g_print ("%s\n", line->text);
 -
  
          handle_command (line->text + 1);
      }
@@@ -1481,6 -1514,22 +1510,22 @@@ handle_login1_seat_get_property (GDBusC
          return g_variant_new_boolean (seat->can_multi_session);
      else if (strcmp (property_name, "Id") == 0)
          return g_variant_new_string (seat->id);
+     else if (strcmp (property_name, "ActiveSession") == 0)
+     {
+         if (seat->active_session)
+         {
+             gchar *path;
+             GVariant *ret;
+             
+             path = g_strdup_printf ("/org/freedesktop/login1/session/%s", seat->active_session);
+             ret = g_variant_new ("(so)", seat->active_session, path);
+             g_free (path);
+             return ret;
+         }
+         else 
+             return NULL;
+     }
      else
          return NULL;
  }
@@@ -1497,6 -1546,7 +1542,7 @@@ add_login1_seat (GDBusConnection *conne
          "  <interface name='org.freedesktop.login1.Seat'>"
          "    <property name='CanGraphical' type='b' access='read'/>"
          "    <property name='CanMultiSession' type='b' access='read'/>"
+         "    <property name='ActiveSession' type='(so)' access='read'/>"
          "    <property name='Id' type='s' access='read'/>"
          "  </interface>"
          "</node>";
      seat->path = g_strdup_printf ("/org/freedesktop/login1/seat/%s", seat->id);
      seat->can_graphical = TRUE;
      seat->can_multi_session = TRUE;
+     seat->active_session = NULL;
  
      login1_seat_info = g_dbus_node_info_new_for_xml (login1_seat_interface, &error);
      if (error)
@@@ -1589,6 -1640,7 +1636,7 @@@ remove_login1_seat (GDBusConnection *co
      login1_seats = g_list_remove (login1_seats, seat);
      g_free (seat->id);
      g_free (seat->path);
+     g_free (seat->active_session);
      g_free (seat);
  }