Commit 6574b4f2 authored by Ray Strode's avatar Ray Strode Committed by Ray Strode

common: dedupe activate_session_id

Right now there are three copies of activate_session_id.

This commit consolidates the code to gdm-common.c
parent 0e9f09da
......@@ -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;
......
......@@ -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 */
......@@ -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);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment