Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
AddonBase.h
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "c-api/addon_base.h"
12#include "versions.h"
13
14#include <assert.h> /* assert */
15#include <stdarg.h> /* va_list, va_start, va_arg, va_end */
16
17#ifdef __cplusplus
18
19#include "tools/StringUtils.h"
20
21#include <cstdlib>
22#include <cstring>
23#include <ctime>
24#include <memory>
25#include <stdexcept>
26#include <string>
27#include <vector>
28
29namespace kodi
30{
31
32namespace gui
33{
34struct IRenderHelper;
35} /* namespace gui */
36
37//==============================================================================
61using HardwareContext = ADDON_HARDWARE_CONTEXT;
63//------------------------------------------------------------------------------
64
65namespace addon
66{
67
72struct ATTR_DLL_LOCAL CPrivateBase
73{
74 // Interface function table to hold addresses on add-on and from kodi
75 static AddonGlobalInterface* m_interface;
76};
77
81inline char* AllocAndCopyString(const char* source)
82{
83 if (source)
84 {
85 const size_t len{strlen(source) + 1};
86 char* target = new char[len];
87 memcpy(target, source, len);
88 return target;
89 }
90 return nullptr;
91}
92
96inline void FreeString(const char* str)
97{
98 delete[] str;
99}
100
104inline void ReallocAndCopyString(const char** stringToRealloc, const char* stringToCopy)
105{
106 FreeString(*stringToRealloc);
107 *stringToRealloc = AllocAndCopyString(stringToCopy);
108}
109
113template<typename CPP_CLASS, typename C_STRUCT>
114inline static C_STRUCT** AllocAndCopyPointerArray(std::vector<CPP_CLASS>& sourceVector,
115 unsigned int& targetArraySize)
116{
117 targetArraySize = static_cast<unsigned int>(sourceVector.size());
118 if (targetArraySize > 0)
119 {
120 C_STRUCT** targetArray = new C_STRUCT* [targetArraySize] {};
121
122 unsigned int i{0};
123 for (auto& entry : sourceVector)
124 {
125 // Assign data to target array. Take pointer ownership.
126 C_STRUCT** arrayElem{&targetArray[i]};
127 *arrayElem = entry.release();
128 ++i;
129 }
130 return targetArray;
131 }
132 return nullptr;
133}
134
138template<typename CPP_CLASS, typename C_STRUCT>
139inline static void FreeDynamicPointerArray(C_STRUCT** targetArray, unsigned int targetArraySize)
140{
141 for (unsigned int i = 0; i < targetArraySize; ++i)
142 {
143 C_STRUCT** arrayElem{&targetArray[i]};
144 CPP_CLASS::FreeResources(*arrayElem);
145 delete *arrayElem;
146 }
147 delete[] targetArray;
148}
149
153template<typename CPP_CLASS, typename C_STRUCT>
154inline static void FreeStaticPointerArray(C_STRUCT** targetArray, unsigned int targetArraySize)
155{
156 for (unsigned int i = 0; i < targetArraySize; ++i)
157 {
158 C_STRUCT** arrayElem{&targetArray[i]};
159 delete *arrayElem;
160 }
161 delete[] targetArray;
162}
163
164/*
165 * Internally used helper class to manage processing of a "C" structure in "CPP"
166 * class.
167 *
168 * At constant, the "C" structure is copied, otherwise the given pointer is
169 * superseded and is changeable.
170 *
171 * -----------------------------------------------------------------------------
172 *
173 * Example:
174 *
175 * ~~~~~~~~~~~~~{.cpp}
176 * extern "C" typedef struct C_SAMPLE_DATA
177 * {
178 * unsigned int iUniqueId;
179 * } C_SAMPLE_DATA;
180 *
181 * class CPPSampleData : public CStructHdl<CPPSampleData, C_SAMPLE_DATA>
182 * {
183 * public:
184 * CPPSampleData() = default;
185 * CPPSampleData(const CPPSampleData& sample) : CStructHdl(sample) { }
186 * CPPSampleData(const C_SAMPLE_DATA* sample) : CStructHdl(sample) { }
187 * CPPSampleData(C_SAMPLE_DATA* sample) : CStructHdl(sample) { }
188 *
189 * void SetUniqueId(unsigned int uniqueId) { m_cStructure->iUniqueId = uniqueId; }
190 * unsigned int GetUniqueId() const { return m_cStructure->iUniqueId; }
191 * };
192 *
193 * ~~~~~~~~~~~~~
194 *
195 * It also works with the following example:
196 *
197 * ~~~~~~~~~~~~~{.cpp}
198 * CPPSampleData test;
199 * // Some work
200 * C_SAMPLE_DATA* data = test;
201 * // Give "data" to Kodi
202 * ~~~~~~~~~~~~~
203 */
204template<class CPP_CLASS, typename C_STRUCT>
206{
207public:
208 CStructHdl() : m_cStructure(new C_STRUCT()), m_owner(true) {}
209
210 CStructHdl(const CStructHdl& cppClass)
211 : m_cStructure(new C_STRUCT(*cppClass.m_cStructure)), m_owner(true)
212 {
213 }
214
215 explicit CStructHdl(const C_STRUCT* cStructure)
216 : m_cStructure(new C_STRUCT(*cStructure)), m_owner(true)
217 {
218 }
219
220 explicit CStructHdl(C_STRUCT* cStructure) : m_cStructure(cStructure) { assert(cStructure); }
221
222 const CStructHdl& operator=(const CStructHdl& right)
223 {
224 if (this == &right)
225 return *this;
226
227 if (m_cStructure && !m_owner)
228 {
229 memcpy(m_cStructure, right.m_cStructure, sizeof(C_STRUCT));
230 }
231 else
232 {
233 if (m_owner)
234 delete m_cStructure;
235 m_owner = true;
236 m_cStructure = new C_STRUCT(*right.m_cStructure);
237 }
238 return *this;
239 }
240
241 const CStructHdl& operator=(const C_STRUCT& right)
242 {
243 assert(&right);
244
245 if (m_cStructure == &right)
246 return *this;
247
248 if (m_cStructure && !m_owner)
249 {
250 memcpy(m_cStructure, &right, sizeof(C_STRUCT));
251 }
252 else
253 {
254 if (m_owner)
255 delete m_cStructure;
256 m_owner = true;
257 m_cStructure = new C_STRUCT(*right);
258 }
259 return *this;
260 }
261
262 virtual ~CStructHdl()
263 {
264 if (m_owner)
265 delete m_cStructure;
266 }
267
268 operator C_STRUCT*() { return m_cStructure; }
269 operator const C_STRUCT*() const { return m_cStructure; }
270
271 const C_STRUCT* GetCStructure() const { return m_cStructure; }
272
273 C_STRUCT* release()
274 {
275 m_owner = false;
276 return m_cStructure;
277 }
278
279protected:
280 C_STRUCT* m_cStructure = nullptr;
281
282private:
283 bool m_owner = false;
284};
285
286template<class CPP_CLASS, typename C_STRUCT>
288{
289public:
290 DynamicCStructHdl() : m_cStructure(new C_STRUCT()), m_owner(true)
291 {
292 memset(m_cStructure, 0, sizeof(C_STRUCT));
293 }
294
295 DynamicCStructHdl(const DynamicCStructHdl& cppClass)
296 : m_cStructure(new C_STRUCT(*cppClass.m_cStructure)), m_owner(true)
297 {
298 CPP_CLASS::AllocResources(cppClass.m_cStructure, m_cStructure);
299 }
300
301 explicit DynamicCStructHdl(const C_STRUCT* cStructure)
302 : m_cStructure(new C_STRUCT(*cStructure)), m_owner(true)
303 {
304 CPP_CLASS::AllocResources(cStructure, m_cStructure);
305 }
306
307 explicit DynamicCStructHdl(C_STRUCT* cStructure) : m_cStructure(cStructure)
308 {
309 assert(cStructure);
310 }
311
312 const DynamicCStructHdl& operator=(const DynamicCStructHdl& right)
313 {
314 if (this == &right)
315 return *this;
316
317 CPP_CLASS::FreeResources(m_cStructure);
318 if (m_cStructure && !m_owner)
319 {
320 memcpy(m_cStructure, right.m_cStructure, sizeof(C_STRUCT));
321 }
322 else
323 {
324 if (m_owner)
325 delete m_cStructure;
326 m_owner = true;
327 m_cStructure = new C_STRUCT(*right.m_cStructure);
328 }
329 CPP_CLASS::AllocResources(right.m_cStructure, m_cStructure);
330 return *this;
331 }
332
333 const DynamicCStructHdl& operator=(const C_STRUCT& right)
334 {
335 assert(&right);
336
337 if (m_cStructure == &right)
338 return *this;
339
340 CPP_CLASS::FreeResources(m_cStructure);
341 if (m_cStructure && !m_owner)
342 {
343 memcpy(m_cStructure, &right, sizeof(C_STRUCT));
344 }
345 else
346 {
347 if (m_owner)
348 delete m_cStructure;
349 m_owner = true;
350 m_cStructure = new C_STRUCT(*right);
351 }
352 CPP_CLASS::AllocResources(&right, m_cStructure);
353 return *this;
354 }
355
356 virtual ~DynamicCStructHdl()
357 {
358 if (m_owner)
359 {
360 CPP_CLASS::FreeResources(m_cStructure);
361 delete m_cStructure;
362 }
363 }
364
365 operator C_STRUCT*() { return m_cStructure; }
366 operator const C_STRUCT*() const { return m_cStructure; }
367
368 const C_STRUCT* GetCStructure() const { return m_cStructure; }
369
370 C_STRUCT* release()
371 {
372 m_owner = false;
373 return m_cStructure;
374 }
375
376protected:
377 C_STRUCT* m_cStructure = nullptr;
378
379private:
380 bool m_owner = false;
381};
382
383//==============================================================================
436class ATTR_DLL_LOCAL CSettingValue
437{
438public:
439 explicit CSettingValue(const std::string& settingValue) : str(settingValue) {}
440
441 bool empty() const { return str.empty(); }
442
455
458
460 const std::string& GetString() const { return str; }
461
463 int GetInt() const { return std::atoi(str.c_str()); }
464
466 unsigned int GetUInt() const { return std::atoi(str.c_str()); }
467
469 bool GetBoolean() const { return std::atoi(str.c_str()) > 0; }
470
472 float GetFloat() const { return static_cast<float>(std::atof(str.c_str())); }
473
476 template<typename enumType>
477 enumType GetEnum() const
478 {
479 return static_cast<enumType>(GetInt());
480 }
481
483
484private:
485 const std::string str;
486};
488//------------------------------------------------------------------------------
489
490//==============================================================================
497class ATTR_DLL_LOCAL IInstanceInfo
498{
499public:
500 explicit IInstanceInfo(KODI_ADDON_INSTANCE_STRUCT* instance) : m_instance(instance) {}
501
514
517
519 KODI_ADDON_INSTANCE_TYPE GetType() const { return m_instance->info->type; }
520
525 bool IsType(KODI_ADDON_INSTANCE_TYPE type) const { return m_instance->info->type == type; }
526
528 uint32_t GetNumber() const { return m_instance->info->number; }
529
531 std::string GetID() const { return m_instance->info->id; }
532
534 std::string GetAPIVersion() const { return m_instance->info->version; }
535
537 bool FirstInstance() const { return m_instance->info->first_instance; }
538
540
541 operator KODI_ADDON_INSTANCE_STRUCT*() { return m_instance; }
542
543 operator KODI_ADDON_INSTANCE_STRUCT*() const { return m_instance; }
544
545private:
546 IInstanceInfo() = delete;
547 IInstanceInfo(const IInstanceInfo&) = delete;
548
549 KODI_ADDON_INSTANCE_STRUCT* m_instance;
550};
552//------------------------------------------------------------------------------
553
554//==============================================================================
555/*
556 * Internal class to control various instance types with general parts defined
557 * here.
558 *
559 * Mainly is this currently used to identify requested instance types.
560 *
561 * @note This class is not need to know during add-on development thats why
562 * commented with "*".
563 */
564class ATTR_DLL_LOCAL IAddonInstance
565{
566public:
567 explicit IAddonInstance(const kodi::addon::IInstanceInfo& instance) : m_instance(instance)
568 {
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;
575 }
576 virtual ~IAddonInstance() = default;
577
578 virtual ADDON_STATUS CreateInstance(const kodi::addon::IInstanceInfo& instance,
579 KODI_ADDON_INSTANCE_HDL& hdl)
580 {
581 return ADDON_STATUS_NOT_IMPLEMENTED;
582 }
583
584 std::string GetInstanceAPIVersion() const { return m_instance->info->version; }
585
586 virtual ADDON_STATUS SetInstanceSetting(const std::string& settingName,
587 const kodi::addon::CSettingValue& settingValue)
588 {
590 }
591
592 inline bool IsInstanceSettingUsingDefault(const std::string& settingName)
593 {
594 return m_instance->info->functions->is_instance_setting_using_default(m_instance->info->kodi,
595 settingName.c_str());
596 }
597
598 inline std::string GetInstanceUserPath(const std::string& append = "")
599 {
600 using namespace kodi::addon;
601
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,
606 str);
607 if (!append.empty())
608 {
609 if (append.at(0) != '\\' && append.at(0) != '/')
610#ifdef TARGET_WINDOWS
611 ret.append("\\");
612#else
613 ret.append("/");
614#endif
615 ret.append(append);
616 }
617 return ret;
618 }
619
620 inline bool CheckInstanceSettingString(const std::string& settingName, std::string& settingValue)
621 {
622 char* buffer = nullptr;
623 bool ret = m_instance->info->functions->get_instance_setting_string(
624 m_instance->info->kodi, settingName.c_str(), &buffer);
625 if (buffer)
626 {
627 if (ret)
628 settingValue = buffer;
629 free(buffer);
630 }
631 return ret;
632 }
633
634 inline std::string GetInstanceSettingString(const std::string& settingName,
635 const std::string& defaultValue = "")
636 {
637 std::string settingValue = defaultValue;
638 CheckInstanceSettingString(settingName, settingValue);
639 return settingValue;
640 }
641
642 inline void SetInstanceSettingString(const std::string& settingName,
643 const std::string& settingValue)
644 {
645 m_instance->info->functions->set_instance_setting_string(
646 m_instance->info->kodi, settingName.c_str(), settingValue.c_str());
647 }
648
649 inline bool CheckInstanceSettingInt(const std::string& settingName, int& settingValue)
650 {
651 KODI_ADDON_INSTANCE_FUNC_CB* cb = m_instance->info->functions;
652 return cb->get_instance_setting_int(m_instance->info->kodi, settingName.c_str(), &settingValue);
653 }
654
655 inline int GetInstanceSettingInt(const std::string& settingName, int defaultValue = 0)
656 {
657 int settingValue = defaultValue;
658 CheckInstanceSettingInt(settingName, settingValue);
659 return settingValue;
660 }
661
662 inline void SetInstanceSettingInt(const std::string& settingName, int settingValue)
663 {
664 m_instance->info->functions->set_instance_setting_int(m_instance->info->kodi,
665 settingName.c_str(), settingValue);
666 }
667
668 inline bool CheckInstanceSettingBoolean(const std::string& settingName, bool& settingValue)
669 {
670 return m_instance->info->functions->get_instance_setting_bool(
671 m_instance->info->kodi, settingName.c_str(), &settingValue);
672 }
673
674 inline bool GetInstanceSettingBoolean(const std::string& settingName, bool defaultValue = false)
675 {
676 bool settingValue = defaultValue;
677 CheckInstanceSettingBoolean(settingName, settingValue);
678 return settingValue;
679 }
680
681 inline void SetInstanceSettingBoolean(const std::string& settingName, bool settingValue)
682 {
683 m_instance->info->functions->set_instance_setting_bool(m_instance->info->kodi,
684 settingName.c_str(), settingValue);
685 }
686
687 inline bool CheckInstanceSettingFloat(const std::string& settingName, float& settingValue)
688 {
689 return m_instance->info->functions->get_instance_setting_float(
690 m_instance->info->kodi, settingName.c_str(), &settingValue);
691 }
692
693 inline float GetInstanceSettingFloat(const std::string& settingName, float defaultValue = 0.0f)
694 {
695 float settingValue = defaultValue;
696 CheckInstanceSettingFloat(settingName, settingValue);
697 return settingValue;
698 }
699
700 inline void SetInstanceSettingFloat(const std::string& settingName, float settingValue)
701 {
702 m_instance->info->functions->set_instance_setting_float(m_instance->info->kodi,
703 settingName.c_str(), settingValue);
704 }
705
706 template<typename enumType>
707 inline bool CheckInstanceSettingEnum(const std::string& settingName, enumType& settingValue)
708 {
709 using namespace kodi::addon;
710
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);
714 if (ret)
715 settingValue = static_cast<enumType>(settingValueInt);
716 return ret;
717 }
718
719 template<typename enumType>
720 inline enumType GetInstanceSettingEnum(const std::string& settingName,
721 enumType defaultValue = static_cast<enumType>(0))
722 {
723 enumType settingValue = defaultValue;
724 CheckInstanceSettingEnum(settingName, settingValue);
725 return settingValue;
726 }
727
728 template<typename enumType>
729 inline void SetInstanceSettingEnum(const std::string& settingName, enumType settingValue)
730 {
731 m_instance->info->functions->set_instance_setting_int(
732 m_instance->info->kodi, settingName.c_str(), static_cast<int>(settingValue));
733 }
734
735private:
736 static inline ADDON_STATUS INSTANCE_instance_setting_change_string(
737 const KODI_ADDON_INSTANCE_HDL hdl, const char* name, const char* value)
738 {
739 return static_cast<IAddonInstance*>(hdl)->SetInstanceSetting(name, CSettingValue(value));
740 }
741
742 static inline ADDON_STATUS INSTANCE_instance_setting_change_boolean(
743 const KODI_ADDON_INSTANCE_HDL hdl, const char* name, bool value)
744 {
745 return static_cast<IAddonInstance*>(hdl)->SetInstanceSetting(name,
746 CSettingValue(value ? "1" : "0"));
747 }
748
749 static inline ADDON_STATUS INSTANCE_instance_setting_change_integer(
750 const KODI_ADDON_INSTANCE_HDL hdl, const char* name, int value)
751 {
752 return static_cast<IAddonInstance*>(hdl)->SetInstanceSetting(
753 name, CSettingValue(std::to_string(value)));
754 }
755
756 static inline ADDON_STATUS INSTANCE_instance_setting_change_float(
757 const KODI_ADDON_INSTANCE_HDL hdl, const char* name, float value)
758 {
759 return static_cast<IAddonInstance*>(hdl)->SetInstanceSetting(
760 name, CSettingValue(std::to_string(value)));
761 }
762
763 friend class CAddonBase;
764
765 const KODI_ADDON_INSTANCE_STRUCT* m_instance;
766};
767
768//============================================================================
774class ATTR_DLL_LOCAL CAddonBase
775{
776public:
777 //============================================================================
782 {
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;
791 }
792 //----------------------------------------------------------------------------
793
794 //============================================================================
798 virtual ~CAddonBase() = default;
799 //----------------------------------------------------------------------------
800
801 //============================================================================
817 virtual ADDON_STATUS Create() { return ADDON_STATUS_OK; }
818 //----------------------------------------------------------------------------
819
820 //============================================================================
870 virtual ADDON_STATUS SetSetting(const std::string& settingName,
871 const kodi::addon::CSettingValue& settingValue)
872 {
874 }
875 //----------------------------------------------------------------------------
876
877 //==========================================================================
925 KODI_ADDON_INSTANCE_HDL& hdl)
926 {
927 return ADDON_STATUS_NOT_IMPLEMENTED;
928 }
929 //--------------------------------------------------------------------------
930
931 //==========================================================================
944 virtual void DestroyInstance(const IInstanceInfo& instance, const KODI_ADDON_INSTANCE_HDL hdl) {}
945 //--------------------------------------------------------------------------
946
947 /* Background helper for GUI render systems, e.g. Screensaver or Visualization */
948 std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper;
949
950private:
951 static inline void ADDONBASE_Destroy(const KODI_ADDON_HDL hdl)
952 {
953 delete static_cast<CAddonBase*>(hdl);
954 }
955
956 static inline ADDON_STATUS ADDONBASE_CreateInstance(const KODI_ADDON_HDL hdl,
957 struct KODI_ADDON_INSTANCE_STRUCT* instance)
958 {
959 CAddonBase* base = static_cast<CAddonBase*>(hdl);
960
961 ADDON_STATUS status = ADDON_STATUS_NOT_IMPLEMENTED;
962
963 /* Check about single instance usage:
964 * 1. The kodi side instance pointer must be equal to first one
965 * 2. The addon side instance pointer must be set
966 * 3. And the requested type must be equal with used add-on class
967 */
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)
972 {
973 /* The handling here is intended for the case of the add-on only one
974 * instance and this is integrated in the add-on base class.
975 */
976 instance->hdl = CPrivateBase::m_interface->globalSingleInstance;
977 status = ADDON_STATUS_OK;
978 }
979 else
980 {
981 /* Here it should use the CreateInstance instance function to allow
982 * creation of several on one addon.
983 */
984
985 IInstanceInfo instanceInfo(instance);
986
987 /* Check first a parent is defined about (e.g. Codec within inputstream) */
988 if (instance->info->parent != nullptr)
989 status = static_cast<IAddonInstance*>(instance->info->parent)
990 ->CreateInstance(instanceInfo, instance->hdl);
991
992 /* if no parent call the main instance creation function to get it */
993 if (status == ADDON_STATUS_NOT_IMPLEMENTED)
994 {
995 status = base->CreateInstance(instanceInfo, instance->hdl);
996 }
997 }
998
999 if (instance->hdl == nullptr)
1000 {
1001 if (status == ADDON_STATUS_OK)
1002 {
1003 CPrivateBase::m_interface->toKodi->addon_log_msg(
1004 CPrivateBase::m_interface->toKodi->kodiBase, ADDON_LOG_FATAL,
1005 "kodi::addon::CAddonBase CreateInstance returned an "
1006 "empty instance pointer, but reported OK!");
1008 }
1009 else
1010 {
1011 return status;
1012 }
1013 }
1014
1015 if (static_cast<IAddonInstance*>(instance->hdl)->m_instance->info->type != instance->info->type)
1016 {
1017 CPrivateBase::m_interface->toKodi->addon_log_msg(
1018 CPrivateBase::m_interface->toKodi->kodiBase, ADDON_LOG_FATAL,
1019 "kodi::addon::CAddonBase CreateInstance difference between given and returned");
1020 delete static_cast<IAddonInstance*>(instance->hdl);
1021 instance->hdl = nullptr;
1023 }
1024
1025 return status;
1026 }
1027
1028 static inline void ADDONBASE_DestroyInstance(const KODI_ADDON_HDL hdl,
1029 struct KODI_ADDON_INSTANCE_STRUCT* instance)
1030 {
1031 CAddonBase* base = static_cast<CAddonBase*>(hdl);
1032
1033 if (CPrivateBase::m_interface->globalSingleInstance == nullptr && instance->hdl != base)
1034 {
1035 IInstanceInfo instanceInfo(instance);
1036 base->DestroyInstance(instanceInfo, instance->hdl);
1037 delete static_cast<IAddonInstance*>(instance->hdl);
1038 }
1039 }
1040
1041 static inline ADDON_STATUS ADDONBASE_setting_change_string(const KODI_ADDON_HDL hdl,
1042 const char* name,
1043 const char* value)
1044 {
1045 return static_cast<CAddonBase*>(hdl)->SetSetting(name, CSettingValue(value));
1046 }
1047
1048 static inline ADDON_STATUS ADDONBASE_setting_change_boolean(const KODI_ADDON_HDL hdl,
1049 const char* name,
1050 bool value)
1051 {
1052 return static_cast<CAddonBase*>(hdl)->SetSetting(name, CSettingValue(value ? "1" : "0"));
1053 }
1054
1055 static inline ADDON_STATUS ADDONBASE_setting_change_integer(const KODI_ADDON_HDL hdl,
1056 const char* name,
1057 int value)
1058 {
1059 return static_cast<CAddonBase*>(hdl)->SetSetting(name, CSettingValue(std::to_string(value)));
1060 }
1061
1062 static inline ADDON_STATUS ADDONBASE_setting_change_float(const KODI_ADDON_HDL hdl,
1063 const char* name,
1064 float value)
1065 {
1066 return static_cast<CAddonBase*>(hdl)->SetSetting(name, CSettingValue(std::to_string(value)));
1067 }
1068};
1069
1070//==============================================================================
1077inline std::string ATTR_DLL_LOCAL GetAddonPath(const std::string& append = "")
1078{
1079 using namespace kodi::addon;
1080
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())
1086 {
1087 if (append.at(0) != '\\' && append.at(0) != '/')
1088#ifdef TARGET_WINDOWS
1089 ret.append("\\");
1090#else
1091 ret.append("/");
1092#endif
1093 ret.append(append);
1094 }
1095 return ret;
1096}
1097//------------------------------------------------------------------------------
1098
1099//==============================================================================
1114inline std::string ATTR_DLL_LOCAL GetLibPath(const std::string& append = "")
1115{
1116 using namespace kodi::addon;
1117
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())
1123 {
1124 if (append.at(0) != '\\' && append.at(0) != '/')
1125#ifdef TARGET_WINDOWS
1126 ret.append("\\");
1127#else
1128 ret.append("/");
1129#endif
1130 ret.append(append);
1131 }
1132 return ret;
1133}
1134//------------------------------------------------------------------------------
1135
1136//==============================================================================
1146inline std::string ATTR_DLL_LOCAL GetUserPath(const std::string& append = "")
1147{
1148 using namespace kodi::addon;
1149
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())
1155 {
1156 if (append.at(0) != '\\' && append.at(0) != '/')
1157#ifdef TARGET_WINDOWS
1158 ret.append("\\");
1159#else
1160 ret.append("/");
1161#endif
1162 ret.append(append);
1163 }
1164 return ret;
1165}
1166//------------------------------------------------------------------------------
1167
1168//==============================================================================
1179inline std::string ATTR_DLL_LOCAL GetTempPath(const std::string& append = "")
1180{
1181 using namespace kodi::addon;
1182
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())
1188 {
1189 if (append.at(0) != '\\' && append.at(0) != '/')
1190#ifdef TARGET_WINDOWS
1191 ret.append("\\");
1192#else
1193 ret.append("/");
1194#endif
1195 ret.append(append);
1196 }
1197 return ret;
1198}
1199//------------------------------------------------------------------------------
1200
1201//==============================================================================
1228inline std::string ATTR_DLL_LOCAL GetLocalizedString(uint32_t labelId,
1229 const std::string& defaultStr = "")
1230{
1231 using namespace kodi::addon;
1232
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)
1237 {
1238 if (std::strlen(strMsg))
1239 retString = strMsg;
1240 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1241 strMsg);
1242 }
1243 return retString;
1244}
1245//------------------------------------------------------------------------------
1246
1247//##############################################################################
1259
1261//==============================================================================
1277inline bool ATTR_DLL_LOCAL OpenSettings()
1278{
1279 using namespace kodi::addon;
1280 return CPrivateBase::m_interface->toKodi->kodi_addon->open_settings_dialog(
1281 CPrivateBase::m_interface->toKodi->kodiBase);
1282}
1283//------------------------------------------------------------------------------
1284
1285//==============================================================================
1293inline bool ATTR_DLL_LOCAL IsSettingUsingDefault(const std::string& settingName)
1294{
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());
1298}
1299//------------------------------------------------------------------------------
1300
1301//==============================================================================
1324inline bool ATTR_DLL_LOCAL CheckSettingString(const std::string& settingName,
1325 std::string& settingValue)
1326{
1327 using namespace kodi::addon;
1328
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);
1332 if (buffer)
1333 {
1334 if (ret)
1335 settingValue = buffer;
1336 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1337 buffer);
1338 }
1339 return ret;
1340}
1341//------------------------------------------------------------------------------
1342
1343//==============================================================================
1362inline std::string ATTR_DLL_LOCAL GetSettingString(const std::string& settingName,
1363 const std::string& defaultValue = "")
1364{
1365 std::string settingValue = defaultValue;
1366 CheckSettingString(settingName, settingValue);
1367 return settingValue;
1368}
1369//------------------------------------------------------------------------------
1370
1371//==============================================================================
1390inline void ATTR_DLL_LOCAL SetSettingString(const std::string& settingName,
1391 const std::string& settingValue)
1392{
1393 using namespace kodi::addon;
1394
1395 CPrivateBase::m_interface->toKodi->kodi_addon->set_setting_string(
1396 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue.c_str());
1397}
1398//------------------------------------------------------------------------------
1399
1400//==============================================================================
1423inline bool ATTR_DLL_LOCAL CheckSettingInt(const std::string& settingName, int& settingValue)
1424{
1425 using namespace kodi::addon;
1426
1427 return CPrivateBase::m_interface->toKodi->kodi_addon->get_setting_int(
1428 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue);
1429}
1430//------------------------------------------------------------------------------
1431
1432//==============================================================================
1451inline int ATTR_DLL_LOCAL GetSettingInt(const std::string& settingName, int defaultValue = 0)
1452{
1453 int settingValue = defaultValue;
1454 CheckSettingInt(settingName, settingValue);
1455 return settingValue;
1456}
1457//------------------------------------------------------------------------------
1458
1459//==============================================================================
1478inline void ATTR_DLL_LOCAL SetSettingInt(const std::string& settingName, int settingValue)
1479{
1480 using namespace kodi::addon;
1481
1482 CPrivateBase::m_interface->toKodi->kodi_addon->set_setting_int(
1483 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue);
1484}
1485//------------------------------------------------------------------------------
1486
1487//==============================================================================
1510inline bool ATTR_DLL_LOCAL CheckSettingBoolean(const std::string& settingName, bool& settingValue)
1511{
1512 using namespace kodi::addon;
1513
1514 return CPrivateBase::m_interface->toKodi->kodi_addon->get_setting_bool(
1515 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue);
1516}
1517//------------------------------------------------------------------------------
1518
1519//==============================================================================
1538inline bool ATTR_DLL_LOCAL GetSettingBoolean(const std::string& settingName,
1539 bool defaultValue = false)
1540{
1541 bool settingValue = defaultValue;
1542 CheckSettingBoolean(settingName, settingValue);
1543 return settingValue;
1544}
1545//------------------------------------------------------------------------------
1546
1547//==============================================================================
1566inline void ATTR_DLL_LOCAL SetSettingBoolean(const std::string& settingName, bool settingValue)
1567{
1568 using namespace kodi::addon;
1569
1570 CPrivateBase::m_interface->toKodi->kodi_addon->set_setting_bool(
1571 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue);
1572}
1573//------------------------------------------------------------------------------
1574
1575//==============================================================================
1598inline bool ATTR_DLL_LOCAL CheckSettingFloat(const std::string& settingName, float& settingValue)
1599{
1600 using namespace kodi::addon;
1601
1602 return CPrivateBase::m_interface->toKodi->kodi_addon->get_setting_float(
1603 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue);
1604}
1605//------------------------------------------------------------------------------
1606
1607//==============================================================================
1626inline float ATTR_DLL_LOCAL GetSettingFloat(const std::string& settingName,
1627 float defaultValue = 0.0f)
1628{
1629 float settingValue = defaultValue;
1630 CheckSettingFloat(settingName, settingValue);
1631 return settingValue;
1632}
1633//------------------------------------------------------------------------------
1634
1635//==============================================================================
1654inline void ATTR_DLL_LOCAL SetSettingFloat(const std::string& settingName, float settingValue)
1655{
1656 using namespace kodi::addon;
1657
1658 CPrivateBase::m_interface->toKodi->kodi_addon->set_setting_float(
1659 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue);
1660}
1661//------------------------------------------------------------------------------
1662
1663//==============================================================================
1694template<typename enumType>
1695inline bool ATTR_DLL_LOCAL CheckSettingEnum(const std::string& settingName, enumType& settingValue)
1696{
1697 using namespace kodi::addon;
1698
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);
1702 if (ret)
1703 settingValue = static_cast<enumType>(settingValueInt);
1704 return ret;
1705}
1706//------------------------------------------------------------------------------
1707
1708//==============================================================================
1736template<typename enumType>
1737inline enumType ATTR_DLL_LOCAL GetSettingEnum(const std::string& settingName,
1738 enumType defaultValue = static_cast<enumType>(0))
1739{
1740 enumType settingValue = defaultValue;
1741 CheckSettingEnum(settingName, settingValue);
1742 return settingValue;
1743}
1744//------------------------------------------------------------------------------
1745
1746//==============================================================================
1774template<typename enumType>
1775inline void ATTR_DLL_LOCAL SetSettingEnum(const std::string& settingName, enumType settingValue)
1776{
1777 using namespace kodi::addon;
1778
1779 CPrivateBase::m_interface->toKodi->kodi_addon->set_setting_int(
1780 CPrivateBase::m_interface->toKodi->kodiBase, settingName.c_str(),
1781 static_cast<int>(settingValue));
1782}
1783//------------------------------------------------------------------------------
1784
1787//==============================================================================
1813inline std::string ATTR_DLL_LOCAL GetAddonInfo(const std::string& id)
1814{
1815 using namespace kodi::addon;
1816
1817 AddonToKodiFuncTable_Addon* toKodi = CPrivateBase::m_interface->toKodi;
1818
1819 std::string strReturn;
1820 char* strMsg = toKodi->kodi_addon->get_addon_info(toKodi->kodiBase, id.c_str());
1821 if (strMsg != nullptr)
1822 {
1823 if (std::strlen(strMsg))
1824 strReturn = strMsg;
1825 toKodi->free_string(toKodi->kodiBase, strMsg);
1826 }
1827 return strReturn;
1828}
1829//------------------------------------------------------------------------------
1830
1831//==============================================================================
1849inline void* GetInterface(const std::string& name, const std::string& version)
1850{
1851 using namespace kodi::addon;
1852
1853 AddonToKodiFuncTable_Addon* toKodi = CPrivateBase::m_interface->toKodi;
1854
1855 return toKodi->kodi_addon->get_interface(toKodi->kodiBase, name.c_str(), version.c_str());
1856}
1857//----------------------------------------------------------------------------
1858
1859//==============================================================================
1869inline std::string ATTR_DLL_LOCAL GetKodiTypeVersion(int type)
1870{
1871 using namespace kodi::addon;
1872
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);
1877 return ret;
1878}
1879//------------------------------------------------------------------------------
1880
1881//============================================================================
1888inline std::string ATTR_DLL_LOCAL TranslateAddonStatus(ADDON_STATUS status)
1889{
1890 switch (status)
1891 {
1892 case ADDON_STATUS_OK:
1893 return "OK";
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";
1906 default:
1907 break;
1908 }
1909 return "Unknown";
1910}
1911//----------------------------------------------------------------------------
1912
1913} /* namespace addon */
1914
1915//==============================================================================
1938inline void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char* format, ...)
1939{
1940 using namespace kodi::addon;
1941
1942 va_list args;
1943 va_start(args, format);
1944 const std::string str = kodi::tools::StringUtils::FormatV(format, args);
1945 va_end(args);
1946 CPrivateBase::m_interface->toKodi->addon_log_msg(CPrivateBase::m_interface->toKodi->kodiBase,
1947 loglevel, str.c_str());
1948}
1949//------------------------------------------------------------------------------
1950
1951} /* namespace kodi */
1952
1953//==============================================================================
2047#define ADDONCREATOR(AddonClass) \
2048 extern "C" ATTR_DLL_EXPORT ADDON_STATUS ADDON_Create(KODI_HANDLE addonInterface) \
2049 { \
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(); \
2054 } \
2055 extern "C" ATTR_DLL_EXPORT const char* ADDON_GetTypeVersion(int type) \
2056 { \
2057 return kodi::addon::GetTypeVersion(type); \
2058 } \
2059 extern "C" ATTR_DLL_EXPORT const char* ADDON_GetTypeMinVersion(int type) \
2060 { \
2061 return kodi::addon::GetTypeMinVersion(type); \
2062 } \
2063 AddonGlobalInterface* kodi::addon::CPrivateBase::m_interface = nullptr;
2064//------------------------------------------------------------------------------
2065
2066#endif /* __cplusplus */
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
static std::string FormatV(PRINTF_FORMAT_STRING const char *fmt, va_list args)
Returns the C++ string pointed by given format list.
Definition StringUtils.h:604
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