2
2
## Origin/Author: add some origin or author
4
4
diff -Nur -x '*.orig' -x '*~' gdm-2.29.92/common/gdm-settings.c gdm-2.29.92.new/common/gdm-settings.c
5
--- gdm-2.29.92/common/gdm-settings.c 2010-03-11 16:52:27.002994993 +1100
6
+++ gdm-2.29.92.new/common/gdm-settings.c 2010-03-11 16:54:23.555535542 +1100
5
--- gdm-2.29.92/common/gdm-settings.c 2010-03-15 18:34:31.952015042 +0100
6
+++ gdm-2.29.92.new/common/gdm-settings.c 2010-03-15 18:35:25.128030717 +0100
10
#include <sys/types.h>
14
#include <glib/gi18n.h>
16
#define GDM_SETTINGS_DBUS_PATH GDM_DBUS_PATH "/Settings"
17
#define GDM_SETTINGS_DBUS_NAME "org.gnome.DisplayManager.Settings"
19
+#define GCONF_SOUND_EVENT_KEY "/desktop/gnome/sound/event_sounds"
21
#define GDM_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SETTINGS, GdmSettingsPrivate))
23
struct GdmSettingsPrivate
29
+gdm_settings_get_gconf_sound_value (gboolean *enabled) {
31
+ GError *error = NULL;
32
+ char *shutdown_command[] = { "gconftool-2", "--shutdown" };
33
+ char *get_command[] = { "gconftool-2", "--direct", "-g", GCONF_SOUND_EVENT_KEY };
35
+ struct passwd *pwent;
38
+ gboolean success = FALSE;
40
+ current_uid = geteuid ();
41
+ pwent = getpwnam (GDM_USERNAME);
42
+ if G_UNLIKELY (pwent == NULL)
43
+ g_warning ("Can't access to 'gdm' user name in passwd");
45
+ gdm_uid = pwent->pw_uid;
47
+ res = g_spawn_sync (NULL,
51
+ | G_SPAWN_STDERR_TO_DEV_NULL,
54
+ (gchar **) &enabled,
59
+ if (error != NULL) {
60
+ g_warning ("Unable to get event key to gconf: %s", error->message);
61
+ g_error_free (error);
64
+ g_warning ("Unable to get event key to gconf: unknown error");
69
+ seteuid(current_uid);
71
+ g_strfreev (shutdown_command);
72
+ g_strfreev (get_command);
78
+gdm_settings_set_gconf_sound_value (gboolean enabled) {
80
+ GError *error = NULL;
81
+ char *shutdown_command[] = { "gconftool-2", "--shutdown" };
82
+ char *set_command[] = { "gconftool-2", "--direct", "-s", GCONF_SOUND_EVENT_KEY, "-t", "boolean", (gchar *) enabled };
84
+ struct passwd *pwent;
88
+ current_uid = geteuid ();
89
+ pwent = getpwnam (GDM_USERNAME);
90
+ if G_UNLIKELY (pwent == NULL)
91
+ g_warning ("Can't access to 'gdm' user name in passwd");
93
+ gdm_uid = pwent->pw_uid;
95
+ res = g_spawn_sync (NULL,
98
+ G_SPAWN_SEARCH_PATH,
106
+ if (error != NULL) {
107
+ g_warning ("Unable to shutdown gconf: %s", error->message);
108
+ g_error_free (error);
111
+ g_warning ("Unable to shutdown gconf: unknown error");
114
+ res = g_spawn_async (NULL,
117
+ G_SPAWN_SEARCH_PATH
118
+ | G_SPAWN_STDOUT_TO_DEV_NULL
119
+ | G_SPAWN_STDERR_TO_DEV_NULL,
125
+ if (error != NULL) {
126
+ g_warning ("Unable to set event key to gconf: %s", error->message);
127
+ g_error_free (error);
130
+ g_warning ("Unable to set event key to gconf: unknown error");
134
+ seteuid(current_uid);
136
+ g_strfreev (shutdown_command);
137
+ g_strfreev (set_command);
141
dbus-send --system --print-reply --dest=org.gnome.DisplayManager /org/gnome/DisplayManager/Settings org.gnome.DisplayManager.Settings.GetValue string:"xdmcp/Enable"
53
188
+ SetSoundEnabledData *data)
55
190
+ PolkitAuthorizationResult *auth_result;
57
191
+ GError *error = NULL;
59
193
+ auth_result = polkit_authority_check_authorization_finish (authority, result, &error);
61
195
+ if (!auth_result)
62
196
+ dbus_g_method_return_error (data->context, error);
64
198
+ if (polkit_authorization_result_get_is_authorized (auth_result)) {
65
+ // ... data->enabled
199
+ gdm_settings_set_gconf_sound_value (data->enabled);
66
200
+ dbus_g_method_return (data->context);