summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h')
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h264
1 files changed, 264 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h
new file mode 100644
index 0000000..faa99fa
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h
@@ -0,0 +1,264 @@
1/*
2 * Copyright (C) 2005-2019 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#ifndef C_API_ADDON_BASE_H
12#define C_API_ADDON_BASE_H
13
14#if !defined(NOMINMAX)
15#define NOMINMAX
16#endif
17
18#include "stdbool.h"
19#include "stdint.h"
20
21#ifndef TARGET_WINDOWS
22#ifndef __cdecl
23#define __cdecl
24#endif
25#ifndef __declspec
26#define __declspec(X)
27#endif
28#endif
29
30#undef ATTRIBUTE_PACKED
31#undef PRAGMA_PACK_BEGIN
32#undef PRAGMA_PACK_END
33
34#if defined(__GNUC__)
35#define ATTRIBUTE_PACKED __attribute__((packed))
36#define PRAGMA_PACK 0
37#define ATTRIBUTE_HIDDEN __attribute__((visibility("hidden")))
38#endif
39
40#if !defined(ATTRIBUTE_PACKED)
41#define ATTRIBUTE_PACKED
42#define PRAGMA_PACK 1
43#endif
44
45#if !defined(ATTRIBUTE_HIDDEN)
46#define ATTRIBUTE_HIDDEN
47#endif
48
49#ifdef _MSC_VER
50#define ATTRIBUTE_FORCEINLINE __forceinline
51#elif defined(__GNUC__)
52#define ATTRIBUTE_FORCEINLINE inline __attribute__((__always_inline__))
53#elif defined(__CLANG__)
54#if __has_attribute(__always_inline__)
55#define ATTRIBUTE_FORCEINLINE inline __attribute__((__always_inline__))
56#else
57#define ATTRIBUTE_FORCEINLINE inline
58#endif
59#else
60#define ATTRIBUTE_FORCEINLINE inline
61#endif
62
63// Hardware specific device context interface
64#define ADDON_HARDWARE_CONTEXT void*
65
66/*
67 * To have a on add-on and kodi itself handled string always on known size!
68 */
69#define ADDON_STANDARD_STRING_LENGTH 1024
70#define ADDON_STANDARD_STRING_LENGTH_SMALL 256
71
72#ifdef __cplusplus
73extern "C"
74{
75#endif /* __cplusplus */
76
77 //============================================================================
78 /// @ingroup cpp_kodi_addon_addonbase
79 /// @brief Return value of functions in @ref cpp_kodi_addon_addonbase "kodi::addon::CAddonBase"
80 /// and associated classes.
81 ///
82 ///@{
83 typedef enum ADDON_STATUS
84 {
85 /// @brief For everything OK and no error
86 ADDON_STATUS_OK,
87
88 /// @brief A needed connection was lost
89 ADDON_STATUS_LOST_CONNECTION,
90
91 /// @brief Addon needs a restart inside Kodi
92 ADDON_STATUS_NEED_RESTART,
93
94 /// @brief Necessary settings are not yet set
95 ADDON_STATUS_NEED_SETTINGS,
96
97 /// @brief Unknown and incomprehensible error
98 ADDON_STATUS_UNKNOWN,
99
100 /// @brief Permanent failure, like failing to resolve methods
101 ADDON_STATUS_PERMANENT_FAILURE,
102
103 /* internal used return error if function becomes not used from child on
104 * addon */
105 ADDON_STATUS_NOT_IMPLEMENTED
106 } ADDON_STATUS;
107 ///@}
108 //----------------------------------------------------------------------------
109
110 //============================================================================
111 /// @defgroup cpp_kodi_Defs_AddonLog enum AddonLog
112 /// @ingroup cpp_kodi_Defs
113 /// @brief **Log file type definitions**\n
114 /// These define the types of log entries given with @ref kodi::Log() to Kodi.
115 ///
116 /// -------------------------------------------------------------------------
117 ///
118 /// **Example:**
119 /// ~~~~~~~~~~~~~{.cpp}
120 /// #include <kodi/General.h>
121 ///
122 /// kodi::Log(ADDON_LOG_ERROR, "%s: There is an error occurred!", __func__);
123 ///
124 /// ~~~~~~~~~~~~~
125 ///
126 ///@{
127 typedef enum AddonLog
128 {
129 /// @brief **0** : To include debug information in the log file.
130 ADDON_LOG_DEBUG = 0,
131
132 /// @brief **1** : To include information messages in the log file.
133 ADDON_LOG_INFO = 1,
134
135 /// @brief **2** : To write warnings in the log file.
136 ADDON_LOG_WARNING = 2,
137
138 /// @brief **3** : To report error messages in the log file.
139 ADDON_LOG_ERROR = 3,
140
141 /// @brief **4** : To notify fatal unrecoverable errors, which can may also indicate
142 /// upcoming crashes.
143 ADDON_LOG_FATAL = 4
144 } AddonLog;
145 ///@}
146 //----------------------------------------------------------------------------
147
148 /*! @brief Standard undefined pointer handle */
149 typedef void* KODI_HANDLE;
150
151 /*!
152 * @brief Handle used to return data from the PVR add-on to CPVRClient
153 */
154 struct ADDON_HANDLE_STRUCT
155 {
156 void* callerAddress; /*!< address of the caller */
157 void* dataAddress; /*!< address to store data in */
158 int dataIdentifier; /*!< parameter to pass back when calling the callback */
159 };
160 typedef struct ADDON_HANDLE_STRUCT* ADDON_HANDLE;
161
162 /*!
163 * @brief Callback function tables from addon to Kodi
164 * Set complete from Kodi!
165 */
166 struct AddonToKodiFuncTable_kodi;
167 struct AddonToKodiFuncTable_kodi_audioengine;
168 struct AddonToKodiFuncTable_kodi_filesystem;
169 struct AddonToKodiFuncTable_kodi_network;
170 struct AddonToKodiFuncTable_kodi_gui;
171 typedef struct AddonToKodiFuncTable_Addon
172 {
173 // Pointer inside Kodi, used on callback functions to give related handle
174 // class, for this ADDON::CAddonDll inside Kodi.
175 KODI_HANDLE kodiBase;
176
177 // Function addresses used for callbacks from addon to Kodi
178 char* (*get_type_version)(void* kodiBase, int type);
179
180 void (*free_string)(void* kodiBase, char* str);
181 void (*free_string_array)(void* kodiBase, char** arr, int numElements);
182 char* (*get_addon_path)(void* kodiBase);
183 char* (*get_base_user_path)(void* kodiBase);
184 void (*addon_log_msg)(void* kodiBase, const int loglevel, const char* msg);
185
186 bool (*get_setting_bool)(void* kodiBase, const char* id, bool* value);
187 bool (*get_setting_int)(void* kodiBase, const char* id, int* value);
188 bool (*get_setting_float)(void* kodiBase, const char* id, float* value);
189 bool (*get_setting_string)(void* kodiBase, const char* id, char** value);
190
191 bool (*set_setting_bool)(void* kodiBase, const char* id, bool value);
192 bool (*set_setting_int)(void* kodiBase, const char* id, int value);
193 bool (*set_setting_float)(void* kodiBase, const char* id, float value);
194 bool (*set_setting_string)(void* kodiBase, const char* id, const char* value);
195
196 void* (*get_interface)(void* kodiBase, const char* name, const char* version);
197
198 struct AddonToKodiFuncTable_kodi* kodi;
199 struct AddonToKodiFuncTable_kodi_audioengine* kodi_audioengine;
200 struct AddonToKodiFuncTable_kodi_filesystem* kodi_filesystem;
201 struct AddonToKodiFuncTable_kodi_gui* kodi_gui;
202 struct AddonToKodiFuncTable_kodi_network* kodi_network;
203
204 // Move up by min version change about
205 bool (*is_setting_using_default)(void* kodiBase, const char* id);
206 } AddonToKodiFuncTable_Addon;
207
208 /*!
209 * @brief Function tables from Kodi to addon
210 */
211 typedef struct KodiToAddonFuncTable_Addon
212 {
213 void (*destroy)();
214 ADDON_STATUS (*get_status)();
215 ADDON_STATUS(*create_instance)
216 (int instanceType,
217 const char* instanceID,
218 KODI_HANDLE instance,
219 const char* version,
220 KODI_HANDLE* addonInstance,
221 KODI_HANDLE parent);
222 void (*destroy_instance)(int instanceType, KODI_HANDLE instance);
223 ADDON_STATUS (*set_setting)(const char* settingName, const void* settingValue);
224 } KodiToAddonFuncTable_Addon;
225
226 /*!
227 * @brief Main structure passed from kodi to addon with basic information needed to
228 * create add-on.
229 */
230 typedef struct AddonGlobalInterface
231 {
232 // String with full path where add-on is installed (without his name on end)
233 // Set from Kodi!
234 const char* libBasePath;
235
236 // Master API version of Kodi itself (ADDON_GLOBAL_VERSION_MAIN)
237 const char* kodi_base_api_version;
238
239 // Pointer of first created instance, used in case this add-on goes with single way
240 // Set from Kodi!
241 KODI_HANDLE firstKodiInstance;
242
243 // Pointer to master base class inside add-on
244 // Set from addon header (kodi::addon::CAddonBase)!
245 KODI_HANDLE addonBase;
246
247 // Pointer to a instance used on single way (together with this class)
248 // Set from addon header (kodi::addon::IAddonInstance)!
249 KODI_HANDLE globalSingleInstance;
250
251 // Callback function tables from addon to Kodi
252 // Set from Kodi!
253 AddonToKodiFuncTable_Addon* toKodi;
254
255 // Function tables from Kodi to addon
256 // Set from addon header!
257 KodiToAddonFuncTable_Addon* toAddon;
258 } AddonGlobalInterface;
259
260#ifdef __cplusplus
261}
262#endif /* __cplusplus */
263
264#endif /* !C_API_ADDON_BASE_H */