aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphunkyfish <phunkyfish@gmail.com>2020-07-28 09:28:31 +0100
committerGitHub <noreply@github.com>2020-07-28 09:28:31 +0100
commit16393bf6cdfdbdb12b9e6a37758529555a95c752 (patch)
treeb7195c9fd8a39b22fa42562f332745c6a998c1e4
parentdb40b2ade4b6e13d6fead7004e819325e2ea0f0b (diff)
parent8ba3e2881069b54abdad2310dc1e2b0d42ffb07e (diff)
Merge pull request #18181 from phunkyfish/binary-origin-addons
[addons] Detect binary addons and Origin Type and set properties to be accessed in skins
-rw-r--r--CMakeLists.txt1
-rw-r--r--addons/resource.language.en_gb/resources/strings.po24
-rw-r--r--cmake/scripts/common/ArchSetup.cmake2
-rw-r--r--xbmc/CompileInfo.cpp.in5
-rw-r--r--xbmc/CompileInfo.h1
-rw-r--r--xbmc/GUIInfoManager.cpp16
-rw-r--r--xbmc/addons/Addon.h1
-rw-r--r--xbmc/addons/AddonManager.cpp10
-rw-r--r--xbmc/addons/AddonManager.h2
-rw-r--r--xbmc/addons/IAddon.h1
-rw-r--r--xbmc/addons/addoninfo/AddonInfo.h13
-rw-r--r--xbmc/addons/addoninfo/AddonInfoBuilder.cpp14
-rw-r--r--xbmc/filesystem/AddonsDirectory.cpp18
13 files changed, 107 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ffd7d310ed..3c01a9479a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -225,6 +225,7 @@ add_custom_command(OUTPUT ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp
-DAPP_SCMID=${APP_SCMID}
-DAPP_COPYRIGHT_YEARS=${APP_COPYRIGHT_YEARS}
-DAPP_BUILD_DATE=${APP_BUILD_DATE}
+ -DAPP_SHARED_LIBRARY_SUFFIX="${APP_SHARED_LIBRARY_SUFFIX}"
-Dprefix=${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}
-P ${CMAKE_SOURCE_DIR}/cmake/scripts/common/GenerateVersionedFiles.cmake
DEPENDS ${CMAKE_SOURCE_DIR}/version.txt
diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po
index 4334be50cf..40641cc001 100644
--- a/addons/resource.language.en_gb/resources/strings.po
+++ b/addons/resource.language.en_gb/resources/strings.po
@@ -15853,7 +15853,29 @@ msgctxt "#25013"
msgid "Auto-skip on"
msgstr ""
-#empty strings from id 25014 to 29800
+#. Used for skins to tell addon origin type
+#. xbmc/filesystem/AddonsDirectory.cpp
+#: addons/skin.estuary/xml/DialogAddonInfo.xml
+msgctxt "#25014"
+msgid "system"
+msgstr ""
+
+#. Used for skins to tell addon origin type
+#. xbmc/filesystem/AddonsDirectory.cpp
+#: addons/skin.estuary/xml/AddonBrowser.xml
+msgctxt "#25015"
+msgid "repository"
+msgstr ""
+
+#. Used for skins to tell addon origin type
+#. xbmc/filesystem/AddonsDirectory.cpp
+#: addons/skin.estuary/xml/AddonBrowser.xml
+#: addons/skin.estuary/xml/DialogAddonInfo.xml
+msgctxt "#25016"
+msgid "manual"
+msgstr ""
+
+#empty strings from id 25017 to 29800
#: unused
msgctxt "#29801"
diff --git a/cmake/scripts/common/ArchSetup.cmake b/cmake/scripts/common/ArchSetup.cmake
index 2e1eb128ad..057361180e 100644
--- a/cmake/scripts/common/ArchSetup.cmake
+++ b/cmake/scripts/common/ArchSetup.cmake
@@ -144,3 +144,5 @@ if(NOT MSVC)
add_options(ALL_LANGUAGES DEBUG "-g" "-D_DEBUG")
endif()
+# set for compile info to help detect binary addons
+set(APP_SHARED_LIBRARY_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}")
diff --git a/xbmc/CompileInfo.cpp.in b/xbmc/CompileInfo.cpp.in
index 95cf766237..59af946559 100644
--- a/xbmc/CompileInfo.cpp.in
+++ b/xbmc/CompileInfo.cpp.in
@@ -60,6 +60,11 @@ std::string CCompileInfo::GetOfficialAddonRepos()
return "@APP_ADDON_REPOS@";
}
+std::string CCompileInfo::GetSharedLibrarySuffix()
+{
+ return "@APP_SHARED_LIBRARY_SUFFIX@";
+}
+
const char* CCompileInfo::GetCopyrightYears()
{
return "@APP_COPYRIGHT_YEARS@";
diff --git a/xbmc/CompileInfo.h b/xbmc/CompileInfo.h
index 40e82c011e..001f143219 100644
--- a/xbmc/CompileInfo.h
+++ b/xbmc/CompileInfo.h
@@ -21,6 +21,7 @@ public:
static const char* GetSuffix(); // Git "Tag", e.g. alpha1
static const char* GetSCMID(); // Git Revision
static std::string GetOfficialAddonRepos();
+ static std::string GetSharedLibrarySuffix();
static const char* GetCopyrightYears();
static std::string GetBuildDate();
static const char* GetVersionCode();
diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp
index 828fe1da26..9828b5b109 100644
--- a/xbmc/GUIInfoManager.cpp
+++ b/xbmc/GUIInfoManager.cpp
@@ -4381,6 +4381,22 @@ const infomap container_str[] = {{ "property", CONTAINER_PROPERTY },
/// @skinning_v19 **[New Boolean Condition]** \link ListItem_Property_AddonIsFromOfficialRepo `ListItem.Property(Addon.IsFromOfficialRepo)`\endlink
/// <p>
/// }
+/// \table_row3{ <b>`ListItem.Property(Addon.IsBinary)`</b>,
+/// \anchor ListItem_Property_AddonIsBinary
+/// _boolean_,
+/// @return **True** if this add-on is a binary addon.
+/// <p><hr>
+/// @skinning_v19 **[New Boolean Condition]** \link ListItem_Property_AddonIsBinary `ListItem.Property(Addon.IsBinary)`\endlink
+/// <p>
+/// }
+/// \table_row3{ <b>`ListItem.Property(Addon.OriginType)`</b>,
+/// \anchor ListItem_Property_AddonOriginType
+/// _string_,
+/// @return A string representing the origin type. One of system\, repository or manual.
+/// <p><hr>
+/// @skinning_v19 **[New String Value]** \link ListItem_Property_AddonOriginType `ListItem.Property(Addon.OriginType)`\endlink
+/// <p>
+/// }
/// \table_row3{ <b>`ListItem.Label`</b>,
/// \anchor ListItem_Label
/// _string_,
diff --git a/xbmc/addons/Addon.h b/xbmc/addons/Addon.h
index c42e54f6f9..e8fed4e5bc 100644
--- a/xbmc/addons/Addon.h
+++ b/xbmc/addons/Addon.h
@@ -84,6 +84,7 @@ public:
std::string ID() const override{ return m_addonInfo->ID(); }
std::string Name() const override { return m_addonInfo->Name(); }
bool IsInUse() const override{ return false; };
+ bool IsBinary() const override { return m_addonInfo->IsBinary(); };
AddonVersion Version() const override { return m_addonInfo->Version(); }
AddonVersion MinVersion() const override { return m_addonInfo->MinVersion(); }
std::string Summary() const override { return m_addonInfo->Summary(); }
diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp
index 9f3413bcee..fdb702dcdb 100644
--- a/xbmc/addons/AddonManager.cpp
+++ b/xbmc/addons/AddonManager.cpp
@@ -1088,6 +1088,16 @@ bool CAddonMgr::IsFromOfficialRepo(const AddonPtr& addon, bool bCheckAddonPath)
std::any_of(m_officialAddonRepos.begin(), m_officialAddonRepos.end(), comparator);
}
+AddonOriginType CAddonMgr::GetAddonOriginType(const AddonPtr& addon) const
+{
+ if (addon->Origin() == ORIGIN_SYSTEM)
+ return AddonOriginType::SYSTEM;
+ else if (!addon->Origin().empty())
+ return AddonOriginType::REPOSITORY;
+ else
+ return AddonOriginType::MANUAL;
+}
+
void CAddonMgr::AddAddonIfLatest(const AddonPtr& addonToAdd,
std::map<std::string, AddonPtr>& map) const
{
diff --git a/xbmc/addons/AddonManager.h b/xbmc/addons/AddonManager.h
index 9e8372a90d..b0940cac22 100644
--- a/xbmc/addons/AddonManager.h
+++ b/xbmc/addons/AddonManager.h
@@ -329,6 +329,8 @@ namespace ADDON
*/
bool IsFromOfficialRepo(const AddonPtr& addon) const;
+ AddonOriginType GetAddonOriginType(const AddonPtr& addon) const;
+
private:
CAddonMgr& operator=(CAddonMgr const&) = delete;
diff --git a/xbmc/addons/IAddon.h b/xbmc/addons/IAddon.h
index 5a3c14ca1c..7e7d81b201 100644
--- a/xbmc/addons/IAddon.h
+++ b/xbmc/addons/IAddon.h
@@ -39,6 +39,7 @@ namespace ADDON
virtual std::string ID() const =0;
virtual std::string Name() const =0;
virtual bool IsInUse() const =0;
+ virtual bool IsBinary() const = 0;
virtual AddonVersion Version() const =0;
virtual AddonVersion MinVersion() const =0;
virtual std::string Summary() const =0;
diff --git a/xbmc/addons/addoninfo/AddonInfo.h b/xbmc/addons/addoninfo/AddonInfo.h
index 59f2b30c5b..03db6e7501 100644
--- a/xbmc/addons/addoninfo/AddonInfo.h
+++ b/xbmc/addons/addoninfo/AddonInfo.h
@@ -37,6 +37,16 @@ enum class AddonDisabledReason
PERMANENT_FAILURE = 3
};
+enum class AddonOriginType
+{
+ /// @brief The type of the origin of an addon.
+ ///
+ /// Represents where an addon was installed from.
+ SYSTEM = 0, /// The addon is a system addon
+ REPOSITORY = 1, /// The addon origin is a repository
+ MANUAL = 2 /// The addon origin is a zip file, package or development build
+};
+
struct DependencyInfo
{
std::string id;
@@ -74,6 +84,7 @@ public:
CAddonInfo(std::string id, TYPE type);
void SetMainType(TYPE type) { m_mainType = type; }
+ void SetBinary(bool isBinary) { m_isBinary = isBinary; }
void SetLibName(const std::string& libname) { m_libname = libname; }
void SetPath(const std::string& path) { m_path = path; }
void AddExtraInfo(const std::string& idName, const std::string& value) { m_extrainfo[idName] = value; }
@@ -133,6 +144,7 @@ public:
const AddonVersion& Version() const { return m_version; }
const AddonVersion& MinVersion() const { return m_minversion; }
+ bool IsBinary() const { return m_isBinary; }
const AddonVersion& DependencyMinVersion(const std::string& dependencyID) const;
const AddonVersion& DependencyVersion(const std::string& dependencyID) const;
const std::string& Name() const { return m_name; }
@@ -181,6 +193,7 @@ private:
AddonVersion m_version;
AddonVersion m_minversion;
+ bool m_isBinary;
std::string m_name;
std::string m_license;
std::unordered_map<std::string, std::string> m_summary;
diff --git a/xbmc/addons/addoninfo/AddonInfoBuilder.cpp b/xbmc/addons/addoninfo/AddonInfoBuilder.cpp
index f62446521b..1aa30b8d78 100644
--- a/xbmc/addons/addoninfo/AddonInfoBuilder.cpp
+++ b/xbmc/addons/addoninfo/AddonInfoBuilder.cpp
@@ -8,6 +8,7 @@
#include "AddonInfoBuilder.h"
+#include "CompileInfo.h"
#include "LangInfo.h"
#include "addons/addoninfo/AddonType.h"
#include "filesystem/File.h"
@@ -22,6 +23,7 @@
#include <algorithm>
#include <memory>
+#include <regex>
namespace
{
@@ -405,7 +407,19 @@ bool CAddonInfoBuilder::ParseXMLTypes(CAddonType& addonType, AddonInfoPtr info,
if (library == nullptr)
library = GetPlatformLibraryName(child);
if (library != nullptr)
+ {
addonType.m_libname = library;
+ // linux is different an has the version number after the suffix
+ static const std::regex libRegex("^.*" +
+ CCompileInfo::CCompileInfo::GetSharedLibrarySuffix() +
+ "\\.?[0-9]*\\.?[0-9]*\\.?[0-9]*$");
+ if (std::regex_match(library, libRegex))
+ {
+ info->SetBinary(true);
+ CLog::Log(LOGDEBUG, "CAddonInfoBuilder::{}: Binary addon found: {}", __FUNCTION__,
+ info->ID());
+ }
+ }
if (!ParseXMLExtension(addonType, child))
{
diff --git a/xbmc/filesystem/AddonsDirectory.cpp b/xbmc/filesystem/AddonsDirectory.cpp
index b529471fa0..618b0a2791 100644
--- a/xbmc/filesystem/AddonsDirectory.cpp
+++ b/xbmc/filesystem/AddonsDirectory.cpp
@@ -788,11 +788,29 @@ void CAddonsDirectory::GenerateAddonListing(const CURL &path,
bool disabled = CServiceBroker::GetAddonMgr().IsAddonDisabled(addon->ID());
bool hasUpdate = outdated.find(addon->ID()) != outdated.end();
bool fromOfficialRepo = CServiceBroker::GetAddonMgr().IsFromOfficialRepo(addon);
+ AddonOriginType addonOriginType = CServiceBroker::GetAddonMgr().GetAddonOriginType(addon);
pItem->SetProperty("Addon.IsInstalled", installed);
pItem->SetProperty("Addon.IsEnabled", installed && !disabled);
pItem->SetProperty("Addon.HasUpdate", hasUpdate);
pItem->SetProperty("Addon.IsFromOfficialRepo", fromOfficialRepo);
+ pItem->SetProperty("Addon.IsBinary", addon->IsBinary());
+
+ std::string addonOriginTypeProperty;
+ switch (addonOriginType)
+ {
+ case AddonOriginType::SYSTEM:
+ addonOriginTypeProperty = g_localizeStrings.Get(25014); // system
+ break;
+ case AddonOriginType::REPOSITORY:
+ addonOriginTypeProperty = g_localizeStrings.Get(25015); // repository
+ break;
+ case AddonOriginType::MANUAL:
+ default:
+ addonOriginTypeProperty = g_localizeStrings.Get(25016); // manual
+ break;
+ }
+ pItem->SetProperty("Addon.OriginType", addonOriginTypeProperty);
if (installed)
pItem->SetProperty("Addon.Status", g_localizeStrings.Get(305));