Skip to content

Commit

Permalink
Merge pull request xbmc#18116 from phunkyfish/show-incompatible-addons
Browse files Browse the repository at this point in the history
[addons] Show both enabled and disabled incompatbile addons when performing a migration
  • Loading branch information
phunkyfish authored and Maven85 committed Aug 7, 2020
1 parent 3493d0a commit c2f1f56
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
4 changes: 2 additions & 2 deletions xbmc/Application.cpp
Expand Up @@ -794,7 +794,7 @@ bool CApplication::Initialize()

// Addon migration
std::vector<AddonInfoPtr> incompatible;
if (CServiceBroker::GetAddonMgr().GetIncompatibleAddons(incompatible))
if (CServiceBroker::GetAddonMgr().GetIncompatibleEnabledAddonInfos(incompatible))
{
if (CAddonSystemSettings::GetInstance().GetAddonAutoUpdateMode() == AUTO_UPDATES_ON)
{
Expand Down Expand Up @@ -2331,7 +2331,7 @@ void CApplication::OnApplicationMessage(ThreadMessage* pMsg)
}
}
break;

default:
CLog::Log(LOGERROR, "%s: Unhandled threadmessage sent, %u", __FUNCTION__, msg);
break;
Expand Down
16 changes: 12 additions & 4 deletions xbmc/addons/AddonManager.cpp
Expand Up @@ -364,9 +364,17 @@ bool CAddonMgr::GetAddonsInternal(const TYPE& type,
return addons.size() > 0;
}

bool CAddonMgr::GetIncompatibleAddons(std::vector<AddonInfoPtr>& incompatible) const
bool CAddonMgr::GetIncompatibleEnabledAddonInfos(std::vector<AddonInfoPtr>& incompatible) const
{
return GetIncompatibleAddonInfos(incompatible, false);
}

bool CAddonMgr::GetIncompatibleAddonInfos(std::vector<AddonInfoPtr>& incompatible,
bool includeDisabled) const
{
GetAddonInfos(incompatible, true, ADDON_UNKNOWN);
if (includeDisabled)
GetDisabledAddonInfos(incompatible, ADDON_UNKNOWN, AddonDisabledReason::INCOMPATIBLE);
incompatible.erase(std::remove_if(incompatible.begin(), incompatible.end(),
[this](const AddonInfoPtr& a) { return IsCompatible(a); }),
incompatible.end());
Expand All @@ -384,7 +392,7 @@ std::vector<std::string> CAddonMgr::MigrateAddons()

// get addons that became incompatible and disable them
std::vector<AddonInfoPtr> incompatible;
GetIncompatibleAddons(incompatible);
GetIncompatibleAddonInfos(incompatible, true);

return DisableIncompatibleAddons(incompatible);
}
Expand Down Expand Up @@ -944,14 +952,14 @@ bool CAddonMgr::GetAddonInfos(AddonInfos& addonInfos, bool enabledOnly, TYPE typ
return !addonInfos.empty();
}

bool CAddonMgr::GetDisabledAddonInfos(std::vector<AddonInfoPtr>& addonInfos, TYPE type)
bool CAddonMgr::GetDisabledAddonInfos(std::vector<AddonInfoPtr>& addonInfos, TYPE type) const
{
return GetDisabledAddonInfos(addonInfos, type, AddonDisabledReason::NONE);
}

bool CAddonMgr::GetDisabledAddonInfos(std::vector<AddonInfoPtr>& addonInfos,
TYPE type,
AddonDisabledReason disabledReason)
AddonDisabledReason disabledReason) const
{
CSingleLock lock(m_critSection);

Expand Down
21 changes: 16 additions & 5 deletions xbmc/addons/AddonManager.h
Expand Up @@ -126,17 +126,17 @@ namespace ADDON

/*!
* @brief Fills the the provided vector with the list of incompatible
* addons and returns if there's any.
* enabled addons and returns if there's any.
*
* @param[out] incompatible List of incompatible addons
* @return true if there are incompatible addons
*/
bool GetIncompatibleAddons(std::vector<AddonInfoPtr>& incompatible) const;
bool GetIncompatibleEnabledAddonInfos(std::vector<AddonInfoPtr>& incompatible) const;

/*!
* @brief Disable addons in given list.
*
* @param[in] incompatible List of incompatible addons
* @param[in] incompatible List of incompatible addon infos
* @return list of all addon **names** that were disabled
*/
std::vector<std::string> DisableIncompatibleAddons(
Expand Down Expand Up @@ -291,7 +291,7 @@ namespace ADDON
* returned who match them. Default is for all types.
* @return true if the list contains entries
*/
bool GetDisabledAddonInfos(std::vector<AddonInfoPtr>& addonInfos, TYPE type);
bool GetDisabledAddonInfos(std::vector<AddonInfoPtr>& addonInfos, TYPE type) const;

/*!
* @brief Get a list of disabled add-on's with info's for the on system
Expand All @@ -311,7 +311,7 @@ namespace ADDON
*/
bool GetDisabledAddonInfos(std::vector<AddonInfoPtr>& addonInfos,
TYPE type,
AddonDisabledReason disabledReason);
AddonDisabledReason disabledReason) const;

const AddonInfoPtr GetAddonInfo(const std::string& id, TYPE type = ADDON_UNKNOWN) const;

Expand All @@ -337,6 +337,17 @@ namespace ADDON

void FindAddons(ADDON_INFO_LIST& addonmap, const std::string& path);

/*!
* @brief Fills the the provided vector with the list of incompatible
* addons and returns if there's any.
*
* @param[out] incompatible List of incompatible addons
* @param[in] whether or not to include incompatible addons that are disabled
* @return true if there are incompatible addons
*/
bool GetIncompatibleAddonInfos(std::vector<AddonInfoPtr>& incompatible,
bool includeDisabled) const;

/*!
* Get the list of of available updates
* \param[in,out] updates the vector of addons to be filled with addons that need to be updated (not blacklisted)
Expand Down

0 comments on commit c2f1f56

Please sign in to comment.