diff options
-rw-r--r-- | ChangeLog | 36 | ||||
-rw-r--r-- | daemon/gdm-greeter-server.c | 33 | ||||
-rw-r--r-- | daemon/gdm-greeter-server.h | 32 | ||||
-rw-r--r-- | daemon/gdm-session-worker.c | 21 | ||||
-rw-r--r-- | daemon/gdm-simple-slave.c | 2 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-greeter-client.c | 583 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-greeter-client.h | 2 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-greeter-session.c | 24 |
8 files changed, 436 insertions, 297 deletions
@@ -1,5 +1,41 @@ 2007-10-30 William Jon McCann <mccann@jhu.edu> + * daemon/gdm-greeter-server.c: (send_dbus_message), + (send_dbus_string_signal), + (gdm_greeter_server_selected_user_changed), (do_introspect): + * daemon/gdm-greeter-server.h: + * daemon/gdm-session-worker.c: (send_dbus_string_method), + (gdm_session_worker_get_username), + (gdm_session_worker_process_pam_message), + (worker_dbus_filter_function): + * daemon/gdm-simple-slave.c: (on_session_selected_user_changed): + * gui/simple-greeter/gdm-greeter-client.c: + (emit_string_signal_for_message), (on_selected_user_changed), + (on_info_query), (on_secret_info_query), (on_info), (on_problem), + (on_ready), (on_reset), (send_dbus_string_method), + (send_dbus_void_method), + (gdm_greeter_client_call_begin_verification), + (gdm_greeter_client_call_begin_verification_for_user), + (gdm_greeter_client_call_answer_query), + (gdm_greeter_client_call_select_session), + (gdm_greeter_client_call_select_language), + (gdm_greeter_client_call_select_user), + (gdm_greeter_client_call_select_hostname), + (gdm_greeter_client_call_cancel), + (gdm_greeter_client_call_disconnect), (send_get_display_id), + (gdm_greeter_client_call_get_display_id), + (client_dbus_handle_message), (client_dbus_filter_function), + (gdm_greeter_client_start), (gdm_greeter_client_class_init): + * gui/simple-greeter/gdm-greeter-client.h: + * gui/simple-greeter/gdm-greeter-session.c: (on_info), + (on_problem), (on_ready), (on_reset), (on_selected_user_changed), + (on_info_query), (on_secret_info_query), + (gdm_greeter_session_init): + Convert the GreeterClient to use dbus instead of dbus-glib. Add + support for the SelectedUserChanged signal. + +2007-10-30 William Jon McCann <mccann@jhu.edu> + * gui/simple-greeter/gdm-user-chooser-widget.c: (gdm_user_chooser_widget_init): Make checkbox column smaller. diff --git a/daemon/gdm-greeter-server.c b/daemon/gdm-greeter-server.c index ea11eb91..35802548 100644 --- a/daemon/gdm-greeter-server.c +++ b/daemon/gdm-greeter-server.c @@ -114,17 +114,25 @@ send_dbus_message (DBusConnection *connection, } sent = dbus_connection_send (connection, message, NULL); + dbus_connection_flush (connection); return sent; } static void send_dbus_string_signal (GdmGreeterServer *greeter_server, - const char *name, - const char *text) + const char *name, + const char *text) { DBusMessage *message; DBusMessageIter iter; + const char *str; + + if (text != NULL) { + str = text; + } else { + str = ""; + } g_return_if_fail (greeter_server != NULL); @@ -133,8 +141,9 @@ send_dbus_string_signal (GdmGreeterServer *greeter_server, name); dbus_message_iter_init_append (message, &iter); - dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &text); + dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &str); + g_debug ("Sending %s (%s)", name, str); if (! send_dbus_message (greeter_server->priv->greeter_connection, message)) { g_debug ("Could not send %s signal", name); } @@ -163,7 +172,7 @@ send_dbus_void_signal (GdmGreeterServer *greeter_server, gboolean gdm_greeter_server_info_query (GdmGreeterServer *greeter_server, - const char *text) + const char *text) { send_dbus_string_signal (greeter_server, "InfoQuery", text); @@ -172,7 +181,7 @@ gdm_greeter_server_info_query (GdmGreeterServer *greeter_server, gboolean gdm_greeter_server_secret_info_query (GdmGreeterServer *greeter_server, - const char *text) + const char *text) { send_dbus_string_signal (greeter_server, "SecretInfoQuery", text); return TRUE; @@ -180,7 +189,7 @@ gdm_greeter_server_secret_info_query (GdmGreeterServer *greeter_server, gboolean gdm_greeter_server_info (GdmGreeterServer *greeter_server, - const char *text) + const char *text) { send_dbus_string_signal (greeter_server, "Info", text); return TRUE; @@ -188,7 +197,7 @@ gdm_greeter_server_info (GdmGreeterServer *greeter_server, gboolean gdm_greeter_server_problem (GdmGreeterServer *greeter_server, - const char *text) + const char *text) { send_dbus_string_signal (greeter_server, "Problem", text); return TRUE; @@ -208,6 +217,13 @@ gdm_greeter_server_ready (GdmGreeterServer *greeter_server) return TRUE; } +void +gdm_greeter_server_selected_user_changed (GdmGreeterServer *greeter_server, + const char *username) +{ + send_dbus_string_signal (greeter_server, "SelectedUserChanged", username); +} + /* Note: Use abstract sockets like dbus does by default on Linux. Abstract * sockets are only available on Linux. */ @@ -560,6 +576,9 @@ do_introspect (DBusConnection *connection, " <signal name=\"SecretInfoQuery\">\n" " <arg name=\"text\" type=\"s\"/>\n" " </signal>\n" + " <signal name=\"SelectedUserChanged\">\n" + " <arg name=\"username\" type=\"s\"/>\n" + " </signal>\n" " <signal name=\"Ready\">\n" " </signal>\n" " <signal name=\"Reset\">\n" diff --git a/daemon/gdm-greeter-server.h b/daemon/gdm-greeter-server.h index daa3ba83..1b9ef288 100644 --- a/daemon/gdm-greeter-server.h +++ b/daemon/gdm-greeter-server.h @@ -63,24 +63,26 @@ typedef struct void (* disconnected) (GdmGreeterServer *greeter_server); } GdmGreeterServerClass; -GType gdm_greeter_server_get_type (void); -GdmGreeterServer * gdm_greeter_server_new (const char *display_id); +GType gdm_greeter_server_get_type (void); +GdmGreeterServer * gdm_greeter_server_new (const char *display_id); -gboolean gdm_greeter_server_start (GdmGreeterServer *greeter_server); -gboolean gdm_greeter_server_stop (GdmGreeterServer *greeter_server); -char * gdm_greeter_server_get_address (GdmGreeterServer *greeter_server); +gboolean gdm_greeter_server_start (GdmGreeterServer *greeter_server); +gboolean gdm_greeter_server_stop (GdmGreeterServer *greeter_server); +char * gdm_greeter_server_get_address (GdmGreeterServer *greeter_server); -gboolean gdm_greeter_server_info_query (GdmGreeterServer *greeter_server, - const char *text); -gboolean gdm_greeter_server_secret_info_query (GdmGreeterServer *greeter_server, - const char *text); -gboolean gdm_greeter_server_info (GdmGreeterServer *greeter_server, - const char *text); -gboolean gdm_greeter_server_problem (GdmGreeterServer *greeter_server, - const char *text); -gboolean gdm_greeter_server_reset (GdmGreeterServer *greeter_server); -gboolean gdm_greeter_server_ready (GdmGreeterServer *greeter_server); +gboolean gdm_greeter_server_info_query (GdmGreeterServer *greeter_server, + const char *text); +gboolean gdm_greeter_server_secret_info_query (GdmGreeterServer *greeter_server, + const char *text); +gboolean gdm_greeter_server_info (GdmGreeterServer *greeter_server, + const char *text); +gboolean gdm_greeter_server_problem (GdmGreeterServer *greeter_server, + const char *text); +gboolean gdm_greeter_server_reset (GdmGreeterServer *greeter_server); +gboolean gdm_greeter_server_ready (GdmGreeterServer *greeter_server); +void gdm_greeter_server_selected_user_changed (GdmGreeterServer *greeter_server, + const char *text); G_END_DECLS diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c index 716edf71..4b94ecd1 100644 --- a/daemon/gdm-session-worker.c +++ b/daemon/gdm-session-worker.c @@ -311,6 +311,13 @@ send_dbus_string_method (DBusConnection *connection, DBusMessage *message; DBusMessage *reply; DBusMessageIter iter; + const char *str; + + if (payload != NULL) { + str = payload; + } else { + str = ""; + } g_debug ("Calling %s", method); message = dbus_message_new_method_call (NULL, @@ -325,7 +332,7 @@ send_dbus_string_method (DBusConnection *connection, dbus_message_iter_init_append (message, &iter); dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, - &payload); + &str); dbus_error_init (&error); reply = dbus_connection_send_with_reply_and_block (connection, @@ -488,11 +495,10 @@ gdm_session_worker_get_username (GdmSessionWorker *worker, g_assert (worker->priv->pam_handle != NULL); if (pam_get_item (worker->priv->pam_handle, PAM_USER, &item) == PAM_SUCCESS) { - if (username) { + if (username != NULL) { *username = g_strdup ((char *) item); g_debug ("username is '%s'", - *username != NULL ? *username : - "<unset>"); + *username != NULL ? *username : "<unset>"); } return TRUE; } @@ -665,6 +671,8 @@ gdm_session_worker_process_pam_message (GdmSessionWorker *worker, *response_text = NULL; } + gdm_session_worker_update_username (worker); + g_debug ("received pam message of type %u with payload '%s'", query->msg_style, query->msg); @@ -703,7 +711,7 @@ gdm_session_worker_process_pam_message (GdmSessionWorker *worker, g_free (user_answer); g_debug ("trying to get updated username"); - gdm_session_worker_update_username (worker); + res = TRUE; } @@ -1789,8 +1797,7 @@ worker_dbus_filter_function (DBusConnection *connection, if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected") && strcmp (path, DBUS_PATH_LOCAL) == 0) { - g_message ("Got disconnected from the session message bus; " - "retrying to reconnect every 10 seconds"); + g_message ("Got disconnected from the server"); dbus_connection_unref (connection); worker->priv->connection = NULL; diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c index 4377e877..989a9150 100644 --- a/daemon/gdm-simple-slave.c +++ b/daemon/gdm-simple-slave.c @@ -242,7 +242,7 @@ on_session_selected_user_changed (GdmSession *session, { g_debug ("Selected user changed: %s", text); - /* FIXME: send this over to the greeter */ + gdm_greeter_server_selected_user_changed (slave->priv->greeter_server, text); } diff --git a/gui/simple-greeter/gdm-greeter-client.c b/gui/simple-greeter/gdm-greeter-client.c index 5ae36a4f..a6af9ea2 100644 --- a/gui/simple-greeter/gdm-greeter-client.c +++ b/gui/simple-greeter/gdm-greeter-client.c @@ -29,6 +29,7 @@ #include <glib/gi18n.h> #include <glib-object.h> #define DBUS_API_SUBJECT_TO_CHANGE +#include <dbus/dbus.h> #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> @@ -36,16 +37,15 @@ #define GDM_GREETER_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_GREETER_CLIENT, GdmGreeterClientPrivate)) -#define SERVER_DBUS_PATH "/org/gnome/DisplayManager/GreeterServer" -#define SERVER_DBUS_INTERFACE "org.gnome.DisplayManager.GreeterServer" +#define GREETER_SERVER_DBUS_PATH "/org/gnome/DisplayManager/GreeterServer" +#define GREETER_SERVER_DBUS_INTERFACE "org.gnome.DisplayManager.GreeterServer" #define GDM_DBUS_NAME "org.gnome.DisplayManager" #define GDM_DBUS_DISPLAY_INTERFACE "org.gnome.DisplayManager.Display" struct GdmGreeterClientPrivate { - DBusGConnection *connection; - DBusGProxy *server_proxy; + DBusConnection *connection; char *address; char *display_id; @@ -63,6 +63,7 @@ enum { SECRET_INFO_QUERY, READY, RESET, + SELECTED_USER_CHANGED, LAST_SIGNAL }; @@ -96,32 +97,71 @@ gdm_greeter_client_get_display_is_local (GdmGreeterClient *client) } static void -on_info (DBusGProxy *proxy, - const char *text, - GdmGreeterClient *client) +emit_string_signal_for_message (GdmGreeterClient *client, + const char *name, + DBusMessage *message, + int signal) { - g_debug ("GREETER INFO: %s", text); + DBusError error; + const char *text; + dbus_bool_t res; + + dbus_error_init (&error); + res = dbus_message_get_args (message, + &error, + DBUS_TYPE_STRING, &text, + DBUS_TYPE_INVALID); + if (res) { + + g_debug ("Recieved %s (%s)", name, text); + + g_signal_emit (client, + gdm_greeter_client_signals[signal], + 0, text); + } else { + g_warning ("Unable to get arguments: %s", error.message); + dbus_error_free (&error); + } +} - g_signal_emit (client, - gdm_greeter_client_signals[INFO], - 0, text); +static void +on_selected_user_changed (GdmGreeterClient *client, + DBusMessage *message) +{ + emit_string_signal_for_message (client, "SelectedUserChanged", message, SELECTED_USER_CHANGED); } static void -on_problem (DBusGProxy *proxy, - const char *text, - GdmGreeterClient *client) +on_info_query (GdmGreeterClient *client, + DBusMessage *message) { - g_debug ("GREETER PROBLEM: %s", text); + emit_string_signal_for_message (client, "InfoQuery", message, INFO_QUERY); +} - g_signal_emit (client, - gdm_greeter_client_signals[PROBLEM], - 0, text); +static void +on_secret_info_query (GdmGreeterClient *client, + DBusMessage *message) +{ + emit_string_signal_for_message (client, "SecretInfoQuery", message, SECRET_INFO_QUERY); } static void -on_ready (DBusGProxy *proxy, - GdmGreeterClient *client) +on_info (GdmGreeterClient *client, + DBusMessage *message) +{ + emit_string_signal_for_message (client, "Info", message, INFO); +} + +static void +on_problem (GdmGreeterClient *client, + DBusMessage *message) +{ + emit_string_signal_for_message (client, "Problem", message, PROBLEM); +} + +static void +on_ready (GdmGreeterClient *client, + DBusMessage *message) { g_debug ("GREETER SERVER READY"); @@ -131,8 +171,8 @@ on_ready (DBusGProxy *proxy, } static void -on_reset (DBusGProxy *proxy, - GdmGreeterClient *client) +on_reset (GdmGreeterClient *client, + DBusMessage *message) { g_debug ("GREETER RESET"); @@ -141,257 +181,240 @@ on_reset (DBusGProxy *proxy, 0); } -static void -on_info_query (DBusGProxy *proxy, - const char *text, - GdmGreeterClient *client) +static gboolean +send_dbus_string_method (DBusConnection *connection, + const char *method, + const char *payload) { - g_debug ("GREETER Info query: %s", text); + DBusError error; + DBusMessage *message; + DBusMessage *reply; + DBusMessageIter iter; + const char *str; + + if (payload != NULL) { + str = payload; + } else { + str = ""; + } - g_signal_emit (client, - gdm_greeter_client_signals[INFO_QUERY], - 0, text); -} + g_debug ("Calling %s", method); + message = dbus_message_new_method_call (NULL, + GREETER_SERVER_DBUS_PATH, + GREETER_SERVER_DBUS_INTERFACE, + method); + if (message == NULL) { + g_warning ("Couldn't allocate the D-Bus message"); + return FALSE; + } -static void -on_secret_info_query (DBusGProxy *proxy, - const char *text, - GdmGreeterClient *client) -{ - g_debug ("GREETER Secret info query: %s", text); + dbus_message_iter_init_append (message, &iter); + dbus_message_iter_append_basic (&iter, + DBUS_TYPE_STRING, + &str); + + dbus_error_init (&error); + reply = dbus_connection_send_with_reply_and_block (connection, + message, + -1, + &error); + + dbus_message_unref (message); + + if (dbus_error_is_set (&error)) { + g_warning ("%s %s raised: %s\n", + method, + error.name, + error.message); + return FALSE; + } + dbus_message_unref (reply); + dbus_connection_flush (connection); - g_signal_emit (client, - gdm_greeter_client_signals[SECRET_INFO_QUERY], - 0, text); + return TRUE; } -void -gdm_greeter_client_call_begin_verification (GdmGreeterClient *client) + +static gboolean +send_dbus_void_method (DBusConnection *connection, + const char *method) { - gboolean res; - GError *error; + DBusError error; + DBusMessage *message; + DBusMessage *reply; + + g_debug ("Calling %s", method); + message = dbus_message_new_method_call (NULL, + GREETER_SERVER_DBUS_PATH, + GREETER_SERVER_DBUS_INTERFACE, + method); + if (message == NULL) { + g_warning ("Couldn't allocate the D-Bus message"); + return FALSE; + } - g_return_if_fail (GDM_IS_GREETER_CLIENT (client)); + dbus_error_init (&error); + reply = dbus_connection_send_with_reply_and_block (connection, + message, + -1, + &error); - g_debug ("GREETER begin verification"); + dbus_message_unref (message); - error = NULL; - res = dbus_g_proxy_call (client->priv->server_proxy, - "BeginVerification", - &error, - G_TYPE_INVALID, - G_TYPE_INVALID); - if (! res) { - g_warning ("Unable to send BeginVerification: %s", error->message); - g_error_free (error); + if (dbus_error_is_set (&error)) { + g_warning ("%s %s raised: %s\n", + method, + error.name, + error.message); + return FALSE; } + dbus_message_unref (reply); + dbus_connection_flush (connection); + + return TRUE; } +void +gdm_greeter_client_call_begin_verification (GdmGreeterClient *client) +{ + send_dbus_void_method (client->priv->connection, + "BeginVerification"); +} void gdm_greeter_client_call_begin_verification_for_user (GdmGreeterClient *client, const char *username) { - gboolean res; - GError *error; - - g_return_if_fail (GDM_IS_GREETER_CLIENT (client)); - - g_debug ("GREETER begin verification for user: '%s'", username); - - error = NULL; - res = dbus_g_proxy_call (client->priv->server_proxy, + send_dbus_string_method (client->priv->connection, "BeginVerificationForUser", - &error, - G_TYPE_STRING, username, - G_TYPE_INVALID, - G_TYPE_INVALID); - if (! res) { - g_warning ("Unable to send BeginVerificationForUser: %s", error->message); - g_error_free (error); - } + username); } void gdm_greeter_client_call_answer_query (GdmGreeterClient *client, const char *text) { - gboolean res; - GError *error; - - g_debug ("GREETER answer"); - - error = NULL; - res = dbus_g_proxy_call (client->priv->server_proxy, + send_dbus_string_method (client->priv->connection, "AnswerQuery", - &error, - G_TYPE_STRING, text, - G_TYPE_INVALID, - G_TYPE_INVALID); - if (! res) { - g_warning ("Unable to send AnswerQuery: %s", error->message); - g_error_free (error); - } + text); } void gdm_greeter_client_call_select_session (GdmGreeterClient *client, const char *text) { - gboolean res; - GError *error; - - g_debug ("GREETER client selected: %s", text); - - error = NULL; - res = dbus_g_proxy_call (client->priv->server_proxy, + send_dbus_string_method (client->priv->connection, "SelectSession", - &error, - G_TYPE_STRING, text, - G_TYPE_INVALID, - G_TYPE_INVALID); - if (! res) { - g_warning ("Unable to send SelectSession: %s", error->message); - g_error_free (error); - } + text); } void gdm_greeter_client_call_select_language (GdmGreeterClient *client, const char *text) { - gboolean res; - GError *error; - - g_debug ("GREETER client selected: %s", text); - - error = NULL; - res = dbus_g_proxy_call (client->priv->server_proxy, + send_dbus_string_method (client->priv->connection, "SelectLanguage", - &error, - G_TYPE_STRING, text, - G_TYPE_INVALID, - G_TYPE_INVALID); - if (! res) { - g_warning ("Unable to send SelectLanguage: %s", error->message); - g_error_free (error); - } + text); } void gdm_greeter_client_call_select_user (GdmGreeterClient *client, const char *text) { - gboolean res; - GError *error; - - g_debug ("GREETER user selected: %s", text); - - error = NULL; - res = dbus_g_proxy_call (client->priv->server_proxy, + send_dbus_string_method (client->priv->connection, "SelectUser", - &error, - G_TYPE_STRING, text, - G_TYPE_INVALID, - G_TYPE_INVALID); - if (! res) { - g_warning ("Unable to send SelectUser: %s", error->message); - g_error_free (error); - } + text); } void gdm_greeter_client_call_select_hostname (GdmGreeterClient *client, const char *text) { - gboolean res; - GError *error; - - g_debug ("GREETER hostname selected: %s", text); - - error = NULL; - res = dbus_g_proxy_call (client->priv->server_proxy, + send_dbus_string_method (client->priv->connection, "SelectHostname", - &error, - G_TYPE_STRING, text, - G_TYPE_INVALID, - G_TYPE_INVALID); - if (! res) { - g_warning ("Unable to send SelectHostname: %s", error->message); - g_error_free (error); - } + text); } void gdm_greeter_client_call_cancel (GdmGreeterClient *client) { - gboolean res; - GError *error; - - g_debug ("GREETER cancelled"); - - error = NULL; - res = dbus_g_proxy_call (client->priv->server_proxy, - "Cancel", - &error, - G_TYPE_INVALID, - G_TYPE_INVALID); - if (! res) { - g_warning ("Unable to send Cancelled: %s", error->message); - g_error_free (error); - } + send_dbus_void_method (client->priv->connection, + "Cancel"); } void gdm_greeter_client_call_disconnect (GdmGreeterClient *client) { - gboolean res; - GError *error; - - g_debug ("GREETER disconnected"); - - error = NULL; - res = dbus_g_proxy_call (client->priv->server_proxy, - "Disconnect", - &error, - G_TYPE_INVALID, - G_TYPE_INVALID); - if (! res) { - g_warning ("Unable to send Disconnected: %s", error->message); - g_error_free (error); - } + send_dbus_void_method (client->priv->connection, + "Disconnect"); } -char * -gdm_greeter_client_call_get_display_id (GdmGreeterClient *client) + +static gboolean +send_get_display_id (GdmGreeterClient *client, + const char *method, + char **answerp) { - gboolean res; - GError *error; - char *id; + DBusError error; + DBusMessage *message; + DBusMessage *reply; + DBusMessageIter iter; + gboolean ret; + const char *answer; - g_return_val_if_fail (GDM_IS_GREETER_CLIENT (client), NULL); + ret = FALSE; - id = NULL; - error = NULL; - res = dbus_g_proxy_call (client->priv->server_proxy, - "GetDisplayId", - &error, - G_TYPE_INVALID, - DBUS_TYPE_G_OBJECT_PATH, &id, - G_TYPE_INVALID); - if (! res) { - g_warning ("Unable to GetDisplayId: %s", error->message); - g_error_free (error); + g_debug ("Calling %s", method); + message = dbus_message_new_method_call (NULL, + GREETER_SERVER_DBUS_PATH, + GREETER_SERVER_DBUS_INTERFACE, + method); + if (message == NULL) { + g_warning ("Couldn't allocate the D-Bus message"); + return FALSE; } - return id; + dbus_error_init (&error); + reply = dbus_connection_send_with_reply_and_block (client->priv->connection, + message, + -1, + &error); + dbus_message_unref (message); + + if (dbus_error_is_set (&error)) { + g_warning ("%s %s raised: %s\n", + method, + error.name, + error.message); + goto out; + } + + dbus_message_iter_init (reply, &iter); + dbus_message_iter_get_basic (&iter, &answer); + if (answerp != NULL) { + *answerp = g_strdup (answer); + } + ret = TRUE; + + dbus_message_unref (reply); + dbus_connection_flush (client->priv->connection); + + out: + + return ret; } -static void -proxy_destroyed (GObject *object, - gpointer data) +char * +gdm_greeter_client_call_get_display_id (GdmGreeterClient *client) { - g_debug ("GREETER Proxy disconnected"); + char *display_id; + + display_id = NULL; + send_get_display_id (client, + "GetDisplayId", + &display_id); + + return display_id; } static void @@ -441,12 +464,84 @@ cache_display_values (GdmGreeterClient *client) } } +static DBusHandlerResult +client_dbus_handle_message (DBusConnection *connection, + DBusMessage *message, + void *user_data, + dbus_bool_t local_interface) +{ + GdmGreeterClient *client = GDM_GREETER_CLIENT (user_data); + +#if 0 + g_message ("obj_path=%s interface=%s method=%s destination=%s", + dbus_message_get_path (message), + dbus_message_get_interface (message), + dbus_message_get_member (message), + dbus_message_get_destination (message)); +#endif + + g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); + g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); + + if (dbus_message_is_signal (message, GREETER_SERVER_DBUS_INTERFACE, "InfoQuery")) { + on_info_query (client, message); + } else if (dbus_message_is_signal (message, GREETER_SERVER_DBUS_INTERFACE, "SecretInfoQuery")) { + on_secret_info_query (client, message); + } else if (dbus_message_is_signal (message, GREETER_SERVER_DBUS_INTERFACE, "Info")) { + on_info (client, message); + } else if (dbus_message_is_signal (message, GREETER_SERVER_DBUS_INTERFACE, "Problem")) { + on_problem (client, message); + } else if (dbus_message_is_signal (message, GREETER_SERVER_DBUS_INTERFACE, "Ready")) { + on_ready (client, message); + } else if (dbus_message_is_signal (message, GREETER_SERVER_DBUS_INTERFACE, "Reset")) { + on_reset (client, message); + } else if (dbus_message_is_signal (message, GREETER_SERVER_DBUS_INTERFACE, "SelectedUserChanged")) { + on_selected_user_changed (client, message); + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static DBusHandlerResult +client_dbus_filter_function (DBusConnection *connection, + DBusMessage *message, + void *user_data) +{ + GdmGreeterClient *client = GDM_GREETER_CLIENT (user_data); + const char *path; + + path = dbus_message_get_path (message); + + g_debug ("obj_path=%s interface=%s method=%s", + dbus_message_get_path (message), + dbus_message_get_interface (message), + dbus_message_get_member (message)); + + if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected") + && strcmp (path, DBUS_PATH_LOCAL) == 0) { + + g_message ("Got disconnected from the session message bus"); + + dbus_connection_unref (connection); + client->priv->connection = NULL; + + } else if (dbus_message_is_signal (message, + DBUS_INTERFACE_DBUS, + "NameOwnerChanged")) { + g_debug ("Name owner changed?"); + } else { + return client_dbus_handle_message (connection, message, user_data, FALSE); + } + + return DBUS_HANDLER_RESULT_HANDLED; +} + gboolean gdm_greeter_client_start (GdmGreeterClient *client, - GError **error) + GError **error) { - gboolean ret; - GError *local_error; + gboolean ret; + DBusError local_error; g_return_val_if_fail (GDM_IS_GREETER_CLIENT (client), FALSE); @@ -463,73 +558,29 @@ gdm_greeter_client_start (GdmGreeterClient *client, g_debug ("GREETER connecting to address: %s", client->priv->address); - local_error = NULL; - client->priv->connection = dbus_g_connection_open (client->priv->address, &local_error); + dbus_error_init (&local_error); + client->priv->connection = dbus_connection_open (client->priv->address, &local_error); if (client->priv->connection == NULL) { - if (local_error != NULL) { - g_warning ("error opening connection: %s", local_error->message); - g_propagate_error (error, local_error); + if (dbus_error_is_set (&local_error)) { + g_warning ("error opening connection: %s", local_error.message); + g_set_error (error, + GDM_GREETER_CLIENT_ERROR, + GDM_GREETER_CLIENT_ERROR_GENERIC, + local_error.message); + dbus_error_free (&local_error); } else { g_warning ("Unable to open connection"); } goto out; } - g_debug ("GREETER creating proxy for peer: %s", SERVER_DBUS_PATH); - client->priv->server_proxy = dbus_g_proxy_new_for_peer (client->priv->connection, - SERVER_DBUS_PATH, - SERVER_DBUS_INTERFACE); - if (client->priv->server_proxy == NULL) { - g_warning ("Unable to create proxy for peer"); - g_set_error (error, - GDM_GREETER_CLIENT_ERROR, - GDM_GREETER_CLIENT_ERROR_GENERIC, - "Unable to create proxy for peer"); - - /* FIXME: drop connection? */ - goto out; - } + dbus_connection_setup_with_g_main (client->priv->connection, NULL); + dbus_connection_set_exit_on_disconnect (client->priv->connection, TRUE); - g_signal_connect (client->priv->server_proxy, "destroy", G_CALLBACK (proxy_destroyed), NULL); - - /* FIXME: not sure why introspection isn't working */ - dbus_g_proxy_add_signal (client->priv->server_proxy, "InfoQuery", G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal (client->priv->server_proxy, "SecretInfoQuery", G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal (client->priv->server_proxy, "Info", G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal (client->priv->server_proxy, "Problem", G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal (client->priv->server_proxy, "Ready", G_TYPE_INVALID); - dbus_g_proxy_add_signal (client->priv->server_proxy, "Reset", G_TYPE_INVALID); - - dbus_g_proxy_connect_signal (client->priv->server_proxy, - "InfoQuery", - G_CALLBACK (on_info_query), - client, - NULL); - dbus_g_proxy_connect_signal (client->priv->server_proxy, - "SecretInfoQuery", - G_CALLBACK (on_secret_info_query), - client, - NULL); - dbus_g_proxy_connect_signal (client->priv->server_proxy, - "Info", - G_CALLBACK (on_info), - client, - NULL); - dbus_g_proxy_connect_signal (client->priv->server_proxy, - "Problem", - G_CALLBACK (on_problem), - client, - NULL); - dbus_g_proxy_connect_signal (client->priv->server_proxy, - "Ready", - G_CALLBACK (on_ready), - client, - NULL); - dbus_g_proxy_connect_signal (client->priv->server_proxy, - "Reset", - G_CALLBACK (on_reset), - client, - NULL); + dbus_connection_add_filter (client->priv->connection, + client_dbus_filter_function, + client, + NULL); cache_display_values (client); @@ -691,6 +742,16 @@ gdm_greeter_client_class_init (GdmGreeterClientClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + gdm_greeter_client_signals[SELECTED_USER_CHANGED] = + g_signal_new ("selected-user-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GdmGreeterClientClass, selected_user_changed), + NULL, + NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, G_TYPE_STRING); } static void diff --git a/gui/simple-greeter/gdm-greeter-client.h b/gui/simple-greeter/gdm-greeter-client.h index 766e5739..b7b013be 100644 --- a/gui/simple-greeter/gdm-greeter-client.h +++ b/gui/simple-greeter/gdm-greeter-client.h @@ -57,6 +57,8 @@ typedef struct const char *problem); void (* ready) (GdmGreeterClient *client); void (* reset) (GdmGreeterClient *client); + void (* selected_user_changed) (GdmGreeterClient *client, + const char *username); } GdmGreeterClientClass; diff --git a/gui/simple-greeter/gdm-greeter-session.c b/gui/simple-greeter/gdm-greeter-session.c index 58556c7e..2cae4c55 100644 --- a/gui/simple-greeter/gdm-greeter-session.c +++ b/gui/simple-greeter/gdm-greeter-session.c @@ -67,7 +67,7 @@ on_info (GdmGreeterClient *client, const char *text, GdmGreeterSession *session) { - g_debug ("GREETER INFO: %s", text); + g_debug ("GreeterClient Info: %s", text); gdm_greeter_login_window_info (GDM_GREETER_LOGIN_WINDOW (session->priv->login_window), text); } @@ -77,7 +77,7 @@ on_problem (GdmGreeterClient *client, const char *text, GdmGreeterSession *session) { - g_debug ("GREETER PROBLEM: %s", text); + g_debug ("GreeterClient Problem: %s", text); gdm_greeter_login_window_problem (GDM_GREETER_LOGIN_WINDOW (session->priv->login_window), text); } @@ -86,7 +86,7 @@ static void on_ready (GdmGreeterClient *client, GdmGreeterSession *session) { - g_debug ("GREETER SERVER READY"); + g_debug ("GreeterClient Ready"); gdm_greeter_login_window_ready (GDM_GREETER_LOGIN_WINDOW (session->priv->login_window)); } @@ -95,17 +95,25 @@ static void on_reset (GdmGreeterClient *client, GdmGreeterSession *session) { - g_debug ("GREETER RESET"); + g_debug ("GreeterClient Reset"); gdm_greeter_login_window_reset (GDM_GREETER_LOGIN_WINDOW (session->priv->login_window)); } static void +on_selected_user_changed (GdmGreeterClient *client, + const char *text, + GdmGreeterSession *session) +{ + g_debug ("GreeterClient selected user changed: %s", text); +} + +static void on_info_query (GdmGreeterClient *client, const char *text, GdmGreeterSession *session) { - g_debug ("GREETER Info query: %s", text); + g_debug ("GreeterClient Info query: %s", text); gdm_greeter_login_window_info_query (GDM_GREETER_LOGIN_WINDOW (session->priv->login_window), text); } @@ -115,7 +123,7 @@ on_secret_info_query (GdmGreeterClient *client, const char *text, GdmGreeterSession *session) { - g_debug ("GREETER Secret info query: %s", text); + g_debug ("GreeterClient Secret info query: %s", text); gdm_greeter_login_window_secret_info_query (GDM_GREETER_LOGIN_WINDOW (session->priv->login_window), text); } @@ -519,6 +527,10 @@ gdm_greeter_session_init (GdmGreeterSession *session) "reset", G_CALLBACK (on_reset), session); + g_signal_connect (session->priv->client, + "selected-user-changed", + G_CALLBACK (on_selected_user_changed), + session); } |