diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2014-10-02 20:54:44 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2014-10-02 20:54:44 +1300 |
commit | 3a73ec0e11131fa874475a5076212fac24b74052 (patch) | |
tree | 1aa12987d356ff917c61cb8944311b7bedef8f3b | |
parent | 2d206d412126971545ff9cb82351bfe4366b9c6d (diff) | |
parent | a5615ad176fbc334f069676c82cf475f1995a177 (diff) | |
download | lightdm-3a73ec0e11131fa874475a5076212fac24b74052.tar.gz |
Merge with trunk
44 files changed, 577 insertions, 292 deletions
diff --git a/common/user-list.c b/common/user-list.c index e9a729d1..636ac778 100644 --- a/common/user-list.c +++ b/common/user-list.c @@ -117,6 +117,9 @@ typedef struct /* Shell for user */ gchar *shell; + /* TRUE if a system account */ + gboolean system_account; + /* Image for user */ gchar *image; @@ -407,7 +410,7 @@ load_passwd_file (CommonUserList *user_list, gboolean emit_add_signal) { CommonUser *info = link->data; g_debug ("User %s added", common_user_get_name (info)); - g_signal_connect (info, "changed", G_CALLBACK (user_changed_cb), NULL); + g_signal_connect (info, USER_SIGNAL_CHANGED, G_CALLBACK (user_changed_cb), NULL); if (emit_add_signal) g_signal_emit (user_list, list_signals[USER_ADDED], 0, info); } @@ -451,7 +454,110 @@ passwd_changed_cb (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileM } } -static gboolean load_accounts_user (CommonUser *user); +static gboolean +update_user_property (CommonUser *user, const gchar *name, GVariant *value) +{ + CommonUserPrivate *priv = GET_USER_PRIVATE (user); + + if (strcmp (name, "UserName") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + { + g_free (priv->name); + priv->name = g_variant_dup_string (value, NULL); + return TRUE; + } + + if (strcmp (name, "RealName") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + { + g_free (priv->real_name); + priv->real_name = g_variant_dup_string (value, NULL); + return TRUE; + } + + if (strcmp (name, "HomeDirectory") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + { + g_free (priv->home_directory); + priv->home_directory = g_variant_dup_string (value, NULL); + return TRUE; + } + + if (strcmp (name, "Shell") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + { + g_free (priv->shell); + priv->shell = g_variant_dup_string (value, NULL); + return TRUE; + } + + if (strcmp (name, "SystemAccount") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) + { + priv->system_account = g_variant_get_boolean (value); + return TRUE; + } + + if (strcmp (name, "Language") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + { + if (priv->language) + g_free (priv->language); + priv->language = g_variant_dup_string (value, NULL); + return TRUE; + } + + if (strcmp (name, "IconFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + { + g_free (priv->image); + priv->image = g_variant_dup_string (value, NULL); + if (strcmp (priv->image, "") == 0) + { + g_free (priv->image); + priv->image = NULL; + } + return TRUE; + } + + if (strcmp (name, "XSession") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + { + g_free (priv->session); + priv->session = g_variant_dup_string (value, NULL); + return TRUE; + } + + if (strcmp (name, "BackgroundFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + { + g_free (priv->background); + priv->background = g_variant_dup_string (value, NULL); + if (strcmp (priv->background, "") == 0) + { + g_free (priv->background); + priv->background = NULL; + } + return TRUE; + } + + if (strcmp (name, "XKeyboardLayouts") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY)) + { + g_strfreev (priv->layouts); + priv->layouts = g_variant_dup_strv (value, NULL); + if (!priv->layouts) + { + priv->layouts = g_malloc (sizeof (gchar *) * 1); + priv->layouts[0] = NULL; + } + return TRUE; + } + + if (strcmp (name, "XHasMessages") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) + { + priv->has_messages = g_variant_get_boolean (value); + return TRUE; + } + + if (strcmp (name, "Uid") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_UINT64)) + { + priv->uid = g_variant_get_uint64 (value); + return TRUE; + } + + return FALSE; +} static void accounts_user_changed_cb (GDBusConnection *connection, @@ -463,11 +569,57 @@ accounts_user_changed_cb (GDBusConnection *connection, gpointer data) { CommonUser *user = data; - CommonUserPrivate *priv = GET_USER_PRIVATE (user); + CommonUserPrivate *priv = GET_USER_PRIVATE (user); + gboolean changed = FALSE; + GVariantIter *iter; + GVariantIter *invalidated_properties; + gchar *name; + GVariant *value; - g_debug ("User %s changed", priv->path); - if (load_accounts_user (user)) + g_variant_get (parameters, "(sa{sv}as)", NULL, &iter, &invalidated_properties); + while (g_variant_iter_loop (iter, "{&sv}", &name, &value)) + { + if (update_user_property (user, name, value)) + changed = TRUE; + } + g_variant_iter_free (iter); + while (g_variant_iter_loop (invalidated_properties, "&s", &name)) + { + GVariant *result; + GError *error = NULL; + + result = g_dbus_connection_call_sync (connection, + "org.freedesktop.Accounts", + priv->path, + "org.freedesktop.DBus.Properties", + "Get", + g_variant_new ("(ss)", "org.freedesktop.Accounts.User", name), + G_VARIANT_TYPE ("(v)"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (error) + g_warning ("Error updating user property %s: %s", name, error->message); + g_clear_error (&error); + + if (result) + { + GVariant *value; + + g_variant_get (result, "(v)", &value); + if (update_user_property (user, name, value)) + changed = TRUE; + g_variant_unref (value); + g_variant_unref (result); + } + } + + if (changed) + { + g_debug ("User %s changed", priv->path); g_signal_emit (user, user_signals[CHANGED], 0); + } } static gboolean @@ -477,17 +629,16 @@ load_accounts_user (CommonUser *user) GVariant *result, *value; GVariantIter *iter; gchar *name; - gboolean system_account = FALSE; GError *error = NULL; /* Get the properties for this user */ if (!priv->changed_signal) priv->changed_signal = g_dbus_connection_signal_subscribe (GET_LIST_PRIVATE (priv->user_list)->bus, "org.freedesktop.Accounts", - "org.freedesktop.Accounts.User", - "Changed", + "org.freedesktop.DBus.Properties", + "PropertiesChanged", priv->path, - NULL, + "org.freedesktop.Accounts.User", G_DBUS_SIGNAL_FLAGS_NONE, accounts_user_changed_cb, user, @@ -512,80 +663,12 @@ load_accounts_user (CommonUser *user) /* Store the properties we need */ g_variant_get (result, "(a{sv})", &iter); while (g_variant_iter_loop (iter, "{&sv}", &name, &value)) - { - if (strcmp (name, "UserName") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) - { - g_free (priv->name); - priv->name = g_variant_dup_string (value, NULL); - } - else if (strcmp (name, "RealName") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) - { - g_free (priv->real_name); - priv->real_name = g_variant_dup_string (value, NULL); - } - else if (strcmp (name, "HomeDirectory") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) - { - g_free (priv->home_directory); - priv->home_directory = g_variant_dup_string (value, NULL); - } - else if (strcmp (name, "Shell") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) - { - g_free (priv->shell); - priv->shell = g_variant_dup_string (value, NULL); - } - else if (strcmp (name, "SystemAccount") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) - system_account = g_variant_get_boolean (value); - else if (strcmp (name, "Language") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) - { - if (priv->language) - g_free (priv->language); - priv->language = g_variant_dup_string (value, NULL); - } - else if (strcmp (name, "IconFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) - { - g_free (priv->image); - priv->image = g_variant_dup_string (value, NULL); - if (strcmp (priv->image, "") == 0) - { - g_free (priv->image); - priv->image = NULL; - } - } - else if (strcmp (name, "XSession") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) - { - g_free (priv->session); - priv->session = g_variant_dup_string (value, NULL); - } - else if (strcmp (name, "BackgroundFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) - { - g_free (priv->background); - priv->background = g_variant_dup_string (value, NULL); - if (strcmp (priv->background, "") == 0) - { - g_free (priv->background); - priv->background = NULL; - } - } - else if (strcmp (name, "XKeyboardLayouts") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY)) - { - g_strfreev (priv->layouts); - priv->layouts = g_variant_dup_strv (value, NULL); - if (!priv->layouts) - { - priv->layouts = g_malloc (sizeof (gchar *) * 1); - priv->layouts[0] = NULL; - } - } - else if (strcmp (name, "XHasMessages") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) - priv->has_messages = g_variant_get_boolean (value); - else if (strcmp (name, "Uid") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_UINT64)) - priv->uid = g_variant_get_uint64 (value); - } + update_user_property (user, name, value); g_variant_iter_free (iter); g_variant_unref (result); - return !system_account; + return !priv->system_account; } static void @@ -601,7 +684,7 @@ add_accounts_user (CommonUserList *user_list, const gchar *path, gboolean emit_s g_debug ("User %s added", path); priv->user_list = user_list; priv->path = g_strdup (path); - g_signal_connect (user, "changed", G_CALLBACK (user_changed_cb), NULL); + g_signal_connect (user, USER_SIGNAL_CHANGED, G_CALLBACK (user_changed_cb), NULL); if (load_accounts_user (user)) { list_priv->users = g_list_insert_sorted (list_priv->users, user, compare_user); @@ -1088,7 +1171,7 @@ common_user_list_class_init (CommonUserListClass *klass) * The ::user-added signal gets emitted when a user account is created. **/ list_signals[USER_ADDED] = - g_signal_new ("user-added", + g_signal_new (USER_LIST_SIGNAL_USER_ADDED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CommonUserListClass, user_added), @@ -1104,7 +1187,7 @@ common_user_list_class_init (CommonUserListClass *klass) * The ::user-changed signal gets emitted when a user account is modified. **/ list_signals[USER_CHANGED] = - g_signal_new ("user-changed", + g_signal_new (USER_LIST_SIGNAL_USER_CHANGED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CommonUserListClass, user_changed), @@ -1120,7 +1203,7 @@ common_user_list_class_init (CommonUserListClass *klass) * The ::user-removed signal gets emitted when a user account is removed. **/ list_signals[USER_REMOVED] = - g_signal_new ("user-removed", + g_signal_new (USER_LIST_SIGNAL_USER_REMOVED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CommonUserListClass, user_removed), @@ -1744,7 +1827,7 @@ common_user_class_init (CommonUserClass *klass) * The ::changed signal gets emitted this user account is modified. **/ user_signals[CHANGED] = - g_signal_new ("changed", + g_signal_new (USER_SIGNAL_CHANGED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CommonUserClass, changed), diff --git a/common/user-list.h b/common/user-list.h index 0d38cfe9..8d16e8d0 100644 --- a/common/user-list.h +++ b/common/user-list.h @@ -32,6 +32,12 @@ G_BEGIN_DECLS #define COMMON_IS_USER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), COMMON_TYPE_USER)) #define COMMON_USER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), COMMON_TYPE_USER, CommonUserClass)) +#define USER_LIST_SIGNAL_USER_ADDED "user-added" +#define USER_LIST_SIGNAL_USER_CHANGED "user-changed" +#define USER_LIST_SIGNAL_USER_REMOVED "user-removed" + +#define USER_SIGNAL_CHANGED "changed" + typedef struct { GObject parent_instance; diff --git a/liblightdm-gobject/greeter.c b/liblightdm-gobject/greeter.c index 8214490c..1c281450 100644 --- a/liblightdm-gobject/greeter.c +++ b/liblightdm-gobject/greeter.c @@ -1804,7 +1804,7 @@ lightdm_greeter_class_init (LightDMGreeterClass *klass) * lightdm_greeter_cancel_authentication() to abort the authentication. **/ signals[SHOW_PROMPT] = - g_signal_new ("show-prompt", + g_signal_new (LIGHTDM_GREETER_SIGNAL_SHOW_PROMPT, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (LightDMGreeterClass, show_prompt), @@ -1822,7 +1822,7 @@ lightdm_greeter_class_init (LightDMGreeterClass *klass) * should show a message to the user. **/ signals[SHOW_MESSAGE] = - g_signal_new ("show-message", + g_signal_new (LIGHTDM_GREETER_SIGNAL_SHOW_MESSAGE, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (LightDMGreeterClass, show_message), @@ -1841,7 +1841,7 @@ lightdm_greeter_class_init (LightDMGreeterClass *klass) * was successful. **/ signals[AUTHENTICATION_COMPLETE] = - g_signal_new ("authentication-complete", + g_signal_new (LIGHTDM_GREETER_SIGNAL_AUTHENTICATION_COMPLETE, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (LightDMGreeterClass, authentication_complete), @@ -1857,7 +1857,7 @@ lightdm_greeter_class_init (LightDMGreeterClass *klass) * The application should then call lightdm_greeter_login(). **/ signals[AUTOLOGIN_TIMER_EXPIRED] = - g_signal_new ("autologin-timer-expired", + g_signal_new (LIGHTDM_GREETER_SIGNAL_AUTOLOGIN_TIMER_EXPIRED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (LightDMGreeterClass, autologin_timer_expired), @@ -1876,7 +1876,7 @@ lightdm_greeter_class_init (LightDMGreeterClass *klass) * resettable using lightdm_greeter_set_resettable(). **/ signals[IDLE] = - g_signal_new ("idle", + g_signal_new (LIGHTDM_GREETER_SIGNAL_IDLE, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (LightDMGreeterClass, idle), @@ -1895,7 +1895,7 @@ lightdm_greeter_class_init (LightDMGreeterClass *klass) * resettable using lightdm_greeter_set_resettable(). **/ signals[RESET] = - g_signal_new ("reset", + g_signal_new (LIGHTDM_GREETER_SIGNAL_RESET, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (LightDMGreeterClass, reset), diff --git a/liblightdm-gobject/lightdm/greeter.h b/liblightdm-gobject/lightdm/greeter.h index 68a81b54..0d046479 100644 --- a/liblightdm-gobject/lightdm/greeter.h +++ b/liblightdm-gobject/lightdm/greeter.h @@ -23,6 +23,13 @@ G_BEGIN_DECLS #define LIGHTDM_IS_GREETER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LIGHTDM_TYPE_GREETER)) #define LIGHTDM_GREETER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LIGHTDM_TYPE_GREETER, LightDMGreeterClass)) +#define LIGHTDM_GREETER_SIGNAL_SHOW_PROMPT "show-prompt" +#define LIGHTDM_GREETER_SIGNAL_SHOW_MESSAGE "show-message" +#define LIGHTDM_GREETER_SIGNAL_AUTHENTICATION_COMPLETE "authentication-complete" +#define LIGHTDM_GREETER_SIGNAL_AUTOLOGIN_TIMER_EXPIRED "autologin-timer-expired" +#define LIGHTDM_GREETER_SIGNAL_IDLE "idle" +#define LIGHTDM_GREETER_SIGNAL_RESET "reset" + /** * LightDMPromptType: * @LIGHTDM_PROMPT_TYPE_QUESTION: Prompt is a question. The information can be shown as it is entered. diff --git a/liblightdm-gobject/lightdm/user.h b/liblightdm-gobject/lightdm/user.h index f955ab29..f2bea3fc 100644 --- a/liblightdm-gobject/lightdm/user.h +++ b/liblightdm-gobject/lightdm/user.h @@ -29,6 +29,12 @@ G_BEGIN_DECLS #define LIGHTDM_IS_USER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LIGHTDM_TYPE_USER)) #define LIGHTDM_USER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LIGHTDM_TYPE_USER, LightDMUserClass)) +#define LIGHTDM_USER_LIST_SIGNAL_USER_ADDED "user-added" +#define LIGHTDM_USER_LIST_SIGNAL_USER_CHANGED "user-changed" +#define LIGHTDM_USER_LIST_SIGNAL_USER_REMOVED "user-removed" + +#define LIGHTDM_SIGNAL_USER_CHANGED "changed" + typedef struct { GObject parent_instance; diff --git a/liblightdm-gobject/user.c b/liblightdm-gobject/user.c index c4e5661e..f8355df2 100644 --- a/liblightdm-gobject/user.c +++ b/liblightdm-gobject/user.c @@ -104,7 +104,7 @@ static LightDMUser * wrap_common_user (CommonUser *user) { LightDMUser *lightdm_user = g_object_new (LIGHTDM_TYPE_USER, "common-user", user, NULL); - g_signal_connect (user, "changed", G_CALLBACK (user_changed_cb), lightdm_user); + g_signal_connect (user, USER_SIGNAL_CHANGED, G_CALLBACK (user_changed_cb), lightdm_user); return lightdm_user; } @@ -167,9 +167,9 @@ initialize_user_list_if_needed (LightDMUserList *user_list) priv->lightdm_list = g_list_reverse (priv->lightdm_list); CommonUserList *common_list = common_user_list_get_instance (); - g_signal_connect (common_list, "user-added", G_CALLBACK (user_list_added_cb), user_list); - g_signal_connect (common_list, "user-changed", G_CALLBACK (user_list_changed_cb), user_list); - g_signal_connect (common_list, "user-removed", G_CALLBACK (user_list_removed_cb), user_list); + g_signal_connect (common_list, USER_LIST_SIGNAL_USER_ADDED, G_CALLBACK (user_list_added_cb), user_list); + g_signal_connect (common_list, USER_LIST_SIGNAL_USER_CHANGED, G_CALLBACK (user_list_changed_cb), user_list); + g_signal_connect (common_list, USER_LIST_SIGNAL_USER_REMOVED, G_CALLBACK (user_list_removed_cb), user_list); priv->initialized = TRUE; } @@ -306,7 +306,7 @@ lightdm_user_list_class_init (LightDMUserListClass *klass) * The ::user-added signal gets emitted when a user account is created. **/ list_signals[USER_ADDED] = - g_signal_new ("user-added", + g_signal_new (LIGHTDM_USER_LIST_SIGNAL_USER_ADDED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (LightDMUserListClass, user_added), @@ -322,7 +322,7 @@ lightdm_user_list_class_init (LightDMUserListClass *klass) * The ::user-changed signal gets emitted when a user account is modified. **/ list_signals[USER_CHANGED] = - g_signal_new ("user-changed", + g_signal_new (LIGHTDM_USER_LIST_SIGNAL_USER_CHANGED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (LightDMUserListClass, user_changed), @@ -338,7 +338,7 @@ lightdm_user_list_class_init (LightDMUserListClass *klass) * The ::user-removed signal gets emitted when a user account is removed. **/ list_signals[USER_REMOVED] = - g_signal_new ("user-removed", + g_signal_new (LIGHTDM_USER_LIST_SIGNAL_USER_REMOVED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (LightDMUserListClass, user_removed), @@ -752,7 +752,7 @@ lightdm_user_class_init (LightDMUserClass *klass) * The ::changed signal gets emitted this user account is modified. **/ user_signals[CHANGED] = - g_signal_new ("changed", + g_signal_new (LIGHTDM_SIGNAL_USER_CHANGED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (LightDMUserClass, changed), diff --git a/liblightdm-qt/greeter.cpp b/liblightdm-qt/greeter.cpp index 3ef6996b..382e3e1e 100644 --- a/liblightdm-qt/greeter.cpp +++ b/liblightdm-qt/greeter.cpp @@ -48,12 +48,12 @@ GreeterPrivate::GreeterPrivate(Greeter *parent) : #endif ldmGreeter = lightdm_greeter_new(); - g_signal_connect (ldmGreeter, "show-prompt", G_CALLBACK (cb_showPrompt), this); - g_signal_connect (ldmGreeter, "show-message", G_CALLBACK (cb_showMessage), this); - g_signal_connect (ldmGreeter, "authentication-complete", G_CALLBACK (cb_authenticationComplete), this); - g_signal_connect (ldmGreeter, "autologin-timer-expired", G_CALLBACK (cb_autoLoginExpired), this); - g_signal_connect (ldmGreeter, "idle", G_CALLBACK (cb_idle), this); - g_signal_connect (ldmGreeter, "reset", G_CALLBACK (cb_reset), this); + g_signal_connect (ldmGreeter, LIGHTDM_GREETER_SIGNAL_SHOW_PROMPT, G_CALLBACK (cb_showPrompt), this); + g_signal_connect (ldmGreeter, LIGHTDM_GREETER_SIGNAL_SHOW_MESSAGE, G_CALLBACK (cb_showMessage), this); + g_signal_connect (ldmGreeter, LIGHTDM_GREETER_SIGNAL_AUTHENTICATION_COMPLETE, G_CALLBACK (cb_authenticationComplete), this); + g_signal_connect (ldmGreeter, LIGHTDM_GREETER_SIGNAL_AUTOLOGIN_TIMER_EXPIRED, G_CALLBACK (cb_autoLoginExpired), this); + g_signal_connect (ldmGreeter, LIGHTDM_GREETER_SIGNAL_IDLE, G_CALLBACK (cb_idle), this); + g_signal_connect (ldmGreeter, LIGHTDM_GREETER_SIGNAL_RESET, G_CALLBACK (cb_reset), this); } void GreeterPrivate::cb_showPrompt(LightDMGreeter *greeter, const gchar *text, LightDMPromptType type, gpointer data) diff --git a/liblightdm-qt/usersmodel.cpp b/liblightdm-qt/usersmodel.cpp index 558cd329..14d8df1f 100644 --- a/liblightdm-qt/usersmodel.cpp +++ b/liblightdm-qt/usersmodel.cpp @@ -106,9 +106,9 @@ void UsersModelPrivate::loadUsers() q->endInsertRows(); } - g_signal_connect(lightdm_user_list_get_instance(), "user-added", G_CALLBACK (cb_userAdded), this); - g_signal_connect(lightdm_user_list_get_instance(), "user-changed", G_CALLBACK (cb_userChanged), this); - g_signal_connect(lightdm_user_list_get_instance(), "user-removed", G_CALLBACK (cb_userRemoved), this); + g_signal_connect(lightdm_user_list_get_instance(), LIGHTDM_USER_LIST_SIGNAL_USER_ADDED, G_CALLBACK (cb_userAdded), this); + g_signal_connect(lightdm_user_list_get_instance(), LIGHTDM_USER_LIST_SIGNAL_USER_CHANGED, G_CALLBACK (cb_userChanged), this); + g_signal_connect(lightdm_user_list_get_instance(), LIGHTDM_USER_LIST_SIGNAL_USER_REMOVED, G_CALLBACK (cb_userRemoved), this); } void UsersModelPrivate::cb_userAdded(LightDMUserList *user_list, LightDMUser *ldmUser, gpointer data) diff --git a/src/display-manager.c b/src/display-manager.c index bf8d24ae..b683fdaa 100644 --- a/src/display-manager.c +++ b/src/display-manager.c @@ -111,7 +111,7 @@ display_manager_add_seat (DisplayManager *manager, Seat *seat) return FALSE; manager->priv->seats = g_list_append (manager->priv->seats, g_object_ref (seat)); - g_signal_connect (seat, "stopped", G_CALLBACK (seat_stopped_cb), manager); + g_signal_connect (seat, SEAT_SIGNAL_STOPPED, G_CALLBACK (seat_stopped_cb), manager); g_signal_emit (manager, signals[SEAT_ADDED], 0, seat); return TRUE; @@ -195,7 +195,7 @@ display_manager_class_init (DisplayManagerClass *klass) g_type_class_add_private (klass, sizeof (DisplayManagerPrivate)); signals[SEAT_ADDED] = - g_signal_new ("seat-added", + g_signal_new (DISPLAY_MANAGER_SIGNAL_SEAT_ADDED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (DisplayManagerClass, seat_added), @@ -203,7 +203,7 @@ display_manager_class_init (DisplayManagerClass *klass) NULL, G_TYPE_NONE, 1, SEAT_TYPE); signals[SEAT_REMOVED] = - g_signal_new ("seat-removed", + g_signal_new (DISPLAY_MANAGER_SIGNAL_SEAT_REMOVED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (DisplayManagerClass, seat_removed), @@ -211,7 +211,7 @@ display_manager_class_init (DisplayManagerClass *klass) NULL, G_TYPE_NONE, 1, SEAT_TYPE); signals[STOPPED] = - g_signal_new ("stopped", + g_signal_new (DISPLAY_MANAGER_SIGNAL_STOPPED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (DisplayManagerClass, stopped), diff --git a/src/display-manager.h b/src/display-manager.h index c4b7d939..bc3ec517 100644 --- a/src/display-manager.h +++ b/src/display-manager.h @@ -21,6 +21,10 @@ G_BEGIN_DECLS #define DISPLAY_MANAGER_TYPE (display_manager_get_type()) #define DISPLAY_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DISPLAY_MANAGER_TYPE, DisplayManager)); +#define DISPLAY_MANAGER_SIGNAL_SEAT_ADDED "seat-added" +#define DISPLAY_MANAGER_SIGNAL_SEAT_REMOVED "seat-removed" +#define DISPLAY_MANAGER_SIGNAL_STOPPED "stopped" + typedef struct DisplayManagerPrivate DisplayManagerPrivate; typedef struct diff --git a/src/display-server.c b/src/display-server.c index 19098d2c..336a6eed 100644 --- a/src/display-server.c +++ b/src/display-server.c @@ -179,7 +179,7 @@ display_server_class_init (DisplayServerClass *klass) g_type_class_add_private (klass, sizeof (DisplayServerPrivate)); signals[READY] = - g_signal_new ("ready", + g_signal_new (DISPLAY_SERVER_SIGNAL_READY, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (DisplayServerClass, ready), @@ -187,7 +187,7 @@ display_server_class_init (DisplayServerClass *klass) NULL, G_TYPE_NONE, 0); signals[STOPPED] = - g_signal_new ("stopped", + g_signal_new (DISPLAY_SERVER_SIGNAL_STOPPED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (DisplayServerClass, stopped), diff --git a/src/display-server.h b/src/display-server.h index c31d096e..4d6f888a 100644 --- a/src/display-server.h +++ b/src/display-server.h @@ -26,6 +26,9 @@ G_BEGIN_DECLS #define DISPLAY_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DISPLAY_SERVER_TYPE, DisplayServerClass)) #define DISPLAY_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DISPLAY_SERVER_TYPE, DisplayServerClass)) +#define DISPLAY_SERVER_SIGNAL_READY "ready" +#define DISPLAY_SERVER_SIGNAL_STOPPED "stopped" + typedef struct DisplayServerPrivate DisplayServerPrivate; struct DisplayServer diff --git a/src/greeter.c b/src/greeter.c index 980fa8eb..e1d47f86 100644 --- a/src/greeter.c +++ b/src/greeter.c @@ -436,7 +436,7 @@ handle_login (Greeter *greeter, guint32 sequence_number, const gchar *username) if (greeter->priv->active_username) g_free (greeter->priv->active_username); greeter->priv->active_username = g_strdup (username); - g_object_notify (G_OBJECT (greeter), "active-username"); + g_object_notify (G_OBJECT (greeter), GREETER_PROPERTY_ACTIVE_USERNAME); greeter->priv->authentication_sequence_number = sequence_number; g_signal_emit (greeter, signals[CREATE_SESSION], 0, &greeter->priv->authentication_session); @@ -446,8 +446,8 @@ handle_login (Greeter *greeter, guint32 sequence_number, const gchar *username) return; } - g_signal_connect (G_OBJECT (greeter->priv->authentication_session), "got-messages", G_CALLBACK (pam_messages_cb), greeter); - g_signal_connect (G_OBJECT (greeter->priv->authentication_session), "authentication-complete", G_CALLBACK (authentication_complete_cb), greeter); + g_signal_connect (G_OBJECT (greeter->priv->authentication_session), SESSION_SIGNAL_GOT_MESSAGES, G_CALLBACK (pam_messages_cb), greeter); + g_signal_connect (G_OBJECT (greeter->priv->authentication_session), SESSION_SIGNAL_AUTHENTICATION_COMPLETE, G_CALLBACK (authentication_complete_cb), greeter); /* Use non-interactive service for autologin user */ autologin_username = g_hash_table_lookup (greeter->priv->hints, "autologin-user"); @@ -550,8 +550,8 @@ handle_login_remote (Greeter *greeter, const gchar *session_name, const gchar *u g_signal_emit (greeter, signals[CREATE_SESSION], 0, &greeter->priv->authentication_session); if (greeter->priv->authentication_session) { - g_signal_connect (G_OBJECT (greeter->priv->authentication_session), "got-messages", G_CALLBACK (pam_messages_cb), greeter); - g_signal_connect (G_OBJECT (greeter->priv->authentication_session), "authentication-complete", G_CALLBACK (authentication_complete_cb), greeter); + g_signal_connect (G_OBJECT (greeter->priv->authentication_session), SESSION_SIGNAL_GOT_MESSAGES, G_CALLBACK (pam_messages_cb), greeter); + g_signal_connect (G_OBJECT (greeter->priv->authentication_session), SESSION_SIGNAL_AUTHENTICATION_COMPLETE, G_CALLBACK (authentication_complete_cb), greeter); /* Run the session process */ session_set_pam_service (greeter->priv->authentication_session, service); @@ -1101,7 +1101,7 @@ greeter_class_init (GreeterClass *klass) object_class->set_property = greeter_set_property; signals[CONNECTED] = - g_signal_new ("connected", + g_signal_new (GREETER_SIGNAL_CONNECTED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GreeterClass, connected), @@ -1110,7 +1110,7 @@ greeter_class_init (GreeterClass *klass) G_TYPE_NONE, 0); signals[CREATE_SESSION] = - g_signal_new ("create-session", + g_signal_new (GREETER_SIGNAL_CREATE_SESSION, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GreeterClass, create_session), @@ -1120,7 +1120,7 @@ greeter_class_init (GreeterClass *klass) SESSION_TYPE, 0); signals[START_SESSION] = - g_signal_new ("start-session", + g_signal_new (GREETER_SIGNAL_START_SESSION, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GreeterClass, start_session), @@ -1131,8 +1131,8 @@ greeter_class_init (GreeterClass *klass) g_object_class_install_property (object_class, PROP_ACTIVE_USERNAME, - g_param_spec_string ("active-username", - "active-username", + g_param_spec_string (GREETER_PROPERTY_ACTIVE_USERNAME, + GREETER_PROPERTY_ACTIVE_USERNAME, "Active username", NULL, G_PARAM_READABLE)); diff --git a/src/greeter.h b/src/greeter.h index 47929ac1..32b76b5e 100644 --- a/src/greeter.h +++ b/src/greeter.h @@ -22,6 +22,14 @@ G_BEGIN_DECLS #define GREETER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_TYPE, GreeterClass)) #define IS_GREETER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_TYPE)) +#define GREETER_SIGNAL_CONNECTED "connected" +#define GREETER_SIGNAL_CREATE_SESSION "create-session" +#define GREETER_SIGNAL_START_SESSION "start-session" + +#define GREETER_PROPERTY_ACTIVE_USERNAME "active-username" + +#define GREETER_SIGNAL_ACTIVE_USERNAME_CHANGED "notify::" GREETER_PROPERTY_ACTIVE_USERNAME + typedef struct GreeterPrivate GreeterPrivate; typedef struct diff --git a/src/lightdm.c b/src/lightdm.c index f48af8bb..838ecbd5 100644 --- a/src/lightdm.c +++ b/src/lightdm.c @@ -147,32 +147,54 @@ log_init (void) g_free (path); } -static void -set_seat_properties (Seat *seat, const gchar *config_section) +static GList* +get_config_sections (const gchar *seat_name) { - gchar **keys; - gint i; + gchar **groups, **i; + GList *config_sections = NULL; - keys = config_get_keys (config_get_instance (), "SeatDefaults"); - for (i = 0; keys && keys[i]; i++) + config_sections = g_list_append (config_sections, g_strdup ("SeatDefaults")); + + if (!seat_name) + return config_sections; + + groups = config_get_groups (config_get_instance ()); + for (i = groups; *i; i++) { - gchar *value = config_get_string (config_get_instance (), "SeatDefaults", keys[i]); - seat_set_property (seat, keys[i], value); - g_free (value); + if (g_str_has_prefix (*i, "Seat:")) + { + const gchar *seat_name_glob = *i + strlen ("Seat:"); + if (g_pattern_match_simple (seat_name_glob, seat_name)) + config_sections = g_list_append (config_sections, g_strdup (*i)); + } } - g_strfreev (keys); + g_strfreev (groups); + + return config_sections; +} - if (config_section) +static void +set_seat_properties (Seat *seat, const gchar *seat_name) +{ + GList *sections, *link; + gchar **keys; + gint i; + + sections = get_config_sections (seat_name); + for (link = sections; link; link = link->next) { - keys = config_get_keys (config_get_instance (), config_section); + const gchar *section = link->data; + g_debug ("Loading properties from config section %s", section); + keys = config_get_keys (config_get_instance (), section); for (i = 0; keys && keys[i]; i++) { - gchar *value = config_get_string (config_get_instance (), config_section, keys[i]); + gchar *value = config_get_string (config_get_instance (), section, keys[i]); seat_set_property (seat, keys[i], value); g_free (value); } g_strfreev (keys); } + g_list_free_full (sections, g_free); } static void @@ -223,11 +245,7 @@ display_manager_seat_removed_cb (DisplayManager *display_manager, Seat *seat) if (next_seat) { - gchar *config_section; - - config_section = g_strdup_printf ("Seat:%s", seat_get_name (seat)); - set_seat_properties (next_seat, config_section); - g_free (config_section); + set_seat_properties (next_seat, seat_get_name (seat)); // We set this manually on default seat. Let's port it over if needed. if (seat_get_boolean_property (seat, "exit-on-failure")) @@ -705,8 +723,8 @@ seat_added_cb (DisplayManager *display_manager, Seat *seat) emit_object_value_changed (bus, "/org/freedesktop/DisplayManager", "org.freedesktop.DisplayManager", "Seats", get_seat_list ()); emit_object_signal (bus, "/org/freedesktop/DisplayManager", "SeatAdded", entry->path); - g_signal_connect (seat, "running-user-session", G_CALLBACK (running_user_session_cb), NULL); - g_signal_connect (seat, "session-removed", G_CALLBACK (session_removed_cb), NULL); + g_signal_connect (seat, SEAT_SIGNAL_RUNNING_USER_SESSION, G_CALLBACK (running_user_session_cb), NULL); + g_signal_connect (seat, SEAT_SIGNAL_SESSION_REMOVED, G_CALLBACK (session_removed_cb), NULL); } static void @@ -838,8 +856,8 @@ bus_acquired_cb (GDBusConnection *connection, seat_bus_entries = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, seat_bus_entry_free); session_bus_entries = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, session_bus_entry_free); - g_signal_connect (display_manager, "seat-added", G_CALLBACK (seat_added_cb), NULL); - g_signal_connect (display_manager, "seat-removed", G_CALLBACK (seat_removed_cb), NULL); + g_signal_connect (display_manager, DISPLAY_MANAGER_SIGNAL_SEAT_ADDED, G_CALLBACK (seat_added_cb), NULL); + g_signal_connect (display_manager, DISPLAY_MANAGER_SIGNAL_SEAT_REMOVED, G_CALLBACK (seat_removed_cb), NULL); for (link = display_manager_get_seats (display_manager); link; link = link->next) seat_added_cb (display_manager, (Seat *) link->data); @@ -858,7 +876,7 @@ bus_acquired_cb (GDBusConnection *connection, if (port > 0) xdmcp_server_set_port (xdmcp_server, port); } - g_signal_connect (xdmcp_server, "new-session", G_CALLBACK (xdmcp_session_cb), NULL); + g_signal_connect (xdmcp_server, XDMCP_SERVER_SIGNAL_NEW_SESSION, G_CALLBACK (xdmcp_session_cb), NULL); key_name = config_get_string (config_get_instance (), "XDMCPServer", "key"); if (key_name) @@ -911,7 +929,7 @@ bus_acquired_cb (GDBusConnection *connection, if (port > 0) vnc_server_set_port (vnc_server, port); } - g_signal_connect (vnc_server, "new-connection", G_CALLBACK (vnc_connection_cb), NULL); + g_signal_connect (vnc_server, VNC_SERVER_SIGNAL_NEW_CONNECTION, G_CALLBACK (vnc_connection_cb), NULL); g_debug ("Starting VNC server on TCP/IP port %d", vnc_server_get_port (vnc_server)); vnc_server_start (vnc_server); @@ -940,42 +958,31 @@ static gboolean add_login1_seat (Login1Seat *login1_seat) { const gchar *seat_name = login1_seat_get_id (login1_seat); - gchar **groups, **i; - gchar *config_section = NULL; gchar **types = NULL, **type; + GList *config_sections = NULL, *link; Seat *seat = NULL; gboolean is_seat0, started = FALSE; g_debug ("New seat added from logind: %s", seat_name); is_seat0 = strcmp (seat_name, "seat0") == 0; - groups = config_get_groups (config_get_instance ()); - for (i = groups; !config_section && *i; i++) - { - if (g_str_has_prefix (*i, "Seat:") && - g_str_has_suffix (*i, seat_name)) - { - config_section = g_strdup (*i); - break; - } - } - g_strfreev (groups); - - if (config_section) + config_sections = get_config_sections (seat_name); + for (link = g_list_last (config_sections); link; link = link->prev) { - g_debug ("Loading properties from config section %s", config_section); + gchar *config_section = link->data; types = config_get_string_list (config_get_instance (), config_section, "type"); + if (types) + break; } + g_list_free_full (config_sections, g_free); - if (!types) - types = config_get_string_list (config_get_instance (), "SeatDefaults", "type"); for (type = types; !seat && type && *type; type++) seat = seat_new (*type, seat_name); g_strfreev (types); if (seat) { - set_seat_properties (seat, NULL); + set_seat_properties (seat, seat_name); if (!login1_seat_get_can_multi_session (login1_seat)) { @@ -983,9 +990,6 @@ add_login1_seat (Login1Seat *login1_seat) seat_set_property (seat, "allow-user-switching", "false"); } - if (config_section) - set_seat_properties (seat, config_section); - if (is_seat0) seat_set_property (seat, "exit-on-failure", "true"); } @@ -999,7 +1003,6 @@ add_login1_seat (Login1Seat *login1_seat) g_debug ("Failed to start seat: %s", seat_name); } - g_free (config_section); g_object_unref (seat); return started; @@ -1035,7 +1038,7 @@ update_login1_seat (Login1Seat *login1_seat) if (seat) { if (seat_get_is_stopping (seat)) - g_signal_connect (seat, "stopped", G_CALLBACK (seat_stopped_cb), login1_seat); + g_signal_connect (seat, SEAT_SIGNAL_STOPPED, G_CALLBACK (seat_stopped_cb), login1_seat); return TRUE; } @@ -1064,7 +1067,7 @@ login1_service_seat_added_cb (Login1Service *service, Login1Seat *login1_seat) g_debug ("Seat %s added from logind without graphical output", login1_seat_get_id (login1_seat)); if (config_get_boolean (config_get_instance (), "LightDM", "logind-check-graphical")) - g_signal_connect (login1_seat, "can-graphical-changed", G_CALLBACK (login1_can_graphical_changed_cb), NULL); + g_signal_connect (login1_seat, LOGIN1_SEAT_SIGNAL_CAN_GRAPHICAL_CHANGED, G_CALLBACK (login1_can_graphical_changed_cb), NULL); update_login1_seat (login1_seat); } @@ -1137,7 +1140,7 @@ main (int argc, char **argv) messages = g_list_append (messages, g_strdup_printf ("Starting Light Display Manager %s, UID=%i PID=%i", VERSION, getuid (), getpid ())); - g_signal_connect (process_get_current (), "got-signal", G_CALLBACK (signal_cb), NULL); + g_signal_connect (process_get_current (), PROCESS_SIGNAL_GOT_SIGNAL, G_CALLBACK (signal_cb), NULL); option_context = g_option_context_new (/* Arguments and description for --help test */ _("- Display Manager")); @@ -1401,8 +1404,8 @@ main (int argc, char **argv) g_debug ("Using Xephyr for X servers"); display_manager = display_manager_new (); - g_signal_connect (display_manager, "stopped", G_CALLBACK (display_manager_stopped_cb), NULL); - g_signal_connect (display_manager, "seat-removed", G_CALLBACK (display_manager_seat_removed_cb), NULL); + g_signal_connect (display_manager, DISPLAY_MANAGER_SIGNAL_STOPPED, G_CALLBACK (display_manager_stopped_cb), NULL); + g_signal_connect (display_manager, DISPLAY_MANAGER_SIGNAL_SEAT_REMOVED, G_CALLBACK (display_manager_seat_removed_cb), NULL); shared_data_manager_start (shared_data_manager_get_instance ()); @@ -1414,14 +1417,14 @@ main (int argc, char **argv) if (config_get_boolean (config_get_instance (), "LightDM", "start-default-seat")) { - g_signal_connect (login1_service_get_instance (), "seat-added", G_CALLBACK (login1_service_seat_added_cb), NULL); - g_signal_connect (login1_service_get_instance (), "seat-removed", G_CALLBACK (login1_service_seat_removed_cb), NULL); + g_signal_connect (login1_service_get_instance (), LOGIN1_SERVICE_SIGNAL_SEAT_ADDED, G_CALLBACK (login1_service_seat_added_cb), NULL); + g_signal_connect (login1_service_get_instance (), LOGIN1_SERVICE_SIGNAL_SEAT_REMOVED, G_CALLBACK (login1_service_seat_removed_cb), NULL); for (link = login1_service_get_seats (login1_service_get_instance ()); link; link = link->next) { Login1Seat *login1_seat = link->data; if (config_get_boolean (config_get_instance (), "LightDM", "logind-check-graphical")) - g_signal_connect (login1_seat, "can-graphical-changed", G_CALLBACK (login1_can_graphical_changed_cb), NULL); + g_signal_connect (login1_seat, LOGIN1_SEAT_SIGNAL_CAN_GRAPHICAL_CHANGED, G_CALLBACK (login1_can_graphical_changed_cb), NULL); if (!update_login1_seat (login1_seat)) return EXIT_FAILURE; } diff --git a/src/login1.c b/src/login1.c index f799e3ed..83d64b6e 100644 --- a/src/login1.c +++ b/src/login1.c @@ -82,6 +82,16 @@ login1_service_get_instance (void) } static void +update_property (Login1Seat *seat, const gchar *name, GVariant *value) +{ + if (strcmp (name, "CanGraphical") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) + { + seat->priv->can_graphical = g_variant_get_boolean (value); + g_signal_emit (seat, seat_signals[CAN_GRAPHICAL_CHANGED], 0); + } +} + +static void seat_properties_changed_cb (GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, @@ -91,43 +101,39 @@ seat_properties_changed_cb (GDBusConnection *connection, gpointer user_data) { Login1Seat *seat = user_data; + GVariantIter *iter; GVariantIter *invalidated_properties; - const gchar *property_name; - - g_variant_get (parameters, "(sa{sv}as)", NULL, NULL, &invalidated_properties); - while (g_variant_iter_loop (invalidated_properties, "&s", &property_name)) + const gchar *name; + GVariant *value; + + g_variant_get (parameters, "(sa{sv}as)", NULL, &iter, &invalidated_properties); + while (g_variant_iter_loop (iter, "{&sv}", &name, &value)) + update_property (seat, name, value); + g_variant_iter_free (iter); + while (g_variant_iter_loop (invalidated_properties, "&s", &name)) { - if (strcmp (property_name, "CanGraphical") == 0) - { - GVariant *result; - GError *error = NULL; - - result = g_dbus_connection_call_sync (connection, - LOGIN1_SERVICE_NAME, - seat->priv->path, - "org.freedesktop.DBus.Properties", - "Get", - g_variant_new ("(ss)", "org.freedesktop.login1.Seat", property_name), - G_VARIANT_TYPE ("(v)"), - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - &error); - if (error) - g_warning ("Error updating CanGraphical: %s", error->message); - g_clear_error (&error); - if (result) - { - GVariant *value; - - g_variant_get (result, "(v)", &value); - seat->priv->can_graphical = g_variant_get_boolean (value); - g_variant_unref (value); - - g_signal_emit (seat, seat_signals[CAN_GRAPHICAL_CHANGED], 0); + GVariant *result; + GError *error = NULL; - g_variant_unref (result); - } + result = g_dbus_connection_call_sync (connection, + LOGIN1_SERVICE_NAME, + seat->priv->path, + "org.freedesktop.DBus.Properties", + "Get", + g_variant_new ("(ss)", "org.freedesktop.login1.Seat", name), + G_VARIANT_TYPE ("(v)"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (error) + g_warning ("Error updating seat property %s: %s", name, error->message); + g_clear_error (&error); + if (result) + { + g_variant_get (result, "(v)", &value); + update_property (seat, name, value); + g_variant_unref (result); } } g_variant_iter_free (invalidated_properties); @@ -451,7 +457,7 @@ login1_service_class_init (Login1ServiceClass *klass) g_type_class_add_private (klass, sizeof (Login1ServicePrivate)); service_signals[SEAT_ADDED] = - g_signal_new ("seat-added", + g_signal_new (LOGIN1_SERVICE_SIGNAL_SEAT_ADDED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (Login1ServiceClass, seat_added), @@ -459,7 +465,7 @@ login1_service_class_init (Login1ServiceClass *klass) NULL, G_TYPE_NONE, 1, LOGIN1_SEAT_TYPE); service_signals[SEAT_REMOVED] = - g_signal_new ("seat-removed", + g_signal_new (LOGIN1_SERVICE_SIGNAL_SEAT_REMOVED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (Login1ServiceClass, seat_removed), @@ -518,7 +524,7 @@ login1_seat_class_init (Login1SeatClass *klass) g_type_class_add_private (klass, sizeof (Login1SeatPrivate)); seat_signals[CAN_GRAPHICAL_CHANGED] = - g_signal_new ("can-graphical-changed", + g_signal_new (LOGIN1_SEAT_SIGNAL_CAN_GRAPHICAL_CHANGED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (Login1SeatClass, can_graphical_changed), diff --git a/src/login1.h b/src/login1.h index af9f2a96..c266e23d 100644 --- a/src/login1.h +++ b/src/login1.h @@ -22,6 +22,11 @@ G_BEGIN_DECLS #define LOGIN1_SERVICE_TYPE (login1_service_get_type()) #define LOGIN1_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LOGIN1_SERVICE_TYPE, Login1Service)); +#define LOGIN1_SERVICE_SIGNAL_SEAT_ADDED "seat-added" +#define LOGIN1_SERVICE_SIGNAL_SEAT_REMOVED "seat-removed" + +#define LOGIN1_SEAT_SIGNAL_CAN_GRAPHICAL_CHANGED "can-graphical-changed" + typedef struct Login1SeatPrivate Login1SeatPrivate; typedef struct diff --git a/src/process.c b/src/process.c index adb06f78..50c0a9b0 100644 --- a/src/process.c +++ b/src/process.c @@ -432,7 +432,7 @@ process_class_init (ProcessClass *klass) g_type_class_add_private (klass, sizeof (ProcessPrivate)); signals[GOT_DATA] = - g_signal_new ("got-data", + g_signal_new (PROCESS_SIGNAL_GOT_DATA, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ProcessClass, got_data), @@ -440,7 +440,7 @@ process_class_init (ProcessClass *klass) NULL, G_TYPE_NONE, 0); signals[GOT_SIGNAL] = - g_signal_new ("got-signal", + g_signal_new (PROCESS_SIGNAL_GOT_SIGNAL, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ProcessClass, got_signal), @@ -448,7 +448,7 @@ process_class_init (ProcessClass *klass) NULL, G_TYPE_NONE, 1, G_TYPE_INT); signals[STOPPED] = - g_signal_new ("stopped", + g_signal_new (PROCESS_SIGNAL_STOPPED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ProcessClass, stopped), diff --git a/src/process.h b/src/process.h index d15477b1..b8c50926 100644 --- a/src/process.h +++ b/src/process.h @@ -21,6 +21,10 @@ G_BEGIN_DECLS #define PROCESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROCESS_TYPE, Process)) #define PROCESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROCESS_TYPE, ProcessClass)) +#define PROCESS_SIGNAL_GOT_DATA "got-data" +#define PROCESS_SIGNAL_GOT_SIGNAL "got-signal" +#define PROCESS_SIGNAL_STOPPED "stopped" + typedef struct ProcessPrivate ProcessPrivate; typedef struct diff --git a/src/seat-unity.c b/src/seat-unity.c index bc08437d..32d30b23 100644 --- a/src/seat-unity.c +++ b/src/seat-unity.c @@ -127,7 +127,7 @@ compositor_ready_cb (UnitySystemCompositor *compositor, SeatUnity *seat) g_key_file_free (keys); } - g_signal_connect (seat->priv->xdmcp_x_server, "stopped", G_CALLBACK (xdmcp_x_server_stopped_cb), seat); + g_signal_connect (seat->priv->xdmcp_x_server, DISPLAY_SERVER_SIGNAL_STOPPED, G_CALLBACK (xdmcp_x_server_stopped_cb), seat); if (!display_server_start (DISPLAY_SERVER (seat->priv->xdmcp_x_server))) seat_stop (SEAT (seat)); } @@ -182,8 +182,8 @@ seat_unity_start (Seat *seat) timeout = 60; SEAT_UNITY (seat)->priv->compositor = unity_system_compositor_new (); - g_signal_connect (SEAT_UNITY (seat)->priv->compositor, "ready", G_CALLBACK (compositor_ready_cb), seat); - g_signal_connect (SEAT_UNITY (seat)->priv->compositor, "stopped", G_CALLBACK (compositor_stopped_cb), seat); + g_signal_connect (SEAT_UNITY (seat)->priv->compositor, DISPLAY_SERVER_SIGNAL_READY, G_CALLBACK (compositor_ready_cb), seat); + g_signal_connect (SEAT_UNITY (seat)->priv->compositor, DISPLAY_SERVER_SIGNAL_STOPPED, G_CALLBACK (compositor_stopped_cb), seat); unity_system_compositor_set_command (SEAT_UNITY (seat)->priv->compositor, seat_get_string_property (SEAT (seat), "unity-compositor-command")); unity_system_compositor_set_vt (SEAT_UNITY (seat)->priv->compositor, vt); unity_system_compositor_set_timeout (SEAT_UNITY (seat)->priv->compositor, timeout); diff --git a/src/seat-xlocal.c b/src/seat-xlocal.c index 04a76982..7b5ec7ed 100644 --- a/src/seat-xlocal.c +++ b/src/seat-xlocal.c @@ -110,7 +110,7 @@ seat_xlocal_start (Seat *seat) g_key_file_free (keys); } - g_signal_connect (s->priv->xdmcp_x_server, "stopped", G_CALLBACK (xdmcp_x_server_stopped_cb), seat); + g_signal_connect (s->priv->xdmcp_x_server, DISPLAY_SERVER_SIGNAL_STOPPED, G_CALLBACK (xdmcp_x_server_stopped_cb), seat); return display_server_start (DISPLAY_SERVER (s->priv->xdmcp_x_server)); } @@ -150,8 +150,8 @@ get_vt (Seat *seat, DisplayServer *display_server) if (active_vt >= vt_get_min ()) { vt = active_vt; - g_signal_connect (display_server, "ready", G_CALLBACK (display_server_ready_cb), seat); - g_signal_connect (display_server, "stopped", G_CALLBACK (display_server_transition_plymouth_cb), seat); + g_signal_connect (display_server, DISPLAY_SERVER_SIGNAL_READY, G_CALLBACK (display_server_ready_cb), seat); + g_signal_connect (display_server, DISPLAY_SERVER_SIGNAL_STOPPED, G_CALLBACK (display_server_transition_plymouth_cb), seat); plymouth_deactivate (); } else @@ -850,8 +850,8 @@ create_session (Seat *seat, gboolean autostart) session = SEAT_GET_CLASS (seat)->create_session (seat); seat->priv->sessions = g_list_append (seat->priv->sessions, session); if (autostart) - g_signal_connect (session, "authentication-complete", G_CALLBACK (session_authentication_complete_cb), seat); - g_signal_connect (session, "stopped", G_CALLBACK (session_stopped_cb), seat); + g_signal_connect (session, SESSION_SIGNAL_AUTHENTICATION_COMPLETE, G_CALLBACK (session_authentication_complete_cb), seat); + g_signal_connect (session, SESSION_SIGNAL_STOPPED, G_CALLBACK (session_stopped_cb), seat); set_session_env (session); @@ -1211,9 +1211,9 @@ create_greeter_session (Seat *seat) greeter_session = SEAT_GET_CLASS (seat)->create_greeter_session (seat); session_set_config (SESSION (greeter_session), session_config); seat->priv->sessions = g_list_append (seat->priv->sessions, SESSION (greeter_session)); - g_signal_connect (greeter_session, "notify::active-username", G_CALLBACK (greeter_active_username_changed_cb), seat); - g_signal_connect (greeter_session, "authentication-complete", G_CALLBACK (session_authentication_complete_cb), seat); - g_signal_connect (greeter_session, "stopped", G_CALLBACK (session_stopped_cb), seat); + g_signal_connect (greeter_session, GREETER_SIGNAL_ACTIVE_USERNAME_CHANGED, G_CALLBACK (greeter_active_username_changed_cb), seat); + g_signal_connect (greeter_session, SESSION_SIGNAL_AUTHENTICATION_COMPLETE, G_CALLBACK (session_authentication_complete_cb), seat); + g_signal_connect (greeter_session, SESSION_SIGNAL_STOPPED, G_CALLBACK (session_stopped_cb), seat); set_session_env (SESSION (greeter_session)); session_set_env (SESSION (greeter_session), "XDG_SESSION_CLASS", "greeter"); @@ -1237,8 +1237,8 @@ create_greeter_session (Seat *seat) greeter_set_pam_services (greeter_session, seat_get_string_property (seat, "pam-service"), seat_get_string_property (seat, "pam-autologin-service")); - g_signal_connect (greeter_session, "create-session", G_CALLBACK (greeter_create_session_cb), seat); - g_signal_connect (greeter_session, "start-session", G_CALLBACK (greeter_start_session_cb), seat); + g_signal_connect (greeter_session, GREETER_SIGNAL_CREATE_SESSION, G_CALLBACK (greeter_create_session_cb), seat); + g_signal_connect (greeter_session, GREETER_SIGNAL_START_SESSION, G_CALLBACK (greeter_start_session_cb), seat); /* Set hints to greeter */ greeter_set_allow_guest (greeter_session, seat_get_allow_guest (seat)); @@ -1334,8 +1334,8 @@ create_display_server (Seat *seat, Session *session) return NULL; seat->priv->display_servers = g_list_append (seat->priv->display_servers, display_server); - g_signal_connect (display_server, "ready", G_CALLBACK (display_server_ready_cb), seat); - g_signal_connect (display_server, "stopped", G_CALLBACK (display_server_stopped_cb), seat); + g_signal_connect (display_server, DISPLAY_SERVER_SIGNAL_READY, G_CALLBACK (display_server_ready_cb), seat); + g_signal_connect (display_server, DISPLAY_SERVER_SIGNAL_STOPPED, G_CALLBACK (display_server_stopped_cb), seat); return display_server; } @@ -1466,7 +1466,7 @@ seat_switch_to_user (Seat *seat, const gchar *username, const gchar *session_nam /* Attempt to authenticate them */ session = create_user_session (seat, username, FALSE); - g_signal_connect (session, "authentication-complete", G_CALLBACK (switch_authentication_complete_cb), seat); + g_signal_connect (session, SESSION_SIGNAL_AUTHENTICATION_COMPLETE, G_CALLBACK (switch_authentication_complete_cb), seat); session_set_pam_service (session, seat_get_string_property (seat, "pam-service")); return session_start (session); @@ -1833,7 +1833,7 @@ seat_class_init (SeatClass *klass) g_type_class_add_private (klass, sizeof (SeatPrivate)); signals[SESSION_ADDED] = - g_signal_new ("session-added", + g_signal_new (SEAT_SIGNAL_SESSION_ADDED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SeatClass, session_added), @@ -1841,7 +1841,7 @@ seat_class_init (SeatClass *klass) NULL, G_TYPE_NONE, 1, SESSION_TYPE); signals[RUNNING_USER_SESSION] = - g_signal_new ("running-user-session", + g_signal_new (SEAT_SIGNAL_RUNNING_USER_SESSION, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SeatClass, running_user_session), @@ -1849,7 +1849,7 @@ seat_class_init (SeatClass *klass) NULL, G_TYPE_NONE, 1, SESSION_TYPE); signals[SESSION_REMOVED] = - g_signal_new ("session-removed", + g_signal_new (SEAT_SIGNAL_SESSION_REMOVED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SeatClass, session_removed), @@ -1857,7 +1857,7 @@ seat_class_init (SeatClass *klass) NULL, G_TYPE_NONE, 1, SESSION_TYPE); signals[STOPPED] = - g_signal_new ("stopped", + g_signal_new (SEAT_SIGNAL_STOPPED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SeatClass, stopped), @@ -26,6 +26,11 @@ G_BEGIN_DECLS #define SEAT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAT_TYPE, SeatClass)) #define SEAT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAT_TYPE, SeatClass)) +#define SEAT_SIGNAL_SESSION_ADDED "session-added" +#define SEAT_SIGNAL_RUNNING_USER_SESSION "running-user-session" +#define SEAT_SIGNAL_SESSION_REMOVED "session-removed" +#define SEAT_SIGNAL_STOPPED "stopped" + typedef struct SeatPrivate SeatPrivate; typedef struct diff --git a/src/session.c b/src/session.c index 7b5fcf9a..4b825e78 100644 --- a/src/session.c +++ b/src/session.c @@ -930,7 +930,7 @@ session_class_init (SessionClass *klass) g_type_class_add_private (klass, sizeof (SessionPrivate)); signals[GOT_MESSAGES] = - g_signal_new ("got-messages", + g_signal_new (SESSION_SIGNAL_GOT_MESSAGES, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SessionClass, got_messages), @@ -939,7 +939,7 @@ session_class_init (SessionClass *klass) G_TYPE_NONE, 0); signals[AUTHENTICATION_COMPLETE] = - g_signal_new ("authentication-complete", + g_signal_new (SESSION_SIGNAL_AUTHENTICATION_COMPLETE, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SessionClass, authentication_complete), @@ -948,7 +948,7 @@ session_class_init (SessionClass *klass) G_TYPE_NONE, 0); signals[STOPPED] = - g_signal_new ("stopped", + g_signal_new (SESSION_SIGNAL_STOPPED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SessionClass, stopped), diff --git a/src/session.h b/src/session.h index 38205a8f..b7c245c5 100644 --- a/src/session.h +++ b/src/session.h @@ -31,6 +31,10 @@ G_BEGIN_DECLS #define SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SESSION_TYPE, SessionClass)) #define SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SESSION_TYPE, SessionClass)) +#define SESSION_SIGNAL_GOT_MESSAGES "got-messages" +#define SESSION_SIGNAL_AUTHENTICATION_COMPLETE "authentication-complete" +#define SESSION_SIGNAL_STOPPED "stopped" + typedef struct SessionPrivate SessionPrivate; struct Session diff --git a/src/shared-data-manager.c b/src/shared-data-manager.c index 5b667647..47f1c10d 100644 --- a/src/shared-data-manager.c +++ b/src/shared-data-manager.c @@ -227,7 +227,7 @@ shared_data_manager_start (SharedDataManager *manager) g_object_unref (file); /* And listen for user removals. */ - g_signal_connect (common_user_list_get_instance (), "user-removed", G_CALLBACK (user_removed_cb), manager); + g_signal_connect (common_user_list_get_instance (), USER_LIST_SIGNAL_USER_REMOVED, G_CALLBACK (user_removed_cb), manager); } static void diff --git a/src/unity-system-compositor.c b/src/unity-system-compositor.c index 40502557..03824284 100644 --- a/src/unity-system-compositor.c +++ b/src/unity-system-compositor.c @@ -85,6 +85,8 @@ void unity_system_compositor_set_command (UnitySystemCompositor *compositor, const gchar *command) { g_return_if_fail (compositor != NULL); + g_return_if_fail (command != NULL); + g_free (compositor->priv->command); compositor->priv->command = g_strdup (command); } @@ -438,7 +440,7 @@ unity_system_compositor_start (DisplayServer *server) g_string_free (command, TRUE); /* Start the compositor */ - g_signal_connect (compositor->priv->process, "stopped", G_CALLBACK (stopped_cb), compositor); + g_signal_connect (compositor->priv->process, PROCESS_SIGNAL_STOPPED, G_CALLBACK (stopped_cb), compositor); result = process_start (compositor->priv->process, FALSE); /* Close compostor ends of the pipes */ diff --git a/src/vnc-server.c b/src/vnc-server.c index 1755ffdb..2ccb2292 100644 --- a/src/vnc-server.c +++ b/src/vnc-server.c @@ -168,7 +168,7 @@ vnc_server_class_init (VNCServerClass *klass) g_type_class_add_private (klass, sizeof (VNCServerPrivate)); signals[NEW_CONNECTION] = - g_signal_new ("new-connection", + g_signal_new (VNC_SERVER_SIGNAL_NEW_CONNECTION, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (VNCServerClass, new_connection), diff --git a/src/vnc-server.h b/src/vnc-server.h index 109dc904..64fe1daf 100644 --- a/src/vnc-server.h +++ b/src/vnc-server.h @@ -19,6 +19,8 @@ G_BEGIN_DECLS #define VNC_SERVER_TYPE (vnc_server_get_type()) #define VNC_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VNC_SERVER_TYPE, VNCServer)); +#define VNC_SERVER_SIGNAL_NEW_CONNECTION "new-connection" + typedef struct VNCServerPrivate VNCServerPrivate; typedef struct diff --git a/src/x-server-local.c b/src/x-server-local.c index 3f58e0b7..b6a55aa9 100644 --- a/src/x-server-local.c +++ b/src/x-server-local.c @@ -439,8 +439,8 @@ x_server_local_start (DisplayServer *display_server) server->priv->x_server_process = process_new (run_cb, server); process_set_clear_environment (server->priv->x_server_process, TRUE); - g_signal_connect (server->priv->x_server_process, "got-signal", G_CALLBACK (got_signal_cb), server); - g_signal_connect (server->priv->x_server_process, "stopped", G_CALLBACK (stopped_cb), server); + g_signal_connect (server->priv->x_server_process, PROCESS_SIGNAL_GOT_SIGNAL, G_CALLBACK (got_signal_cb), server); + g_signal_connect (server->priv->x_server_process, PROCESS_SIGNAL_STOPPED, G_CALLBACK (stopped_cb), server); /* Setup logging */ filename = g_strdup_printf ("%s.log", display_server_get_name (display_server)); diff --git a/src/x-server-xvnc.c b/src/x-server-xvnc.c index cea1782a..a48290e5 100644 --- a/src/x-server-xvnc.c +++ b/src/x-server-xvnc.c @@ -195,8 +195,8 @@ x_server_xvnc_start (DisplayServer *display_server) server->priv->x_server_process = process_new (run_cb, server); process_set_clear_environment (server->priv->x_server_process, TRUE); - g_signal_connect (server->priv->x_server_process, "got-signal", G_CALLBACK (got_signal_cb), server); - g_signal_connect (server->priv->x_server_process, "stopped", G_CALLBACK (stopped_cb), server); + g_signal_connect (server->priv->x_server_process, PROCESS_SIGNAL_GOT_SIGNAL, G_CALLBACK (got_signal_cb), server); + g_signal_connect (server->priv->x_server_process, PROCESS_SIGNAL_STOPPED, G_CALLBACK (stopped_cb), server); /* Setup logging */ filename = g_strdup_printf ("%s.log", display_server_get_name (display_server)); diff --git a/src/xdmcp-server.c b/src/xdmcp-server.c index 4d45fb40..d240e380 100644 --- a/src/xdmcp-server.c +++ b/src/xdmcp-server.c @@ -703,7 +703,7 @@ xdmcp_server_class_init (XDMCPServerClass *klass) g_type_class_add_private (klass, sizeof (XDMCPServerPrivate)); signals[NEW_SESSION] = - g_signal_new ("new-session", + g_signal_new (XDMCP_SERVER_SIGNAL_NEW_SESSION, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XDMCPServerClass, new_session), diff --git a/src/xdmcp-server.h b/src/xdmcp-server.h index 31cd0fb6..32ca63b4 100644 --- a/src/xdmcp-server.h +++ b/src/xdmcp-server.h @@ -21,6 +21,8 @@ G_BEGIN_DECLS #define XDMCP_SERVER_TYPE (xdmcp_server_get_type()) #define XDMCP_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XDMCP_SERVER_TYPE, XDMCPServer)); +#define XDMCP_SERVER_SIGNAL_NEW_SESSION "new-session" + typedef struct XDMCPServerPrivate XDMCPServerPrivate; typedef struct diff --git a/tests/Makefile.am b/tests/Makefile.am index d0e7c739..8be0746e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -181,6 +181,7 @@ TESTS = \ test-multi-seat-non-graphical-disabled \ test-multi-seat-change-graphical \ test-multi-seat-change-graphical-disabled \ + test-multi-seat-globbing-config-sections \ test-mir-autologin \ test-mir-greeter \ test-mir-session \ @@ -448,6 +449,7 @@ EXTRA_DIST = \ scripts/multi-seat-non-graphical-disabled.conf \ scripts/multi-seat-seat0-non-graphical.conf \ scripts/multi-seat-seat0-non-graphical-disabled.conf \ + scripts/multi-seat-globbing-config-sections.conf \ scripts/no-accounts-service.conf \ scripts/no-config.conf \ scripts/no-login1.conf \ diff --git a/tests/scripts/multi-seat-globbing-config-sections.conf b/tests/scripts/multi-seat-globbing-config-sections.conf new file mode 100644 index 00000000..3109e649 --- /dev/null +++ b/tests/scripts/multi-seat-globbing-config-sections.conf @@ -0,0 +1,105 @@ +# +# Check can set globbing config sections matching different seats +# + +[Seat:*] +autologin-user=have-password1 +user-session=default + +[Seat:seat*Foo] +autologin-user-timeout=99 + +[Seat:seatAAAFoo] +autologin-user=have-password2 + +[Seat:seatBBB*] +autologin-user=have-password3 + +#?*START-DAEMON +#?RUNNER DAEMON-START + +# seat0 starts +#?XSERVER-0 START VT=7 SEAT=seat0 +#?*XSERVER-0 INDICATE-READY +#?XSERVER-0 INDICATE-READY +#?XSERVER-0 ACCEPT-CONNECT + +# Session starts for configured user +#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 +#?LOGIN1 ACTIVATE-SESSION SESSION=c0 +#?XSERVER-0 ACCEPT-CONNECT +#?SESSION-X-0 CONNECT-XSERVER + +# Add seatAAAFoo +#?*ADD-SEAT ID=seatAAAFoo + +# seatAAAFoo starts +#?XSERVER-1 START SEAT=seatAAAFoo SHAREVTS=TRUE +#?*XSERVER-1 INDICATE-READY +#?XSERVER-1 INDICATE-READY +#?XSERVER-1 ACCEPT-CONNECT + +# Greeter starts +#?GREETER-X-1 START XDG_SEAT=seatAAAFoo XDG_SESSION_CLASS=greeter +#?LOGIN1 ACTIVATE-SESSION SESSION=c1 +#?XSERVER-1 ACCEPT-CONNECT +#?GREETER-X-1 CONNECT-XSERVER +#?GREETER-X-1 CONNECT-TO-DAEMON +#?GREETER-X-1 CONNECTED-TO-DAEMON + +# Greeter is requested to timeout +#?GREETER-X-1 AUTOLOGIN-USER USERNAME=have-password2 TIMEOUT=99 + +# Trigger autologin +#?*GREETER-X-1 AUTHENTICATE-AUTOLOGIN +#?GREETER-X-1 AUTHENTICATION-COMPLETE USERNAME=have-password2 AUTHENTICATED=TRUE +#?*GREETER-X-1 START-SESSION +#?GREETER-X-1 TERMINATE SIGNAL=15 + +# Session starts for configured user +#?SESSION-X-1 START XDG_SEAT=seatAAAFoo XDG_GREETER_DATA_DIR=.*/have-password2 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password2 +#?LOGIN1 ACTIVATE-SESSION SESSION=c2 +#?XSERVER-1 ACCEPT-CONNECT +#?SESSION-X-1 CONNECT-XSERVER + +# Add seatBBBFoo +#?*ADD-SEAT ID=seatBBBFoo + +# seatBBBFoo starts +#?XSERVER-2 START SEAT=seatBBBFoo SHAREVTS=TRUE +#?*XSERVER-2 INDICATE-READY +#?XSERVER-2 INDICATE-READY +#?XSERVER-2 ACCEPT-CONNECT + +# Greeter starts +#?GREETER-X-2 START XDG_SEAT=seatBBBFoo XDG_SESSION_CLASS=greeter +#?LOGIN1 ACTIVATE-SESSION SESSION=c3 +#?XSERVER-2 ACCEPT-CONNECT +#?GREETER-X-2 CONNECT-XSERVER +#?GREETER-X-2 CONNECT-TO-DAEMON +#?GREETER-X-2 CONNECTED-TO-DAEMON + +# Greeter is requested to timeout +#?GREETER-X-2 AUTOLOGIN-USER USERNAME=have-password3 TIMEOUT=99 + +# Trigger autologin +#?*GREETER-X-2 AUTHENTICATE-AUTOLOGIN +#?GREETER-X-2 AUTHENTICATION-COMPLETE USERNAME=have-password3 AUTHENTICATED=TRUE +#?*GREETER-X-2 START-SESSION +#?GREETER-X-2 TERMINATE SIGNAL=15 + +# Session starts for configured user +#?SESSION-X-2 START XDG_SEAT=seatBBBFoo XDG_GREETER_DATA_DIR=.*/have-password3 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password3 +#?LOGIN1 ACTIVATE-SESSION SESSION=c4 +#?XSERVER-2 ACCEPT-CONNECT +#?SESSION-X-2 CONNECT-XSERVER + +# Cleanup +#?*STOP-DAEMON +#?XSERVER-0 TERMINATE SIGNAL=15 +#?SESSION-X-0 TERMINATE SIGNAL=15 +#?XSERVER-1 TERMINATE SIGNAL=15 +#?SESSION-X-1 TERMINATE SIGNAL=15 +#?XSERVER-2 TERMINATE SIGNAL=15 +#?SESSION-X-2 TERMINATE SIGNAL=15 +#?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/src/X.c b/tests/src/X.c index 2fd722da..2ad77b21 100644 --- a/tests/src/X.c +++ b/tests/src/X.c @@ -317,8 +317,8 @@ main (int argc, char **argv) status_connect (request_cb, id); xserver = x_server_new (display_number); - g_signal_connect (xserver, "client-connected", G_CALLBACK (client_connected_cb), NULL); - g_signal_connect (xserver, "client-disconnected", G_CALLBACK (client_disconnected_cb), NULL); + g_signal_connect (xserver, X_SERVER_SIGNAL_CLIENT_CONNECTED, G_CALLBACK (client_connected_cb), NULL); + g_signal_connect (xserver, X_SERVER_SIGNAL_CLIENT_DISCONNECTED, G_CALLBACK (client_disconnected_cb), NULL); status_text = g_string_new (""); g_string_printf (status_text, "%s START", id); @@ -415,11 +415,11 @@ main (int argc, char **argv) xdmcp_client_set_hostname (xdmcp_client, xdmcp_host); if (xdmcp_port > 0) xdmcp_client_set_port (xdmcp_client, xdmcp_port); - g_signal_connect (xdmcp_client, "query", G_CALLBACK (xdmcp_query_cb), NULL); - g_signal_connect (xdmcp_client, "willing", G_CALLBACK (xdmcp_willing_cb), NULL); - g_signal_connect (xdmcp_client, "accept", G_CALLBACK (xdmcp_accept_cb), NULL); - g_signal_connect (xdmcp_client, "decline", G_CALLBACK (xdmcp_decline_cb), NULL); - g_signal_connect (xdmcp_client, "failed", G_CALLBACK (xdmcp_failed_cb), NULL); + g_signal_connect (xdmcp_client, XDMCP_CLIENT_SIGNAL_QUERY, G_CALLBACK (xdmcp_query_cb), NULL); + g_signal_connect (xdmcp_client, XDMCP_CLIENT_SIGNAL_WILLING, G_CALLBACK (xdmcp_willing_cb), NULL); + g_signal_connect (xdmcp_client, XDMCP_CLIENT_SIGNAL_ACCEPT, G_CALLBACK (xdmcp_accept_cb), NULL); + g_signal_connect (xdmcp_client, XDMCP_CLIENT_SIGNAL_DECLINE, G_CALLBACK (xdmcp_decline_cb), NULL); + g_signal_connect (xdmcp_client, XDMCP_CLIENT_SIGNAL_FAILED, G_CALLBACK (xdmcp_failed_cb), NULL); } g_main_loop_run (loop); diff --git a/tests/src/Xvnc.c b/tests/src/Xvnc.c index 79f9193e..971ddcef 100644 --- a/tests/src/Xvnc.c +++ b/tests/src/Xvnc.c @@ -225,8 +225,8 @@ main (int argc, char **argv) status_connect (request_cb, id); xserver = x_server_new (display_number); - g_signal_connect (xserver, "client-connected", G_CALLBACK (client_connected_cb), NULL); - g_signal_connect (xserver, "client-disconnected", G_CALLBACK (client_disconnected_cb), NULL); + g_signal_connect (xserver, X_SERVER_SIGNAL_CLIENT_CONNECTED, G_CALLBACK (client_connected_cb), NULL); + g_signal_connect (xserver, X_SERVER_SIGNAL_CLIENT_DISCONNECTED, G_CALLBACK (client_disconnected_cb), NULL); status_notify ("%s START GEOMETRY=%s DEPTH=%d OPTION=%s", id, geometry, depth, has_option ? "TRUE" : "FALSE"); diff --git a/tests/src/test-gobject-greeter.c b/tests/src/test-gobject-greeter.c index 927586cd..0af3e25b 100644 --- a/tests/src/test-gobject-greeter.c +++ b/tests/src/test-gobject-greeter.c @@ -238,7 +238,7 @@ request_cb (const gchar *name, GHashTable *params) username = g_hash_table_lookup (params, "USERNAME"); user = lightdm_user_list_get_user_by_name (lightdm_user_list_get_instance (), username); if (user) - g_signal_connect (user, "changed", G_CALLBACK (user_changed_cb), NULL); + g_signal_connect (user, LIGHTDM_SIGNAL_USER_CHANGED, G_CALLBACK (user_changed_cb), NULL); status_notify ("%s WATCH-USER USERNAME=%s", greeter_id, username); } @@ -479,21 +479,21 @@ main (int argc, char **argv) } greeter = lightdm_greeter_new (); - g_signal_connect (greeter, "show-message", G_CALLBACK (show_message_cb), NULL); - g_signal_connect (greeter, "show-prompt", G_CALLBACK (show_prompt_cb), NULL); - g_signal_connect (greeter, "authentication-complete", G_CALLBACK (authentication_complete_cb), NULL); - g_signal_connect (greeter, "autologin-timer-expired", G_CALLBACK (autologin_timer_expired_cb), NULL); + g_signal_connect (greeter, LIGHTDM_GREETER_SIGNAL_SHOW_MESSAGE, G_CALLBACK (show_message_cb), NULL); + g_signal_connect (greeter, LIGHTDM_GREETER_SIGNAL_SHOW_PROMPT, G_CALLBACK (show_prompt_cb), NULL); + g_signal_connect (greeter, LIGHTDM_GREETER_SIGNAL_AUTHENTICATION_COMPLETE, G_CALLBACK (authentication_complete_cb), NULL); + g_signal_connect (greeter, LIGHTDM_GREETER_SIGNAL_AUTOLOGIN_TIMER_EXPIRED, G_CALLBACK (autologin_timer_expired_cb), NULL); if (g_key_file_get_boolean (config, "test-greeter-config", "resettable", NULL)) { lightdm_greeter_set_resettable (greeter, TRUE); - g_signal_connect (greeter, "idle", G_CALLBACK (idle_cb), NULL); - g_signal_connect (greeter, "reset", G_CALLBACK (reset_cb), NULL); + g_signal_connect (greeter, LIGHTDM_GREETER_SIGNAL_IDLE, G_CALLBACK (idle_cb), NULL); + g_signal_connect (greeter, LIGHTDM_GREETER_SIGNAL_RESET, G_CALLBACK (reset_cb), NULL); } if (g_key_file_get_boolean (config, "test-greeter-config", "log-user-changes", NULL)) { - g_signal_connect (lightdm_user_list_get_instance (), "user-added", G_CALLBACK (user_added_cb), NULL); - g_signal_connect (lightdm_user_list_get_instance (), "user-removed", G_CALLBACK (user_removed_cb), NULL); + g_signal_connect (lightdm_user_list_get_instance (), LIGHTDM_USER_LIST_SIGNAL_USER_ADDED, G_CALLBACK (user_added_cb), NULL); + g_signal_connect (lightdm_user_list_get_instance (), LIGHTDM_USER_LIST_SIGNAL_USER_REMOVED, G_CALLBACK (user_removed_cb), NULL); } status_notify ("%s CONNECT-TO-DAEMON", greeter_id); diff --git a/tests/src/test-runner.c b/tests/src/test-runner.c index 356458bc..017811d0 100644 --- a/tests/src/test-runner.c +++ b/tests/src/test-runner.c @@ -806,7 +806,6 @@ handle_command (const gchar *command) GString *status_text; gchar *username; AccountsUser *user; - GError *error = NULL; status_text = g_string_new ("RUNNER UPDATE-USER USERNAME="); @@ -815,67 +814,81 @@ handle_command (const gchar *command) user = get_accounts_user_by_name (username); if (user) { + GVariantBuilder invalidated_properties; + GError *error = NULL; + + g_variant_builder_init (&invalidated_properties, G_VARIANT_TYPE_ARRAY); + if (g_hash_table_lookup (params, "NAME")) { user->user_name = g_strdup (g_hash_table_lookup (params, "NAME")); g_string_append_printf (status_text, " NAME=%s", user->user_name); + g_variant_builder_add (&invalidated_properties, "s", "UserName"); } if (g_hash_table_lookup (params, "REAL-NAME")) { user->real_name = g_strdup (g_hash_table_lookup (params, "REAL-NAME")); g_string_append_printf (status_text, " REAL-NAME=%s", user->real_name); + g_variant_builder_add (&invalidated_properties, "s", "RealName"); } if (g_hash_table_lookup (params, "HOME-DIRECTORY")) { user->home_directory = g_strdup (g_hash_table_lookup (params, "HOME-DIRECTORY")); g_string_append_printf (status_text, " HOME-DIRECTORY=%s", user->home_directory); + g_variant_builder_add (&invalidated_properties, "s", "HomeDirectory"); } if (g_hash_table_lookup (params, "IMAGE")) { user->image = g_strdup (g_hash_table_lookup (params, "IMAGE")); g_string_append_printf (status_text, " IMAGE=%s", user->image); + g_variant_builder_add (&invalidated_properties, "s", "IconFile"); } if (g_hash_table_lookup (params, "BACKGROUND")) { user->background = g_strdup (g_hash_table_lookup (params, "BACKGROUND")); g_string_append_printf (status_text, " BACKGROUND=%s", user->background); + g_variant_builder_add (&invalidated_properties, "s", "BackgroundFile"); } if (g_hash_table_lookup (params, "LANGUAGE")) { user->language = g_strdup (g_hash_table_lookup (params, "LANGUAGE")); g_string_append_printf (status_text, " LANGUAGE=%s", user->language); + g_variant_builder_add (&invalidated_properties, "s", "Language"); } if (g_hash_table_lookup (params, "LAYOUTS")) { const gchar *value = g_hash_table_lookup (params, "LAYOUTS"); user->layouts = g_strsplit (value, ";", -1); g_string_append_printf (status_text, " LAYOUTS=%s", value); + g_variant_builder_add (&invalidated_properties, "s", "XKeyboardLayouts"); } if (g_hash_table_lookup (params, "HAS-MESSAGES")) { user->has_messages = g_strcmp0 (g_hash_table_lookup (params, "HAS-MESSAGES"), "TRUE") == 0; g_string_append_printf (status_text, " HAS-MESSAGES=%s", user->has_messages ? "TRUE" : "FALSE"); + g_variant_builder_add (&invalidated_properties, "s", "XHasMessages"); } if (g_hash_table_lookup (params, "SESSION")) { user->xsession = g_strdup (g_hash_table_lookup (params, "SESSION")); g_string_append_printf (status_text, " SESSION=%s", user->xsession); + g_variant_builder_add (&invalidated_properties, "s", "XSession"); } + + g_dbus_connection_emit_signal (accounts_connection, + NULL, + user->path, + "org.freedesktop.DBus.Properties", + "PropertiesChanged", + g_variant_new ("(sa{sv}as)", "org.freedesktop.Accounts.User", NULL, &invalidated_properties), + &error); + if (error) + g_warning ("Failed to emit PropertiesChanged: %s", error->message); + g_clear_error (&error); } else g_warning ("Unknown user %s", username); - g_dbus_connection_emit_signal (accounts_connection, - NULL, - user->path, - "org.freedesktop.Accounts.User", - "Changed", - g_variant_new ("()"), - &error); - if (error) - g_warning ("Failed to emit Changed: %s", error->message); - g_clear_error (&error); - check_status (status_text->str); g_string_free (status_text, TRUE); } @@ -1896,6 +1909,7 @@ handle_user_call (GDBusConnection *connection, if (strcmp (method_name, "SetXSession") == 0) { gchar *xsession; + GVariantBuilder invalidated_properties; g_variant_get (parameters, "(&s)", &xsession); @@ -1905,12 +1919,14 @@ handle_user_call (GDBusConnection *connection, g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); /* And notify others that it took */ + g_variant_builder_init (&invalidated_properties, G_VARIANT_TYPE_ARRAY); + g_variant_builder_add (&invalidated_properties, "s", "XSession"); g_dbus_connection_emit_signal (accounts_connection, NULL, user->path, - "org.freedesktop.Accounts.User", - "Changed", - g_variant_new ("()"), + "org.freedesktop.DBus.Properties", + "PropertiesChanged", + g_variant_new ("(sa{sv}as)", "org.freedesktop.Accounts.User", NULL, &invalidated_properties), NULL); } else @@ -2006,7 +2022,6 @@ accounts_name_acquired_cb (GDBusConnection *connection, " <property name='XSession' type='s' access='read'/>" " <property name='XKeyboardLayouts' type='as' access='read'/>" " <property name='XHasMessages' type='b' access='read'/>" - " <signal name='Changed' />" " </interface>" "</node>"; GError *error = NULL; diff --git a/tests/src/x-server.c b/tests/src/x-server.c index ab604fdf..d756c58c 100644 --- a/tests/src/x-server.c +++ b/tests/src/x-server.c @@ -90,7 +90,7 @@ x_client_class_init (XClientClass *klass) g_type_class_add_private (klass, sizeof (XClientPrivate)); x_client_signals[X_CLIENT_DISCONNECTED] = - g_signal_new ("disconnected", + g_signal_new (X_CLIENT_SIGNAL_DISCONNECTED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XClientClass, disconnected), @@ -132,7 +132,7 @@ socket_connect_cb (GIOChannel *channel, GIOCondition condition, gpointer data) client = g_object_new (x_client_get_type (), NULL); client->priv->server = server; - g_signal_connect (client, "disconnected", G_CALLBACK (x_client_disconnected_cb), server); + g_signal_connect (client, X_CLIENT_SIGNAL_DISCONNECTED, G_CALLBACK (x_client_disconnected_cb), server); client->priv->socket = data_socket; client->priv->channel = g_io_channel_unix_new (g_socket_get_fd (data_socket)); g_hash_table_insert (server->priv->clients, client->priv->channel, client); @@ -195,7 +195,7 @@ x_server_class_init (XServerClass *klass) object_class->finalize = x_server_finalize; g_type_class_add_private (klass, sizeof (XServerPrivate)); x_server_signals[X_SERVER_CLIENT_CONNECTED] = - g_signal_new ("client-connected", + g_signal_new (X_SERVER_SIGNAL_CLIENT_CONNECTED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XServerClass, client_connected), @@ -203,7 +203,7 @@ x_server_class_init (XServerClass *klass) NULL, G_TYPE_NONE, 1, x_client_get_type ()); x_server_signals[X_SERVER_CLIENT_DISCONNECTED] = - g_signal_new ("client-disconnected", + g_signal_new (X_SERVER_SIGNAL_CLIENT_DISCONNECTED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XServerClass, client_disconnected), diff --git a/tests/src/x-server.h b/tests/src/x-server.h index 5f5b4728..7ce8c3fe 100644 --- a/tests/src/x-server.h +++ b/tests/src/x-server.h @@ -6,6 +6,11 @@ G_BEGIN_DECLS +#define X_CLIENT_SIGNAL_DISCONNECTED "disconnected" + +#define X_SERVER_SIGNAL_CLIENT_CONNECTED "client-connected" +#define X_SERVER_SIGNAL_CLIENT_DISCONNECTED "client-disconnected" + typedef struct XClientPrivate XClientPrivate; typedef struct diff --git a/tests/src/xdmcp-client.c b/tests/src/xdmcp-client.c index 63c5dba1..985745f7 100644 --- a/tests/src/xdmcp-client.c +++ b/tests/src/xdmcp-client.c @@ -438,7 +438,7 @@ xdmcp_client_class_init (XDMCPClientClass *klass) object_class->finalize = xdmcp_client_finalize; g_type_class_add_private (klass, sizeof (XDMCPClientPrivate)); xdmcp_client_signals[XDMCP_CLIENT_QUERY] = - g_signal_new ("query", + g_signal_new (XDMCP_CLIENT_SIGNAL_QUERY, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XDMCPClientClass, query), @@ -446,7 +446,7 @@ xdmcp_client_class_init (XDMCPClientClass *klass) NULL, G_TYPE_NONE, 0); xdmcp_client_signals[XDMCP_CLIENT_WILLING] = - g_signal_new ("willing", + g_signal_new (XDMCP_CLIENT_SIGNAL_WILLING, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XDMCPClientClass, willing), @@ -454,7 +454,7 @@ xdmcp_client_class_init (XDMCPClientClass *klass) NULL, G_TYPE_NONE, 1, G_TYPE_POINTER); xdmcp_client_signals[XDMCP_CLIENT_ACCEPT] = - g_signal_new ("accept", + g_signal_new (XDMCP_CLIENT_SIGNAL_ACCEPT, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XDMCPClientClass, accept), @@ -462,7 +462,7 @@ xdmcp_client_class_init (XDMCPClientClass *klass) NULL, G_TYPE_NONE, 1, G_TYPE_POINTER); xdmcp_client_signals[XDMCP_CLIENT_DECLINE] = - g_signal_new ("decline", + g_signal_new (XDMCP_CLIENT_SIGNAL_DECLINE, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XDMCPClientClass, decline), @@ -470,7 +470,7 @@ xdmcp_client_class_init (XDMCPClientClass *klass) NULL, G_TYPE_NONE, 1, G_TYPE_POINTER); xdmcp_client_signals[XDMCP_CLIENT_FAILED] = - g_signal_new ("failed", + g_signal_new (XDMCP_CLIENT_SIGNAL_FAILED, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XDMCPClientClass, failed), diff --git a/tests/src/xdmcp-client.h b/tests/src/xdmcp-client.h index 0f08fcc6..7b865abd 100644 --- a/tests/src/xdmcp-client.h +++ b/tests/src/xdmcp-client.h @@ -7,6 +7,12 @@ #define XDMCP_VERSION 1 #define XDMCP_PORT 177 +#define XDMCP_CLIENT_SIGNAL_QUERY "query" +#define XDMCP_CLIENT_SIGNAL_WILLING "willing" +#define XDMCP_CLIENT_SIGNAL_ACCEPT "accept" +#define XDMCP_CLIENT_SIGNAL_DECLINE "decline" +#define XDMCP_CLIENT_SIGNAL_FAILED "failed" + typedef struct { gchar *authentication_name; diff --git a/tests/test-multi-seat-globbing-config-sections b/tests/test-multi-seat-globbing-config-sections new file mode 100755 index 00000000..674dbdfc --- /dev/null +++ b/tests/test-multi-seat-globbing-config-sections @@ -0,0 +1,2 @@ +#!/bin/sh +./src/dbus-env ./src/test-runner multi-seat-globbing-config-sections test-gobject-greeter |