aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Morten Kvarving <spiff@kodi.tv>2018-02-07 14:26:48 +0100
committerGitHub <noreply@github.com>2018-02-07 14:26:48 +0100
commit0de231ad320f0f41424e4279eae7cb8436fa73f9 (patch)
tree50367f5cb00dc31457a7f2d1e88823ff07877991
parentebe2912767f170e3a14dc38b8f33adf7a68f1a44 (diff)
parentadb2c3529584d28b3c83feb46576620a83130d0d (diff)
Merge pull request #13486 from garbear/servicebroker
Remove ServiceBroker usage from FileExtensionProvider
-rw-r--r--xbmc/ServiceManager.cpp18
-rw-r--r--xbmc/utils/FileExtensionProvider.cpp19
-rw-r--r--xbmc/utils/FileExtensionProvider.h14
3 files changed, 35 insertions, 16 deletions
diff --git a/xbmc/ServiceManager.cpp b/xbmc/ServiceManager.cpp
index db63b45175..92e010aad8 100644
--- a/xbmc/ServiceManager.cpp
+++ b/xbmc/ServiceManager.cpp
@@ -72,8 +72,7 @@ bool CServiceManager::InitForTesting()
m_databaseManager.reset(new CDatabaseManager);
- m_fileExtensionProvider.reset(new CFileExtensionProvider());
-
+ m_binaryAddonManager.reset(new ADDON::CBinaryAddonManager());
m_addonMgr.reset(new ADDON::CAddonMgr());
if (!m_addonMgr->Init())
{
@@ -81,6 +80,15 @@ bool CServiceManager::InitForTesting()
return false;
}
+ if (!m_binaryAddonManager->Init())
+ {
+ CLog::Log(LOGFATAL, "CServiceManager::%s: Unable to initialize CBinaryAddonManager", __FUNCTION__);
+ return false;
+ }
+
+ m_fileExtensionProvider.reset(new CFileExtensionProvider(*m_addonMgr,
+ *m_binaryAddonManager));
+
init_level = 1;
return true;
}
@@ -88,8 +96,9 @@ bool CServiceManager::InitForTesting()
void CServiceManager::DeinitTesting()
{
init_level = 0;
- m_addonMgr.reset();
m_fileExtensionProvider.reset();
+ m_binaryAddonManager.reset();
+ m_addonMgr.reset();
m_databaseManager.reset();
m_profileManager.reset();
m_network.reset();
@@ -175,7 +184,8 @@ bool CServiceManager::InitStageTwo(const CAppParamParser &params)
m_gameRenderManager.reset(new RETRO::CGUIGameRenderManager);
- m_fileExtensionProvider.reset(new CFileExtensionProvider());
+ m_fileExtensionProvider.reset(new CFileExtensionProvider(*m_addonMgr,
+ *m_binaryAddonManager));
m_powerManager.reset(new CPowerManager());
m_powerManager->Initialize();
diff --git a/xbmc/utils/FileExtensionProvider.cpp b/xbmc/utils/FileExtensionProvider.cpp
index 7266d6c2b9..0650bef4c5 100644
--- a/xbmc/utils/FileExtensionProvider.cpp
+++ b/xbmc/utils/FileExtensionProvider.cpp
@@ -25,7 +25,6 @@
#include "addons/AddonManager.h"
#include "addons/binary-addons/BinaryAddonBase.h"
-#include "ServiceBroker.h"
using namespace ADDON;
@@ -35,20 +34,21 @@ const std::vector<TYPE> ADDON_TYPES = {
ADDON_AUDIODECODER
};
-CFileExtensionProvider::CFileExtensionProvider()
+CFileExtensionProvider::CFileExtensionProvider(ADDON::CAddonMgr &addonManager,
+ ADDON::CBinaryAddonManager &binaryAddonManager) :
+ m_addonManager(addonManager),
+ m_binaryAddonManager(binaryAddonManager)
{
m_advancedSettings = g_advancedSettingsRef;
SetAddonExtensions();
- if (CServiceBroker::IsBinaryAddonCacheUp())
- CServiceBroker::GetAddonMgr().Events().Subscribe(this, &CFileExtensionProvider::OnAddonEvent);
+ m_addonManager.Events().Subscribe(this, &CFileExtensionProvider::OnAddonEvent);
}
CFileExtensionProvider::~CFileExtensionProvider()
{
- if (CServiceBroker::IsBinaryAddonCacheUp())
- CServiceBroker::GetAddonMgr().Events().Unsubscribe(this);
+ m_addonManager.Events().Unsubscribe(this);
m_advancedSettings.reset();
m_addonExtensions.clear();
@@ -133,13 +133,10 @@ void CFileExtensionProvider::SetAddonExtensions()
void CFileExtensionProvider::SetAddonExtensions(const TYPE& type)
{
- if (!CServiceBroker::IsBinaryAddonCacheUp())
- return;
-
std::vector<std::string> extensions;
std::vector<std::string> fileFolderExtensions;
BinaryAddonBaseList addonInfos;
- CServiceBroker::GetBinaryAddonManager().GetAddonInfos(addonInfos, true, type);
+ m_binaryAddonManager.GetAddonInfos(addonInfos, true, type);
for (const auto& addonInfo : addonInfos)
{
std::string info = ADDON_VFS == type ? "@extensions" : "@extension";
@@ -169,7 +166,7 @@ void CFileExtensionProvider::OnAddonEvent(const AddonEvent& event)
{
for (auto &type : ADDON_TYPES)
{
- if (CServiceBroker::GetAddonMgr().HasType(event.id, type))
+ if (m_addonManager.HasType(event.id, type))
{
SetAddonExtensions(type);
break;
diff --git a/xbmc/utils/FileExtensionProvider.h b/xbmc/utils/FileExtensionProvider.h
index e46d2d9a54..06a563bd7a 100644
--- a/xbmc/utils/FileExtensionProvider.h
+++ b/xbmc/utils/FileExtensionProvider.h
@@ -23,10 +23,17 @@
#include "addons/AddonEvents.h"
#include "settings/AdvancedSettings.h"
+namespace ADDON
+{
+ class CAddonMgr;
+ class CBinaryAddonManager;
+}
+
class CFileExtensionProvider
{
public:
- CFileExtensionProvider();
+ CFileExtensionProvider(ADDON::CAddonMgr &addonManager,
+ ADDON::CBinaryAddonManager &binaryAddonManager);
~CFileExtensionProvider();
/*!
@@ -67,6 +74,11 @@ private:
void OnAddonEvent(const ADDON::AddonEvent& event);
+ // Construction properties
+ ADDON::CAddonMgr &m_addonManager;
+ ADDON::CBinaryAddonManager &m_binaryAddonManager;
+
+ // File extension properties
std::map<ADDON::TYPE, std::string> m_addonExtensions;
std::shared_ptr<CAdvancedSettings> m_advancedSettings;
std::map<ADDON::TYPE, std::string> m_addonFileFolderExtensions;