From e132254cbe5559843f788ff927b0ffbfbc087e66 Mon Sep 17 00:00:00 2001 From: Alexander Mikhaylenko Date: Sun, 19 Sep 2021 21:42:09 +0000 Subject: [PATCH 1/7] Implement the settings portal Thankfully, we don't have to implement everything - settings portal can have multiple implementations and will combine settings from all of them. Fixes https://github.com/elementary/settings-daemon/issues/37 --- src/config.vala.in => config.vala.in | 0 meson.build | 16 ++ meson_options.txt | 1 + settings-portal/Error.vala | 56 +++++++ settings-portal/Main.vala | 78 +++++++++ settings-portal/Settings.vala | 156 ++++++++++++++++++ .../io.elementary.settings-daemon.portal | 4 + ...tings-daemon.xdg-desktop-portal.service.in | 7 + settings-portal/meson.build | 57 +++++++ ...ktop.elementary.settings-daemon.service.in | 4 + src/meson.build | 12 +- 11 files changed, 380 insertions(+), 11 deletions(-) rename src/config.vala.in => config.vala.in (100%) create mode 100644 meson_options.txt create mode 100644 settings-portal/Error.vala create mode 100644 settings-portal/Main.vala create mode 100644 settings-portal/Settings.vala create mode 100644 settings-portal/io.elementary.settings-daemon.portal create mode 100644 settings-portal/io.elementary.settings-daemon.xdg-desktop-portal.service.in create mode 100644 settings-portal/meson.build create mode 100644 settings-portal/org.freedesktop.impl.portal.desktop.elementary.settings-daemon.service.in diff --git a/src/config.vala.in b/config.vala.in similarity index 100% rename from src/config.vala.in rename to config.vala.in diff --git a/meson.build b/meson.build index 78535439..dff5b370 100644 --- a/meson.build +++ b/meson.build @@ -13,6 +13,21 @@ cc = meson.get_compiler('c') m_dep = cc.find_library('m', required : false) libgeoclue_dep = dependency ('libgeoclue-2.0') +conf_data = configuration_data() +conf_data.set('PROJECT_NAME', meson.project_name()) +conf_data.set('VERSION', meson.project_version()) + +config_file = configure_file( + input: 'config.vala.in', + output: 'config.vala', + configuration: conf_data +) + +config_dep = declare_dependency( + sources: config_file, + include_directories: include_directories('.') +) + prefix = get_option('prefix') datadir = join_paths(prefix, get_option('datadir')) @@ -21,5 +36,6 @@ symlink = join_paths(meson.current_source_dir (), 'meson', 'create-symlink.sh') subdir('data') subdir('po') subdir('src') +subdir('settings-portal') meson.add_install_script('meson/post_install.py') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..d1195c4b --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('systemduserunitdir', type: 'string', value: '', description: 'custom directory for systemd user units, or \'no\' to disable') diff --git a/settings-portal/Error.vala b/settings-portal/Error.vala new file mode 100644 index 00000000..115949b5 --- /dev/null +++ b/settings-portal/Error.vala @@ -0,0 +1,56 @@ +/*- + * Copyright 2021 Alexander Mikhaylenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1335 USA. + */ + +namespace XdgDesktopPortal { + public enum Error { + FAILED, + INVALID_ARGUMENT, + NOT_FOUND, + EXISTS, + NOT_ALLOWED, + CANCELLED, + WINDOW_DESTROYED + } + + const GLib.DBusErrorEntry[] ERROR_ENTRIES = { + { Error.FAILED, "org.freedesktop.portal.Error.Failed" }, + { Error.INVALID_ARGUMENT, "org.freedesktop.portal.Error.InvalidArgument" }, + { Error.NOT_FOUND, "org.freedesktop.portal.Error.NotFound" }, + { Error.EXISTS, "org.freedesktop.portal.Error.Exists" }, + { Error.NOT_ALLOWED, "org.freedesktop.portal.Error.NotAllowed" }, + { Error.CANCELLED, "org.freedesktop.portal.Error.Cancelled" }, + { Error.WINDOW_DESTROYED, "org.freedesktop.portal.Error.WindowDestroyed" } + }; + + private size_t quark = 0; + + private GLib.Quark error_quark () { + GLib.DBusError.register_error_domain ( + "xdg-desktop-portal-error-quark", + (size_t) &quark, + ERROR_ENTRIES + ); + + return (GLib.Quark) quark; + } + + public GLib.Error create_error (Error code, string message) { + return new GLib.Error.literal (error_quark (), code, message); + } +} diff --git a/settings-portal/Main.vala b/settings-portal/Main.vala new file mode 100644 index 00000000..57d5518f --- /dev/null +++ b/settings-portal/Main.vala @@ -0,0 +1,78 @@ +/*- + * Copyright 2021 Alexander Mikhaylenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1335 USA. + */ + +private static bool opt_replace = false; +private static bool show_version = false; + +private static GLib.MainLoop loop; + +private const GLib.OptionEntry[] ENTRIES = { + { "replace", 'r', 0, OptionArg.NONE, ref opt_replace, "Replace a running instance", null }, + { "version", 0, 0, OptionArg.NONE, ref show_version, "Show program version.", null }, + { null } +}; + +private void on_bus_acquired (GLib.DBusConnection connection, string name) { + try { + connection.register_object ("/org/freedesktop/portal/desktop", new SettingsDaemon.Settings (connection)); + } catch (GLib.Error e) { + critical ("Unable to register the object: %s", e.message); + } +} + +public int main (string[] args) { + var context = new GLib.OptionContext ("- Settings portal"); + context.add_main_entries (ENTRIES, null); + try { + context.parse (ref args); + } catch (Error e) { + printerr ("%s: %s", Environment.get_application_name (), e.message); + printerr ("\n"); + printerr ("Try \"%s --help\" for more information.", GLib.Environment.get_prgname ()); + printerr ("\n"); + return 1; + } + + if (show_version) { + print ("0.0 \n"); + return 0; + } + + loop = new GLib.MainLoop (null, false); + + try { + var session_bus = GLib.Bus.get_sync (GLib.BusType.SESSION); + var owner_id = GLib.Bus.own_name ( + GLib.BusType.SESSION, + "org.freedesktop.impl.portal.desktop.elementary.settings-daemon", + GLib.BusNameOwnerFlags.ALLOW_REPLACEMENT | (opt_replace ? GLib.BusNameOwnerFlags.REPLACE : 0), + on_bus_acquired, + () => { debug ("org.freedesktop.impl.portal.desktop.elementary.settings acquired"); }, + () => { loop.quit (); } + ); + loop.run (); + GLib.Bus.unown_name (owner_id); + } catch (Error e) { + printerr ("No session bus: %s\n", e.message); + return 2; + } + + return 0; + +} diff --git a/settings-portal/Settings.vala b/settings-portal/Settings.vala new file mode 100644 index 00000000..12fc6be4 --- /dev/null +++ b/settings-portal/Settings.vala @@ -0,0 +1,156 @@ + /*- + * Copyright 2021 Alexander Mikhaylenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1335 USA. + */ + +[DBus (name = "io.elementary.pantheon.AccountsService")] +private interface Pantheon.AccountsService : Object { + public abstract int prefers_color_scheme { owned get; set; } +} + +[DBus (name = "org.freedesktop.Accounts")] +interface FDO.Accounts : Object { + public abstract string find_user_by_name (string username) throws GLib.Error; +} + +private class AccountsServiceMonitor : GLib.Object { + private FDO.Accounts? accounts_service = null; + private Pantheon.AccountsService? pantheon_act = null; + private string user_path; + + public int32 color_scheme { get; set; } + + construct { + setup_user_path (); + setup_prefers_color_scheme (); + } + + private void setup_user_path () { + try { + accounts_service = GLib.Bus.get_proxy_sync ( + GLib.BusType.SYSTEM, + "org.freedesktop.Accounts", + "/org/freedesktop/Accounts" + ); + + user_path = accounts_service.find_user_by_name (GLib.Environment.get_user_name ()); + } catch (Error e) { + critical (e.message); + } + } + + private void setup_prefers_color_scheme () { + try { + pantheon_act = GLib.Bus.get_proxy_sync ( + GLib.BusType.SYSTEM, + "org.freedesktop.Accounts", + user_path, + GLib.DBusProxyFlags.GET_INVALIDATED_PROPERTIES + ); + + color_scheme = pantheon_act.prefers_color_scheme; + + ((GLib.DBusProxy) pantheon_act).g_properties_changed.connect ((changed, invalid) => { + var value = changed.lookup_value ("PrefersColorScheme", new VariantType ("i")); + if (value != null) { + color_scheme = value.get_int32 (); + } + }); + } catch (Error e) { + critical (e.message); + } + } +} + +[DBus (name = "org.freedesktop.impl.portal.Settings")] +public class SettingsDaemon.Settings : GLib.Object { + private GLib.DBusConnection connection; + + public uint32 version { + get { return 1; } + } + + public signal void setting_changed (string namespace, string key, GLib.Variant value); + + private AccountsServiceMonitor monitor; + + public Settings (GLib.DBusConnection connection) { + this.connection = connection; + } + + construct { + monitor = new AccountsServiceMonitor (); + monitor.notify["color-scheme"].connect (() => { + var color_scheme = new Variant.uint32 (monitor.color_scheme); + setting_changed ("org.freedesktop.appearance", "color-scheme", get_color_scheme ()); + }); + } + + private bool namespace_matches (string namespace, string[] patterns) { + foreach (var pattern in patterns) { + if (pattern[0] == '\0') { + return true; + } + + if (pattern == namespace) { + return true; + } + + int pattern_len = pattern.length; + if (pattern[pattern_len - 1] == '*' && Posix.strncmp (namespace, pattern, pattern_len - 1) == 0) { + return true; + } + } + + return patterns.length == 0; + } + + private GLib.Variant get_color_scheme () { + return new GLib.Variant.uint32 (monitor.color_scheme); + } + + public async void read_all (string[] namespaces, out GLib.Variant value) throws GLib.DBusError, GLib.IOError { + var builder = new GLib.VariantBuilder (new GLib.VariantType ("(a{sa{sv}})")); + + builder.open (new GLib.VariantType ("a{sa{sv}}")); + + if (namespace_matches ("org.freedesktop.appearance", namespaces)) { + var dict = new VariantDict (); + + dict.insert_value ("color-scheme", get_color_scheme ()); + + builder.add ("{sa{sv}}", "org.freedesktop.appearance", dict.end ()); + } + + builder.close (); + + value = builder.end (); + } + + public async void read (string namespace, string key, out GLib.Variant value) throws GLib.DBusError, GLib.Error { + debug ("Read %s %s", namespace, key); + + if (namespace == "org.freedesktop.appearance" && key == "color-scheme") { + value = get_color_scheme (); + return; + } + + debug ("Attempted to read unknown namespace/key pair: %s %s", namespace, key); + + throw XdgDesktopPortal.create_error (NOT_FOUND, "Requested setting not found"); + } +} diff --git a/settings-portal/io.elementary.settings-daemon.portal b/settings-portal/io.elementary.settings-daemon.portal new file mode 100644 index 00000000..6da980a5 --- /dev/null +++ b/settings-portal/io.elementary.settings-daemon.portal @@ -0,0 +1,4 @@ +[portal] +DBusName=org.freedesktop.impl.portal.desktop.elementary.settings-daemon +Interfaces=org.freedesktop.impl.portal.Settings +UseIn=pantheon diff --git a/settings-portal/io.elementary.settings-daemon.xdg-desktop-portal.service.in b/settings-portal/io.elementary.settings-daemon.xdg-desktop-portal.service.in new file mode 100644 index 00000000..7ff6f514 --- /dev/null +++ b/settings-portal/io.elementary.settings-daemon.xdg-desktop-portal.service.in @@ -0,0 +1,7 @@ +[Unit] +Description=Portal service (Pantheon Settings Daemon) + +[Service] +Type=dbus +BusName=org.freedesktop.impl.portal.desktop.elementary.settings-daemon +ExecStart=@libexecdir@/io.elementary.settings-daemon.xdg-desktop-portal diff --git a/settings-portal/meson.build b/settings-portal/meson.build new file mode 100644 index 00000000..619da482 --- /dev/null +++ b/settings-portal/meson.build @@ -0,0 +1,57 @@ +libexec_dir = join_paths(get_option('prefix'), get_option ('libexecdir')) + +portal_sources = files( + 'Error.vala', + 'Main.vala', + 'Settings.vala', +) + +valac = meson.get_compiler('vala') +posix_dep = valac.find_library('posix') + +executable( + 'io.elementary.settings-daemon.xdg-desktop-portal', + portal_sources, + dependencies: [ + config_dep, + glib_dep, + gio_dep, + posix_dep, + ], + install: true, + install_dir: libexec_dir, +) + +portal_conf_data = configuration_data() +portal_conf_data.set('libexecdir', libexec_dir) + +systemd_systemduserunitdir = get_option('systemduserunitdir') +if systemd_systemduserunitdir != 'no' + + if systemd_systemduserunitdir == '' + systemd_dep = dependency('systemd', version: '>= 206', required: false) + assert(systemd_dep.found(), 'systemd required but not found, please provide a valid systemd user unit dir or disable it') + systemd_systemduserunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir', define_variable: ['prefix', get_option('prefix')]) + endif + + configure_file( + input: 'io.elementary.settings-daemon.xdg-desktop-portal.service.in', + output: '@BASENAME@', + configuration: portal_conf_data, + install: true, + install_dir: systemd_systemduserunitdir + ) +endif + +install_data( + 'io.elementary.settings-daemon.portal', + install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'xdg-desktop-portal', 'portals') +) + +configure_file( + input: 'org.freedesktop.impl.portal.desktop.elementary.settings-daemon.service.in', + output: '@BASENAME@', + configuration: portal_conf_data, + install: true, + install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'dbus-1', 'services') +) diff --git a/settings-portal/org.freedesktop.impl.portal.desktop.elementary.settings-daemon.service.in b/settings-portal/org.freedesktop.impl.portal.desktop.elementary.settings-daemon.service.in new file mode 100644 index 00000000..35c978ad --- /dev/null +++ b/settings-portal/org.freedesktop.impl.portal.desktop.elementary.settings-daemon.service.in @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=org.freedesktop.impl.portal.desktop.elementary.settings-daemon +Exec=@libexecdir@/io.elementary.settings-daemon.xdg-desktop-portal +SystemdService=io.elementary.settings-daemon.xdg-desktop-portal.service diff --git a/src/meson.build b/src/meson.build index 8ced24ee..6ccdebe6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,13 +1,3 @@ -conf_data = configuration_data() -conf_data.set('PROJECT_NAME', meson.project_name()) -conf_data.set('VERSION', meson.project_version()) - -config_file = configure_file( - input: 'config.vala.in', - output: 'config.vala', - configuration: conf_data -) - sources = files( 'AccountsService.vala', 'Application.vala', @@ -21,8 +11,8 @@ sources = files( executable( meson.project_name(), sources, - config_file, dependencies: [ + config_dep, gio_dep, glib_dep, granite_dep, From a0ef5a1e2a58c591475270f77ccca31a321de3c8 Mon Sep 17 00:00:00 2001 From: Alexander Mikhaylenko Date: Mon, 20 Sep 2021 07:18:12 +0000 Subject: [PATCH 2/7] Address review --- settings-portal/Error.vala | 56 ----------------------------------- settings-portal/Settings.vala | 39 +++++++++++++----------- settings-portal/meson.build | 1 - 3 files changed, 21 insertions(+), 75 deletions(-) delete mode 100644 settings-portal/Error.vala diff --git a/settings-portal/Error.vala b/settings-portal/Error.vala deleted file mode 100644 index 115949b5..00000000 --- a/settings-portal/Error.vala +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright 2021 Alexander Mikhaylenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1335 USA. - */ - -namespace XdgDesktopPortal { - public enum Error { - FAILED, - INVALID_ARGUMENT, - NOT_FOUND, - EXISTS, - NOT_ALLOWED, - CANCELLED, - WINDOW_DESTROYED - } - - const GLib.DBusErrorEntry[] ERROR_ENTRIES = { - { Error.FAILED, "org.freedesktop.portal.Error.Failed" }, - { Error.INVALID_ARGUMENT, "org.freedesktop.portal.Error.InvalidArgument" }, - { Error.NOT_FOUND, "org.freedesktop.portal.Error.NotFound" }, - { Error.EXISTS, "org.freedesktop.portal.Error.Exists" }, - { Error.NOT_ALLOWED, "org.freedesktop.portal.Error.NotAllowed" }, - { Error.CANCELLED, "org.freedesktop.portal.Error.Cancelled" }, - { Error.WINDOW_DESTROYED, "org.freedesktop.portal.Error.WindowDestroyed" } - }; - - private size_t quark = 0; - - private GLib.Quark error_quark () { - GLib.DBusError.register_error_domain ( - "xdg-desktop-portal-error-quark", - (size_t) &quark, - ERROR_ENTRIES - ); - - return (GLib.Quark) quark; - } - - public GLib.Error create_error (Error code, string message) { - return new GLib.Error.literal (error_quark (), code, message); - } -} diff --git a/settings-portal/Settings.vala b/settings-portal/Settings.vala index 12fc6be4..f6b3c827 100644 --- a/settings-portal/Settings.vala +++ b/settings-portal/Settings.vala @@ -17,6 +17,17 @@ * Boston, MA 02110-1335 USA. */ +[DBus (name = "org.freedesktop.portal.Error")] +public errordomain PortalError { + FAILED, + INVALID_ARGUMENT, + NOT_FOUND, + EXISTS, + NOT_ALLOWED, + CANCELLED, + WINDOW_DESTROYED +} + [DBus (name = "io.elementary.pantheon.AccountsService")] private interface Pantheon.AccountsService : Object { public abstract int prefers_color_scheme { owned get; set; } @@ -95,7 +106,6 @@ public class SettingsDaemon.Settings : GLib.Object { construct { monitor = new AccountsServiceMonitor (); monitor.notify["color-scheme"].connect (() => { - var color_scheme = new Variant.uint32 (monitor.color_scheme); setting_changed ("org.freedesktop.appearance", "color-scheme", get_color_scheme ()); }); } @@ -111,7 +121,7 @@ public class SettingsDaemon.Settings : GLib.Object { } int pattern_len = pattern.length; - if (pattern[pattern_len - 1] == '*' && Posix.strncmp (namespace, pattern, pattern_len - 1) == 0) { + if (pattern[pattern_len - 1] == '*' && namespace.has_prefix (pattern.slice (0, pattern_len - 1))) { return true; } } @@ -123,34 +133,27 @@ public class SettingsDaemon.Settings : GLib.Object { return new GLib.Variant.uint32 (monitor.color_scheme); } - public async void read_all (string[] namespaces, out GLib.Variant value) throws GLib.DBusError, GLib.IOError { - var builder = new GLib.VariantBuilder (new GLib.VariantType ("(a{sa{sv}})")); - - builder.open (new GLib.VariantType ("a{sa{sv}}")); + public async GLib.HashTable> read_all (string[] namespaces) throws GLib.DBusError, GLib.IOError { + var ret = new GLib.HashTable> (str_hash, str_equal); if (namespace_matches ("org.freedesktop.appearance", namespaces)) { - var dict = new VariantDict (); + var dict = new HashTable (str_hash, str_equal); - dict.insert_value ("color-scheme", get_color_scheme ()); + dict.insert ("color-scheme", get_color_scheme ()); - builder.add ("{sa{sv}}", "org.freedesktop.appearance", dict.end ()); + ret.insert ("org.freedesktop.appearance", dict); } - builder.close (); - - value = builder.end (); + return ret; } - public async void read (string namespace, string key, out GLib.Variant value) throws GLib.DBusError, GLib.Error { - debug ("Read %s %s", namespace, key); - + public async GLib.Variant read (string namespace, string key) throws GLib.DBusError, GLib.Error { if (namespace == "org.freedesktop.appearance" && key == "color-scheme") { - value = get_color_scheme (); - return; + return get_color_scheme (); } debug ("Attempted to read unknown namespace/key pair: %s %s", namespace, key); - throw XdgDesktopPortal.create_error (NOT_FOUND, "Requested setting not found"); + throw new PortalError.NOT_FOUND ("Requested setting not found"); } } diff --git a/settings-portal/meson.build b/settings-portal/meson.build index 619da482..facfefa6 100644 --- a/settings-portal/meson.build +++ b/settings-portal/meson.build @@ -1,7 +1,6 @@ libexec_dir = join_paths(get_option('prefix'), get_option ('libexecdir')) portal_sources = files( - 'Error.vala', 'Main.vala', 'Settings.vala', ) From 94a4e42597375ae9ccb59c59221232d5c4d28679 Mon Sep 17 00:00:00 2001 From: Alexander Mikhaylenko Date: Wed, 22 Sep 2021 10:03:19 +0000 Subject: [PATCH 3/7] Address review --- settings-portal/Main.vala | 6 ++++-- settings-portal/Settings.vala | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/settings-portal/Main.vala b/settings-portal/Main.vala index 57d5518f..130b3975 100644 --- a/settings-portal/Main.vala +++ b/settings-portal/Main.vala @@ -1,5 +1,5 @@ /*- - * Copyright 2021 Alexander Mikhaylenko + * Copyright 2020 elementary LLC * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -15,6 +15,8 @@ * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor * Boston, MA 02110-1335 USA. + * + * Authored by: Corentin Noël */ private static bool opt_replace = false; @@ -30,7 +32,7 @@ private const GLib.OptionEntry[] ENTRIES = { private void on_bus_acquired (GLib.DBusConnection connection, string name) { try { - connection.register_object ("/org/freedesktop/portal/desktop", new SettingsDaemon.Settings (connection)); + connection.register_object ("/org/freedesktop/portal/desktop", new SettingsDaemon.Settings ()); } catch (GLib.Error e) { critical ("Unable to register the object: %s", e.message); } diff --git a/settings-portal/Settings.vala b/settings-portal/Settings.vala index f6b3c827..52e39f6e 100644 --- a/settings-portal/Settings.vala +++ b/settings-portal/Settings.vala @@ -1,4 +1,5 @@ - /*- +/*- + * Copyright 2021 elementary, Inc. (https://elementary.io) * Copyright 2021 Alexander Mikhaylenko * * This library is free software; you can redistribute it and/or @@ -38,6 +39,7 @@ interface FDO.Accounts : Object { public abstract string find_user_by_name (string username) throws GLib.Error; } +/* Copied from Granite.Settings */ private class AccountsServiceMonitor : GLib.Object { private FDO.Accounts? accounts_service = null; private Pantheon.AccountsService? pantheon_act = null; @@ -89,8 +91,6 @@ private class AccountsServiceMonitor : GLib.Object { [DBus (name = "org.freedesktop.impl.portal.Settings")] public class SettingsDaemon.Settings : GLib.Object { - private GLib.DBusConnection connection; - public uint32 version { get { return 1; } } From 7bbf77e7137d005b43fd1d974a6ef321542cf189 Mon Sep 17 00:00:00 2001 From: Alexander Mikhaylenko Date: Wed, 22 Sep 2021 10:05:57 +0000 Subject: [PATCH 4/7] Commit what hadn't been committed. --- settings-portal/Settings.vala | 4 ---- 1 file changed, 4 deletions(-) diff --git a/settings-portal/Settings.vala b/settings-portal/Settings.vala index 52e39f6e..8a5cbf69 100644 --- a/settings-portal/Settings.vala +++ b/settings-portal/Settings.vala @@ -99,10 +99,6 @@ public class SettingsDaemon.Settings : GLib.Object { private AccountsServiceMonitor monitor; - public Settings (GLib.DBusConnection connection) { - this.connection = connection; - } - construct { monitor = new AccountsServiceMonitor (); monitor.notify["color-scheme"].connect (() => { From 8c75e0e3c6d9f0888d8d8d562297a4cdd99289ba Mon Sep 17 00:00:00 2001 From: Alexander Mikhaylenko Date: Thu, 30 Sep 2021 09:36:33 +0000 Subject: [PATCH 5/7] Remove the leftover posix dep --- settings-portal/meson.build | 4 ---- 1 file changed, 4 deletions(-) diff --git a/settings-portal/meson.build b/settings-portal/meson.build index facfefa6..93ea855c 100644 --- a/settings-portal/meson.build +++ b/settings-portal/meson.build @@ -5,9 +5,6 @@ portal_sources = files( 'Settings.vala', ) -valac = meson.get_compiler('vala') -posix_dep = valac.find_library('posix') - executable( 'io.elementary.settings-daemon.xdg-desktop-portal', portal_sources, @@ -15,7 +12,6 @@ executable( config_dep, glib_dep, gio_dep, - posix_dep, ], install: true, install_dir: libexec_dir, From 1ecc562e6579d70d5986f68b7cb71097133644ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 6 Oct 2021 11:04:29 -0700 Subject: [PATCH 6/7] Update Main.vala --- settings-portal/Main.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings-portal/Main.vala b/settings-portal/Main.vala index 130b3975..b9160522 100644 --- a/settings-portal/Main.vala +++ b/settings-portal/Main.vala @@ -1,5 +1,5 @@ /*- - * Copyright 2020 elementary LLC + * Copyright 2021 elementary, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public From 2cdbd52d7504bd255ac5f7e567ac70c7d1b7c3c3 Mon Sep 17 00:00:00 2001 From: Alexander Mikhaylenko Date: Wed, 6 Oct 2021 19:58:05 +0000 Subject: [PATCH 7/7] Fix version --- settings-portal/Main.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings-portal/Main.vala b/settings-portal/Main.vala index b9160522..cd440768 100644 --- a/settings-portal/Main.vala +++ b/settings-portal/Main.vala @@ -52,7 +52,7 @@ public int main (string[] args) { } if (show_version) { - print ("0.0 \n"); + print ("%s \n", Build.VERSION); return 0; }