Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added: basic cpluff support

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@29798 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information...
commit 1b2781c7c992aaaaae18cae1ef43ee7d4aa4c80b 1 parent 3ca7ae2
alcoheca authored
View
1  xbmc/DllPaths_generated.h.in
@@ -2,6 +2,7 @@
#define DLL_PATHS_GENERATED_H_
/* libraries */
+#define DLL_PATH_CPLUFF "special://xbmc/system/libcpluff-@ARCH@.so"
#define DLL_PATH_IMAGELIB "special://xbmc/system/ImageLib-@ARCH@.so"
#define DLL_PATH_LIBEXIF "special://xbmc/system/libexif-@ARCH@.so"
#define DLL_PATH_LIBID3TAG "special://xbmc/system/libid3tag-@ARCH@.so"
View
1  xbmc/DllPaths_win32.h
@@ -2,6 +2,7 @@
#define DLL_PATHS_WIN32_H_
/* libraries */
+#define DLL_PATH_CPLUFF "special://xbmc/system/cpluff.dll"
#define DLL_PATH_IMAGELIB "special://xbmc/system/ImageLib.dll"
#define DLL_PATH_LIBEXIF "special://xbmc/system/libexif.dll"
#define DLL_PATH_LIBID3TAG "special://xbmc/system/libid3tag.dll"
View
24 xbmc/addons/Addon.cpp
@@ -218,11 +218,29 @@ CStdString AddonVersion::Print() const
return CStdString(out);
}
+AddonProps::AddonProps(cp_plugin_info_t *props)
+ : id(props->identifier)
+ , version(props->version)
+{}
+
/**
* CAddon
*
*/
+CAddon::CAddon(cp_plugin_info_t *props)
+ : m_props(props)
+ , m_parent(AddonPtr())
+{
+ if (m_props.libname.IsEmpty()) BuildLibName();
+ else m_strLibName = m_props.libname;
+ BuildProfilePath();
+ CUtil::AddFileToFolder(Profile(), "settings.xml", m_userSettingsPath);
+ m_enabled = true;
+ m_hasStrings = false;
+ m_checkedStrings = false;
+}
+
CAddon::CAddon(const AddonProps &props)
: m_props(props)
, m_parent(AddonPtr())
@@ -529,6 +547,12 @@ const CStdString CAddon::Icon() const
*
*/
+CAddonLibrary::CAddonLibrary(cp_plugin_info_t *props)
+ : CAddon(props)
+ , m_addonType(SetAddonType())
+{
+}
+
CAddonLibrary::CAddonLibrary(const AddonProps& props)
: CAddon(props)
, m_addonType(SetAddonType())
View
6 xbmc/addons/Addon.h
@@ -30,6 +30,8 @@
class CURL;
class TiXmlElement;
+typedef struct cp_plugin_info_t cp_plugin_info_t;
+
namespace ADDON
{
@@ -64,6 +66,8 @@ class AddonProps
{
}
+ AddonProps(cp_plugin_info_t *props);
+
AddonProps(const AddonPtr &addon)
: id(addon->ID())
, type(addon->Type())
@@ -108,6 +112,7 @@ class CAddon : public IAddon
{
public:
CAddon(const AddonProps &addonprops);
+ CAddon(cp_plugin_info_t *props);
virtual ~CAddon() {}
virtual AddonPtr Clone(const AddonPtr& parent) const;
@@ -179,6 +184,7 @@ class CAddonLibrary : public CAddon
{
public:
CAddonLibrary(const AddonProps &props);
+ CAddonLibrary(cp_plugin_info_t *props);
private:
virtual bool IsAddonLibrary() { return true; }
View
11 xbmc/addons/AddonDll.h
@@ -38,6 +38,7 @@ namespace ADDON
{
public:
CAddonDll(const AddonProps &props);
+ CAddonDll(cp_plugin_info_t *props);
virtual ~CAddonDll();
AddonPtr Clone() const;
virtual ADDON_STATUS GetStatus();
@@ -76,6 +77,16 @@ namespace ADDON
};
template<class TheDll, typename TheStruct, typename TheProps>
+CAddonDll<TheDll, TheStruct, TheProps>::CAddonDll(cp_plugin_info_t *props)
+ : CAddon(props)
+{
+ m_pStruct = NULL;
+ m_initialized = false;
+ m_pDll = NULL;
+ m_pInfo = NULL;
+}
+
+template<class TheDll, typename TheStruct, typename TheProps>
CAddonDll<TheDll, TheStruct, TheProps>::CAddonDll(const AddonProps &props)
: CAddon(props)
{
View
145 xbmc/addons/AddonManager.cpp
@@ -21,6 +21,7 @@
#include "AddonManager.h"
#include "Addon.h"
#include "AddonDatabase.h"
+#include "DllLibCPluff.h"
#include "StringUtils.h"
#include "RegExp.h"
#include "XMLUtils.h"
@@ -31,6 +32,7 @@
#include "Settings.h"
#include "GUISettings.h"
#include "DownloadQueueManager.h"
+#include "AdvancedSettings.h"
#include "log.h"
#ifdef HAS_VISUALISATION
@@ -61,6 +63,28 @@ namespace ADDON
CAddonMgr* CAddonMgr::m_pInstance = NULL;
map<TYPE, IAddonMgrCallback*> CAddonMgr::m_managers;
+AddonPtr AddonFactory(const cp_extension_t *props)
+{
+ const TYPE type = TranslateType(props->ext_point_id);
+ switch (type)
+ {
+ case ADDON_PLUGIN:
+ case ADDON_SCRIPT:
+ return AddonPtr(new CAddon(props->plugin));
+ case ADDON_SCRAPER:
+ return AddonPtr(new CScraper(props->plugin));
+ case ADDON_VIZ:
+ return AddonPtr(new CVisualisation(props->plugin));
+ case ADDON_SCREENSAVER:
+ return AddonPtr(new CScreenSaver(props->plugin));
+ case ADDON_SCRAPER_LIBRARY:
+ case ADDON_VIZ_LIBRARY:
+ return AddonPtr(new CAddonLibrary(props->plugin));
+ default:
+ return AddonPtr();
+ }
+}
+
CAddonMgr::CAddonMgr()
{
FindAddons();
@@ -69,6 +93,8 @@ CAddonMgr::CAddonMgr()
CAddonMgr::~CAddonMgr()
{
+ if(m_cpluff)
+ m_cpluff->destroy();
}
CAddonMgr* CAddonMgr::Get()
@@ -104,6 +130,61 @@ void CAddonMgr::UnregisterAddonMgrCallback(TYPE type)
m_managers.erase(type);
}
+bool CAddonMgr::Init()
+{
+ m_cpluff = new DllLibCPluff;
+ m_cpluff->Load();
+
+ if (!m_cpluff->IsLoaded())
+ {
+ CLog::Log(LOGERROR, "ADDONS: Fatal Error, could not load cpluff");
+ assert(false);
+ }
+
+ cp_log_severity_t log;
+ if (g_advancedSettings.m_logLevel >= LOG_LEVEL_DEBUG_SAMBA)
+ log = CP_LOG_DEBUG;
+ else if (g_advancedSettings.m_logLevel >= LOG_LEVEL_DEBUG)
+ log = CP_LOG_INFO;
+ else
+ log = CP_LOG_WARNING;
+ m_cpluff->set_fatal_error_handler(cp_fatalErrorHandler);
+
+ cp_status_t status;
+ status = m_cpluff->init();
+ if (status != CP_OK)
+ {
+ CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_init() returned status: %i", status);
+ assert(false);
+ }
+
+ //TODO could separate addons into different contexts
+ // would allow partial unloading of addon framework
+ m_cp_context = m_cpluff->create_context(&status);
+ assert(m_cp_context);
+ if (!CSpecialProtocol::XBMCIsHome())
+ {
+ status = m_cpluff->register_pcollection(m_cp_context, _P("special://home/addons/cpluff"));
+ assert(status == CP_OK);
+ }
+ status = m_cpluff->register_pcollection(m_cp_context, _P("special://xbmc/addons/cpluff"));
+ assert(status == CP_OK);
+ status = m_cpluff->register_logger(m_cp_context, cp_logger, &CAddonMgr::m_pInstance, CP_LOG_INFO);
+ assert(status == CP_OK);
+ status = m_cpluff->scan_plugins(m_cp_context, 0);
+}
+
+bool CAddonMgr::HasAddons2(const TYPE &type, const CONTENT_TYPE &content/*= CONTENT_NONE*/)
+{
+ cp_status_t status;
+ int num;
+ CStdString ext_point(TranslateType(type));
+ cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
+ if (status == CP_OK)
+ return (num > 0);
+ return false;
+}
+
bool CAddonMgr::HasAddons(const TYPE &type, const CONTENT_TYPE &content/*= CONTENT_NONE*/, bool enabledOnly/*= true*/)
{
if (m_addons.empty())
@@ -137,6 +218,22 @@ bool CAddonMgr::GetAllAddons(VECADDONS &addons, bool enabledOnly/*= true*/)
return !addons.empty();
}
+bool CAddonMgr::GetAddons2(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content)
+{
+ cp_status_t status;
+ int num;
+ CStdString ext_point(TranslateType(type));
+ cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
+ for(int i=0; i <num; i++)
+ {
+ AddonPtr addon(AddonFactory(exts[i]));
+ if (addon)
+ addons.push_back(addon);
+ }
+ m_cpluff->release_info(m_cp_context, exts);
+ return addons.size();
+}
+
bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content/*= CONTENT_NONE*/, bool enabledOnly/*= true*/)
{
CSingleLock lock(m_critSection);
@@ -193,6 +290,13 @@ bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &typ
return false;
}
+AddonPtr CAddonMgr::GetAddon2(const CStdString &str)
+{
+ CSingleLock lock(m_critSection);
+
+ return AddonPtr();
+}
+
//TODO handle all 'default' cases here, not just scrapers & vizs
bool CAddonMgr::GetDefault(const TYPE &type, AddonPtr &addon, const CONTENT_TYPE &content)
{
@@ -746,5 +850,46 @@ void CAddonMgr::OnJobComplete(unsigned int jobID, bool success, CJob* job)
((CRepositoryUpdateJob*)job)->m_repo->SetUpdated(CDateTime::GetCurrentDateTime());
}
+/*
+ * libcpluff interaction
+ */
+
+void CAddonMgr::CPluffFatalError(const char *msg)
+{
+ CLog::Log(LOGERROR, "ADDONS: CPluffFatalError(%s)", msg);
+}
+
+int cp_to_clog(cp_log_severity_t lvl)
+{
+ if( lvl == CP_LOG_DEBUG )
+ return 0;
+ else if (lvl == CP_LOG_INFO)
+ return 1;
+ else if (lvl == CP_LOG_WARNING)
+ return 3;
+ else
+ return 4;
+}
+
+cp_log_severity_t clog_to_cp(int lvl)
+{
+ if (lvl >= 4)
+ return CP_LOG_ERROR;
+ else if (lvl == 3)
+ return CP_LOG_WARNING;
+ else if (lvl >= 1)
+ return CP_LOG_INFO;
+ else
+ return CP_LOG_DEBUG;
+}
+
+void CAddonMgr::CPluffLog(cp_log_severity_t level, const char *msg, const char *apid, void *user_data)
+{
+ if(!apid)
+ CLog::Log(LOGDEBUG, "ADDON: '%s'", msg);
+ else
+ CLog::Log(LOGDEBUG, "ADDON: '%s' reports '%s'", apid, msg);
+}
+
} /* namespace ADDON */
View
25 xbmc/addons/AddonManager.h
@@ -29,6 +29,12 @@
#include <vector>
#include <map>
+class DllLibCPluff;
+extern "C"
+{
+#include "lib/cpluff/libcpluff/cpluff.h"
+}
+
namespace ADDON
{
typedef std::vector<AddonPtr> VECADDONS;
@@ -68,6 +74,7 @@ namespace ADDON
{
public:
static CAddonMgr* Get();
+ bool Init();
virtual ~CAddonMgr();
IAddonMgrCallback* GetCallbackForType(TYPE type);
@@ -77,8 +84,11 @@ namespace ADDON
/* Addon access */
bool GetDefault(const TYPE &type, AddonPtr &addon, const CONTENT_TYPE &content = CONTENT_NONE);
bool GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type = ADDON_UNKNOWN, bool enabledOnly = true);
+ AddonPtr GetAddon2(const CStdString &str);
bool HasAddons(const TYPE &type, const CONTENT_TYPE &content = CONTENT_NONE, bool enabledOnly = true);
+ bool HasAddons2(const TYPE &type, const CONTENT_TYPE &content = CONTENT_NONE);
bool GetAddons(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content = CONTENT_NONE, bool enabled = true);
+ bool GetAddons2(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content = CONTENT_NONE);
bool GetAllAddons(VECADDONS &addons, bool enabledOnly = true);
CStdString GetString(const CStdString &id, const int number);
@@ -93,6 +103,21 @@ namespace ADDON
std::map<CStdString, AddonPtr>& unresolved);
void OnJobComplete(unsigned int jobID, bool sucess, CJob* job);
+
+ /* libcpluff */
+ bool GetExtensions(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content);
+ void CPluffFatalError(const char *msg);
+ void CPluffLog(cp_log_severity_t level, const char *msg, const char *apid, void *user_data);
+ cp_context_t *m_cp_context;
+ DllLibCPluff *m_cpluff;
+
+ static void cp_fatalErrorHandler(const char *msg) {
+ CAddonMgr::Get()->CPluffFatalError(msg);
+ }
+ static void cp_logger(cp_log_severity_t level, const char *msg, const char *apid, void *user_data) {
+ CAddonMgr::Get()->CPluffLog(level, msg, apid, user_data);
+ }
+
private:
bool DependenciesMet(AddonPtr &addon);
bool UpdateIfKnown(AddonPtr &addon);
View
2  xbmc/addons/DllLibCPluff.h
@@ -56,7 +56,7 @@ class DllLibCPluffInterface
class DllLibCPluff : public DllDynamic, DllLibCPluffInterface
{
- DECLARE_DLL_WRAPPER(DllLibCPluff, DLL_PATH_LIBCPLUFF)
+ DECLARE_DLL_WRAPPER(DllLibCPluff, DLL_PATH_CPLUFF)
DEFINE_METHOD0(const char*, get_version)
DEFINE_METHOD1(void, set_fatal_error_handler, (cp_fatal_error_func_t p1))
DEFINE_METHOD0(cp_status_t, init)
View
1  xbmc/addons/Scraper.h
@@ -31,6 +31,7 @@ namespace ADDON
{
public:
CScraper(const AddonProps &props) : CAddon(props) { }
+ CScraper(cp_plugin_info_t *props) : CAddon(props) { }
virtual ~CScraper() {}
virtual AddonPtr Clone(const AddonPtr &self) const;
View
3  xbmc/addons/ScreenSaver.h
@@ -29,7 +29,8 @@ namespace ADDON
class CScreenSaver : public ADDON::CAddonDll<DllScreenSaver, ScreenSaver, SCR_PROPS>
{
public:
- CScreenSaver(const ADDON::AddonProps& props) : ADDON::CAddonDll<DllScreenSaver, ScreenSaver, SCR_PROPS>(props) {};
+ CScreenSaver(const AddonProps &props) : ADDON::CAddonDll<DllScreenSaver, ScreenSaver, SCR_PROPS>(props) {};
+ CScreenSaver(cp_plugin_info_t *props) : ADDON::CAddonDll<DllScreenSaver, ScreenSaver, SCR_PROPS>(props) {};
virtual ~CScreenSaver() {}
// Things that MUST be supplied by the child classes
View
1  xbmc/addons/Visualisation.h
@@ -54,6 +54,7 @@ namespace ADDON
{
public:
CVisualisation(const ADDON::AddonProps &props) : CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>(props) {}
+ CVisualisation(cp_plugin_info_t *props) : CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>(props) {}
virtual void OnInitialize(int iChannels, int iSamplesPerSec, int iBitsPerSample);
virtual void OnAudioData(const unsigned char* pAudioData, int iAudioDataLength);
bool Create(int x, int y, int w, int h);
Please sign in to comment.
Something went wrong with that request. Please try again.