~ubuntu-branches/ubuntu/oneiric/gdm/oneiric

« back to all changes in this revision

Viewing changes to common/gdm-settings.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt, Sebastien Bacher, Gunnar Hjalmarsson, Robert Ancell, Martin Pitt
  • Date: 2011-06-29 12:05:47 UTC
  • mfrom: (1.4.49 upstream)
  • Revision ID: james.westby@ubuntu.com-20110629120547-j5yvrc0jec43j9f4
Tags: 3.0.4-0ubuntu1
[ Sebastien Bacher ]
* New upstream version 3.0.0
* Start cleaning for the GNOME3 update
* debian/patches/00git_passwordless_login_crash.patch,
  debian/patches/17_use_timed_login_after_autologin.patch,
  debian/patches/19_no_greeter_for_autologin.patch,
  debian/patches/37_disable_resize_grip.patch,
  debian/patches/38_user_chooser_focus.patch,
  debian/patches/43_translate_cancel_button.patch:
  - those are fixed is in the new version
* debian/patches/08_use_polkit_for_settings.patch,
  debian/patches/09_gdmsetup.patch:
  - drop gdmsetup, the options should be integrated in gnome-control-center 
    (the autologin one is in the user account configuration for example)
* debian/patches/09_gdmserver_gconf_settings.patch:
  - the gconf hack to turn on and off login sounds, that should be
    rewritten use gsettings if wanted, lightdm should also make that easier
* debian/patches/10_xsplash.patch:
  - xsplash was a one cycle hack and has been deprecated since
* debian/patches/24_respect_system_minuid.patch:
  - deprecated with the accountsservice use
* debian/patches/25_update_gconf_directories.patch:
  - the new version use gsettings and that was useful for the
    gdmsetup configuration only
* debian/patches/34_disable_a11y_default.patch:
  - the change was not appropriate for a sru but is fine early 
    during the cycle
* debian/%gconf-tree.xml:
  - tweaks to the default layout, those will need to be revisited with the
    new ui and gsettings if needed (no needed if lightdm is the default?)
* Resynchronize some of the files on Debian to lower the difference

[ Gunnar Hjalmarsson ]
* debian/patches/36_language_environment_settings.patch:
  Set LC_CTYPE and LC_COLLATE to the same locale name as LC_MESSAGES
  (LP: #786986).
* Patches adapted to gdm-3.0.0:
  - 15_default_session.patch
  - 30_don_t_save_failsafe_session.patch
  - 32-hide-mouse-cursor.patch
  - 45_time_display_on_greeter.patch
  - 90_register-bin-true-as-URI-scheme-handler-for-several-schemes.patch
* debian/patches/45_time_display_on_greeter.patch:
  Display time on the greeter in a proper format also when
  /etc/default/locale assigns different locales to LANG respective
  LC_MESSAGES (LP: #777264).
* debian/gdm.upstart:
  Export LC_MESSAGES so the weekday gets displayed in the system
  language on the greeter.
* debian/patches/41_pt_time_format.patch:
  Patch deleted (superseded by 45_time_display_on_greeter.patch).

[ Robert Ancell ]
* debian/patches/42_no_ecryptfs_autologin.patch:
  - Only stop autologin if full home directory encryption is used
    (LP: #753707)

[ Martin Pitt ]
* New upstream version 3.0.4.
* debian/control.in: Require accountsservice 0.6.12.
* Drop 90_register-bin-true-as-URI-scheme-handler-for-several-schemes.patch:
  Fixed upstream in a different way.
* debian/gdm.install: install the dummy desktop handler and the
  mimeapps.list to /usr/share/gdm/applications.
* debian/rules: Drop installation of bonobo .server for FUSA, this is all
  obsolete.
* debian/rules: Drop installation of debian/%gconf-tree.xml, which was
  removed above.
* Drop 35_langlist_and_lsmess_dmrc_fields.patch: This now needs to be
  reimplemented in accountsservice.
* 42_no_ecryptfs_autologin.patch: Update to gdm 3.0.
* Synchronize patches with Debian:
  - Drop 04_fix_external_program_directories.patch, replace with
    07_libexec-paths.patch.
  - Add 93_xdg_data_dirs.patch.
  - Add 01_language.patch.
  - Drop 02_x_server_location.patch, replace with 16_xserver_path.patch. Set
    $X_PATH and friends in debian/rules.
  - Rename 05_initial_server_on_vt7.patch to 06_first_vt.patch. They have
    the same purpose, but ours is two magnitudes simpler.
  - Add 08_frequent-users_greeter.patch.
  - Rename 06_run_xsession.d.patch to ubuntu_run_xsession.d.patch; we don't
    use Debian's Xsession script, but upstream's.
  - Rename 11_crash_for_apport.patch to ubuntu_dont_catch_sigsegv.patch.
  - Rename 14_guest_session.patch to ubuntu_guest_session.patch.
  - Rename 20_upstart.patch to ubuntu_upstart_event.patch.
  - Rename 26_no_debug.patch to ubuntu_no_debug.patch.
  - Rename 39_grep_path.patch to 29_grep_path.patch just as Debian did.
* Merge 27_save_root_window.patch and 28_plymouth_transition.patch into
  ubuntu_plymouth.patch, to correspond better with its origin at
  http://pkgs.fedoraproject.org/gitweb/?p=gdm.git;a=blob;f=plymouth.patch;hb=HEAD
* Drop 16_gdmserver_user_manager.patch, this info is now provided by
  accountsservice.
* Drop 32-hide-mouse-cursor.patch. It never really looked that much better,
  and is unimportant now that gdm isn't even the default DM any more.
* Drop 40_one_lang_option_per_translation.patch: gdm does not show a
  language list any more, thus obsolete.
* 44_xsession-errors_symlink.patch: Fix case of .xsession-errors pointing to
  non-files such as /dev/null. Also rename to
  00git_xsession-errors_symlink.patch, as the patch was also committed
  upstream now. (LP: #771661)
* debian/watch: Look for .bz2 tarballs; upstream stopped publishing .gz
  ones.
* debian/control.in: Add missing gnome-pkg-tools dependency.
* debian/control.in: Bump Standards-Vesion to 3.9.2.
* debian/gdm.preinst: Add missing debhelper token.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <signal.h>
29
29
#include <sys/stat.h>
30
30
#include <sys/types.h>
31
 
#include <pwd.h>
32
31
 
33
32
#include <glib.h>
34
33
#include <glib/gi18n.h>
37
36
#define DBUS_API_SUBJECT_TO_CHANGE
38
37
#include <dbus/dbus-glib.h>
39
38
#include <dbus/dbus-glib-lowlevel.h>
40
 
#include <polkit/polkit.h>
41
39
 
42
40
#include "gdm-settings.h"
43
41
#include "gdm-settings-glue.h"
50
48
#define GDM_SETTINGS_DBUS_PATH GDM_DBUS_PATH "/Settings"
51
49
#define GDM_SETTINGS_DBUS_NAME "org.gnome.DisplayManager.Settings"
52
50
 
53
 
#define GCONF_SOUND_EVENT_KEY "/desktop/gnome/sound/event_sounds"
54
 
#define GCONF_FACE_BROWSER_DISABLE_KEY "/apps/gdm/simple-greeter/disable_user_list"
55
 
 
56
51
#define GDM_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SETTINGS, GdmSettingsPrivate))
57
52
 
58
53
struct GdmSettingsPrivate
87
82
        return ret;
88
83
}
89
84
 
90
 
static void
91
 
set_gdm_uid_child_setup ()
92
 
{
93
 
        struct passwd *pwent;
94
 
        uid_t  gdm_uid;
95
 
        uid_t  gdm_gid;
96
 
 
97
 
        pwent = getpwnam (GDM_USERNAME);
98
 
        // --shutdown take into account the resuid/resgid and HOME whereas
99
 
        // --get --set take the euid/egid
100
 
        setenv("HOME", pwent->pw_dir, 1);
101
 
        gdm_uid = pwent->pw_uid;
102
 
        gdm_gid = pwent->pw_gid;
103
 
        setresgid (gdm_gid, gdm_gid, gdm_gid);
104
 
        setresuid (gdm_uid, gdm_uid, gdm_uid);
105
 
 
106
 
}
107
 
 
108
 
static gboolean
109
 
gdm_settings_get_gconf_value (gchar *gconf_key, gchar **value) {
110
 
 
111
 
        GError  *error = NULL;
112
 
        char    *shutdown_command[] = { "gconftool-2", "--shutdown", NULL };
113
 
        char    *get_command[]  =  { "gconftool-2", "--direct", "-g", gconf_key, "--config-source", NULL, NULL };
114
 
        gboolean res;
115
 
        struct passwd *pwent;
116
 
        gboolean success = FALSE;
117
 
 
118
 
        pwent = getpwnam (GDM_USERNAME);
119
 
        if G_UNLIKELY (pwent == NULL)
120
 
                g_warning ("Can't access to 'gdm' user name in passwd");
121
 
        else {
122
 
                get_command[5] = g_strdup_printf("xml:readwrite:%s/.gconf", pwent->pw_dir);
123
 
                res = g_spawn_sync (NULL,
124
 
                                    shutdown_command,
125
 
                                    NULL,
126
 
                                    G_SPAWN_SEARCH_PATH,
127
 
                                    (GSpawnChildSetupFunc)set_gdm_uid_child_setup,
128
 
                                    NULL,
129
 
                                    NULL,
130
 
                                    NULL,
131
 
                                    NULL,
132
 
                                    &error);
133
 
                if (!res) {
134
 
                        if (error != NULL) {
135
 
                                g_warning ("Unable to shutdown gconf: %s", error->message);
136
 
                                g_error_free (error);
137
 
                        }
138
 
                        else
139
 
                                g_warning ("Unable to shutdown gconf: unknown error");
140
 
                }
141
 
                else {
142
 
                        res = g_spawn_sync (NULL,
143
 
                                            get_command,
144
 
                                            NULL,
145
 
                                            G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL,
146
 
                                            (GSpawnChildSetupFunc)set_gdm_uid_child_setup,
147
 
                                            NULL,
148
 
                                            value,
149
 
                                            NULL,
150
 
                                            NULL,
151
 
                                            &error);
152
 
                        if (!res) {
153
 
                                 if (error != NULL) {
154
 
                                         g_warning ("Unable to get event key to gconf: %s", error->message);
155
 
                                         g_error_free (error);
156
 
                                 }
157
 
                                else
158
 
                                         g_warning ("Unable to get event key to gconf: unknown error");
159
 
                         }
160
 
                        else {
161
 
                                 if (error != NULL) {
162
 
                                         g_warning ("Unable to get event key to gconf: %s", error->message);
163
 
                                         g_error_free (error);
164
 
                                 }
165
 
                                 else {
166
 
                                         g_debug ("gconftool call returning: %s", *value);
167
 
                                         success = TRUE;
168
 
                                 }
169
 
                        }
170
 
                }
171
 
        }
172
 
 
173
 
        return success;
174
 
}
175
 
 
176
 
 
177
 
 
178
 
static gboolean
179
 
gdm_settings_get_bool_gconf_value (gchar *gconf_key, gboolean *enabled) {
180
 
 
181
 
        gchar *value = NULL;
182
 
        gboolean result = FALSE;
183
 
 
184
 
        if (gdm_settings_get_gconf_value(gconf_key, &value)) {
185
 
                result = TRUE;
186
 
                if (strstr(value, "false") != NULL)
187
 
                        *enabled = FALSE;
188
 
                else if (strstr(value, "true") != NULL)
189
 
                        *enabled = TRUE;
190
 
                else
191
 
                    result = FALSE;
192
 
        }
193
 
 
194
 
        if (value)
195
 
                g_free (value);
196
 
        return result;
197
 
 
198
 
}
199
 
 
200
 
static gboolean
201
 
gdm_settings_set_gconf_value (gchar *gconf_key, gchar *type, gchar *value) {
202
 
 
203
 
        GError  *error = NULL;
204
 
        char    *shutdown_command[] = { "gconftool-2", "--shutdown", NULL };
205
 
        char    *set_command[]  =  { "gconftool-2", "--direct", "-s", gconf_key, "--config-source", NULL, "-t", type, value, NULL };
206
 
        gboolean res;
207
 
        struct passwd *pwent;
208
 
        gboolean success = FALSE;
209
 
 
210
 
        pwent = getpwnam (GDM_USERNAME);
211
 
        if G_UNLIKELY (pwent == NULL)
212
 
                g_warning ("Can't access to 'gdm' user name in passwd");
213
 
        else {
214
 
                set_command[5] = g_strdup_printf("xml:readwrite:%s/.gconf", pwent->pw_dir);
215
 
                res = g_spawn_sync (NULL,
216
 
                                    shutdown_command,
217
 
                                    NULL,
218
 
                                    G_SPAWN_SEARCH_PATH,
219
 
                                    (GSpawnChildSetupFunc)set_gdm_uid_child_setup,
220
 
                                    NULL,
221
 
                                    NULL,
222
 
                                    NULL,
223
 
                                    NULL,
224
 
                                    &error);
225
 
                if (!res) {
226
 
                        if (error != NULL) {
227
 
                                g_warning ("Unable to shutdown gconf: %s", error->message);
228
 
                                g_error_free (error);
229
 
                        }
230
 
                        else
231
 
                                g_warning ("Unable to shutdown gconf: unknown error");
232
 
                }
233
 
                else {
234
 
                        res = g_spawn_async (NULL,
235
 
                                             set_command,
236
 
                                             NULL,
237
 
                                             G_SPAWN_SEARCH_PATH
238
 
                                             | G_SPAWN_STDOUT_TO_DEV_NULL
239
 
                                             | G_SPAWN_STDERR_TO_DEV_NULL,
240
 
                                             (GSpawnChildSetupFunc)set_gdm_uid_child_setup,
241
 
                                             NULL,
242
 
                                             NULL,
243
 
                                             &error);
244
 
                        if (!res) {
245
 
                                if (error != NULL) {
246
 
                                        g_warning ("Unable to set event key to gconf: %s", error->message);
247
 
                                        g_error_free (error);
248
 
                                 }
249
 
                                 else
250
 
                                        g_warning ("Unable to set event key to gconf: unknown error");
251
 
                        }
252
 
                        else
253
 
                                 success = TRUE;
254
 
                }
255
 
        }
256
 
 
257
 
        return success;
258
 
}
259
 
 
260
 
static gboolean
261
 
gdm_settings_set_bool_gconf_value (gchar *gconf_key, gboolean enabled) {
262
 
 
263
 
        gchar *value = g_strdup_printf ("%i", enabled);
264
 
        gboolean result;
265
 
 
266
 
        result = gdm_settings_set_gconf_value (gconf_key, "bool", value);
267
 
 
268
 
        if (value)
269
 
                g_free (value);
270
 
        return result;
271
 
}
272
 
 
273
 
 
274
85
/*
275
86
dbus-send --system --print-reply --dest=org.gnome.DisplayManager /org/gnome/DisplayManager/Settings org.gnome.DisplayManager.Settings.GetValue string:"xdmcp/Enable"
276
87
*/
299
110
        return res;
300
111
}
301
112
 
302
 
 
303
 
/*
304
 
dbus-send --system --print-reply --dest=org.gnome.DisplayManager /org/gnome/DisplayManager/Settings org.gnome.DisplayManager.Settings.GetSoundEnabled
305
 
*/
306
 
 
307
 
gboolean
308
 
gdm_settings_get_sound_enabled (GdmSettings *settings,
309
 
                                gboolean    *enabled,
310
 
                                GError     **error)
311
 
{
312
 
        gboolean res;
313
 
        g_debug ("Trying to get sound");
314
 
 
315
 
        g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
316
 
 
317
 
        *enabled = FALSE;
318
 
        res = gdm_settings_get_bool_gconf_value (GCONF_SOUND_EVENT_KEY, enabled);
319
 
        if (res)
320
 
                  g_debug ("get sound returned: %i", *enabled);
321
 
 
322
 
        return TRUE;
323
 
}
324
 
 
325
 
 
326
 
/*
327
 
dbus-send --system --print-reply --dest=org.gnome.DisplayManager /org/gnome/DisplayManager/Settings org.gnome.DisplayManager.Settings.GetFaceBrowserEnabled
328
 
*/
329
 
 
330
 
gboolean
331
 
gdm_settings_get_face_browser_enabled (GdmSettings *settings,
332
 
                                       gboolean    *enabled,
333
 
                                       GError     **error)
334
 
{
335
 
        gboolean res;
336
 
 
337
 
        g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
338
 
 
339
 
        *enabled = TRUE;  
340
 
        res = gdm_settings_get_bool_gconf_value (GCONF_FACE_BROWSER_DISABLE_KEY, enabled);
341
 
        if (res)
342
 
            *enabled = !*enabled;
343
 
 
344
 
        return TRUE;
345
 
}
346
 
 
347
 
static void
348
 
unlock_auth_cb (PolkitAuthority *authority,
349
 
                GAsyncResult *result,
350
 
                DBusGMethodInvocation *context)
351
 
{
352
 
        PolkitAuthorizationResult *auth_result;
353
 
        GError  *error = NULL;
354
 
 
355
 
        auth_result = polkit_authority_check_authorization_finish (authority, result, &error);
356
 
 
357
 
        if (!auth_result)
358
 
                dbus_g_method_return_error (context, error);
359
 
        else {
360
 
                dbus_g_method_return (context,
361
 
                                      polkit_authorization_result_get_is_authorized (auth_result));
362
 
        }
363
 
    
364
 
        if (auth_result)
365
 
                g_object_unref (auth_result);
366
 
        if (error)
367
 
                g_error_free (error);
368
 
}
369
 
 
370
 
gboolean
371
 
gdm_settings_unlock (GdmSettings *settings,
372
 
                     DBusGMethodInvocation *context)
373
 
{
374
 
        polkit_authority_check_authorization (polkit_authority_get (),
375
 
                                              polkit_system_bus_name_new (dbus_g_method_get_sender (context)),
376
 
                                              "org.gnome.displaymanager.settings.write",
377
 
                                              NULL,
378
 
                                              POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
379
 
                                              NULL,
380
 
                                              (GAsyncReadyCallback) unlock_auth_cb,
381
 
                                              context);
382
 
}
383
 
 
384
 
typedef struct
385
 
{
386
 
        GdmSettings *settings;
387
 
        DBusGMethodInvocation *context;
388
 
        gchar *key, *value;
389
 
} SetValueData;
390
 
 
391
 
typedef struct
392
 
{
393
 
        DBusGMethodInvocation *context;
394
 
        gboolean enabled;
395
 
} SetGConfBooleanData;
396
 
 
397
 
static void
398
 
set_value_auth_cb (PolkitAuthority *authority,
399
 
                   GAsyncResult *result,
400
 
                   SetValueData *data)
401
 
{
402
 
        PolkitAuthorizationResult *auth_result;
403
 
        GError  *error = NULL;
404
 
 
405
 
        auth_result = polkit_authority_check_authorization_finish (authority, result, &error);
406
 
 
407
 
        if (!auth_result)
408
 
                dbus_g_method_return_error (data->context, error);
409
 
        else {
410
 
                if (polkit_authorization_result_get_is_authorized (auth_result)) {
411
 
                        gboolean result;
412
 
                    
413
 
                        result = gdm_settings_backend_set_value (data->settings->priv->backend,
414
 
                                                                 data->key,
415
 
                                                                 data->value,
416
 
                                                                 &error);
417
 
                        if (result)
418
 
                                dbus_g_method_return (data->context);
419
 
                        else
420
 
                                dbus_g_method_return_error (data->context, error);
421
 
                }
422
 
                else {
423
 
                        error = g_error_new (DBUS_GERROR_REMOTE_EXCEPTION, 0, "Not authorized");
424
 
                        dbus_g_method_return_error (data->context, error);
425
 
                }
426
 
        }
427
 
    
428
 
        if (auth_result)
429
 
                g_object_unref (auth_result);
430
 
        if (error)
431
 
                g_error_free (error);
432
 
        g_free (data->key);
433
 
        g_free (data->value);
434
 
        g_free (data);
435
 
}
436
 
 
437
113
/*
438
114
dbus-send --system --print-reply --dest=org.gnome.DisplayManager /org/gnome/DisplayManager/Settings org.gnome.DisplayManager.Settings.SetValue string:"xdmcp/Enable" string:"false"
439
115
*/
442
118
gdm_settings_set_value (GdmSettings *settings,
443
119
                        const char  *key,
444
120
                        const char  *value,
445
 
                        DBusGMethodInvocation *context)
 
121
                        GError     **error)
446
122
{
447
 
        SetValueData *data;
448
 
    
 
123
        GError  *local_error;
 
124
        gboolean res;
 
125
 
449
126
        g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
450
127
        g_return_val_if_fail (key != NULL, FALSE);
451
128
 
452
129
        g_debug ("Setting value %s", key);
453
 
    
454
 
        /* Authorize with PolicyKit */
455
 
        data = g_malloc (sizeof(SetValueData));
456
 
        data->settings = settings;
457
 
        data->context = context;
458
 
        data->key = g_strdup(key);
459
 
        data->value = g_strdup(value);    
460
 
        polkit_authority_check_authorization (polkit_authority_get (),
461
 
                                              polkit_system_bus_name_new (dbus_g_method_get_sender (context)),
462
 
                                              "org.gnome.displaymanager.settings.write",
463
 
                                              NULL,
464
 
                                              POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
465
 
                                              NULL,
466
 
                                              (GAsyncReadyCallback) set_value_auth_cb,
467
 
                                              data);
468
 
        return TRUE;
469
 
}
470
 
 
471
 
static void
472
 
set_sound_enabled_auth_cb (PolkitAuthority *authority,
473
 
                           GAsyncResult *result,
474
 
                           SetGConfBooleanData *data)
475
 
{
476
 
        PolkitAuthorizationResult *auth_result;
477
 
        GError  *error = NULL;
478
 
        
479
 
        auth_result = polkit_authority_check_authorization_finish (authority, result, &error);
480
 
 
481
 
        if (!auth_result)
482
 
                dbus_g_method_return_error (data->context, error);
483
 
        else {
484
 
                if (polkit_authorization_result_get_is_authorized (auth_result)) {
485
 
                        if (!gdm_settings_set_bool_gconf_value (GCONF_SOUND_EVENT_KEY, data->enabled))
486
 
                                g_warning ("set new value for sound failed");
487
 
                        dbus_g_method_return (data->context);
488
 
                }
489
 
                else {
490
 
                        error = g_error_new (DBUS_GERROR_REMOTE_EXCEPTION, 0, "Not authorized");
491
 
                        dbus_g_method_return_error (data->context, error);
492
 
                }
493
 
        }
494
 
    
495
 
        if (auth_result)
496
 
                g_object_unref (auth_result);
497
 
        if (error)
498
 
                g_error_free (error);
499
 
 
500
 
        g_free (data);
501
 
}
502
 
 
503
 
/*
504
 
dbus-send --system --print-reply --dest=org.gnome.DisplayManager /org/gnome/DisplayManager/Settings org.gnome.DisplayManager.Settings.SetSoundEnabled boolean:false
505
 
*/
506
 
 
507
 
gboolean
508
 
gdm_settings_set_sound_enabled (GdmSettings *settings,
509
 
                                gboolean     enabled,
510
 
                                DBusGMethodInvocation *context)
511
 
{
512
 
        SetGConfBooleanData *data;
513
 
    
514
 
        g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
515
 
 
516
 
 
517
 
        g_debug ("Setting sound enabled to %s", enabled ? "true" : "false");
518
 
    
519
 
        /* Authorize with PolicyKit */
520
 
        data = g_malloc (sizeof(SetGConfBooleanData));
521
 
        data->context = context;
522
 
        data->enabled = enabled;
523
 
        polkit_authority_check_authorization (polkit_authority_get (),
524
 
                                              polkit_system_bus_name_new (dbus_g_method_get_sender (context)),
525
 
                                              "org.gnome.displaymanager.settings.write",
526
 
                                              NULL,
527
 
                                              POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
528
 
                                              NULL,
529
 
                                              (GAsyncReadyCallback) set_sound_enabled_auth_cb,
530
 
                                              data);
531
 
        return TRUE;
532
 
}
533
 
 
534
 
static void
535
 
set_face_browser_enabled_auth_cb (PolkitAuthority *authority,
536
 
                                  GAsyncResult *result,
537
 
                                  SetGConfBooleanData *data)
538
 
{
539
 
        PolkitAuthorizationResult *auth_result;
540
 
        GError  *error = NULL;
541
 
        
542
 
        auth_result = polkit_authority_check_authorization_finish (authority, result, &error);
543
 
 
544
 
        if (!auth_result)
545
 
                dbus_g_method_return_error (data->context, error);
546
 
        else {
547
 
                if (polkit_authorization_result_get_is_authorized (auth_result)) {
548
 
                        if (!gdm_settings_set_bool_gconf_value (GCONF_FACE_BROWSER_DISABLE_KEY, !data->enabled))
549
 
                                g_warning ("set new value for face browser failed");
550
 
                        dbus_g_method_return (data->context);
551
 
                }
552
 
                else {
553
 
                        error = g_error_new (DBUS_GERROR_REMOTE_EXCEPTION, 0, "Not authorized");
554
 
                        dbus_g_method_return_error (data->context, error);
555
 
                }
556
 
        }
557
 
    
558
 
        if (auth_result)
559
 
                g_object_unref (auth_result);
560
 
        if (error)
561
 
                g_error_free (error);
562
 
 
563
 
        g_free (data);
564
 
}
565
 
 
566
 
/*
567
 
dbus-send --system --print-reply --dest=org.gnome.DisplayManager /org/gnome/DisplayManager/Settings org.gnome.DisplayManager.Settings.SetFaceBrowserEnabled boolean:true
568
 
*/
569
 
 
570
 
gboolean
571
 
gdm_settings_set_face_browser_enabled (GdmSettings *settings,
572
 
                                       gboolean     enabled,
573
 
                                       DBusGMethodInvocation *context)
574
 
{
575
 
        SetGConfBooleanData *data;
576
 
    
577
 
        g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
578
 
    
579
 
        /* Authorize with PolicyKit */
580
 
        data = g_malloc (sizeof(SetGConfBooleanData));
581
 
        data->context = context;
582
 
        data->enabled = enabled;
583
 
        polkit_authority_check_authorization (polkit_authority_get (),
584
 
                                              polkit_system_bus_name_new (dbus_g_method_get_sender (context)),
585
 
                                              "org.gnome.displaymanager.settings.write",
586
 
                                              NULL,
587
 
                                              POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
588
 
                                              NULL,
589
 
                                              (GAsyncReadyCallback) set_face_browser_enabled_auth_cb,
590
 
                                              data);
591
 
        return TRUE;
 
130
 
 
131
        local_error = NULL;
 
132
        res = gdm_settings_backend_set_value (settings->priv->backend,
 
133
                                              key,
 
134
                                              value,
 
135
                                              &local_error);
 
136
        if (! res) {
 
137
                g_propagate_error (error, local_error);
 
138
        }
 
139
 
 
140
        return res;
592
141
}
593
142
 
594
143
static gboolean