New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[addons] make binary addon management independent #12299
Conversation
0c9152d
to
0bf12ba
Compare
Yes, architecturally I think this is fine. Ideally GetInstalledBinaryAddonPaths would return a CAddon with all the info CBinaryAddonManger needs instead of the paths directly. But if you can't make it work, that's ok. It will be easy to fix later once CAddonDll and CAddon are separated. |
cf05f24
to
bfab227
Compare
The request is now complete updated and use a working way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some questions and suggestions...
xbmc/ServiceManager.cpp
Outdated
m_binaryAddonManager.reset(new ADDON::CBinaryAddonManager()); | ||
if (!m_binaryAddonManager->Init()) | ||
{ | ||
CLog::Log(LOGFATAL, "CServiceManager::Init: Unable to start CBinaryAddonManager"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
xbmc/ServiceManager.cpp
Outdated
return *m_binaryAddonManager.get(); | ||
} | ||
|
||
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
xbmc/addons/AddonManager.cpp
Outdated
std::vector<CAddonBuilder> builders; | ||
m_database.GetInstalled(builders); | ||
|
||
for (auto& builder : builders) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
xbmc/addons/AddonManager.h
Outdated
@@ -117,6 +117,8 @@ namespace ADDON | |||
|
|||
bool GetInstallableAddons(VECADDONS& addons, const TYPE &type); | |||
|
|||
bool GetInstalledBinaryAddonPaths(std::vector<std::pair<std::string, bool>>& binaryAddonList); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
CBinaryAddonBase::CBinaryAddonBase(const std::string& addonPath) | ||
{ | ||
|
||
m_usable = false; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
CBinaryAddonManager::CBinaryAddonManager() | ||
{ | ||
|
||
} |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
CBinaryAddonManager::~CBinaryAddonManager() | ||
{ | ||
|
||
} |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
std::vector<std::pair<std::string, bool>> binaryAddonList; | ||
if (!CAddonMgr::GetInstance().GetInstalledBinaryAddonPaths(binaryAddonList)) | ||
{ | ||
CLog::Log(LOGERROR, "Binary Addons: failed to get list"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
for (auto addon : binaryAddonList) | ||
{ | ||
BinaryAddonBase base = std::make_shared<CBinaryAddonBase>(addon.first); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
continue; | ||
m_installedAddons[base->ID()] = base; | ||
if (addon.second) | ||
m_enabledAddons[base->ID()] = base; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we go. Lots of stuff...
xbmc/ServiceManager.cpp
Outdated
m_addonMgr.reset(new ADDON::CAddonMgr()); | ||
if (!m_addonMgr->Init()) | ||
{ | ||
CLog::Log(LOGFATAL, "CServiceManager::Init: Unable to start CAddonMgr"); | ||
return false; | ||
} | ||
|
||
if (!m_binaryAddonManager->Init()) | ||
{ | ||
CLog::Log(LOGFATAL, "CServiceManager::Init: Unable to start CBinaryAddonManager"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
xbmc/addons/AddonInfo.h
Outdated
@@ -143,40 +101,31 @@ namespace ADDON | |||
static TYPE TranslateSubContent(const std::string &content); | |||
//@} | |||
|
|||
InfoMap extrainfo; // defined here, but removed in future with cpluff | |||
|
|||
private: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
xbmc/addons/AddonManager.h
Outdated
@@ -117,6 +117,8 @@ namespace ADDON | |||
|
|||
bool GetInstallableAddons(VECADDONS& addons, const TYPE &type); | |||
|
|||
bool GetInstalledBinaryAddonPaths(std::vector<std::tuple<std::string, bool, std::string>>& binaryAddonList); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
|
||
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
AddonPtr addon = CServiceBroker::GetBinaryAddonManager().GetRunningAddon(ID()); | ||
if (addon) | ||
return addon; | ||
return AddonPtr(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
m_installedAddons[base->ID()] = base; | ||
if (std::get<1>(addon)) | ||
m_enabledAddons[base->ID()] = base; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* @param[in] type Add-on type to check installed | ||
* @return true if given type is installed | ||
*/ | ||
bool HasInstalledAddons(const TYPE &type); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* @param[in] type Add-on type to check enabled | ||
* @return true if given type is enabled | ||
*/ | ||
bool HasEnabledAddons(const TYPE &type); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* If a type id becomes added are only add-ons | ||
* returned who match them. Default is for all types. | ||
*/ | ||
void GetAddonInfos(BinaryAddonBaseList& addonInfos, bool enabledOnly, const TYPE &type); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* not a nullptr is returned | ||
* @return add-on information pointer of installed add-on | ||
*/ | ||
const BinaryAddonBasePtr GetInstalledAddonInfo(const std::string& addonId, const TYPE &type = ADDON_UNKNOWN); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
bfab227
to
a94c70f
Compare
CSingleLock lock(m_critSection); | ||
|
||
BINARY_ADDON_LIST binaryAddonList; | ||
CAddonMgr::GetInstance().GetInstalledBinaryAddonPaths(binaryAddonList); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
b70b429
to
0bb9b15
Compare
Is complete updated, instead of the CAddon use it CAddonInfo who was created by CAddonBuilder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice. Just some nitpicking...
xbmc/addons/AddonBuilder.h
Outdated
@@ -61,6 +61,8 @@ class CAddonBuilder | |||
const std::string& GetId() const { return m_addonInfo.m_id; } | |||
const AddonVersion& GetVersion() const { return m_addonInfo.m_version; } | |||
|
|||
const CAddonInfo& GetAddonInfo() { return m_addonInfo; } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
xbmc/ServiceManager.cpp
Outdated
m_addonMgr.reset(new ADDON::CAddonMgr()); | ||
if (!m_addonMgr->Init()) | ||
{ | ||
CLog::Log(LOGFATAL, "CServiceManager::Init: Unable to start CAddonMgr"); | ||
return false; | ||
} | ||
|
||
if (!m_binaryAddonManager->Init()) | ||
{ | ||
CLog::Log(LOGFATAL, "CServiceManager::Init: Unable to initialize CBinaryAddonManager"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -564,6 +567,40 @@ bool CAddonMgr::FindInstallableById(const std::string& addonId, AddonPtr& result | |||
return true; | |||
} | |||
|
|||
bool CAddonMgr::GetInstalledBinaryAddons(BINARY_ADDON_LIST& binaryAddonList) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
CSingleLock lock(m_critSection); | ||
|
||
auto addon = m_installedAddons.find(addonId); | ||
if (addon != m_installedAddons.end() && addon->second) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
return URIUtils::AddFileToFolder(m_path, m_libname); | ||
} | ||
|
||
const char* CBinaryAddonType::GetPlatformLibraryName(const TiXmlElement* element) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Why didn't using CAddon work? |
Make no sense to use, it need only to have the CAddonInfo (who becomes also stored) for binary addon creation. CAddon becomes created with CAddonInfo as value, the binary part need then only to read the CAddonInfo and destroy the CAddon. With that he gets it directly: binaryAddonList.push_back(BINARY_ADDON_LIST_ENTRY(!IsAddonDisabled(cp_addon->identifier), std::move(builder.GetAddonInfo()))); Otherwise must be the AddonPtr addon;
...
addon = builder.Build();
binaryAddonList.push_back(BINARY_ADDON_LIST_ENTRY(!IsAddonDisabled(cp_addon->identifier), addon));
... added who then make never needed work. |
0bb9b15
to
5119f63
Compare
jenkins build this please |
Needed from external places if something on CAddon construction need to changed.
Is for binary addons who do this job byself and not needed from here.
2ce6afe
to
31e90a1
Compare
31e90a1
to
fa02f65
Compare
Everything else that interface with addon manager use IAddon as the 'info' so it makes sense to do the same for binary addons. Even if you don't to directly need it. When you don't set an extension point there is 0 overhead of |
} | ||
|
||
for (auto addon : binaryAddonList) | ||
AddAddonBaseEntry(addon); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
bool CBinaryAddonManager::AddAddonBaseEntry(BINARY_ADDON_LIST_ENTRY& entry) | ||
{ | ||
BinaryAddonBasePtr base = std::make_shared<CBinaryAddonBase>(entry.second); | ||
if (!base->Create()) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This changes add a new binary addon manager who handle the addons on request. This way allow the use of several instances on the same addon. Currently only used on Visualization and Screensaver, but other binary addon types becomes on next steps changed to use them here. Further becomes on next changes everything related to binary addons moved to the new folder "./xbmc/addons/binary-addons". The old system is not changed!
fa02f65
to
105c23b
Compare
jenkins build this please |
Description
This changes add a new binary addon manager who handle the
addons on request.
This way allow the use of several instances on the same addon.
Currently only used on Visualization and Screensaver, but other binary
addon types becomes on next steps changed to use them here.
Further becomes on next changes everything related to binary addons
moved to the new folder "./xbmc/addons/binary-addons".
The old system is not changed!
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of change
Checklist: