add 0001-formats-locale-property.patch
(cherry picked from commit 8bfb6a13a593a776820b16b52cdabd505fcea814)
This commit is contained in:
parent
f41bd7003d
commit
0e7417fa5f
277
0001-formats-locale-property.patch
Normal file
277
0001-formats-locale-property.patch
Normal file
@ -0,0 +1,277 @@
|
||||
From f090729b7e6f977de4deb3201f177e60de81d006 Mon Sep 17 00:00:00 2001
|
||||
From: peijiankang <peijiankang@kylinos.cn>
|
||||
Date: Thu, 29 Jun 2023 16:23:24 +0800
|
||||
Subject: [PATCH] Addition of FormatsLocale property and SetFormatsLocale
|
||||
|
||||
---
|
||||
data/org.freedesktop.Accounts.User.xml | 45 ++++++++++++++++++++
|
||||
src/libaccountsservice/act-user.c | 55 ++++++++++++++++++++++++
|
||||
src/libaccountsservice/act-user.h | 3 ++
|
||||
src/user.c | 59 ++++++++++++++++++++++++++
|
||||
4 files changed, 162 insertions(+)
|
||||
|
||||
diff --git a/data/org.freedesktop.Accounts.User.xml b/data/org.freedesktop.Accounts.User.xml
|
||||
index 5302e20..3833506 100644
|
||||
--- a/data/org.freedesktop.Accounts.User.xml
|
||||
+++ b/data/org.freedesktop.Accounts.User.xml
|
||||
@@ -150,6 +150,41 @@
|
||||
</doc:doc>
|
||||
</method>
|
||||
|
||||
+ <method name="SetFormatsLocale">
|
||||
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
+ <arg name="formats_locale" direction="in" type="s">
|
||||
+ <doc:doc>
|
||||
+ <doc:summary>
|
||||
+ The new regional formats, as a locale specification like "de_DE.UTF-8".
|
||||
+ </doc:summary>
|
||||
+ </doc:doc>
|
||||
+ </arg>
|
||||
+ <doc:doc>
|
||||
+ <doc:description>
|
||||
+ <doc:para>
|
||||
+ Sets the users regional formats.
|
||||
+ </doc:para>
|
||||
+ </doc:description>
|
||||
+ <doc:permission>
|
||||
+ The caller needs one of the following PolicyKit authorizations:
|
||||
+ <doc:list>
|
||||
+ <doc:item>
|
||||
+ <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term>
|
||||
+ <doc:definition>To change his own language</doc:definition>
|
||||
+ </doc:item>
|
||||
+ <doc:item>
|
||||
+ <doc:term>org.freedesktop.accounts.user-administration</doc:term>
|
||||
+ <doc:definition>To change the language of another user</doc:definition>
|
||||
+ </doc:item>
|
||||
+ </doc:list>
|
||||
+ </doc:permission>
|
||||
+ <doc:errors>
|
||||
+ <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error>
|
||||
+ <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error>
|
||||
+ </doc:errors>
|
||||
+ </doc:doc>
|
||||
+ </method>
|
||||
+
|
||||
<method name="SetXSession">
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="user_set_x_session"/>
|
||||
@@ -806,6 +841,16 @@
|
||||
</doc:doc>
|
||||
</property>
|
||||
|
||||
+ <property name="FormatsLocale" type="s" access="read">
|
||||
+ <doc:doc>
|
||||
+ <doc:description>
|
||||
+ <doc:para>
|
||||
+ The users regional formats, as a locale specification like "de_DE.UTF-8".
|
||||
+ </doc:para>
|
||||
+ </doc:description>
|
||||
+ </doc:doc>
|
||||
+ </property>
|
||||
+
|
||||
<property name="XSession" type="s" access="read">
|
||||
<doc:doc>
|
||||
<doc:description>
|
||||
diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c
|
||||
index 25a28b6..5c39157 100644
|
||||
--- a/src/libaccountsservice/act-user.c
|
||||
+++ b/src/libaccountsservice/act-user.c
|
||||
@@ -96,6 +96,7 @@ enum {
|
||||
PROP_BACKGROUND_FILE,
|
||||
PROP_ICON_FILE,
|
||||
PROP_LANGUAGE,
|
||||
+ PROP_FORMATS_LOCALE,
|
||||
PROP_X_SESSION,
|
||||
PROP_IS_LOADED
|
||||
};
|
||||
@@ -395,6 +396,13 @@ act_user_class_init (ActUserClass *class)
|
||||
"User's locale.",
|
||||
NULL,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
+ g_object_class_install_property (gobject_class,
|
||||
+ PROP_FORMATS_LOCALE,
|
||||
+ g_param_spec_string ("formats_locale",
|
||||
+ "Regional Formats",
|
||||
+ "User's regional formats.",
|
||||
+ NULL,
|
||||
+ G_PARAM_READABLE));
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_X_SESSION,
|
||||
g_param_spec_string ("x-session",
|
||||
@@ -1054,6 +1062,25 @@ act_user_get_language (ActUser *user)
|
||||
return accounts_user_get_language (user->accounts_proxy);
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * act_user_get_formats_locale:
|
||||
+ * @user: a #ActUser
|
||||
+ *
|
||||
+ * Returns the path to the configured formats locale of @user.
|
||||
+ *
|
||||
+ * Returns: (transfer none): a path to an icon
|
||||
+ */
|
||||
+const char *
|
||||
+act_user_get_formats_locale (ActUser *user)
|
||||
+{
|
||||
+ g_return_val_if_fail (ACT_IS_USER (user), NULL);
|
||||
+
|
||||
+ if (user->accounts_proxy == NULL)
|
||||
+ return NULL;
|
||||
+
|
||||
+ return accounts_user_get_formats_locale (user->accounts_proxy);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* act_user_get_x_session:
|
||||
* @user: a #ActUser
|
||||
@@ -1338,6 +1365,34 @@ act_user_get_password_expiration_policy (ActUser *user,
|
||||
}
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * act_user_set_formats_locale:
|
||||
+ * @user: the user object to alter.
|
||||
+ * @formats_locale: a locale (e.g. en_US.utf8)
|
||||
+ *
|
||||
+ * Assigns a new formats locale for @user.
|
||||
+ *
|
||||
+ * Note this function is synchronous and ignores errors.
|
||||
+ **/
|
||||
+void
|
||||
+act_user_set_formats_locale (ActUser *user,
|
||||
+ const char *formats_locale)
|
||||
+{
|
||||
+ g_autoptr(GError) error = NULL;
|
||||
+
|
||||
+ g_return_if_fail (ACT_IS_USER (user));
|
||||
+ g_return_if_fail (formats_locale != NULL);
|
||||
+ g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy));
|
||||
+
|
||||
+ if (!accounts_user_call_set_formats_locale_sync (user->accounts_proxy,
|
||||
+ formats_locale,
|
||||
+ NULL,
|
||||
+ &error)) {
|
||||
+ g_warning ("SetFormatsLocale call failed: %s", error->message);
|
||||
+ return;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* act_user_set_email:
|
||||
* @user: the user object to alter.
|
||||
diff --git a/src/libaccountsservice/act-user.h b/src/libaccountsservice/act-user.h
|
||||
index af66542..40cf7aa 100644
|
||||
--- a/src/libaccountsservice/act-user.h
|
||||
+++ b/src/libaccountsservice/act-user.h
|
||||
@@ -79,6 +79,7 @@ gboolean act_user_is_nonexistent (ActUser *user);
|
||||
const char *act_user_get_background_file (ActUser *user);
|
||||
const char *act_user_get_icon_file (ActUser *user);
|
||||
const char *act_user_get_language (ActUser *user);
|
||||
+const char *act_user_get_formats_locale (ActUser *user);
|
||||
const char *act_user_get_x_session (ActUser *user);
|
||||
const char *act_user_get_session (ActUser *user);
|
||||
const char *act_user_get_session_type (ActUser *user);
|
||||
@@ -100,6 +101,8 @@ void act_user_set_email (ActUser *user,
|
||||
const char *email);
|
||||
void act_user_set_language (ActUser *user,
|
||||
const char *language);
|
||||
+void act_user_set_formats_locale (ActUser *user,
|
||||
+ const char *formats_locale);
|
||||
void act_user_set_background_file (ActUser *user,
|
||||
const char *background_file);
|
||||
void act_user_set_x_session (ActUser *user,
|
||||
diff --git a/src/user.c b/src/user.c
|
||||
index 60b97b0..1bd545f 100644
|
||||
--- a/src/user.c
|
||||
+++ b/src/user.c
|
||||
@@ -256,6 +256,12 @@ user_update_from_keyfile (User *user,
|
||||
g_clear_pointer (&s, g_free);
|
||||
}
|
||||
|
||||
+ s = g_key_file_get_string (keyfile, "User", "FormatsLocale", NULL);
|
||||
+ if (s != NULL) {
|
||||
+ accounts_user_set_formats_locale (ACCOUNTS_USER (user), s);
|
||||
+ g_clear_pointer (&s, g_free);
|
||||
+ }
|
||||
+
|
||||
s = g_key_file_get_string (keyfile, "User", "XSession", NULL);
|
||||
if (s != NULL) {
|
||||
accounts_user_set_xsession (ACCOUNTS_USER (user), s);
|
||||
@@ -354,6 +360,9 @@ user_save_to_keyfile (User *user,
|
||||
if (accounts_user_get_session_type (ACCOUNTS_USER (user)))
|
||||
g_key_file_set_string (keyfile, "User", "SessionType", accounts_user_get_session_type (ACCOUNTS_USER (user)));
|
||||
|
||||
+ if (accounts_user_get_formats_locale (ACCOUNTS_USER (user)))
|
||||
+ g_key_file_set_string (keyfile, "User", "FormatsLocale", accounts_user_get_formats_locale (ACCOUNTS_USER (user)));
|
||||
+
|
||||
if (accounts_user_get_xsession (ACCOUNTS_USER (user)))
|
||||
g_key_file_set_string (keyfile, "User", "XSession", accounts_user_get_xsession (ACCOUNTS_USER (user)));
|
||||
|
||||
@@ -1161,6 +1170,55 @@ user_set_session_type (AccountsUser *auser,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+static void
|
||||
+user_change_formats_locale_authorized_cb (Daemon *daemon,
|
||||
+ User *user,
|
||||
+ GDBusMethodInvocation *context,
|
||||
+ gpointer user_data)
|
||||
+
|
||||
+{
|
||||
+ const gchar *formats_locale = user_data;
|
||||
+
|
||||
+ if (g_strcmp0 (accounts_user_get_formats_locale (ACCOUNTS_USER (user)), formats_locale) != 0) {
|
||||
+ accounts_user_set_formats_locale (ACCOUNTS_USER (user), formats_locale);
|
||||
+
|
||||
+ save_extra_data (user);
|
||||
+ }
|
||||
+
|
||||
+ accounts_user_complete_set_formats_locale (ACCOUNTS_USER (user), context);
|
||||
+}
|
||||
+
|
||||
+static gboolean
|
||||
+user_set_formats_locale (AccountsUser *auser,
|
||||
+ GDBusMethodInvocation *context,
|
||||
+ const gchar *formats_locale)
|
||||
+{
|
||||
+ User *user = (User*)auser;
|
||||
+ int uid;
|
||||
+ const gchar *action_id;
|
||||
+
|
||||
+ if (!get_caller_uid (context, &uid)) {
|
||||
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ if (accounts_user_get_uid (ACCOUNTS_USER (user)) == (uid_t) uid)
|
||||
+ action_id = "org.freedesktop.accounts.change-own-user-data";
|
||||
+ else
|
||||
+ action_id = "org.freedesktop.accounts.user-administration";
|
||||
+
|
||||
+ daemon_local_check_auth (user->daemon,
|
||||
+ user,
|
||||
+ action_id,
|
||||
+ TRUE,
|
||||
+ user_change_formats_locale_authorized_cb,
|
||||
+ context,
|
||||
+ g_strdup (formats_locale),
|
||||
+ (GDestroyNotify) g_free);
|
||||
+
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
user_change_x_session_authorized_cb (Daemon *daemon,
|
||||
User *user,
|
||||
@@ -2191,6 +2249,7 @@ user_accounts_user_iface_init (AccountsUserIface *iface)
|
||||
iface->handle_set_automatic_login = user_set_automatic_login;
|
||||
iface->handle_set_background_file = user_set_background_file;
|
||||
iface->handle_set_email = user_set_email;
|
||||
+ iface->handle_set_formats_locale = user_set_formats_locale;
|
||||
iface->handle_set_home_directory = user_set_home_directory;
|
||||
iface->handle_set_icon_file = user_set_icon_file;
|
||||
iface->handle_set_language = user_set_language;
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: accountsservice
|
||||
Version: 0.6.55
|
||||
Release: 3
|
||||
Release: 4
|
||||
Summary: D-Bus service for accessing the list of user accounts and information attached to those accounts.
|
||||
|
||||
License: GPLv3+
|
||||
@ -9,6 +9,7 @@ Source0: https://www.freedesktop.org/software/%{name}/%{name}-%{version}.
|
||||
|
||||
Patch1: 0001-exclude-pcpqa-user-who-cannot-login-because-of-SELin.patch
|
||||
Patch2: accountsservice-0.6.55-kylin-add-background-file-support.patch
|
||||
Patch3: 0001-formats-locale-property.patch
|
||||
|
||||
BuildRequires: gtk-doc polkit-devel libxslt pkgconfig(dbus-1) systemd systemd-devel
|
||||
BuildRequires: meson gobject-introspection-devel gettext-devel glib2-devel
|
||||
@ -90,6 +91,12 @@ are contained in %{name}-devel package.
|
||||
%{_datadir}/gtk-doc/html/libaccountsservice/*
|
||||
|
||||
%changelog
|
||||
* Thu Jun 29 2023 peijiankang <peijiankang@kylinos.cn> - 0.6.55-4
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: add patch3: 0001-formats-locale-property.patch
|
||||
|
||||
* Wed Jun 21 2023 huayadong <huayadong@kylinos.cn> - 0.6.55-3
|
||||
- add patch2:accountsservice-0.6.55-kylin-add-background-file-support.patch
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user