~elementary-apps/elementaryos/accountsservices-patch-background-infos

« back to all changes in this revision

Viewing changes to debian/patches/0001-formats-locale-property.patch

  • Committer: RabbitBot
  • Date: 2014-10-06 02:14:17 UTC
  • Revision ID: rabbitbot@elementaryos.org-20141006021417-fka7omad4zdd3eg6
Initial import, version 0.6.35-0ubuntu7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Addition of FormatsLocale property and SetFormatsLocale method.
 
2
Forwarded: https://bugs.freedesktop.org/42857
 
3
Author: Gunnar Hjalmarsson <ubuntu@gunnar.cc>
 
4
Last-Update: 2011-11-12
 
5
 
 
6
Index: accountsservice-0.6.35/data/org.freedesktop.Accounts.User.xml
 
7
===================================================================
 
8
--- accountsservice-0.6.35.orig/data/org.freedesktop.Accounts.User.xml  2013-11-13 15:16:36.076124828 +0100
 
9
+++ accountsservice-0.6.35/data/org.freedesktop.Accounts.User.xml       2013-11-13 15:16:36.064124828 +0100
 
10
@@ -150,6 +150,41 @@
 
11
     </doc:doc>
 
12
   </method>
 
13
 
 
14
+  <method name="SetFormatsLocale">
 
15
+    <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
 
16
+    <arg name="formats_locale" direction="in" type="s">
 
17
+      <doc:doc>
 
18
+        <doc:summary>
 
19
+          The new regional formats, as a locale specification like "de_DE.UTF-8".
 
20
+        </doc:summary>
 
21
+      </doc:doc>
 
22
+    </arg>
 
23
+    <doc:doc>
 
24
+      <doc:description>
 
25
+        <doc:para>
 
26
+          Sets the users regional formats.
 
27
+        </doc:para>
 
28
+      </doc:description>
 
29
+      <doc:permission>
 
30
+        The caller needs one of the following PolicyKit authorizations:
 
31
+        <doc:list>
 
32
+          <doc:item>
 
33
+            <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term>
 
34
+            <doc:definition>To change his own language</doc:definition>
 
35
+          </doc:item>
 
36
+          <doc:item>
 
37
+            <doc:term>org.freedesktop.accounts.user-administration</doc:term>
 
38
+            <doc:definition>To change the language of another user</doc:definition>
 
39
+          </doc:item>
 
40
+        </doc:list>
 
41
+      </doc:permission>
 
42
+      <doc:errors>
 
43
+        <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error>
 
44
+        <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error>
 
45
+      </doc:errors>
 
46
+    </doc:doc>
 
47
+  </method>
 
48
+
 
49
   <method name="SetXSession">
 
50
     <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
 
51
     <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="user_set_x_session"/>
 
52
@@ -621,6 +656,16 @@
 
53
         </doc:para>
 
54
       </doc:description>
 
55
     </doc:doc>
 
56
+  </property>
 
57
+
 
58
+  <property name="FormatsLocale" type="s" access="read">
 
59
+    <doc:doc>
 
60
+      <doc:description>
 
61
+        <doc:para>
 
62
+          The users regional formats, as a locale specification like "de_DE.UTF-8".
 
63
+        </doc:para>
 
64
+      </doc:description>
 
65
+    </doc:doc>
 
66
   </property>
 
67
 
 
68
   <property name="XSession" type="s" access="read">
 
69
Index: accountsservice-0.6.35/src/libaccountsservice/act-user.c
 
70
===================================================================
 
71
--- accountsservice-0.6.35.orig/src/libaccountsservice/act-user.c       2013-11-13 15:16:36.076124828 +0100
 
72
+++ accountsservice-0.6.35/src/libaccountsservice/act-user.c    2013-11-13 15:16:36.068124828 +0100
 
73
@@ -93,6 +93,7 @@
 
74
         PROP_LOGIN_HISTORY,
 
75
         PROP_ICON_FILE,
 
76
         PROP_LANGUAGE,
 
77
+        PROP_FORMATS_LOCALE,
 
78
         PROP_X_SESSION,
 
79
         PROP_IS_LOADED
 
80
 };
 
81
@@ -122,6 +123,7 @@
 
82
         char           *location;
 
83
         char           *icon_file;
 
84
         char           *language;
 
85
+        char           *formats_locale;
 
86
         char           *x_session;
 
87
         GList          *our_sessions;
 
88
         GList          *other_sessions;
 
89
@@ -308,6 +310,9 @@
 
90
         case PROP_LANGUAGE:
 
91
                 g_value_set_string (value, user->language);
 
92
                 break;
 
93
+        case PROP_FORMATS_LOCALE:
 
94
+                g_value_set_string (value, user->formats_locale);
 
95
+                break;
 
96
         case PROP_X_SESSION:
 
97
                 g_value_set_string (value, user->x_session);
 
98
                 break;
 
99
@@ -464,6 +469,13 @@
 
100
                                                               NULL,
 
101
                                                               G_PARAM_READABLE));
 
102
         g_object_class_install_property (gobject_class,
 
103
+                                         PROP_FORMATS_LOCALE,
 
104
+                                         g_param_spec_string ("formats_locale",
 
105
+                                                              "Regional Formats",
 
106
+                                                              "User's regional formats.",
 
107
+                                                              NULL,
 
108
+                                                              G_PARAM_READABLE));
 
109
+        g_object_class_install_property (gobject_class,
 
110
                                          PROP_X_SESSION,
 
111
                                          g_param_spec_string ("x-session",
 
112
                                                               "X session",
 
113
@@ -583,6 +595,7 @@
 
114
         g_free (user->location);
 
115
         if (user->login_history)
 
116
           g_variant_unref (user->login_history);
 
117
+        g_free (user->formats_locale);
 
118
 
 
119
         if (user->accounts_proxy != NULL) {
 
120
                 g_object_unref (user->accounts_proxy);
 
121
@@ -1052,6 +1065,22 @@
 
122
 }
 
123
 
 
124
 /**
 
125
+ * act_user_get_formats_locale:
 
126
+ * @user: a #ActUser
 
127
+ *
 
128
+ * Returns the path to the configured formats locale of @user.
 
129
+ *
 
130
+ * Returns: (transfer none): a path to an icon
 
131
+ */
 
132
+const char *
 
133
+act_user_get_formats_locale (ActUser *user)
 
134
+{
 
135
+        g_return_val_if_fail (ACT_IS_USER (user), NULL);
 
136
+
 
137
+        return user->formats_locale;
 
138
+}
 
139
+
 
140
+/**
 
141
  * act_user_get_x_session:
 
142
  * @user: a #ActUser
 
143
  *
 
144
@@ -1279,6 +1308,17 @@
 
145
                         user->language = g_strdup (new_language);
 
146
                         g_object_notify (G_OBJECT (user), "language");
 
147
                 }
 
148
+
 
149
+        } else if (strcmp (key, "FormatsLocale") == 0) {
 
150
+                const char *new_formats_locale;
 
151
+
 
152
+                new_formats_locale = g_variant_get_string (value, NULL);
 
153
+                if (g_strcmp0 (user->formats_locale, new_formats_locale) != 0) {
 
154
+                        g_free (user->formats_locale);
 
155
+                        user->formats_locale = g_strdup (new_formats_locale);
 
156
+                        g_object_notify (G_OBJECT (user), "formats_locale");
 
157
+                }
 
158
+
 
159
         } else if (strcmp (key, "XSession") == 0) {
 
160
                 const char *new_x_session;
 
161
 
 
162
@@ -1603,6 +1643,35 @@
 
163
                 g_error_free (error);
 
164
                 return;
 
165
         }
 
166
+}
 
167
+
 
168
+/**
 
169
+ * act_user_set_formats_locale:
 
170
+ * @user: the user object to alter.
 
171
+ * @formats_locale: a locale (e.g. en_US.utf8)
 
172
+ *
 
173
+ * Assigns a new formats locale for @user.
 
174
+ *
 
175
+ * Note this function is synchronous and ignores errors.
 
176
+ **/
 
177
+void
 
178
+act_user_set_formats_locale (ActUser    *user,
 
179
+                             const char *formats_locale)
 
180
+{
 
181
+        GError *error = NULL;
 
182
+
 
183
+        g_return_if_fail (ACT_IS_USER (user));
 
184
+        g_return_if_fail (formats_locale != NULL);
 
185
+        g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy));
 
186
+
 
187
+        if (!accounts_user_call_set_formats_locale_sync (user->accounts_proxy,
 
188
+                                                         formats_locale,
 
189
+                                                         NULL,
 
190
+                                                         &error)) {
 
191
+                g_warning ("SetFormatsLocale call failed: %s", error->message);
 
192
+                g_error_free (error);
 
193
+                return;
 
194
+        }
 
195
 }
 
196
 
 
197
 /**
 
198
Index: accountsservice-0.6.35/src/libaccountsservice/act-user.h
 
199
===================================================================
 
200
--- accountsservice-0.6.35.orig/src/libaccountsservice/act-user.h       2013-11-13 15:16:36.076124828 +0100
 
201
+++ accountsservice-0.6.35/src/libaccountsservice/act-user.h    2013-11-13 15:16:36.068124828 +0100
 
202
@@ -77,6 +77,7 @@
 
203
 gboolean       act_user_is_nonexistent            (ActUser   *user);
 
204
 const char    *act_user_get_icon_file             (ActUser   *user);
 
205
 const char    *act_user_get_language              (ActUser   *user);
 
206
+const char    *act_user_get_formats_locale        (ActUser   *user);
 
207
 const char    *act_user_get_x_session             (ActUser   *user);
 
208
 const char    *act_user_get_primary_session_id    (ActUser   *user);
 
209
 
 
210
@@ -88,6 +89,8 @@
 
211
                                                    const char *email);
 
212
 void           act_user_set_language              (ActUser    *user,
 
213
                                                    const char *language);
 
214
+void           act_user_set_formats_locale        (ActUser    *user,
 
215
+                                                   const char *formats_locale);
 
216
 void           act_user_set_x_session             (ActUser    *user,
 
217
                                                    const char *x_session);
 
218
 void           act_user_set_location              (ActUser    *user,
 
219
Index: accountsservice-0.6.35/src/user.c
 
220
===================================================================
 
221
--- accountsservice-0.6.35.orig/src/user.c      2013-11-13 15:16:36.076124828 +0100
 
222
+++ accountsservice-0.6.35/src/user.c   2013-11-13 15:16:36.072124828 +0100
 
223
@@ -58,6 +58,7 @@
 
224
         PROP_SHELL,
 
225
         PROP_EMAIL,
 
226
         PROP_LANGUAGE,
 
227
+        PROP_FORMATS_LOCALE,
 
228
         PROP_X_SESSION,
 
229
         PROP_LOCATION,
 
230
         PROP_LOGIN_FREQUENCY,
 
231
@@ -93,6 +94,7 @@
 
232
         gchar        *shell;
 
233
         gchar        *email;
 
234
         gchar        *language;
 
235
+        gchar        *formats_locale;
 
236
         gchar        *x_session;
 
237
         gchar        *location;
 
238
         guint64       login_frequency;
 
239
@@ -322,6 +324,13 @@
 
240
                 g_object_notify (G_OBJECT (user), "language");
 
241
         }
 
242
 
 
243
+        s = g_key_file_get_string (keyfile, "User", "FormatsLocale", NULL);
 
244
+        if (s != NULL) {
 
245
+                g_free (user->formats_locale);
 
246
+                user->formats_locale = s;
 
247
+                g_object_notify (G_OBJECT (user), "formats-locale");
 
248
+        }
 
249
+
 
250
         s = g_key_file_get_string (keyfile, "User", "XSession", NULL);
 
251
         if (s != NULL) {
 
252
                 g_free (user->x_session);
 
253
@@ -405,6 +414,9 @@
 
254
         if (user->language)
 
255
                 g_key_file_set_string (keyfile, "User", "Language", user->language);
 
256
 
 
257
+        if (user->formats_locale)
 
258
+                g_key_file_set_string (keyfile, "User", "FormatsLocale", user->formats_locale);
 
259
+
 
260
         if (user->x_session)
 
261
                 g_key_file_set_string (keyfile, "User", "XSession", user->x_session);
 
262
 
 
263
@@ -1106,6 +1118,61 @@
 
264
 }
 
265
 
 
266
 static void
 
267
+user_change_formats_locale_authorized_cb (Daemon                *daemon,
 
268
+                                          User                  *user,
 
269
+                                          GDBusMethodInvocation *context,
 
270
+                                          gpointer               data)
 
271
+
 
272
+{
 
273
+        gchar *formats_locale = data;
 
274
+
 
275
+        if (g_strcmp0 (user->formats_locale, formats_locale) != 0) {
 
276
+                g_free (user->formats_locale);
 
277
+                user->formats_locale = g_strdup (formats_locale);
 
278
+
 
279
+                save_extra_data (user);
 
280
+
 
281
+                accounts_user_emit_changed (ACCOUNTS_USER (user));
 
282
+
 
283
+                g_object_notify (G_OBJECT (user), "formats_locale");
 
284
+        }
 
285
+
 
286
+        accounts_user_complete_set_formats_locale (ACCOUNTS_USER (user), context);
 
287
+}
 
288
+
 
289
+gboolean
 
290
+user_set_formats_locale (AccountsUser          *auser,
 
291
+                         GDBusMethodInvocation *context,
 
292
+                         const gchar           *formats_locale)
 
293
+{
 
294
+        User *user = (User*)auser;
 
295
+
 
296
+        int uid;
 
297
+        const gchar *action_id;
 
298
+
 
299
+        if (!get_caller_uid (context, &uid)) {
 
300
+                throw_error (context, ERROR_FAILED, "identifying caller failed");
 
301
+                return FALSE;
 
302
+        }
 
303
+
 
304
+        if (user->uid == (uid_t) uid)
 
305
+                action_id = "org.freedesktop.accounts.change-own-user-data";
 
306
+        else
 
307
+                action_id = "org.freedesktop.accounts.user-administration";
 
308
+
 
309
+        daemon_local_check_auth (user->daemon,
 
310
+                                 user,
 
311
+                                 action_id,
 
312
+                                 TRUE,
 
313
+                                 user_change_formats_locale_authorized_cb,
 
314
+                                 context,
 
315
+                                 g_strdup (formats_locale),
 
316
+                                 (GDestroyNotify) g_free);
 
317
+
 
318
+        return TRUE;
 
319
+}
 
320
+
 
321
+static void
 
322
 user_change_x_session_authorized_cb (Daemon                *daemon,
 
323
                                      User                  *user,
 
324
                                      GDBusMethodInvocation *context,
 
325
@@ -2106,6 +2173,7 @@
 
326
         g_free (user->default_icon_file);
 
327
         g_free (user->email);
 
328
         g_free (user->language);
 
329
+        g_free (user->formats_locale);
 
330
         g_free (user->x_session);
 
331
         g_free (user->location);
 
332
         g_free (user->password_hint);
 
333
@@ -2132,6 +2200,9 @@
 
334
         case PROP_LANGUAGE:
 
335
                 user->language = g_value_dup_string (value);
 
336
                 break;
 
337
+        case PROP_FORMATS_LOCALE:
 
338
+                user->formats_locale = g_value_dup_string (value);
 
339
+                break;
 
340
         case PROP_X_SESSION:
 
341
                 user->x_session = g_value_dup_string (value);
 
342
                 break;
 
343
@@ -2200,6 +2271,9 @@
 
344
         case PROP_LANGUAGE:
 
345
                 g_value_set_string (value, user->language);
 
346
                 break;
 
347
+        case PROP_FORMATS_LOCALE:
 
348
+                g_value_set_string (value, user->formats_locale);
 
349
+                break;
 
350
         case PROP_X_SESSION:
 
351
                 g_value_set_string (value, user->x_session);
 
352
                 break;
 
353
@@ -2263,6 +2337,7 @@
 
354
         iface->handle_set_account_type = user_set_account_type;
 
355
         iface->handle_set_automatic_login = user_set_automatic_login;
 
356
         iface->handle_set_email = user_set_email;
 
357
+        iface->handle_set_formats_locale = user_set_formats_locale;
 
358
         iface->handle_set_home_directory = user_set_home_directory;
 
359
         iface->handle_set_icon_file = user_set_icon_file;
 
360
         iface->handle_set_language = user_set_language;
 
361
@@ -2309,6 +2384,7 @@
 
362
         user->default_icon_file = NULL;
 
363
         user->email = NULL;
 
364
         user->language = NULL;
 
365
+        user->formats_locale = NULL;
 
366
         user->x_session = NULL;
 
367
         user->location = NULL;
 
368
         user->password_mode = PASSWORD_MODE_REGULAR;