Skip to content

Commit

Permalink
Drivers v2 (with support for device grouping) (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 authored May 30, 2024
1 parent 9886ae5 commit 9fcaf5c
Show file tree
Hide file tree
Showing 6 changed files with 402 additions and 95 deletions.
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
option('busctlpath', type: 'string', value: '', description: 'custom path to busctl executable')
option('ubuntu_drivers', type: 'boolean', value: 'true', description: 'whether to enable ubuntu drivers integration')
option('systemdsystemunitdir', type: 'string', value: '', description: 'custom directory for systemd system units, or \'no\' to disable')
option('systemduserunitdir', type: 'string', value: '', description: 'custom directory for systemd user units, or \'no\' to disable')
4 changes: 4 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public sealed class SettingsDaemon.Application : Gtk.Application {

connection.register_object (object_path, new Backends.SystemUpdate ());

#if UBUNTU_DRIVERS
connection.register_object (object_path, new Backends.UbuntuDrivers ());
#endif

return true;
}

Expand Down
99 changes: 4 additions & 95 deletions src/Backends/SystemUpdate.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@

[DBus (name="io.elementary.settings_daemon.SystemUpdate")]
public class SettingsDaemon.Backends.SystemUpdate : Object {
public enum State {
UP_TO_DATE,
CHECKING,
AVAILABLE,
DOWNLOADING,
RESTART_REQUIRED,
ERROR
}

public struct CurrentState {
State state;
string status;
}

public struct UpdateDetails {
string[] packages;
int size;
Expand All @@ -33,7 +19,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {

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

private CurrentState current_state;
private PkUtils.CurrentState current_state;
private UpdateDetails update_details;

private Pk.Task task;
Expand Down Expand Up @@ -187,7 +173,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {
}

private void progress_callback (Pk.Progress progress, Pk.ProgressType progress_type) {
update_state (current_state.state, status_to_title (progress.status));
update_state (current_state.state, PkUtils.status_to_title (progress.status));
}

private void send_error (string message) {
Expand All @@ -201,7 +187,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {
update_state (ERROR, message);
}

private void update_state (State state, string message = "") {
private void update_state (PkUtils.State state, string message = "") {
current_state = {
state,
message
Expand All @@ -210,84 +196,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {
state_changed ();
}

private unowned string status_to_title (Pk.Status status) {
// From https://github.com/elementary/appcenter/blob/master/src/Core/ChangeInformation.vala#L51
switch (status) {
case Pk.Status.SETUP:
return _("Starting");
case Pk.Status.WAIT:
return _("Waiting");
case Pk.Status.RUNNING:
return _("Running");
case Pk.Status.QUERY:
return _("Querying");
case Pk.Status.INFO:
return _("Getting information");
case Pk.Status.REMOVE:
return _("Removing packages");
case Pk.Status.DOWNLOAD:
return _("Downloading");
case Pk.Status.REFRESH_CACHE:
return _("Refreshing software list");
case Pk.Status.UPDATE:
return _("Installing updates");
case Pk.Status.CLEANUP:
return _("Cleaning up packages");
case Pk.Status.OBSOLETE:
return _("Obsoleting packages");
case Pk.Status.DEP_RESOLVE:
return _("Resolving dependencies");
case Pk.Status.SIG_CHECK:
return _("Checking signatures");
case Pk.Status.TEST_COMMIT:
return _("Testing changes");
case Pk.Status.COMMIT:
return _("Committing changes");
case Pk.Status.REQUEST:
return _("Requesting data");
case Pk.Status.FINISHED:
return _("Finished");
case Pk.Status.CANCEL:
return _("Cancelling");
case Pk.Status.DOWNLOAD_REPOSITORY:
return _("Downloading repository information");
case Pk.Status.DOWNLOAD_PACKAGELIST:
return _("Downloading list of packages");
case Pk.Status.DOWNLOAD_FILELIST:
return _("Downloading file lists");
case Pk.Status.DOWNLOAD_CHANGELOG:
return _("Downloading lists of changes");
case Pk.Status.DOWNLOAD_GROUP:
return _("Downloading groups");
case Pk.Status.DOWNLOAD_UPDATEINFO:
return _("Downloading update information");
case Pk.Status.REPACKAGING:
return _("Repackaging files");
case Pk.Status.LOADING_CACHE:
return _("Loading cache");
case Pk.Status.SCAN_APPLICATIONS:
return _("Scanning applications");
case Pk.Status.GENERATE_PACKAGE_LIST:
return _("Generating package lists");
case Pk.Status.WAITING_FOR_LOCK:
return _("Waiting for package manager lock");
case Pk.Status.WAITING_FOR_AUTH:
return _("Waiting for authentication");
case Pk.Status.SCAN_PROCESS_LIST:
return _("Updating running applications");
case Pk.Status.CHECK_EXECUTABLE_FILES:
return _("Checking applications in use");
case Pk.Status.CHECK_LIBRARIES:
return _("Checking libraries in use");
case Pk.Status.COPY_FILES:
return _("Copying files");
case Pk.Status.INSTALL:
default:
return _("Installing");
}
}

public async CurrentState get_current_state () throws DBusError, IOError {
public async PkUtils.CurrentState get_current_state () throws DBusError, IOError {
return current_state;
}

Expand Down
Loading

0 comments on commit 9fcaf5c

Please sign in to comment.