Skip to content
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

Merged
merged 3 commits into from Jun 17, 2017

Conversation

AlwinEsch
Copy link
Member

@AlwinEsch AlwinEsch commented Jun 14, 2017

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the Code guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the CONTRIBUTING document
  • I have added tests to cover my change
  • All new and existing tests passed

@AlwinEsch AlwinEsch changed the title [addons] add CBinaraAddonManager (currently only to ask) [addons] add CBinaryAddonManager (currently only to ask) Jun 14, 2017
@tamland
Copy link
Member

tamland commented Jun 14, 2017

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.

@AlwinEsch AlwinEsch force-pushed the another-addon-way branch 2 times, most recently from cf05f24 to bfab227 Compare June 15, 2017 07:19
@AlwinEsch AlwinEsch changed the title [addons] add CBinaryAddonManager (currently only to ask) [addons] make binary addon management independent Jun 15, 2017
@AlwinEsch AlwinEsch added Component: Binary add-ons Type: Feature non-breaking change which adds functionality v18 Leia labels Jun 15, 2017
@AlwinEsch AlwinEsch added this to the L 18.0-alpha1 milestone Jun 15, 2017
@AlwinEsch
Copy link
Member Author

The request is now complete updated and use a working way.

Copy link
Member

@ksooo ksooo left a 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...

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.

return *m_binaryAddonManager.get();
}


This comment was marked as spam.

std::vector<CAddonBuilder> builders;
m_database.GetInstalled(builders);

for (auto& builder : builders)

This comment was marked as spam.

@@ -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.

CBinaryAddonBase::CBinaryAddonBase(const std::string& addonPath)
{

m_usable = false;

This comment was marked as spam.

CBinaryAddonManager::CBinaryAddonManager()
{

}

This comment was marked as spam.

CBinaryAddonManager::~CBinaryAddonManager()
{

}

This comment was marked as spam.

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.


for (auto addon : binaryAddonList)
{
BinaryAddonBase base = std::make_shared<CBinaryAddonBase>(addon.first);

This comment was marked as spam.

This comment was marked as spam.

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.

Copy link
Member

@ksooo ksooo left a 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...

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.

@@ -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.

@@ -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.

AddonPtr addon = CServiceBroker::GetBinaryAddonManager().GetRunningAddon(ID());
if (addon)
return addon;
return AddonPtr();

This comment was marked as spam.

This comment was marked as spam.

}
m_installedAddons[base->ID()] = base;
if (std::get<1>(addon))
m_enabledAddons[base->ID()] = base;

This comment was marked as spam.

* @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.

* @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.

* 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.

* 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.

CSingleLock lock(m_critSection);

BINARY_ADDON_LIST binaryAddonList;
CAddonMgr::GetInstance().GetInstalledBinaryAddonPaths(binaryAddonList);

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@AlwinEsch AlwinEsch force-pushed the another-addon-way branch 2 times, most recently from b70b429 to 0bb9b15 Compare June 16, 2017 03:55
@AlwinEsch
Copy link
Member Author

Is complete updated, instead of the CAddon use it CAddonInfo who was created by CAddonBuilder.

Copy link
Member

@ksooo ksooo left a 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...

@@ -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.

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.

This comment was marked as spam.

@@ -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.

This comment was marked as spam.

This comment was marked as spam.

CSingleLock lock(m_critSection);

auto addon = m_installedAddons.find(addonId);
if (addon != m_installedAddons.end() && addon->second)

This comment was marked as spam.

return URIUtils::AddFileToFolder(m_path, m_libname);
}

const char* CBinaryAddonType::GetPlatformLibraryName(const TiXmlElement* element)

This comment was marked as spam.

@tamland
Copy link
Member

tamland commented Jun 16, 2017

Is complete updated, instead of the CAddon use it CAddonInfo who was created by CAddonBuilder.

Why didn't using CAddon work?

@AlwinEsch
Copy link
Member Author

AlwinEsch commented Jun 16, 2017

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.

@AlwinEsch
Copy link
Member Author

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.
@AlwinEsch AlwinEsch force-pushed the another-addon-way branch 2 times, most recently from 2ce6afe to 31e90a1 Compare June 17, 2017 07:08
@tamland
Copy link
Member

tamland commented Jun 17, 2017

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.

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 Build() (it just calls the CAddon constructor). If it's impossible to do now, at the very least be prepared to fix it later

}

for (auto addon : binaryAddonList)
AddAddonBaseEntry(addon);

This comment was marked as spam.

This comment was marked as spam.

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 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!
@AlwinEsch
Copy link
Member Author

jenkins build this please

@AlwinEsch AlwinEsch merged commit 5e81f25 into xbmc:master Jun 17, 2017
@AlwinEsch AlwinEsch deleted the another-addon-way branch June 27, 2017 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Binary add-ons Type: Feature non-breaking change which adds functionality v18 Leia
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants