Skip to content

Commit

Permalink
dnfdaemon: D-Bus API to reset the goal
Browse files Browse the repository at this point in the history
With this patch the user can re-use the session to resolve multiple
transactions without running them. The use case might be to check what
dependencies would be installed with given package.
  • Loading branch information
m-blaha committed Sep 6, 2024
1 parent a4b11b5 commit 3cd0a6e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dnf5daemon-server/dbus/interfaces/org.rpm.dnf.v0.Goal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.
<arg name="error_msg" type="s" />
</method>

<!--
reset:
Reset the prepared rpm transaction. After this call the session is ready to perform another rpm transaction.
-->
<method name="reset">
</method>

</interface>

</node>
10 changes: 10 additions & 0 deletions dnf5daemon-server/services/goal/goal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ void Goal::dbus_register() {
[this](sdbus::MethodCall call) -> void {
session.get_threads_manager().handle_method(*this, &Goal::cancel, call, session.session_locale);
});
dbus_object->registerMethod(
dnfdaemon::INTERFACE_GOAL, "reset", "", {}, "", {}, [this](sdbus::MethodCall call) -> void {
session.get_threads_manager().handle_method(*this, &Goal::reset, call, session.session_locale);
});
}

sdbus::MethodReply Goal::resolve(sdbus::MethodCall & call) {
Expand Down Expand Up @@ -349,3 +353,9 @@ sdbus::MethodReply Goal::cancel(sdbus::MethodCall & call) {
reply << error_msg;
return reply;
}

sdbus::MethodReply Goal::reset(sdbus::MethodCall & call) {
session.reset_goal();
auto reply = call.createReply();
return reply;
}
1 change: 1 addition & 0 deletions dnf5daemon-server/services/goal/goal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Goal : public IDbusSessionService {
sdbus::MethodReply get_transaction_problems(sdbus::MethodCall & call);
sdbus::MethodReply do_transaction(sdbus::MethodCall & call);
sdbus::MethodReply cancel(sdbus::MethodCall & call);
sdbus::MethodReply reset(sdbus::MethodCall & call);
};

#endif

0 comments on commit 3cd0a6e

Please sign in to comment.