aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhowie-f <rftc@gmx.de>2020-10-04 00:08:57 +0200
committerhowie-f <rftc@gmx.de>2020-10-08 16:29:26 +0200
commita5d9b9f7aa32f922511a75d34ecdef39221c1556 (patch)
tree7f3c95fc76b51735203863d84310a3954c300640
parentcc286a397145184ff27458c610bfe839d5c432c7 (diff)
[addons] refactor: change bool parameter to enum: IsFromOfficialRepo()
changes order of CAddonManager::IsAddonInstalled() functions
-rw-r--r--xbmc/addons/AddonManager.cpp12
-rw-r--r--xbmc/addons/AddonManager.h14
-rw-r--r--xbmc/addons/AddonRepos.cpp14
-rw-r--r--xbmc/addons/AddonRepos.h22
-rw-r--r--xbmc/filesystem/AddonsDirectory.cpp2
5 files changed, 30 insertions, 34 deletions
diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp
index 0fcfa4573a..9d8db3ef47 100644
--- a/xbmc/addons/AddonManager.cpp
+++ b/xbmc/addons/AddonManager.cpp
@@ -887,6 +887,12 @@ bool CAddonMgr::IsAddonInstalled(const std::string& ID)
return GetAddon(ID, tmp, ADDON_UNKNOWN, false);
}
+bool CAddonMgr::IsAddonInstalled(const std::string& ID, const std::string& origin) const
+{
+ AddonPtr tmp;
+ return (GetAddon(ID, tmp, ADDON_UNKNOWN, false) && tmp && tmp->Origin() == origin);
+}
+
bool CAddonMgr::IsAddonInstalled(const std::string& ID,
const std::string& origin,
const AddonVersion& version)
@@ -896,12 +902,6 @@ bool CAddonMgr::IsAddonInstalled(const std::string& ID,
tmp->Version() == version);
}
-bool CAddonMgr::IsAddonInstalled(const std::string& ID, const std::string& origin) const
-{
- AddonPtr tmp;
- return (GetAddon(ID, tmp, ADDON_UNKNOWN, false) && tmp && tmp->Origin() == origin);
-}
-
bool CAddonMgr::CanAddonBeInstalled(const AddonPtr& addon)
{
return addon != nullptr && addon->LifecycleState() != AddonLifecycleState::BROKEN &&
diff --git a/xbmc/addons/AddonManager.h b/xbmc/addons/AddonManager.h
index 37d59127e7..22f871a25a 100644
--- a/xbmc/addons/AddonManager.h
+++ b/xbmc/addons/AddonManager.h
@@ -241,21 +241,21 @@ namespace ADDON
bool IsAddonInstalled(const std::string& ID);
/* \brief Checks whether an addon is installed from a
- * particular origin repo and version
+ * particular origin repo
* \param ID id of the addon
* \param origin origin repository id
- * \param version the version of the addon
*/
- bool IsAddonInstalled(const std::string& ID,
- const std::string& origin,
- const AddonVersion& version);
+ bool IsAddonInstalled(const std::string& ID, const std::string& origin) const;
/* \brief Checks whether an addon is installed from a
- * particular origin repo
+ * particular origin repo and version
* \param ID id of the addon
* \param origin origin repository id
+ * \param version the version of the addon
*/
- bool IsAddonInstalled(const std::string& ID, const std::string& origin) const;
+ bool IsAddonInstalled(const std::string& ID,
+ const std::string& origin,
+ const AddonVersion& version);
/* \brief Checks whether an addon can be installed. Broken addons can't be installed.
\param addon addon to be checked
diff --git a/xbmc/addons/AddonRepos.cpp b/xbmc/addons/AddonRepos.cpp
index 1f529144d9..29e751829c 100644
--- a/xbmc/addons/AddonRepos.cpp
+++ b/xbmc/addons/AddonRepos.cpp
@@ -32,15 +32,11 @@ static std::vector<RepoInfo> officialRepoInfos = CCompileInfo::LoadOfficialRepoI
*
*/
-bool CAddonRepos::IsFromOfficialRepo(const std::shared_ptr<IAddon>& addon)
-{
- return IsFromOfficialRepo(addon, false);
-}
-
-bool CAddonRepos::IsFromOfficialRepo(const std::shared_ptr<IAddon>& addon, bool bCheckAddonPath)
+bool CAddonRepos::IsFromOfficialRepo(const std::shared_ptr<IAddon>& addon,
+ CheckAddonPath checkAddonPath)
{
auto comparator = [&](const RepoInfo& officialRepo) {
- if (bCheckAddonPath)
+ if (checkAddonPath == CheckAddonPath::YES)
{
return (addon->Origin() == officialRepo.m_repoId &&
StringUtils::StartsWithNoCase(addon->Path(), officialRepo.m_origin));
@@ -133,7 +129,7 @@ void CAddonRepos::SetupLatestVersionMaps()
{
const auto& addonToAdd = addonMapEntry.second;
- if (IsFromOfficialRepo(addonToAdd, true))
+ if (IsFromOfficialRepo(addonToAdd, CheckAddonPath::YES))
{
AddAddonIfLatest(addonToAdd, m_latestOfficialVersions);
}
@@ -246,7 +242,7 @@ bool CAddonRepos::DoAddonUpdateCheck(const std::shared_ptr<IAddon>& addon,
if (ORIGIN_SYSTEM != addon->Origin() && !hasOfficialUpdate) // not a system addon
{
// If we didn't find an official update
- if (IsFromOfficialRepo(addon, true)) // is an official addon
+ if (IsFromOfficialRepo(addon, CheckAddonPath::YES)) // is an official addon
{
if (updateMode == AddonRepoUpdateMode::ANY_REPOSITORY)
{
diff --git a/xbmc/addons/AddonRepos.h b/xbmc/addons/AddonRepos.h
index 60f56d66cb..0e07bf5cf5 100644
--- a/xbmc/addons/AddonRepos.h
+++ b/xbmc/addons/AddonRepos.h
@@ -22,6 +22,12 @@ class CAddonMgr;
class CRepository;
class IAddon;
+enum class CheckAddonPath
+{
+ YES,
+ NO,
+};
+
/**
* Struct - CAddonWithUpdate
*/
@@ -97,21 +103,15 @@ public:
/*!
* \brief Checks if the origin-repository of a given addon is defined as official repo
- * but does not check the origin path (e.g. https://mirrors.kodi.tv ...)
- * \param addon pointer to addon to be checked
- * \return true if the repository id of a given addon is defined as official
- */
- static bool IsFromOfficialRepo(const std::shared_ptr<IAddon>& addon);
-
- /*!
- * \brief Checks if the origin-repository of a given addon is defined as official repo
- * and verify if the origin-path is also defined and matching
+ * and can also verify if the origin-path (e.g. https://mirrors.kodi.tv ...)
+ * is matching
* \param addon pointer to addon to be checked
- * \param bCheckAddonPath also check origin path
+ * \param checkAddonPath also check origin path
* \return true if the repository id of a given addon is defined as official
* and the addons origin matches the defined official origin of the repo id
*/
- static bool IsFromOfficialRepo(const std::shared_ptr<IAddon>& addon, bool bCheckAddonPath);
+ static bool IsFromOfficialRepo(const std::shared_ptr<IAddon>& addon,
+ CheckAddonPath checkAddonPath);
/*!
* \brief Check if an update is available for a single addon
diff --git a/xbmc/filesystem/AddonsDirectory.cpp b/xbmc/filesystem/AddonsDirectory.cpp
index c946d1c5da..afe71a5886 100644
--- a/xbmc/filesystem/AddonsDirectory.cpp
+++ b/xbmc/filesystem/AddonsDirectory.cpp
@@ -826,7 +826,7 @@ void CAddonsDirectory::GenerateAddonListing(const CURL& path,
bool isUpdate = CheckOutdatedOrUpdate(false); // check if it's an available update
bool hasUpdate = CheckOutdatedOrUpdate(true); // check if it's an outdated addon
- bool fromOfficialRepo = CAddonRepos::IsFromOfficialRepo(addon);
+ bool fromOfficialRepo = CAddonRepos::IsFromOfficialRepo(addon, CheckAddonPath::NO);
pItem->SetProperty("Addon.IsInstalled", installed);
pItem->SetProperty("Addon.IsEnabled", installed && !disabled);