]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - liblightdm-gobject/user.c
Refactor LightDMUser and User classes to use the same code internally.
[sojka/lightdm.git] / liblightdm-gobject / user.c
1 /* -*- Mode: C; indent-tabs-mode:nil; tab-width:4 -*-
2  *
3  * Copyright (C) 2010 Robert Ancell.
4  * Copyright (C) 2014 Canonical, Ltd.
5  * Authors: Robert Ancell <robert.ancell@canonical.com>
6  *          Michael Terry <michael.terry@canonical.com>
7  * 
8  * This library is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Lesser General Public License as published by the Free
10  * Software Foundation; either version 2 or version 3 of the License.
11  * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
12  */
13
14 #include <config.h>
15
16 #include "user-list.h"
17 #include "lightdm/user.h"
18
19 enum
20 {
21     LIST_PROP_0,
22     LIST_PROP_NUM_USERS,
23     LIST_PROP_USERS,
24 };
25
26 enum
27 {
28     USER_PROP_0,
29     USER_PROP_COMMON_USER,
30     USER_PROP_NAME,
31     USER_PROP_REAL_NAME,
32     USER_PROP_DISPLAY_NAME,
33     USER_PROP_HOME_DIRECTORY,
34     USER_PROP_IMAGE,
35     USER_PROP_BACKGROUND,
36     USER_PROP_LANGUAGE,
37     USER_PROP_LAYOUT,
38     USER_PROP_LAYOUTS,
39     USER_PROP_SESSION,
40     USER_PROP_LOGGED_IN,
41     USER_PROP_HAS_MESSAGES
42 };
43
44 enum
45 {
46     USER_ADDED,
47     USER_CHANGED,
48     USER_REMOVED,
49     LAST_LIST_SIGNAL
50 };
51 static guint list_signals[LAST_LIST_SIGNAL] = { 0 };
52
53 enum
54 {
55     CHANGED,
56     LAST_USER_SIGNAL
57 };
58 static guint user_signals[LAST_USER_SIGNAL] = { 0 };
59
60 typedef struct
61 {
62     gboolean initialized;
63
64     /* Wrapper list, kept locally to preserve transfer-none promises */
65     GList *lightdm_list;
66 } LightDMUserListPrivate;
67
68 typedef struct
69 {
70     CommonUser *common_user;
71 } LightDMUserPrivate;
72
73 G_DEFINE_TYPE (LightDMUserList, lightdm_user_list, G_TYPE_OBJECT);
74 G_DEFINE_TYPE (LightDMUser, lightdm_user, G_TYPE_OBJECT);
75
76 #define GET_LIST_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), LIGHTDM_TYPE_USER_LIST, LightDMUserListPrivate)
77 #define GET_USER_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), LIGHTDM_TYPE_USER, LightDMUserPrivate)
78
79 static LightDMUserList *singleton = NULL;
80
81 /**
82  * lightdm_user_list_get_instance:
83  *
84  * Get the user list.
85  *
86  * Return value: (transfer none): the #LightDMUserList
87  **/
88 LightDMUserList *
89 lightdm_user_list_get_instance (void)
90 {
91     if (!singleton)
92         singleton = g_object_new (LIGHTDM_TYPE_USER_LIST, NULL);
93     return singleton;
94 }
95
96 static void
97 user_changed_cb (CommonUser *common_user, LightDMUser *lightdm_user)
98 {
99     g_signal_emit (lightdm_user, user_signals[CHANGED], 0);
100 }
101
102 static LightDMUser *
103 wrap_common_user (CommonUser *user)
104 {
105     LightDMUser *lightdm_user = g_object_new (LIGHTDM_TYPE_USER, "common-user", user, NULL);
106     g_signal_connect (user, "changed", G_CALLBACK (user_changed_cb), lightdm_user);
107     return lightdm_user;
108 }
109
110 static void
111 user_list_added_cb (CommonUserList *common_list, CommonUser *common_user, LightDMUserList *user_list)
112 {
113     LightDMUserListPrivate *priv = GET_LIST_PRIVATE (user_list);
114     GList *common_users = common_user_list_get_users (common_list);
115     LightDMUser *lightdm_user = wrap_common_user (common_user);
116     priv->lightdm_list = g_list_insert (priv->lightdm_list, lightdm_user, g_list_index (common_users, common_user));
117     g_signal_emit (user_list, list_signals[USER_ADDED], 0, lightdm_user);
118 }
119
120 static void
121 user_list_changed_cb (CommonUserList *common_list, CommonUser *common_user, LightDMUserList *user_list)
122 {
123     LightDMUserListPrivate *priv = GET_LIST_PRIVATE (user_list);
124     GList *common_users = common_user_list_get_users (common_list);
125     LightDMUser *lightdm_user = g_list_nth_data (priv->lightdm_list, g_list_index (common_users, common_user));
126     g_signal_emit (user_list, list_signals[USER_CHANGED], 0, lightdm_user);
127 }
128
129 static void
130 user_list_removed_cb (CommonUserList *common_list, CommonUser *common_user, LightDMUserList *user_list)
131 {
132     LightDMUserListPrivate *priv = GET_LIST_PRIVATE (user_list);
133     GList *link;
134
135     for (link = priv->lightdm_list; link; link = link->next)
136     {
137         LightDMUser *lightdm_user = link->data;
138         LightDMUserPrivate *user_priv = GET_USER_PRIVATE (lightdm_user);
139         if (user_priv->common_user == common_user)
140         {
141             priv->lightdm_list = g_list_delete_link (priv->lightdm_list, link);
142             g_signal_emit (user_list, list_signals[USER_REMOVED], 0, lightdm_user);
143             g_object_unref (lightdm_user);
144             break;
145         }
146     }
147 }
148
149 static void
150 initialize_user_list_if_needed (LightDMUserList *user_list)
151 {
152     LightDMUserListPrivate *priv = GET_LIST_PRIVATE (user_list);
153     GList *common_users;
154     GList *link;
155
156     if (priv->initialized)
157         return;
158
159     common_users = common_user_list_get_users (common_user_list_get_instance ());
160     for (link = common_users; link; link = link->next)
161     {
162         CommonUser *user = link->data;
163         LightDMUser *lightdm_user = wrap_common_user (user);
164         priv->lightdm_list = g_list_prepend (priv->lightdm_list, lightdm_user);
165     }
166     priv->lightdm_list = g_list_reverse (priv->lightdm_list);
167
168     CommonUserList *common_list = common_user_list_get_instance ();
169     g_signal_connect (common_list, "user-added", G_CALLBACK (user_list_added_cb), user_list);
170     g_signal_connect (common_list, "user-changed", G_CALLBACK (user_list_changed_cb), user_list);
171     g_signal_connect (common_list, "user-removed", G_CALLBACK (user_list_removed_cb), user_list);
172
173     priv->initialized = TRUE;
174 }
175
176 /**
177  * lightdm_user_list_get_length:
178  * @user_list: a #LightDMUserList
179  *
180  * Return value: The number of users able to log in
181  **/
182 gint
183 lightdm_user_list_get_length (LightDMUserList *user_list)
184 {
185     g_return_val_if_fail (LIGHTDM_IS_USER_LIST (user_list), 0);
186     initialize_user_list_if_needed (user_list);
187     return g_list_length (GET_LIST_PRIVATE (user_list)->lightdm_list);
188 }
189
190 /**
191  * lightdm_user_list_get_users:
192  * @user_list: A #LightDMUserList
193  *
194  * Get a list of users to present to the user.  This list may be a subset of the
195  * available users and may be empty depending on the server configuration.
196  *
197  * Return value: (element-type LightDMUser) (transfer none): A list of #LightDMUser that should be presented to the user.
198  **/
199 GList *
200 lightdm_user_list_get_users (LightDMUserList *user_list)
201 {
202     g_return_val_if_fail (LIGHTDM_IS_USER_LIST (user_list), NULL);
203     initialize_user_list_if_needed (user_list);
204     return GET_LIST_PRIVATE (user_list)->lightdm_list;
205 }
206
207 /**
208  * lightdm_user_list_get_user_by_name:
209  * @user_list: A #LightDMUserList
210  * @username: Name of user to get.
211  *
212  * Get infomation about a given user or #NULL if this user doesn't exist.
213  *
214  * Return value: (transfer none): A #LightDMUser entry for the given user.
215  **/
216 LightDMUser *
217 lightdm_user_list_get_user_by_name (LightDMUserList *user_list, const gchar *username)
218 {
219     GList *link;
220
221     g_return_val_if_fail (LIGHTDM_IS_USER_LIST (user_list), NULL);
222     g_return_val_if_fail (username != NULL, NULL);
223
224     initialize_user_list_if_needed (user_list);
225
226     for (link = GET_LIST_PRIVATE (user_list)->lightdm_list; link; link = link->next)
227     {
228         LightDMUser *user = link->data;
229         if (g_strcmp0 (lightdm_user_get_name (user), username) == 0)
230             return user;
231     }
232
233     return NULL;
234 }
235
236 static void
237 lightdm_user_list_init (LightDMUserList *user_list)
238 {
239 }
240
241 static void
242 lightdm_user_list_set_property (GObject    *object,
243                                 guint       prop_id,
244                                 const GValue *value,
245                                 GParamSpec *pspec)
246 {
247     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
248 }
249
250 static void
251 lightdm_user_list_get_property (GObject    *object,
252                                 guint       prop_id,
253                                 GValue     *value,
254                                 GParamSpec *pspec)
255 {
256     LightDMUserList *self;
257
258     self = LIGHTDM_USER_LIST (object);
259
260     switch (prop_id)
261     {
262     case LIST_PROP_NUM_USERS:
263         g_value_set_int (value, lightdm_user_list_get_length (self));
264         break;
265     default:
266         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
267         break;
268     }
269 }
270
271 static void
272 lightdm_user_list_finalize (GObject *object)
273 {
274     LightDMUserList *self = LIGHTDM_USER_LIST (object);
275     LightDMUserListPrivate *priv = GET_LIST_PRIVATE (self);
276
277     g_list_free_full (priv->lightdm_list, g_object_unref);
278
279     G_OBJECT_CLASS (lightdm_user_list_parent_class)->finalize (object);
280 }
281
282 static void
283 lightdm_user_list_class_init (LightDMUserListClass *klass)
284 {
285     GObjectClass *object_class = G_OBJECT_CLASS (klass);
286
287     g_type_class_add_private (klass, sizeof (LightDMUserListPrivate));
288
289     object_class->set_property = lightdm_user_list_set_property;
290     object_class->get_property = lightdm_user_list_get_property;
291     object_class->finalize = lightdm_user_list_finalize;
292
293     g_object_class_install_property (object_class,
294                                      LIST_PROP_NUM_USERS,
295                                      g_param_spec_int ("num-users",
296                                                        "num-users",
297                                                        "Number of login users",
298                                                        0, G_MAXINT, 0,
299                                                        G_PARAM_READABLE));
300     /**
301      * LightDMUserList::user-added:
302      * @user_list: A #LightDMUserList
303      * @user: The #LightDM user that has been added.
304      *
305      * The ::user-added signal gets emitted when a user account is created.
306      **/
307     list_signals[USER_ADDED] =
308         g_signal_new ("user-added",
309                       G_TYPE_FROM_CLASS (klass),
310                       G_SIGNAL_RUN_LAST,
311                       G_STRUCT_OFFSET (LightDMUserListClass, user_added),
312                       NULL, NULL,
313                       NULL,
314                       G_TYPE_NONE, 1, LIGHTDM_TYPE_USER);
315
316     /**
317      * LightDMUserList::user-changed:
318      * @user_list: A #LightDMUserList
319      * @user: The #LightDM user that has been changed.
320      *
321      * The ::user-changed signal gets emitted when a user account is modified.
322      **/
323     list_signals[USER_CHANGED] =
324         g_signal_new ("user-changed",
325                       G_TYPE_FROM_CLASS (klass),
326                       G_SIGNAL_RUN_LAST,
327                       G_STRUCT_OFFSET (LightDMUserListClass, user_changed),
328                       NULL, NULL,
329                       NULL,
330                       G_TYPE_NONE, 1, LIGHTDM_TYPE_USER);
331
332     /**
333      * LightDMUserList::user-removed:
334      * @user_list: A #LightDMUserList
335      * @user: The #LightDM user that has been removed.
336      *
337      * The ::user-removed signal gets emitted when a user account is removed.
338      **/
339     list_signals[USER_REMOVED] =
340         g_signal_new ("user-removed",
341                       G_TYPE_FROM_CLASS (klass),
342                       G_SIGNAL_RUN_LAST,
343                       G_STRUCT_OFFSET (LightDMUserListClass, user_removed),
344                       NULL, NULL,
345                       NULL,
346                       G_TYPE_NONE, 1, LIGHTDM_TYPE_USER);
347 }
348
349 /**
350  * lightdm_user_get_name:
351  * @user: A #LightDMUser
352  * 
353  * Get the name of a user.
354  * 
355  * Return value: The name of the given user
356  **/
357 const gchar *
358 lightdm_user_get_name (LightDMUser *user)
359 {
360     g_return_val_if_fail (LIGHTDM_IS_USER (user), NULL);
361     return common_user_get_name (GET_USER_PRIVATE (user)->common_user);
362 }
363
364 /**
365  * lightdm_user_get_real_name:
366  * @user: A #LightDMUser
367  * 
368  * Get the real name of a user.
369  *
370  * Return value: The real name of the given user
371  **/
372 const gchar *
373 lightdm_user_get_real_name (LightDMUser *user)
374 {
375     g_return_val_if_fail (LIGHTDM_IS_USER (user), NULL);
376     return common_user_get_real_name (GET_USER_PRIVATE (user)->common_user);
377 }
378
379 /**
380  * lightdm_user_get_display_name:
381  * @user: A #LightDMUser
382  * 
383  * Get the display name of a user.
384  * 
385  * Return value: The display name of the given user
386  **/
387 const gchar *
388 lightdm_user_get_display_name (LightDMUser *user)
389 {
390     g_return_val_if_fail (LIGHTDM_IS_USER (user), NULL);
391     return common_user_get_display_name (GET_USER_PRIVATE (user)->common_user);
392 }
393
394 /**
395  * lightdm_user_get_home_directory:
396  * @user: A #LightDMUser
397  * 
398  * Get the home directory for a user.
399  * 
400  * Return value: The users home directory
401  */
402 const gchar *
403 lightdm_user_get_home_directory (LightDMUser *user)
404 {
405     g_return_val_if_fail (LIGHTDM_IS_USER (user), NULL);
406     return common_user_get_home_directory (GET_USER_PRIVATE (user)->common_user);
407 }
408
409 /**
410  * lightdm_user_get_image:
411  * @user: A #LightDMUser
412  * 
413  * Get the image URI for a user.
414  * 
415  * Return value: The image URI for the given user or #NULL if no URI
416  **/
417 const gchar *
418 lightdm_user_get_image (LightDMUser *user)
419 {
420     g_return_val_if_fail (LIGHTDM_IS_USER (user), NULL);
421     return common_user_get_image (GET_USER_PRIVATE (user)->common_user);
422 }
423
424 /**
425  * lightdm_user_get_background:
426  * @user: A #LightDMUser
427  * 
428  * Get the background file path for a user.
429  * 
430  * Return value: The background file path for the given user or #NULL if no path
431  **/
432 const gchar *
433 lightdm_user_get_background (LightDMUser *user)
434 {
435     g_return_val_if_fail (LIGHTDM_IS_USER (user), NULL);
436     return common_user_get_background (GET_USER_PRIVATE (user)->common_user);
437 }
438
439 /**
440  * lightdm_user_get_language:
441  * @user: A #LightDMUser
442  * 
443  * Get the language for a user.
444  * 
445  * Return value: The language in the form of a local specification (e.g. "de_DE.UTF-8") for the given user or #NULL if using the system default locale.
446  **/
447 const gchar *
448 lightdm_user_get_language (LightDMUser *user)
449 {
450     g_return_val_if_fail (LIGHTDM_IS_USER (user), NULL);
451     return common_user_get_language (GET_USER_PRIVATE (user)->common_user);
452 }
453
454 /**
455  * lightdm_user_get_layout:
456  * @user: A #LightDMUser
457  * 
458  * Get the keyboard layout for a user.
459  * 
460  * Return value: The keyboard layout for the given user or #NULL if using system defaults.  Copy the value if you want to use it long term.
461  **/
462 const gchar *
463 lightdm_user_get_layout (LightDMUser *user)
464 {
465     g_return_val_if_fail (LIGHTDM_IS_USER (user), NULL);
466     return common_user_get_layout (GET_USER_PRIVATE (user)->common_user);
467 }
468
469 /**
470  * lightdm_user_get_layouts:
471  * @user: A #LightDMUser
472  * 
473  * Get the configured keyboard layouts for a user.
474  * 
475  * Return value: (transfer none): A NULL-terminated array of keyboard layouts for the given user.  Copy the values if you want to use them long term.
476  **/
477 const gchar * const *
478 lightdm_user_get_layouts (LightDMUser *user)
479 {
480     g_return_val_if_fail (LIGHTDM_IS_USER (user), NULL);
481     return common_user_get_layouts (GET_USER_PRIVATE (user)->common_user);
482 }
483
484 /**
485  * lightdm_user_get_session:
486  * @user: A #LightDMUser
487  * 
488  * Get the session for a user.
489  * 
490  * Return value: The session for the given user or #NULL if using system defaults.
491  **/
492 const gchar *
493 lightdm_user_get_session (LightDMUser *user)
494 {
495     g_return_val_if_fail (LIGHTDM_IS_USER (user), NULL);
496     return common_user_get_session (GET_USER_PRIVATE (user)->common_user);
497 }
498
499 /**
500  * lightdm_user_get_logged_in:
501  * @user: A #LightDMUser
502  * 
503  * Check if a user is logged in.
504  * 
505  * Return value: #TRUE if the user is currently logged in.
506  **/
507 gboolean
508 lightdm_user_get_logged_in (LightDMUser *user)
509 {
510     g_return_val_if_fail (LIGHTDM_IS_USER (user), FALSE);
511     return common_user_get_logged_in (GET_USER_PRIVATE (user)->common_user);
512 }
513
514 /**
515  * lightdm_user_get_has_messages:
516  * @user: A #LightDMUser
517  * 
518  * Check if a user has waiting messages.
519  * 
520  * Return value: #TRUE if the user has waiting messages.
521  **/
522 gboolean
523 lightdm_user_get_has_messages (LightDMUser *user)
524 {
525     g_return_val_if_fail (LIGHTDM_IS_USER (user), FALSE);
526     return common_user_get_has_messages (GET_USER_PRIVATE (user)->common_user);
527 }
528
529 static void
530 lightdm_user_init (LightDMUser *user)
531 {
532 }
533
534 static void
535 lightdm_user_set_property (GObject    *object,
536                            guint       prop_id,
537                            const GValue *value,
538                            GParamSpec *pspec)
539 {
540     LightDMUser *self = LIGHTDM_USER (object);
541     LightDMUserPrivate *priv = GET_USER_PRIVATE (self);
542
543     switch (prop_id)
544     {
545     case USER_PROP_COMMON_USER:
546         priv->common_user = g_value_dup_object (value);
547         break;
548     default:
549         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
550         break;
551     }
552 }
553
554 static void
555 lightdm_user_get_property (GObject    *object,
556                            guint       prop_id,
557                            GValue     *value,
558                            GParamSpec *pspec)
559 {
560     LightDMUser *self;
561
562     self = LIGHTDM_USER (object);
563
564     switch (prop_id)
565     {
566     case USER_PROP_NAME:
567         g_value_set_string (value, lightdm_user_get_name (self));
568         break;
569     case USER_PROP_REAL_NAME:
570         g_value_set_string (value, lightdm_user_get_real_name (self));
571         break;
572     case USER_PROP_DISPLAY_NAME:
573         g_value_set_string (value, lightdm_user_get_display_name (self));
574         break;
575     case USER_PROP_HOME_DIRECTORY:
576         g_value_set_string (value, lightdm_user_get_home_directory (self));
577         break;
578     case USER_PROP_IMAGE:
579         g_value_set_string (value, lightdm_user_get_image (self));
580         break;
581     case USER_PROP_BACKGROUND:
582         g_value_set_string (value, lightdm_user_get_background (self));
583         break;
584     case USER_PROP_LANGUAGE:
585         g_value_set_string (value, lightdm_user_get_language (self));
586         break;
587     case USER_PROP_LAYOUT:
588         g_value_set_string (value, lightdm_user_get_layout (self));
589         break;
590     case USER_PROP_LAYOUTS:
591         g_value_set_boxed (value, g_strdupv ((gchar **) lightdm_user_get_layouts (self)));
592         break;
593     case USER_PROP_SESSION:
594         g_value_set_string (value, lightdm_user_get_session (self));
595         break;
596     case USER_PROP_LOGGED_IN:
597         g_value_set_boolean (value, lightdm_user_get_logged_in (self));
598         break;
599     case USER_PROP_HAS_MESSAGES:
600         g_value_set_boolean (value, lightdm_user_get_has_messages (self));
601         break;
602     default:
603         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
604         break;
605     }
606 }
607
608 static void
609 lightdm_user_finalize (GObject *object)
610 {
611     LightDMUser *self = LIGHTDM_USER (object);
612     LightDMUserPrivate *priv = GET_USER_PRIVATE (self);
613
614     g_object_unref (priv->common_user);
615
616     G_OBJECT_CLASS (lightdm_user_parent_class)->finalize (object);
617 }
618
619 static void
620 lightdm_user_class_init (LightDMUserClass *klass)
621 {
622     GObjectClass *object_class = G_OBJECT_CLASS (klass);
623   
624     g_type_class_add_private (klass, sizeof (LightDMUserPrivate));
625
626     object_class->set_property = lightdm_user_set_property;
627     object_class->get_property = lightdm_user_get_property;
628     object_class->finalize = lightdm_user_finalize;
629
630     g_object_class_install_property (object_class,
631                                      USER_PROP_COMMON_USER,
632                                      g_param_spec_object ("common-user",
633                                                           "common-user",
634                                                           "Internal user object",
635                                                           COMMON_TYPE_USER,
636                                                           G_PARAM_PRIVATE|G_PARAM_CONSTRUCT_ONLY|G_PARAM_WRITABLE));
637     g_object_class_install_property (object_class,
638                                      USER_PROP_NAME,
639                                      g_param_spec_string ("name",
640                                                           "name",
641                                                           "Username",
642                                                           NULL,
643                                                           G_PARAM_READWRITE));
644     g_object_class_install_property (object_class,
645                                      USER_PROP_REAL_NAME,
646                                      g_param_spec_string ("real-name",
647                                                           "real-name",
648                                                           "Users real name",
649                                                           NULL,
650                                                           G_PARAM_READWRITE));
651     g_object_class_install_property (object_class,
652                                      USER_PROP_DISPLAY_NAME,
653                                      g_param_spec_string ("display-name",
654                                                           "display-name",
655                                                           "Users display name",
656                                                           NULL,
657                                                           G_PARAM_READABLE));
658     g_object_class_install_property (object_class,
659                                      USER_PROP_HOME_DIRECTORY,
660                                      g_param_spec_string ("home-directory",
661                                                           "home-directory",
662                                                           "Home directory",
663                                                           NULL,
664                                                           G_PARAM_READWRITE));
665     g_object_class_install_property (object_class,
666                                      USER_PROP_IMAGE,
667                                      g_param_spec_string ("image",
668                                                           "image",
669                                                           "Avatar image",
670                                                           NULL,
671                                                           G_PARAM_READWRITE));
672     g_object_class_install_property (object_class,
673                                      USER_PROP_BACKGROUND,
674                                      g_param_spec_string ("background",
675                                                           "background",
676                                                           "User background",
677                                                           NULL,
678                                                           G_PARAM_READWRITE));
679     g_object_class_install_property (object_class,
680                                      USER_PROP_LANGUAGE,
681                                      g_param_spec_string ("language",
682                                                          "language",
683                                                          "Language used by this user",
684                                                          NULL,
685                                                          G_PARAM_READABLE));
686     g_object_class_install_property (object_class,
687                                      USER_PROP_LAYOUT,
688                                      g_param_spec_string ("layout",
689                                                           "layout",
690                                                           "Keyboard layout used by this user",
691                                                           NULL,
692                                                           G_PARAM_READABLE));
693     g_object_class_install_property (object_class,
694                                      USER_PROP_LAYOUTS,
695                                      g_param_spec_boxed ("layouts",
696                                                          "layouts",
697                                                          "Keyboard layouts used by this user",
698                                                          G_TYPE_STRV,
699                                                          G_PARAM_READABLE));
700     g_object_class_install_property (object_class,
701                                      USER_PROP_SESSION,
702                                      g_param_spec_string ("session",
703                                                           "session",
704                                                           "Session used by this user",
705                                                           NULL,
706                                                           G_PARAM_READABLE));
707     g_object_class_install_property (object_class,
708                                      USER_PROP_LOGGED_IN,
709                                      g_param_spec_boolean ("logged-in",
710                                                            "logged-in",
711                                                            "TRUE if the user is currently in a session",
712                                                            FALSE,
713                                                            G_PARAM_READWRITE));
714     g_object_class_install_property (object_class,
715                                      USER_PROP_LOGGED_IN,
716                                      g_param_spec_boolean ("has-messages",
717                                                            "has-messages",
718                                                            "TRUE if the user is has waiting messages",
719                                                            FALSE,
720                                                            G_PARAM_READWRITE));
721
722     /**
723      * LightDMUser::changed:
724      * @user: A #LightDMUser
725      *
726      * The ::changed signal gets emitted this user account is modified.
727      **/
728     user_signals[CHANGED] =
729         g_signal_new ("changed",
730                       G_TYPE_FROM_CLASS (klass),
731                       G_SIGNAL_RUN_LAST,
732                       G_STRUCT_OFFSET (LightDMUserClass, changed),
733                       NULL, NULL,
734                       NULL,
735                       G_TYPE_NONE, 0);
736 }