aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhowie-f <rftc@gmx.de>2020-10-13 16:14:43 +0200
committerhowie-f <rftc@gmx.de>2020-10-25 05:46:16 +0000
commit6e2dea3853d64959129824ddc34dfdbfd98e0fc9 (patch)
tree00dc6c943140a1262d568722eaaca2457262a3d5
parentc413111b8731253f78bcb0d09f8a02ea2246a3de (diff)
[addons] cleanup: remove bool parameter and obsolete wrappers
-rw-r--r--xbmc/addons/AddonManager.cpp15
-rw-r--r--xbmc/addons/AddonManager.h8
-rw-r--r--xbmc/addons/AddonRepos.cpp18
-rw-r--r--xbmc/addons/AddonRepos.h28
4 files changed, 22 insertions, 47 deletions
diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp
index 6fde91fd0a..49961013b1 100644
--- a/xbmc/addons/AddonManager.cpp
+++ b/xbmc/addons/AddonManager.cpp
@@ -212,7 +212,7 @@ bool CAddonMgr::ReloadSettings(const std::string &id)
std::vector<std::shared_ptr<IAddon>> CAddonMgr::GetAvailableUpdates() const
{
std::vector<std::shared_ptr<IAddon>> availableUpdates =
- GetAvailableUpdatesOrOutdatedAddons(false);
+ GetAvailableUpdatesOrOutdatedAddons(AddonCheckType::AVAILABLE_UPDATES);
std::lock_guard<std::mutex> lock(m_lastAvailableUpdatesCountMutex);
m_lastAvailableUpdatesCountAsString = std::to_string(availableUpdates.size());
@@ -228,11 +228,11 @@ const std::string& CAddonMgr::GetLastAvailableUpdatesCountAsString() const
std::vector<std::shared_ptr<IAddon>> CAddonMgr::GetOutdatedAddons() const
{
- return GetAvailableUpdatesOrOutdatedAddons(true);
+ return GetAvailableUpdatesOrOutdatedAddons(AddonCheckType::OUTDATED_ADDONS);
}
std::vector<std::shared_ptr<IAddon>> CAddonMgr::GetAvailableUpdatesOrOutdatedAddons(
- bool returnOutdatedAddons) const
+ AddonCheckType addonCheckType) const
{
CSingleLock lock(m_critSection);
auto start = XbmcThreads::SystemClockMillis();
@@ -245,14 +245,7 @@ std::vector<std::shared_ptr<IAddon>> CAddonMgr::GetAvailableUpdatesOrOutdatedAdd
GetAddonsForUpdate(installed);
- if (returnOutdatedAddons)
- {
- addonRepos.BuildOutdatedList(installed, result);
- }
- else
- {
- addonRepos.BuildUpdateList(installed, result);
- }
+ addonRepos.BuildUpdateOrOutdatedList(installed, result, addonCheckType);
CLog::Log(LOGDEBUG, "CAddonMgr::GetAvailableUpdatesOrOutdatedAddons took %i ms",
XbmcThreads::SystemClockMillis() - start);
diff --git a/xbmc/addons/AddonManager.h b/xbmc/addons/AddonManager.h
index 126ed3730a..cfb6be10b8 100644
--- a/xbmc/addons/AddonManager.h
+++ b/xbmc/addons/AddonManager.h
@@ -26,6 +26,12 @@ namespace ADDON
const std::string ADDON_PYTHON_EXT = "*.py";
+ enum class AddonCheckType
+ {
+ OUTDATED_ADDONS,
+ AVAILABLE_UPDATES
+ };
+
struct CAddonWithUpdate;
/**
@@ -507,7 +513,7 @@ namespace ADDON
* \return vector filled with either available updates or outdated addons
*/
std::vector<std::shared_ptr<IAddon>> GetAvailableUpdatesOrOutdatedAddons(
- bool returnOutdatedAddons) const;
+ AddonCheckType addonCheckType) const;
bool GetAddonsInternal(const TYPE& type,
VECADDONS& addons,
diff --git a/xbmc/addons/AddonRepos.cpp b/xbmc/addons/AddonRepos.cpp
index e7066b50a4..ef1d43e523 100644
--- a/xbmc/addons/AddonRepos.cpp
+++ b/xbmc/addons/AddonRepos.cpp
@@ -175,32 +175,20 @@ void CAddonRepos::AddAddonIfLatest(
}
}
-void CAddonRepos::BuildUpdateList(const std::vector<std::shared_ptr<IAddon>>& installed,
- std::vector<std::shared_ptr<IAddon>>& updates) const
-{
- BuildUpdateOrOutdatedList(installed, updates, false);
-}
-
-void CAddonRepos::BuildOutdatedList(const std::vector<std::shared_ptr<IAddon>>& installed,
- std::vector<std::shared_ptr<IAddon>>& outdated) const
-{
- BuildUpdateOrOutdatedList(installed, outdated, true);
-}
-
void CAddonRepos::BuildUpdateOrOutdatedList(const std::vector<std::shared_ptr<IAddon>>& installed,
std::vector<std::shared_ptr<IAddon>>& result,
- bool returnOutdatedAddons) const
+ AddonCheckType addonCheckType) const
{
std::shared_ptr<IAddon> update;
CLog::Log(LOGDEBUG, "CAddonRepos::{}: Building {} list from installed add-ons", __func__,
- returnOutdatedAddons ? "outdated" : "update");
+ addonCheckType == AddonCheckType::OUTDATED_ADDONS ? "outdated" : "update");
for (const auto& addon : installed)
{
if (DoAddonUpdateCheck(addon, update))
{
- result.emplace_back(returnOutdatedAddons ? addon : update);
+ result.emplace_back(addonCheckType == AddonCheckType::OUTDATED_ADDONS ? addon : update);
}
}
}
diff --git a/xbmc/addons/AddonRepos.h b/xbmc/addons/AddonRepos.h
index 4073744a57..c87066c868 100644
--- a/xbmc/addons/AddonRepos.h
+++ b/xbmc/addons/AddonRepos.h
@@ -21,6 +21,7 @@ class CAddonDatabase;
class CAddonMgr;
class CRepository;
class IAddon;
+enum class AddonCheckType;
enum class CheckAddonPath
{
@@ -75,22 +76,17 @@ public:
/*!
* \brief Build the list of addons to be updated depending on defined rules
+ * or the list of outdated addons
* \param installed vector of all addons installed on the system that are
* checked for an update
- * \param[out] updates list of addon versions that are going to be installed
+ * \param[in] addonCheckType build list of OUTDATED or UPDATES
+ * \param[out] result list of addon versions that are going to be installed
+ * or are outdated
*/
- void BuildUpdateList(const std::vector<std::shared_ptr<IAddon>>& installed,
- std::vector<std::shared_ptr<IAddon>>& updates) const;
+ void BuildUpdateOrOutdatedList(const std::vector<std::shared_ptr<IAddon>>& installed,
+ std::vector<std::shared_ptr<IAddon>>& result,
+ AddonCheckType addonCheckType) const;
- /*!
- * \brief Build the list of addons that are outdated and have an update
- * available depending on defined rules
- * \param installed vector of all addons installed on the system that are
- * checked for an update
- * \param[out] outdated list of addon versions that have an update available
- */
- void BuildOutdatedList(const std::vector<std::shared_ptr<IAddon>>& installed,
- std::vector<std::shared_ptr<IAddon>>& outdated) const;
/*!
* \brief Build the list of outdated addons and their available updates.
@@ -188,14 +184,6 @@ public:
private:
/*!
- * \brief Executor for BuildUpdateList() and BuildOutdatedList()
- * \sa BuildUpdateList() BuildOutdatedList()
- */
- void BuildUpdateOrOutdatedList(const std::vector<std::shared_ptr<IAddon>>& installed,
- std::vector<std::shared_ptr<IAddon>>& result,
- bool returnOutdatedAddons) const;
-
- /*!
* \brief Load the map of addons
* \note this function should only by called from publicly exposed wrappers
* \return true on success, false otherwise