Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public sealed class SettingsDaemon.Application : Gtk.Application {
protected override bool dbus_register (DBusConnection connection, string object_path) throws Error {
base.dbus_register (connection, object_path);

if (!SettingsDaemon.Utils.is_sysupdate ()) {
connection.register_object (object_path, new Backends.SystemUpdate ());
connection.register_object (object_path, new Backends.SystemUpdate ());

if (!SettingsDaemon.Utils.is_sysupdate ()) {
#if UBUNTU_DRIVERS
connection.register_object (object_path, new Backends.UbuntuDrivers ());
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@
* Authored by: Leonhard Kargl <leo.kargl@proton.me>
*/

[DBus (name="io.elementary.settings_daemon.SystemUpdate")]
public class SettingsDaemon.Backends.SystemUpdate : Object {
public struct UpdateDetails {
string[] packages;
uint64 size;
Pk.Info[] info;
}

public class SettingsDaemon.Backends.PackageKit : Object, SystemUpdateProvider {
private const string NOTIFICATION_ID = "system-update";

public signal void state_changed ();

private static Settings settings = new GLib.Settings ("io.elementary.settings-daemon.system-update");

private PkUtils.CurrentState current_state;
Expand Down
70 changes: 70 additions & 0 deletions src/Backends/SystemUpdate/SystemUpdate.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright 2023 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Authored by: Leonhard Kargl <leo.kargl@proton.me>
*/

[DBus (name="io.elementary.settings_daemon.SystemUpdate")]
public class SettingsDaemon.Backends.SystemUpdate : Object {
public signal void state_changed ();

private SystemUpdateProvider? provider;

construct {
if (SettingsDaemon.Utils.is_sysupdate ()) {
return;
}

provider = new PackageKit ();
provider.state_changed.connect (() => state_changed ());
}

public async void check_for_updates (bool force, bool notify) throws DBusError, IOError {
if (provider == null) {
throw new IOError.NOT_SUPPORTED ("No system update provider available");
}

yield provider.check_for_updates (force, notify);
}

public async void update () throws DBusError, IOError {
if (provider == null) {
throw new IOError.NOT_SUPPORTED ("No system update provider available");
}

yield provider.update ();
}

public void cancel () throws DBusError, IOError {
if (provider == null) {
throw new IOError.NOT_SUPPORTED ("No system update provider available");
}

provider.cancel ();
}

public async PkUtils.CurrentState get_current_state () throws DBusError, IOError {
if (provider == null) {
throw new IOError.NOT_SUPPORTED ("No system update provider available");
}

return yield provider.get_current_state ();
}

public async SystemUpdateProvider.UpdateDetails get_update_details () throws DBusError, IOError {
if (provider == null) {
throw new IOError.NOT_SUPPORTED ("No system update provider available");
}

return yield provider.get_update_details ();
}

public async int64 get_last_refresh_time () throws DBusError, IOError {
if (provider == null) {
throw new IOError.NOT_SUPPORTED ("No system update provider available");
}

return yield provider.get_last_refresh_time ();
}
}
23 changes: 23 additions & 0 deletions src/Backends/SystemUpdate/SystemUpdateProvider.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2023 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Authored by: Leonhard Kargl <leo.kargl@proton.me>
*/

public interface SettingsDaemon.Backends.SystemUpdateProvider : Object {
public struct UpdateDetails {
string[] packages;
uint64 size;
Pk.Info[] info;
}

public signal void state_changed ();

public abstract async void check_for_updates (bool force, bool notify) throws DBusError, IOError;
public abstract async void update () throws DBusError, IOError;
public abstract void cancel () throws DBusError, IOError;
public abstract async PkUtils.CurrentState get_current_state () throws DBusError, IOError;
public abstract async UpdateDetails get_update_details () throws DBusError, IOError;
public abstract async int64 get_last_refresh_time () throws DBusError, IOError;
}
4 changes: 3 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ sources = files(
'Backends/NightLightSettings.vala',
'Backends/PowerProfilesSync.vala',
'Backends/PrefersColorSchemeSettings.vala',
'Backends/SystemUpdate.vala',
'Backends/SystemUpdate/PackageKit.vala',
'Backends/SystemUpdate/SystemUpdate.vala',
'Backends/SystemUpdate/SystemUpdateProvider.vala',
'DBus/DesktopIntegration.vala',
'DBus/ShellKeyGrabber.vala',
'Utils/PkUtils.vala',
Expand Down
Loading