~lightdm-team/lightdm/1.4

« back to all changes in this revision

Viewing changes to liblightdm-gobject/user.c

  • Committer: Robert Ancell
  • Date: 2011-05-05 06:11:16 UTC
  • Revision ID: robert.ancell@canonical.com-20110505061116-4nhrdw6k0huve3ek
Move user manager into liblightdm

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
    PROP_NAME,
18
18
    PROP_REAL_NAME,
19
19
    PROP_DISPLAY_NAME,
 
20
    PROP_HOME_DIRECTORY,
20
21
    PROP_IMAGE,
21
22
    PROP_LANGUAGE,
22
23
    PROP_LAYOUT,
30
31
 
31
32
    gchar *name;
32
33
    gchar *real_name;
 
34
    gchar *home_directory;
33
35
    gchar *image;
34
36
    gboolean logged_in;
35
37
 
48
50
 * @greeter: The greeter the user is connected to
49
51
 * @name: The username
50
52
 * @real_name: The real name of the user
 
53
 * @home_directory: The home directory of the user
51
54
 * @image: The image URI
52
55
 * @logged_in: TRUE if this user is currently logged in
53
56
 * 
54
57
 * Return value: the new #LdmUser
55
58
 **/
56
59
LdmUser *
57
 
ldm_user_new (LdmGreeter *greeter, const gchar *name, const gchar *real_name, const gchar *image, gboolean logged_in)
 
60
ldm_user_new (LdmGreeter *greeter, const gchar *name, const gchar *real_name, const gchar *home_directory, const gchar *image, gboolean logged_in)
58
61
{
59
 
    return g_object_new (LDM_TYPE_USER, "greeter", greeter, "name", name, "real-name", real_name, "image", image, "logged-in", logged_in, NULL);
 
62
    return g_object_new (LDM_TYPE_USER, "greeter", greeter, "name", name, "real-name", real_name, "home-directory", home_directory, "image", image, "logged-in", logged_in, NULL);
60
63
}
61
64
 
62
65
/**
74
77
    return user->priv->name;
75
78
}
76
79
 
 
80
void
 
81
ldm_user_set_name (LdmUser *user, const gchar *name)
 
82
{
 
83
    g_return_if_fail (LDM_IS_USER (user));
 
84
    g_free (user->priv->name);
 
85
    user->priv->name = g_strdup (name);
 
86
}
 
87
 
77
88
/**
78
89
 * ldm_user_get_real_name:
79
90
 * @user: A #LdmUser
110
121
{
111
122
    g_return_val_if_fail (LDM_IS_USER (user), NULL);
112
123
 
113
 
    if (user->priv->real_name[0] != '\0')
 
124
    if (user->priv->real_name)
114
125
        return user->priv->real_name;
115
126
    else
116
127
        return user->priv->name;
117
128
}
118
129
 
119
130
/**
 
131
 * ldm_user_get_home_directory:
 
132
 * @user: A #LdmUser
 
133
 * 
 
134
 * Get the home directory for a user.
 
135
 * 
 
136
 * Return value: The users home directory
 
137
 */
 
138
const gchar *
 
139
ldm_user_get_home_directory (LdmUser *user)
 
140
{
 
141
    g_return_val_if_fail (LDM_IS_USER (user), NULL);
 
142
    return user->priv->home_directory;
 
143
}
 
144
 
 
145
void
 
146
ldm_user_set_home_directory (LdmUser *user, const gchar *home_directory)
 
147
{
 
148
    g_return_if_fail (LDM_IS_USER (user));
 
149
    g_free (user->priv->home_directory);
 
150
    user->priv->home_directory = g_strdup (home_directory);
 
151
}
 
152
 
 
153
/**
120
154
 * ldm_user_get_image:
121
155
 * @user: A #LdmUser
122
156
 * 
240
274
        self->priv->greeter = g_object_ref (g_value_get_object (value));
241
275
        break;
242
276
    case PROP_NAME:
243
 
        self->priv->name = g_strdup (g_value_get_string (value));
 
277
        ldm_user_set_name (self, g_value_get_string (value));
244
278
        break;
245
279
    case PROP_REAL_NAME:
246
 
        self->priv->real_name = g_strdup (g_value_get_string (value));
 
280
        ldm_user_set_real_name (self, g_value_get_string (value));
 
281
        break;
 
282
    case PROP_HOME_DIRECTORY:
 
283
        ldm_user_set_home_directory (self, g_value_get_string (value));
247
284
        break;
248
285
    case PROP_IMAGE:
249
 
        self->priv->image = g_strdup (g_value_get_string (value));
 
286
        ldm_user_set_image (self, g_value_get_string (value));
250
287
        break;
251
288
    case PROP_LOGGED_IN:
252
 
        self->priv->logged_in = g_value_get_boolean (value);
 
289
        ldm_user_set_logged_in (self, g_value_get_boolean (value));
253
290
        break;
254
291
    default:
255
292
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
277
314
    case PROP_DISPLAY_NAME:
278
315
        g_value_set_string (value, ldm_user_get_display_name (self));
279
316
        break;
 
317
    case PROP_HOME_DIRECTORY:
 
318
        g_value_set_string (value, ldm_user_get_home_directory (self));
 
319
        break;
280
320
    case PROP_IMAGE:
281
321
        g_value_set_string (value, ldm_user_get_image (self));
282
322
        break;
337
377
                                                        NULL,
338
378
                                                        G_PARAM_READABLE));
339
379
    g_object_class_install_property(object_class,
 
380
                                    PROP_HOME_DIRECTORY,
 
381
                                    g_param_spec_string("home-directory",
 
382
                                                        "home-directory",
 
383
                                                        "Home directory",
 
384
                                                        NULL,
 
385
                                                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 
386
    g_object_class_install_property(object_class,
340
387
                                    PROP_IMAGE,
341
388
                                    g_param_spec_string("image",
342
389
                                                        "image",