-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dnf5daemon: Fix goal.resolve() return value
To correctly present resolved transaction to the user we need to change the structure of transaction item returned from goal.resolve(). The new transaction item structure consists of: - string object_type. This allows the client to correctly interpret data stored in transaction object map. Value is one of libdnf::transaction::TransactionItemType enum. - string action. One of libdnf::transaction::TransactionItemAction - string reason. One of libdnf::transaction::TransactionItemReason enum - {string:variant} map with other transaction item attributes. Currently used for group id in case of REASON_CHANGE action and GROUP reason. - {string:variant} map with object - package / group / environment / module, according to object_type. All enum values are passed as string using corresponding libdnf::transaction::*_to_string() methods. Server and client can use different versions of libdnf with potentially different enum definitions. Using strings makes communication more reliable.
- Loading branch information
Showing
8 changed files
with
144 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
Copyright Contributors to the libdnf project. | ||
This file is part of libdnf: https://github.com/rpm-software-management/libdnf/ | ||
Libdnf is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
Libdnf is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with libdnf. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "group.hpp" | ||
|
||
#include <fmt/format.h> | ||
|
||
#include <map> | ||
|
||
|
||
// map string group attribute name to actual attribute | ||
const std::map<std::string, GroupAttribute> group_attributes{ | ||
{"groupid", GroupAttribute::groupid}, {"name", GroupAttribute::name}, {"description", GroupAttribute::description}}; | ||
|
||
|
||
dnfdaemon::KeyValueMap group_to_map( | ||
const libdnf::comps::Group & libdnf_group, const std::vector<std::string> & attributes) { | ||
dnfdaemon::KeyValueMap dbus_group; | ||
// add group id by default | ||
dbus_group.emplace(std::make_pair("groupid", libdnf_group.get_groupid())); | ||
// attributes required by client | ||
for (auto & attr : attributes) { | ||
auto it = group_attributes.find(attr); | ||
if (it == group_attributes.end()) { | ||
throw std::runtime_error(fmt::format("Group attribute '{}' not supported", attr)); | ||
} | ||
switch (it->second) { | ||
case GroupAttribute::groupid: | ||
// already added by default | ||
break; | ||
case GroupAttribute::name: | ||
dbus_group.emplace(attr, libdnf_group.get_name()); | ||
break; | ||
case GroupAttribute::description: | ||
dbus_group.emplace(attr, libdnf_group.get_description()); | ||
break; | ||
} | ||
} | ||
return dbus_group; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
Copyright Contributors to the libdnf project. | ||
This file is part of libdnf: https://github.com/rpm-software-management/libdnf/ | ||
Libdnf is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
Libdnf is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with libdnf. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DNF5DAEMON_SERVER_GROUP_HPP | ||
#define DNF5DAEMON_SERVER_GROUP_HPP | ||
|
||
#include "dbus.hpp" | ||
|
||
#include <libdnf/comps/group/group.hpp> | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
// group attributes available to be retrieved | ||
enum class GroupAttribute { | ||
groupid, | ||
name, | ||
description | ||
// TODO(mblaha): translated_name, translated_description, packages, reason | ||
}; | ||
|
||
dnfdaemon::KeyValueMap group_to_map( | ||
const libdnf::comps::Group & libdnf_group, const std::vector<std::string> & attributes); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters