[gnome-initial-setup: 1/2] account: Set the IsParent metadata on the parent account
- From: Will Thompson <wjt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup: 1/2] account: Set the IsParent metadata on the parent account
- Date: Tue, 25 Feb 2020 13:44:55 +0000 (UTC)
commit 76f6acfebb7a23710936f50999533317a3113eed
Author: Philip Withnall <withnall endlessm com>
Date: Fri Feb 14 17:51:49 2020 +0000
account: Set the IsParent metadata on the parent account
If parental controls are enabled (and hence g-i-s creates a parent
account as well as a main account), set the
`com.endlessm.ParentalControls.AccountInfo.IsParent` property on the new
account. This is provided by malcontent, and stored as additional info
bolted on to the side of the user account by accounts-service (like the
rest of the parental controls data is stored).
This doesn’t use new APIs from libmalcontent yet because the APIs
haven’t been decided. It’s more important at the moment to just get the
property set, so that any users who use parental controls have the right
metadata from the beginning; and we can build on that in future.
Signed-off-by: Philip Withnall <withnall endlessm com>
Fixes: #94
.../pages/account/gis-account-page-local.c | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
---
diff --git a/gnome-initial-setup/pages/account/gis-account-page-local.c
b/gnome-initial-setup/pages/account/gis-account-page-local.c
index fb12c05..cfd06a2 100644
--- a/gnome-initial-setup/pages/account/gis-account-page-local.c
+++ b/gnome-initial-setup/pages/account/gis-account-page-local.c
@@ -560,6 +560,7 @@ local_create_user (GisAccountPageLocal *local,
/* Always create the admin user first, in case of failure part-way through
* this function, which would leave us with no admin user at all. */
if (parental_controls_enabled) {
+ g_autoptr(GDBusConnection) connection = NULL;
const gchar *parent_username = "administrator";
const gchar *parent_fullname = _("Administrator");
@@ -569,6 +570,32 @@ local_create_user (GisAccountPageLocal *local,
return;
}
+ /* Mark it as the parent user account.
+ * FIXME: This should be async. */
+ connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &local_error);
+ if (connection != NULL) {
+ g_dbus_connection_call_sync (connection,
+ "org.freedesktop.Accounts",
+ act_user_get_object_path (parent_user),
+ "org.freedesktop.DBus.Properties",
+ "Set",
+ g_variant_new ("(ssv)",
+ "com.endlessm.ParentalControls.AccountInfo",
+ "IsParent",
+ g_variant_new_boolean (TRUE)),
+ NULL, /* reply type */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* default timeout */
+ NULL, /* cancellable */
+ &local_error);
+ }
+ if (local_error != NULL) {
+ /* Make this non-fatal, since the correct accounts-service interface
+ * might not be installed, depending on which version of malcontent is installed. */
+ g_warning ("Failed to mark user as parent: %s", local_error->message);
+ g_clear_error (&local_error);
+ }
+
g_signal_emit (local, signals[PARENT_USER_CREATED], 0, parent_user, "");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]