Skip to content

Commit

Permalink
dnf5daemon: Signals to wrap rpm transaction execution
Browse files Browse the repository at this point in the history
Use the new callbacks before_begin / after_complete to signal clients
about overall transaction progress.
  • Loading branch information
m-blaha committed Feb 16, 2024
1 parent 0a1e51a commit 7b6dc20
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions dnf5daemon-server/callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ sdbus::Signal DbusTransactionCB::create_signal_pkg(
}


void DbusTransactionCB::before_begin(uint64_t total) {
try {
auto signal = create_signal(dnfdaemon::INTERFACE_RPM, dnfdaemon::SIGNAL_TRANSACTION_BEFORE_BEGIN);
signal << total;
dbus_object->emitSignal(signal);
} catch (...) {
}
}

void DbusTransactionCB::after_complete(bool success) {
try {
auto signal = create_signal(dnfdaemon::INTERFACE_RPM, dnfdaemon::SIGNAL_TRANSACTION_AFTER_COMPLETE);
signal << success;
dbus_object->emitSignal(signal);
} catch (...) {
}
}

void DbusTransactionCB::install_start(const libdnf5::rpm::TransactionItem & item, uint64_t total) {
try {
dnfdaemon::RpmTransactionItemActions action;
Expand Down
4 changes: 4 additions & 0 deletions dnf5daemon-server/callbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ class DbusTransactionCB : public libdnf5::rpm::TransactionCallbacks, public Dbus
explicit DbusTransactionCB(Session & session) : DbusCallback(session) {}
virtual ~DbusTransactionCB() = default;

// overall transaction progress
void before_begin(uint64_t total) override;
void after_complete(bool success) override;

// transaction preparation
void transaction_start(uint64_t total) override;
void transaction_progress(uint64_t amount, uint64_t total) override;
Expand Down
2 changes: 2 additions & 0 deletions dnf5daemon-server/dbus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const char * const SIGNAL_DOWNLOAD_MIRROR_FAILURE = "download_mirror_failure";

const char * const SIGNAL_REPO_KEY_IMPORT_REQUEST = "repo_key_import_request";

const char * const SIGNAL_TRANSACTION_BEFORE_BEGIN = "transaction_before_begin";
const char * const SIGNAL_TRANSACTION_AFTER_COMPLETE = "transaction_after_complete";
const char * const SIGNAL_TRANSACTION_TRANSACTION_START = "transaction_transaction_start";
const char * const SIGNAL_TRANSACTION_TRANSACTION_PROGRESS = "transaction_transaction_progress";
const char * const SIGNAL_TRANSACTION_TRANSACTION_STOP = "transaction_transaction_stop";
Expand Down

0 comments on commit 7b6dc20

Please sign in to comment.