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