diff --git a/dnf5daemon-client/wrappers/dbus_goal_wrapper.cpp b/dnf5daemon-client/wrappers/dbus_goal_wrapper.cpp index cc3377e02..044c13ac0 100644 --- a/dnf5daemon-client/wrappers/dbus_goal_wrapper.cpp +++ b/dnf5daemon-client/wrappers/dbus_goal_wrapper.cpp @@ -31,17 +31,24 @@ DbusGoalWrapper::DbusGoalWrapper(std::vector tra std::map transaction_packages_by_id; for (const auto & ti : transaction) { - auto object_type = libdnf5::transaction::transaction_item_type_from_string(std::get<0>(ti)); - if (object_type == libdnf5::transaction::TransactionItemType::PACKAGE) { + auto object_type = std::get<0>(ti); + if (object_type == "Package") { transaction_packages.push_back(DbusTransactionPackageWrapper(ti)); transaction_packages_by_id.emplace( transaction_packages.back().get_package().get_id(), transaction_packages.size() - 1); - } else if (object_type == libdnf5::transaction::TransactionItemType::GROUP) { + } else if (object_type == "Group") { transaction_groups.push_back(DbusTransactionGroupWrapper(ti)); - } else if (object_type == libdnf5::transaction::TransactionItemType::ENVIRONMENT) { + } else if (object_type == "Environment") { transaction_environments.push_back(DbusTransactionEnvironmentWrapper(ti)); - } else if (object_type == libdnf5::transaction::TransactionItemType::MODULE) { + } else if (object_type == "Module") { transaction_modules.push_back(DbusTransactionModuleWrapper(ti)); + } else if (object_type == "Skipped") { + auto trans_item_attrs = std::get<3>(ti); + if (key_value_map_get(trans_item_attrs, "reason_skipped", "conflict") == "conflict") { + conflicting_packages.emplace_back(std::get<4>(ti)); + } else { + broken_dependency_packages.emplace_back(std::get<4>(ti)); + } } } // set "replaces" for transaction_packages. Since transaction_package contains only diff --git a/dnf5daemon-client/wrappers/dbus_goal_wrapper.hpp b/dnf5daemon-client/wrappers/dbus_goal_wrapper.hpp index 9f327ee35..569957e81 100644 --- a/dnf5daemon-client/wrappers/dbus_goal_wrapper.hpp +++ b/dnf5daemon-client/wrappers/dbus_goal_wrapper.hpp @@ -47,11 +47,16 @@ class DbusGoalWrapper { std::vector get_resolve_logs_as_strings() const { return resolve_logs; } void set_resolve_logs(std::vector logs) { resolve_logs = logs; } + std::vector get_conflicting_packages() const { return conflicting_packages; } + std::vector get_broken_dependency_packages() const { return broken_dependency_packages; } + private: std::vector transaction_packages; std::vector transaction_groups; std::vector transaction_environments; std::vector transaction_modules; + std::vector conflicting_packages; + std::vector broken_dependency_packages; std::vector resolve_logs; }; diff --git a/dnf5daemon-server/dbus.hpp b/dnf5daemon-server/dbus.hpp index 1bc223a2b..3c8981423 100644 --- a/dnf5daemon-server/dbus.hpp +++ b/dnf5daemon-server/dbus.hpp @@ -33,8 +33,10 @@ using KeyValueMapList = std::vector; enum class RepoStatus { NOT_READY, PENDING, READY, ERROR }; enum class ResolveResult { NO_PROBLEM, WARNING, ERROR }; +enum class DbusTransactionItemType : int { PACKAGE, GROUP, ENVIRONMENT, MODULE, SKIPPED }; + using DbusTransactionItem = sdbus::Struct< - std::string, // libdnf5::transaction::TransactionItemType + std::string, // DbusTransactionItemType std::string, // libdnf5::transaction::TransactionItemAction std::string, // libdnf5::transaction::TransactionItemReason KeyValueMap, // other transaction item attributes - e.g. group id for REASON_CHANGE to GROUP, diff --git a/dnf5daemon-server/services/goal/goal.cpp b/dnf5daemon-server/services/goal/goal.cpp index 193178dd6..6c1b11bb1 100644 --- a/dnf5daemon-server/services/goal/goal.cpp +++ b/dnf5daemon-server/services/goal/goal.cpp @@ -43,6 +43,22 @@ along with libdnf. If not, see . } \ }) +static std::string dbus_transaction_item_type_to_string(dnfdaemon::DbusTransactionItemType type) { + switch (type) { + case dnfdaemon::DbusTransactionItemType::PACKAGE: + return "Package"; + case dnfdaemon::DbusTransactionItemType::GROUP: + return "Group"; + case dnfdaemon::DbusTransactionItemType::ENVIRONMENT: + return "Environment"; + case dnfdaemon::DbusTransactionItemType::MODULE: + return "Module"; + case dnfdaemon::DbusTransactionItemType::SKIPPED: + return "Skipped"; + } + return ""; +} + void Goal::dbus_register() { auto dbus_object = session.get_dbus_object(); // TODO(mblaha) Adjust resolve method to accommodate also groups, environments, @@ -119,7 +135,8 @@ sdbus::MethodReply Goal::resolve(sdbus::MethodCall & call) { "download_size", "install_size", "evr", - "reason"}; + "reason", + "full_nevra"}; for (auto & tspkg : transaction.get_transaction_packages()) { dnfdaemon::KeyValueMap trans_item_attrs{}; if (tspkg.get_reason_change_group_id()) { @@ -134,7 +151,7 @@ sdbus::MethodReply Goal::resolve(sdbus::MethodCall & call) { trans_item_attrs.emplace("replaces", replaces_ids); } dbus_transaction.push_back(dnfdaemon::DbusTransactionItem( - transaction_item_type_to_string(libdnf5::transaction::TransactionItemType::PACKAGE), + dbus_transaction_item_type_to_string(dnfdaemon::DbusTransactionItemType::PACKAGE), transaction_item_action_to_string(tspkg.get_action()), transaction_item_reason_to_string(tspkg.get_reason()), trans_item_attrs, @@ -144,7 +161,7 @@ sdbus::MethodReply Goal::resolve(sdbus::MethodCall & call) { dnfdaemon::KeyValueMap trans_item_attrs{}; for (auto & tsgrp : transaction.get_transaction_groups()) { dbus_transaction.push_back(dnfdaemon::DbusTransactionItem( - transaction_item_type_to_string(libdnf5::transaction::TransactionItemType::GROUP), + dbus_transaction_item_type_to_string(dnfdaemon::DbusTransactionItemType::GROUP), transaction_item_action_to_string(tsgrp.get_action()), transaction_item_reason_to_string(tsgrp.get_reason()), trans_item_attrs, @@ -152,7 +169,7 @@ sdbus::MethodReply Goal::resolve(sdbus::MethodCall & call) { } for (auto & tsenv : transaction.get_transaction_environments()) { dbus_transaction.push_back(dnfdaemon::DbusTransactionItem( - transaction_item_type_to_string(libdnf5::transaction::TransactionItemType::ENVIRONMENT), + dbus_transaction_item_type_to_string(dnfdaemon::DbusTransactionItemType::ENVIRONMENT), transaction_item_action_to_string(tsenv.get_action()), transaction_item_reason_to_string(tsenv.get_reason()), trans_item_attrs, @@ -165,6 +182,26 @@ sdbus::MethodReply Goal::resolve(sdbus::MethodCall & call) { } else { overall_result = dnfdaemon::ResolveResult::NO_PROBLEM; } + for (const auto & pkg : transaction.get_conflicting_packages()) { + dnfdaemon::KeyValueMap trans_item_attrs{}; + trans_item_attrs.emplace("reason_skipped", "conflict"); + dbus_transaction.emplace_back( + dbus_transaction_item_type_to_string(dnfdaemon::DbusTransactionItemType::SKIPPED), + "", + "", + trans_item_attrs, + package_to_map(pkg, pkg_attrs)); + } + for (const auto & pkg : transaction.get_broken_dependency_packages()) { + dnfdaemon::KeyValueMap trans_item_attrs{}; + trans_item_attrs.emplace("reason_skipped", "broken_dependency"); + dbus_transaction.emplace_back( + dbus_transaction_item_type_to_string(dnfdaemon::DbusTransactionItemType::SKIPPED), + "", + "", + trans_item_attrs, + package_to_map(pkg, pkg_attrs)); + } } auto reply = call.createReply();