diff --git a/daemon/CommonBackend.vala b/daemon/CommonBackend.vala new file mode 100644 index 000000000..6314867dc --- /dev/null +++ b/daemon/CommonBackend.vala @@ -0,0 +1,22 @@ +/* + * Copyright 2021-2026 elementary, Inc. (https://elementary.io) + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +[DBus (name = "io.elementary.InstallerDaemon")] +public class InstallerDaemon.CommonBackend : GLib.Object { + public void set_demo_mode_locale (string locale) throws GLib.Error { + GLib.FileUtils.set_contents ("/etc/default/locale", "LANG=" + locale); + } + + public void trigger_demo_mode () throws GLib.Error { + var demo_mode_file = GLib.File.new_for_path ("/var/lib/lightdm/demo-mode"); + try { + demo_mode_file.create (GLib.FileCreateFlags.NONE); + } catch (GLib.Error e) { + if (!(e is GLib.IOError.EXISTS)) { + throw e; + } + } + } +} diff --git a/daemon/Daemon.vala b/daemon/Daemon.vala index 040373011..ed60df90f 100644 --- a/daemon/Daemon.vala +++ b/daemon/Daemon.vala @@ -15,6 +15,7 @@ public class InstallerDaemon.Application : GLib.Application { base.dbus_register (connection, object_path); try { + connection.register_object ("/io/elementary/InstallerDaemon", new InstallerDaemon.CommonBackend ()); #if DISTINST_BACKEND connection.register_object ("/io/elementary/InstallerDaemon", new InstallerDaemon.DistinstBackend ()); #endif diff --git a/daemon/DistinstBackend.vala b/daemon/DistinstBackend.vala index 31837378e..4b90c8589 100644 --- a/daemon/DistinstBackend.vala +++ b/daemon/DistinstBackend.vala @@ -219,21 +219,6 @@ public class InstallerDaemon.DistinstBackend : GLib.Object { }); } - public void set_demo_mode_locale (string locale) throws GLib.Error { - GLib.FileUtils.set_contents ("/etc/default/locale", "LANG=" + locale); - } - - public void trigger_demo_mode () throws GLib.Error { - var demo_mode_file = GLib.File.new_for_path ("/var/lib/lightdm/demo-mode"); - try { - demo_mode_file.create (GLib.FileCreateFlags.NONE); - } catch (GLib.Error e) { - if (!(e is GLib.IOError.EXISTS)) { - throw e; - } - } - } - private string casper_dir () { const string CDROM = "/cdrom"; diff --git a/daemon/meson.build b/daemon/meson.build index f4a07ee25..26ca3e69d 100644 --- a/daemon/meson.build +++ b/daemon/meson.build @@ -1,4 +1,5 @@ vala_files = [ + 'CommonBackend.vala', 'Daemon.vala', common_files ]