~didrocks/gdm/sound-session

« back to all changes in this revision

Viewing changes to debian/patches/09_gdmserver_sound_settings.patch

  • Committer: Didier Roche
  • Date: 2010-03-15 17:39:07 UTC
  • Revision ID: didier.roche@canonical.com-20100315173907-qz1wzmd20myoa17k
get the gconf backend for sound setting ready

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
## Origin/Author: add some origin or author
3
3
## Bug: bug URL
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
7
 
@@ -111,6 +111,25 @@
 
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
 
7
@@ -28,6 +28,7 @@
 
8
 #include <signal.h>
 
9
 #include <sys/stat.h>
 
10
 #include <sys/types.h>
 
11
+#include <pwd.h>
 
12
 
 
13
 #include <glib.h>
 
14
 #include <glib/gi18n.h>
 
15
@@ -49,6 +50,8 @@
 
16
 #define GDM_SETTINGS_DBUS_PATH GDM_DBUS_PATH "/Settings"
 
17
 #define GDM_SETTINGS_DBUS_NAME "org.gnome.DisplayManager.Settings"
 
18
 
 
19
+#define GCONF_SOUND_EVENT_KEY "/desktop/gnome/sound/event_sounds"
 
20
+
 
21
 #define GDM_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SETTINGS, GdmSettingsPrivate))
 
22
 
 
23
 struct GdmSettingsPrivate
 
24
@@ -83,6 +86,118 @@
 
25
         return ret;
 
26
 }
 
27
 
 
28
+static gboolean
 
29
+gdm_settings_get_gconf_sound_value (gboolean *enabled) {
 
30
+
 
31
+        GError  *error = NULL;
 
32
+        char   *shutdown_command[] = { "gconftool-2", "--shutdown" };
 
33
+        char   *get_command[]  =  { "gconftool-2", "--direct", "-g", GCONF_SOUND_EVENT_KEY };
 
34
+        gboolean res;
 
35
+        struct passwd *pwent;
 
36
+        uid_t          gdm_uid;
 
37
+        uid_t          current_uid;
 
38
+        gboolean success = FALSE;
 
39
+
 
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");
 
44
+        else {
 
45
+                gdm_uid = pwent->pw_uid;
 
46
+                seteuid (gdm_uid);
 
47
+                res = g_spawn_sync (NULL,
 
48
+                                    get_command,
 
49
+                                    NULL,
 
50
+                                    G_SPAWN_SEARCH_PATH
 
51
+                                    | G_SPAWN_STDERR_TO_DEV_NULL,
 
52
+                                    NULL,
 
53
+                                    NULL,
 
54
+                                    (gchar **) &enabled,
 
55
+                                    NULL,
 
56
+                                    NULL,
 
57
+                                    &error);
 
58
+                if (!res) {
 
59
+                        if (error != NULL) {
 
60
+                                 g_warning ("Unable to get event key to gconf: %s", error->message);
 
61
+                                 g_error_free (error);
 
62
+                        }
 
63
+                        else
 
64
+                                 g_warning ("Unable to get event key to gconf: unknown error");
 
65
+                }
 
66
+                else
 
67
+                        success = TRUE;
 
68
+        }
 
69
+        seteuid(current_uid);
 
70
+
 
71
+        g_strfreev (shutdown_command);
 
72
+        g_strfreev (get_command);
 
73
+        return success;
 
74
+}
 
75
+
 
76
+
 
77
+static void
 
78
+gdm_settings_set_gconf_sound_value (gboolean enabled) {
 
79
+
 
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 };
 
83
+        gboolean res;
 
84
+        struct passwd *pwent;
 
85
+        uid_t          gdm_uid;
 
86
+        uid_t          current_uid;
 
87
+
 
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");
 
92
+        else {
 
93
+                gdm_uid = pwent->pw_uid;
 
94
+                seteuid (gdm_uid);
 
95
+                res = g_spawn_sync (NULL,
 
96
+                                    shutdown_command,
 
97
+                                    NULL,
 
98
+                                    G_SPAWN_SEARCH_PATH,
 
99
+                                    NULL,
 
100
+                                    NULL,
 
101
+                                    NULL,
 
102
+                                    NULL,
 
103
+                                    NULL,
 
104
+                                    &error);
 
105
+                if (!res) {
 
106
+                        if (error != NULL) {
 
107
+                                g_warning ("Unable to shutdown gconf: %s", error->message);
 
108
+                                g_error_free (error);
 
109
+                        }
 
110
+                        else
 
111
+                                g_warning ("Unable to shutdown gconf: unknown error");
 
112
+                 }
 
113
+                 else {
 
114
+                        res = g_spawn_async (NULL,
 
115
+                                             set_command,
 
116
+                                             NULL,
 
117
+                                             G_SPAWN_SEARCH_PATH
 
118
+                                             | G_SPAWN_STDOUT_TO_DEV_NULL
 
119
+                                             | G_SPAWN_STDERR_TO_DEV_NULL,
 
120
+                                             NULL,
 
121
+                                             NULL,
 
122
+                                             NULL,
 
123
+                                             &error);
 
124
+                        if (!res) {
 
125
+                                if (error != NULL) {
 
126
+                                        g_warning ("Unable to set event key to gconf: %s", error->message);
 
127
+                                        g_error_free (error);
 
128
+                                 }
 
129
+                                 else
 
130
+                                        g_warning ("Unable to set event key to gconf: unknown error");
 
131
+                        }
 
132
+                }
 
133
+        }
 
134
+        seteuid(current_uid);
 
135
+
 
136
+        g_strfreev (shutdown_command);
 
137
+        g_strfreev (set_command);
 
138
+
 
139
+}
 
140
 /*
 
141
 dbus-send --system --print-reply --dest=org.gnome.DisplayManager /org/gnome/DisplayManager/Settings org.gnome.DisplayManager.Settings.GetValue string:"xdmcp/Enable"
 
142
 */
 
143
@@ -111,6 +226,24 @@
8
144
         return res;
9
145
 }
10
146
 
18
154
+                                gboolean    *enabled,
19
155
+                                GError     **error)
20
156
+{
21
 
+        gboolean res = TRUE;
 
157
+        gboolean res;
22
158
+
23
159
+        g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
24
 
+
25
 
+        *enabled = FALSE;
 
160
+        res = gdm_settings_get_gconf_sound_value (enabled);
26
161
+
27
162
+        return res;
28
163
+}
30
165
 static void
31
166
 unlock_auth_cb (PolkitAuthority *authority,
32
167
                 GAsyncResult *result,
33
 
@@ -155,6 +174,12 @@
 
168
@@ -155,6 +288,12 @@
34
169
         gchar *key, *value;
35
170
 } SetValueData;
36
171
 
43
178
 static void
44
179
 set_value_auth_cb (PolkitAuthority *authority,
45
180
                    GAsyncResult *result,
46
 
@@ -229,6 +254,69 @@
 
181
@@ -229,6 +368,68 @@
47
182
         return TRUE;
48
183
 }
49
184
 
53
188
+                           SetSoundEnabledData *data)
54
189
+{
55
190
+        PolkitAuthorizationResult *auth_result;
56
 
+        gboolean enabled;
57
191
+        GError  *error = NULL;
58
 
+  
 
192
+        
59
193
+        auth_result = polkit_authority_check_authorization_finish (authority, result, &error);
60
194
+
61
195
+        if (!auth_result)
62
196
+                dbus_g_method_return_error (data->context, error);
63
197
+        else {
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);
67
201
+                }
68
202
+                else {
114
248
 register_settings (GdmSettings *settings)
115
249
 {
116
250
diff -Nur -x '*.orig' -x '*~' gdm-2.29.92/common/gdm-settings.h gdm-2.29.92.new/common/gdm-settings.h
117
 
--- gdm-2.29.92/common/gdm-settings.h   2010-03-11 16:52:27.002994993 +1100
118
 
+++ gdm-2.29.92.new/common/gdm-settings.h       2010-03-11 16:52:27.512996055 +1100
 
251
--- gdm-2.29.92/common/gdm-settings.h   2010-03-15 18:34:31.952015042 +0100
 
252
+++ gdm-2.29.92.new/common/gdm-settings.h       2010-03-15 18:34:32.756013320 +0100
119
253
@@ -71,12 +71,18 @@
120
254
                                                                  const char  *key,
121
255
                                                                  char       **value,
136
270
 G_END_DECLS
137
271
 
138
272
diff -Nur -x '*.orig' -x '*~' gdm-2.29.92/common/gdm-settings.xml gdm-2.29.92.new/common/gdm-settings.xml
139
 
--- gdm-2.29.92/common/gdm-settings.xml 2010-03-11 16:52:27.002994993 +1100
140
 
+++ gdm-2.29.92.new/common/gdm-settings.xml     2010-03-11 16:52:27.512996055 +1100
 
273
--- gdm-2.29.92/common/gdm-settings.xml 2010-03-15 18:34:31.952015042 +0100
 
274
+++ gdm-2.29.92.new/common/gdm-settings.xml     2010-03-15 18:34:32.756013320 +0100
141
275
@@ -5,6 +5,9 @@
142
276
       <arg name="key" direction="in" type="s"/>
143
277
       <arg name="value" direction="out" type="s"/>