summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2011-09-21 16:47:52 +1000
committerRobert Ancell <robert.ancell@canonical.com>2011-09-21 16:47:52 +1000
commit7d7be54e4365864bd1493f83bd798488491a6223 (patch)
treebd61bf8c88f2df82095a6812314d9daf63a39324
parent4f8c10c307ece13b003e2bb21d59f59ad2938a19 (diff)
downloadlightdm-7d7be54e4365864bd1493f83bd798488491a6223.tar.gz
Put back GetSeatForCookie and GetSessionForCookie for now
-rw-r--r--NEWS5
-rw-r--r--src/lightdm.c80
-rw-r--r--src/session.c7
-rw-r--r--src/session.h2
4 files changed, 92 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 76aa1dde..68d5da98 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,8 @@
Overview of changes in lightdm 0.9.8
- * Remove GetSeatForCookie and GetSessionForCookie now XDG_SEAT_PATH and
- XDG_SESSION_PATH exist.
+ * GetSeatForCookie and GetSessionForCookie are now deprecated. They
+ remain for now but use the XDG_SEAT_PATH and XDG_SESSION_PATH
+ environment variables instead.
* Change log filenames to be unique across different display types.
* Fix up script hooks, add regression tests for them
* Complete removal of X code from the core of LightDM, so it can better
diff --git a/src/lightdm.c b/src/lightdm.c
index 209c5caa..7851ff9b 100644
--- a/src/lightdm.c
+++ b/src/lightdm.c
@@ -220,6 +220,37 @@ set_seat_properties (Seat *seat, const gchar *config_section)
}
}
+static Session *
+get_session_for_cookie (const gchar *cookie, Seat **seat)
+{
+ GList *link;
+
+ for (link = display_manager_get_seats (display_manager); link; link = link->next)
+ {
+ Seat *s = link->data;
+ GList *l;
+
+ for (l = seat_get_displays (s); l; l = l->next)
+ {
+ Display *display = l->data;
+ Session *session;
+
+ session = display_get_session (display);
+ if (!session)
+ continue;
+
+ if (g_strcmp0 (session_get_console_kit_cookie (session), cookie) == 0)
+ {
+ if (seat)
+ *seat = s;
+ return session;
+ }
+ }
+ }
+
+ return NULL;
+}
+
static void
handle_display_manager_call (GDBusConnection *connection,
const gchar *sender,
@@ -305,6 +336,47 @@ handle_display_manager_call (GDBusConnection *connection,
else// FIXME: Need to make proper error
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Failed to start seat");
}
+ /* NOTE: This method is deprecated, use the XSG_SEAT_PATH environment variable instead */
+ else if (g_strcmp0 (method_name, "GetSeatForCookie") == 0)
+ {
+ gchar *cookie;
+ Seat *seat = NULL;
+ BusEntry *entry = NULL;
+
+ if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(s)")))
+ return;
+
+ g_variant_get (parameters, "(&s)", &cookie);
+
+ get_session_for_cookie (cookie, &seat);
+ if (seat)
+ entry = g_hash_table_lookup (seat_bus_entries, seat);
+ if (entry)
+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("(o)", entry->path));
+ else // FIXME: Need to make proper error
+ g_dbus_method_invocation_return_error_literal (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Unable to find seat for cookie");
+ }
+
+ /* NOTE: This method is deprecated, use the XSG_SESSION_PATH environment variable instead */
+ else if (g_strcmp0 (method_name, "GetSessionForCookie") == 0)
+ {
+ gchar *cookie;
+ Session *session;
+ BusEntry *entry = NULL;
+
+ if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(s)")))
+ return;
+
+ g_variant_get (parameters, "(&s)", &cookie);
+
+ session = get_session_for_cookie (cookie, NULL);
+ if (session)
+ entry = g_hash_table_lookup (session_bus_entries, session);
+ if (entry)
+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("(o)", entry->path));
+ else // FIXME: Need to make proper error
+ g_dbus_method_invocation_return_error_literal (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Unable to find session for cookie");
+ }
}
static GVariant *
@@ -604,6 +676,14 @@ bus_acquired_cb (GDBusConnection *connection,
" <arg name='display-number' direction='in' type='i'/>"
" <arg name='seat' direction='out' type='o'/>"
" </method>"
+ " <method name='GetSeatForCookie'>"
+ " <arg name='cookie' direction='in' type='s'/>"
+ " <arg name='seat' direction='out' type='o'/>"
+ " </method>"
+ " <method name='GetSessionForCookie'>"
+ " <arg name='cookie' direction='in' type='s'/>"
+ " <arg name='session' direction='out' type='o'/>"
+ " </method>"
" <signal name='SeatAdded'>"
" <arg name='seat' type='o'/>"
" </signal>"
diff --git a/src/session.c b/src/session.c
index f7d157a2..2d1ac8a6 100644
--- a/src/session.c
+++ b/src/session.c
@@ -167,6 +167,13 @@ session_set_console_kit_parameter (Session *session, const gchar *name, GVariant
g_hash_table_insert (session->priv->console_kit_parameters, g_strdup (name), value);
}
+const gchar *
+session_get_console_kit_cookie (Session *session)
+{
+ g_return_val_if_fail (session != NULL, NULL);
+ return session->priv->console_kit_cookie;
+}
+
/* Set the LANG variable based on the chosen language. This is not a great
* solution, as it will override the language set in PAM (which is where it
* should be set). It's also overly simplistic to set all the locale
diff --git a/src/session.h b/src/session.h
index c61d476d..bfda1792 100644
--- a/src/session.h
+++ b/src/session.h
@@ -61,6 +61,8 @@ const gchar *session_get_env (Session *session, const gchar *name);
void session_set_console_kit_parameter (Session *session, const gchar *name, GVariant *value);
+const gchar *session_get_console_kit_cookie (Session *session);
+
gboolean session_start (Session *session);
void session_unlock (Session *session);