Skip to content

Commit

Permalink
Merge pull request xbmc#23602 from howie-f/v21-deprecated-iscompatible
Browse files Browse the repository at this point in the history
[cleanup] change deprecated 'CAddonMgr::IsCompatible(const IAddon& ad…
  • Loading branch information
howie-f authored Aug 20, 2023
2 parents 7db7157 + 44e72a4 commit cb02c86
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
14 changes: 7 additions & 7 deletions xbmc/addons/AddonManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ bool CAddonMgr::EnableSingle(const std::string& id)

auto eventLog = CServiceBroker::GetEventLog();

if (!IsCompatible(*addon))
if (!IsCompatible(addon))
{
CLog::Log(LOGERROR, "Add-on '{}' is not compatible with Kodi", addon->ID());
if (eventLog)
Expand Down Expand Up @@ -1111,9 +1111,9 @@ void CAddonMgr::PublishInstanceRemoved(const std::string& addonId, AddonInstance
m_events.Publish(AddonEvents::InstanceRemoved(addonId, instanceId));
}

bool CAddonMgr::IsCompatible(const IAddon& addon) const
bool CAddonMgr::IsCompatible(const std::shared_ptr<const IAddon>& addon) const
{
for (const auto& dependency : addon.GetDependencies())
for (const auto& dependency : addon->GetDependencies())
{
if (!dependency.optional)
{
Expand All @@ -1122,10 +1122,10 @@ bool CAddonMgr::IsCompatible(const IAddon& addon) const
if (StringUtils::StartsWith(dependency.id, "xbmc.") ||
StringUtils::StartsWith(dependency.id, "kodi."))
{
AddonPtr addon;
bool haveAddon =
GetAddon(dependency.id, addon, AddonType::UNKNOWN, OnlyEnabled::CHOICE_YES);
if (!haveAddon || !addon->MeetsVersion(dependency.versionMin, dependency.version))
std::shared_ptr<IAddon> dep;
const bool haveDependency =
GetAddon(dependency.id, dep, AddonType::UNKNOWN, OnlyEnabled::CHOICE_YES);
if (!haveDependency || !dep->MeetsVersion(dependency.versionMin, dependency.version))
return false;
}
}
Expand Down
8 changes: 5 additions & 3 deletions xbmc/addons/AddonManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,12 @@ class CAddonMgr
bool ServicesHasStarted() const;

/*!
* @deprecated This addon function should no more used and becomes replaced
* in future with the other below by his callers.
* @brief Check if given addon is compatible with Kodi.
*
* @param[in] addon Addon to check
* @return true if compatible, false if not
*/
bool IsCompatible(const IAddon& addon) const;
bool IsCompatible(const std::shared_ptr<const IAddon>& addon) const;

/*!
* @brief Check given addon information is compatible with Kodi.
Expand Down
4 changes: 2 additions & 2 deletions xbmc/addons/AddonRepos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ bool CAddonRepos::LoadAddonsFromDatabase(const std::string& addonId,

for (const auto& addon : m_allAddons)
{
if (m_addonMgr.IsCompatible(*addon))
if (m_addonMgr.IsCompatible(addon))
{
m_addonsByRepoMap[addon->Origin()].insert({addon->ID(), addon});
}
Expand Down Expand Up @@ -487,7 +487,7 @@ void CAddonRepos::BuildCompatibleVersionsList(

for (const auto& addon : m_allAddons)
{
if (m_addonMgr.IsCompatible(*addon))
if (m_addonMgr.IsCompatible(addon))
{
if (IsFromOfficialRepo(addon, CheckAddonPath::CHOICE_YES))
{
Expand Down

0 comments on commit cb02c86

Please sign in to comment.