11#include "c-api/addon_base.h"
19#include "tools/StringUtils.h"
61using HardwareContext = ADDON_HARDWARE_CONTEXT;
81inline char* AllocAndCopyString(
const char* source)
85 const size_t len{strlen(source) + 1};
86 char* target =
new char[len];
87 memcpy(target, source, len);
96inline void FreeString(
const char* str)
104inline void ReallocAndCopyString(
const char** stringToRealloc,
const char* stringToCopy)
106 FreeString(*stringToRealloc);
107 *stringToRealloc = AllocAndCopyString(stringToCopy);
113template<
typename CPP_CLASS,
typename C_STRUCT>
114inline static C_STRUCT** AllocAndCopyPointerArray(std::vector<CPP_CLASS>& sourceVector,
115 unsigned int& targetArraySize)
117 targetArraySize =
static_cast<unsigned int>(sourceVector.size());
118 if (targetArraySize > 0)
120 C_STRUCT** targetArray =
new C_STRUCT* [targetArraySize] {};
123 for (
auto& entry : sourceVector)
126 C_STRUCT** arrayElem{&targetArray[i]};
127 *arrayElem = entry.release();
138template<
typename CPP_CLASS,
typename C_STRUCT>
139inline static void FreeDynamicPointerArray(C_STRUCT** targetArray,
unsigned int targetArraySize)
141 for (
unsigned int i = 0; i < targetArraySize; ++i)
143 C_STRUCT** arrayElem{&targetArray[i]};
144 CPP_CLASS::FreeResources(*arrayElem);
147 delete[] targetArray;
153template<
typename CPP_CLASS,
typename C_STRUCT>
154inline static void FreeStaticPointerArray(C_STRUCT** targetArray,
unsigned int targetArraySize)
156 for (
unsigned int i = 0; i < targetArraySize; ++i)
158 C_STRUCT** arrayElem{&targetArray[i]};
161 delete[] targetArray;
204template<
class CPP_CLASS,
typename C_STRUCT>
208 CStructHdl() : m_cStructure(
new C_STRUCT()), m_owner(
true) {}
211 : m_cStructure(
new C_STRUCT(*cppClass.m_cStructure)), m_owner(
true)
215 explicit CStructHdl(
const C_STRUCT* cStructure)
216 : m_cStructure(
new C_STRUCT(*cStructure)), m_owner(
true)
220 explicit CStructHdl(C_STRUCT* cStructure) : m_cStructure(cStructure) { assert(cStructure); }
227 if (m_cStructure && !m_owner)
229 memcpy(m_cStructure, right.m_cStructure,
sizeof(C_STRUCT));
236 m_cStructure =
new C_STRUCT(*right.m_cStructure);
241 const CStructHdl& operator=(
const C_STRUCT& right)
245 if (m_cStructure == &right)
248 if (m_cStructure && !m_owner)
250 memcpy(m_cStructure, &right,
sizeof(C_STRUCT));
257 m_cStructure =
new C_STRUCT(*right);
268 operator C_STRUCT*() {
return m_cStructure; }
269 operator const C_STRUCT*()
const {
return m_cStructure; }
271 const C_STRUCT* GetCStructure()
const {
return m_cStructure; }
280 C_STRUCT* m_cStructure =
nullptr;
283 bool m_owner =
false;
286template<
class CPP_CLASS,
typename C_STRUCT>
292 memset(m_cStructure, 0,
sizeof(C_STRUCT));
296 : m_cStructure(
new C_STRUCT(*cppClass.m_cStructure)), m_owner(
true)
298 CPP_CLASS::AllocResources(cppClass.m_cStructure, m_cStructure);
302 : m_cStructure(
new C_STRUCT(*cStructure)), m_owner(
true)
304 CPP_CLASS::AllocResources(cStructure, m_cStructure);
317 CPP_CLASS::FreeResources(m_cStructure);
318 if (m_cStructure && !m_owner)
320 memcpy(m_cStructure, right.m_cStructure,
sizeof(C_STRUCT));
327 m_cStructure =
new C_STRUCT(*right.m_cStructure);
329 CPP_CLASS::AllocResources(right.m_cStructure, m_cStructure);
337 if (m_cStructure == &right)
340 CPP_CLASS::FreeResources(m_cStructure);
341 if (m_cStructure && !m_owner)
343 memcpy(m_cStructure, &right,
sizeof(C_STRUCT));
350 m_cStructure =
new C_STRUCT(*right);
352 CPP_CLASS::AllocResources(&right, m_cStructure);
360 CPP_CLASS::FreeResources(m_cStructure);
365 operator C_STRUCT*() {
return m_cStructure; }
366 operator const C_STRUCT*()
const {
return m_cStructure; }
368 const C_STRUCT* GetCStructure()
const {
return m_cStructure; }
377 C_STRUCT* m_cStructure =
nullptr;
380 bool m_owner =
false;
439 explicit CSettingValue(
const std::string& settingValue) : str(settingValue) {}
441 bool empty()
const {
return str.empty(); }
463 int GetInt()
const {
return std::atoi(str.c_str()); }
466 unsigned int GetUInt()
const {
return std::atoi(str.c_str()); }
469 bool GetBoolean()
const {
return std::atoi(str.c_str()) > 0; }
472 float GetFloat()
const {
return static_cast<float>(std::atof(str.c_str())); }
476 template<
typename enumType>
479 return static_cast<enumType
>(GetInt());
485 const std::string str;
519 KODI_ADDON_INSTANCE_TYPE
GetType()
const {
return m_instance->info->type; }
525 bool IsType(KODI_ADDON_INSTANCE_TYPE type)
const {
return m_instance->info->type == type; }
528 uint32_t
GetNumber()
const {
return m_instance->info->number; }
531 std::string
GetID()
const {
return m_instance->info->id; }
546 IInstanceInfo() =
delete;
547 IInstanceInfo(
const IInstanceInfo&) =
delete;
569 m_instance->functions->instance_setting_change_string = INSTANCE_instance_setting_change_string;
570 m_instance->functions->instance_setting_change_integer =
571 INSTANCE_instance_setting_change_integer;
572 m_instance->functions->instance_setting_change_boolean =
573 INSTANCE_instance_setting_change_boolean;
574 m_instance->functions->instance_setting_change_float = INSTANCE_instance_setting_change_float;
579 KODI_ADDON_INSTANCE_HDL& hdl)
581 return ADDON_STATUS_NOT_IMPLEMENTED;
584 std::string GetInstanceAPIVersion()
const {
return m_instance->info->version; }
586 virtual ADDON_STATUS SetInstanceSetting(
const std::string& settingName,
592 inline bool IsInstanceSettingUsingDefault(
const std::string& settingName)
594 return m_instance->info->functions->is_instance_setting_using_default(m_instance->info->kodi,
595 settingName.c_str());
598 inline std::string GetInstanceUserPath(
const std::string& append =
"")
600 using namespace kodi::addon;
602 char* str = m_instance->info->functions->get_instance_user_path(
603 CPrivateBase::m_interface->toKodi->kodiBase);
604 std::string ret = str;
605 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
609 if (append.at(0) !=
'\\' && append.at(0) !=
'/')
620 inline bool CheckInstanceSettingString(
const std::string& settingName, std::string& settingValue)
622 char* buffer =
nullptr;
623 bool ret = m_instance->info->functions->get_instance_setting_string(
624 m_instance->info->kodi, settingName.c_str(), &buffer);
628 settingValue = buffer;
634 inline std::string GetInstanceSettingString(
const std::string& settingName,
635 const std::string& defaultValue =
"")
637 std::string settingValue = defaultValue;
638 CheckInstanceSettingString(settingName, settingValue);
642 inline void SetInstanceSettingString(
const std::string& settingName,
643 const std::string& settingValue)
645 m_instance->info->functions->set_instance_setting_string(
646 m_instance->info->kodi, settingName.c_str(), settingValue.c_str());
649 inline bool CheckInstanceSettingInt(
const std::string& settingName,
int& settingValue)
652 return cb->get_instance_setting_int(m_instance->info->kodi, settingName.c_str(), &settingValue);
655 inline int GetInstanceSettingInt(
const std::string& settingName,
int defaultValue = 0)
657 int settingValue = defaultValue;
658 CheckInstanceSettingInt(settingName, settingValue);
662 inline void SetInstanceSettingInt(
const std::string& settingName,
int settingValue)
664 m_instance->info->functions->set_instance_setting_int(m_instance->info->kodi,
665 settingName.c_str(), settingValue);
668 inline bool CheckInstanceSettingBoolean(
const std::string& settingName,
bool& settingValue)
670 return m_instance->info->functions->get_instance_setting_bool(
671 m_instance->info->kodi, settingName.c_str(), &settingValue);
674 inline bool GetInstanceSettingBoolean(
const std::string& settingName,
bool defaultValue =
false)
676 bool settingValue = defaultValue;
677 CheckInstanceSettingBoolean(settingName, settingValue);
681 inline void SetInstanceSettingBoolean(
const std::string& settingName,
bool settingValue)
683 m_instance->info->functions->set_instance_setting_bool(m_instance->info->kodi,
684 settingName.c_str(), settingValue);
687 inline bool CheckInstanceSettingFloat(
const std::string& settingName,
float& settingValue)
689 return m_instance->info->functions->get_instance_setting_float(
690 m_instance->info->kodi, settingName.c_str(), &settingValue);
693 inline float GetInstanceSettingFloat(
const std::string& settingName,
float defaultValue = 0.0f)
695 float settingValue = defaultValue;
696 CheckInstanceSettingFloat(settingName, settingValue);
700 inline void SetInstanceSettingFloat(
const std::string& settingName,
float settingValue)
702 m_instance->info->functions->set_instance_setting_float(m_instance->info->kodi,
703 settingName.c_str(), settingValue);
706 template<
typename enumType>
707 inline bool CheckInstanceSettingEnum(
const std::string& settingName, enumType& settingValue)
709 using namespace kodi::addon;
711 int settingValueInt =
static_cast<int>(settingValue);
712 bool ret = m_instance->info->functions->get_instance_setting_int(
713 m_instance->info->kodi, settingName.c_str(), &settingValueInt);
715 settingValue =
static_cast<enumType
>(settingValueInt);
719 template<
typename enumType>
720 inline enumType GetInstanceSettingEnum(
const std::string& settingName,
721 enumType defaultValue =
static_cast<enumType
>(0))
723 enumType settingValue = defaultValue;
724 CheckInstanceSettingEnum(settingName, settingValue);
728 template<
typename enumType>
729 inline void SetInstanceSettingEnum(
const std::string& settingName, enumType settingValue)
731 m_instance->info->functions->set_instance_setting_int(
732 m_instance->info->kodi, settingName.c_str(),
static_cast<int>(settingValue));
736 static inline ADDON_STATUS INSTANCE_instance_setting_change_string(
737 const KODI_ADDON_INSTANCE_HDL hdl,
const char* name,
const char* value)
742 static inline ADDON_STATUS INSTANCE_instance_setting_change_boolean(
743 const KODI_ADDON_INSTANCE_HDL hdl,
const char* name,
bool value)
745 return static_cast<IAddonInstance*
>(hdl)->SetInstanceSetting(name,
749 static inline ADDON_STATUS INSTANCE_instance_setting_change_integer(
750 const KODI_ADDON_INSTANCE_HDL hdl,
const char* name,
int value)
756 static inline ADDON_STATUS INSTANCE_instance_setting_change_float(
757 const KODI_ADDON_INSTANCE_HDL hdl,
const char* name,
float value)
783 CPrivateBase::m_interface->toAddon->create =
nullptr;
784 CPrivateBase::m_interface->toAddon->destroy = ADDONBASE_Destroy;
785 CPrivateBase::m_interface->toAddon->create_instance = ADDONBASE_CreateInstance;
786 CPrivateBase::m_interface->toAddon->destroy_instance = ADDONBASE_DestroyInstance;
787 CPrivateBase::m_interface->toAddon->setting_change_string = ADDONBASE_setting_change_string;
788 CPrivateBase::m_interface->toAddon->setting_change_boolean = ADDONBASE_setting_change_boolean;
789 CPrivateBase::m_interface->toAddon->setting_change_integer = ADDONBASE_setting_change_integer;
790 CPrivateBase::m_interface->toAddon->setting_change_float = ADDONBASE_setting_change_float;
925 KODI_ADDON_INSTANCE_HDL& hdl)
927 return ADDON_STATUS_NOT_IMPLEMENTED;
948 std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper;
951 static inline void ADDONBASE_Destroy(
const KODI_ADDON_HDL hdl)
956 static inline ADDON_STATUS ADDONBASE_CreateInstance(
const KODI_ADDON_HDL hdl,
968 if (CPrivateBase::m_interface->firstKodiInstance == instance &&
969 CPrivateBase::m_interface->globalSingleInstance &&
970 static_cast<IAddonInstance*
>(CPrivateBase::m_interface->globalSingleInstance)
971 ->m_instance->info->type == instance->info->type)
976 instance->hdl = CPrivateBase::m_interface->globalSingleInstance;
988 if (instance->info->parent !=
nullptr)
990 ->CreateInstance(instanceInfo, instance->hdl);
993 if (status == ADDON_STATUS_NOT_IMPLEMENTED)
999 if (instance->hdl ==
nullptr)
1003 CPrivateBase::m_interface->toKodi->addon_log_msg(
1005 "kodi::addon::CAddonBase CreateInstance returned an "
1006 "empty instance pointer, but reported OK!");
1015 if (
static_cast<IAddonInstance*
>(instance->hdl)->m_instance->info->type != instance->info->type)
1017 CPrivateBase::m_interface->toKodi->addon_log_msg(
1019 "kodi::addon::CAddonBase CreateInstance difference between given and returned");
1021 instance->hdl =
nullptr;
1028 static inline void ADDONBASE_DestroyInstance(
const KODI_ADDON_HDL hdl,
1033 if (CPrivateBase::m_interface->globalSingleInstance ==
nullptr && instance->hdl != base)
1041 static inline ADDON_STATUS ADDONBASE_setting_change_string(
const KODI_ADDON_HDL hdl,
1048 static inline ADDON_STATUS ADDONBASE_setting_change_boolean(
const KODI_ADDON_HDL hdl,
1055 static inline ADDON_STATUS ADDONBASE_setting_change_integer(
const KODI_ADDON_HDL hdl,
1062 static inline ADDON_STATUS ADDONBASE_setting_change_float(
const KODI_ADDON_HDL hdl,
1077inline std::string ATTR_DLL_LOCAL
GetAddonPath(
const std::string& append =
"")
1079 using namespace kodi::addon;
1081 char* str = CPrivateBase::m_interface->toKodi->kodi_addon->get_addon_path(
1082 CPrivateBase::m_interface->toKodi->kodiBase);
1083 std::string ret = str;
1084 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase, str);
1085 if (!append.empty())
1087 if (append.at(0) !=
'\\' && append.at(0) !=
'/')
1088#ifdef TARGET_WINDOWS
1114inline std::string ATTR_DLL_LOCAL
GetLibPath(
const std::string& append =
"")
1116 using namespace kodi::addon;
1118 char* str = CPrivateBase::m_interface->toKodi->kodi_addon->get_lib_path(
1119 CPrivateBase::m_interface->toKodi->kodiBase);
1120 std::string ret = str;
1121 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase, str);
1122 if (!append.empty())
1124 if (append.at(0) !=
'\\' && append.at(0) !=
'/')
1125#ifdef TARGET_WINDOWS
1146inline std::string ATTR_DLL_LOCAL
GetUserPath(
const std::string& append =
"")
1148 using namespace kodi::addon;
1150 char* str = CPrivateBase::m_interface->toKodi->kodi_addon->get_user_path(
1151 CPrivateBase::m_interface->toKodi->kodiBase);
1152 std::string ret = str;
1153 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase, str);
1154 if (!append.empty())
1156 if (append.at(0) !=
'\\' && append.at(0) !=
'/')
1157#ifdef TARGET_WINDOWS
1179inline std::string ATTR_DLL_LOCAL
GetTempPath(
const std::string& append =
"")
1181 using namespace kodi::addon;
1183 char* str = CPrivateBase::m_interface->toKodi->kodi_addon->get_temp_path(
1184 CPrivateBase::m_interface->toKodi->kodiBase);
1185 std::string ret = str;
1186 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase, str);
1187 if (!append.empty())
1189 if (append.at(0) !=
'\\' && append.at(0) !=
'/')
1190#ifdef TARGET_WINDOWS
1229 const std::string& defaultStr =
"")
1231 using namespace kodi::addon;
1233 std::string retString = defaultStr;
1234 char* strMsg = CPrivateBase::m_interface->toKodi->kodi_addon->get_localized_string(
1235 CPrivateBase::m_interface->toKodi->kodiBase, labelId);
1236 if (strMsg !=
nullptr)
1238 if (std::strlen(strMsg))
1240 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1279 using namespace kodi::addon;
1280 return CPrivateBase::m_interface->toKodi->kodi_addon->open_settings_dialog(
1281 CPrivateBase::m_interface->toKodi->kodiBase);
1295 using namespace kodi::addon;
1296 return CPrivateBase::m_interface->toKodi->kodi_addon->is_setting_using_default(
1297 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str());
1325 std::string& settingValue)
1327 using namespace kodi::addon;
1329 char* buffer =
nullptr;
1330 bool ret = CPrivateBase::m_interface->toKodi->kodi_addon->get_setting_string(
1331 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), &buffer);
1335 settingValue = buffer;
1336 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1363 const std::string& defaultValue =
"")
1365 std::string settingValue = defaultValue;
1367 return settingValue;
1391 const std::string& settingValue)
1393 using namespace kodi::addon;
1395 CPrivateBase::m_interface->toKodi->kodi_addon->set_setting_string(
1396 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue.c_str());
1423inline bool ATTR_DLL_LOCAL
CheckSettingInt(
const std::string& settingName,
int& settingValue)
1425 using namespace kodi::addon;
1427 return CPrivateBase::m_interface->toKodi->kodi_addon->get_setting_int(
1428 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue);
1451inline int ATTR_DLL_LOCAL
GetSettingInt(
const std::string& settingName,
int defaultValue = 0)
1453 int settingValue = defaultValue;
1455 return settingValue;
1478inline void ATTR_DLL_LOCAL
SetSettingInt(
const std::string& settingName,
int settingValue)
1480 using namespace kodi::addon;
1482 CPrivateBase::m_interface->toKodi->kodi_addon->set_setting_int(
1483 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue);
1512 using namespace kodi::addon;
1514 return CPrivateBase::m_interface->toKodi->kodi_addon->get_setting_bool(
1515 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue);
1539 bool defaultValue =
false)
1541 bool settingValue = defaultValue;
1543 return settingValue;
1568 using namespace kodi::addon;
1570 CPrivateBase::m_interface->toKodi->kodi_addon->set_setting_bool(
1571 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue);
1600 using namespace kodi::addon;
1602 return CPrivateBase::m_interface->toKodi->kodi_addon->get_setting_float(
1603 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue);
1627 float defaultValue = 0.0f)
1629 float settingValue = defaultValue;
1631 return settingValue;
1654inline void ATTR_DLL_LOCAL
SetSettingFloat(
const std::string& settingName,
float settingValue)
1656 using namespace kodi::addon;
1658 CPrivateBase::m_interface->toKodi->kodi_addon->set_setting_float(
1659 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue);
1694template<
typename enumType>
1695inline bool ATTR_DLL_LOCAL
CheckSettingEnum(
const std::string& settingName, enumType& settingValue)
1697 using namespace kodi::addon;
1699 int settingValueInt =
static_cast<int>(settingValue);
1700 bool ret = CPrivateBase::m_interface->toKodi->kodi_addon->get_setting_int(
1701 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValueInt);
1703 settingValue =
static_cast<enumType
>(settingValueInt);
1736template<
typename enumType>
1738 enumType defaultValue =
static_cast<enumType
>(0))
1740 enumType settingValue = defaultValue;
1742 return settingValue;
1774template<
typename enumType>
1775inline void ATTR_DLL_LOCAL
SetSettingEnum(
const std::string& settingName, enumType settingValue)
1777 using namespace kodi::addon;
1779 CPrivateBase::m_interface->toKodi->kodi_addon->set_setting_int(
1780 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(),
1781 static_cast<int>(settingValue));
1815 using namespace kodi::addon;
1819 std::string strReturn;
1820 char* strMsg = toKodi->kodi_addon->get_addon_info(toKodi->kodiBase,
id.c_str());
1821 if (strMsg !=
nullptr)
1823 if (std::strlen(strMsg))
1825 toKodi->free_string(toKodi->kodiBase, strMsg);
1849inline void*
GetInterface(
const std::string& name,
const std::string& version)
1851 using namespace kodi::addon;
1855 return toKodi->kodi_addon->get_interface(toKodi->kodiBase, name.c_str(), version.c_str());
1871 using namespace kodi::addon;
1873 char* str = CPrivateBase::m_interface->toKodi->kodi_addon->get_type_version(
1874 CPrivateBase::m_interface->toKodi->kodiBase, type);
1875 std::string ret = str;
1876 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase, str);
1895 return "Lost Connection";
1897 return "Need Restart";
1899 return "Need Settings";
1901 return "Unknown error";
1903 return "Permanent failure";
1904 case ADDON_STATUS_NOT_IMPLEMENTED:
1905 return "Not implemented";
1938inline void ATTR_DLL_LOCAL
Log(
const ADDON_LOG loglevel,
const char* format, ...)
1940 using namespace kodi::addon;
1943 va_start(args, format);
1946 CPrivateBase::m_interface->toKodi->addon_log_msg(CPrivateBase::m_interface->toKodi->kodiBase,
1947 loglevel, str.c_str());
2047#define ADDONCREATOR(AddonClass) \
2048 extern "C" ATTR_DLL_EXPORT ADDON_STATUS ADDON_Create(KODI_HANDLE addonInterface) \
2050 using namespace kodi::addon; \
2051 CPrivateBase::m_interface = static_cast<AddonGlobalInterface*>(addonInterface); \
2052 CPrivateBase::m_interface->addonBase = new AddonClass; \
2053 return static_cast<CAddonBase*>(CPrivateBase::m_interface->addonBase)->Create(); \
2055 extern "C" ATTR_DLL_EXPORT const char* ADDON_GetTypeVersion(int type) \
2057 return kodi::addon::GetTypeVersion(type); \
2059 extern "C" ATTR_DLL_EXPORT const char* ADDON_GetTypeMinVersion(int type) \
2061 return kodi::addon::GetTypeMinVersion(type); \
2063 AddonGlobalInterface* kodi::addon::CPrivateBase::m_interface = nullptr;
Definition AddonBase.h:775
Definition AddonBase.h:437
Definition AddonBase.h:206
Definition AddonBase.h:288
Definition AddonBase.h:565
Definition AddonBase.h:498
ADDON_LOG
Definition addon_base.h:182
@ ADDON_LOG_FATAL
4 : To notify fatal unrecoverable errors, which can may also indicate upcoming crashes.
Definition addon_base.h:197
ADDON_STATUS
Definition addon_base.h:138
@ ADDON_STATUS_NEED_SETTINGS
Necessary settings are not yet set.
Definition addon_base.h:149
@ ADDON_STATUS_LOST_CONNECTION
A needed connection was lost.
Definition addon_base.h:143
@ ADDON_STATUS_OK
For everything OK and no error.
Definition addon_base.h:140
@ ADDON_STATUS_NEED_RESTART
Addon needs a restart inside Kodi.
Definition addon_base.h:146
@ ADDON_STATUS_UNKNOWN
Unknown and incomprehensible error.
Definition addon_base.h:152
@ ADDON_STATUS_PERMANENT_FAILURE
Permanent failure, like failing to resolve methods.
Definition addon_base.h:155
unsigned int GetUInt() const
To get settings value as unsigned integer.
Definition AddonBase.h:466
int GetInt() const
To get settings value as integer.
Definition AddonBase.h:463
bool GetBoolean() const
To get settings value as boolean.
Definition AddonBase.h:469
const std::string & GetString() const
To get settings value as string.
Definition AddonBase.h:460
float GetFloat() const
To get settings value as floating point.
Definition AddonBase.h:472
enumType GetEnum() const
To get settings value as enum.
Definition AddonBase.h:477
uint32_t GetNumber() const
Get optional identification number (usage relate to addon type).
Definition AddonBase.h:528
std::string GetID() const
Get optional identification string (usage relate to addon type).
Definition AddonBase.h:531
KODI_ADDON_INSTANCE_TYPE GetType() const
To get settings value as string.
Definition AddonBase.h:519
bool FirstInstance() const
Check this is first created instance by Kodi.
Definition AddonBase.h:537
bool IsType(KODI_ADDON_INSTANCE_TYPE type) const
Check asked type used on this class.
Definition AddonBase.h:525
std::string GetAPIVersion() const
Get API version from Kodi about instance.
Definition AddonBase.h:534
virtual ADDON_STATUS SetSetting(const std::string &settingName, const kodi::addon::CSettingValue &settingValue)
To inform addon about changed settings values.
Definition AddonBase.h:870
virtual ADDON_STATUS CreateInstance(const kodi::addon::IInstanceInfo &instance, KODI_ADDON_INSTANCE_HDL &hdl)
Instance created.
Definition AddonBase.h:924
virtual ~CAddonBase()=default
Destructor.
virtual ADDON_STATUS Create()
Main addon creation function.
Definition AddonBase.h:817
CAddonBase()
Addon base class constructor.
Definition AddonBase.h:781
virtual void DestroyInstance(const IInstanceInfo &instance, const KODI_ADDON_INSTANCE_HDL hdl)
Instance destroy.
Definition AddonBase.h:944
std::string ATTR_DLL_LOCAL GetLocalizedString(uint32_t labelId, const std::string &defaultStr="")
Returns an addon's localized 'unicode string'.
Definition AddonBase.h:1228
std::string ATTR_DLL_LOCAL GetTempPath(const std::string &append="")
To get a temporary path for the addon.
Definition AddonBase.h:1179
std::string ATTR_DLL_LOCAL TranslateAddonStatus(ADDON_STATUS status)
Get to related ADDON_STATUS a human readable text.
Definition AddonBase.h:1888
std::string ATTR_DLL_LOCAL GetLibPath(const std::string &append="")
This function gives OS associated executable binary path of the addon.
Definition AddonBase.h:1114
void * GetInterface(const std::string &name, const std::string &version)
Returns a function table to a named interface.
Definition AddonBase.h:1849
std::string ATTR_DLL_LOCAL GetUserPath(const std::string &append="")
To get the user-related folder of the addon.
Definition AddonBase.h:1146
std::string ATTR_DLL_LOCAL GetKodiTypeVersion(int type)
To get used version inside Kodi itself about asked type.
Definition AddonBase.h:1869
std::string ATTR_DLL_LOCAL GetAddonInfo(const std::string &id)
Returns the value of an addon property as a string.
Definition AddonBase.h:1813
std::string ATTR_DLL_LOCAL GetAddonPath(const std::string &append="")
To get the addon system installation folder.
Definition AddonBase.h:1077
void ATTR_DLL_LOCAL SetSettingInt(const std::string &settingName, int settingValue)
Set integer setting of addon.
Definition AddonBase.h:1478
bool ATTR_DLL_LOCAL CheckSettingFloat(const std::string &settingName, float &settingValue)
Check and get a floating point setting value.
Definition AddonBase.h:1598
bool ATTR_DLL_LOCAL CheckSettingInt(const std::string &settingName, int &settingValue)
Check and get a integer setting value.
Definition AddonBase.h:1423
void ATTR_DLL_LOCAL SetSettingString(const std::string &settingName, const std::string &settingValue)
Set string setting of addon.
Definition AddonBase.h:1390
bool ATTR_DLL_LOCAL OpenSettings()
Opens this Add-Ons settings dialog.
Definition AddonBase.h:1277
void ATTR_DLL_LOCAL SetSettingFloat(const std::string &settingName, float settingValue)
Set floating point setting of addon.
Definition AddonBase.h:1654
bool ATTR_DLL_LOCAL IsSettingUsingDefault(const std::string &settingName)
Check the given setting name is set to default value.
Definition AddonBase.h:1293
std::string ATTR_DLL_LOCAL GetSettingString(const std::string &settingName, const std::string &defaultValue="")
Get string setting value.
Definition AddonBase.h:1362
bool ATTR_DLL_LOCAL CheckSettingEnum(const std::string &settingName, enumType &settingValue)
Check and get a enum setting value.
Definition AddonBase.h:1695
bool ATTR_DLL_LOCAL CheckSettingBoolean(const std::string &settingName, bool &settingValue)
Check and get a boolean setting value.
Definition AddonBase.h:1510
void ATTR_DLL_LOCAL SetSettingEnum(const std::string &settingName, enumType settingValue)
Set enum setting of addon.
Definition AddonBase.h:1775
enumType ATTR_DLL_LOCAL GetSettingEnum(const std::string &settingName, enumType defaultValue=static_cast< enumType >(0))
Get enum setting value.
Definition AddonBase.h:1737
float ATTR_DLL_LOCAL GetSettingFloat(const std::string &settingName, float defaultValue=0.0f)
Get floating point setting value.
Definition AddonBase.h:1626
void ATTR_DLL_LOCAL SetSettingBoolean(const std::string &settingName, bool settingValue)
Set boolean setting of addon.
Definition AddonBase.h:1566
bool ATTR_DLL_LOCAL GetSettingBoolean(const std::string &settingName, bool defaultValue=false)
Get boolean setting value.
Definition AddonBase.h:1538
bool ATTR_DLL_LOCAL CheckSettingString(const std::string &settingName, std::string &settingValue)
Check and get a string setting value.
Definition AddonBase.h:1324
int ATTR_DLL_LOCAL GetSettingInt(const std::string &settingName, int defaultValue=0)
Get integer setting value.
Definition AddonBase.h:1451
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938
Main structure passed from kodi to addon with basic information needed to create add-on.
Definition addon_base.h:379
Callback function tables from addon to Kodi Set complete from Kodi!
Definition addon_base.h:326
Definition addon_base.h:220
Definition addon_base.h:268
Internal used structure to have stored C API data above and available for everything below.
Definition AddonBase.h:73