Skip to content

Commit

Permalink
Merge pull request xbmc#17813 from AlwinEsch/rework-filesystem
Browse files Browse the repository at this point in the history
[addons][filesystem][base] add some new functions, improvement, cleanups and doc rework
  • Loading branch information
AlwinEsch authored and Maven85 committed Aug 7, 2020
1 parent a2e2415 commit e22eda6
Show file tree
Hide file tree
Showing 29 changed files with 3,667 additions and 2,000 deletions.
17 changes: 7 additions & 10 deletions xbmc/addons/binary-addons/AddonDll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,8 @@ ADDON_STATUS CAddonDll::Create(ADDON_TYPE type, void* funcTable, void* info)

/* Call Create to make connections, initializing data or whatever is
needed to become the AddOn running */
ADDON_STATUS status = m_pDll->CreateEx_available()
? m_pDll->CreateEx(m_pHelpers->GetCallbacks(), kodi::addon::GetTypeVersion(ADDON_GLOBAL_MAIN), info)
: m_pDll->Create(m_pHelpers->GetCallbacks(), info);
ADDON_STATUS status = m_pDll->Create(m_pHelpers->GetCallbacks(),
kodi::addon::GetTypeVersion(ADDON_GLOBAL_MAIN), info);

if (status == ADDON_STATUS_OK)
{
Expand Down Expand Up @@ -236,9 +235,8 @@ ADDON_STATUS CAddonDll::Create(KODI_HANDLE firstKodiInstance)

/* Call Create to make connections, initializing data or whatever is
needed to become the AddOn running */
ADDON_STATUS status = m_pDll->CreateEx_available()
? m_pDll->CreateEx(&m_interface, kodi::addon::GetTypeVersion(ADDON_GLOBAL_MAIN), nullptr)
: m_pDll->Create(&m_interface, nullptr);
ADDON_STATUS status =
m_pDll->Create(&m_interface, kodi::addon::GetTypeVersion(ADDON_GLOBAL_MAIN), nullptr);

if (status == ADDON_STATUS_OK)
{
Expand Down Expand Up @@ -303,10 +301,9 @@ ADDON_STATUS CAddonDll::CreateInstance(ADDON_TYPE instanceType,
return ADDON_STATUS_PERMANENT_FAILURE;

KODI_HANDLE addonInstance = nullptr;
if (!m_interface.toAddon->create_instance_ex)
status = m_interface.toAddon->create_instance(instanceType, instanceID.c_str(), instance, &addonInstance, parentInstance);
else
status = m_interface.toAddon->create_instance_ex(instanceType, instanceID.c_str(), instance, &addonInstance, parentInstance, kodi::addon::GetTypeVersion(instanceType));
status = m_interface.toAddon->create_instance(instanceType, instanceID.c_str(), instance,
kodi::addon::GetTypeVersion(instanceType),
&addonInstance, parentInstance);

if (status == ADDON_STATUS_OK)
{
Expand Down
10 changes: 3 additions & 7 deletions xbmc/addons/binary-addons/DllAddon.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class DllAddonInterface
public:
virtual ~DllAddonInterface() = default;
virtual void GetAddon(void* pAddon) =0;
virtual ADDON_STATUS Create(void *cb, void *info) =0;
virtual ADDON_STATUS CreateEx(void *cb, const char* globalApiVersion, void *info) = 0;
virtual ADDON_STATUS Create(void* cb, const char* globalApiVersion, void* info) = 0;
virtual void Destroy() =0;
virtual ADDON_STATUS GetStatus() =0;
virtual ADDON_STATUS SetSetting(const char *settingName, const void *settingValue) =0;
Expand All @@ -29,9 +28,7 @@ class DllAddon : public DllDynamic, public DllAddonInterface
{
public:
DECLARE_DLL_WRAPPER_TEMPLATE(DllAddon)
DEFINE_METHOD2(ADDON_STATUS, Create, (void* p1, void* p2))
DEFINE_METHOD3(ADDON_STATUS, CreateEx, (void* p1, const char* p2, void* p3))
bool CreateEx_available() { return m_CreateEx != nullptr; }
DEFINE_METHOD3(ADDON_STATUS, Create, (void* p1, const char* p2, void* p3))
DEFINE_METHOD0(void, Destroy)
DEFINE_METHOD0(ADDON_STATUS, GetStatus)
DEFINE_METHOD2(ADDON_STATUS, SetSetting, (const char *p1, const void *p2))
Expand All @@ -40,9 +37,8 @@ class DllAddon : public DllDynamic, public DllAddonInterface
DEFINE_METHOD1(const char*, GetAddonTypeMinVersion, (int p1))
bool GetAddonTypeMinVersion_available() { return m_GetAddonTypeMinVersion != nullptr; }
BEGIN_METHOD_RESOLVE()
RESOLVE_METHOD_RENAME(get_addon,GetAddon)
RESOLVE_METHOD_RENAME_OPTIONAL(get_addon, GetAddon)
RESOLVE_METHOD_RENAME(ADDON_Create, Create)
RESOLVE_METHOD_RENAME_OPTIONAL(ADDON_CreateEx, CreateEx)
RESOLVE_METHOD_RENAME(ADDON_Destroy, Destroy)
RESOLVE_METHOD_RENAME(ADDON_GetStatus, GetStatus)
RESOLVE_METHOD_RENAME(ADDON_SetSetting, SetSetting)
Expand Down
35 changes: 19 additions & 16 deletions xbmc/addons/interfaces/AddonBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ bool Interface_Base::InitInterface(CAddonDll* addon,

addonInterface.libBasePath =
strdup(CSpecialProtocol::TranslatePath("special://xbmcbinaddons").c_str());
addonInterface.kodi_base_api_version = strdup(kodi::addon::GetTypeVersion(ADDON_GLOBAL_MAIN));
addonInterface.addonBase = nullptr;
addonInterface.globalSingleInstance = nullptr;
addonInterface.firstKodiInstance = firstKodiInstance;
Expand All @@ -45,6 +46,7 @@ bool Interface_Base::InitInterface(CAddonDll* addon,
// compatible with other versions
addonInterface.toKodi = new AddonToKodiFuncTable_Addon();
addonInterface.toKodi->kodiBase = addon;
addonInterface.toKodi->get_type_version = get_type_version;
addonInterface.toKodi->get_addon_path = get_addon_path;
addonInterface.toKodi->get_base_user_path = get_base_user_path;
addonInterface.toKodi->addon_log_msg = addon_log_msg;
Expand All @@ -58,6 +60,7 @@ bool Interface_Base::InitInterface(CAddonDll* addon,
addonInterface.toKodi->set_setting_string = set_setting_string;
addonInterface.toKodi->free_string = free_string;
addonInterface.toKodi->free_string_array = free_string_array;
addonInterface.toKodi->get_interface = get_interface;

// Related parts becomes set from addon headers, make here to nullptr to allow
// checks for right set of them
Expand All @@ -70,8 +73,6 @@ bool Interface_Base::InitInterface(CAddonDll* addon,
Interface_Network::Init(&addonInterface);
Interface_GUIGeneral::Init(&addonInterface);

addonInterface.toKodi->get_interface = get_interface;

return true;
}

Expand All @@ -85,6 +86,8 @@ void Interface_Base::DeInitInterface(AddonGlobalInterface& addonInterface)

if (addonInterface.libBasePath)
free(const_cast<char*>(addonInterface.libBasePath));
if (addonInterface.kodi_base_api_version)
free(const_cast<char*>(addonInterface.kodi_base_api_version));

delete addonInterface.toKodi;
delete addonInterface.toAddon;
Expand Down Expand Up @@ -131,6 +134,11 @@ bool Interface_Base::UpdateSettingInActiveDialog(CAddonDll* addon,
*/
//@{

char* Interface_Base::get_type_version(void* kodiBase, int type)
{
return strdup(kodi::addon::GetTypeVersion(type));
}

char* Interface_Base::get_addon_path(void* kodiBase)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
Expand Down Expand Up @@ -167,28 +175,23 @@ void Interface_Base::addon_log_msg(void* kodiBase, const int addonLogLevel, cons
int logLevel = LOGNONE;
switch (addonLogLevel)
{
case ADDON_LOG_FATAL:
logLevel = LOGFATAL;
break;
case ADDON_LOG_SEVERE:
logLevel = LOGSEVERE;
case ADDON_LOG_DEBUG:
logLevel = LOGDEBUG;
break;
case ADDON_LOG_ERROR:
logLevel = LOGERROR;
case ADDON_LOG_INFO:
logLevel = LOGINFO;
break;
case ADDON_LOG_WARNING:
logLevel = LOGWARNING;
break;
case ADDON_LOG_NOTICE:
logLevel = LOGNOTICE;
break;
case ADDON_LOG_INFO:
logLevel = LOGINFO;
case ADDON_LOG_ERROR:
logLevel = LOGERROR;
break;
case ADDON_LOG_DEBUG:
logLevel = LOGDEBUG;
case ADDON_LOG_FATAL:
logLevel = LOGFATAL;
break;
default:
logLevel = LOGDEBUG;
break;
}

Expand Down
1 change: 1 addition & 0 deletions xbmc/addons/interfaces/AddonBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct Interface_Base
* class.
*/
//@{
static char* get_type_version(void* kodiBase, int type);
static char* get_addon_path(void* kodiBase);
static char* get_base_user_path(void* kodiBase);
static void addon_log_msg(void* kodiBase, const int addonLogLevel, const char* strMessage);
Expand Down
Loading

0 comments on commit e22eda6

Please sign in to comment.