[gdm/multi-stack: 5/31] Drop session "Open" in favor of "StartConversation"
- From: Ray Strode <halfline src gnome org>
- To: svn-commits-list gnome org
- Subject: [gdm/multi-stack: 5/31] Drop session "Open" in favor of "StartConversation"
- Date: Fri, 17 Apr 2009 10:25:58 -0400 (EDT)
commit b1fbbdad6d4fd847b248aaad7eec9a8730714b06
Author: Ray Strode <rstrode redhat com>
Date: Fri Jan 16 11:00:08 2009 -0500
Drop session "Open" in favor of "StartConversation"
We want to eventually support having multiple
simultaneous PAM conversations in one login
screen (so, e.g., username/password, smart card, and
fingerprint all work at the same time).
This commit refactors the session code to be in terms
of a conversation object. With this change, it should
be easier later to have multiple conversation objects.
The conversation is named by the pam service the login
screen is talking to.
---
daemon/gdm-factory-slave.c | 13 +-
daemon/gdm-product-slave.c | 47 ++++--
daemon/gdm-session-direct.c | 327 ++++++++++++++++++++++++---------------
daemon/gdm-session-private.h | 3 +-
daemon/gdm-session-relay.c | 29 +++--
daemon/gdm-session-worker-job.c | 7 +
daemon/gdm-session-worker-job.h | 2 +
daemon/gdm-session.c | 20 ++-
daemon/gdm-session.h | 9 +-
daemon/gdm-simple-slave.c | 3 -
daemon/test-session.c | 13 +-
11 files changed, 296 insertions(+), 177 deletions(-)
diff --git a/daemon/gdm-factory-slave.c b/daemon/gdm-factory-slave.c
index d09c913..6497293 100644
--- a/daemon/gdm-factory-slave.c
+++ b/daemon/gdm-factory-slave.c
@@ -180,10 +180,11 @@ on_session_secret_info_query (GdmSession *session,
}
static void
-on_session_opened (GdmSession *session,
- GdmFactorySlave *slave)
+on_session_conversation_started (GdmSession *session,
+ GdmFactorySlave *slave,
+ const char *service_name)
{
- g_debug ("GdmFactorySlave: session opened");
+ g_debug ("GdmFactorySlave: session conversation started");
gdm_greeter_server_ready (slave->priv->greeter_server);
}
@@ -367,7 +368,7 @@ on_session_relay_connected (GdmSessionRelay *session,
{
g_debug ("GdmFactorySlave: Relay Connected");
- gdm_session_open (GDM_SESSION (slave->priv->session));
+ gdm_session_start_conversation (GDM_SESSION (slave->priv->session), "gdm");
}
static void
@@ -694,8 +695,8 @@ gdm_factory_slave_start (GdmSlave *slave)
GDM_FACTORY_SLAVE (slave)->priv->session = gdm_session_relay_new ();
g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
- "opened",
- G_CALLBACK (on_session_opened),
+ "conversation-started",
+ G_CALLBACK (on_session_conversation_started),
slave);
g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
"setup-complete",
diff --git a/daemon/gdm-product-slave.c b/daemon/gdm-product-slave.c
index 9adcb09..15a2820 100644
--- a/daemon/gdm-product-slave.c
+++ b/daemon/gdm-product-slave.c
@@ -246,19 +246,21 @@ relay_session_started (GdmProductSlave *slave,
}
static void
-relay_session_opened (GdmProductSlave *slave)
+relay_session_conversation_started (GdmProductSlave *slave,
+ const char *service_name)
{
- send_dbus_void_method (slave->priv->session_relay_connection,
- "Opened");
+ send_dbus_string_method (slave->priv->session_relay_connection,
+ "ConversationStarted", service_name);
}
static void
-on_session_opened (GdmSession *session,
- GdmProductSlave *slave)
+on_session_conversation_started (GdmSession *session,
+ const char *service_name,
+ GdmProductSlave *slave)
{
- g_debug ("GdmProductSlave: session opened");
+ g_debug ("GdmProductSlave: session conversation started");
- relay_session_opened (slave);
+ relay_session_conversation_started (slave, service_name);
}
static void
@@ -784,10 +786,27 @@ on_relay_user_selected (GdmProductSlave *slave,
}
static void
-on_relay_open (GdmProductSlave *slave,
- DBusMessage *message)
+on_relay_start_conversation (GdmProductSlave *slave,
+ DBusMessage *message)
{
- gdm_session_open (GDM_SESSION (slave->priv->session));
+ DBusError error;
+ char *service_name;
+ dbus_bool_t res;
+
+ dbus_error_init (&error);
+ res = dbus_message_get_args (message,
+ &error,
+ DBUS_TYPE_STRING, &service_name,
+ DBUS_TYPE_INVALID);
+ if (res) {
+ g_debug ("GdmProductSlave: Started conversation with %s service", service_name);
+ gdm_session_start_conversation (GDM_SESSION (slave->priv->session),
+ service_name);
+ } else {
+ g_warning ("Unable to get arguments: %s", error.message);
+ }
+
+ dbus_error_free (&error);
}
static void
@@ -832,8 +851,8 @@ create_new_session (GdmProductSlave *slave)
g_free (display_device);
g_signal_connect (slave->priv->session,
- "opened",
- G_CALLBACK (on_session_opened),
+ "conversation-started",
+ G_CALLBACK (on_session_conversation_started),
slave);
g_signal_connect (slave->priv->session,
"setup-complete",
@@ -991,8 +1010,8 @@ relay_dbus_handle_message (DBusConnection *connection,
on_relay_user_selected (slave, message);
} else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "StartSession")) {
on_relay_start_session (slave, message);
- } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "Open")) {
- on_relay_open (slave, message);
+ } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "StartConversation")) {
+ on_relay_start_conversation (slave, message);
} else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "Cancelled")) {
on_relay_cancelled (slave, message);
} else {
diff --git a/daemon/gdm-session-direct.c b/daemon/gdm-session-direct.c
index 3942ec7..304a67b 100644
--- a/daemon/gdm-session-direct.c
+++ b/daemon/gdm-session-direct.c
@@ -61,6 +61,16 @@
#define GDM_SESSION_DEFAULT_PATH "/usr/local/bin:/usr/bin:/bin"
#endif
+typedef struct
+{
+ GdmSessionDirect *session;
+ GdmSessionWorkerJob *job;
+ GPid worker_pid;
+ char *service_name;
+ DBusConnection *worker_connection;
+ DBusMessage *message_pending_reply;
+} GdmSessionConversation;
+
struct _GdmSessionDirectPrivate
{
/* per open scope */
@@ -73,13 +83,11 @@ struct _GdmSessionDirectPrivate
char *selected_user;
char *user_x11_authority_file;
- DBusMessage *message_pending_reply;
- DBusConnection *worker_connection;
+ GdmSessionConversation *conversation;
- GdmSessionWorkerJob *job;
- GPid session_pid;
guint32 is_authenticated : 1;
guint32 is_running : 1;
+ GPid session_pid;
/* object lifetime scope */
char *id;
@@ -116,39 +124,39 @@ G_DEFINE_TYPE_WITH_CODE (GdmSessionDirect,
gdm_session_iface_init))
static gboolean
-send_dbus_message (DBusConnection *connection,
- DBusMessage *message)
+send_dbus_message (GdmSessionConversation *conversation,
+ DBusMessage *message)
{
gboolean is_connected;
gboolean sent;
g_return_val_if_fail (message != NULL, FALSE);
- if (connection == NULL) {
+ if (conversation->worker_connection == NULL) {
g_warning ("There is no valid connection");
return FALSE;
}
- is_connected = dbus_connection_get_is_connected (connection);
+ is_connected = dbus_connection_get_is_connected (conversation->worker_connection);
if (! is_connected) {
g_warning ("Not connected!");
return FALSE;
}
- sent = dbus_connection_send (connection, message, NULL);
+ sent = dbus_connection_send (conversation->worker_connection, message, NULL);
return sent;
}
static void
-send_dbus_string_signal (GdmSessionDirect *session,
+send_dbus_string_signal (GdmSessionConversation *conversation,
const char *name,
const char *text)
{
DBusMessage *message;
DBusMessageIter iter;
- g_return_if_fail (session != NULL);
+ g_return_if_fail (conversation != NULL);
message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
GDM_SESSION_DBUS_INTERFACE,
@@ -157,7 +165,7 @@ send_dbus_string_signal (GdmSessionDirect *session,
dbus_message_iter_init_append (message, &iter);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &text);
- if (! send_dbus_message (session->priv->worker_connection, message)) {
+ if (! send_dbus_message (conversation, message)) {
g_debug ("GdmSessionDirect: Could not send %s signal", name);
}
@@ -165,18 +173,18 @@ send_dbus_string_signal (GdmSessionDirect *session,
}
static void
-send_dbus_void_signal (GdmSessionDirect *session,
- const char *name)
+send_dbus_void_signal (GdmSessionConversation *conversation,
+ const char *name)
{
DBusMessage *message;
- g_return_if_fail (session != NULL);
+ g_return_if_fail (conversation != NULL);
message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
GDM_SESSION_DBUS_INTERFACE,
name);
- if (! send_dbus_message (session->priv->worker_connection, message)) {
+ if (! send_dbus_message (conversation, message)) {
g_debug ("GdmSessionDirect: Could not send %s signal", name);
}
@@ -188,22 +196,32 @@ on_authentication_failed (GdmSession *session,
const char *message)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
- gdm_session_record_failed (impl->priv->session_pid,
- impl->priv->selected_user,
- impl->priv->display_hostname,
- impl->priv->display_name,
- impl->priv->display_device);
+ GdmSessionConversation *conversation;
+
+ conversation = impl->priv->conversation;
+ if (conversation != NULL) {
+ gdm_session_record_failed (conversation->worker_pid,
+ impl->priv->selected_user,
+ impl->priv->display_hostname,
+ impl->priv->display_name,
+ impl->priv->display_device);
+ }
}
static void
on_session_started (GdmSession *session)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
- gdm_session_record_login (impl->priv->session_pid,
- impl->priv->selected_user,
- impl->priv->display_hostname,
- impl->priv->display_name,
- impl->priv->display_device);
+ GdmSessionConversation *conversation;
+
+ conversation = impl->priv->conversation;
+ if (conversation != NULL) {
+ gdm_session_record_login (conversation->worker_pid,
+ impl->priv->selected_user,
+ impl->priv->display_hostname,
+ impl->priv->display_name,
+ impl->priv->display_device);
+ }
}
static void
@@ -211,11 +229,16 @@ on_session_start_failed (GdmSession *session,
const char *message)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
- gdm_session_record_login (impl->priv->session_pid,
- impl->priv->selected_user,
- impl->priv->display_hostname,
- impl->priv->display_name,
- impl->priv->display_device);
+ GdmSessionConversation *conversation;
+
+ conversation = impl->priv->conversation;
+ if (conversation != NULL) {
+ gdm_session_record_login (conversation->worker_pid,
+ impl->priv->selected_user,
+ impl->priv->display_hostname,
+ impl->priv->display_name,
+ impl->priv->display_device);
+ }
}
static void
@@ -223,6 +246,7 @@ on_session_exited (GdmSession *session,
int exit_code)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+
gdm_session_record_logout (impl->priv->session_pid,
impl->priv->selected_user,
impl->priv->display_hostname,
@@ -731,25 +755,26 @@ gdm_session_direct_handle_username_changed (GdmSessionDirect *session,
}
static void
-cancel_pending_query (GdmSessionDirect *session)
+cancel_pending_query (GdmSessionConversation *conversation)
{
DBusMessage *reply;
- if (session->priv->message_pending_reply == NULL) {
+ if (conversation->message_pending_reply == NULL) {
return;
}
g_debug ("GdmSessionDirect: Cancelling pending query");
- reply = dbus_message_new_error (session->priv->message_pending_reply,
+ reply = dbus_message_new_error (conversation->message_pending_reply,
GDM_SESSION_DBUS_ERROR_CANCEL,
"Operation cancelled");
- dbus_connection_send (session->priv->worker_connection, reply, NULL);
- dbus_connection_flush (session->priv->worker_connection);
+ conversation = session->priv->conversation;
+ dbus_connection_send (conversation->worker_connection, reply, NULL);
+ dbus_connection_flush (conversation->worker_connection);
dbus_message_unref (reply);
- dbus_message_unref (session->priv->message_pending_reply);
- session->priv->message_pending_reply = NULL;
+ dbus_message_unref (conversation->message_pending_reply);
+ conversation->message_pending_reply = NULL;
}
static void
@@ -758,27 +783,29 @@ answer_pending_query (GdmSessionDirect *session,
{
DBusMessage *reply;
DBusMessageIter iter;
+ GdmSessionConversation *conversation;
- g_assert (session->priv->message_pending_reply != NULL);
+ conversation = find_conversation_by_name (session, service_name);
- reply = dbus_message_new_method_return (session->priv->message_pending_reply);
+ reply = dbus_message_new_method_return (conversation->message_pending_reply);
dbus_message_iter_init_append (reply, &iter);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &answer);
- dbus_connection_send (session->priv->worker_connection, reply, NULL);
+ conversation = session->priv->conversation;
+ dbus_connection_send (conversation->worker_connection, reply, NULL);
dbus_message_unref (reply);
- dbus_message_unref (session->priv->message_pending_reply);
- session->priv->message_pending_reply = NULL;
+ dbus_message_unref (conversation->message_pending_reply);
+ conversation->message_pending_reply = NULL;
}
static void
-set_pending_query (GdmSessionDirect *session,
- DBusMessage *message)
+set_pending_query (GdmSessionConversation *conversation,
+ DBusMessage *message)
{
- g_assert (session->priv->message_pending_reply == NULL);
+ g_assert (conversation->message_pending_reply == NULL);
- session->priv->message_pending_reply = dbus_message_ref (message);
+ conversation->message_pending_reply = dbus_message_ref (message);
}
static DBusHandlerResult
@@ -796,7 +823,7 @@ gdm_session_direct_handle_info_query (GdmSessionDirect *session,
g_warning ("ERROR: %s", error.message);
}
- set_pending_query (session, message);
+ set_pending_query (conversation, message);
g_debug ("GdmSessionDirect: Emitting 'info-query' signal");
_gdm_session_info_query (GDM_SESSION (session), text);
@@ -819,7 +846,7 @@ gdm_session_direct_handle_secret_info_query (GdmSessionDirect *session,
g_warning ("ERROR: %s", error.message);
}
- set_pending_query (session, message);
+ set_pending_query (conversation, message);
g_debug ("GdmSessionDirect: Emitting 'secret-info-query' signal");
_gdm_session_secret_info_query (GDM_SESSION (session), text);
@@ -861,7 +888,7 @@ gdm_session_direct_handle_cancel_pending_query (GdmSessionDirect *session,
DBusMessage *reply;
g_debug ("GdmSessionDirect: worker cancelling pending query");
- cancel_pending_query (session);
+ cancel_pending_query (conversation);
reply = dbus_message_new_method_return (message);
dbus_connection_send (connection, reply, NULL);
@@ -1439,16 +1466,18 @@ handle_connection (DBusServer *server,
void *user_data)
{
GdmSessionDirect *session = GDM_SESSION_DIRECT (user_data);
+ GdmSessionConversation *conversation;
g_debug ("GdmSessionDirect: Handing new connection");
- if (session->priv->worker_connection == NULL) {
+ conversation = session->priv->conversation;
+ if (conversation->worker_connection == NULL) {
DBusObjectPathVTable vtable = { &session_unregister_handler,
&session_message_handler,
NULL, NULL, NULL, NULL
};
- session->priv->worker_connection = new_connection;
+ conversation->worker_connection = new_connection;
dbus_connection_ref (new_connection);
dbus_connection_setup_with_g_main (new_connection, NULL);
@@ -1465,8 +1494,9 @@ handle_connection (DBusServer *server,
&vtable,
session);
- g_debug ("GdmSessionDirect: Emitting opened signal");
- _gdm_session_opened (GDM_SESSION (session));
+ g_debug ("GdmSessionDirect: Emitting conversation-started signal");
+ _gdm_session_conversation_started (GDM_SESSION (session),
+ conversation->service_name);
}
}
@@ -1536,8 +1566,6 @@ gdm_session_direct_init (GdmSessionDirect *session)
G_CALLBACK (on_session_exited),
NULL);
- session->priv->session_pid = -1;
-
session->priv->environment = g_hash_table_new_full (g_str_hash,
g_str_equal,
(GDestroyNotify) g_free,
@@ -1549,7 +1577,7 @@ gdm_session_direct_init (GdmSessionDirect *session)
static void
worker_started (GdmSessionWorkerJob *job,
- GdmSessionDirect *session)
+ GdmSessionConversation *conversation)
{
g_debug ("GdmSessionDirect: Worker job started");
}
@@ -1557,99 +1585,119 @@ worker_started (GdmSessionWorkerJob *job,
static void
worker_exited (GdmSessionWorkerJob *job,
int code,
- GdmSessionDirect *session)
+ GdmSessionConversation *conversation)
{
g_debug ("GdmSessionDirect: Worker job exited: %d", code);
- if (!session->priv->is_authenticated) {
+ if (!conversation->session->priv->is_authenticated) {
char *msg;
msg = g_strdup_printf (_("worker exited with status %d"), code);
- _gdm_session_authentication_failed (GDM_SESSION (session), msg);
+ _gdm_session_authentication_failed (GDM_SESSION (conversation->session), msg);
g_free (msg);
- } else if (session->priv->is_running) {
- _gdm_session_session_exited (GDM_SESSION (session), code);
+ } else if (conversation->session->priv->is_running) {
+ _gdm_session_session_exited (GDM_SESSION (conversation->session), code);
}
}
static void
worker_died (GdmSessionWorkerJob *job,
int signum,
- GdmSessionDirect *session)
+ GdmSessionConversation *conversation)
{
g_debug ("GdmSessionDirect: Worker job died: %d", signum);
- if (!session->priv->is_authenticated) {
+ if (!conversation->session->priv->is_authenticated) {
char *msg;
msg = g_strdup_printf (_("worker exited with status %d"), signum);
- _gdm_session_authentication_failed (GDM_SESSION (session), msg);
+ _gdm_session_authentication_failed (GDM_SESSION (conversation->session), msg);
g_free (msg);
- } else if (session->priv->is_running) {
- _gdm_session_session_died (GDM_SESSION (session), signum);
+ } else if (conversation->session->priv->is_running) {
+ _gdm_session_session_died (GDM_SESSION (conversation->session), signum);
}
}
-static gboolean
-start_worker (GdmSessionDirect *session)
+static GdmSessionConversation *
+start_conversation (GdmSessionDirect *session,
+ const char *service_name)
{
- gboolean res;
+ GdmSessionConversation *conversation;
- session->priv->job = gdm_session_worker_job_new ();
- gdm_session_worker_job_set_server_address (session->priv->job, session->priv->server_address);
- g_signal_connect (session->priv->job,
+ conversation = g_new0 (GdmSessionConversation, 1);
+ conversation->session = session;
+ conversation->service_name = g_strdup (service_name);
+ conversation->worker_pid = -1;
+ conversation->job = gdm_session_worker_job_new ();
+ gdm_session_worker_job_set_server_address (conversation->job, session->priv->server_address);
+ g_signal_connect (conversation->job,
"started",
G_CALLBACK (worker_started),
- session);
- g_signal_connect (session->priv->job,
+ conversation);
+ g_signal_connect (conversation->job,
"exited",
G_CALLBACK (worker_exited),
- session);
- g_signal_connect (session->priv->job,
+ conversation);
+ g_signal_connect (conversation->job,
"died",
G_CALLBACK (worker_died),
- session);
+ conversation);
- res = gdm_session_worker_job_start (session->priv->job);
+ if (!gdm_session_worker_job_start (conversation->job)) {
+ g_object_unref (conversation->job);
+ g_free (conversation->service_name);
+ g_free (conversation);
+ return NULL;
+ }
- return res;
+ conversation->worker_pid = gdm_session_worker_job_get_pid (conversation->job);
+
+ return conversation;
}
static void
-stop_worker (GdmSessionDirect *session)
+stop_conversation (GdmSessionConversation *conversation)
{
- g_signal_handlers_disconnect_by_func (session->priv->job,
+ GdmSessionDirect *session;
+
+ session = conversation->session;
+
+ g_signal_handlers_disconnect_by_func (conversation->job,
G_CALLBACK (worker_started),
- session);
- g_signal_handlers_disconnect_by_func (session->priv->job,
+ conversation);
+ g_signal_handlers_disconnect_by_func (conversation->job,
G_CALLBACK (worker_exited),
- session);
- g_signal_handlers_disconnect_by_func (session->priv->job,
+ conversation);
+ g_signal_handlers_disconnect_by_func (conversation->job,
G_CALLBACK (worker_died),
- session);
+ conversation);
cancel_pending_query (session);
- if (session->priv->worker_connection != NULL) {
- dbus_connection_close (session->priv->worker_connection);
- session->priv->worker_connection = NULL;
+ if (conversation->worker_connection != NULL) {
+ dbus_connection_remove_filter (conversation->worker_connection, on_message, session);
+
+ dbus_connection_close (conversation->worker_connection);
+ conversation->worker_connection = NULL;
}
- gdm_session_worker_job_stop (session->priv->job);
- g_object_unref (session->priv->job);
- session->priv->job = NULL;
+ gdm_session_worker_job_stop (conversation->job);
+ g_object_unref (conversation->job);
+ g_free (conversation->service_name);
+ g_free (conversation);
}
static void
-gdm_session_direct_open (GdmSession *session)
+gdm_session_direct_start_conversation (GdmSession *session,
+ const char *service_name)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
g_return_if_fail (session != NULL);
- g_debug ("GdmSessionDirect: Opening session");
+ g_debug ("GdmSessionDirect: starting conversation");
- start_worker (impl);
+ impl->priv->conversation = start_conversation (impl, service_name);
}
static void
@@ -1662,6 +1710,7 @@ send_setup (GdmSessionDirect *session,
const char *display_device;
const char *display_hostname;
const char *display_x11_authority_file;
+ GdmSessionConversation *conversation;
g_assert (service_name != NULL);
@@ -1699,7 +1748,8 @@ send_setup (GdmSessionDirect *session,
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_hostname);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_x11_authority_file);
- if (! send_dbus_message (session->priv->worker_connection, message)) {
+ conversation = session->priv->conversation;
+ if (! send_dbus_message (conversation, message)) {
g_debug ("GdmSessionDirect: Could not send %s signal", "Setup");
}
@@ -1717,6 +1767,7 @@ send_setup_for_user (GdmSessionDirect *session,
const char *display_hostname;
const char *display_x11_authority_file;
const char *selected_user;
+ GdmSessionConversation *conversation;
g_assert (service_name != NULL);
@@ -1760,7 +1811,8 @@ send_setup_for_user (GdmSessionDirect *session,
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_x11_authority_file);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &selected_user);
- if (! send_dbus_message (session->priv->worker_connection, message)) {
+ conversation = session->priv->conversation;
+ if (! send_dbus_message (conversation, message)) {
g_debug ("GdmSessionDirect: Could not send %s signal", "SetupForUser");
}
@@ -1774,7 +1826,8 @@ gdm_session_direct_setup (GdmSession *session,
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
g_return_if_fail (session != NULL);
- g_return_if_fail (dbus_connection_get_is_connected (impl->priv->worker_connection));
+ g_return_if_fail (impl->priv->conversation != NULL);
+ g_return_if_fail (dbus_connection_get_is_connected (impl->priv->conversation->worker_connection));
send_setup (impl, service_name);
gdm_session_direct_defaults_changed (impl);
@@ -1788,7 +1841,8 @@ gdm_session_direct_setup_for_user (GdmSession *session,
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
g_return_if_fail (session != NULL);
- g_return_if_fail (dbus_connection_get_is_connected (impl->priv->worker_connection));
+ g_return_if_fail (impl->priv->conversation != NULL);
+ g_return_if_fail (dbus_connection_get_is_connected (impl->priv->conversation->worker_connection));
g_return_if_fail (username != NULL);
gdm_session_direct_select_user (session, username);
@@ -1801,22 +1855,28 @@ static void
gdm_session_direct_authenticate (GdmSession *session)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+ GdmSessionConversation *conversation;
g_return_if_fail (session != NULL);
- g_return_if_fail (dbus_connection_get_is_connected (impl->priv->worker_connection));
+ g_return_if_fail (impl->priv->conversation != NULL);
+ g_return_if_fail (dbus_connection_get_is_connected (impl->priv->conversation->worker_connection));
- send_dbus_void_signal (impl, "Authenticate");
+ conversation = impl->priv->conversation;
+ send_dbus_void_signal (conversation, "Authenticate");
}
static void
gdm_session_direct_authorize (GdmSession *session)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+ GdmSessionConversation *conversation;
g_return_if_fail (session != NULL);
- g_return_if_fail (dbus_connection_get_is_connected (impl->priv->worker_connection));
+ g_return_if_fail (impl->priv->conversation != NULL);
+ g_return_if_fail (dbus_connection_get_is_connected (impl->priv->conversation->worker_connection));
- send_dbus_void_signal (impl, "Authorize");
+ conversation = impl->priv->conversation;
+ send_dbus_void_signal (conversation, "Authorize");
}
static void
@@ -1824,16 +1884,19 @@ gdm_session_direct_accredit (GdmSession *session,
int cred_flag)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+ GdmSessionConversation *conversation;
g_return_if_fail (session != NULL);
- g_return_if_fail (dbus_connection_get_is_connected (impl->priv->worker_connection));
+ g_return_if_fail (impl->priv->conversation != NULL);
+ g_return_if_fail (dbus_connection_get_is_connected (impl->priv->conversation->worker_connection));
+ conversation = impl->priv->conversation;
switch (cred_flag) {
case GDM_SESSION_CRED_ESTABLISH:
- send_dbus_void_signal (impl, "EstablishCredentials");
+ send_dbus_void_signal (conversation, "EstablishCredentials");
break;
case GDM_SESSION_CRED_REFRESH:
- send_dbus_void_signal (impl, "RefreshCredentials");
+ send_dbus_void_signal (conversation, "RefreshCredentials");
break;
default:
g_assert_not_reached ();
@@ -1847,6 +1910,7 @@ send_environment_variable (const char *key,
{
DBusMessage *message;
DBusMessageIter iter;
+ GdmSessionConversation *conversation;
message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH,
GDM_SESSION_DBUS_INTERFACE,
@@ -1856,7 +1920,8 @@ send_environment_variable (const char *key,
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &key);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &value);
- if (! send_dbus_message (session->priv->worker_connection, message)) {
+ conversation = session->priv->conversation;
+ if (! send_dbus_message (conversation, message)) {
g_debug ("GdmSessionDirect: Could not send %s signal", "SetEnvironmentVariable");
}
@@ -1986,6 +2051,7 @@ static void
gdm_session_direct_start_session (GdmSession *session)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+ GdmSessionConversation *conversation;
char *command;
char *program;
@@ -1999,7 +2065,8 @@ gdm_session_direct_start_session (GdmSession *session)
setup_session_environment (impl);
send_environment (impl);
- send_dbus_string_signal (impl, "StartProgram", program);
+ conversation = impl->priv->conversation;
+ send_dbus_string_signal (conversation, "StartProgram", program);
g_free (program);
}
@@ -2012,16 +2079,12 @@ gdm_session_direct_close (GdmSession *session)
g_debug ("GdmSessionDirect: Closing session");
- if (impl->priv->job != NULL) {
- if (impl->priv->is_running) {
- gdm_session_record_logout (impl->priv->session_pid,
- impl->priv->selected_user,
- impl->priv->display_hostname,
- impl->priv->display_name,
- impl->priv->display_device);
- }
-
- stop_worker (impl);
+ if (impl->priv->is_running) {
+ gdm_session_record_logout (impl->priv->session_pid,
+ impl->priv->selected_user,
+ impl->priv->display_hostname,
+ impl->priv->display_name,
+ impl->priv->display_device);
}
g_free (impl->priv->selected_user);
@@ -2050,7 +2113,6 @@ gdm_session_direct_close (GdmSession *session)
g_hash_table_remove_all (impl->priv->environment);
- impl->priv->session_pid = -1;
impl->priv->is_authenticated = FALSE;
impl->priv->is_running = FALSE;
}
@@ -2070,10 +2132,19 @@ static void
gdm_session_direct_cancel (GdmSession *session)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+ GHashTableIter iter;
+ gpointer key, value;
g_return_if_fail (session != NULL);
- cancel_pending_query (impl);
+ g_hash_table_iter_init (&iter, impl->priv->conversations);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ GdmSessionConversation *conversation;
+
+ conversation = (GdmSessionConversation *) value;
+
+ cancel_pending_query (conversation);
+ }
}
char *
@@ -2089,6 +2160,7 @@ gdm_session_direct_select_session (GdmSession *session,
const char *text)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+ GdmSessionConversation *conversation;
g_free (impl->priv->selected_session);
@@ -2098,7 +2170,8 @@ gdm_session_direct_select_session (GdmSession *session,
impl->priv->selected_session = g_strdup (text);
}
- send_dbus_string_signal (impl, "SetSessionName",
+ conversation = impl->priv->conversation;
+ send_dbus_string_signal (conversation, "SetSessionName",
get_session_name (impl));
}
@@ -2107,6 +2180,7 @@ gdm_session_direct_select_language (GdmSession *session,
const char *text)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+ GdmSessionConversation *conversation;
g_free (impl->priv->selected_language);
@@ -2116,7 +2190,8 @@ gdm_session_direct_select_language (GdmSession *session,
impl->priv->selected_language = g_strdup (text);
}
- send_dbus_string_signal (impl, "SetLanguageName",
+ conversation = impl->priv->conversation;
+ send_dbus_string_signal (conversation, "SetLanguageName",
get_language_name (impl));
}
@@ -2125,6 +2200,7 @@ gdm_session_direct_select_layout (GdmSession *session,
const char *text)
{
GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+ GdmSessionConversation *conversation;
g_free (impl->priv->selected_layout);
@@ -2134,7 +2210,8 @@ gdm_session_direct_select_layout (GdmSession *session,
impl->priv->selected_layout = g_strdup (text);
}
- send_dbus_string_signal (impl, "SetLayoutName",
+ conversation = impl->priv->conversation;
+ send_dbus_string_signal (conversation, "SetLayoutName",
get_layout_name (impl));
}
@@ -2394,7 +2471,7 @@ gdm_session_direct_constructor (GType type,
static void
gdm_session_iface_init (GdmSessionIface *iface)
{
- iface->open = gdm_session_direct_open;
+ iface->start_conversation = gdm_session_direct_start_conversation;
iface->setup = gdm_session_direct_setup;
iface->setup_for_user = gdm_session_direct_setup_for_user;
iface->authenticate = gdm_session_direct_authenticate;
diff --git a/daemon/gdm-session-private.h b/daemon/gdm-session-private.h
index 6a6fcfc..074aa6f 100644
--- a/daemon/gdm-session-private.h
+++ b/daemon/gdm-session-private.h
@@ -27,7 +27,8 @@
G_BEGIN_DECLS
/* state changes */
-void _gdm_session_opened (GdmSession *session);
+void _gdm_session_conversation_started (GdmSession *session,
+ const char *service_name);
void _gdm_session_setup_complete (GdmSession *session);
void _gdm_session_setup_failed (GdmSession *session,
const char *message);
diff --git a/daemon/gdm-session-relay.c b/daemon/gdm-session-relay.c
index b57bf89..35b4738 100644
--- a/daemon/gdm-session-relay.c
+++ b/daemon/gdm-session-relay.c
@@ -180,10 +180,11 @@ send_dbus_void_signal (GdmSessionRelay *session_relay,
}
static void
-gdm_session_relay_open (GdmSession *session)
+gdm_session_relay_start_conversation (GdmSession *session,
+ const char *service_name)
{
GdmSessionRelay *impl = GDM_SESSION_RELAY (session);
- send_dbus_void_signal (impl, "Open");
+ send_dbus_string_signal (impl, "StartConversation", service_name);
}
static void
@@ -664,22 +665,28 @@ handle_session_stopped (GdmSessionRelay *session_relay,
}
static DBusHandlerResult
-handle_opened (GdmSessionRelay *session_relay,
+handle_conversation_started (GdmSessionRelay *session_relay,
DBusConnection *connection,
DBusMessage *message)
{
DBusMessage *reply;
DBusError error;
+ char *service_name;
dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &service_name,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
- g_debug ("GdmSessionRelay: Opened");
+ g_debug ("GdmSessionRelay: Conversation Started");
reply = dbus_message_new_method_return (message);
dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
- _gdm_session_opened (GDM_SESSION (session_relay));
+ _gdm_session_conversation_started (GDM_SESSION (session_relay), service_name);
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -719,8 +726,8 @@ session_handle_child_message (DBusConnection *connection,
return handle_session_started (session_relay, connection, message);
} else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "SessionStopped")) {
return handle_session_stopped (session_relay, connection, message);
- } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Opened")) {
- return handle_opened (session_relay, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "ConversationStarted")) {
+ return handle_conversation_started (session_relay, connection, message);
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -749,7 +756,8 @@ do_introspect (DBusConnection *connection,
/* interface */
xml = g_string_append (xml,
" <interface name=\"org.gnome.DisplayManager.SessionRelay\">\n"
- " <method name=\"Opened\">\n"
+ " <method name=\"ConversationStarted\">\n"
+ " <arg name=\"service_name\" direction=\"in\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"SetupComplete\">\n"
" </method>\n"
@@ -810,7 +818,8 @@ do_introspect (DBusConnection *connection,
" <signal name=\"RefreshCredentials\">\n"
" </signal>\n"
- " <signal name=\"Open\">\n"
+ " <signal name=\"StartConversation\">\n"
+ " <arg name=\"service_name\" type=\"s\"/>\n"
" </signal>\n"
" <signal name=\"Close\">\n"
" </signal>\n"
@@ -1106,7 +1115,7 @@ static void
gdm_session_iface_init (GdmSessionIface *iface)
{
- iface->open = gdm_session_relay_open;
+ iface->start_conversation = gdm_session_relay_start_conversation;
iface->setup = gdm_session_relay_setup;
iface->setup_for_user = gdm_session_relay_setup_for_user;
iface->authenticate = gdm_session_relay_authenticate;
diff --git a/daemon/gdm-session-worker-job.c b/daemon/gdm-session-worker-job.c
index 633d6e2..9c020fa 100644
--- a/daemon/gdm-session-worker-job.c
+++ b/daemon/gdm-session-worker-job.c
@@ -296,6 +296,13 @@ gdm_session_worker_job_stop (GdmSessionWorkerJob *session_worker_job)
return TRUE;
}
+GPid
+gdm_session_worker_job_get_pid (GdmSessionWorkerJob *session_worker_job)
+{
+ g_return_val_if_fail (GDM_IS_SESSION_WORKER_JOB (session_worker_job), 0);
+ return session_worker_job->priv->pid;
+}
+
void
gdm_session_worker_job_set_server_address (GdmSessionWorkerJob *session_worker_job,
const char *address)
diff --git a/daemon/gdm-session-worker-job.h b/daemon/gdm-session-worker-job.h
index 5ad1c92..d24f025 100644
--- a/daemon/gdm-session-worker-job.h
+++ b/daemon/gdm-session-worker-job.h
@@ -60,6 +60,8 @@ void gdm_session_worker_job_set_server_address (GdmSessionWor
gboolean gdm_session_worker_job_start (GdmSessionWorkerJob *session_worker_job);
gboolean gdm_session_worker_job_stop (GdmSessionWorkerJob *session_worker_job);
+GPid gdm_session_worker_job_get_pid (GdmSessionWorkerJob *session_worker_job);
+
G_END_DECLS
#endif /* __GDM_SESSION_WORKER_JOB_H */
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
index feb7938..0073294 100644
--- a/daemon/gdm-session.c
+++ b/daemon/gdm-session.c
@@ -28,7 +28,7 @@
#include "gdm-session-private.h"
enum {
- OPENED = 0,
+ CONVERSATION_STARTED = 0,
SETUP_COMPLETE,
SETUP_FAILED,
RESET_COMPLETE,
@@ -78,11 +78,12 @@ gdm_session_get_type (void)
}
void
-gdm_session_open (GdmSession *session)
+gdm_session_start_conversation (GdmSession *session,
+ const char *service_name)
{
g_return_if_fail (GDM_IS_SESSION (session));
- GDM_SESSION_GET_IFACE (session)->open (session);
+ GDM_SESSION_GET_IFACE (session)->start_conversation (session, service_name);
}
void
@@ -203,14 +204,14 @@ gdm_session_class_init (gpointer g_iface)
{
GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
- signals [OPENED] =
- g_signal_new ("opened",
+ signals [CONVERSATION_STARTED] =
+ g_signal_new ("conversation-started",
iface_type,
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdmSessionIface, opened),
+ G_STRUCT_OFFSET (GdmSessionIface, conversation_started),
NULL,
NULL,
- g_cclosure_marshal_VOID__VOID,
+ g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE,
0);
signals [SETUP_COMPLETE] =
@@ -608,10 +609,11 @@ _gdm_session_session_died (GdmSession *session,
}
void
-_gdm_session_opened (GdmSession *session)
+_gdm_session_conversation_started (GdmSession *session,
+ const char *service_name)
{
g_return_if_fail (GDM_IS_SESSION (session));
- g_signal_emit (session, signals [OPENED], 0);
+ g_signal_emit (session, signals [CONVERSATION_STARTED], 0, service_name);
}
void
diff --git a/daemon/gdm-session.h b/daemon/gdm-session.h
index dfb7e27..77e0cf6 100644
--- a/daemon/gdm-session.h
+++ b/daemon/gdm-session.h
@@ -45,7 +45,8 @@ struct _GdmSessionIface
GTypeInterface base_iface;
/* Methods */
- void (* open) (GdmSession *session);
+ void (* start_conversation) (GdmSession *session,
+ const char *service_name);
void (* setup) (GdmSession *session,
const char *service_name);
void (* setup_for_user) (GdmSession *session,
@@ -103,7 +104,8 @@ struct _GdmSessionIface
int exit_code);
void (* session_died) (GdmSession *session,
int signal_number);
- void (* opened) (GdmSession *session);
+ void (* conversation_started) (GdmSession *session,
+ const char *service_name);
void (* closed) (GdmSession *session);
void (* selected_user_changed) (GdmSession *session,
const char *text);
@@ -118,7 +120,8 @@ struct _GdmSessionIface
GType gdm_session_get_type (void) G_GNUC_CONST;
-void gdm_session_open (GdmSession *session);
+void gdm_session_start_conversation (GdmSession *session,
+ const char *service_name);
void gdm_session_setup (GdmSession *session,
const char *service_name);
void gdm_session_setup_for_user (GdmSession *session,
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index 3a2623c..f193ff5 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -174,7 +174,6 @@ reset_session (GdmSimpleSlave *slave)
{
destroy_session (slave);
create_new_session (slave);
- gdm_session_open (GDM_SESSION (slave->priv->session));
}
static gboolean
@@ -816,8 +815,6 @@ on_greeter_connected (GdmGreeterServer *greeter_server,
g_debug ("GdmSimpleSlave: Greeter connected");
- gdm_session_open (GDM_SESSION (slave->priv->session));
-
g_object_get (slave,
"display-is-local", &display_is_local,
NULL);
diff --git a/daemon/test-session.c b/daemon/test-session.c
index c6a158c..d9fa26e 100644
--- a/daemon/test-session.c
+++ b/daemon/test-session.c
@@ -33,12 +33,13 @@
static GMainLoop *loop;
static void
-on_open (GdmSession *session,
- const char *username)
+on_conversation_started (GdmSession *session,
+ const char *service_name,
+ const char *username)
{
g_debug ("Got opened: calling setup...");
- gdm_session_setup (session, "gdm");
+ gdm_session_setup (session, service_name);
}
static void
@@ -256,11 +257,11 @@ main (int argc,
username = argv[1];
}
- gdm_session_open (GDM_SESSION (session));
+ gdm_session_start_conversation (GDM_SESSION (session), "gdm");
g_signal_connect (session,
- "opened",
- G_CALLBACK (on_open),
+ "conversation-started",
+ G_CALLBACK (on_conversation_started),
username);
g_signal_connect (session,
"setup-complete",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]