diff --git a/include/libdnf5/module/module_item.hpp b/include/libdnf5/module/module_item.hpp index 035608aa5c..61dc86eec9 100644 --- a/include/libdnf5/module/module_item.hpp +++ b/include/libdnf5/module/module_item.hpp @@ -35,6 +35,9 @@ class ModuleTest; namespace libdnf5::module { +enum class ModuleStatus; + + struct ModuleItemId { public: ModuleItemId() = default; @@ -167,6 +170,10 @@ class ModuleItem { // TODO(jmracek) Read a real decision from the modular solver bool is_active() const; + /// @return The status of this ModuleItem. + /// @since 5.1.5 + ModuleStatus get_status() const; + ModuleItem(const ModuleItem & mpkg); ModuleItem & operator=(const ModuleItem & mpkg); ModuleItem(ModuleItem && mpkg); diff --git a/libdnf5/module/module_item.cpp b/libdnf5/module/module_item.cpp index bc93707997..d7877e8727 100644 --- a/libdnf5/module/module_item.cpp +++ b/libdnf5/module/module_item.cpp @@ -444,4 +444,14 @@ bool ModuleItem::is_active() const { } +ModuleStatus ModuleItem::get_status() const { + const ModuleStatus & module_status = module_sack->p_impl->module_db->get_status(get_name()); + if (module_status == ModuleStatus::ENABLED && + get_stream() != module_sack->p_impl->module_db->get_enabled_stream(get_name())) { + return ModuleStatus::AVAILABLE; + } + return module_status; +} + + } // namespace libdnf5::module