diff options
| author | manuel <manuel@mausz.at> | 2017-06-04 16:57:49 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2017-06-04 16:57:49 +0200 |
| commit | f44ecaa4f27e7538ddcad66d40e543bffa2d2d86 (patch) | |
| tree | d8de60fc7e17edeb6f0921726c038ee54b281445 /xbmc/addons/kodi-addon-dev-kit/include | |
| parent | ae08c8b7221bc965ac40d70e53fc8fcddb050c46 (diff) | |
| download | kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.tar.gz kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.tar.bz2 kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.zip | |
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include')
62 files changed, 9580 insertions, 3190 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/NOTE b/xbmc/addons/kodi-addon-dev-kit/include/NOTE new file mode 100644 index 0000000..c375cd8 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/NOTE | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | NOTE: | ||
| 2 | |||
| 3 | This directory contains independent Headers to build Add-on's | ||
| 4 | without the whole Kodi source tree. The Add-on itself can add | ||
| 5 | this headers to his source tree without dependencies to any | ||
| 6 | Kodi related classes or functions. | ||
| 7 | |||
| 8 | Also this headers are never changed without a API Version | ||
| 9 | change. | ||
| 10 | |||
| 11 | The current PVR API version can be found in xbmc_pvr_types.h: | ||
| 12 | XBMC_PVR_API_VERSION | ||
| 13 | |||
| 14 | The current audio DSP API version can be found in kodi_adsp_types.h: | ||
| 15 | KODI_AE_DSP_API_VERSION | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h new file mode 100644 index 0000000..fdf030b --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h | |||
| @@ -0,0 +1,634 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team Kodi | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with Kodi; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <stdarg.h> /* va_list, va_start, va_arg, va_end */ | ||
| 23 | #include <cstdlib> | ||
| 24 | #include <cstring> | ||
| 25 | #include <stdexcept> | ||
| 26 | #include <string> | ||
| 27 | #include <vector> | ||
| 28 | |||
| 29 | #ifndef TARGET_WINDOWS | ||
| 30 | #ifndef __cdecl | ||
| 31 | #define __cdecl | ||
| 32 | #endif | ||
| 33 | #ifndef __declspec | ||
| 34 | #define __declspec(X) | ||
| 35 | #endif | ||
| 36 | #endif | ||
| 37 | |||
| 38 | #undef ATTRIBUTE_PACKED | ||
| 39 | #undef PRAGMA_PACK_BEGIN | ||
| 40 | #undef PRAGMA_PACK_END | ||
| 41 | |||
| 42 | #if defined(__GNUC__) | ||
| 43 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) | ||
| 44 | #define ATTRIBUTE_PACKED __attribute__ ((packed)) | ||
| 45 | #define PRAGMA_PACK 0 | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if !defined(ATTRIBUTE_PACKED) | ||
| 50 | #define ATTRIBUTE_PACKED | ||
| 51 | #define PRAGMA_PACK 1 | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #include "versions.h" | ||
| 55 | |||
| 56 | namespace kodi { namespace addon { class CAddonBase; }} | ||
| 57 | namespace kodi { namespace addon { class IAddonInstance; }} | ||
| 58 | |||
| 59 | extern "C" { | ||
| 60 | |||
| 61 | //============================================================================== | ||
| 62 | /// Standard undefined pointer handle | ||
| 63 | typedef void* KODI_HANDLE; | ||
| 64 | //------------------------------------------------------------------------------ | ||
| 65 | |||
| 66 | //============================================================================== | ||
| 67 | /// | ||
| 68 | typedef enum ADDON_STATUS | ||
| 69 | { | ||
| 70 | /// | ||
| 71 | ADDON_STATUS_OK, | ||
| 72 | |||
| 73 | /// | ||
| 74 | ADDON_STATUS_LOST_CONNECTION, | ||
| 75 | |||
| 76 | /// | ||
| 77 | ADDON_STATUS_NEED_RESTART, | ||
| 78 | |||
| 79 | /// | ||
| 80 | ADDON_STATUS_NEED_SETTINGS, | ||
| 81 | |||
| 82 | /// | ||
| 83 | ADDON_STATUS_UNKNOWN, | ||
| 84 | |||
| 85 | /// | ||
| 86 | ADDON_STATUS_NEED_SAVEDSETTINGS, | ||
| 87 | |||
| 88 | /// permanent failure, like failing to resolve methods | ||
| 89 | ADDON_STATUS_PERMANENT_FAILURE, | ||
| 90 | |||
| 91 | /* internal used return error if function becomes not used from child on | ||
| 92 | * addon */ | ||
| 93 | ADDON_STATUS_NOT_IMPLEMENTED | ||
| 94 | } ADDON_STATUS; | ||
| 95 | //------------------------------------------------------------------------------ | ||
| 96 | |||
| 97 | //============================================================================== | ||
| 98 | /// @todo remove start with ADDON_* after old way on libXBMC_addon.h is removed | ||
| 99 | /// | ||
| 100 | typedef enum AddonLog | ||
| 101 | { | ||
| 102 | /// | ||
| 103 | ADDON_LOG_DEBUG = 0, | ||
| 104 | |||
| 105 | /// | ||
| 106 | ADDON_LOG_INFO = 1, | ||
| 107 | |||
| 108 | /// | ||
| 109 | ADDON_LOG_NOTICE = 2, | ||
| 110 | |||
| 111 | /// | ||
| 112 | ADDON_LOG_WARNING = 3, | ||
| 113 | |||
| 114 | /// | ||
| 115 | ADDON_LOG_ERROR = 4, | ||
| 116 | |||
| 117 | /// | ||
| 118 | ADDON_LOG_SEVERE = 5, | ||
| 119 | |||
| 120 | /// | ||
| 121 | ADDON_LOG_FATAL = 6 | ||
| 122 | } AddonLog; | ||
| 123 | //------------------------------------------------------------------------------ | ||
| 124 | |||
| 125 | /*! | ||
| 126 | * @brief Handle used to return data from the PVR add-on to CPVRClient | ||
| 127 | */ | ||
| 128 | struct ADDON_HANDLE_STRUCT | ||
| 129 | { | ||
| 130 | void *callerAddress; /*!< address of the caller */ | ||
| 131 | void *dataAddress; /*!< address to store data in */ | ||
| 132 | int dataIdentifier; /*!< parameter to pass back when calling the callback */ | ||
| 133 | }; | ||
| 134 | typedef ADDON_HANDLE_STRUCT *ADDON_HANDLE; | ||
| 135 | |||
| 136 | /* | ||
| 137 | * To have a on add-on and kodi itself handled string always on known size! | ||
| 138 | */ | ||
| 139 | #define ADDON_STANDARD_STRING_LENGTH 1024 | ||
| 140 | #define ADDON_STANDARD_STRING_LENGTH_SMALL 256 | ||
| 141 | |||
| 142 | /* | ||
| 143 | * Callback function tables from addon to Kodi | ||
| 144 | * Set complete from Kodi! | ||
| 145 | */ | ||
| 146 | struct AddonToKodiFuncTable_kodi; | ||
| 147 | struct AddonToKodiFuncTable_kodi_audioengine; | ||
| 148 | struct AddonToKodiFuncTable_kodi_filesystem; | ||
| 149 | struct AddonToKodiFuncTable_kodi_network; | ||
| 150 | struct AddonToKodiFuncTable_kodi_gui; | ||
| 151 | typedef struct AddonToKodiFuncTable_Addon | ||
| 152 | { | ||
| 153 | // Pointer inside Kodi, used on callback functions to give related handle | ||
| 154 | // class, for this ADDON::CAddonDll inside Kodi. | ||
| 155 | KODI_HANDLE kodiBase; | ||
| 156 | |||
| 157 | // Function addresses used for callbacks from addon to Kodi | ||
| 158 | void (*free_string)(void* kodiBase, char* str); | ||
| 159 | char* (*get_addon_path)(void* kodiBase); | ||
| 160 | char* (*get_base_user_path)(void* kodiBase); | ||
| 161 | void (*addon_log_msg)(void* kodiBase, const int loglevel, const char *msg); | ||
| 162 | bool (*get_setting)(void* kodiBase, const char* settingName, void *settingValue); | ||
| 163 | bool (*set_setting)(void* kodiBase, const char* settingName, const char* settingValue); | ||
| 164 | |||
| 165 | AddonToKodiFuncTable_kodi* kodi; | ||
| 166 | AddonToKodiFuncTable_kodi_audioengine* kodi_audioengine; | ||
| 167 | AddonToKodiFuncTable_kodi_filesystem* kodi_filesystem; | ||
| 168 | AddonToKodiFuncTable_kodi_gui* kodi_gui; | ||
| 169 | AddonToKodiFuncTable_kodi_network *kodi_network; | ||
| 170 | } AddonToKodiFuncTable_Addon; | ||
| 171 | |||
| 172 | /* | ||
| 173 | * Function tables from Kodi to addon | ||
| 174 | */ | ||
| 175 | typedef struct KodiToAddonFuncTable_Addon | ||
| 176 | { | ||
| 177 | void (*destroy)(); | ||
| 178 | ADDON_STATUS (*get_status)(); | ||
| 179 | ADDON_STATUS (*create_instance)(int instanceType, const char* instanceID, KODI_HANDLE instance, KODI_HANDLE* addonInstance, KODI_HANDLE parent); | ||
| 180 | void (*destroy_instance)(int instanceType, KODI_HANDLE instance); | ||
| 181 | ADDON_STATUS (*set_setting)(const char *settingName, const void *settingValue); | ||
| 182 | } KodiToAddonFuncTable_Addon; | ||
| 183 | |||
| 184 | /* | ||
| 185 | * Main structure passed from kodi to addon with basic information needed to | ||
| 186 | * create add-on. | ||
| 187 | */ | ||
| 188 | typedef struct AddonGlobalInterface | ||
| 189 | { | ||
| 190 | // String with full path where add-on is installed (without his name on end) | ||
| 191 | // Set from Kodi! | ||
| 192 | const char* libBasePath; | ||
| 193 | |||
| 194 | // Pointer of first created instance, used in case this add-on goes with single way | ||
| 195 | // Set from Kodi! | ||
| 196 | KODI_HANDLE firstKodiInstance; | ||
| 197 | |||
| 198 | // Pointer to master base class inside add-on | ||
| 199 | // Set from addon header! | ||
| 200 | kodi::addon::CAddonBase* addonBase; | ||
| 201 | |||
| 202 | // Pointer to a instance used on single way (together with this class) | ||
| 203 | // Set from addon header! | ||
| 204 | kodi::addon::IAddonInstance* globalSingleInstance; | ||
| 205 | |||
| 206 | // Callback function tables from addon to Kodi | ||
| 207 | // Set from Kodi! | ||
| 208 | AddonToKodiFuncTable_Addon* toKodi; | ||
| 209 | |||
| 210 | // Function tables from Kodi to addon | ||
| 211 | // Set from addon header! | ||
| 212 | KodiToAddonFuncTable_Addon* toAddon; | ||
| 213 | } AddonGlobalInterface; | ||
| 214 | |||
| 215 | } /* extern "C" */ | ||
| 216 | |||
| 217 | //============================================================================== | ||
| 218 | namespace kodi { | ||
| 219 | namespace addon { | ||
| 220 | /* | ||
| 221 | * Internal class to control various instance types with general parts defined | ||
| 222 | * here. | ||
| 223 | * | ||
| 224 | * Mainly is this currently used to identify requested instance types. | ||
| 225 | * | ||
| 226 | * @note This class is not need to know during add-on development thats why | ||
| 227 | * commented with "*". | ||
| 228 | */ | ||
| 229 | class IAddonInstance | ||
| 230 | { | ||
| 231 | public: | ||
| 232 | IAddonInstance(ADDON_TYPE type) : m_type(type) { } | ||
| 233 | virtual ~IAddonInstance() = default; | ||
| 234 | |||
| 235 | virtual ADDON_STATUS CreateInstance(int instanceType, std::string instanceID, KODI_HANDLE instance, KODI_HANDLE& addonInstance) | ||
| 236 | { | ||
| 237 | return ADDON_STATUS_NOT_IMPLEMENTED; | ||
| 238 | } | ||
| 239 | |||
| 240 | const ADDON_TYPE m_type; | ||
| 241 | }; | ||
| 242 | } /* namespace addon */ | ||
| 243 | } /* namespace kodi */ | ||
| 244 | //------------------------------------------------------------------------------ | ||
| 245 | |||
| 246 | //============================================================================== | ||
| 247 | namespace kodi { | ||
| 248 | /// | ||
| 249 | class CSettingValue | ||
| 250 | { | ||
| 251 | public: | ||
| 252 | CSettingValue(const void *settingValue) : m_settingValue(settingValue) {} | ||
| 253 | |||
| 254 | bool empty() const { return (m_settingValue == nullptr) ? true : false; } | ||
| 255 | std::string GetString() const { return (char*)m_settingValue; } | ||
| 256 | int GetInt() const { return *(int*)m_settingValue; } | ||
| 257 | unsigned int GetUInt() const { return *(unsigned int*)m_settingValue; } | ||
| 258 | bool GetBoolean() const { return *(bool*)m_settingValue; } | ||
| 259 | float GetFloat() const { return *(float*)m_settingValue; } | ||
| 260 | |||
| 261 | private: | ||
| 262 | const void *m_settingValue; | ||
| 263 | }; | ||
| 264 | } /* namespace kodi */ | ||
| 265 | //------------------------------------------------------------------------------ | ||
| 266 | |||
| 267 | //============================================================================== | ||
| 268 | namespace kodi { | ||
| 269 | namespace addon { | ||
| 270 | /// Add-on main instance class. | ||
| 271 | class CAddonBase | ||
| 272 | { | ||
| 273 | public: | ||
| 274 | CAddonBase() | ||
| 275 | { | ||
| 276 | CAddonBase::m_interface->toAddon->destroy = ADDONBASE_Destroy; | ||
| 277 | CAddonBase::m_interface->toAddon->get_status = ADDONBASE_GetStatus; | ||
| 278 | CAddonBase::m_interface->toAddon->create_instance = ADDONBASE_CreateInstance; | ||
| 279 | CAddonBase::m_interface->toAddon->destroy_instance = ADDONBASE_DestroyInstance; | ||
| 280 | CAddonBase::m_interface->toAddon->set_setting = ADDONBASE_SetSetting; | ||
| 281 | } | ||
| 282 | |||
| 283 | virtual ~CAddonBase() = default; | ||
| 284 | |||
| 285 | virtual ADDON_STATUS Create() { return ADDON_STATUS_OK; } | ||
| 286 | |||
| 287 | virtual ADDON_STATUS GetStatus() { return ADDON_STATUS_OK; } | ||
| 288 | |||
| 289 | virtual ADDON_STATUS SetSetting(const std::string& settingName, const CSettingValue& settingValue) { return ADDON_STATUS_UNKNOWN; } | ||
| 290 | |||
| 291 | virtual ADDON_STATUS CreateInstance(int instanceType, std::string instanceID, KODI_HANDLE instance, KODI_HANDLE& addonInstance) | ||
| 292 | { | ||
| 293 | /* The handling below is intended for the case of the add-on only one | ||
| 294 | * instance and this is integrated in the add-on base class. | ||
| 295 | */ | ||
| 296 | |||
| 297 | /* Check about single instance usage */ | ||
| 298 | if (CAddonBase::m_interface->firstKodiInstance == instance && // the kodi side instance pointer must be equal to first one | ||
| 299 | CAddonBase::m_interface->globalSingleInstance && // the addon side instance pointer must be set | ||
| 300 | CAddonBase::m_interface->globalSingleInstance->m_type == instanceType) // and the requested type must be equal with used add-on class | ||
| 301 | { | ||
| 302 | addonInstance = CAddonBase::m_interface->globalSingleInstance; | ||
| 303 | return ADDON_STATUS_OK; | ||
| 304 | } | ||
| 305 | |||
| 306 | return ADDON_STATUS_UNKNOWN; | ||
| 307 | } | ||
| 308 | |||
| 309 | /* Global variables of class */ | ||
| 310 | static AddonGlobalInterface* m_interface; // Interface function table to hold addresses on add-on and from kodi | ||
| 311 | |||
| 312 | /*private:*/ /* Needed public as long the old call functions becomes used! */ | ||
| 313 | static inline void ADDONBASE_Destroy() | ||
| 314 | { | ||
| 315 | delete CAddonBase::m_interface->addonBase; | ||
| 316 | CAddonBase::m_interface->addonBase = nullptr; | ||
| 317 | } | ||
| 318 | |||
| 319 | static inline ADDON_STATUS ADDONBASE_GetStatus() { return CAddonBase::m_interface->addonBase->GetStatus(); } | ||
| 320 | |||
| 321 | static inline ADDON_STATUS ADDONBASE_SetSetting(const char *settingName, const void *settingValue) | ||
| 322 | { | ||
| 323 | return CAddonBase::m_interface->addonBase->SetSetting(settingName, CSettingValue(settingValue)); | ||
| 324 | } | ||
| 325 | |||
| 326 | static inline ADDON_STATUS ADDONBASE_CreateInstance(int instanceType, const char* instanceID, KODI_HANDLE instance, KODI_HANDLE* addonInstance, KODI_HANDLE parent) | ||
| 327 | { | ||
| 328 | ADDON_STATUS status = ADDON_STATUS_NOT_IMPLEMENTED; | ||
| 329 | if (parent != nullptr) | ||
| 330 | status = static_cast<IAddonInstance*>(parent)->CreateInstance(instanceType, instanceID, instance, *addonInstance); | ||
| 331 | if (status == ADDON_STATUS_NOT_IMPLEMENTED) | ||
| 332 | status = CAddonBase::m_interface->addonBase->CreateInstance(instanceType, instanceID, instance, *addonInstance); | ||
| 333 | if (*addonInstance == nullptr) | ||
| 334 | throw std::logic_error("kodi::addon::CAddonBase CreateInstance returns a empty instance pointer!"); | ||
| 335 | |||
| 336 | if (static_cast<::kodi::addon::IAddonInstance*>(*addonInstance)->m_type != instanceType) | ||
| 337 | throw std::logic_error("kodi::addon::CAddonBase CreateInstance with difference on given and returned instance type!"); | ||
| 338 | |||
| 339 | return status; | ||
| 340 | } | ||
| 341 | |||
| 342 | static inline void ADDONBASE_DestroyInstance(int instanceType, KODI_HANDLE instance) | ||
| 343 | { | ||
| 344 | if (CAddonBase::m_interface->globalSingleInstance == nullptr && instance != CAddonBase::m_interface->addonBase) | ||
| 345 | { | ||
| 346 | if (static_cast<::kodi::addon::IAddonInstance*>(instance)->m_type == instanceType) | ||
| 347 | delete static_cast<::kodi::addon::IAddonInstance*>(instance); | ||
| 348 | else | ||
| 349 | throw std::logic_error("kodi::addon::CAddonBase DestroyInstance called with difference on given and present instance type!"); | ||
| 350 | } | ||
| 351 | } | ||
| 352 | }; | ||
| 353 | } /* namespace addon */ | ||
| 354 | } /* namespace kodi */ | ||
| 355 | //------------------------------------------------------------------------------ | ||
| 356 | |||
| 357 | //============================================================================== | ||
| 358 | namespace kodi { | ||
| 359 | /// | ||
| 360 | inline std::string GetAddonPath(const std::string& append = "") | ||
| 361 | { | ||
| 362 | char* str = ::kodi::addon::CAddonBase::m_interface->toKodi->get_addon_path(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase); | ||
| 363 | std::string ret = str; | ||
| 364 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, str); | ||
| 365 | if (!append.empty()) | ||
| 366 | { | ||
| 367 | if (append.at(0) != '\\' && | ||
| 368 | append.at(0) != '/') | ||
| 369 | #ifdef TARGET_WINDOWS | ||
| 370 | ret.append("\\"); | ||
| 371 | #else | ||
| 372 | ret.append("/"); | ||
| 373 | #endif | ||
| 374 | ret.append(append); | ||
| 375 | } | ||
| 376 | return ret; | ||
| 377 | } | ||
| 378 | } /* namespace kodi */ | ||
| 379 | //------------------------------------------------------------------------------ | ||
| 380 | |||
| 381 | //============================================================================== | ||
| 382 | namespace kodi { | ||
| 383 | /// | ||
| 384 | inline std::string GetBaseUserPath(const std::string& append = "") | ||
| 385 | { | ||
| 386 | char* str = ::kodi::addon::CAddonBase::m_interface->toKodi->get_base_user_path(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase); | ||
| 387 | std::string ret = str; | ||
| 388 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, str); | ||
| 389 | if (!append.empty()) | ||
| 390 | { | ||
| 391 | if (append.at(0) != '\\' && | ||
| 392 | append.at(0) != '/') | ||
| 393 | #ifdef TARGET_WINDOWS | ||
| 394 | ret.append("\\"); | ||
| 395 | #else | ||
| 396 | ret.append("/"); | ||
| 397 | #endif | ||
| 398 | ret.append(append); | ||
| 399 | } | ||
| 400 | return ret; | ||
| 401 | } | ||
| 402 | } /* namespace kodi */ | ||
| 403 | //------------------------------------------------------------------------------ | ||
| 404 | |||
| 405 | //============================================================================== | ||
| 406 | namespace kodi { | ||
| 407 | /// | ||
| 408 | inline std::string GetLibPath() | ||
| 409 | { | ||
| 410 | return ::kodi::addon::CAddonBase::m_interface->libBasePath; | ||
| 411 | } | ||
| 412 | } /* namespace kodi */ | ||
| 413 | //------------------------------------------------------------------------------ | ||
| 414 | |||
| 415 | //============================================================================== | ||
| 416 | namespace kodi { | ||
| 417 | /// | ||
| 418 | inline void Log(const AddonLog loglevel, const char* format, ...) | ||
| 419 | { | ||
| 420 | char buffer[16384]; | ||
| 421 | va_list args; | ||
| 422 | va_start(args, format); | ||
| 423 | vsprintf(buffer, format, args); | ||
| 424 | va_end(args); | ||
| 425 | ::kodi::addon::CAddonBase::m_interface->toKodi->addon_log_msg(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, loglevel, buffer); | ||
| 426 | } | ||
| 427 | } /* namespace kodi */ | ||
| 428 | //------------------------------------------------------------------------------ | ||
| 429 | |||
| 430 | //============================================================================ | ||
| 431 | namespace kodi { | ||
| 432 | /// | ||
| 433 | inline bool CheckSettingString(const std::string& settingName, std::string& settingValue) | ||
| 434 | { | ||
| 435 | char * buffer = nullptr; | ||
| 436 | bool ret = ::kodi::addon::CAddonBase::m_interface->toKodi->get_setting(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &buffer); | ||
| 437 | if (buffer) | ||
| 438 | { | ||
| 439 | if (ret) | ||
| 440 | settingValue = buffer; | ||
| 441 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, buffer); | ||
| 442 | } | ||
| 443 | return ret; | ||
| 444 | } | ||
| 445 | } /* namespace kodi */ | ||
| 446 | //---------------------------------------------------------------------------- | ||
| 447 | |||
| 448 | //============================================================================ | ||
| 449 | namespace kodi { | ||
| 450 | /// | ||
| 451 | inline std::string GetSettingString(const std::string& settingName) | ||
| 452 | { | ||
| 453 | std::string settingValue; | ||
| 454 | CheckSettingString(settingName, settingValue); | ||
| 455 | return settingValue; | ||
| 456 | } | ||
| 457 | } /* namespace kodi */ | ||
| 458 | //---------------------------------------------------------------------------- | ||
| 459 | |||
| 460 | //============================================================================ | ||
| 461 | namespace kodi { | ||
| 462 | /// | ||
| 463 | inline void SetSettingString(const std::string& settingName, const std::string& settingValue) | ||
| 464 | { | ||
| 465 | ::kodi::addon::CAddonBase::m_interface->toKodi->set_setting(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue.c_str()); | ||
| 466 | } | ||
| 467 | } /* namespace kodi */ | ||
| 468 | //---------------------------------------------------------------------------- | ||
| 469 | |||
| 470 | //============================================================================ | ||
| 471 | namespace kodi { | ||
| 472 | /// | ||
| 473 | inline bool CheckSettingInt(const std::string& settingName, int& settingValue) | ||
| 474 | { | ||
| 475 | return ::kodi::addon::CAddonBase::m_interface->toKodi->get_setting(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue); | ||
| 476 | } | ||
| 477 | } /* namespace kodi */ | ||
| 478 | //---------------------------------------------------------------------------- | ||
| 479 | |||
| 480 | //============================================================================ | ||
| 481 | namespace kodi { | ||
| 482 | /// | ||
| 483 | inline int GetSettingInt(const std::string& settingName) | ||
| 484 | { | ||
| 485 | int settingValue = 0; | ||
| 486 | CheckSettingInt(settingName, settingValue); | ||
| 487 | return settingValue; | ||
| 488 | } | ||
| 489 | } /* namespace kodi */ | ||
| 490 | //---------------------------------------------------------------------------- | ||
| 491 | |||
| 492 | //============================================================================ | ||
| 493 | namespace kodi { | ||
| 494 | /// | ||
| 495 | inline void SetSettingInt(const std::string& settingName, int settingValue) | ||
| 496 | { | ||
| 497 | char buffer[33]; | ||
| 498 | snprintf(buffer, sizeof(buffer), "%i", settingValue); | ||
| 499 | ::kodi::addon::CAddonBase::m_interface->toKodi->set_setting(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), buffer); | ||
| 500 | } | ||
| 501 | } /* namespace kodi */ | ||
| 502 | //---------------------------------------------------------------------------- | ||
| 503 | |||
| 504 | //============================================================================ | ||
| 505 | namespace kodi { | ||
| 506 | /// | ||
| 507 | inline bool CheckSettingBoolean(const std::string& settingName, bool& settingValue) | ||
| 508 | { | ||
| 509 | return ::kodi::addon::CAddonBase::m_interface->toKodi->get_setting(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue); | ||
| 510 | } | ||
| 511 | } /* namespace kodi */ | ||
| 512 | //---------------------------------------------------------------------------- | ||
| 513 | |||
| 514 | //============================================================================ | ||
| 515 | namespace kodi { | ||
| 516 | /// | ||
| 517 | inline bool GetSettingBoolean(const std::string& settingName) | ||
| 518 | { | ||
| 519 | bool settingValue = false; | ||
| 520 | CheckSettingBoolean(settingName, settingValue); | ||
| 521 | return settingValue; | ||
| 522 | } | ||
| 523 | } /* namespace kodi */ | ||
| 524 | //---------------------------------------------------------------------------- | ||
| 525 | |||
| 526 | //============================================================================ | ||
| 527 | namespace kodi { | ||
| 528 | /// | ||
| 529 | inline void SetSettingBoolean(const std::string& settingName, bool settingValue) | ||
| 530 | { | ||
| 531 | ::kodi::addon::CAddonBase::m_interface->toKodi->set_setting(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue ? "true" : "false"); | ||
| 532 | } | ||
| 533 | } /* namespace kodi */ | ||
| 534 | //---------------------------------------------------------------------------- | ||
| 535 | |||
| 536 | //============================================================================ | ||
| 537 | namespace kodi { | ||
| 538 | /// | ||
| 539 | inline bool CheckSettingFloat(const std::string& settingName, float& settingValue) | ||
| 540 | { | ||
| 541 | return ::kodi::addon::CAddonBase::m_interface->toKodi->get_setting(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue); | ||
| 542 | } | ||
| 543 | } /* namespace kodi */ | ||
| 544 | //---------------------------------------------------------------------------- | ||
| 545 | |||
| 546 | //============================================================================ | ||
| 547 | namespace kodi { | ||
| 548 | /// | ||
| 549 | inline float GetSettingFloat(const std::string& settingName) | ||
| 550 | { | ||
| 551 | float settingValue = 0.0f; | ||
| 552 | CheckSettingFloat(settingName, settingValue); | ||
| 553 | return settingValue; | ||
| 554 | } | ||
| 555 | } /* namespace kodi */ | ||
| 556 | //---------------------------------------------------------------------------- | ||
| 557 | |||
| 558 | //============================================================================ | ||
| 559 | namespace kodi { | ||
| 560 | /// | ||
| 561 | inline void SetSettingFloat(const std::string& settingName, float settingValue) | ||
| 562 | { | ||
| 563 | char buffer[50]; | ||
| 564 | snprintf(buffer, sizeof(buffer), "%f", settingValue); | ||
| 565 | ::kodi::addon::CAddonBase::m_interface->toKodi->set_setting(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), buffer); | ||
| 566 | } | ||
| 567 | } /* namespace kodi */ | ||
| 568 | //---------------------------------------------------------------------------- | ||
| 569 | |||
| 570 | //============================================================================ | ||
| 571 | namespace kodi { | ||
| 572 | /// | ||
| 573 | inline std::string TranslateAddonStatus(ADDON_STATUS status) | ||
| 574 | { | ||
| 575 | switch (status) | ||
| 576 | { | ||
| 577 | case ADDON_STATUS_OK: | ||
| 578 | return "OK"; | ||
| 579 | case ADDON_STATUS_LOST_CONNECTION: | ||
| 580 | return "Lost Connection"; | ||
| 581 | case ADDON_STATUS_NEED_RESTART: | ||
| 582 | return "Need Restart"; | ||
| 583 | case ADDON_STATUS_NEED_SETTINGS: | ||
| 584 | return "Need Settings"; | ||
| 585 | case ADDON_STATUS_UNKNOWN: | ||
| 586 | return "Unknown error"; | ||
| 587 | case ADDON_STATUS_NEED_SAVEDSETTINGS: | ||
| 588 | return "Need saved settings"; | ||
| 589 | case ADDON_STATUS_PERMANENT_FAILURE: | ||
| 590 | return "Permanent failure"; | ||
| 591 | case ADDON_STATUS_NOT_IMPLEMENTED: | ||
| 592 | return "Not implemented"; | ||
| 593 | default: | ||
| 594 | break; | ||
| 595 | } | ||
| 596 | return "Unknown"; | ||
| 597 | } | ||
| 598 | } /* namespace kodi */ | ||
| 599 | //---------------------------------------------------------------------------- | ||
| 600 | |||
| 601 | |||
| 602 | /*! addon creation macro | ||
| 603 | * @todo cleanup this stupid big macro | ||
| 604 | * This macro includes now all for add-on's needed functions. This becomes a bigger | ||
| 605 | * rework after everything is done on Kodi itself, currently is this way needed | ||
| 606 | * to have compatibility with not reworked interfaces. | ||
| 607 | * | ||
| 608 | * Becomes really cleaned up soon :D | ||
| 609 | */ | ||
| 610 | #define ADDONCREATOR(AddonClass) \ | ||
| 611 | extern "C" __declspec(dllexport) void get_addon(void* pAddon) {} \ | ||
| 612 | extern "C" __declspec(dllexport) ADDON_STATUS ADDON_Create(KODI_HANDLE addonInterface, void *unused) \ | ||
| 613 | { \ | ||
| 614 | kodi::addon::CAddonBase::m_interface = static_cast<AddonGlobalInterface*>(addonInterface); \ | ||
| 615 | kodi::addon::CAddonBase::m_interface->addonBase = new AddonClass; \ | ||
| 616 | return kodi::addon::CAddonBase::m_interface->addonBase->Create(); \ | ||
| 617 | } \ | ||
| 618 | extern "C" __declspec(dllexport) void ADDON_Destroy() \ | ||
| 619 | { \ | ||
| 620 | kodi::addon::CAddonBase::ADDONBASE_Destroy(); \ | ||
| 621 | } \ | ||
| 622 | extern "C" __declspec(dllexport) ADDON_STATUS ADDON_GetStatus() \ | ||
| 623 | { \ | ||
| 624 | return kodi::addon::CAddonBase::ADDONBASE_GetStatus(); \ | ||
| 625 | } \ | ||
| 626 | extern "C" __declspec(dllexport) ADDON_STATUS ADDON_SetSetting(const char *settingName, const void *settingValue) \ | ||
| 627 | { \ | ||
| 628 | return kodi::addon::CAddonBase::ADDONBASE_SetSetting(settingName, settingValue); \ | ||
| 629 | } \ | ||
| 630 | extern "C" __declspec(dllexport) const char* ADDON_GetTypeVersion(int type) \ | ||
| 631 | { \ | ||
| 632 | return kodi::addon::GetTypeVersion(type); \ | ||
| 633 | } \ | ||
| 634 | AddonGlobalInterface* kodi::addon::CAddonBase::m_interface = nullptr; | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AudioEngine.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/AudioEngine.h new file mode 100644 index 0000000..380e5e2 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/AudioEngine.h | |||
| @@ -0,0 +1,580 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with Kodi; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "AddonBase.h" | ||
| 23 | |||
| 24 | #ifdef BUILD_KODI_ADDON | ||
| 25 | #include "AEChannelData.h" | ||
| 26 | #else | ||
| 27 | #include "cores/AudioEngine/Utils/AEChannelData.h" | ||
| 28 | #endif | ||
| 29 | |||
| 30 | //============================================================================== | ||
| 31 | /// | ||
| 32 | /// \defgroup cpp_kodi_audioengine Interface - kodi::audioengine | ||
| 33 | /// \ingroup cpp | ||
| 34 | /// @brief **Audio engine functions** | ||
| 35 | /// | ||
| 36 | /// | ||
| 37 | /// It has the header \ref AudioEngine.h "#include <kodi/AudioEngine.h>" be included | ||
| 38 | /// to enjoy it. | ||
| 39 | /// | ||
| 40 | //------------------------------------------------------------------------------ | ||
| 41 | |||
| 42 | //============================================================================== | ||
| 43 | /// | ||
| 44 | /// \defgroup cpp_kodi_audioengine_Defs Definitions, structures and enumerators | ||
| 45 | /// \ingroup cpp_kodi_audioengine | ||
| 46 | /// @brief **Library definition values** | ||
| 47 | /// | ||
| 48 | //------------------------------------------------------------------------------ | ||
| 49 | |||
| 50 | extern "C" | ||
| 51 | { | ||
| 52 | |||
| 53 | //============================================================================ | ||
| 54 | /// \ingroup cpp_kodi_audioengine_Defs | ||
| 55 | /// @brief Bit options to pass to CAddonAEStream | ||
| 56 | /// | ||
| 57 | typedef enum AudioEngineStreamOptions | ||
| 58 | { | ||
| 59 | /// force resample even if rates match | ||
| 60 | AUDIO_STREAM_FORCE_RESAMPLE = 1 << 0, | ||
| 61 | /// create the stream paused | ||
| 62 | AUDIO_STREAM_PAUSED = 1 << 1, | ||
| 63 | /// autostart the stream when enough data is buffered | ||
| 64 | AUDIO_STREAM_AUTOSTART = 1 << 2, | ||
| 65 | /// if this option is set the ADSP-System is bypassed and the raw stream | ||
| 66 | /// will be passed through IAESink | ||
| 67 | AUDIO_STREAM_BYPASS_ADSP = 1 << 3 | ||
| 68 | } AudioEngineStreamOptions; | ||
| 69 | //---------------------------------------------------------------------------- | ||
| 70 | |||
| 71 | //============================================================================ | ||
| 72 | /// \defgroup cpp_kodi_audioengine_Defs_AudioEngineFormat struct AudioEngineFormat | ||
| 73 | /// \ingroup cpp_kodi_audioengine_Defs | ||
| 74 | /// @brief The audio format structure that fully defines a stream's audio | ||
| 75 | /// information | ||
| 76 | /// | ||
| 77 | //@{ | ||
| 78 | struct AudioEngineFormat | ||
| 79 | { | ||
| 80 | /// The stream's data format (eg, AE_FMT_S16LE) | ||
| 81 | enum AEDataFormat m_dataFormat; | ||
| 82 | |||
| 83 | /// The stream's sample rate (eg, 48000) | ||
| 84 | unsigned int m_sampleRate; | ||
| 85 | |||
| 86 | /// The encoded streams sample rate if a bitstream, otherwise undefined | ||
| 87 | unsigned int m_encodedRate; | ||
| 88 | |||
| 89 | /// The amount of used speaker channels | ||
| 90 | unsigned int m_channelCount; | ||
| 91 | |||
| 92 | /// The stream's channel layout | ||
| 93 | enum AEChannel m_channels[AE_CH_MAX]; | ||
| 94 | |||
| 95 | /// The number of frames per period | ||
| 96 | unsigned int m_frames; | ||
| 97 | |||
| 98 | /// The size of one frame in bytes | ||
| 99 | unsigned int m_frameSize; | ||
| 100 | |||
| 101 | AudioEngineFormat() | ||
| 102 | { | ||
| 103 | m_dataFormat = AE_FMT_INVALID; | ||
| 104 | m_sampleRate = 0; | ||
| 105 | m_encodedRate = 0; | ||
| 106 | m_frames = 0; | ||
| 107 | m_frameSize = 0; | ||
| 108 | m_channelCount = 0; | ||
| 109 | |||
| 110 | for (unsigned int ch = 0; ch < AE_CH_MAX; ++ch) | ||
| 111 | { | ||
| 112 | m_channels[ch] = AE_CH_MAX; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | /// Function to compare the format structure with another | ||
| 117 | bool compareFormat(const AudioEngineFormat *fmt) | ||
| 118 | { | ||
| 119 | if (!fmt) | ||
| 120 | { | ||
| 121 | return false; | ||
| 122 | } | ||
| 123 | |||
| 124 | if (m_dataFormat != fmt->m_dataFormat || | ||
| 125 | m_sampleRate != fmt->m_sampleRate || | ||
| 126 | m_encodedRate != fmt->m_encodedRate || | ||
| 127 | m_frames != fmt->m_frames || | ||
| 128 | m_frameSize != fmt->m_frameSize || | ||
| 129 | m_channelCount != fmt->m_channelCount) | ||
| 130 | { | ||
| 131 | return false; | ||
| 132 | } | ||
| 133 | |||
| 134 | for (unsigned int ch = 0; ch < AE_CH_MAX; ++ch) | ||
| 135 | { | ||
| 136 | if (fmt->m_channels[ch] != m_channels[ch]) | ||
| 137 | { | ||
| 138 | return false; | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | return true; | ||
| 143 | } | ||
| 144 | }; | ||
| 145 | //@} | ||
| 146 | //---------------------------------------------------------------------------- | ||
| 147 | |||
| 148 | /* A stream handle pointer, which is only used internally by the addon stream handle */ | ||
| 149 | typedef void AEStreamHandle; | ||
| 150 | |||
| 151 | /* | ||
| 152 | * Function address structure, not need to visible on dev kit doxygen | ||
| 153 | * documentation | ||
| 154 | */ | ||
| 155 | typedef struct AddonToKodiFuncTable_kodi_audioengine | ||
| 156 | { | ||
| 157 | AEStreamHandle* (*MakeStream) (void *kodiBase, AudioEngineFormat format, unsigned int options); | ||
| 158 | void (*FreeStream) (void *kodiBase, AEStreamHandle *stream); | ||
| 159 | bool (*GetCurrentSinkFormat) (void *kodiBase, AudioEngineFormat *SinkFormat); | ||
| 160 | |||
| 161 | // Audio Engine Stream definitions | ||
| 162 | unsigned int (*AEStream_GetSpace) (void *kodiBase, AEStreamHandle *handle); | ||
| 163 | unsigned int (*AEStream_AddData) (void *kodiBase, AEStreamHandle *handle, uint8_t* const *Data, unsigned int Offset, unsigned int Frames); | ||
| 164 | double (*AEStream_GetDelay)(void *kodiBase, AEStreamHandle *handle); | ||
| 165 | bool (*AEStream_IsBuffering)(void *kodiBase, AEStreamHandle *handle); | ||
| 166 | double (*AEStream_GetCacheTime)(void *kodiBase, AEStreamHandle *handle); | ||
| 167 | double (*AEStream_GetCacheTotal)(void *kodiBase, AEStreamHandle *handle); | ||
| 168 | void (*AEStream_Pause)(void *kodiBase, AEStreamHandle *handle); | ||
| 169 | void (*AEStream_Resume)(void *kodiBase, AEStreamHandle *handle); | ||
| 170 | void (*AEStream_Drain)(void *kodiBase, AEStreamHandle *handle, bool Wait); | ||
| 171 | bool (*AEStream_IsDraining)(void *kodiBase, AEStreamHandle *handle); | ||
| 172 | bool (*AEStream_IsDrained)(void *kodiBase, AEStreamHandle *handle); | ||
| 173 | void (*AEStream_Flush)(void *kodiBase, AEStreamHandle *handle); | ||
| 174 | float (*AEStream_GetVolume)(void *kodiBase, AEStreamHandle *handle); | ||
| 175 | void (*AEStream_SetVolume)(void *kodiBase, AEStreamHandle *handle, float Volume); | ||
| 176 | float (*AEStream_GetAmplification)(void *kodiBase, AEStreamHandle *handle); | ||
| 177 | void (*AEStream_SetAmplification)(void *kodiBase, AEStreamHandle *handle, float Amplify); | ||
| 178 | const unsigned int (*AEStream_GetFrameSize)(void *kodiBase, AEStreamHandle *handle); | ||
| 179 | const unsigned int (*AEStream_GetChannelCount)(void *kodiBase, AEStreamHandle *handle); | ||
| 180 | const unsigned int (*AEStream_GetSampleRate)(void *kodiBase, AEStreamHandle *handle); | ||
| 181 | const AEDataFormat (*AEStream_GetDataFormat)(void *kodiBase, AEStreamHandle *handle); | ||
| 182 | double (*AEStream_GetResampleRatio)(void *kodiBase, AEStreamHandle *handle); | ||
| 183 | void (*AEStream_SetResampleRatio)(void *kodiBase, AEStreamHandle *handle, double Ratio); | ||
| 184 | } AddonToKodiFuncTable_kodi_audioengine; | ||
| 185 | |||
| 186 | } /* extern "C" */ | ||
| 187 | |||
| 188 | namespace kodi | ||
| 189 | { | ||
| 190 | namespace audioengine | ||
| 191 | { | ||
| 192 | |||
| 193 | //============================================================================ | ||
| 194 | /// | ||
| 195 | /// \defgroup cpp_kodi_audioengine_CAddonAEStream class CAddonAEStream | ||
| 196 | /// \ingroup cpp_kodi_audioengine | ||
| 197 | /// @brief **Audio Engine Stream Class** | ||
| 198 | /// | ||
| 199 | /// | ||
| 200 | /// It has the header \ref AudioEngine.h "#include <kodi/AudioEngine.h>" be | ||
| 201 | /// included to enjoy it. | ||
| 202 | /// | ||
| 203 | //---------------------------------------------------------------------------- | ||
| 204 | class CAddonAEStream | ||
| 205 | { | ||
| 206 | public: | ||
| 207 | //========================================================================== | ||
| 208 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 209 | /// @brief Contructs new class to an Kodi IAEStream in the format specified. | ||
| 210 | /// | ||
| 211 | /// @param[in] format The data format the incoming audio will be in | ||
| 212 | /// (e.g. \ref AE_FMT_S16LE) | ||
| 213 | /// @param[in] options [opt] A bit field of stream options (see: enum \ref AudioEngineStreamOptions) | ||
| 214 | /// | ||
| 215 | /// | ||
| 216 | /// ------------------------------------------------------------------------ | ||
| 217 | /// | ||
| 218 | /// **Audio engine format information:** | ||
| 219 | /// @code | ||
| 220 | /// /* | ||
| 221 | /// * Audio engine format information | ||
| 222 | /// * | ||
| 223 | /// * Only as example shown here! See always the original structure on related header. | ||
| 224 | /// */ | ||
| 225 | /// typedef struct AudioEngineFormat | ||
| 226 | /// { | ||
| 227 | /// enum AEDataFormat m_dataFormat; /* The stream's data format (eg, AE_FMT_S16LE) */ | ||
| 228 | /// unsigned int m_sampleRate; /* The stream's sample rate (eg, 48000) */ | ||
| 229 | /// unsigned int m_encodedRate; /* The encoded streams sample rate if a bitstream, otherwise undefined */ | ||
| 230 | /// unsigned int m_channelCount; /* The amount of used speaker channels */ | ||
| 231 | /// enum AEChannel m_channels[AE_CH_MAX]; /* The stream's channel layout */ | ||
| 232 | /// unsigned int m_frames; /* The number of frames per period */ | ||
| 233 | /// unsigned int m_frameSamples; /* The number of samples in one frame */ | ||
| 234 | /// unsigned int m_frameSize; /* The size of one frame in bytes */ | ||
| 235 | /// | ||
| 236 | /// /* Function to compare the format structure with another */ | ||
| 237 | /// bool compareFormat(const AudioEngineFormat *fmt); | ||
| 238 | /// } AudioEngineFormat; | ||
| 239 | /// @endcode | ||
| 240 | /// | ||
| 241 | /// ------------------------------------------------------------------------ | ||
| 242 | /// | ||
| 243 | /// **Bit options to pass to CAELib_Stream (on Kodi by <c>IAE::MakeStream</c>)** | ||
| 244 | /// | ||
| 245 | /// | enum AEStreamOptions | Value: | Description: | ||
| 246 | /// |-------------------------:|:------:|:----------------------------------- | ||
| 247 | /// | AE_STREAM_FORCE_RESAMPLE | 1 << 0 | Force resample even if rates match | ||
| 248 | /// | AE_STREAM_PAUSED | 1 << 1 | Create the stream paused | ||
| 249 | /// | AE_STREAM_AUTOSTART | 1 << 2 | Autostart the stream when enough data is buffered | ||
| 250 | /// | AE_STREAM_BYPASS_ADSP | 1 << 3 | if this option is set the ADSP-System is bypassed and the raw stream will be passed through IAESink. | ||
| 251 | /// | ||
| 252 | /// | ||
| 253 | /// ------------------------------------------------------------------------ | ||
| 254 | /// | ||
| 255 | /// **Example:** | ||
| 256 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 257 | /// | ||
| 258 | /// #include <kodi/AudioEngine.h> | ||
| 259 | /// | ||
| 260 | /// using namespace kodi::audioengine; | ||
| 261 | /// | ||
| 262 | /// ... | ||
| 263 | /// | ||
| 264 | /// CAddonAEStream* stream = new CAddonAEStream(AE_FMT_S16LE, AE_STREAM_AUTOSTART | AE_STREAM_BYPASS_ADSP); | ||
| 265 | /// | ||
| 266 | /// ~~~~~~~~~~~~~ | ||
| 267 | /// | ||
| 268 | CAddonAEStream(AudioEngineFormat format, unsigned int options = 0) | ||
| 269 | : m_kodiBase(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase), | ||
| 270 | m_cb(::kodi::addon::CAddonBase::m_interface->toKodi->kodi_audioengine) | ||
| 271 | { | ||
| 272 | AEStreamHandle *streamHandle = m_cb->MakeStream(m_kodiBase, format, options); | ||
| 273 | if (streamHandle == nullptr) | ||
| 274 | { | ||
| 275 | kodi::Log(ADDON_LOG_FATAL, "CAddonAEStream: MakeStream failed!"); | ||
| 276 | } | ||
| 277 | } | ||
| 278 | //-------------------------------------------------------------------------- | ||
| 279 | |||
| 280 | ~CAddonAEStream() | ||
| 281 | { | ||
| 282 | if (m_StreamHandle) | ||
| 283 | { | ||
| 284 | m_cb->FreeStream(m_kodiBase, m_StreamHandle); | ||
| 285 | m_StreamHandle = nullptr; | ||
| 286 | } | ||
| 287 | } | ||
| 288 | |||
| 289 | //========================================================================== | ||
| 290 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 291 | /// @brief Returns the amount of space available in the stream | ||
| 292 | /// | ||
| 293 | /// @return The number of bytes AddData will consume | ||
| 294 | /// | ||
| 295 | unsigned int GetSpace() | ||
| 296 | { | ||
| 297 | return m_cb->AEStream_GetSpace(m_kodiBase, m_StreamHandle); | ||
| 298 | } | ||
| 299 | //-------------------------------------------------------------------------- | ||
| 300 | |||
| 301 | //========================================================================== | ||
| 302 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 303 | /// @brief Add planar or interleaved PCM data to the stream | ||
| 304 | /// | ||
| 305 | /// @param data array of pointers to the planes | ||
| 306 | /// @param offset to frame in frames | ||
| 307 | /// @param frames number of frames | ||
| 308 | /// @return The number of frames consumed | ||
| 309 | /// | ||
| 310 | unsigned int AddData(uint8_t* const *data, unsigned int offset, unsigned int frames) | ||
| 311 | { | ||
| 312 | return m_cb->AEStream_AddData(m_kodiBase, m_StreamHandle, data, offset, frames); | ||
| 313 | } | ||
| 314 | //-------------------------------------------------------------------------- | ||
| 315 | |||
| 316 | //========================================================================== | ||
| 317 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 318 | /// @brief Returns the time in seconds that it will take for the next added | ||
| 319 | /// packet to be heard from the speakers. | ||
| 320 | /// | ||
| 321 | /// @return seconds | ||
| 322 | /// | ||
| 323 | double GetDelay() | ||
| 324 | { | ||
| 325 | return m_cb->AEStream_GetDelay(m_kodiBase, m_StreamHandle); | ||
| 326 | } | ||
| 327 | //-------------------------------------------------------------------------- | ||
| 328 | |||
| 329 | //========================================================================== | ||
| 330 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 331 | /// @brief Returns if the stream is buffering | ||
| 332 | /// | ||
| 333 | /// @return True if the stream is buffering | ||
| 334 | /// | ||
| 335 | bool IsBuffering() | ||
| 336 | { | ||
| 337 | return m_cb->AEStream_IsBuffering(m_kodiBase, m_StreamHandle); | ||
| 338 | } | ||
| 339 | //-------------------------------------------------------------------------- | ||
| 340 | |||
| 341 | //========================================================================== | ||
| 342 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 343 | /// @brief Returns the time in seconds of the stream's cached audio samples. | ||
| 344 | /// Engine buffers excluded. | ||
| 345 | /// | ||
| 346 | /// @return seconds | ||
| 347 | /// | ||
| 348 | double GetCacheTime() | ||
| 349 | { | ||
| 350 | return m_cb->AEStream_GetCacheTime(m_kodiBase, m_StreamHandle); | ||
| 351 | } | ||
| 352 | //-------------------------------------------------------------------------- | ||
| 353 | |||
| 354 | //========================================================================== | ||
| 355 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 356 | /// @brief Returns the total time in seconds of the cache | ||
| 357 | /// | ||
| 358 | /// @return seconds | ||
| 359 | /// | ||
| 360 | double GetCacheTotal() | ||
| 361 | { | ||
| 362 | return m_cb->AEStream_GetCacheTotal(m_kodiBase, m_StreamHandle); | ||
| 363 | } | ||
| 364 | //-------------------------------------------------------------------------- | ||
| 365 | |||
| 366 | //========================================================================== | ||
| 367 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 368 | /// @brief Pauses the stream playback | ||
| 369 | /// | ||
| 370 | void Pause() | ||
| 371 | { | ||
| 372 | return m_cb->AEStream_Pause(m_kodiBase, m_StreamHandle); | ||
| 373 | } | ||
| 374 | //-------------------------------------------------------------------------- | ||
| 375 | |||
| 376 | //========================================================================== | ||
| 377 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 378 | /// @brief Resumes the stream after pausing | ||
| 379 | /// | ||
| 380 | void Resume() | ||
| 381 | { | ||
| 382 | return m_cb->AEStream_Resume(m_kodiBase, m_StreamHandle); | ||
| 383 | } | ||
| 384 | //-------------------------------------------------------------------------- | ||
| 385 | |||
| 386 | //========================================================================== | ||
| 387 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 388 | /// @brief Start draining the stream | ||
| 389 | /// | ||
| 390 | /// @param[in] wait [opt] Wait until drain is finished if set to | ||
| 391 | /// true, otherwise it returns direct | ||
| 392 | /// | ||
| 393 | /// @note Once called AddData will not consume more data. | ||
| 394 | /// | ||
| 395 | void Drain(bool wait) | ||
| 396 | { | ||
| 397 | return m_cb->AEStream_Drain(m_kodiBase, m_StreamHandle, wait=true); | ||
| 398 | } | ||
| 399 | //-------------------------------------------------------------------------- | ||
| 400 | |||
| 401 | //========================================================================== | ||
| 402 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 403 | /// @brief Returns true if the is stream draining | ||
| 404 | /// | ||
| 405 | bool IsDraining() | ||
| 406 | { | ||
| 407 | return m_cb->AEStream_IsDraining(m_kodiBase, m_StreamHandle); | ||
| 408 | } | ||
| 409 | //-------------------------------------------------------------------------- | ||
| 410 | |||
| 411 | //========================================================================== | ||
| 412 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 413 | /// @brief Returns true if the is stream has finished draining | ||
| 414 | /// | ||
| 415 | bool IsDrained() | ||
| 416 | { | ||
| 417 | return m_cb->AEStream_IsDrained(m_kodiBase, m_StreamHandle); | ||
| 418 | } | ||
| 419 | //-------------------------------------------------------------------------- | ||
| 420 | |||
| 421 | //========================================================================== | ||
| 422 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 423 | /// @brief Flush all buffers dropping the audio data | ||
| 424 | /// | ||
| 425 | void Flush() | ||
| 426 | { | ||
| 427 | return m_cb->AEStream_Flush(m_kodiBase, m_StreamHandle); | ||
| 428 | } | ||
| 429 | //-------------------------------------------------------------------------- | ||
| 430 | |||
| 431 | //========================================================================== | ||
| 432 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 433 | /// @brief Return the stream's current volume level | ||
| 434 | /// | ||
| 435 | /// @return The volume level between 0.0 and 1.0 | ||
| 436 | /// | ||
| 437 | float GetVolume() | ||
| 438 | { | ||
| 439 | return m_cb->AEStream_GetVolume(m_kodiBase, m_StreamHandle); | ||
| 440 | } | ||
| 441 | //-------------------------------------------------------------------------- | ||
| 442 | |||
| 443 | //========================================================================== | ||
| 444 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 445 | /// @brief Set the stream's volume level | ||
| 446 | /// | ||
| 447 | /// @param[in] volume The new volume level between 0.0 and 1.0 | ||
| 448 | /// | ||
| 449 | void SetVolume(float volume) | ||
| 450 | { | ||
| 451 | return m_cb->AEStream_SetVolume(m_kodiBase, m_StreamHandle, volume); | ||
| 452 | } | ||
| 453 | //-------------------------------------------------------------------------- | ||
| 454 | |||
| 455 | //========================================================================== | ||
| 456 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 457 | /// @brief Gets the stream's volume amplification in linear units. | ||
| 458 | /// | ||
| 459 | /// @return The volume amplification factor between 1.0 and 1000.0 | ||
| 460 | /// | ||
| 461 | float GetAmplification() | ||
| 462 | { | ||
| 463 | return m_cb->AEStream_GetAmplification(m_kodiBase, m_StreamHandle); | ||
| 464 | } | ||
| 465 | //-------------------------------------------------------------------------- | ||
| 466 | |||
| 467 | //========================================================================== | ||
| 468 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 469 | /// @brief Sets the stream's volume amplification in linear units. | ||
| 470 | /// | ||
| 471 | /// @param[in] amplify The volume amplification factor between | ||
| 472 | /// 1.0 and 1000.0 | ||
| 473 | /// | ||
| 474 | void SetAmplification(float amplify) | ||
| 475 | { | ||
| 476 | return m_cb->AEStream_SetAmplification(m_kodiBase, m_StreamHandle, amplify); | ||
| 477 | } | ||
| 478 | //-------------------------------------------------------------------------- | ||
| 479 | |||
| 480 | //========================================================================== | ||
| 481 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 482 | /// @brief Returns the size of one audio frame in bytes (channelCount * resolution) | ||
| 483 | /// | ||
| 484 | /// @return The size in bytes of one frame | ||
| 485 | /// | ||
| 486 | const unsigned int GetFrameSize() const | ||
| 487 | { | ||
| 488 | return m_cb->AEStream_GetFrameSize(m_kodiBase, m_StreamHandle); | ||
| 489 | } | ||
| 490 | //-------------------------------------------------------------------------- | ||
| 491 | |||
| 492 | //========================================================================== | ||
| 493 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 494 | /// @brief Returns the number of channels the stream is configured to accept | ||
| 495 | /// | ||
| 496 | /// @return The channel count | ||
| 497 | /// | ||
| 498 | const unsigned int GetChannelCount() const | ||
| 499 | { | ||
| 500 | return m_cb->AEStream_GetChannelCount(m_kodiBase, m_StreamHandle); | ||
| 501 | } | ||
| 502 | //-------------------------------------------------------------------------- | ||
| 503 | |||
| 504 | //========================================================================== | ||
| 505 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 506 | /// @brief Returns the stream's sample rate, if the stream is using a dynamic | ||
| 507 | /// sample rate, this value will NOT reflect any changes made by calls to | ||
| 508 | /// SetResampleRatio() | ||
| 509 | /// | ||
| 510 | /// @return The stream's sample rate (eg, 48000) | ||
| 511 | /// | ||
| 512 | const unsigned int GetSampleRate() const | ||
| 513 | { | ||
| 514 | return m_cb->AEStream_GetSampleRate(m_kodiBase, m_StreamHandle); | ||
| 515 | } | ||
| 516 | //-------------------------------------------------------------------------- | ||
| 517 | |||
| 518 | //========================================================================== | ||
| 519 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 520 | /// @brief Return the data format the stream has been configured with | ||
| 521 | /// | ||
| 522 | /// @return The stream's data format (eg, AUDIOENGINE_FMT_S16LE) | ||
| 523 | /// | ||
| 524 | const AEDataFormat GetDataFormat() const | ||
| 525 | { | ||
| 526 | return m_cb->AEStream_GetDataFormat(m_kodiBase, m_StreamHandle); | ||
| 527 | } | ||
| 528 | //-------------------------------------------------------------------------- | ||
| 529 | |||
| 530 | //========================================================================== | ||
| 531 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 532 | /// @brief Return the resample ratio | ||
| 533 | /// | ||
| 534 | /// @note This will return an undefined value if the stream is not resampling | ||
| 535 | /// | ||
| 536 | /// @return the current resample ratio or undefined if the stream is not resampling | ||
| 537 | /// | ||
| 538 | double GetResampleRatio() | ||
| 539 | { | ||
| 540 | return m_cb->AEStream_GetResampleRatio(m_kodiBase, m_StreamHandle); | ||
| 541 | } | ||
| 542 | //-------------------------------------------------------------------------- | ||
| 543 | |||
| 544 | //========================================================================== | ||
| 545 | /// @ingroup cpp_kodi_audioengine_CAddonAEStream | ||
| 546 | /// @brief Sets the resample ratio | ||
| 547 | /// | ||
| 548 | /// @note This function may return false if the stream is not resampling, if | ||
| 549 | /// you wish to use this be sure to set the AESTREAM_FORCE_RESAMPLE option | ||
| 550 | /// | ||
| 551 | /// @param[in] ratio the new sample rate ratio, calculated by | ||
| 552 | /// ((double)desiredRate / (double)GetSampleRate()) | ||
| 553 | /// | ||
| 554 | void SetResampleRatio(double ratio) | ||
| 555 | { | ||
| 556 | m_cb->AEStream_SetResampleRatio(m_kodiBase, m_StreamHandle, ratio); | ||
| 557 | } | ||
| 558 | //-------------------------------------------------------------------------- | ||
| 559 | |||
| 560 | private: | ||
| 561 | void* m_kodiBase; | ||
| 562 | AddonToKodiFuncTable_kodi_audioengine* m_cb; | ||
| 563 | AEStreamHandle *m_StreamHandle; | ||
| 564 | }; | ||
| 565 | |||
| 566 | //============================================================================ | ||
| 567 | /// @ingroup cpp_kodi_audioengine | ||
| 568 | /// @brief Get the current sink data format | ||
| 569 | /// | ||
| 570 | /// @param[in] format Current sink data format. For more details see AudioEngineFormat. | ||
| 571 | /// @return Returns true on success, else false. | ||
| 572 | /// | ||
| 573 | inline bool GetCurrentSinkFormat(AudioEngineFormat &format) | ||
| 574 | { | ||
| 575 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_audioengine->GetCurrentSinkFormat(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, &format); | ||
| 576 | } | ||
| 577 | //---------------------------------------------------------------------------- | ||
| 578 | |||
| 579 | } /* audioengine */ | ||
| 580 | } /* kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h new file mode 100644 index 0000000..3222e8b --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h | |||
| @@ -0,0 +1,1490 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team Kodi | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with Kodi; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "AddonBase.h" | ||
| 23 | |||
| 24 | #include <map> | ||
| 25 | |||
| 26 | #if !defined(_WIN32) | ||
| 27 | #include <sys/stat.h> | ||
| 28 | #if !defined(__stat64) | ||
| 29 | #define __stat64 stat64 | ||
| 30 | #endif | ||
| 31 | #endif | ||
| 32 | #ifdef _WIN32 // windows | ||
| 33 | #ifndef _SSIZE_T_DEFINED | ||
| 34 | typedef intptr_t ssize_t; | ||
| 35 | #define _SSIZE_T_DEFINED | ||
| 36 | #endif // !_SSIZE_T_DEFINED | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #ifndef S_ISDIR | ||
| 40 | #define S_ISDIR(mode) ((((mode)) & 0170000) == (0040000)) | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #ifndef S_ISLNK | ||
| 44 | #define S_ISLNK(mode) ((((mode)) & 0170000) == (0120000)) | ||
| 45 | #endif | ||
| 46 | |||
| 47 | /* | ||
| 48 | * For interface between add-on and kodi. | ||
| 49 | * | ||
| 50 | * This structure defines the addresses of functions stored inside Kodi which | ||
| 51 | * are then available for the add-on to call | ||
| 52 | * | ||
| 53 | * All function pointers there are used by the C++ interface functions below. | ||
| 54 | * You find the set of them on xbmc/addons/interfaces/General.cpp | ||
| 55 | * | ||
| 56 | * Note: For add-on development itself this is not needed | ||
| 57 | */ | ||
| 58 | extern "C" | ||
| 59 | { | ||
| 60 | |||
| 61 | struct VFSProperty | ||
| 62 | { | ||
| 63 | char* name; | ||
| 64 | char* val; | ||
| 65 | }; | ||
| 66 | |||
| 67 | struct VFSDirEntry | ||
| 68 | { | ||
| 69 | char* label; //!< item label | ||
| 70 | char* title; //!< item title | ||
| 71 | char* path; //!< item path | ||
| 72 | unsigned int num_props; //!< Number of properties attached to item | ||
| 73 | VFSProperty* properties; //!< Properties | ||
| 74 | time_t date_time; //!< file creation date & time | ||
| 75 | bool folder; //!< Item is a folder | ||
| 76 | uint64_t size; //!< Size of file represented by item | ||
| 77 | }; | ||
| 78 | |||
| 79 | typedef struct AddonToKodiFuncTable_kodi_filesystem | ||
| 80 | { | ||
| 81 | bool (*can_open_directory)(void* kodiBase, const char* url); | ||
| 82 | bool (*create_directory)(void* kodiBase, const char* path); | ||
| 83 | bool (*remove_directory)(void* kodiBase, const char* path); | ||
| 84 | bool (*directory_exists)(void* kodiBase, const char* path); | ||
| 85 | bool (*get_directory)(void* kodiBase, const char* path, const char* mask, VFSDirEntry** items, unsigned int* num_items); | ||
| 86 | void (*free_directory)(void* kodiBase, VFSDirEntry* items, unsigned int num_items); | ||
| 87 | |||
| 88 | bool (*file_exists)(void* kodiBase, const char *filename, bool useCache); | ||
| 89 | int (*stat_file)(void* kodiBase, const char *filename, struct __stat64* buffer); | ||
| 90 | bool (*delete_file)(void* kodiBase, const char *filename); | ||
| 91 | bool (*rename_file)(void* kodiBase, const char *filename, const char *newFileName); | ||
| 92 | bool (*copy_file)(void* kodiBase, const char *filename, const char *dest); | ||
| 93 | |||
| 94 | char* (*get_file_md5)(void* kodiBase, const char* filename); | ||
| 95 | char* (*get_cache_thumb_name)(void* kodiBase, const char* filename); | ||
| 96 | char* (*make_legal_filename)(void* kodiBase, const char* filename); | ||
| 97 | char* (*make_legal_path)(void* kodiBase, const char* path); | ||
| 98 | char* (*translate_special_protocol)(void* kodiBase, const char *strSource); | ||
| 99 | |||
| 100 | void* (*open_file)(void* kodiBase, const char* filename, unsigned int flags); | ||
| 101 | void* (*open_file_for_write)(void* kodiBase, const char* filename, bool overwrite); | ||
| 102 | ssize_t (*read_file)(void* kodiBase, void* file, void* ptr, size_t size); | ||
| 103 | bool (*read_file_string)(void* kodiBase, void* file, char *szLine, int iLineLength); | ||
| 104 | ssize_t (*write_file)(void* kodiBase, void* file, const void* ptr, size_t size); | ||
| 105 | void (*flush_file)(void* kodiBase, void* file); | ||
| 106 | int64_t (*seek_file)(void* kodiBase, void* file, int64_t position, int whence); | ||
| 107 | int (*truncate_file)(void* kodiBase, void* file, int64_t size); | ||
| 108 | int64_t (*get_file_position)(void* kodiBase, void* file); | ||
| 109 | int64_t (*get_file_length)(void* kodiBase, void* file); | ||
| 110 | double (*get_file_download_speed)(void* kodiBase, void* file); | ||
| 111 | void (*close_file)(void* kodiBase, void* file); | ||
| 112 | int (*get_file_chunk_size)(void* kodiBase, void* file); | ||
| 113 | |||
| 114 | void* (*curl_create)(void* kodiBase, const char* url); | ||
| 115 | bool (*curl_add_option)(void* kodiBase, void* file, int type, const char* name, const char* value); | ||
| 116 | bool (*curl_open)(void* kodiBase, void* file, unsigned int flags); | ||
| 117 | } AddonToKodiFuncTable_kodi_filesystem; | ||
| 118 | |||
| 119 | } /* extern "C" */ | ||
| 120 | |||
| 121 | //============================================================================== | ||
| 122 | /// \defgroup cpp_kodi_vfs_CFile_Defs Definitions, structures and enumerators | ||
| 123 | /// \ingroup cpp_kodi_vfs_CFile | ||
| 124 | /// @brief **Virtual file Server definition values** | ||
| 125 | //------------------------------------------------------------------------------ | ||
| 126 | |||
| 127 | //============================================================================== | ||
| 128 | /// | ||
| 129 | /// @ingroup cpp_kodi_vfs_CFile_Defs | ||
| 130 | /// Flags to define way how file becomes opened with kodi::vfs::CFile::OpenFile() | ||
| 131 | /// | ||
| 132 | /// The values can be used together, e.g. <b>`file.Open("myfile", READ_TRUNCATED | READ_CHUNKED);`</b> | ||
| 133 | /// | ||
| 134 | typedef enum OpenFileFlags | ||
| 135 | { | ||
| 136 | /// indicate that caller can handle truncated reads, where function returns | ||
| 137 | /// before entire buffer has been filled | ||
| 138 | READ_TRUNCATED = 0x01, | ||
| 139 | |||
| 140 | /// indicate that that caller support read in the minimum defined chunk size, | ||
| 141 | /// this disables internal cache then | ||
| 142 | READ_CHUNKED = 0x02, | ||
| 143 | |||
| 144 | /// use cache to access this file | ||
| 145 | READ_CACHED = 0x04, | ||
| 146 | |||
| 147 | /// open without caching. regardless to file type | ||
| 148 | READ_NO_CACHE = 0x08, | ||
| 149 | |||
| 150 | /// calcuate bitrate for file while reading | ||
| 151 | READ_BITRATE = 0x10, | ||
| 152 | |||
| 153 | /// indicate to the caller we will seek between multiple streams in the file | ||
| 154 | /// frequently | ||
| 155 | READ_MULTI_STREAM = 0x20, | ||
| 156 | |||
| 157 | /// indicate to the caller file is audio and/or video (and e.g. may grow) | ||
| 158 | READ_AUDIO_VIDEO = 0x40, | ||
| 159 | |||
| 160 | /// indicate that caller will do write operations before reading | ||
| 161 | READ_AFTER_WRITE = 0x80, | ||
| 162 | |||
| 163 | /// indicate that caller want to reopen a file if its already open | ||
| 164 | READ_REOPEN = 0x100 | ||
| 165 | } OpenFileFlags; | ||
| 166 | //------------------------------------------------------------------------------ | ||
| 167 | |||
| 168 | //============================================================================== | ||
| 169 | /// \ingroup cpp_kodi_vfs_CFile_Defs | ||
| 170 | /// @brief Used CURL message types | ||
| 171 | /// | ||
| 172 | typedef enum CURLOptiontype | ||
| 173 | { | ||
| 174 | /// Set a general option | ||
| 175 | ADDON_CURL_OPTION_OPTION, | ||
| 176 | /// Set a protocol option | ||
| 177 | ADDON_CURL_OPTION_PROTOCOL, | ||
| 178 | /// Set User and password | ||
| 179 | ADDON_CURL_OPTION_CREDENTIALS, | ||
| 180 | /// Add a Header | ||
| 181 | ADDON_CURL_OPTION_HEADER | ||
| 182 | } CURLOptiontype; | ||
| 183 | //------------------------------------------------------------------------------ | ||
| 184 | |||
| 185 | //============================================================================ | ||
| 186 | /// | ||
| 187 | /// \ingroup cpp_kodi_vfs_CFile_Defs | ||
| 188 | /// @brief Information about a file | ||
| 189 | /// | ||
| 190 | struct STAT_STRUCTURE | ||
| 191 | { | ||
| 192 | /// ID of device containing file | ||
| 193 | uint32_t deviceId; | ||
| 194 | /// Total size, in bytes | ||
| 195 | uint64_t size; | ||
| 196 | #ifdef TARGET_WINDOWS | ||
| 197 | /// Time of last access | ||
| 198 | __time64_t accessTime; | ||
| 199 | /// Time of last modification | ||
| 200 | __time64_t modificationTime; | ||
| 201 | /// Time of last status change | ||
| 202 | __time64_t statusTime; | ||
| 203 | #else | ||
| 204 | /// Time of last access | ||
| 205 | timespec accessTime; | ||
| 206 | /// Time of last modification | ||
| 207 | timespec modificationTime; | ||
| 208 | /// Time of last status change | ||
| 209 | timespec statusTime; | ||
| 210 | #endif | ||
| 211 | /// The stat url is a directory | ||
| 212 | bool isDirectory; | ||
| 213 | /// The stat url is a symbolic link | ||
| 214 | bool isSymLink; | ||
| 215 | }; | ||
| 216 | //------------------------------------------------------------------------------ | ||
| 217 | |||
| 218 | namespace kodi | ||
| 219 | { | ||
| 220 | namespace vfs | ||
| 221 | { | ||
| 222 | |||
| 223 | //============================================================================ | ||
| 224 | /// | ||
| 225 | /// \defgroup cpp_kodi_vfs_CDirEntry class CDirEntry | ||
| 226 | /// \ingroup cpp_kodi_vfs | ||
| 227 | /// | ||
| 228 | /// @brief **Virtual file server directory entry** | ||
| 229 | /// | ||
| 230 | /// This class is used as an entry for files and folders in | ||
| 231 | /// kodi::vfs::GetDirectory(). | ||
| 232 | /// | ||
| 233 | /// | ||
| 234 | /// ------------------------------------------------------------------------ | ||
| 235 | /// | ||
| 236 | /// **Example:** | ||
| 237 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 238 | /// #include <kodi/Filesystem.h> | ||
| 239 | /// | ||
| 240 | /// ... | ||
| 241 | /// | ||
| 242 | /// std::vector<kodi::vfs::CDirEntry> items; | ||
| 243 | /// kodi::vfs::GetDirectory("special://temp", "", items); | ||
| 244 | /// | ||
| 245 | /// fprintf(stderr, "Directory have %lu entries\n", items.size()); | ||
| 246 | /// for (unsigned long i = 0; i < items.size(); i++) | ||
| 247 | /// { | ||
| 248 | /// char buff[20]; | ||
| 249 | /// time_t now = items[i].DateTime(); | ||
| 250 | /// strftime(buff, 20, "%Y-%m-%d %H:%M:%S", gmtime(&now)); | ||
| 251 | /// fprintf(stderr, " - %04lu -- Folder: %s -- Name: %s -- Path: %s -- Time: %s\n", | ||
| 252 | /// i+1, | ||
| 253 | /// items[i].IsFolder() ? "yes" : "no ", | ||
| 254 | /// items[i].Label().c_str(), | ||
| 255 | /// items[i].Path().c_str(), | ||
| 256 | /// buff); | ||
| 257 | /// } | ||
| 258 | /// ~~~~~~~~~~~~~ | ||
| 259 | /// | ||
| 260 | /// It has the header \ref Filesystem.h "#include <kodi/Filesystem.h>" be included | ||
| 261 | /// to enjoy it. | ||
| 262 | /// | ||
| 263 | //@{ | ||
| 264 | class CDirEntry | ||
| 265 | { | ||
| 266 | public: | ||
| 267 | //============================================================================ | ||
| 268 | /// | ||
| 269 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 270 | /// @brief Constructor for VFS directory entry | ||
| 271 | /// | ||
| 272 | /// @param[in] label [opt] Name to use for entry | ||
| 273 | /// @param[in] path [opt] Used path of the entry | ||
| 274 | /// @param[in] folder [opt] If set entry used as folder | ||
| 275 | /// @param[in] size [opt] If used as file, his size defined there | ||
| 276 | /// | ||
| 277 | CDirEntry(const std::string& label = "", | ||
| 278 | const std::string& path = "", | ||
| 279 | bool folder = false, | ||
| 280 | int64_t size = -1) : | ||
| 281 | m_label(label), | ||
| 282 | m_path(path), | ||
| 283 | m_folder(folder), | ||
| 284 | m_size(size) | ||
| 285 | { | ||
| 286 | } | ||
| 287 | //---------------------------------------------------------------------------- | ||
| 288 | |||
| 289 | //============================================================================ | ||
| 290 | // @note Not for addon development itself needed, thats why below is | ||
| 291 | // disabled for doxygen! | ||
| 292 | // | ||
| 293 | // @ingroup cpp_kodi_vfs_CDirEntry | ||
| 294 | // @brief Constructor to create own copy | ||
| 295 | // | ||
| 296 | // @param[in] dirEntry pointer to own class type | ||
| 297 | // | ||
| 298 | CDirEntry(const VFSDirEntry& dirEntry) : | ||
| 299 | m_label(dirEntry.label ? dirEntry.label : ""), | ||
| 300 | m_path(dirEntry.path ? dirEntry.path : ""), | ||
| 301 | m_folder(dirEntry.folder), | ||
| 302 | m_size(dirEntry.size), | ||
| 303 | m_dateTime(dirEntry.date_time) | ||
| 304 | { | ||
| 305 | } | ||
| 306 | //---------------------------------------------------------------------------- | ||
| 307 | |||
| 308 | //============================================================================ | ||
| 309 | /// | ||
| 310 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 311 | /// @brief Get the directory entry name | ||
| 312 | /// | ||
| 313 | /// @return Name of the entry | ||
| 314 | /// | ||
| 315 | const std::string& Label(void) const { return m_label; } | ||
| 316 | //---------------------------------------------------------------------------- | ||
| 317 | |||
| 318 | //============================================================================ | ||
| 319 | /// | ||
| 320 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 321 | /// @brief Get the optional title of entry | ||
| 322 | /// | ||
| 323 | /// @return Title of the entry, if exists | ||
| 324 | /// | ||
| 325 | const std::string& Title(void) const { return m_title; } | ||
| 326 | //---------------------------------------------------------------------------- | ||
| 327 | |||
| 328 | //============================================================================ | ||
| 329 | /// | ||
| 330 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 331 | /// @brief Get the path of the entry | ||
| 332 | /// | ||
| 333 | /// @return File system path of the entry | ||
| 334 | /// | ||
| 335 | const std::string& Path(void) const { return m_path; } | ||
| 336 | //---------------------------------------------------------------------------- | ||
| 337 | |||
| 338 | //============================================================================ | ||
| 339 | /// | ||
| 340 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 341 | /// @brief Used to check entry is folder | ||
| 342 | /// | ||
| 343 | /// @return true if entry is a folder | ||
| 344 | /// | ||
| 345 | bool IsFolder(void) const { return m_folder; } | ||
| 346 | //---------------------------------------------------------------------------- | ||
| 347 | |||
| 348 | //============================================================================ | ||
| 349 | /// | ||
| 350 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 351 | /// @brief If file, the size of the file | ||
| 352 | /// | ||
| 353 | /// @return Defined file size | ||
| 354 | /// | ||
| 355 | int64_t Size(void) const { return m_size; } | ||
| 356 | //---------------------------------------------------------------------------- | ||
| 357 | |||
| 358 | //============================================================================ | ||
| 359 | /// | ||
| 360 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 361 | /// @brief Get file time and date for a new entry | ||
| 362 | /// | ||
| 363 | /// @return The with time_t defined date and time of file | ||
| 364 | /// | ||
| 365 | time_t DateTime() { return m_dateTime; } | ||
| 366 | //---------------------------------------------------------------------------- | ||
| 367 | |||
| 368 | //============================================================================ | ||
| 369 | /// | ||
| 370 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 371 | /// @brief Set the label name | ||
| 372 | /// | ||
| 373 | /// @param[in] label name of entry | ||
| 374 | /// | ||
| 375 | void SetLabel(const std::string& label) { m_label = label; } | ||
| 376 | //---------------------------------------------------------------------------- | ||
| 377 | |||
| 378 | //============================================================================ | ||
| 379 | /// | ||
| 380 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 381 | /// @brief Set the title name | ||
| 382 | /// | ||
| 383 | /// @param[in] title title name of entry | ||
| 384 | /// | ||
| 385 | void SetTitle(const std::string& title) { m_title = title; } | ||
| 386 | //---------------------------------------------------------------------------- | ||
| 387 | |||
| 388 | //============================================================================ | ||
| 389 | /// | ||
| 390 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 391 | /// @brief Set the path of the entry | ||
| 392 | /// | ||
| 393 | /// @param[in] path path of entry | ||
| 394 | /// | ||
| 395 | void SetPath(const std::string& path) { m_path = path; } | ||
| 396 | //---------------------------------------------------------------------------- | ||
| 397 | |||
| 398 | //============================================================================ | ||
| 399 | /// | ||
| 400 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 401 | /// @brief Set the entry defined as folder | ||
| 402 | /// | ||
| 403 | /// @param[in] folder If true becomes entry defined as folder | ||
| 404 | /// | ||
| 405 | void SetFolder(bool folder) { m_folder = folder; } | ||
| 406 | //---------------------------------------------------------------------------- | ||
| 407 | |||
| 408 | //============================================================================ | ||
| 409 | /// | ||
| 410 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 411 | /// @brief Set a file size for a new entry | ||
| 412 | /// | ||
| 413 | /// @param[in] size Size to set for dir entry | ||
| 414 | /// | ||
| 415 | void SetSize(int64_t size) { m_size = size; } | ||
| 416 | //---------------------------------------------------------------------------- | ||
| 417 | |||
| 418 | //============================================================================ | ||
| 419 | /// | ||
| 420 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 421 | /// @brief Set file time and date for a new entry | ||
| 422 | /// | ||
| 423 | /// @param[in] dateTime The with time_t defined date and time of file | ||
| 424 | /// | ||
| 425 | void SetDateTime(time_t dateTime) { m_dateTime = dateTime; } | ||
| 426 | //---------------------------------------------------------------------------- | ||
| 427 | |||
| 428 | //============================================================================ | ||
| 429 | /// | ||
| 430 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 431 | /// @brief Add a by string defined property entry to directory entry | ||
| 432 | /// | ||
| 433 | /// @note A property can be used to add some special information about a file | ||
| 434 | /// or directory entry, this can be used on other places to do the right work | ||
| 435 | /// of them. | ||
| 436 | /// | ||
| 437 | /// @param[in] id Identification name of property | ||
| 438 | /// @param[in] value The property value to add by given id | ||
| 439 | /// | ||
| 440 | void AddProperty(const std::string& id, const std::string& value) { m_properties[id] = value; } | ||
| 441 | //---------------------------------------------------------------------------- | ||
| 442 | |||
| 443 | //============================================================================ | ||
| 444 | /// | ||
| 445 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 446 | /// @brief Clear all present properties | ||
| 447 | /// | ||
| 448 | void ClearProperties() { m_properties.clear(); } | ||
| 449 | //---------------------------------------------------------------------------- | ||
| 450 | |||
| 451 | //============================================================================ | ||
| 452 | /// | ||
| 453 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 454 | /// @brief Get the present properties list on directory entry | ||
| 455 | /// | ||
| 456 | /// @return map with all present properties | ||
| 457 | /// | ||
| 458 | const std::map<std::string, std::string>& GetProperties() const { return m_properties; } | ||
| 459 | //---------------------------------------------------------------------------- | ||
| 460 | |||
| 461 | private: | ||
| 462 | std::string m_label; | ||
| 463 | std::string m_title; | ||
| 464 | std::string m_path; | ||
| 465 | std::map<std::string, std::string> m_properties; | ||
| 466 | bool m_folder; | ||
| 467 | int64_t m_size; | ||
| 468 | time_t m_dateTime; | ||
| 469 | }; | ||
| 470 | //@} | ||
| 471 | //---------------------------------------------------------------------------- | ||
| 472 | |||
| 473 | //============================================================================ | ||
| 474 | /// | ||
| 475 | /// @ingroup cpp_kodi_vfs | ||
| 476 | /// @brief Make a directory | ||
| 477 | /// | ||
| 478 | /// The kodi::vfs::CreateDirectory() function shall create a | ||
| 479 | /// new directory with name path. | ||
| 480 | /// | ||
| 481 | /// The newly created directory shall be an empty directory. | ||
| 482 | /// | ||
| 483 | /// @param[in] path Path to the directory. | ||
| 484 | /// @return Upon successful completion, CreateDirectory() shall return true. | ||
| 485 | /// Otherwise false shall be returned, no directory shall be created. | ||
| 486 | /// | ||
| 487 | /// | ||
| 488 | /// ------------------------------------------------------------------------- | ||
| 489 | /// | ||
| 490 | /// **Example:** | ||
| 491 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 492 | /// #include <kodi/Filesystem.h> | ||
| 493 | /// ... | ||
| 494 | /// std::string directory = "C:\\my_dir"; | ||
| 495 | /// bool ret = kodi::vfs::CreateDirectory(directory); | ||
| 496 | /// fprintf(stderr, "Directory '%s' successfull created: %s\n", directory.c_str(), ret ? "yes" : "no"); | ||
| 497 | /// ... | ||
| 498 | /// ~~~~~~~~~~~~~ | ||
| 499 | /// | ||
| 500 | inline bool CreateDirectory(const std::string& path) | ||
| 501 | { | ||
| 502 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->create_directory(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 503 | } | ||
| 504 | //---------------------------------------------------------------------------- | ||
| 505 | |||
| 506 | //============================================================================ | ||
| 507 | /// | ||
| 508 | /// @ingroup cpp_kodi_vfs | ||
| 509 | /// @brief Verifying the Existence of a Directory | ||
| 510 | /// | ||
| 511 | /// The kodi::vfs::DirectoryExists() method determines whether | ||
| 512 | /// a specified folder exists. | ||
| 513 | /// | ||
| 514 | /// @param[in] path Path to the directory. | ||
| 515 | /// @return True when it exists, false otherwise. | ||
| 516 | /// | ||
| 517 | /// | ||
| 518 | /// ------------------------------------------------------------------------- | ||
| 519 | /// | ||
| 520 | /// **Example:** | ||
| 521 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 522 | /// #include <kodi/Filesystem.h> | ||
| 523 | /// ... | ||
| 524 | /// std::string directory = "C:\\my_dir"; | ||
| 525 | /// bool ret = kodi::vfs::DirectoryExists(directory); | ||
| 526 | /// fprintf(stderr, "Directory '%s' present: %s\n", directory.c_str(), ret ? "yes" : "no"); | ||
| 527 | /// ... | ||
| 528 | /// ~~~~~~~~~~~~~ | ||
| 529 | /// | ||
| 530 | inline bool DirectoryExists(const std::string& path) | ||
| 531 | { | ||
| 532 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->directory_exists(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 533 | } | ||
| 534 | //---------------------------------------------------------------------------- | ||
| 535 | |||
| 536 | //============================================================================ | ||
| 537 | /// | ||
| 538 | /// @ingroup cpp_kodi_vfs | ||
| 539 | /// @brief Removes a directory. | ||
| 540 | /// | ||
| 541 | /// The kodi::vfs::RemoveDirectory() function shall remove a | ||
| 542 | /// directory whose name is given by path. | ||
| 543 | /// | ||
| 544 | /// @param[in] path Path to the directory. | ||
| 545 | /// @return Upon successful completion, the function RemoveDirectory() shall | ||
| 546 | /// return true. Otherwise, false shall be returned, and errno set | ||
| 547 | /// to indicate the error. If false is returned, the named directory | ||
| 548 | /// shall not be changed. | ||
| 549 | /// | ||
| 550 | /// | ||
| 551 | /// ------------------------------------------------------------------------- | ||
| 552 | /// | ||
| 553 | /// **Example:** | ||
| 554 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 555 | /// #include <kodi/Filesystem.h> | ||
| 556 | /// ... | ||
| 557 | /// bool ret = kodi::vfs::RemoveDirectory("C:\\my_dir"); | ||
| 558 | /// ... | ||
| 559 | /// ~~~~~~~~~~~~~ | ||
| 560 | /// | ||
| 561 | inline bool RemoveDirectory(const std::string& path) | ||
| 562 | { | ||
| 563 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->remove_directory(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 564 | } | ||
| 565 | //---------------------------------------------------------------------------- | ||
| 566 | |||
| 567 | //============================================================================ | ||
| 568 | /// | ||
| 569 | /// @ingroup cpp_kodi_vfs | ||
| 570 | /// @brief Lists a directory. | ||
| 571 | /// | ||
| 572 | /// Return the list of files and directories which have been found in the | ||
| 573 | /// specified directory and which respect the given constraint. | ||
| 574 | /// | ||
| 575 | /// It can handle the normal OS dependent paths and also the special virtual | ||
| 576 | /// filesystem from Kodi what starts with \b special://. | ||
| 577 | /// | ||
| 578 | /// @param[in] path The path in which the files and directories are located. | ||
| 579 | /// @param[in] mask Mask to filter out requested files, e.g. "*.avi|*.mpg" to | ||
| 580 | /// files with this ending. | ||
| 581 | /// @param[out] items The returned list directory entries. | ||
| 582 | /// @return True if listing was successful, false otherwise. | ||
| 583 | /// | ||
| 584 | /// | ||
| 585 | /// ------------------------------------------------------------------------- | ||
| 586 | /// | ||
| 587 | /// **Example:** | ||
| 588 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 589 | /// #include <kodi/Filesystem.h> | ||
| 590 | /// | ||
| 591 | /// std::vector<kodi::vfs::CDirEntry> items; | ||
| 592 | /// kodi::vfs::GetDirectory("special://temp", "", items); | ||
| 593 | /// | ||
| 594 | /// fprintf(stderr, "Directory have %lu entries\n", items.size()); | ||
| 595 | /// for (unsigned long i = 0; i < items.size(); i++) | ||
| 596 | /// { | ||
| 597 | /// fprintf(stderr, " - %04lu -- Folder: %s -- Name: %s -- Path: %s\n", | ||
| 598 | /// i+1, | ||
| 599 | /// items[i].IsFolder() ? "yes" : "no ", | ||
| 600 | /// items[i].Label().c_str(), | ||
| 601 | /// items[i].Path().c_str()); | ||
| 602 | /// } | ||
| 603 | /// ~~~~~~~~~~~~~ | ||
| 604 | inline bool GetDirectory(const std::string& path, const std::string& mask, std::vector<CDirEntry>& items) | ||
| 605 | { | ||
| 606 | VFSDirEntry* dir_list = nullptr; | ||
| 607 | unsigned int num_items = 0; | ||
| 608 | if (::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_directory(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), mask.c_str(), &dir_list, &num_items)) | ||
| 609 | { | ||
| 610 | if (dir_list) | ||
| 611 | { | ||
| 612 | for (unsigned int i = 0; i < num_items; ++i) | ||
| 613 | items.push_back(CDirEntry(dir_list[i])); | ||
| 614 | |||
| 615 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->free_directory(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, dir_list, num_items); | ||
| 616 | } | ||
| 617 | |||
| 618 | return true; | ||
| 619 | } | ||
| 620 | return false; | ||
| 621 | } | ||
| 622 | //---------------------------------------------------------------------------- | ||
| 623 | |||
| 624 | //============================================================================ | ||
| 625 | /// | ||
| 626 | /// @ingroup cpp_kodi_vfs | ||
| 627 | /// @brief Retrieve MD5sum of a file | ||
| 628 | /// | ||
| 629 | /// @param[in] path path to the file to MD5sum | ||
| 630 | /// @return md5 sum of the file | ||
| 631 | /// | ||
| 632 | /// | ||
| 633 | /// ------------------------------------------------------------------------- | ||
| 634 | /// | ||
| 635 | /// **Example:** | ||
| 636 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 637 | /// #include <kodi/Filesystem.h> | ||
| 638 | /// #include <kodi/gui/DialogFileBrowser.h> | ||
| 639 | /// ... | ||
| 640 | /// std::string md5; | ||
| 641 | /// std::string filename; | ||
| 642 | /// if (kodi::gui::DialogFileBrowser::ShowAndGetFile("local", "*.avi|*.mpg|*.mp4", | ||
| 643 | /// "Test File selection to get MD5", | ||
| 644 | /// filename)) | ||
| 645 | /// { | ||
| 646 | /// md5 = kodi::vfs::GetFileMD5(filename); | ||
| 647 | /// fprintf(stderr, "MD5 of file '%s' is %s\n", md5.c_str(), filename.c_str()); | ||
| 648 | /// } | ||
| 649 | /// ~~~~~~~~~~~~~ | ||
| 650 | /// | ||
| 651 | inline std::string GetFileMD5(const std::string& path) | ||
| 652 | { | ||
| 653 | std::string strReturn; | ||
| 654 | char* strMd5 = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_md5(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 655 | if (strMd5 != nullptr) | ||
| 656 | { | ||
| 657 | if (std::strlen(strMd5)) | ||
| 658 | strReturn = strMd5; | ||
| 659 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, strMd5); | ||
| 660 | } | ||
| 661 | return strReturn; | ||
| 662 | } | ||
| 663 | //---------------------------------------------------------------------------- | ||
| 664 | |||
| 665 | //============================================================================ | ||
| 666 | /// | ||
| 667 | /// @ingroup cpp_kodi_vfs | ||
| 668 | /// @brief Returns a thumb cache filename | ||
| 669 | /// | ||
| 670 | /// @param[in] filename path to file | ||
| 671 | /// @return cache filename | ||
| 672 | /// | ||
| 673 | /// | ||
| 674 | /// ------------------------------------------------------------------------ | ||
| 675 | /// | ||
| 676 | /// **Example:** | ||
| 677 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 678 | /// #include <kodi/Filesystem.h> | ||
| 679 | /// #include <kodi/gui/DialogFileBrowser.h> | ||
| 680 | /// ... | ||
| 681 | /// std::string thumb; | ||
| 682 | /// std::string filename; | ||
| 683 | /// if (kodi::gui::DialogFileBrowser::ShowAndGetFile("local", "*.avi|*.mpg|*.mp4", | ||
| 684 | /// "Test File selection to get Thumnail", | ||
| 685 | /// filename)) | ||
| 686 | /// { | ||
| 687 | /// thumb = kodi::vfs::GetCacheThumbName(filename); | ||
| 688 | /// fprintf(stderr, "Thumb name of file '%s' is %s\n", thumb.c_str(), filename.c_str()); | ||
| 689 | /// } | ||
| 690 | /// ~~~~~~~~~~~~~ | ||
| 691 | /// | ||
| 692 | inline std::string GetCacheThumbName(const std::string& filename) | ||
| 693 | { | ||
| 694 | std::string strReturn; | ||
| 695 | char* strThumbName = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_cache_thumb_name(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str()); | ||
| 696 | if (strThumbName != nullptr) | ||
| 697 | { | ||
| 698 | if (std::strlen(strThumbName)) | ||
| 699 | strReturn = strThumbName; | ||
| 700 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, strThumbName); | ||
| 701 | } | ||
| 702 | return strReturn; | ||
| 703 | } | ||
| 704 | //---------------------------------------------------------------------------- | ||
| 705 | |||
| 706 | //============================================================================ | ||
| 707 | /// | ||
| 708 | /// @ingroup cpp_kodi_vfs | ||
| 709 | /// @brief Make filename valid | ||
| 710 | /// | ||
| 711 | /// Function to replace not valid characters with '_'. It can be also | ||
| 712 | /// compared with original before in a own loop until it is equal | ||
| 713 | /// (no invalid characters). | ||
| 714 | /// | ||
| 715 | /// @param[in] filename Filename to check and fix | ||
| 716 | /// @return The legal filename | ||
| 717 | /// | ||
| 718 | /// | ||
| 719 | /// ------------------------------------------------------------------------ | ||
| 720 | /// | ||
| 721 | /// **Example:** | ||
| 722 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 723 | /// #include <kodi/Filesystem.h> | ||
| 724 | /// ... | ||
| 725 | /// std::string fileName = "///\\jk???lj????.mpg"; | ||
| 726 | /// std::string legalName = kodi::vfs::MakeLegalFileName(fileName); | ||
| 727 | /// fprintf(stderr, "Legal name of '%s' is '%s'\n", fileName.c_str(), legalName.c_str()); | ||
| 728 | /// | ||
| 729 | /// /* Returns as legal: 'jk___lj____.mpg' */ | ||
| 730 | /// ~~~~~~~~~~~~~ | ||
| 731 | /// | ||
| 732 | inline std::string MakeLegalFileName(const std::string& filename) | ||
| 733 | { | ||
| 734 | std::string strReturn; | ||
| 735 | char* strLegalFileName = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->make_legal_filename(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str()); | ||
| 736 | if (strLegalFileName != nullptr) | ||
| 737 | { | ||
| 738 | if (std::strlen(strLegalFileName)) | ||
| 739 | strReturn = strLegalFileName; | ||
| 740 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, strLegalFileName); | ||
| 741 | } | ||
| 742 | return strReturn; | ||
| 743 | } | ||
| 744 | //---------------------------------------------------------------------------- | ||
| 745 | |||
| 746 | //============================================================================ | ||
| 747 | /// | ||
| 748 | /// @ingroup cpp_kodi_vfs | ||
| 749 | /// @brief Make directory name valid | ||
| 750 | /// | ||
| 751 | /// Function to replace not valid characters with '_'. It can be also | ||
| 752 | /// compared with original before in a own loop until it is equal | ||
| 753 | /// (no invalid characters). | ||
| 754 | /// | ||
| 755 | /// @param[in] path Directory name to check and fix | ||
| 756 | /// @return The legal directory name | ||
| 757 | /// | ||
| 758 | /// | ||
| 759 | /// ------------------------------------------------------------------------ | ||
| 760 | /// | ||
| 761 | /// **Example:** | ||
| 762 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 763 | /// #include <kodi/Filesystem.h> | ||
| 764 | /// ... | ||
| 765 | /// std::string path = "///\\jk???lj????\\hgjkg"; | ||
| 766 | /// std::string legalPath = kodi::vfs::MakeLegalPath(path); | ||
| 767 | /// fprintf(stderr, "Legal name of '%s' is '%s'\n", path.c_str(), legalPath.c_str()); | ||
| 768 | /// | ||
| 769 | /// /* Returns as legal: '/jk___lj____/hgjkg' */ | ||
| 770 | /// ~~~~~~~~~~~~~ | ||
| 771 | /// | ||
| 772 | inline std::string MakeLegalPath(const std::string& path) | ||
| 773 | { | ||
| 774 | std::string strReturn; | ||
| 775 | char* strLegalPath = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->make_legal_path(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 776 | if (strLegalPath != nullptr) | ||
| 777 | { | ||
| 778 | if (std::strlen(strLegalPath)) | ||
| 779 | strReturn = strLegalPath; | ||
| 780 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, strLegalPath); | ||
| 781 | } | ||
| 782 | return strReturn; | ||
| 783 | } | ||
| 784 | //---------------------------------------------------------------------------- | ||
| 785 | |||
| 786 | //============================================================================ | ||
| 787 | /// | ||
| 788 | /// \ingroup cpp_kodi | ||
| 789 | /// @brief Returns the translated path | ||
| 790 | /// | ||
| 791 | /// @param[in] source string or unicode - Path to format | ||
| 792 | /// @return A human-readable string suitable for logging | ||
| 793 | /// | ||
| 794 | /// @note Only useful if you are coding for both Linux and Windows. | ||
| 795 | /// e.g. Converts 'special://masterprofile/script_data' -> '/home/user/.kodi/UserData/script_data' | ||
| 796 | /// on Linux. | ||
| 797 | /// | ||
| 798 | /// | ||
| 799 | /// ------------------------------------------------------------------------ | ||
| 800 | /// | ||
| 801 | /// **Example:** | ||
| 802 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 803 | /// #include <kodi/Filesystem.h> | ||
| 804 | /// ... | ||
| 805 | /// std::string path = kodi::vfs::TranslateSpecialProtocol("special://masterprofile/script_data"); | ||
| 806 | /// fprintf(stderr, "Translated path is: %s\n", path.c_str()); | ||
| 807 | /// ... | ||
| 808 | /// ~~~~~~~~~~~~~ | ||
| 809 | /// or | ||
| 810 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 811 | /// #include <kodi/Filesystem.h> | ||
| 812 | /// ... | ||
| 813 | /// fprintf(stderr, "Directory 'special://temp' is '%s'\n", kodi::vfs::TranslateSpecialProtocol("special://temp").c_str()); | ||
| 814 | /// ... | ||
| 815 | /// ~~~~~~~~~~~~~ | ||
| 816 | /// | ||
| 817 | inline std::string TranslateSpecialProtocol(const std::string& source) | ||
| 818 | { | ||
| 819 | std::string strReturn; | ||
| 820 | char* protocol = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->translate_special_protocol(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, source.c_str()); | ||
| 821 | if (protocol != nullptr) | ||
| 822 | { | ||
| 823 | if (std::strlen(protocol)) | ||
| 824 | strReturn = protocol; | ||
| 825 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, protocol); | ||
| 826 | } | ||
| 827 | return strReturn; | ||
| 828 | } | ||
| 829 | //---------------------------------------------------------------------------- | ||
| 830 | |||
| 831 | //============================================================================ | ||
| 832 | /// | ||
| 833 | /// @ingroup cpp_kodi_vfs | ||
| 834 | /// @brief Return the file name from given complate path string | ||
| 835 | /// | ||
| 836 | /// @param[in] path The complete path include file and directory | ||
| 837 | /// @return Filename from path | ||
| 838 | /// | ||
| 839 | /// | ||
| 840 | /// ------------------------------------------------------------------------ | ||
| 841 | /// | ||
| 842 | /// **Example:** | ||
| 843 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 844 | /// #include <kodi/Filesystem.h> | ||
| 845 | /// ... | ||
| 846 | /// std::string fileName = kodi::vfs::GetFileName("special://temp/kodi.log"); | ||
| 847 | /// fprintf(stderr, "File name is '%s'\n", fileName.c_str()); | ||
| 848 | /// ~~~~~~~~~~~~~ | ||
| 849 | /// | ||
| 850 | inline std::string GetFileName(const std::string& path) | ||
| 851 | { | ||
| 852 | /* find the last slash */ | ||
| 853 | const size_t slash = path.find_last_of("/\\"); | ||
| 854 | return path.substr(slash+1); | ||
| 855 | } | ||
| 856 | //---------------------------------------------------------------------------- | ||
| 857 | |||
| 858 | //============================================================================ | ||
| 859 | /// | ||
| 860 | /// @ingroup cpp_kodi_vfs | ||
| 861 | /// @brief Return the directory name from given complate path string | ||
| 862 | /// | ||
| 863 | /// @param[in] path The complete path include file and directory | ||
| 864 | /// @return Directory name from path | ||
| 865 | /// | ||
| 866 | /// | ||
| 867 | /// ------------------------------------------------------------------------ | ||
| 868 | /// | ||
| 869 | /// **Example:** | ||
| 870 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 871 | /// #include <kodi/Filesystem.h> | ||
| 872 | /// ... | ||
| 873 | /// std::string dirName = kodi::vfs::GetDirectoryName("special://temp/kodi.log"); | ||
| 874 | /// fprintf(stderr, "Directory name is '%s'\n", dirName.c_str()); | ||
| 875 | /// ~~~~~~~~~~~~~ | ||
| 876 | /// | ||
| 877 | inline std::string GetDirectoryName(const std::string& path) | ||
| 878 | { | ||
| 879 | // Will from a full filename return the directory the file resides in. | ||
| 880 | // Keeps the final slash at end and possible |option=foo options. | ||
| 881 | |||
| 882 | size_t iPosSlash = path.find_last_of("/\\"); | ||
| 883 | if (iPosSlash == std::string::npos) | ||
| 884 | return ""; // No slash, so no path (ignore any options) | ||
| 885 | |||
| 886 | size_t iPosBar = path.rfind('|'); | ||
| 887 | if (iPosBar == std::string::npos) | ||
| 888 | return path.substr(0, iPosSlash + 1); // Only path | ||
| 889 | |||
| 890 | return path.substr(0, iPosSlash + 1) + path.substr(iPosBar); // Path + options | ||
| 891 | } | ||
| 892 | //---------------------------------------------------------------------------- | ||
| 893 | |||
| 894 | //============================================================================ | ||
| 895 | /// | ||
| 896 | /// @ingroup cpp_kodi_vfs | ||
| 897 | /// @brief Return a size aligned to the chunk size at least as large as the chunk size. | ||
| 898 | /// | ||
| 899 | /// @param[in] chunk The chunk size | ||
| 900 | /// @param[in] minimum The minimum size (or maybe the minimum number of chunks?) | ||
| 901 | /// @return The aligned size | ||
| 902 | /// | ||
| 903 | inline unsigned int GetChunkSize(unsigned int chunk, unsigned int minimum) | ||
| 904 | { | ||
| 905 | if (chunk) | ||
| 906 | return chunk * ((minimum + chunk - 1) / chunk); | ||
| 907 | else | ||
| 908 | return minimum; | ||
| 909 | } | ||
| 910 | //---------------------------------------------------------------------------- | ||
| 911 | |||
| 912 | //============================================================================ | ||
| 913 | /// | ||
| 914 | /// @ingroup cpp_kodi_vfs | ||
| 915 | /// @brief Check if a file exists. | ||
| 916 | /// | ||
| 917 | /// @param[in] filename The filename to check. | ||
| 918 | /// @param[in] usecache Check in file cache. | ||
| 919 | /// @return true if the file exists false otherwise. | ||
| 920 | /// | ||
| 921 | /// | ||
| 922 | /// ------------------------------------------------------------------------- | ||
| 923 | /// | ||
| 924 | /// **Example:** | ||
| 925 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 926 | /// #include <kodi/Filesystem.h> | ||
| 927 | /// ... | ||
| 928 | /// bool exists = kodi::vfs::FileExists("special://temp/kodi.log"); | ||
| 929 | /// fprintf(stderr, "Log file should be always present, is it present? %s\n", exists ? "yes" : "no"); | ||
| 930 | /// ~~~~~~~~~~~~~ | ||
| 931 | /// | ||
| 932 | static inline bool FileExists(const std::string& filename, bool usecache = false) | ||
| 933 | { | ||
| 934 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->file_exists(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), usecache); | ||
| 935 | } | ||
| 936 | //---------------------------------------------------------------------------- | ||
| 937 | |||
| 938 | //============================================================================ | ||
| 939 | /// | ||
| 940 | /// @ingroup cpp_kodi_vfs | ||
| 941 | /// @brief Get file status. | ||
| 942 | /// | ||
| 943 | /// These function return information about a file. Execute (search) | ||
| 944 | /// permission is required on all of the directories in path that | ||
| 945 | /// lead to the file. | ||
| 946 | /// | ||
| 947 | /// The call return a stat structure, which contains the on \ref STAT_STRUCTURE | ||
| 948 | /// defined values. | ||
| 949 | /// | ||
| 950 | /// @warning Not all of the OS file systems implement all of the time fields. | ||
| 951 | /// | ||
| 952 | /// @param[in] filename The filename to read the status from. | ||
| 953 | /// @param[out] buffer The file status is written into this buffer. | ||
| 954 | /// @return On success, tru is returned. On error, fale is returned | ||
| 955 | /// | ||
| 956 | /// | ||
| 957 | /// ------------------------------------------------------------------------- | ||
| 958 | /// | ||
| 959 | /// **Example:** | ||
| 960 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 961 | /// #include <kodi/Filesystem.h> | ||
| 962 | /// ... | ||
| 963 | /// STAT_STRUCTURE statFile; | ||
| 964 | /// int ret = kodi::vfs::StatFile("special://temp/kodi.log", &statFile); | ||
| 965 | /// fprintf(stderr, "deviceId (ID of device containing file) = %u\n" | ||
| 966 | /// "size (total size, in bytes) = %lu\n" | ||
| 967 | /// "accessTime (time of last access) = %lu\n" | ||
| 968 | /// "modificationTime (time of last modification) = %lu\n" | ||
| 969 | /// "statusTime (time of last status change) = %lu\n" | ||
| 970 | /// "isDirectory (The stat url is a directory) = %s\n" | ||
| 971 | /// "isSymLink (The stat url is a symbolic link) = %s\n" | ||
| 972 | /// "Return value = %i\n", | ||
| 973 | /// statFile.deviceId, | ||
| 974 | /// statFile.size, | ||
| 975 | /// statFile.accessTime, | ||
| 976 | /// statFile.modificationTime, | ||
| 977 | /// statFile.statusTime, | ||
| 978 | /// statFile.isDirectory ? "true" : "false", | ||
| 979 | /// statFile.isSymLink ? "true" : "false", | ||
| 980 | /// ret); | ||
| 981 | /// ~~~~~~~~~~~~~ | ||
| 982 | /// | ||
| 983 | static inline bool StatFile(const std::string& filename, STAT_STRUCTURE& buffer) | ||
| 984 | { | ||
| 985 | struct __stat64 frontendBuffer = { }; | ||
| 986 | if (::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->stat_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), &frontendBuffer)) | ||
| 987 | { | ||
| 988 | buffer.deviceId = frontendBuffer.st_dev; | ||
| 989 | buffer.size = frontendBuffer.st_size; | ||
| 990 | #if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) | ||
| 991 | buffer.accessTime = frontendBuffer.st_atimespec; | ||
| 992 | buffer.modificationTime = frontendBuffer.st_mtimespec; | ||
| 993 | buffer.statusTime = frontendBuffer.st_ctimespec; | ||
| 994 | #elif defined(TARGET_WINDOWS) | ||
| 995 | buffer.accessTime = frontendBuffer.st_atime; | ||
| 996 | buffer.modificationTime = frontendBuffer.st_mtime; | ||
| 997 | buffer.statusTime = frontendBuffer.st_ctime; | ||
| 998 | #elif defined(TARGET_ANDROID) | ||
| 999 | buffer.accessTime.tv_sec = frontendBuffer.st_atime; | ||
| 1000 | buffer.accessTime.tv_nsec = frontendBuffer.st_atime_nsec; | ||
| 1001 | buffer.modificationTime.tv_sec = frontendBuffer.st_mtime; | ||
| 1002 | buffer.modificationTime.tv_nsec = frontendBuffer.st_mtime_nsec; | ||
| 1003 | buffer.statusTime.tv_sec = frontendBuffer.st_ctime; | ||
| 1004 | buffer.statusTime.tv_nsec = frontendBuffer.st_ctime_nsec; | ||
| 1005 | #else | ||
| 1006 | buffer.accessTime = frontendBuffer.st_atim; | ||
| 1007 | buffer.modificationTime = frontendBuffer.st_mtim; | ||
| 1008 | buffer.statusTime = frontendBuffer.st_ctim; | ||
| 1009 | #endif | ||
| 1010 | buffer.isDirectory = S_ISDIR(frontendBuffer.st_mode); | ||
| 1011 | buffer.isSymLink = S_ISLNK(frontendBuffer.st_mode); | ||
| 1012 | return true; | ||
| 1013 | } | ||
| 1014 | return false; | ||
| 1015 | } | ||
| 1016 | //---------------------------------------------------------------------------- | ||
| 1017 | |||
| 1018 | //============================================================================ | ||
| 1019 | /// | ||
| 1020 | /// @ingroup cpp_kodi_vfs | ||
| 1021 | /// @brief Deletes a file. | ||
| 1022 | /// | ||
| 1023 | /// @param[in] filename The filename to delete. | ||
| 1024 | /// @return The file was successfully deleted. | ||
| 1025 | /// | ||
| 1026 | /// | ||
| 1027 | /// ------------------------------------------------------------------------- | ||
| 1028 | /// | ||
| 1029 | /// **Example:** | ||
| 1030 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1031 | /// #include <kodi/Filesystem.h> | ||
| 1032 | /// #include <kodi/gui/DialogFileBrowser.h> | ||
| 1033 | /// #include <kodi/gui/DialogOK.h> | ||
| 1034 | /// ... | ||
| 1035 | /// std::string filename; | ||
| 1036 | /// if (kodi::gui::DialogFileBrowser::ShowAndGetFile("local", "", | ||
| 1037 | /// "Test File selection and delete of them!", | ||
| 1038 | /// filename)) | ||
| 1039 | /// { | ||
| 1040 | /// bool successed = kodi::vfs::DeleteFile(filename); | ||
| 1041 | /// if (!successed) | ||
| 1042 | /// kodi::gui::DialogOK::ShowAndGetInput("Error", "Delete of File", filename, "failed!"); | ||
| 1043 | /// else | ||
| 1044 | /// kodi::gui::DialogOK::ShowAndGetInput("Information", "Delete of File", filename, "successfull done."); | ||
| 1045 | /// } | ||
| 1046 | /// ~~~~~~~~~~~~~ | ||
| 1047 | /// | ||
| 1048 | static inline bool DeleteFile(const std::string& filename) | ||
| 1049 | { | ||
| 1050 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->delete_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str()); | ||
| 1051 | } | ||
| 1052 | //---------------------------------------------------------------------------- | ||
| 1053 | |||
| 1054 | //============================================================================ | ||
| 1055 | /// | ||
| 1056 | /// @ingroup cpp_kodi_vfs | ||
| 1057 | /// @brief Rename a file name | ||
| 1058 | /// | ||
| 1059 | /// @param[in] filename The filename to copy. | ||
| 1060 | /// @param[in] newFileName The new filename | ||
| 1061 | /// @return true if successfully renamed | ||
| 1062 | /// | ||
| 1063 | /// | ||
| 1064 | static inline bool RenameFile(const std::string& filename, const std::string& newFileName) | ||
| 1065 | { | ||
| 1066 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->rename_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), newFileName.c_str()); | ||
| 1067 | } | ||
| 1068 | //---------------------------------------------------------------------------- | ||
| 1069 | |||
| 1070 | //============================================================================ | ||
| 1071 | /// | ||
| 1072 | /// @ingroup cpp_kodi_vfs | ||
| 1073 | /// @brief Copy a file from source to destination | ||
| 1074 | /// | ||
| 1075 | /// @param[in] filename The filename to copy. | ||
| 1076 | /// @param[in] destination The destination to copy file to | ||
| 1077 | /// @return true if successfully copied | ||
| 1078 | /// | ||
| 1079 | /// | ||
| 1080 | static inline bool CopyFile(const std::string& filename, const std::string& destination) | ||
| 1081 | { | ||
| 1082 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->copy_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), destination.c_str()); | ||
| 1083 | } | ||
| 1084 | //---------------------------------------------------------------------------- | ||
| 1085 | |||
| 1086 | //============================================================================ | ||
| 1087 | /// | ||
| 1088 | /// \defgroup cpp_kodi_vfs_CFile class CFile | ||
| 1089 | /// \ingroup cpp_kodi_vfs | ||
| 1090 | /// | ||
| 1091 | /// @brief **Virtual file server control** | ||
| 1092 | /// | ||
| 1093 | /// CFile is the class used for handling Files in Kodi. This class can be used | ||
| 1094 | /// for creating, reading, writing and modifying files. It directly provides unbuffered, binary disk input/output services | ||
| 1095 | /// | ||
| 1096 | /// It has the header \ref Filesystem.h "#include <kodi/Filesystem.h>" be included | ||
| 1097 | /// to enjoy it. | ||
| 1098 | /// | ||
| 1099 | /// | ||
| 1100 | /// ------------------------------------------------------------------------ | ||
| 1101 | /// | ||
| 1102 | /// **Example:** | ||
| 1103 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1104 | /// #include <kodi/Filesystem.h> | ||
| 1105 | /// | ||
| 1106 | /// ... | ||
| 1107 | /// | ||
| 1108 | /// /* Create the needed file handle class */ | ||
| 1109 | /// kodi::vfs::CFile myFile(); | ||
| 1110 | /// | ||
| 1111 | /// /* In this example we use the user path for the add-on */ | ||
| 1112 | /// std::string file = kodi::GetUserPath() + "/myFile.txt"; | ||
| 1113 | /// | ||
| 1114 | /// /* Now create and open the file or overwrite if present */ | ||
| 1115 | /// myFile.OpenFileForWrite(file, true); | ||
| 1116 | /// | ||
| 1117 | /// const char* str = "I love Kodi!"; | ||
| 1118 | /// | ||
| 1119 | /// /* write string */ | ||
| 1120 | /// myFile.Write(str, sizeof(str)); | ||
| 1121 | /// | ||
| 1122 | /// /* On this way the Close() is not needed to call, becomes done from destructor */ | ||
| 1123 | /// | ||
| 1124 | /// ~~~~~~~~~~~~~ | ||
| 1125 | /// | ||
| 1126 | //@{ | ||
| 1127 | class CFile | ||
| 1128 | { | ||
| 1129 | public: | ||
| 1130 | //========================================================================== | ||
| 1131 | /// | ||
| 1132 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1133 | /// @brief Construct a new, unopened file | ||
| 1134 | /// | ||
| 1135 | CFile() : m_file(nullptr) { } | ||
| 1136 | //-------------------------------------------------------------------------- | ||
| 1137 | |||
| 1138 | //========================================================================== | ||
| 1139 | /// | ||
| 1140 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1141 | /// @brief Close() is called from the destructor, so explicitly closing the | ||
| 1142 | /// file isn't required | ||
| 1143 | /// | ||
| 1144 | virtual ~CFile() { Close(); } | ||
| 1145 | //-------------------------------------------------------------------------- | ||
| 1146 | |||
| 1147 | //========================================================================== | ||
| 1148 | /// | ||
| 1149 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1150 | /// @brief Open the file with filename via Kodi's \ref cpp_kodi_vfs_CFile | ||
| 1151 | /// "CFile". Needs to be closed by calling Close() when done. | ||
| 1152 | /// | ||
| 1153 | /// @param[in] filename The filename to open. | ||
| 1154 | /// @param[in] flags [opt] The flags to pass, see \ref OpenFileFlags | ||
| 1155 | /// @return True on success or false on failure | ||
| 1156 | /// | ||
| 1157 | bool OpenFile(const std::string& filename, unsigned int flags = 0) | ||
| 1158 | { | ||
| 1159 | Close(); | ||
| 1160 | m_file = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->open_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), flags); | ||
| 1161 | return m_file != nullptr; | ||
| 1162 | } | ||
| 1163 | //-------------------------------------------------------------------------- | ||
| 1164 | |||
| 1165 | //========================================================================== | ||
| 1166 | /// | ||
| 1167 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1168 | /// @brief Open the file with filename via Kodi's \ref cpp_kodi_vfs_CFile | ||
| 1169 | /// "CFile" in write mode. Needs to be closed by calling Close() when | ||
| 1170 | /// done. | ||
| 1171 | /// | ||
| 1172 | /// @note Related folders becomes created if not present. | ||
| 1173 | /// | ||
| 1174 | /// @param[in] filename The filename to open. | ||
| 1175 | /// @param[in] overwrite True to overwrite, false otherwise. | ||
| 1176 | /// @return True on success or false on failure | ||
| 1177 | /// | ||
| 1178 | bool OpenFileForWrite(const std::string& filename, bool overwrite = false) | ||
| 1179 | { | ||
| 1180 | Close(); | ||
| 1181 | |||
| 1182 | // Try to open the file. If it fails, check if we need to create the directory first | ||
| 1183 | // This way we avoid checking if the directory exists every time | ||
| 1184 | m_file = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->open_file_for_write(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite); | ||
| 1185 | if (!m_file) | ||
| 1186 | { | ||
| 1187 | std::string cacheDirectory = kodi::vfs::GetDirectoryName(filename); | ||
| 1188 | if (::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->directory_exists(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str()) || | ||
| 1189 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->create_directory(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str())) | ||
| 1190 | m_file = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->open_file_for_write(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite); | ||
| 1191 | } | ||
| 1192 | return m_file != nullptr; | ||
| 1193 | } | ||
| 1194 | //-------------------------------------------------------------------------- | ||
| 1195 | |||
| 1196 | //========================================================================== | ||
| 1197 | /// | ||
| 1198 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1199 | /// @brief Create a Curl representation | ||
| 1200 | /// | ||
| 1201 | /// @param[in] url the URL of the Type. | ||
| 1202 | /// @return True on success or false on failure | ||
| 1203 | /// | ||
| 1204 | bool CURLCreate(const std::string& url) | ||
| 1205 | { | ||
| 1206 | m_file = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->curl_create(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, url.c_str()); | ||
| 1207 | return m_file != nullptr; | ||
| 1208 | } | ||
| 1209 | //-------------------------------------------------------------------------- | ||
| 1210 | |||
| 1211 | //========================================================================== | ||
| 1212 | /// | ||
| 1213 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1214 | /// @brief Add options to the curl file created with CURLCreate | ||
| 1215 | /// | ||
| 1216 | /// @param[in] type option type to set, see \ref CURLOptiontype | ||
| 1217 | /// @param[in] name name of the option | ||
| 1218 | /// @param[in] value value of the option | ||
| 1219 | /// @return True on success or false on failure | ||
| 1220 | /// | ||
| 1221 | bool CURLAddOption(CURLOptiontype type, const std::string& name, const std::string& value) | ||
| 1222 | { | ||
| 1223 | if (!m_file) | ||
| 1224 | { | ||
| 1225 | kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before!"); | ||
| 1226 | return false; | ||
| 1227 | } | ||
| 1228 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->curl_add_option(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), value.c_str()); | ||
| 1229 | } | ||
| 1230 | //-------------------------------------------------------------------------- | ||
| 1231 | |||
| 1232 | //========================================================================== | ||
| 1233 | /// | ||
| 1234 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1235 | /// @brief Open the curl file created with CURLCreate | ||
| 1236 | /// | ||
| 1237 | /// @param[in] flags [opt] The flags to pass, see \ref OpenFileFlags | ||
| 1238 | /// @return True on success or false on failure | ||
| 1239 | /// | ||
| 1240 | bool CURLOpen(unsigned int flags = 0) | ||
| 1241 | { | ||
| 1242 | if (!m_file) | ||
| 1243 | { | ||
| 1244 | kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before!"); | ||
| 1245 | return false; | ||
| 1246 | } | ||
| 1247 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->curl_open(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, flags); | ||
| 1248 | } | ||
| 1249 | //-------------------------------------------------------------------------- | ||
| 1250 | |||
| 1251 | //========================================================================== | ||
| 1252 | /// | ||
| 1253 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1254 | /// @brief Read from an open file. | ||
| 1255 | /// | ||
| 1256 | /// @param[in] ptr The buffer to store the data in. | ||
| 1257 | /// @param[in] size The size of the buffer. | ||
| 1258 | /// @return number of successfully read bytes if any bytes | ||
| 1259 | /// were read and stored in buffer, zero if no bytes | ||
| 1260 | /// are available to read (end of file was reached) | ||
| 1261 | /// or undetectable error occur, -1 in case of any | ||
| 1262 | /// explicit error | ||
| 1263 | /// | ||
| 1264 | ssize_t Read(void* ptr, size_t size) | ||
| 1265 | { | ||
| 1266 | if (!m_file) | ||
| 1267 | return -1; | ||
| 1268 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->read_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, ptr, size); | ||
| 1269 | } | ||
| 1270 | //-------------------------------------------------------------------------- | ||
| 1271 | |||
| 1272 | //========================================================================== | ||
| 1273 | /// | ||
| 1274 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1275 | /// @brief Read a string from an open file. | ||
| 1276 | /// | ||
| 1277 | /// @param[out] line The buffer to store the data in. | ||
| 1278 | /// @return True when a line was read, false otherwise. | ||
| 1279 | /// | ||
| 1280 | bool ReadLine(std::string &line) | ||
| 1281 | { | ||
| 1282 | line.clear(); | ||
| 1283 | if (!m_file) | ||
| 1284 | return false; | ||
| 1285 | // TODO: Read 1024 chars into buffer. If file position advanced that many | ||
| 1286 | // chars, we didn't hit a newline. Otherwise, if file position is 1 or 2 | ||
| 1287 | // past the number of bytes read, we read (and skipped) a newline sequence. | ||
| 1288 | char buffer[1025]; | ||
| 1289 | if (::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->read_file_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, buffer, sizeof(buffer))) | ||
| 1290 | { | ||
| 1291 | line = buffer; | ||
| 1292 | return !line.empty(); | ||
| 1293 | } | ||
| 1294 | return false; | ||
| 1295 | } | ||
| 1296 | //-------------------------------------------------------------------------- | ||
| 1297 | |||
| 1298 | //========================================================================== | ||
| 1299 | /// | ||
| 1300 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1301 | /// @brief Write to a file opened in write mode. | ||
| 1302 | /// | ||
| 1303 | /// @param[in] ptr Pointer to the data to write, converted to a | ||
| 1304 | /// const void*. | ||
| 1305 | /// @param[in] size Size of the data to write. | ||
| 1306 | /// @return number of successfully written bytes if any | ||
| 1307 | /// bytes were written, zero if no bytes were | ||
| 1308 | /// written and no detectable error occur,-1 in case | ||
| 1309 | /// of any explicit error | ||
| 1310 | /// | ||
| 1311 | ssize_t Write(const void* ptr, size_t size) | ||
| 1312 | { | ||
| 1313 | if (!m_file) | ||
| 1314 | return -1; | ||
| 1315 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->write_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, ptr, size); | ||
| 1316 | } | ||
| 1317 | //-------------------------------------------------------------------------- | ||
| 1318 | |||
| 1319 | //========================================================================== | ||
| 1320 | /// | ||
| 1321 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1322 | /// @brief Flush buffered data. | ||
| 1323 | /// | ||
| 1324 | /// If the given stream was open for writing (or if it was open for updating | ||
| 1325 | /// and the last i/o operation was an output operation) any unwritten data | ||
| 1326 | /// in its output buffer is written to the file. | ||
| 1327 | /// | ||
| 1328 | /// The stream remains open after this call. | ||
| 1329 | /// | ||
| 1330 | /// When a file is closed, either because of a call to close or because the | ||
| 1331 | /// class is destructed, all the buffers associated with it are | ||
| 1332 | /// automatically flushed. | ||
| 1333 | /// | ||
| 1334 | void Flush() | ||
| 1335 | { | ||
| 1336 | if (!m_file) | ||
| 1337 | return; | ||
| 1338 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->flush_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1339 | } | ||
| 1340 | //-------------------------------------------------------------------------- | ||
| 1341 | |||
| 1342 | //========================================================================== | ||
| 1343 | /// | ||
| 1344 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1345 | /// @brief Set the file's current position. | ||
| 1346 | /// | ||
| 1347 | /// The whence argument is optional and defaults to SEEK_SET (0) | ||
| 1348 | /// | ||
| 1349 | /// @param[in] position the position that you want to seek to | ||
| 1350 | /// @param[in] whence [optional] offset relative to | ||
| 1351 | /// You can set the value of whence to one. | ||
| 1352 | /// of three things: | ||
| 1353 | /// | Value | int | Description | | ||
| 1354 | /// |:--------:|:---:|:----------------------------------------------------| | ||
| 1355 | /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence. | ||
| 1356 | /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes." | ||
| 1357 | /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion. | ||
| 1358 | /// | ||
| 1359 | /// @return Returns the resulting offset location as | ||
| 1360 | /// measured in bytes from the beginning of | ||
| 1361 | /// the file. On error, the value -1 is | ||
| 1362 | /// returned. | ||
| 1363 | /// | ||
| 1364 | int64_t Seek(int64_t position, int whence = SEEK_SET) | ||
| 1365 | { | ||
| 1366 | if (!m_file) | ||
| 1367 | return -1; | ||
| 1368 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->seek_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, position, whence); | ||
| 1369 | } | ||
| 1370 | //-------------------------------------------------------------------------- | ||
| 1371 | |||
| 1372 | //========================================================================== | ||
| 1373 | /// | ||
| 1374 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1375 | /// @brief Truncate a file to the requested size. | ||
| 1376 | /// | ||
| 1377 | /// @param[in] size The new max size. | ||
| 1378 | /// @return New size? On error, the value -1 is | ||
| 1379 | /// returned. | ||
| 1380 | /// | ||
| 1381 | int Truncate(int64_t size) | ||
| 1382 | { | ||
| 1383 | if (!m_file) | ||
| 1384 | return -1; | ||
| 1385 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->truncate_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, size); | ||
| 1386 | } | ||
| 1387 | //-------------------------------------------------------------------------- | ||
| 1388 | |||
| 1389 | //========================================================================== | ||
| 1390 | /// | ||
| 1391 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1392 | /// @brief The current offset in an open file. | ||
| 1393 | /// | ||
| 1394 | /// @return The requested offset. On error, the value -1 is | ||
| 1395 | /// returned. | ||
| 1396 | /// | ||
| 1397 | int64_t GetPosition() | ||
| 1398 | { | ||
| 1399 | if (!m_file) | ||
| 1400 | return -1; | ||
| 1401 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_position(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1402 | } | ||
| 1403 | //-------------------------------------------------------------------------- | ||
| 1404 | |||
| 1405 | //========================================================================== | ||
| 1406 | /// | ||
| 1407 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1408 | /// @brief Get the file size of an open file. | ||
| 1409 | /// | ||
| 1410 | /// @return The requested size. On error, the value -1 is | ||
| 1411 | /// returned. | ||
| 1412 | /// | ||
| 1413 | int64_t GetLength() | ||
| 1414 | { | ||
| 1415 | if (!m_file) | ||
| 1416 | return -1; | ||
| 1417 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_length(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1418 | } | ||
| 1419 | //-------------------------------------------------------------------------- | ||
| 1420 | |||
| 1421 | //========================================================================== | ||
| 1422 | /// | ||
| 1423 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1424 | /// @brief Checks the file access is on end position. | ||
| 1425 | /// | ||
| 1426 | /// @return If you've reached the end of the file, AtEnd() returns true. | ||
| 1427 | /// | ||
| 1428 | bool AtEnd() | ||
| 1429 | { | ||
| 1430 | if (!m_file) | ||
| 1431 | return true; | ||
| 1432 | int64_t length = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_length(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1433 | int64_t position = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_position(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1434 | return position >= length; | ||
| 1435 | } | ||
| 1436 | //-------------------------------------------------------------------------- | ||
| 1437 | |||
| 1438 | //========================================================================== | ||
| 1439 | /// | ||
| 1440 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1441 | /// @brief Close an open file. | ||
| 1442 | /// | ||
| 1443 | void Close() | ||
| 1444 | { | ||
| 1445 | if (!m_file) | ||
| 1446 | return; | ||
| 1447 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->close_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1448 | m_file = nullptr; | ||
| 1449 | } | ||
| 1450 | //-------------------------------------------------------------------------- | ||
| 1451 | |||
| 1452 | //========================================================================== | ||
| 1453 | /// | ||
| 1454 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1455 | /// @brief Get the chunk size for an open file. | ||
| 1456 | /// | ||
| 1457 | /// @return The requested size. On error, the value -1 is | ||
| 1458 | /// returned. | ||
| 1459 | /// | ||
| 1460 | int GetChunkSize() | ||
| 1461 | { | ||
| 1462 | if (!m_file) | ||
| 1463 | return -1; | ||
| 1464 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_chunk_size(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1465 | } | ||
| 1466 | //-------------------------------------------------------------------------- | ||
| 1467 | |||
| 1468 | //========================================================================== | ||
| 1469 | /// | ||
| 1470 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1471 | /// @brief Get the current download speed of file if loaded from web. | ||
| 1472 | /// | ||
| 1473 | /// @return The current download speed. | ||
| 1474 | /// | ||
| 1475 | double GetFileDownloadSpeed() | ||
| 1476 | { | ||
| 1477 | if (!m_file) | ||
| 1478 | return 0.0; | ||
| 1479 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_download_speed(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1480 | } | ||
| 1481 | //-------------------------------------------------------------------------- | ||
| 1482 | |||
| 1483 | private: | ||
| 1484 | void* m_file; | ||
| 1485 | }; | ||
| 1486 | //@} | ||
| 1487 | //---------------------------------------------------------------------------- | ||
| 1488 | |||
| 1489 | } /* namespace vfs */ | ||
| 1490 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/General.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/General.h new file mode 100644 index 0000000..50718af --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/General.h | |||
| @@ -0,0 +1,376 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team Kodi | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with Kodi; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "AddonBase.h" | ||
| 23 | |||
| 24 | /* | ||
| 25 | * For interface between add-on and kodi. | ||
| 26 | * | ||
| 27 | * This structure defines the addresses of functions stored inside Kodi which | ||
| 28 | * are then available for the add-on to call | ||
| 29 | * | ||
| 30 | * All function pointers there are used by the C++ interface functions below. | ||
| 31 | * You find the set of them on xbmc/addons/interfaces/General.cpp | ||
| 32 | * | ||
| 33 | * Note: For add-on development itself this is not needed | ||
| 34 | */ | ||
| 35 | typedef struct AddonToKodiFuncTable_kodi | ||
| 36 | { | ||
| 37 | bool (*open_settings_dialog)(void* kodiBase); | ||
| 38 | char* (*unknown_to_utf8)(void* kodiBase, const char* source, bool* ret, bool failOnBadChar); | ||
| 39 | char* (*get_localized_string)(void* kodiBase, long dwCode); | ||
| 40 | char* (*get_language)(void* kodiBase, int format, bool region); | ||
| 41 | bool (*queue_notification)(void* kodiBase, int type, const char* header, const char* message, const char* imageFile, unsigned int displayTime, bool withSound, unsigned int messageTime); | ||
| 42 | } AddonToKodiFuncTable_kodi; | ||
| 43 | |||
| 44 | //============================================================================== | ||
| 45 | /// \ingroup cpp_kodi_Defs | ||
| 46 | /// @brief For kodi::QueueNotification() used message types | ||
| 47 | /// | ||
| 48 | typedef enum QueueMsg | ||
| 49 | { | ||
| 50 | /// Show info notification message | ||
| 51 | QUEUE_INFO, | ||
| 52 | /// Show warning notification message | ||
| 53 | QUEUE_WARNING, | ||
| 54 | /// Show error notification message | ||
| 55 | QUEUE_ERROR, | ||
| 56 | /// Show with own given image and parts if set on values | ||
| 57 | QUEUE_OWN_STYLE | ||
| 58 | } QueueMsg; | ||
| 59 | //------------------------------------------------------------------------------ | ||
| 60 | |||
| 61 | //============================================================================== | ||
| 62 | /// \ingroup cpp_kodi_Defs | ||
| 63 | /// @brief Format codes to get string from them. | ||
| 64 | /// | ||
| 65 | typedef enum LangFormats | ||
| 66 | { | ||
| 67 | /// two letter code as defined in ISO 639-1 | ||
| 68 | LANG_FMT_ISO_639_1, | ||
| 69 | /// three letter code as defined in ISO 639-2/T or ISO 639-2/B | ||
| 70 | LANG_FMT_ISO_639_2, | ||
| 71 | /// full language name in English | ||
| 72 | LANG_FMT_ENGLISH_NAME | ||
| 73 | } LangFormats; | ||
| 74 | //------------------------------------------------------------------------------ | ||
| 75 | |||
| 76 | |||
| 77 | //============================================================================== | ||
| 78 | namespace kodi { | ||
| 79 | /// | ||
| 80 | /// \ingroup cpp_kodi | ||
| 81 | /// @brief Opens this Add-Ons settings dialog. | ||
| 82 | /// | ||
| 83 | /// @return true if settings were changed and the dialog confirmed, false otherwise. | ||
| 84 | /// | ||
| 85 | /// | ||
| 86 | /// -------------------------------------------------------------------------- | ||
| 87 | /// | ||
| 88 | /// **Example:** | ||
| 89 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 90 | /// #include <kodi/General.h> | ||
| 91 | /// .. | ||
| 92 | /// kodi::OpenSettings(); | ||
| 93 | /// .. | ||
| 94 | /// ~~~~~~~~~~~~~ | ||
| 95 | /// | ||
| 96 | inline bool OpenSettings() | ||
| 97 | { | ||
| 98 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->open_settings_dialog(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase); | ||
| 99 | } | ||
| 100 | } /* namespace kodi */ | ||
| 101 | //------------------------------------------------------------------------------ | ||
| 102 | |||
| 103 | //============================================================================== | ||
| 104 | namespace kodi { | ||
| 105 | /// | ||
| 106 | /// \ingroup cpp_kodi | ||
| 107 | /// @brief Returns an addon's localized 'unicode string'. | ||
| 108 | /// | ||
| 109 | /// @param[in] labelId string you want to localize | ||
| 110 | /// @param[in] defaultStr [opt] The default message, also helps to identify | ||
| 111 | /// the code that is used <em>(default is | ||
| 112 | /// <b><c>empty</c></b>)</em> | ||
| 113 | /// @return The localized message, or default if the add-on | ||
| 114 | /// helper fails to return a message | ||
| 115 | /// | ||
| 116 | /// @note Label id's \b 30000 to \b 30999 and \b 32000 to \b 32999 are related | ||
| 117 | /// to the add-on's own included strings from | ||
| 118 | /// <b>./resources/language/resource.language.??_??/strings.po</b> | ||
| 119 | /// All other strings are from Kodi core language files. | ||
| 120 | /// | ||
| 121 | /// | ||
| 122 | /// ------------------------------------------------------------------------ | ||
| 123 | /// | ||
| 124 | /// **Example:** | ||
| 125 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 126 | /// #include <kodi/General.h> | ||
| 127 | /// ... | ||
| 128 | /// std::string str = kodi::GetLocalizedString(30005, "Use me as default"); | ||
| 129 | /// ... | ||
| 130 | /// ~~~~~~~~~~~~~ | ||
| 131 | /// | ||
| 132 | inline std::string GetLocalizedString(uint32_t labelId, const std::string& defaultStr = "") | ||
| 133 | { | ||
| 134 | std::string retString = defaultStr; | ||
| 135 | char* strMsg = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->get_localized_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, labelId); | ||
| 136 | if (strMsg != nullptr) | ||
| 137 | { | ||
| 138 | if (std::strlen(strMsg)) | ||
| 139 | retString = strMsg; | ||
| 140 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, strMsg); | ||
| 141 | } | ||
| 142 | return retString; | ||
| 143 | } | ||
| 144 | } /* namespace kodi */ | ||
| 145 | //------------------------------------------------------------------------------ | ||
| 146 | |||
| 147 | //============================================================================== | ||
| 148 | namespace kodi { | ||
| 149 | /// | ||
| 150 | /// \ingroup cpp_kodi | ||
| 151 | /// @brief Translate a string with an unknown encoding to UTF8. | ||
| 152 | /// | ||
| 153 | /// @param[in] stringSrc The string to translate. | ||
| 154 | /// @param[out] utf8StringDst The translated string. | ||
| 155 | /// @param[in] failOnBadChar [opt] returns failed if bad character is inside <em>(default is <b><c>false</c></b>)</em> | ||
| 156 | /// @return true if OK | ||
| 157 | /// | ||
| 158 | /// | ||
| 159 | /// ------------------------------------------------------------------------ | ||
| 160 | /// | ||
| 161 | /// **Example:** | ||
| 162 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 163 | /// #include <kodi/General.h> | ||
| 164 | /// ... | ||
| 165 | /// std::string ret; | ||
| 166 | /// if (!kodi::UnknownToUTF8("test string", ret, true)) | ||
| 167 | /// fprintf(stderr, "Translation to UTF8 failed!\n"); | ||
| 168 | /// ... | ||
| 169 | /// ~~~~~~~~~~~~~ | ||
| 170 | /// | ||
| 171 | inline bool UnknownToUTF8(const std::string& stringSrc, std::string& utf8StringDst, bool failOnBadChar = false) | ||
| 172 | { | ||
| 173 | bool ret = false; | ||
| 174 | char* retString = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->unknown_to_utf8(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, | ||
| 175 | stringSrc.c_str(), &ret, failOnBadChar); | ||
| 176 | if (retString != nullptr) | ||
| 177 | { | ||
| 178 | if (ret) | ||
| 179 | utf8StringDst = retString; | ||
| 180 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 181 | } | ||
| 182 | return ret; | ||
| 183 | } | ||
| 184 | } /* namespace kodi */ | ||
| 185 | //------------------------------------------------------------------------------ | ||
| 186 | |||
| 187 | //============================================================================== | ||
| 188 | namespace kodi { | ||
| 189 | /// | ||
| 190 | /// \ingroup cpp_kodi | ||
| 191 | /// @brief Returns the active language as a string. | ||
| 192 | /// | ||
| 193 | /// @param[in] format Used format of the returned language string | ||
| 194 | /// | enum code: | Description: | | ||
| 195 | /// |----------------------:|------------------------------------------------------------| | ||
| 196 | /// | LANG_FMT_ENGLISH_NAME | full language name in English (Default) | | ||
| 197 | /// | LANG_FMT_ISO_639_1 | two letter code as defined in ISO 639-1 | | ||
| 198 | /// | LANG_FMT_ISO_639_2 | three letter code as defined in ISO 639-2/T or ISO 639-2/B | | ||
| 199 | /// @param[in] region [opt] append the region delimited by "-" of the language (setting) to the returned language string <em>(default is <b><c>false</c></b>)</em> | ||
| 200 | /// @return active language | ||
| 201 | /// | ||
| 202 | /// | ||
| 203 | /// ------------------------------------------------------------------------ | ||
| 204 | /// | ||
| 205 | /// **Example:** | ||
| 206 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 207 | /// #include <kodi/General.h> | ||
| 208 | /// ... | ||
| 209 | /// std::string language = kodi::GetLanguage(LANG_FMT_ISO_639_1, false); | ||
| 210 | /// ... | ||
| 211 | /// ~~~~~~~~~~~~~ | ||
| 212 | /// | ||
| 213 | inline std::string GetLanguage(LangFormats format = LANG_FMT_ENGLISH_NAME, bool region = false) | ||
| 214 | { | ||
| 215 | std::string language; | ||
| 216 | char* retString = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->get_language(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, format, region); | ||
| 217 | if (retString != nullptr) | ||
| 218 | { | ||
| 219 | if (std::strlen(retString)) | ||
| 220 | language = retString; | ||
| 221 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 222 | } | ||
| 223 | return language; | ||
| 224 | } | ||
| 225 | } /* namespace kodi */ | ||
| 226 | //------------------------------------------------------------------------------ | ||
| 227 | |||
| 228 | //============================================================================== | ||
| 229 | namespace kodi { | ||
| 230 | /// | ||
| 231 | /// \ingroup cpp_kodi | ||
| 232 | /// @brief Writes the C string pointed by format in the GUI. If format includes | ||
| 233 | /// format specifiers (subsequences beginning with %), the additional arguments | ||
| 234 | /// following format are formatted and inserted in the resulting string replacing | ||
| 235 | /// their respective specifiers. | ||
| 236 | /// | ||
| 237 | /// After the format parameter, the function expects at least as many additional | ||
| 238 | /// arguments as specified by format. | ||
| 239 | /// | ||
| 240 | /// @param[in] type The message type. | ||
| 241 | /// | enum code: | Description: | | ||
| 242 | /// |---------------:|-----------------------------------| | ||
| 243 | /// | QUEUE_INFO | Show info notification message | | ||
| 244 | /// | QUEUE_WARNING | Show warning notification message | | ||
| 245 | /// | QUEUE_ERROR | Show error notification message | | ||
| 246 | /// @param[in] format The format of the message to pass to display in Kodi. | ||
| 247 | /// C string that contains the text to be written to the stream. | ||
| 248 | /// It can optionally contain embedded format specifiers that are | ||
| 249 | /// replaced by the values specified in subsequent additional | ||
| 250 | /// arguments and formatted as requested. | ||
| 251 | /// | specifier | Output | Example | ||
| 252 | /// |------------|----------------------------------------------------|------------ | ||
| 253 | /// | d or i | Signed decimal integer | 392 | ||
| 254 | /// | u | Unsigned decimal integer | 7235 | ||
| 255 | /// | o | Unsigned octal | 610 | ||
| 256 | /// | x | Unsigned hexadecimal integer | 7fa | ||
| 257 | /// | X | Unsigned hexadecimal integer (uppercase) | 7FA | ||
| 258 | /// | f | Decimal floating point, lowercase | 392.65 | ||
| 259 | /// | F | Decimal floating point, uppercase | 392.65 | ||
| 260 | /// | e | Scientific notation (mantissa/exponent), lowercase | 3.9265e+2 | ||
| 261 | /// | E | Scientific notation (mantissa/exponent), uppercase | 3.9265E+2 | ||
| 262 | /// | g | Use the shortest representation: %e or %f | 392.65 | ||
| 263 | /// | G | Use the shortest representation: %E or %F | 392.65 | ||
| 264 | /// | a | Hexadecimal floating point, lowercase | -0xc.90fep-2 | ||
| 265 | /// | A | Hexadecimal floating point, uppercase | -0XC.90FEP-2 | ||
| 266 | /// | c | Character | a | ||
| 267 | /// | s | String of characters | sample | ||
| 268 | /// | p | Pointer address | b8000000 | ||
| 269 | /// | % | A % followed by another % character will write a single % to the stream. | % | ||
| 270 | /// | ||
| 271 | /// The length sub-specifier modifies the length of the data type. This is a chart | ||
| 272 | /// showing the types used to interpret the corresponding arguments with and without | ||
| 273 | /// length specifier (if a different type is used, the proper type promotion or | ||
| 274 | /// conversion is performed, if allowed): | ||
| 275 | /// | length| d i | u o x X | f F e E g G a A | c | s | p | n | | ||
| 276 | /// |-------|---------------|-----------------------|-----------------|-------|---------|---------|-----------------| | ||
| 277 | /// | (none)| int | unsigned int | double | int | char* | void* | int* | | ||
| 278 | /// | hh | signed char | unsigned char | | | | | signed char* | | ||
| 279 | /// | h | short int | unsigned short int | | | | | short int* | | ||
| 280 | /// | l | long int | unsigned long int | | wint_t| wchar_t*| | long int* | | ||
| 281 | /// | ll | long long int | unsigned long long int| | | | | long long int* | | ||
| 282 | /// | j | intmax_t | uintmax_t | | | | | intmax_t* | | ||
| 283 | /// | z | size_t | size_t | | | | | size_t* | | ||
| 284 | /// | t | ptrdiff_t | ptrdiff_t | | | | | ptrdiff_t* | | ||
| 285 | /// | L | | | long double | | | | | | ||
| 286 | /// <b>Note:</b> that the c specifier takes an int (or wint_t) as argument, but performs the proper conversion to a char value | ||
| 287 | /// (or a wchar_t) before formatting it for output. | ||
| 288 | /// @param[in] ... (additional arguments) Depending on the format string, the function | ||
| 289 | /// may expect a sequence of additional arguments, each containing a value | ||
| 290 | /// to be used to replace a format specifier in the format string (or a pointer | ||
| 291 | /// to a storage location, for n). | ||
| 292 | /// There should be at least as many of these arguments as the number of values specified | ||
| 293 | /// in the format specifiers. Additional arguments are ignored by the function. | ||
| 294 | /// | ||
| 295 | /// | ||
| 296 | /// ------------------------------------------------------------------------ | ||
| 297 | /// | ||
| 298 | /// **Example:** | ||
| 299 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 300 | /// #include <kodi/General.h> | ||
| 301 | /// ... | ||
| 302 | /// kodi::QueueFormattedNotification(QUEUE_WARNING, "I'm want to inform you, here with a test call to show '%s'", "this"); | ||
| 303 | /// ... | ||
| 304 | /// ~~~~~~~~~~~~~ | ||
| 305 | /// | ||
| 306 | inline void QueueFormattedNotification(QueueMsg type, const char* format, ... ) | ||
| 307 | { | ||
| 308 | va_list args; | ||
| 309 | char buffer[16384]; | ||
| 310 | va_start(args, format); | ||
| 311 | vsprintf(buffer, format, args); | ||
| 312 | va_end(args); | ||
| 313 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->queue_notification(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, | ||
| 314 | type, "", buffer, "", 5000, false, 1000); | ||
| 315 | } | ||
| 316 | } /* namespace kodi */ | ||
| 317 | //------------------------------------------------------------------------------ | ||
| 318 | |||
| 319 | //============================================================================== | ||
| 320 | namespace kodi { | ||
| 321 | /// | ||
| 322 | /// \ingroup cpp_kodi | ||
| 323 | /// @brief Queue a notification in the GUI. | ||
| 324 | /// | ||
| 325 | /// @param[in] type The message type. | ||
| 326 | /// | enum code: | Description: | ||
| 327 | /// |----------------------:|----------------------------------- | ||
| 328 | /// | QUEUE_INFO | Show info notification message | ||
| 329 | /// | QUEUE_WARNING | Show warning notification message | ||
| 330 | /// | QUEUE_ERROR | Show error notification message | ||
| 331 | /// | QUEUE_OWN_STYLE | If used can be with imageFile the wanted image set or if leaved empty shown as info, also are the other optional values available then | ||
| 332 | /// @param[in] header Header Name (if leaved empty becomes addon name used) | ||
| 333 | /// @param[in] message Message to display on Kodi | ||
| 334 | /// @param[in] imageFile [opt] The image file to show on message (to use must be type set to QUEUE_OWN_STYLE) | ||
| 335 | /// @param[in] displayTime [opt] The time how long message is displayed <b>(default 5 sec)</b> (to use must be type set to QUEUE_OWN_STYLE) | ||
| 336 | /// @param[in] withSound [opt] if true also warning sound becomes played <b>(default with sound)</b> (to use must be type set to QUEUE_OWN_STYLE) | ||
| 337 | /// @param[in] messageTime [opt] how many milli seconds start show of notification <b>(default 1 sec)</b> (to use must be type set to QUEUE_OWN_STYLE) | ||
| 338 | /// | ||
| 339 | /// | ||
| 340 | /// ------------------------------------------------------------------------ | ||
| 341 | /// | ||
| 342 | /// **Example:** | ||
| 343 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 344 | /// #include <kodi/General.h> | ||
| 345 | /// ... | ||
| 346 | /// kodi::QueueNotification(QUEUE_OWN_STYLE, "I'm want to inform you", "Here with a test call", "", 3000, false, 1000); | ||
| 347 | /// ... | ||
| 348 | /// ~~~~~~~~~~~~~ | ||
| 349 | /// | ||
| 350 | /// **Example:** | ||
| 351 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 352 | /// #include <kodi/General.h> | ||
| 353 | /// ... | ||
| 354 | /// kodi::QueueNotification(QUEUE_WARNING, "I'm want to inform you", "Here with a test call"); | ||
| 355 | /// ... | ||
| 356 | /// ~~~~~~~~~~~~~ | ||
| 357 | /// | ||
| 358 | /// **Example:** | ||
| 359 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 360 | /// #include <kodi/General.h> | ||
| 361 | /// ... | ||
| 362 | /// kodi::QueueNotification(QUEUE_OWN_STYLE, "", "Here with a test call", "./myImage.png"); | ||
| 363 | /// ... | ||
| 364 | /// ~~~~~~~~~~~~~ | ||
| 365 | /// | ||
| 366 | inline void QueueNotification(QueueMsg type, const std::string& header, | ||
| 367 | const std::string& message, const std::string& imageFile = "", | ||
| 368 | unsigned int displayTime = 5000, bool withSound = true, | ||
| 369 | unsigned int messageTime = 1000) | ||
| 370 | { | ||
| 371 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->queue_notification(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, | ||
| 372 | type, header.c_str(), message.c_str(), imageFile.c_str(), displayTime, | ||
| 373 | withSound, messageTime); | ||
| 374 | } | ||
| 375 | } /* namespace kodi */ | ||
| 376 | //------------------------------------------------------------------------------ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/Network.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/Network.h new file mode 100644 index 0000000..f27b710 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/Network.h | |||
| @@ -0,0 +1,187 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team Kodi | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "AddonBase.h" | ||
| 23 | |||
| 24 | /* | ||
| 25 | * For interface between add-on and kodi. | ||
| 26 | * | ||
| 27 | * This structure defines the addresses of functions stored inside Kodi which | ||
| 28 | * are then available for the add-on to call | ||
| 29 | * | ||
| 30 | * All function pointers there are used by the C++ interface functions below. | ||
| 31 | * You find the set of them on xbmc/addons/interfaces/General.cpp | ||
| 32 | * | ||
| 33 | * Note: For add-on development itself this is not needed | ||
| 34 | */ | ||
| 35 | typedef struct AddonToKodiFuncTable_kodi_network | ||
| 36 | { | ||
| 37 | bool (*wake_on_lan)(void* kodiBase, const char *mac); | ||
| 38 | char* (*get_ip_address)(void* kodiBase); | ||
| 39 | char* (*dns_lookup)(void* kodiBase, const char* url, bool* ret); | ||
| 40 | char* (*url_encode)(void* kodiBase, const char* url); | ||
| 41 | } AddonToKodiFuncTable_kodi_network; | ||
| 42 | |||
| 43 | //============================================================================== | ||
| 44 | /// | ||
| 45 | /// \defgroup cpp_kodi_network Interface - kodi::network | ||
| 46 | /// \ingroup cpp | ||
| 47 | /// @brief **Network functions** | ||
| 48 | /// | ||
| 49 | /// The network module offers functions that allow you to control it. | ||
| 50 | /// | ||
| 51 | /// It has the header \ref Network.h "#include <kodi/Network.h>" be included | ||
| 52 | /// to enjoy it. | ||
| 53 | /// | ||
| 54 | //------------------------------------------------------------------------------ | ||
| 55 | |||
| 56 | namespace kodi | ||
| 57 | { | ||
| 58 | namespace network | ||
| 59 | { | ||
| 60 | |||
| 61 | //============================================================================ | ||
| 62 | /// | ||
| 63 | /// \ingroup cpp_kodi_network | ||
| 64 | /// @brief Send WakeOnLan magic packet. | ||
| 65 | /// | ||
| 66 | /// @param[in] mac Network address of the host to wake. | ||
| 67 | /// @return True if the magic packet was successfully sent, false otherwise. | ||
| 68 | /// | ||
| 69 | inline bool WakeOnLan(const std::string& mac) | ||
| 70 | { | ||
| 71 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_network->wake_on_lan(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, mac.c_str()); | ||
| 72 | } | ||
| 73 | //---------------------------------------------------------------------------- | ||
| 74 | |||
| 75 | //============================================================================ | ||
| 76 | /// | ||
| 77 | /// \ingroup cpp_kodi_network | ||
| 78 | /// @brief To the current own ip address as a string. | ||
| 79 | /// | ||
| 80 | /// @return Own system ip. | ||
| 81 | /// | ||
| 82 | /// | ||
| 83 | /// ------------------------------------------------------------------------ | ||
| 84 | /// | ||
| 85 | /// **Example:** | ||
| 86 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 87 | /// #include <kodi/Network.h> | ||
| 88 | /// ... | ||
| 89 | /// std::string ipAddress = kodi::network::GetIPAddress(); | ||
| 90 | /// fprintf(stderr, "My IP is '%s'\n", ipAddress.c_str()); | ||
| 91 | /// ... | ||
| 92 | /// ~~~~~~~~~~~~~ | ||
| 93 | /// | ||
| 94 | inline std::string GetIPAddress() | ||
| 95 | { | ||
| 96 | std::string ip; | ||
| 97 | char* string = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_network->get_ip_address(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase); | ||
| 98 | if (string != nullptr) | ||
| 99 | { | ||
| 100 | ip = string; | ||
| 101 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, string); | ||
| 102 | } | ||
| 103 | return ip; | ||
| 104 | } | ||
| 105 | //---------------------------------------------------------------------------- | ||
| 106 | |||
| 107 | //============================================================================ | ||
| 108 | /// | ||
| 109 | /// \ingroup cpp_kodi_network | ||
| 110 | /// @brief URL encodes the given string | ||
| 111 | /// | ||
| 112 | /// This function converts the given input string to a URL encoded string and | ||
| 113 | /// returns that as a new allocated string. All input characters that are | ||
| 114 | /// not a-z, A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL escaped" | ||
| 115 | /// version (%NN where NN is a two-digit hexadecimal number). | ||
| 116 | /// | ||
| 117 | /// @param[in] url The code of the message to get. | ||
| 118 | /// @return Encoded URL string | ||
| 119 | /// | ||
| 120 | /// | ||
| 121 | /// ------------------------------------------------------------------------ | ||
| 122 | /// | ||
| 123 | /// **Example:** | ||
| 124 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 125 | /// #include <kodi/Network.h> | ||
| 126 | /// ... | ||
| 127 | /// std::string encodedUrl = kodi::network::URLEncode("François"); | ||
| 128 | /// fprintf(stderr, "Encoded URL is '%s'\n", encodedUrl.c_str()); | ||
| 129 | /// ... | ||
| 130 | /// ~~~~~~~~~~~~~ | ||
| 131 | /// For example, the string: François ,would be encoded as: Fran%C3%A7ois | ||
| 132 | /// | ||
| 133 | inline std::string URLEncode(const std::string& url) | ||
| 134 | { | ||
| 135 | std::string retString; | ||
| 136 | char* string = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_network->url_encode(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, url.c_str()); | ||
| 137 | if (string != nullptr) | ||
| 138 | { | ||
| 139 | retString = string; | ||
| 140 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, string); | ||
| 141 | } | ||
| 142 | return retString; | ||
| 143 | } | ||
| 144 | //---------------------------------------------------------------------------- | ||
| 145 | |||
| 146 | //============================================================================ | ||
| 147 | /// | ||
| 148 | /// \ingroup cpp_kodi_network | ||
| 149 | /// @brief Lookup URL in DNS cache | ||
| 150 | /// | ||
| 151 | /// This test will get DNS record for a domain. The DNS lookup is done directly | ||
| 152 | /// against the domain's authoritative name server, so changes to DNS Records | ||
| 153 | /// should show up instantly. By default, the DNS lookup tool will return an | ||
| 154 | /// IP address if you give it a name (e.g. www.example.com) | ||
| 155 | /// | ||
| 156 | /// @param[in] hostName The code of the message to get. | ||
| 157 | /// @param[out] ipAddress Returned address | ||
| 158 | /// @return true if successfull | ||
| 159 | /// | ||
| 160 | /// | ||
| 161 | /// ------------------------------------------------------------------------ | ||
| 162 | /// | ||
| 163 | /// **Example:** | ||
| 164 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 165 | /// #include <kodi/Network.h> | ||
| 166 | /// ... | ||
| 167 | /// std::string ipAddress; | ||
| 168 | /// bool ret = kodi::network::DNSLookup("www.google.com", ipAddress); | ||
| 169 | /// fprintf(stderr, "DNSLookup returned for www.google.com the IP '%s', call was %s\n", ipAddress.c_str(), ret ? "ok" : "failed"); | ||
| 170 | /// ... | ||
| 171 | /// ~~~~~~~~~~~~~ | ||
| 172 | /// | ||
| 173 | inline bool DNSLookup(const std::string& hostName, std::string& ipAddress) | ||
| 174 | { | ||
| 175 | bool ret = false; | ||
| 176 | char* string = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_network->dns_lookup(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, hostName.c_str(), &ret); | ||
| 177 | if (string != nullptr) | ||
| 178 | { | ||
| 179 | ipAddress = string; | ||
| 180 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, string); | ||
| 181 | } | ||
| 182 | return ret; | ||
| 183 | } | ||
| 184 | //---------------------------------------------------------------------------- | ||
| 185 | |||
| 186 | } /* namespace network */ | ||
| 187 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h new file mode 100644 index 0000000..39baae7 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h | |||
| @@ -0,0 +1,141 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team Kodi | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with Kodi; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "../AddonBase.h" | ||
| 23 | |||
| 24 | namespace kodi { namespace addon { class CInstanceScreensaver; }} | ||
| 25 | |||
| 26 | extern "C" | ||
| 27 | { | ||
| 28 | |||
| 29 | struct AddonInstance_Screensaver; | ||
| 30 | |||
| 31 | typedef struct AddonProps_Screensaver | ||
| 32 | { | ||
| 33 | void *device; | ||
| 34 | int x; | ||
| 35 | int y; | ||
| 36 | int width; | ||
| 37 | int height; | ||
| 38 | float pixelRatio; | ||
| 39 | const char *name; | ||
| 40 | const char *presets; | ||
| 41 | const char *profile; | ||
| 42 | } AddonProps_Screensaver; | ||
| 43 | |||
| 44 | typedef struct AddonToKodiFuncTable_Screensaver | ||
| 45 | { | ||
| 46 | KODI_HANDLE kodiInstance; | ||
| 47 | } AddonToKodiFuncTable_Screensaver; | ||
| 48 | |||
| 49 | typedef struct KodiToAddonFuncTable_Screensaver | ||
| 50 | { | ||
| 51 | kodi::addon::CInstanceScreensaver* addonInstance; | ||
| 52 | bool (__cdecl* Start) (AddonInstance_Screensaver* instance); | ||
| 53 | void (__cdecl* Stop) (AddonInstance_Screensaver* instance); | ||
| 54 | void (__cdecl* Render) (AddonInstance_Screensaver* instance); | ||
| 55 | } KodiToAddonFuncTable_Screensaver; | ||
| 56 | |||
| 57 | typedef struct AddonInstance_Screensaver | ||
| 58 | { | ||
| 59 | AddonProps_Screensaver props; | ||
| 60 | AddonToKodiFuncTable_Screensaver toKodi; | ||
| 61 | KodiToAddonFuncTable_Screensaver toAddon; | ||
| 62 | } AddonInstance_Screensaver; | ||
| 63 | |||
| 64 | } /* extern "C" */ | ||
| 65 | |||
| 66 | namespace kodi | ||
| 67 | { | ||
| 68 | namespace addon | ||
| 69 | { | ||
| 70 | |||
| 71 | class CInstanceScreensaver : public IAddonInstance | ||
| 72 | { | ||
| 73 | public: | ||
| 74 | CInstanceScreensaver() | ||
| 75 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER) | ||
| 76 | { | ||
| 77 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 78 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of more as one in single instance way is not allowed!"); | ||
| 79 | |||
| 80 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); | ||
| 81 | CAddonBase::m_interface->globalSingleInstance = this; | ||
| 82 | } | ||
| 83 | |||
| 84 | CInstanceScreensaver(KODI_HANDLE instance) | ||
| 85 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER) | ||
| 86 | { | ||
| 87 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 88 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of multiple together with single instance way is not allowed!"); | ||
| 89 | |||
| 90 | SetAddonStruct(instance); | ||
| 91 | } | ||
| 92 | |||
| 93 | virtual ~CInstanceScreensaver() { } | ||
| 94 | |||
| 95 | virtual bool Start() { return true; } | ||
| 96 | virtual void Stop() {} | ||
| 97 | virtual void Render() {} | ||
| 98 | |||
| 99 | inline void* Device() { return m_instanceData->props.device; } | ||
| 100 | inline int X() { return m_instanceData->props.x; } | ||
| 101 | inline int Y() { return m_instanceData->props.y; } | ||
| 102 | inline int Width() { return m_instanceData->props.width; } | ||
| 103 | inline int Height() { return m_instanceData->props.height; } | ||
| 104 | inline float PixelRatio() { return m_instanceData->props.pixelRatio; } | ||
| 105 | inline std::string Name() { return m_instanceData->props.name; } | ||
| 106 | inline std::string Presets() { return m_instanceData->props.presets; } | ||
| 107 | inline std::string Profile() { return m_instanceData->props.profile; } | ||
| 108 | |||
| 109 | private: | ||
| 110 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 111 | { | ||
| 112 | if (instance == nullptr) | ||
| 113 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation with empty addon structure not allowed, table must be given from Kodi!"); | ||
| 114 | |||
| 115 | m_instanceData = static_cast<AddonInstance_Screensaver*>(instance); | ||
| 116 | m_instanceData->toAddon.addonInstance = this; | ||
| 117 | m_instanceData->toAddon.Start = ADDON_Start; | ||
| 118 | m_instanceData->toAddon.Stop = ADDON_Stop; | ||
| 119 | m_instanceData->toAddon.Render = ADDON_Render; | ||
| 120 | } | ||
| 121 | |||
| 122 | inline static bool ADDON_Start(AddonInstance_Screensaver* instance) | ||
| 123 | { | ||
| 124 | return instance->toAddon.addonInstance->Start(); | ||
| 125 | } | ||
| 126 | |||
| 127 | inline static void ADDON_Stop(AddonInstance_Screensaver* instance) | ||
| 128 | { | ||
| 129 | instance->toAddon.addonInstance->Stop(); | ||
| 130 | } | ||
| 131 | |||
| 132 | inline static void ADDON_Render(AddonInstance_Screensaver* instance) | ||
| 133 | { | ||
| 134 | instance->toAddon.addonInstance->Render(); | ||
| 135 | } | ||
| 136 | |||
| 137 | AddonInstance_Screensaver* m_instanceData; | ||
| 138 | }; | ||
| 139 | |||
| 140 | } /* namespace addon */ | ||
| 141 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogContextMenu.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogContextMenu.h new file mode 100644 index 0000000..66a1c90 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogContextMenu.h | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "definitions.h" | ||
| 23 | #include "../AddonBase.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | /// \defgroup cpp_kodi_gui_DialogContextMenu Dialog Context Menu | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @brief \cpp_namespace{ kodi::gui::DialogContextMenu } | ||
| 35 | /// **Context menu dialog** | ||
| 36 | /// | ||
| 37 | /// The function listed below permits the call of a dialogue as context menu to | ||
| 38 | /// select of an entry as a key | ||
| 39 | /// | ||
| 40 | /// It has the header \ref DialogContextMenu.h "#include <kodi/gui/DialogContextMenu.h>" | ||
| 41 | /// be included to enjoy it. | ||
| 42 | /// | ||
| 43 | /// | ||
| 44 | namespace DialogContextMenu | ||
| 45 | { | ||
| 46 | //========================================================================== | ||
| 47 | /// | ||
| 48 | /// \ingroup cpp_kodi_gui_DialogContextMenu | ||
| 49 | /// @brief Show a context menu dialog about given parts. | ||
| 50 | /// | ||
| 51 | /// @param[in] heading Dialog heading name | ||
| 52 | /// @param[in] entries String list about entries | ||
| 53 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 54 | /// | ||
| 55 | /// | ||
| 56 | ///------------------------------------------------------------------------- | ||
| 57 | /// | ||
| 58 | /// **Example:** | ||
| 59 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 60 | /// #include <kodi/gui/DialogContextMenu.h> | ||
| 61 | /// | ||
| 62 | /// const std::vector<std::string> entries | ||
| 63 | /// { | ||
| 64 | /// "Test 1", | ||
| 65 | /// "Test 2", | ||
| 66 | /// "Test 3", | ||
| 67 | /// "Test 4", | ||
| 68 | /// "Test 5" | ||
| 69 | /// }; | ||
| 70 | /// | ||
| 71 | /// int selected = kodi::gui::DialogContextMenu::Show("Test selection", entries); | ||
| 72 | /// if (selected < 0) | ||
| 73 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 74 | /// else | ||
| 75 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 76 | /// ~~~~~~~~~~~~~ | ||
| 77 | /// | ||
| 78 | inline int Show(const std::string& heading, const std::vector<std::string>& entries) | ||
| 79 | { | ||
| 80 | using namespace ::kodi::addon; | ||
| 81 | unsigned int size = entries.size(); | ||
| 82 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); | ||
| 83 | for (unsigned int i = 0; i < size; ++i) | ||
| 84 | { | ||
| 85 | cEntries[i] = entries[i].c_str(); | ||
| 86 | } | ||
| 87 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 88 | free(cEntries); | ||
| 89 | return ret; | ||
| 90 | } | ||
| 91 | //-------------------------------------------------------------------------- | ||
| 92 | }; | ||
| 93 | |||
| 94 | } /* namespace gui */ | ||
| 95 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogExtendedProgress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogExtendedProgress.h new file mode 100644 index 0000000..b6f2deb --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogExtendedProgress.h | |||
| @@ -0,0 +1,244 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "definitions.h" | ||
| 23 | #include "../AddonBase.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | /// \defgroup cpp_kodi_gui_CDialogExtendedProgress Dialog Extended Progress | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @brief \cpp_class{ kodi::gui::CDialogExtendedProgress } | ||
| 35 | /// **Progress dialog shown for background work** | ||
| 36 | /// | ||
| 37 | /// The with \ref DialogExtendedProgress.h "#include <kodi/gui/DialogExtendedProgress.h>" | ||
| 38 | /// given class are basically used to create Kodi's extended progress. | ||
| 39 | /// | ||
| 40 | /// | ||
| 41 | /// -------------------------------------------------------------------------- | ||
| 42 | /// | ||
| 43 | /// **Example:** | ||
| 44 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 45 | /// #include <kodi/gui/DialogExtendedProgress.h> | ||
| 46 | /// | ||
| 47 | /// kodi::gui::CDialogExtendedProgress *ext_progress = new kodi::gui::CDialogExtendedProgress("Test Extended progress"); | ||
| 48 | /// ext_progress->SetText("Test progress"); | ||
| 49 | /// for (unsigned int i = 0; i < 50; i += 10) | ||
| 50 | /// { | ||
| 51 | /// ext_progress->SetProgress(i, 100); | ||
| 52 | /// sleep(1); | ||
| 53 | /// } | ||
| 54 | /// | ||
| 55 | /// ext_progress->SetTitle("Test Extended progress - Second round"); | ||
| 56 | /// ext_progress->SetText("Test progress - Step 2"); | ||
| 57 | /// | ||
| 58 | /// for (unsigned int i = 50; i < 100; i += 10) | ||
| 59 | /// { | ||
| 60 | /// ext_progress->SetProgress(i, 100); | ||
| 61 | /// sleep(1); | ||
| 62 | /// } | ||
| 63 | /// delete ext_progress; | ||
| 64 | /// ~~~~~~~~~~~~~ | ||
| 65 | /// | ||
| 66 | class CDialogExtendedProgress | ||
| 67 | { | ||
| 68 | public: | ||
| 69 | //========================================================================== | ||
| 70 | /// | ||
| 71 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 72 | /// Construct a new dialog | ||
| 73 | /// | ||
| 74 | /// @param[in] title Title string | ||
| 75 | /// | ||
| 76 | CDialogExtendedProgress(const std::string& title = "") | ||
| 77 | { | ||
| 78 | using namespace ::kodi::addon; | ||
| 79 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase, title.c_str()); | ||
| 80 | if (!m_DialogHandle) | ||
| 81 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!"); | ||
| 82 | } | ||
| 83 | //-------------------------------------------------------------------------- | ||
| 84 | |||
| 85 | //========================================================================== | ||
| 86 | /// | ||
| 87 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 88 | /// Destructor | ||
| 89 | /// | ||
| 90 | ~CDialogExtendedProgress() | ||
| 91 | { | ||
| 92 | using namespace ::kodi::addon; | ||
| 93 | if (m_DialogHandle) | ||
| 94 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 95 | } | ||
| 96 | //-------------------------------------------------------------------------- | ||
| 97 | |||
| 98 | //========================================================================== | ||
| 99 | /// | ||
| 100 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 101 | /// @brief Get the used title | ||
| 102 | /// | ||
| 103 | /// @return Title string | ||
| 104 | /// | ||
| 105 | std::string Title() const | ||
| 106 | { | ||
| 107 | using namespace ::kodi::addon; | ||
| 108 | std::string text; | ||
| 109 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 110 | if (strMsg != nullptr) | ||
| 111 | { | ||
| 112 | if (std::strlen(strMsg)) | ||
| 113 | text = strMsg; | ||
| 114 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); | ||
| 115 | } | ||
| 116 | return text; | ||
| 117 | } | ||
| 118 | //-------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //========================================================================== | ||
| 121 | /// | ||
| 122 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 123 | /// @brief To set the title of dialog | ||
| 124 | /// | ||
| 125 | /// @param[in] title Title string | ||
| 126 | /// | ||
| 127 | void SetTitle(const std::string& title) | ||
| 128 | { | ||
| 129 | using namespace ::kodi::addon; | ||
| 130 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str()); | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 137 | /// @brief Get the used text information string | ||
| 138 | /// | ||
| 139 | /// @return Text string | ||
| 140 | /// | ||
| 141 | std::string Text() const | ||
| 142 | { | ||
| 143 | using namespace ::kodi::addon; | ||
| 144 | std::string text; | ||
| 145 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 146 | if (strMsg != nullptr) | ||
| 147 | { | ||
| 148 | if (std::strlen(strMsg)) | ||
| 149 | text = strMsg; | ||
| 150 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); | ||
| 151 | } | ||
| 152 | return text; | ||
| 153 | } | ||
| 154 | //-------------------------------------------------------------------------- | ||
| 155 | |||
| 156 | //========================================================================== | ||
| 157 | /// | ||
| 158 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 159 | /// @brief To set the used text information string | ||
| 160 | /// | ||
| 161 | /// @param[in] text information text to set | ||
| 162 | /// | ||
| 163 | void SetText(const std::string& text) | ||
| 164 | { | ||
| 165 | using namespace ::kodi::addon; | ||
| 166 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str()); | ||
| 167 | } | ||
| 168 | //-------------------------------------------------------------------------- | ||
| 169 | |||
| 170 | //========================================================================== | ||
| 171 | /// | ||
| 172 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 173 | /// @brief To ask dialog is finished | ||
| 174 | /// | ||
| 175 | /// @return True if on end | ||
| 176 | /// | ||
| 177 | bool IsFinished() const | ||
| 178 | { | ||
| 179 | using namespace ::kodi::addon; | ||
| 180 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 181 | } | ||
| 182 | //-------------------------------------------------------------------------- | ||
| 183 | |||
| 184 | //========================================================================== | ||
| 185 | /// | ||
| 186 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 187 | /// @brief Mark progress finished | ||
| 188 | /// | ||
| 189 | void MarkFinished() | ||
| 190 | { | ||
| 191 | using namespace ::kodi::addon; | ||
| 192 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 193 | } | ||
| 194 | //-------------------------------------------------------------------------- | ||
| 195 | |||
| 196 | //========================================================================== | ||
| 197 | /// | ||
| 198 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 199 | /// @brief Get the current progress position as percent | ||
| 200 | /// | ||
| 201 | /// @return Position | ||
| 202 | /// | ||
| 203 | float Percentage() const | ||
| 204 | { | ||
| 205 | using namespace ::kodi::addon; | ||
| 206 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 207 | } | ||
| 208 | //-------------------------------------------------------------------------- | ||
| 209 | |||
| 210 | //========================================================================== | ||
| 211 | /// | ||
| 212 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 213 | /// @brief To set the current progress position as percent | ||
| 214 | /// | ||
| 215 | /// @param[in] percentage Position to use from 0.0 to 100.0 | ||
| 216 | /// | ||
| 217 | void SetPercentage(float percentage) | ||
| 218 | { | ||
| 219 | using namespace ::kodi::addon; | ||
| 220 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | ||
| 221 | } | ||
| 222 | //-------------------------------------------------------------------------- | ||
| 223 | |||
| 224 | //========================================================================== | ||
| 225 | /// | ||
| 226 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 227 | /// @brief To set progress position with predefined places | ||
| 228 | /// | ||
| 229 | /// @param[in] currentItem Place position to use | ||
| 230 | /// @param[in] itemCount Amount of used places | ||
| 231 | /// | ||
| 232 | void SetProgress(int currentItem, int itemCount) | ||
| 233 | { | ||
| 234 | using namespace ::kodi::addon; | ||
| 235 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount); | ||
| 236 | } | ||
| 237 | //-------------------------------------------------------------------------- | ||
| 238 | |||
| 239 | private: | ||
| 240 | void* m_DialogHandle; | ||
| 241 | }; | ||
| 242 | |||
| 243 | } /* namespace gui */ | ||
| 244 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogFileBrowser.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogFileBrowser.h new file mode 100644 index 0000000..e348125 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogFileBrowser.h | |||
| @@ -0,0 +1,293 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "definitions.h" | ||
| 23 | #include "../AddonBase.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | /// \defgroup cpp_kodi_gui_DialogFileBrowser Dialog File Browser | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @brief \cpp_namespace{ kodi::gui::DialogFileBrowser } | ||
| 35 | /// **File browser dialog** | ||
| 36 | /// | ||
| 37 | /// The functions listed below of the class "DialogFileBrowser" offer | ||
| 38 | /// the possibility to select to a file by the user of the add-on. | ||
| 39 | /// | ||
| 40 | /// It allows all the options that are possible in Kodi itself and offers all | ||
| 41 | /// support file types. | ||
| 42 | /// | ||
| 43 | /// It has the header \ref DialogFileBrowser.h "#include <kodi/gui/DialogFileBrowser.h>" | ||
| 44 | /// be included to enjoy it. | ||
| 45 | /// | ||
| 46 | namespace DialogFileBrowser | ||
| 47 | { | ||
| 48 | //========================================================================== | ||
| 49 | /// | ||
| 50 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 51 | /// @brief Directory selection dialog | ||
| 52 | /// | ||
| 53 | /// @param[in] shares With Shares becomes the available start folders | ||
| 54 | /// be set. | ||
| 55 | /// @param[in] heading Dialog header name | ||
| 56 | /// @param[in,out] path As in the path to start and return value about | ||
| 57 | /// selected directory | ||
| 58 | /// @param[in] writeOnly If set only writeable folders are shown. | ||
| 59 | /// @return False if selection becomes canceled. | ||
| 60 | /// | ||
| 61 | /// **Example:** | ||
| 62 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 63 | /// #include <kodi/gui/DialogFileBrowser.h> | ||
| 64 | /// | ||
| 65 | /// /* | ||
| 66 | /// * Example show directory selection dialog with on 'share' (first value) | ||
| 67 | /// * defined directory types. | ||
| 68 | /// * | ||
| 69 | /// * If this becomes leaved empty and 'directory' is empty goes it to the | ||
| 70 | /// * base path of the hard disk. | ||
| 71 | /// * | ||
| 72 | /// * Also can be with path written to 'directory' before the dialog forced | ||
| 73 | /// * to a start place. | ||
| 74 | /// */ | ||
| 75 | /// std::string directory; | ||
| 76 | /// bool ret = kodi::gui::DialogFileBrowser::ShowAndGetDirectory("local|network|removable", | ||
| 77 | /// "Test directory selection", | ||
| 78 | /// directory, | ||
| 79 | /// false); | ||
| 80 | /// fprintf(stderr, "Selected directory is : %s and was %s\n", directory.c_str(), ret ? "OK" : "Canceled"); | ||
| 81 | /// ~~~~~~~~~~~~~ | ||
| 82 | /// | ||
| 83 | inline bool ShowAndGetDirectory(const std::string& shares, const std::string& heading, std::string& path, bool writeOnly = false) | ||
| 84 | { | ||
| 85 | using namespace ::kodi::addon; | ||
| 86 | char* retString = nullptr; | ||
| 87 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 88 | shares.c_str(), heading.c_str(), path.c_str(), &retString, writeOnly); | ||
| 89 | if (retString != nullptr) | ||
| 90 | { | ||
| 91 | if (std::strlen(retString)) | ||
| 92 | path = retString; | ||
| 93 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 94 | } | ||
| 95 | return ret; | ||
| 96 | } | ||
| 97 | //-------------------------------------------------------------------------- | ||
| 98 | |||
| 99 | //========================================================================== | ||
| 100 | /// | ||
| 101 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 102 | /// @brief File selection dialog | ||
| 103 | /// | ||
| 104 | /// @param[in] shares With Shares becomes the available start | ||
| 105 | /// folders be set. | ||
| 106 | /// @param[in] mask The mask to filter visible files, e.g. | ||
| 107 | /// ".m3u|.pls|.b4s|.wpl". | ||
| 108 | /// @param[in] heading Dialog header name | ||
| 109 | /// @param[in,out] path As in the path to start and Return value | ||
| 110 | /// about selected file | ||
| 111 | /// @param[in] useThumbs If set show thumbs if possible on dialog. | ||
| 112 | /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are | ||
| 113 | /// handled as directories. | ||
| 114 | /// @return False if selection becomes canceled. | ||
| 115 | /// | ||
| 116 | inline bool ShowAndGetFile(const std::string& shares, const std::string& mask, const std::string& heading, | ||
| 117 | std::string& path, bool useThumbs = false, bool useFileDirectories = false) | ||
| 118 | { | ||
| 119 | using namespace ::kodi::addon; | ||
| 120 | char* retString = nullptr; | ||
| 121 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 122 | shares.c_str(), mask.c_str(), heading.c_str(), path.c_str(), &retString, | ||
| 123 | useThumbs, useFileDirectories); | ||
| 124 | if (retString != nullptr) | ||
| 125 | { | ||
| 126 | if (std::strlen(retString)) | ||
| 127 | path = retString; | ||
| 128 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 129 | } | ||
| 130 | return ret; | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 137 | /// @brief File selection from a directory | ||
| 138 | /// | ||
| 139 | /// @param[in] directory The directory name where the dialog | ||
| 140 | /// start, possible are normal names and | ||
| 141 | /// kodi's special names. | ||
| 142 | /// @param[in] mask The mask to filter visible files, e.g. | ||
| 143 | /// ".m3u|.pls|.b4s|.wpl". | ||
| 144 | /// @param[in] heading Dialog header name | ||
| 145 | /// @param[in,out] path As in the path to start and Return value | ||
| 146 | /// about selected file | ||
| 147 | /// @param[in] useThumbs If set show thumbs if possible on dialog. | ||
| 148 | /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are | ||
| 149 | /// handled as directories. | ||
| 150 | /// @param[in] singleList | ||
| 151 | /// @return False if selection becomes canceled. | ||
| 152 | /// | ||
| 153 | inline bool ShowAndGetFileFromDir(const std::string& directory, const std::string& mask, const std::string& heading, std::string& path, | ||
| 154 | bool useThumbs = false, bool useFileDirectories = false, bool singleList = false) | ||
| 155 | { | ||
| 156 | using namespace ::kodi::addon; | ||
| 157 | char* retString = nullptr; | ||
| 158 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_from_dir(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 159 | directory.c_str(), mask.c_str(), heading.c_str(), | ||
| 160 | path.c_str(), &retString, useThumbs, | ||
| 161 | useFileDirectories, singleList); | ||
| 162 | if (retString != nullptr) | ||
| 163 | { | ||
| 164 | if (std::strlen(retString)) | ||
| 165 | path = retString; | ||
| 166 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 167 | } | ||
| 168 | return ret; | ||
| 169 | } | ||
| 170 | //-------------------------------------------------------------------------- | ||
| 171 | |||
| 172 | //========================================================================== | ||
| 173 | /// | ||
| 174 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 175 | /// @brief File selection dialog to get several in to a list | ||
| 176 | /// | ||
| 177 | /// @param[in] shares With Shares becomes the available start | ||
| 178 | /// folders be set. | ||
| 179 | /// @param[in] mask The mask to filter visible files, e.g. | ||
| 180 | /// ".m3u|.pls|.b4s|.wpl". | ||
| 181 | /// @param[in] heading Dialog header name | ||
| 182 | /// @param[out] fileList Return value about selected files | ||
| 183 | /// @param[in] useThumbs If set show thumbs if possible on dialog. | ||
| 184 | /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are | ||
| 185 | /// handled as directories. | ||
| 186 | /// @return False if selection becomes canceled. | ||
| 187 | /// | ||
| 188 | inline bool ShowAndGetFileList(const std::string& shares, const std::string& mask, const std::string& heading, | ||
| 189 | std::vector<std::string>& fileList, bool useThumbs = false, bool useFileDirectories = false) | ||
| 190 | { | ||
| 191 | using namespace ::kodi::addon; | ||
| 192 | char** list = nullptr; | ||
| 193 | unsigned int listSize = 0; | ||
| 194 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_list(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 195 | shares.c_str(), mask.c_str(), heading.c_str(), &list, &listSize, | ||
| 196 | useThumbs, useFileDirectories); | ||
| 197 | if (ret) | ||
| 198 | { | ||
| 199 | for (unsigned int i = 0; i < listSize; ++i) | ||
| 200 | fileList.push_back(list[i]); | ||
| 201 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | ||
| 202 | } | ||
| 203 | return ret; | ||
| 204 | } | ||
| 205 | //-------------------------------------------------------------------------- | ||
| 206 | |||
| 207 | //========================================================================== | ||
| 208 | /// | ||
| 209 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 210 | /// @brief Source selection dialog | ||
| 211 | /// | ||
| 212 | /// @param[in,out] path As in the path to start and Return value | ||
| 213 | /// about selected source | ||
| 214 | /// @param[in] allowNetworkShares Allow also access to network | ||
| 215 | /// @param[in] additionalShare With additionalShare becomes the available | ||
| 216 | /// start folders be set (optional). | ||
| 217 | /// @param[in] type | ||
| 218 | /// @return False if selection becomes canceled. | ||
| 219 | /// | ||
| 220 | inline bool ShowAndGetSource(std::string& path, bool allowNetworkShares, const std::string& additionalShare = "", const std::string& type = "") | ||
| 221 | { | ||
| 222 | using namespace ::kodi::addon; | ||
| 223 | char* retString = nullptr; | ||
| 224 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_source(CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &retString, | ||
| 225 | allowNetworkShares, additionalShare.c_str(), type.c_str()); | ||
| 226 | if (retString != nullptr) | ||
| 227 | { | ||
| 228 | if (std::strlen(retString)) | ||
| 229 | path = retString; | ||
| 230 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 231 | } | ||
| 232 | return ret; | ||
| 233 | } | ||
| 234 | //-------------------------------------------------------------------------- | ||
| 235 | |||
| 236 | //========================================================================== | ||
| 237 | /// | ||
| 238 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 239 | /// @brief Image selection dialog | ||
| 240 | /// | ||
| 241 | /// @param[in] shares With Shares becomes the available start folders be | ||
| 242 | /// set. | ||
| 243 | /// @param[in] heading Dialog header name | ||
| 244 | /// @param[out] path Return value about selected image | ||
| 245 | /// @return False if selection becomes canceled. | ||
| 246 | /// | ||
| 247 | inline bool ShowAndGetImage(const std::string& shares, const std::string& heading, std::string& path) | ||
| 248 | { | ||
| 249 | using namespace ::kodi::addon; | ||
| 250 | char* retString = nullptr; | ||
| 251 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 252 | shares.c_str(), heading.c_str(), path.c_str(), &retString); | ||
| 253 | if (retString != nullptr) | ||
| 254 | { | ||
| 255 | if (std::strlen(retString)) | ||
| 256 | path = retString; | ||
| 257 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 258 | } | ||
| 259 | return ret; | ||
| 260 | } | ||
| 261 | //-------------------------------------------------------------------------- | ||
| 262 | |||
| 263 | //========================================================================== | ||
| 264 | /// | ||
| 265 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 266 | /// @brief Image selection dialog to get several in to a list | ||
| 267 | /// | ||
| 268 | /// @param[in] shares With Shares becomes the available start folders | ||
| 269 | /// be set. | ||
| 270 | /// @param[in] heading Dialog header name | ||
| 271 | /// @param[out] file_list Return value about selected images | ||
| 272 | /// @return False if selection becomes canceled. | ||
| 273 | /// | ||
| 274 | inline bool ShowAndGetImageList(const std::string& shares, const std::string& heading, std::vector<std::string>& file_list) | ||
| 275 | { | ||
| 276 | using namespace ::kodi::addon; | ||
| 277 | char** list = nullptr; | ||
| 278 | unsigned int listSize = 0; | ||
| 279 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image_list(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 280 | shares.c_str(), heading.c_str(), &list, &listSize); | ||
| 281 | if (ret) | ||
| 282 | { | ||
| 283 | for (unsigned int i = 0; i < listSize; ++i) | ||
| 284 | file_list.push_back(list[i]); | ||
| 285 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | ||
| 286 | } | ||
| 287 | return ret; | ||
| 288 | } | ||
| 289 | //-------------------------------------------------------------------------- | ||
| 290 | }; | ||
| 291 | |||
| 292 | } /* namespace gui */ | ||
| 293 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogKeyboard.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogKeyboard.h new file mode 100644 index 0000000..9261972 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogKeyboard.h | |||
| @@ -0,0 +1,416 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "definitions.h" | ||
| 23 | #include "../AddonBase.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | /// \defgroup cpp_kodi_gui_DialogKeyboard Dialog Keyboard | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @brief \cpp_namespace{ kodi::gui::DialogKeyboard } | ||
| 35 | /// **Keyboard dialogs** | ||
| 36 | /// | ||
| 37 | /// The functions listed below have to be permitted by the user for the | ||
| 38 | /// representation of a keyboard around an input. | ||
| 39 | /// | ||
| 40 | /// The class supports several kinds, from an easy text choice up to the | ||
| 41 | /// passport Word production and their confirmation for add-on. | ||
| 42 | /// | ||
| 43 | /// It has the header \ref DialogKeyboard.h "#include <kodi/gui/DialogKeyboard.h>" | ||
| 44 | /// be included to enjoy it. | ||
| 45 | /// | ||
| 46 | namespace DialogKeyboard | ||
| 47 | { | ||
| 48 | //========================================================================== | ||
| 49 | /// | ||
| 50 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 51 | /// @brief Show keyboard with initial value `text` and replace with result | ||
| 52 | /// string. | ||
| 53 | /// | ||
| 54 | /// @param[in,out] text Overwritten with user input if return=true. | ||
| 55 | /// @param[in] heading String shown on dialog title. | ||
| 56 | /// @param[in] allowEmptyResult Whether a blank password is valid or not. | ||
| 57 | /// @param[in] hiddenInput The inserted input is not shown as text. | ||
| 58 | /// @param[in] autoCloseMs To close the dialog after a specified | ||
| 59 | /// time, in milliseconds, default is 0 which | ||
| 60 | /// keeps the dialog open indefinitely. | ||
| 61 | /// @return true if successful display and user input. | ||
| 62 | /// false if unsuccessful display, no user | ||
| 63 | /// input, or canceled editing. | ||
| 64 | /// | ||
| 65 | /// | ||
| 66 | ///------------------------------------------------------------------------- | ||
| 67 | /// | ||
| 68 | /// **Example:** | ||
| 69 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 70 | /// #include <kodi/gui/DialogKeyboard.h> | ||
| 71 | /// | ||
| 72 | /// /* | ||
| 73 | /// * The example shows the display of keyboard call dialog at Kodi from the add-on. | ||
| 74 | /// * Below all values are set, however, can last two (hidden input = false and autoCloseMs = 0) | ||
| 75 | /// * to be released if not needed. | ||
| 76 | /// */ | ||
| 77 | /// std::string text = "Please change me to them want you want"; /*< It can be leaved empty or a | ||
| 78 | /// entry text added */ | ||
| 79 | /// bool bRet = ::kodi::gui::DialogKeyboard::ShowAndGetInput(text, | ||
| 80 | /// "Demonstration text entry", | ||
| 81 | /// true, | ||
| 82 | /// false, | ||
| 83 | /// 0); | ||
| 84 | /// fprintf(stderr, "Written keyboard input is : '%s' and was %s\n", | ||
| 85 | /// text.c_str(), bRet ? "OK" : "Canceled"); | ||
| 86 | /// ~~~~~~~~~~~~~ | ||
| 87 | /// | ||
| 88 | inline bool ShowAndGetInput(std::string& text, const std::string& heading, bool allowEmptyResult, bool hiddenInput = false, unsigned int autoCloseMs = 0) | ||
| 89 | { | ||
| 90 | using namespace ::kodi::addon; | ||
| 91 | char* retString = nullptr; | ||
| 92 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 93 | text.c_str(), &retString, heading.c_str(), allowEmptyResult, | ||
| 94 | hiddenInput, autoCloseMs); | ||
| 95 | if (retString != nullptr) | ||
| 96 | { | ||
| 97 | if (std::strlen(retString)) | ||
| 98 | text = retString; | ||
| 99 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 100 | } | ||
| 101 | return ret; | ||
| 102 | } | ||
| 103 | //-------------------------------------------------------------------------- | ||
| 104 | |||
| 105 | //========================================================================== | ||
| 106 | /// | ||
| 107 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 108 | /// @brief The example shows the display of keyboard call dialog at Kodi | ||
| 109 | /// from the add-on. | ||
| 110 | /// | ||
| 111 | /// @param[out] text Overwritten with user input if return=true. | ||
| 112 | /// @param[in] allowEmptyResult If set to true keyboard can also exited | ||
| 113 | /// without entered text. | ||
| 114 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 115 | /// in milliseconds, default is 0 which keeps | ||
| 116 | /// the dialog open indefinitely. | ||
| 117 | /// @return true if successful display and user input. | ||
| 118 | /// false if unsuccessful display, no user | ||
| 119 | /// input, or canceled editing. | ||
| 120 | /// | ||
| 121 | inline bool ShowAndGetInput(std::string& text, bool allowEmptyResult, unsigned int autoCloseMs = 0) | ||
| 122 | { | ||
| 123 | using namespace ::kodi::addon; | ||
| 124 | char* retString = nullptr; | ||
| 125 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 126 | text.c_str(), &retString, | ||
| 127 | allowEmptyResult, autoCloseMs); | ||
| 128 | if (retString != nullptr) | ||
| 129 | { | ||
| 130 | if (std::strlen(retString)) | ||
| 131 | text = retString; | ||
| 132 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 133 | } | ||
| 134 | return ret; | ||
| 135 | } | ||
| 136 | //-------------------------------------------------------------------------- | ||
| 137 | |||
| 138 | //========================================================================== | ||
| 139 | /// | ||
| 140 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 141 | /// @brief Shows keyboard and prompts for a password. Differs from | ||
| 142 | /// `ShowAndVerifyNewPassword()` in that no second verification | ||
| 143 | /// | ||
| 144 | /// @param[in,out] newPassword Overwritten with user input if return=true. | ||
| 145 | /// @param[in] heading String shown on dialog title. | ||
| 146 | /// @param[in] allowEmptyResult Whether a blank password is valid or not. | ||
| 147 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 148 | /// in milliseconds, default is 0 which keeps | ||
| 149 | /// the dialog open indefinitely. | ||
| 150 | /// @return true if successful display and user input. | ||
| 151 | /// false if unsuccessful display, no user | ||
| 152 | /// input, or canceled editing. | ||
| 153 | /// | ||
| 154 | inline bool ShowAndGetNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0) | ||
| 155 | { | ||
| 156 | using namespace ::kodi::addon; | ||
| 157 | char* retString = nullptr; | ||
| 158 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 159 | newPassword.c_str(), &retString, heading.c_str(), | ||
| 160 | allowEmptyResult, autoCloseMs); | ||
| 161 | if (retString != nullptr) | ||
| 162 | { | ||
| 163 | if (std::strlen(retString)) | ||
| 164 | newPassword = retString; | ||
| 165 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 166 | } | ||
| 167 | return ret; | ||
| 168 | } | ||
| 169 | //-------------------------------------------------------------------------- | ||
| 170 | |||
| 171 | //========================================================================== | ||
| 172 | /// | ||
| 173 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 174 | /// @brief Shows keyboard and prompts for a password. Differs from | ||
| 175 | /// `ShowAndVerifyNewPassword()` in that no second verification | ||
| 176 | /// | ||
| 177 | /// @param[in,out] newPassword Overwritten with user input if return=true. | ||
| 178 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 179 | /// in milliseconds, default is 0 which keeps | ||
| 180 | /// the dialog open indefinitely. | ||
| 181 | /// @return true if successful display and user input. | ||
| 182 | /// false if unsuccessful display, no user | ||
| 183 | /// input, or canceled editing. | ||
| 184 | /// | ||
| 185 | inline bool ShowAndGetNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) | ||
| 186 | { | ||
| 187 | using namespace ::kodi::addon; | ||
| 188 | char* retString = nullptr; | ||
| 189 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 190 | newPassword.c_str(), &retString, autoCloseMs); | ||
| 191 | if (retString != nullptr) | ||
| 192 | { | ||
| 193 | if (std::strlen(retString)) | ||
| 194 | newPassword = retString; | ||
| 195 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 196 | } | ||
| 197 | return ret; | ||
| 198 | } | ||
| 199 | //-------------------------------------------------------------------------- | ||
| 200 | |||
| 201 | //========================================================================== | ||
| 202 | /// | ||
| 203 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 204 | /// @brief Show keyboard twice to get and confirm a user-entered password | ||
| 205 | /// string. | ||
| 206 | /// | ||
| 207 | /// @param[out] newPassword Overwritten with user input if return=true. | ||
| 208 | /// @param[in] heading String shown on dialog title. | ||
| 209 | /// @param[in] allowEmptyResult | ||
| 210 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 211 | /// in milliseconds, default is 0 which keeps | ||
| 212 | /// the dialog open indefinitely. | ||
| 213 | /// @return true if successful display and user input. | ||
| 214 | /// false if unsuccessful display, no user | ||
| 215 | /// input, or canceled editing. | ||
| 216 | /// | ||
| 217 | /// | ||
| 218 | ///------------------------------------------------------------------------- | ||
| 219 | /// | ||
| 220 | /// **Example:** | ||
| 221 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 222 | /// #include <kodi/General.h> | ||
| 223 | /// #include <kodi/gui/DialogKeyboard.h> | ||
| 224 | /// | ||
| 225 | /// /* | ||
| 226 | /// * The example below shows the complete use of keyboard dialog for password | ||
| 227 | /// * check. If only one check from add-on needed can be function with retries | ||
| 228 | /// * set to '0' called alone. | ||
| 229 | /// * | ||
| 230 | /// * The use of MD5 translated password is always required for the check on Kodi! | ||
| 231 | /// */ | ||
| 232 | /// | ||
| 233 | /// int maxretries = 3; | ||
| 234 | /// /* | ||
| 235 | /// * Password names need to be send as md5 sum to kodi. | ||
| 236 | /// */ | ||
| 237 | /// std::string password; | ||
| 238 | /// kodi::GetMD5("kodi", password); | ||
| 239 | /// | ||
| 240 | /// /* | ||
| 241 | /// * To the loop about password checks. | ||
| 242 | /// */ | ||
| 243 | /// int ret; | ||
| 244 | /// for (unsigned int i = 0; i < maxretries; i++) | ||
| 245 | /// { | ||
| 246 | /// /* | ||
| 247 | /// * Ask the user about the password. | ||
| 248 | /// */ | ||
| 249 | /// ret = ::kodi::gui::DialogKeyboard::ShowAndVerifyPassword(password, "Demo password call for PW 'kodi'", i, 0); | ||
| 250 | /// if (ret == 0) | ||
| 251 | /// { | ||
| 252 | /// fprintf(stderr, "Password successfull confirmed after '%i' tries\n", i+1); | ||
| 253 | /// break; | ||
| 254 | /// } | ||
| 255 | /// else if (ret < 0) | ||
| 256 | /// { | ||
| 257 | /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); | ||
| 258 | /// break; | ||
| 259 | /// } | ||
| 260 | /// else /* if (ret > 0) */ | ||
| 261 | /// { | ||
| 262 | /// fprintf(stderr, "Wrong password entered on try '%i'\n", i+1); | ||
| 263 | /// } | ||
| 264 | /// } | ||
| 265 | /// ~~~~~~~~~~~~~ | ||
| 266 | /// | ||
| 267 | inline bool ShowAndVerifyNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0) | ||
| 268 | { | ||
| 269 | using namespace ::kodi::addon; | ||
| 270 | char* retString = nullptr; | ||
| 271 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 272 | &retString, heading.c_str(), allowEmptyResult, | ||
| 273 | autoCloseMs); | ||
| 274 | if (retString != nullptr) | ||
| 275 | { | ||
| 276 | if (std::strlen(retString)) | ||
| 277 | newPassword = retString; | ||
| 278 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 279 | } | ||
| 280 | return ret; | ||
| 281 | } | ||
| 282 | //-------------------------------------------------------------------------- | ||
| 283 | |||
| 284 | //========================================================================== | ||
| 285 | /// | ||
| 286 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 287 | /// @brief Show keyboard twice to get and confirm a user-entered password | ||
| 288 | /// string. | ||
| 289 | /// | ||
| 290 | /// @param[out] newPassword Overwritten with user input if return=true. | ||
| 291 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 292 | /// in milliseconds, default is 0 which keeps | ||
| 293 | /// the dialog open indefinitely. | ||
| 294 | /// @return true if successful display and user input. | ||
| 295 | /// false if unsuccessful display, no user | ||
| 296 | /// input, or canceled editing. | ||
| 297 | /// | ||
| 298 | inline bool ShowAndVerifyNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) | ||
| 299 | { | ||
| 300 | using namespace ::kodi::addon; | ||
| 301 | char* retString = nullptr; | ||
| 302 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 303 | &retString, autoCloseMs); | ||
| 304 | if (retString != nullptr) | ||
| 305 | { | ||
| 306 | if (std::strlen(retString)) | ||
| 307 | newPassword = retString; | ||
| 308 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 309 | } | ||
| 310 | return ret; | ||
| 311 | } | ||
| 312 | //-------------------------------------------------------------------------- | ||
| 313 | |||
| 314 | //========================================================================== | ||
| 315 | /// | ||
| 316 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 317 | /// @brief Show keyboard and verify user input against `password`. | ||
| 318 | /// | ||
| 319 | /// @param[in,out] password Value to compare against user input. | ||
| 320 | /// @param[in] heading String shown on dialog title. | ||
| 321 | /// @param[in] retries If greater than 0, shows "Incorrect | ||
| 322 | /// password, %d retries left" on dialog line 2, | ||
| 323 | /// else line 2 is blank. | ||
| 324 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 325 | /// in milliseconds, default is 0 which keeps | ||
| 326 | /// the dialog open indefinitely. | ||
| 327 | /// @return 0 if successful display and user input. 1 if | ||
| 328 | /// unsuccessful input. -1 if no user input or | ||
| 329 | /// canceled editing. | ||
| 330 | /// | ||
| 331 | inline int ShowAndVerifyPassword(std::string& password, const std::string& heading, int retries, unsigned int autoCloseMs = 0) | ||
| 332 | { | ||
| 333 | using namespace ::kodi::addon; | ||
| 334 | char* retString = nullptr; | ||
| 335 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 336 | password.c_str(), &retString, heading.c_str(), | ||
| 337 | retries, autoCloseMs); | ||
| 338 | if (retString != nullptr) | ||
| 339 | { | ||
| 340 | if (std::strlen(retString)) | ||
| 341 | password = retString; | ||
| 342 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 343 | } | ||
| 344 | return ret; | ||
| 345 | } | ||
| 346 | //-------------------------------------------------------------------------- | ||
| 347 | |||
| 348 | //========================================================================== | ||
| 349 | /// | ||
| 350 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 351 | /// @brief Shows a filter related keyboard | ||
| 352 | /// | ||
| 353 | /// @param[in,out] text Overwritten with user input if return=true. | ||
| 354 | /// @param[in] searching Use dialog for search and send our search | ||
| 355 | /// message in safe way (only the active window | ||
| 356 | /// needs it) | ||
| 357 | /// - header name if true is "Enter search string" | ||
| 358 | /// - header name if false is "Enter value" | ||
| 359 | /// @param autoCloseMs To close the dialog after a specified time, | ||
| 360 | /// in milliseconds, default is 0 which keeps | ||
| 361 | /// the dialog open indefinitely. | ||
| 362 | /// @return true if successful display and user input. | ||
| 363 | /// false if unsuccessful display, no user | ||
| 364 | /// input, or canceled editing. | ||
| 365 | /// | ||
| 366 | inline bool ShowAndGetFilter(std::string& text, bool searching, unsigned int autoCloseMs = 0) | ||
| 367 | { | ||
| 368 | using namespace ::kodi::addon; | ||
| 369 | char* retString = nullptr; | ||
| 370 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_filter(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 371 | text.c_str(), &retString, searching, autoCloseMs); | ||
| 372 | if (retString != nullptr) | ||
| 373 | { | ||
| 374 | if (std::strlen(retString)) | ||
| 375 | text = retString; | ||
| 376 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 377 | } | ||
| 378 | return ret; | ||
| 379 | } | ||
| 380 | //-------------------------------------------------------------------------- | ||
| 381 | |||
| 382 | //========================================================================== | ||
| 383 | /// | ||
| 384 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 385 | /// @brief Send a text to a visible keyboard | ||
| 386 | /// | ||
| 387 | /// @param[in] text Overwritten with user input if return=true. | ||
| 388 | /// @param[in] closeKeyboard The open dialog is if also closed on 'true'. | ||
| 389 | /// @return true if successful done, false if | ||
| 390 | /// unsuccessful or keyboard not present. | ||
| 391 | /// | ||
| 392 | inline bool SendTextToActiveKeyboard(const std::string& text, bool closeKeyboard = false) | ||
| 393 | { | ||
| 394 | using namespace ::kodi::addon; | ||
| 395 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->send_text_to_active_keyboard(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 396 | text.c_str(), closeKeyboard); | ||
| 397 | } | ||
| 398 | //-------------------------------------------------------------------------- | ||
| 399 | |||
| 400 | //========================================================================== | ||
| 401 | /// | ||
| 402 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 403 | /// @brief Check for visible keyboard on GUI | ||
| 404 | /// | ||
| 405 | /// @return true if keyboard present, false if not present | ||
| 406 | /// | ||
| 407 | inline bool IsKeyboardActivated() | ||
| 408 | { | ||
| 409 | using namespace ::kodi::addon; | ||
| 410 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 411 | } | ||
| 412 | //-------------------------------------------------------------------------- | ||
| 413 | }; | ||
| 414 | |||
| 415 | } /* namespace gui */ | ||
| 416 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogNumeric.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogNumeric.h new file mode 100644 index 0000000..8b5c592 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogNumeric.h | |||
| @@ -0,0 +1,366 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "definitions.h" | ||
| 23 | #include "../AddonBase.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | /// \defgroup cpp_kodi_gui_DialogNumeric Dialog Numeric | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @{ | ||
| 35 | /// @brief \cpp_namespace{ kodi::gui::DialogNumeric } | ||
| 36 | /// **Numeric dialogs** | ||
| 37 | /// | ||
| 38 | /// The functions listed below have to be permitted by the user for the | ||
| 39 | /// representation of a numeric keyboard around an input. | ||
| 40 | /// | ||
| 41 | /// The class supports several kinds, from an easy number choice up to the | ||
| 42 | /// passport Word production and their confirmation for add-on. | ||
| 43 | /// | ||
| 44 | /// It has the header \ref DialogNumeric.h "#include <kodi/gui/DialogNumeric.h>" | ||
| 45 | /// be included to enjoy it. | ||
| 46 | /// | ||
| 47 | namespace DialogNumeric | ||
| 48 | { | ||
| 49 | //========================================================================== | ||
| 50 | /// | ||
| 51 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 52 | /// @brief Use dialog to get numeric new password | ||
| 53 | /// | ||
| 54 | /// @param[out] newPassword String to preload into the keyboard | ||
| 55 | /// accumulator. Overwritten with user input | ||
| 56 | /// if return=true. Returned in MD5 format. | ||
| 57 | /// @return true if successful display and user | ||
| 58 | /// input entry/re-entry. | ||
| 59 | /// false if unsuccessful display, no user | ||
| 60 | /// input, or canceled editing. | ||
| 61 | /// | ||
| 62 | inline bool ShowAndVerifyNewPassword(std::string& newPassword) | ||
| 63 | { | ||
| 64 | using namespace ::kodi::addon; | ||
| 65 | char* pw = nullptr; | ||
| 66 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, &pw); | ||
| 67 | if (pw != nullptr) | ||
| 68 | { | ||
| 69 | if (std::strlen(pw)) | ||
| 70 | newPassword = pw; | ||
| 71 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, pw); | ||
| 72 | } | ||
| 73 | return ret; | ||
| 74 | } | ||
| 75 | //-------------------------------------------------------------------------- | ||
| 76 | |||
| 77 | //========================================================================== | ||
| 78 | /// | ||
| 79 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 80 | /// @brief Use dialog to verify numeric password. | ||
| 81 | /// | ||
| 82 | /// @param[in] password Password to compare with user input, need | ||
| 83 | /// in MD5 format. | ||
| 84 | /// @param[in] heading Heading to display | ||
| 85 | /// @param[in] retries If greater than 0, shows "Incorrect | ||
| 86 | /// password, %d retries left" on dialog | ||
| 87 | /// line 2, else line 2 is blank. | ||
| 88 | /// @return Possible values: | ||
| 89 | /// - 0 if successful display and user input. | ||
| 90 | /// - 1 if unsuccessful input. | ||
| 91 | /// - -1 if no user input or canceled editing. | ||
| 92 | /// | ||
| 93 | /// | ||
| 94 | ///------------------------------------------------------------------------- | ||
| 95 | /// | ||
| 96 | /// **Example:** | ||
| 97 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 98 | /// #include <stdio.h> /* fprintf */ | ||
| 99 | /// #include <kodi/General.h> | ||
| 100 | /// #include <kodi/gui/DialogNumeric.h> | ||
| 101 | /// | ||
| 102 | /// /* | ||
| 103 | /// * The example below shows the complete use of keyboard dialog for password | ||
| 104 | /// * check. If only one check from add-on needed can be function with retries | ||
| 105 | /// * set to '0' called alone. | ||
| 106 | /// * | ||
| 107 | /// * The use of MD5 translated password is always required for the check on Kodi! | ||
| 108 | /// */ | ||
| 109 | /// | ||
| 110 | /// int maxretries = 3; | ||
| 111 | /// | ||
| 112 | /// /* | ||
| 113 | /// * Password names need to be send as md5 sum to kodi. | ||
| 114 | /// */ | ||
| 115 | /// std::string password = kodi::GetMD5("1234"); | ||
| 116 | /// | ||
| 117 | /// /* | ||
| 118 | /// * To the loop about password checks. | ||
| 119 | /// */ | ||
| 120 | /// int ret; | ||
| 121 | /// for (unsigned int i = 0; i < maxretries; i++) | ||
| 122 | /// { | ||
| 123 | /// /* | ||
| 124 | /// * Ask the user about the password. | ||
| 125 | /// */ | ||
| 126 | /// ret = kodi::gui::DialogNumeric::ShowAndVerifyPassword(password, "Demo numeric password call for PW '1234'", i); | ||
| 127 | /// if (ret == 0) | ||
| 128 | /// { | ||
| 129 | /// fprintf(stderr, "Numeric password successfull confirmed after '%i' tries\n", i+1); | ||
| 130 | /// break; | ||
| 131 | /// } | ||
| 132 | /// else if (ret < 0) | ||
| 133 | /// { | ||
| 134 | /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); | ||
| 135 | /// break; | ||
| 136 | /// } | ||
| 137 | /// else /* if (ret > 0) */ | ||
| 138 | /// { | ||
| 139 | /// fprintf(stderr, "Wrong numeric password entered on try '%i'\n", i+1); | ||
| 140 | /// } | ||
| 141 | /// } | ||
| 142 | /// ~~~~~~~~~~~~~ | ||
| 143 | /// | ||
| 144 | inline int ShowAndVerifyPassword(const std::string& password, const std::string& heading, int retries) | ||
| 145 | { | ||
| 146 | using namespace ::kodi::addon; | ||
| 147 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 148 | password.c_str(), heading.c_str(), retries); | ||
| 149 | } | ||
| 150 | //-------------------------------------------------------------------------- | ||
| 151 | |||
| 152 | //========================================================================== | ||
| 153 | /// | ||
| 154 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 155 | /// @brief Use dialog to verify numeric password | ||
| 156 | /// | ||
| 157 | /// @param[in,out] toVerify Value to compare against user input. | ||
| 158 | /// @param[in] heading Heading to display | ||
| 159 | /// @param[in] verifyInput If set as true we verify the users input | ||
| 160 | /// versus toVerify. | ||
| 161 | /// @return true if successful display and user | ||
| 162 | /// input. false if unsuccessful display, no | ||
| 163 | /// user input, or canceled editing. | ||
| 164 | /// | ||
| 165 | inline bool ShowAndVerifyInput(std::string& toVerify, const std::string& heading, bool verifyInput) | ||
| 166 | { | ||
| 167 | using namespace ::kodi::addon; | ||
| 168 | char* retString = nullptr; | ||
| 169 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_input(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 170 | toVerify.c_str(), &retString, heading.c_str(), verifyInput); | ||
| 171 | if (retString != nullptr) | ||
| 172 | { | ||
| 173 | if (std::strlen(retString)) | ||
| 174 | toVerify = retString; | ||
| 175 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 176 | } | ||
| 177 | return ret; | ||
| 178 | } | ||
| 179 | //-------------------------------------------------------------------------- | ||
| 180 | |||
| 181 | //========================================================================== | ||
| 182 | /// | ||
| 183 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 184 | /// @brief Use dialog to get time value. | ||
| 185 | /// | ||
| 186 | /// @param[out] time Overwritten with user input if | ||
| 187 | /// return=true and time inserted. | ||
| 188 | /// @param[in] heading Heading to display. | ||
| 189 | /// @return true if successful display and user | ||
| 190 | /// input. false if unsuccessful display, no | ||
| 191 | /// user input, or canceled editing. | ||
| 192 | /// | ||
| 193 | /// | ||
| 194 | ///------------------------------------------------------------------------- | ||
| 195 | /// | ||
| 196 | /// **Example:** | ||
| 197 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 198 | /// #include <stdio.h> /* printf */ | ||
| 199 | /// #include <time.h> /* time_t, struct tm, time, localtime, strftime */ | ||
| 200 | /// #include <kodi/gui/DialogNumeric.h> | ||
| 201 | /// | ||
| 202 | /// time_t rawtime; | ||
| 203 | /// struct tm * timeinfo; | ||
| 204 | /// char buffer [10]; | ||
| 205 | /// | ||
| 206 | /// time (&rawtime); | ||
| 207 | /// timeinfo = localtime(&rawtime); | ||
| 208 | /// bool bRet = kodi::gui::DialogNumeric::ShowAndGetTime(*timeinfo, "Selected time test call"); | ||
| 209 | /// strftime(buffer, sizeof(buffer), "%H:%M.", timeinfo); | ||
| 210 | /// printf("Selected time it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); | ||
| 211 | /// ~~~~~~~~~~~~~ | ||
| 212 | /// | ||
| 213 | inline bool ShowAndGetTime(tm& time, const std::string& heading) | ||
| 214 | { | ||
| 215 | using namespace ::kodi::addon; | ||
| 216 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_time(CAddonBase::m_interface->toKodi->kodiBase, &time, heading.c_str()); | ||
| 217 | } | ||
| 218 | //-------------------------------------------------------------------------- | ||
| 219 | |||
| 220 | //========================================================================== | ||
| 221 | /// | ||
| 222 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 223 | /// @brief Use dialog to get date value. | ||
| 224 | /// | ||
| 225 | /// @param[in,out] date Overwritten with user input if | ||
| 226 | /// return=true and date inserted. | ||
| 227 | /// @param[in] heading Heading to display | ||
| 228 | /// @return true if successful display and user | ||
| 229 | /// input. false if unsuccessful display, no | ||
| 230 | /// user input, or canceled editing. | ||
| 231 | /// | ||
| 232 | /// | ||
| 233 | ///------------------------------------------------------------------------- | ||
| 234 | /// | ||
| 235 | /// **Example:** | ||
| 236 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 237 | /// #include <stdio.h> /* printf */ | ||
| 238 | /// #include <time.h> /* time_t, struct tm, time, localtime, strftime */ | ||
| 239 | /// #include <kodi/gui/DialogNumeric.h> | ||
| 240 | /// | ||
| 241 | /// time_t rawtime; | ||
| 242 | /// struct tm * timeinfo; | ||
| 243 | /// char buffer [20]; | ||
| 244 | /// | ||
| 245 | /// time (&rawtime); | ||
| 246 | /// timeinfo = localtime(&rawtime); | ||
| 247 | /// bool bRet = kodi::gui::DialogNumeric::ShowAndGetDate(*timeinfo, "Selected date test call"); | ||
| 248 | /// strftime(buffer, sizeof(buffer), "%Y-%m-%d", timeinfo); | ||
| 249 | /// printf("Selected date it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); | ||
| 250 | /// ~~~~~~~~~~~~~ | ||
| 251 | /// | ||
| 252 | inline bool ShowAndGetDate(tm& date, const std::string& heading) | ||
| 253 | { | ||
| 254 | using namespace ::kodi::addon; | ||
| 255 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_date(CAddonBase::m_interface->toKodi->kodiBase, &date, heading.c_str()); | ||
| 256 | } | ||
| 257 | //-------------------------------------------------------------------------- | ||
| 258 | |||
| 259 | //========================================================================== | ||
| 260 | /// | ||
| 261 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 262 | /// @brief Use dialog to get a IP | ||
| 263 | /// | ||
| 264 | /// @param[in,out] ipAddress Overwritten with user input if | ||
| 265 | /// return=true and IP address inserted. | ||
| 266 | /// @param[in] heading Heading to display. | ||
| 267 | /// @return true if successful display and | ||
| 268 | /// user input. false if unsuccessful | ||
| 269 | /// display, no user input, or canceled | ||
| 270 | /// editing. | ||
| 271 | /// | ||
| 272 | inline bool ShowAndGetIPAddress(std::string& ipAddress, const std::string& heading) | ||
| 273 | { | ||
| 274 | using namespace ::kodi::addon; | ||
| 275 | char* retString = nullptr; | ||
| 276 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_ip_address(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 277 | ipAddress.c_str(), &retString, heading.c_str()); | ||
| 278 | if (retString != nullptr) | ||
| 279 | { | ||
| 280 | if (std::strlen(retString)) | ||
| 281 | ipAddress = retString; | ||
| 282 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 283 | } | ||
| 284 | return ret; | ||
| 285 | } | ||
| 286 | //-------------------------------------------------------------------------- | ||
| 287 | |||
| 288 | //========================================================================== | ||
| 289 | /// | ||
| 290 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 291 | /// @brief Use dialog to get normal number. | ||
| 292 | /// | ||
| 293 | /// @param[in,out] input Overwritten with user input if | ||
| 294 | /// return=true and time in seconds inserted | ||
| 295 | /// @param[in] heading Heading to display | ||
| 296 | /// @param[in] autoCloseTimeoutMs To close the dialog after a specified | ||
| 297 | /// time, in milliseconds, default is 0 | ||
| 298 | /// which keeps the dialog open | ||
| 299 | /// indefinitely. | ||
| 300 | /// @return true if successful display and user | ||
| 301 | /// input. false if unsuccessful display, no | ||
| 302 | /// user input, or canceled editing. | ||
| 303 | /// | ||
| 304 | /// | ||
| 305 | ///------------------------------------------------------------------------- | ||
| 306 | /// | ||
| 307 | /// **Example:** | ||
| 308 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 309 | /// #include <stdio.h> /* printf */ | ||
| 310 | /// #include <stdlib.h> /* strtoull (C++11) */ | ||
| 311 | /// #include <kodi/gui/DialogNumeric.h> | ||
| 312 | /// | ||
| 313 | /// std::string number; | ||
| 314 | /// bool bRet = kodi::gui::DialogNumeric::ShowAndGetNumber(number, "Number test call"); | ||
| 315 | /// printf("Written number input is : %llu and was %s\n", | ||
| 316 | /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled"); | ||
| 317 | /// ~~~~~~~~~~~~~ | ||
| 318 | /// | ||
| 319 | inline bool ShowAndGetNumber(std::string& input, const std::string& heading, unsigned int autoCloseTimeoutMs = 0) | ||
| 320 | { | ||
| 321 | using namespace ::kodi::addon; | ||
| 322 | char* retString = nullptr; | ||
| 323 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_number(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 324 | input.c_str(), &retString, heading.c_str(), autoCloseTimeoutMs); | ||
| 325 | if (retString != nullptr) | ||
| 326 | { | ||
| 327 | if (std::strlen(retString)) | ||
| 328 | input = retString; | ||
| 329 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 330 | } | ||
| 331 | return ret; | ||
| 332 | } | ||
| 333 | //-------------------------------------------------------------------------- | ||
| 334 | |||
| 335 | //========================================================================== | ||
| 336 | /// | ||
| 337 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 338 | /// @brief Show numeric keypad to get seconds. | ||
| 339 | /// | ||
| 340 | /// @param[in,out] time Overwritten with user input if return=true and | ||
| 341 | /// time in seconds inserted. | ||
| 342 | /// @param[in] heading Heading to display | ||
| 343 | /// @return true if successful display and user input. false | ||
| 344 | /// if unsuccessful display, no user input, or | ||
| 345 | /// canceled editing. | ||
| 346 | /// | ||
| 347 | inline bool ShowAndGetSeconds(std::string& time, const std::string& heading) | ||
| 348 | { | ||
| 349 | using namespace ::kodi::addon; | ||
| 350 | char* retString = nullptr; | ||
| 351 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_seconds(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 352 | time.c_str(), &retString, heading.c_str()); | ||
| 353 | if (retString != nullptr) | ||
| 354 | { | ||
| 355 | if (std::strlen(retString)) | ||
| 356 | time = retString; | ||
| 357 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 358 | } | ||
| 359 | return ret; | ||
| 360 | } | ||
| 361 | //-------------------------------------------------------------------------- | ||
| 362 | }; | ||
| 363 | /// @} | ||
| 364 | |||
| 365 | } /* namespace gui */ | ||
| 366 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogOK.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogOK.h new file mode 100644 index 0000000..fa98241 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogOK.h | |||
| @@ -0,0 +1,104 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "../AddonBase.h" | ||
| 23 | #include "definitions.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | /// \defgroup cpp_kodi_gui_DialogOK Dialog OK | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @{ | ||
| 35 | /// @brief \cpp_namespace{ kodi::gui::DialogOK } | ||
| 36 | /// **OK dialog** | ||
| 37 | /// | ||
| 38 | /// The functions listed below permit the call of a dialogue of information, a | ||
| 39 | /// confirmation of the user by press from OK required. | ||
| 40 | /// | ||
| 41 | /// It has the header \ref DialogOK.h "#include <kodi/gui/DialogOK.h>" | ||
| 42 | /// be included to enjoy it. | ||
| 43 | /// | ||
| 44 | namespace DialogOK | ||
| 45 | { | ||
| 46 | //========================================================================== | ||
| 47 | /// | ||
| 48 | /// \ingroup cpp_kodi_gui_DialogOK | ||
| 49 | /// @brief Use dialog to inform user with text and confirmation with OK with continued string. | ||
| 50 | /// | ||
| 51 | /// @param[in] heading Dialog heading. | ||
| 52 | /// @param[in] text Multi-line text. | ||
| 53 | /// | ||
| 54 | /// | ||
| 55 | ///------------------------------------------------------------------------- | ||
| 56 | /// | ||
| 57 | /// **Example:** | ||
| 58 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 59 | /// #include <kodi/gui/DialogOK.h> | ||
| 60 | /// ... | ||
| 61 | /// kodi::gui::DialogOK::ShowAndGetInput("Test dialog", "Hello World!\nI'm a call from add-on\n :) :D"); | ||
| 62 | /// ~~~~~~~~~~~~~ | ||
| 63 | /// | ||
| 64 | inline void ShowAndGetInput(const std::string& heading, const std::string& text) | ||
| 65 | { | ||
| 66 | using namespace ::kodi::addon; | ||
| 67 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_single_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 68 | heading.c_str(), text.c_str()); | ||
| 69 | } | ||
| 70 | //-------------------------------------------------------------------------- | ||
| 71 | |||
| 72 | //========================================================================== | ||
| 73 | /// | ||
| 74 | /// \ingroup cpp_kodi_gui_DialogOK | ||
| 75 | /// @brief Use dialog to inform user with text and confirmation with OK with strings separated to the lines. | ||
| 76 | /// | ||
| 77 | /// @param[in] heading Dialog heading. | ||
| 78 | /// @param[in] line0 Line #1 text. | ||
| 79 | /// @param[in] line1 Line #2 text. | ||
| 80 | /// @param[in] line2 Line #3 text. | ||
| 81 | /// | ||
| 82 | /// | ||
| 83 | ///------------------------------------------------------------------------- | ||
| 84 | /// | ||
| 85 | /// **Example:** | ||
| 86 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 87 | /// #include <kodi/gui/DialogOK.h> | ||
| 88 | /// ... | ||
| 89 | /// kodi::gui::DialogOK::ShowAndGetInput("Test dialog", "Hello World!", "I'm a call from add-on", " :) :D"); | ||
| 90 | /// ~~~~~~~~~~~~~ | ||
| 91 | /// | ||
| 92 | inline void ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, const std::string& line2) | ||
| 93 | { | ||
| 94 | using namespace ::kodi::addon; | ||
| 95 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 96 | heading.c_str(), line0.c_str(), line1.c_str(), | ||
| 97 | line2.c_str()); | ||
| 98 | } | ||
| 99 | //-------------------------------------------------------------------------- | ||
| 100 | } | ||
| 101 | /// @} | ||
| 102 | |||
| 103 | } /* namespace gui */ | ||
| 104 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogProgress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogProgress.h new file mode 100644 index 0000000..e652644 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogProgress.h | |||
| @@ -0,0 +1,249 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "definitions.h" | ||
| 23 | #include "../AddonBase.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | /// \defgroup cpp_kodi_gui_CDialogProgress Dialog Progress | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @brief \cpp_class{ kodi::gui::CDialogProgress } | ||
| 35 | /// **Progress dialog shown in center** | ||
| 36 | /// | ||
| 37 | /// The with \ref DialogProgress.h "#include <kodi/gui/DialogProgress.h>" | ||
| 38 | /// given class are basically used to create Kodi's progress dialog with named | ||
| 39 | /// text fields. | ||
| 40 | /// | ||
| 41 | /// **Example:** | ||
| 42 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 43 | /// #include <kodi/gui/DialogProgress.h> | ||
| 44 | /// | ||
| 45 | /// kodi::gui::CDialogProgress *progress = new kodi::gui::CDialogProgress; | ||
| 46 | /// progress->SetHeading("Test progress"); | ||
| 47 | /// progress->SetLine(1, "line 1"); | ||
| 48 | /// progress->SetLine(2, "line 2"); | ||
| 49 | /// progress->SetLine(3, "line 3"); | ||
| 50 | /// progress->SetCanCancel(true); | ||
| 51 | /// progress->ShowProgressBar(true); | ||
| 52 | /// progress->Open(); | ||
| 53 | /// for (unsigned int i = 0; i < 100; i += 10) | ||
| 54 | /// { | ||
| 55 | /// progress->SetPercentage(i); | ||
| 56 | /// sleep(1); | ||
| 57 | /// } | ||
| 58 | /// delete progress; | ||
| 59 | /// ~~~~~~~~~~~~~ | ||
| 60 | /// | ||
| 61 | class CDialogProgress | ||
| 62 | { | ||
| 63 | public: | ||
| 64 | //========================================================================== | ||
| 65 | /// | ||
| 66 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 67 | /// @brief Construct a new dialog | ||
| 68 | /// | ||
| 69 | CDialogProgress() | ||
| 70 | { | ||
| 71 | using namespace ::kodi::addon; | ||
| 72 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 73 | if (!m_DialogHandle) | ||
| 74 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CDialogProgress can't create window class from Kodi !!!"); | ||
| 75 | } | ||
| 76 | //-------------------------------------------------------------------------- | ||
| 77 | |||
| 78 | //========================================================================== | ||
| 79 | /// | ||
| 80 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 81 | /// @brief Destructor | ||
| 82 | /// | ||
| 83 | ~CDialogProgress() | ||
| 84 | { | ||
| 85 | using namespace ::kodi::addon; | ||
| 86 | if (m_DialogHandle) | ||
| 87 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 88 | } | ||
| 89 | //-------------------------------------------------------------------------- | ||
| 90 | |||
| 91 | //========================================================================== | ||
| 92 | /// | ||
| 93 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 94 | /// @brief To open the dialog | ||
| 95 | /// | ||
| 96 | void Open() | ||
| 97 | { | ||
| 98 | using namespace ::kodi::addon; | ||
| 99 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 100 | } | ||
| 101 | //-------------------------------------------------------------------------- | ||
| 102 | |||
| 103 | //========================================================================== | ||
| 104 | /// | ||
| 105 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 106 | /// @brief Set the heading title of dialog | ||
| 107 | /// | ||
| 108 | /// @param[in] heading Title string to use | ||
| 109 | /// | ||
| 110 | void SetHeading(const std::string& heading) | ||
| 111 | { | ||
| 112 | using namespace ::kodi::addon; | ||
| 113 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str()); | ||
| 114 | } | ||
| 115 | //-------------------------------------------------------------------------- | ||
| 116 | |||
| 117 | //========================================================================== | ||
| 118 | /// | ||
| 119 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 120 | /// @brief To set the line text field on dialog from 0 - 2 | ||
| 121 | /// | ||
| 122 | /// @param[in] iLine Line number | ||
| 123 | /// @param[in] line Text string | ||
| 124 | /// | ||
| 125 | void SetLine(unsigned int iLine, const std::string& line) | ||
| 126 | { | ||
| 127 | using namespace ::kodi::addon; | ||
| 128 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str()); | ||
| 129 | } | ||
| 130 | //-------------------------------------------------------------------------- | ||
| 131 | |||
| 132 | //========================================================================== | ||
| 133 | /// | ||
| 134 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 135 | /// @brief To enable and show cancel button on dialog | ||
| 136 | /// | ||
| 137 | /// @param[in] canCancel if true becomes it shown | ||
| 138 | /// | ||
| 139 | void SetCanCancel(bool canCancel) | ||
| 140 | { | ||
| 141 | using namespace ::kodi::addon; | ||
| 142 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel); | ||
| 143 | } | ||
| 144 | //-------------------------------------------------------------------------- | ||
| 145 | |||
| 146 | //========================================================================== | ||
| 147 | /// | ||
| 148 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 149 | /// @brief To check dialog for clicked cancel button | ||
| 150 | /// | ||
| 151 | /// @return True if canceled | ||
| 152 | /// | ||
| 153 | bool IsCanceled() const | ||
| 154 | { | ||
| 155 | using namespace ::kodi::addon; | ||
| 156 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 157 | } | ||
| 158 | //-------------------------------------------------------------------------- | ||
| 159 | |||
| 160 | //========================================================================== | ||
| 161 | /// | ||
| 162 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 163 | /// @brief Get the current progress position as percent | ||
| 164 | /// | ||
| 165 | /// @param[in] percentage Position to use from 0 to 100 | ||
| 166 | /// | ||
| 167 | void SetPercentage(int percentage) | ||
| 168 | { | ||
| 169 | using namespace ::kodi::addon; | ||
| 170 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | ||
| 171 | } | ||
| 172 | //-------------------------------------------------------------------------- | ||
| 173 | |||
| 174 | //========================================================================== | ||
| 175 | /// | ||
| 176 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 177 | /// @brief To set the current progress position as percent | ||
| 178 | /// | ||
| 179 | /// @return Current Position used from 0 to 100 | ||
| 180 | /// | ||
| 181 | int GetPercentage() const | ||
| 182 | { | ||
| 183 | using namespace ::kodi::addon; | ||
| 184 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 185 | } | ||
| 186 | //-------------------------------------------------------------------------- | ||
| 187 | |||
| 188 | //========================================================================== | ||
| 189 | /// | ||
| 190 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 191 | /// @brief To show or hide progress bar dialog | ||
| 192 | /// | ||
| 193 | /// @param[in] onOff If true becomes it shown | ||
| 194 | /// | ||
| 195 | void ShowProgressBar(bool onOff) | ||
| 196 | { | ||
| 197 | using namespace ::kodi::addon; | ||
| 198 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff); | ||
| 199 | } | ||
| 200 | //-------------------------------------------------------------------------- | ||
| 201 | |||
| 202 | //========================================================================== | ||
| 203 | /// | ||
| 204 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 205 | /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used | ||
| 206 | /// | ||
| 207 | /// @param[in] max Biggest usable position to use | ||
| 208 | /// | ||
| 209 | void SetProgressMax(int max) | ||
| 210 | { | ||
| 211 | using namespace ::kodi::addon; | ||
| 212 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max); | ||
| 213 | } | ||
| 214 | //-------------------------------------------------------------------------- | ||
| 215 | |||
| 216 | //========================================================================== | ||
| 217 | /// | ||
| 218 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 219 | /// @brief To increase progress bar by defined step size until reach of maximum position | ||
| 220 | /// | ||
| 221 | /// @param[in] steps Step size to increase, default is 1 | ||
| 222 | /// | ||
| 223 | void SetProgressAdvance(int steps=1) | ||
| 224 | { | ||
| 225 | using namespace ::kodi::addon; | ||
| 226 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps); | ||
| 227 | } | ||
| 228 | //-------------------------------------------------------------------------- | ||
| 229 | |||
| 230 | //========================================================================== | ||
| 231 | /// | ||
| 232 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 233 | /// @brief To check progress was canceled on work | ||
| 234 | /// | ||
| 235 | /// @return True if aborted | ||
| 236 | /// | ||
| 237 | bool Abort() | ||
| 238 | { | ||
| 239 | using namespace ::kodi::addon; | ||
| 240 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 241 | } | ||
| 242 | //-------------------------------------------------------------------------- | ||
| 243 | |||
| 244 | private: | ||
| 245 | void* m_DialogHandle; | ||
| 246 | }; | ||
| 247 | |||
| 248 | } /* namespace gui */ | ||
| 249 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogSelect.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogSelect.h new file mode 100644 index 0000000..36433db --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogSelect.h | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "definitions.h" | ||
| 23 | #include "../AddonBase.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | /// \defgroup cpp_kodi_gui_DialogSelect Dialog Select | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @{ | ||
| 35 | /// @brief \cpp_namespace{ kodi::gui::DialogSelect } | ||
| 36 | /// **Selection dialog** | ||
| 37 | /// | ||
| 38 | /// The function listed below permits the call of a dialogue to select of an | ||
| 39 | /// entry as a key | ||
| 40 | /// | ||
| 41 | /// It has the header \ref DialogSelect.h "#include <kodi/gui/DialogSelect.h>" | ||
| 42 | /// be included to enjoy it. | ||
| 43 | /// | ||
| 44 | /// | ||
| 45 | namespace DialogSelect | ||
| 46 | { | ||
| 47 | //========================================================================== | ||
| 48 | /// | ||
| 49 | /// \ingroup cpp_kodi_gui_DialogSelect | ||
| 50 | /// @brief Show a selection dialog about given parts. | ||
| 51 | /// | ||
| 52 | /// @param[in] heading Dialog heading name | ||
| 53 | /// @param[in] entries String list about entries | ||
| 54 | /// @param[in] selected [opt] Predefined selection (default is | ||
| 55 | /// <tt>-1</tt> for the first) | ||
| 56 | /// @param[in] autoclose [opt] To close dialog automatic after a time | ||
| 57 | /// @return The selected entry, if return <tt>-1</tt> was | ||
| 58 | /// nothing selected or canceled | ||
| 59 | /// | ||
| 60 | /// | ||
| 61 | ///------------------------------------------------------------------------- | ||
| 62 | /// | ||
| 63 | /// **Example:** | ||
| 64 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 65 | /// #include <kodi/gui/DialogSelect.h> | ||
| 66 | /// | ||
| 67 | /// const std::vector<std::string> entries | ||
| 68 | /// { | ||
| 69 | /// "Test 1", | ||
| 70 | /// "Test 2", | ||
| 71 | /// "Test 3", | ||
| 72 | /// "Test 4", | ||
| 73 | /// "Test 5" | ||
| 74 | /// }; | ||
| 75 | /// | ||
| 76 | /// int selected = kodi::gui::DialogSelect::Show("Test selection", entries, -1); | ||
| 77 | /// if (selected < 0) | ||
| 78 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 79 | /// else | ||
| 80 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 81 | /// ~~~~~~~~~~~~~ | ||
| 82 | /// | ||
| 83 | inline int Show(const std::string& heading, const std::vector<std::string>& entries, int selected = -1, bool autoclose = false) | ||
| 84 | { | ||
| 85 | using namespace ::kodi::addon; | ||
| 86 | unsigned int size = entries.size(); | ||
| 87 | const char** cEntries = (const char**)malloc(size*sizeof(const char**)); | ||
| 88 | for (unsigned int i = 0; i < size; ++i) | ||
| 89 | { | ||
| 90 | cEntries[i] = entries[i].c_str(); | ||
| 91 | } | ||
| 92 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, autoclose); | ||
| 93 | free(cEntries); | ||
| 94 | return ret; | ||
| 95 | } | ||
| 96 | //-------------------------------------------------------------------------- | ||
| 97 | }; | ||
| 98 | /// @} | ||
| 99 | |||
| 100 | } /* namespace gui */ | ||
| 101 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogTextViewer.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogTextViewer.h new file mode 100644 index 0000000..09c81bd --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogTextViewer.h | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2015-2016 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "definitions.h" | ||
| 23 | #include "../AddonBase.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | /// \defgroup cpp_kodi_gui_DialogTextViewer Dialog Text Viewer | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @{ | ||
| 35 | /// @brief \cpp_namespace{ kodi::gui::DialogTextViewer } | ||
| 36 | /// **Text viewer dialog** | ||
| 37 | /// | ||
| 38 | /// The text viewer dialog can be used to display descriptions, help texts or | ||
| 39 | /// other larger texts. | ||
| 40 | /// | ||
| 41 | /// In order to achieve a line break is a <b>\\n</b> directly in the text or | ||
| 42 | /// in the <em>"./resources/language/resource.language.??_??/strings.po"</em> | ||
| 43 | /// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>. | ||
| 44 | /// | ||
| 45 | /// It has the header \ref DialogTextViewer.h "#include <kodi/gui/DialogTextViewer.h>" | ||
| 46 | /// be included to enjoy it. | ||
| 47 | /// | ||
| 48 | namespace DialogTextViewer | ||
| 49 | { | ||
| 50 | //========================================================================== | ||
| 51 | /// | ||
| 52 | /// \ingroup cpp_kodi_gui_DialogTextViewer | ||
| 53 | /// @brief Show info text dialog | ||
| 54 | /// | ||
| 55 | /// @param[in] heading Small heading text | ||
| 56 | /// @param[in] text Showed text on dialog | ||
| 57 | /// | ||
| 58 | /// | ||
| 59 | ///------------------------------------------------------------------------- | ||
| 60 | /// | ||
| 61 | /// **Example:** | ||
| 62 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 63 | /// #include <kodi/gui/DialogTextViewer.h> | ||
| 64 | /// | ||
| 65 | /// kodi::gui::DialogTextViewer::Show("The Wizard of Oz (1939 film)", | ||
| 66 | /// "The Wizard of Oz is a 1939 American musical comedy-drama fantasy film " | ||
| 67 | /// "produced by Metro-Goldwyn-Mayer, and the most well-known and commercially " | ||
| 68 | /// "successful adaptation based on the 1900 novel The Wonderful Wizard of Oz " | ||
| 69 | /// "by L. Frank Baum. The film stars Judy Garland as Dorothy Gale. The film" | ||
| 70 | /// "co-stars Terry the dog, billed as Toto; Ray Bolger, Jack Haley, Bert Lahr, " | ||
| 71 | /// "Frank Morgan, Billie Burke, Margaret Hamilton, with Charley Grapewin and " | ||
| 72 | /// "Clara Blandick, and the Singer Midgets as the Munchkins.\n" | ||
| 73 | /// "\n" | ||
| 74 | /// "Notable for its use of Technicolor, fantasy storytelling, musical score and " | ||
| 75 | /// "unusual characters, over the years it has become an icon of American popular " | ||
| 76 | /// "culture. It was nominated for six Academy Awards, including Best Picture but " | ||
| 77 | /// "lost to Gone with the Wind. It did win in two other categories including Best " | ||
| 78 | /// "Original Song for \"Over the Rainbow\". However, the film was a box office " | ||
| 79 | /// "disappointment on its initial release, earning only $3,017,000 on a $2,777,000 " | ||
| 80 | /// "budget, despite receiving largely positive reviews. It was MGM's most " | ||
| 81 | /// "expensive production at that time, and did not completely recoup the studio's " | ||
| 82 | /// "investment and turn a profit until theatrical re-releases starting in 1949.\n" | ||
| 83 | /// "\n" | ||
| 84 | /// "The 1956 broadcast television premiere of the film on CBS re-introduced the " | ||
| 85 | /// "film to the wider public and eventually made the presentation an annual " | ||
| 86 | /// "tradition, making it one of the most known films in cinema history. The " | ||
| 87 | /// "film was named the most-viewed motion picture on television syndication by " | ||
| 88 | /// "the Library of Congress who also included the film in its National Film " | ||
| 89 | /// "Registry in its inaugural year in 1989. Designation on the registry calls " | ||
| 90 | /// "for efforts to preserve it for being \"culturally, historically, and " | ||
| 91 | /// "aesthetically significant\". It is also one of the few films on UNESCO's " | ||
| 92 | /// "Memory of the World Register.\n" | ||
| 93 | /// "\n" | ||
| 94 | /// "The Wizard of Oz is often ranked on best-movie lists in critics' and public " | ||
| 95 | /// "polls. It is the source of many quotes referenced in modern popular culture. " | ||
| 96 | /// "It was directed primarily by Victor Fleming (who left production to take " | ||
| 97 | /// "over direction on the troubled Gone with the Wind production). Noel Langley, " | ||
| 98 | /// "Florence Ryerson and Edgar Allan Woolf received credit for the screenplay, " | ||
| 99 | /// "but there were uncredited contributions by others. The songs were written " | ||
| 100 | /// "by Edgar \"Yip\" Harburg (lyrics) and Harold Arlen (music). The incidental " | ||
| 101 | /// "music, based largely on the songs, was composed by Herbert Stothart, with " | ||
| 102 | /// "interspersed renderings from classical composers.\n"); | ||
| 103 | /// ~~~~~~~~~~~~~ | ||
| 104 | /// | ||
| 105 | inline void Show(const std::string& heading, const std::string& text) | ||
| 106 | { | ||
| 107 | using namespace ::kodi::addon; | ||
| 108 | CAddonBase::m_interface->toKodi->kodi_gui->dialogTextViewer->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); | ||
| 109 | } | ||
| 110 | //-------------------------------------------------------------------------- | ||
| 111 | }; | ||
| 112 | /// @} | ||
| 113 | |||
| 114 | } /* namespace gui */ | ||
| 115 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogYesNo.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogYesNo.h new file mode 100644 index 0000000..064bf8c --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogYesNo.h | |||
| @@ -0,0 +1,187 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "definitions.h" | ||
| 23 | #include "../AddonBase.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | /// \defgroup cpp_kodi_gui_DialogYesNo Dialog Yes/No | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @{ | ||
| 35 | /// @brief \cpp_namespace{ kodi::gui::DialogYesNo } | ||
| 36 | /// **Yes / No dialog** | ||
| 37 | /// | ||
| 38 | /// The Yes / No dialog can be used to inform the user about questions and get | ||
| 39 | /// the answer. | ||
| 40 | /// | ||
| 41 | /// In order to achieve a line break is a <b>\\n</b> directly in the text or | ||
| 42 | /// in the <em>"./resources/language/resource.language.??_??/strings.po"</em> | ||
| 43 | /// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>. | ||
| 44 | /// | ||
| 45 | /// It has the header \ref DialogYesNo.h "#include <kodi/gui/DialogYesNo.h>" | ||
| 46 | /// be included to enjoy it. | ||
| 47 | /// | ||
| 48 | /// | ||
| 49 | namespace DialogYesNo | ||
| 50 | { | ||
| 51 | //========================================================================== | ||
| 52 | /// | ||
| 53 | /// \ingroup cpp_kodi_gui_DialogYesNo | ||
| 54 | /// @brief Use dialog to get numeric new password with one text string shown | ||
| 55 | /// everywhere and cancel return field | ||
| 56 | /// | ||
| 57 | /// @param[in] heading Dialog heading | ||
| 58 | /// @param[in] text Multi-line text | ||
| 59 | /// @param[out] canceled Return value about cancel button | ||
| 60 | /// @param[in] noLabel [opt] label to put on the no button | ||
| 61 | /// @param[in] yesLabel [opt] label to put on the yes button | ||
| 62 | /// @return Returns True if 'Yes' was pressed, else False | ||
| 63 | /// | ||
| 64 | /// @note It is preferred to only use this as it is actually a multi-line text. | ||
| 65 | /// | ||
| 66 | /// | ||
| 67 | ///------------------------------------------------------------------------- | ||
| 68 | /// | ||
| 69 | /// **Example:** | ||
| 70 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 71 | /// #include <kodi/gui/DialogYesNo.h> | ||
| 72 | /// | ||
| 73 | /// bool canceled; | ||
| 74 | /// bool ret = kodi::gui::DialogYesNo::ShowAndGetInput( | ||
| 75 | /// "Yes / No test call", /* The Header */ | ||
| 76 | /// "You has opened Yes / No dialog for test\n\nIs this OK for you?", | ||
| 77 | /// canceled, /* return value about cancel button */ | ||
| 78 | /// "Not really", /* No label, is optional and if empty "No" */ | ||
| 79 | /// "Ohhh yes"); /* Yes label, also optional and if empty "Yes" */ | ||
| 80 | /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", | ||
| 81 | /// ret ? "yes" : "no", | ||
| 82 | /// canceled ? "canceled" : "not canceled"); | ||
| 83 | /// ~~~~~~~~~~~~~ | ||
| 84 | /// | ||
| 85 | inline bool ShowAndGetInput(const std::string& heading, const std::string& text, | ||
| 86 | bool& canceled, const std::string& noLabel = "", | ||
| 87 | const std::string& yesLabel = "") | ||
| 88 | { | ||
| 89 | using namespace ::kodi::addon; | ||
| 90 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 91 | heading.c_str(), text.c_str(), &canceled, | ||
| 92 | noLabel.c_str(), yesLabel.c_str()); | ||
| 93 | } | ||
| 94 | //-------------------------------------------------------------------------- | ||
| 95 | |||
| 96 | //========================================================================== | ||
| 97 | /// | ||
| 98 | /// \ingroup cpp_kodi_gui_DialogYesNo | ||
| 99 | /// @brief Use dialog to get numeric new password with separated line strings | ||
| 100 | /// | ||
| 101 | /// @param[in] heading Dialog heading | ||
| 102 | /// @param[in] line0 Line #0 text | ||
| 103 | /// @param[in] line1 Line #1 text | ||
| 104 | /// @param[in] line2 Line #2 text | ||
| 105 | /// @param[in] noLabel [opt] label to put on the no button. | ||
| 106 | /// @param[in] yesLabel [opt] label to put on the yes button. | ||
| 107 | /// @return Returns True if 'Yes' was pressed, else False. | ||
| 108 | /// | ||
| 109 | /// | ||
| 110 | ///------------------------------------------------------------------------- | ||
| 111 | /// | ||
| 112 | /// **Example:** | ||
| 113 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 114 | /// #include <kodi/gui/DialogYesNo.h> | ||
| 115 | /// | ||
| 116 | /// bool ret = kodi::gui::DialogYesNo::ShowAndGetInput( | ||
| 117 | /// "Yes / No test call", // The Header | ||
| 118 | /// "You has opened Yes / No dialog for test", | ||
| 119 | /// "", | ||
| 120 | /// "Is this OK for you?", | ||
| 121 | /// "Not really", // No label, is optional and if empty "No" | ||
| 122 | /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" | ||
| 123 | /// fprintf(stderr, "You has called Yes/No, returned '%s'\n", | ||
| 124 | /// ret ? "yes" : "no"); | ||
| 125 | /// ~~~~~~~~~~~~~ | ||
| 126 | /// | ||
| 127 | inline bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, | ||
| 128 | const std::string& line2, const std::string& noLabel = "", | ||
| 129 | const std::string& yesLabel = "") | ||
| 130 | { | ||
| 131 | using namespace ::kodi::addon; | ||
| 132 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 133 | heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), | ||
| 134 | noLabel.c_str(), yesLabel.c_str()); | ||
| 135 | } | ||
| 136 | //-------------------------------------------------------------------------- | ||
| 137 | |||
| 138 | //========================================================================== | ||
| 139 | /// | ||
| 140 | /// \ingroup cpp_kodi_gui_DialogYesNo | ||
| 141 | /// @brief Use dialog to get numeric new password with separated line strings and cancel return field | ||
| 142 | /// | ||
| 143 | /// @param[in] heading Dialog heading | ||
| 144 | /// @param[in] line0 Line #0 text | ||
| 145 | /// @param[in] line1 Line #1 text | ||
| 146 | /// @param[in] line2 Line #2 text | ||
| 147 | /// @param[out] canceled Return value about cancel button | ||
| 148 | /// @param[in] noLabel [opt] label to put on the no button | ||
| 149 | /// @param[in] yesLabel [opt] label to put on the yes button | ||
| 150 | /// @return Returns True if 'Yes' was pressed, else False | ||
| 151 | /// | ||
| 152 | /// | ||
| 153 | ///------------------------------------------------------------------------- | ||
| 154 | /// | ||
| 155 | /// **Example:** | ||
| 156 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 157 | /// #include <kodi/gui/DialogYesNo.h> | ||
| 158 | /// | ||
| 159 | /// bool canceled; | ||
| 160 | /// bool ret = kodi::gui::DialogYesNo::ShowAndGetInput( | ||
| 161 | /// "Yes / No test call", // The Header | ||
| 162 | /// "You has opened Yes / No dialog for test", | ||
| 163 | /// "", | ||
| 164 | /// "Is this OK for you?", | ||
| 165 | /// canceled, // return value about cancel button | ||
| 166 | /// "Not really", // No label, is optional and if empty "No" | ||
| 167 | /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" | ||
| 168 | /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", | ||
| 169 | /// ret ? "yes" : "no", | ||
| 170 | /// canceled ? "canceled" : "not canceled"); | ||
| 171 | /// ~~~~~~~~~~~~~ | ||
| 172 | /// | ||
| 173 | inline bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, | ||
| 174 | const std::string& line2, bool& canceled, const std::string& noLabel = "", | ||
| 175 | const std::string& yesLabel = "") | ||
| 176 | { | ||
| 177 | using namespace ::kodi::addon; | ||
| 178 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_button_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 179 | heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), | ||
| 180 | &canceled, noLabel.c_str(), yesLabel.c_str()); | ||
| 181 | } | ||
| 182 | //-------------------------------------------------------------------------- | ||
| 183 | }; | ||
| 184 | /// @} | ||
| 185 | |||
| 186 | } /* namespace gui */ | ||
| 187 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h new file mode 100644 index 0000000..f1df60d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h | |||
| @@ -0,0 +1,156 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "../AddonBase.h" | ||
| 23 | #include "definitions.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | // \defgroup cpp_kodi_gui ::general | ||
| 33 | /// \addtogroup cpp_kodi_gui | ||
| 34 | /// @{ | ||
| 35 | /// @brief **Allow use of binary classes and function to use on add-on's** | ||
| 36 | /// | ||
| 37 | /// Permits the use of the required functions of the add-on to Kodi. This class | ||
| 38 | /// also contains some functions to the control. | ||
| 39 | /// | ||
| 40 | /// These are pure functions them no other initialization need. | ||
| 41 | /// | ||
| 42 | /// It has the header \ref kodi/gui/General.h "#include <kodi/gui/General.h>" be included | ||
| 43 | /// to enjoy it. | ||
| 44 | /// | ||
| 45 | |||
| 46 | //========================================================================== | ||
| 47 | /// | ||
| 48 | /// \ingroup cpp_kodi_gui | ||
| 49 | /// @brief Performs a graphical lock of rendering engine | ||
| 50 | /// | ||
| 51 | inline void Lock() | ||
| 52 | { | ||
| 53 | using namespace ::kodi::addon; | ||
| 54 | CAddonBase::m_interface->toKodi->kodi_gui->general->lock(); | ||
| 55 | } | ||
| 56 | |||
| 57 | //-------------------------------------------------------------------------- | ||
| 58 | |||
| 59 | //========================================================================== | ||
| 60 | /// | ||
| 61 | /// \ingroup cpp_kodi_gui | ||
| 62 | /// @brief Performs a graphical unlock of previous locked rendering engine | ||
| 63 | /// | ||
| 64 | inline void Unlock() | ||
| 65 | { | ||
| 66 | using namespace ::kodi::addon; | ||
| 67 | CAddonBase::m_interface->toKodi->kodi_gui->general->unlock(); | ||
| 68 | } | ||
| 69 | //-------------------------------------------------------------------------- | ||
| 70 | |||
| 71 | //========================================================================== | ||
| 72 | /// | ||
| 73 | /// \ingroup cpp_kodi_gui | ||
| 74 | /// @brief Return the the current screen height with pixel | ||
| 75 | /// | ||
| 76 | inline int GetScreenHeight() | ||
| 77 | { | ||
| 78 | using namespace ::kodi::addon; | ||
| 79 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_height(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 80 | } | ||
| 81 | //-------------------------------------------------------------------------- | ||
| 82 | |||
| 83 | //========================================================================== | ||
| 84 | /// | ||
| 85 | /// \ingroup cpp_kodi_gui | ||
| 86 | /// @brief Return the the current screen width with pixel | ||
| 87 | /// | ||
| 88 | inline int GetScreenWidth() | ||
| 89 | { | ||
| 90 | using namespace ::kodi::addon; | ||
| 91 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_width(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 92 | } | ||
| 93 | //-------------------------------------------------------------------------- | ||
| 94 | |||
| 95 | //========================================================================== | ||
| 96 | /// | ||
| 97 | /// \ingroup cpp_kodi_gui | ||
| 98 | /// @brief Return the the current screen rendering resolution | ||
| 99 | /// | ||
| 100 | inline int GetVideoResolution() | ||
| 101 | { | ||
| 102 | using namespace ::kodi::addon; | ||
| 103 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_video_resolution(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 104 | } | ||
| 105 | //-------------------------------------------------------------------------- | ||
| 106 | |||
| 107 | //========================================================================== | ||
| 108 | /// | ||
| 109 | /// \ingroup cpp_kodi_gui | ||
| 110 | /// @brief Returns the id for the current 'active' dialog as an integer. | ||
| 111 | /// | ||
| 112 | /// @return The currently active dialog Id | ||
| 113 | /// | ||
| 114 | /// | ||
| 115 | ///------------------------------------------------------------------------- | ||
| 116 | /// | ||
| 117 | /// **Example:** | ||
| 118 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 119 | /// .. | ||
| 120 | /// int wid = kodi::gui::GetCurrentWindowDialogId() | ||
| 121 | /// .. | ||
| 122 | /// ~~~~~~~~~~~~~ | ||
| 123 | /// | ||
| 124 | inline int GetCurrentWindowDialogId() | ||
| 125 | { | ||
| 126 | using namespace ::kodi::addon; | ||
| 127 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_dialog_id(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 128 | } | ||
| 129 | //-------------------------------------------------------------------------- | ||
| 130 | |||
| 131 | //========================================================================== | ||
| 132 | /// | ||
| 133 | /// \ingroup cpp_kodi_gui | ||
| 134 | /// @brief Returns the id for the current 'active' window as an integer. | ||
| 135 | /// | ||
| 136 | /// @return The currently active window Id | ||
| 137 | /// | ||
| 138 | /// | ||
| 139 | ///------------------------------------------------------------------------- | ||
| 140 | /// | ||
| 141 | /// **Example:** | ||
| 142 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 143 | /// .. | ||
| 144 | /// int wid = kodi::gui::GetCurrentWindowId() | ||
| 145 | /// .. | ||
| 146 | /// ~~~~~~~~~~~~~ | ||
| 147 | /// | ||
| 148 | inline int GetCurrentWindowId() | ||
| 149 | { | ||
| 150 | using namespace ::kodi::addon; | ||
| 151 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_id(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 152 | } | ||
| 153 | //-------------------------------------------------------------------------- | ||
| 154 | |||
| 155 | } /* namespace gui */ | ||
| 156 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h new file mode 100644 index 0000000..a473f28 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h | |||
| @@ -0,0 +1,336 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team Kodi | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "../AddonBase.h" | ||
| 23 | #include "definitions.h" | ||
| 24 | |||
| 25 | #include <memory> | ||
| 26 | |||
| 27 | namespace kodi | ||
| 28 | { | ||
| 29 | namespace gui | ||
| 30 | { | ||
| 31 | |||
| 32 | class CWindow; | ||
| 33 | |||
| 34 | class CAddonGUIControlBase | ||
| 35 | { | ||
| 36 | public: | ||
| 37 | GUIHANDLE GetControlHandle() const { return m_controlHandle; } | ||
| 38 | |||
| 39 | protected: | ||
| 40 | CAddonGUIControlBase(CAddonGUIControlBase* window) | ||
| 41 | : m_controlHandle(nullptr), | ||
| 42 | m_interface(::kodi::addon::CAddonBase::m_interface->toKodi), | ||
| 43 | m_Window(window) {} | ||
| 44 | |||
| 45 | virtual ~CAddonGUIControlBase() = default; | ||
| 46 | |||
| 47 | friend class CWindow; | ||
| 48 | |||
| 49 | GUIHANDLE m_controlHandle; | ||
| 50 | AddonToKodiFuncTable_Addon* m_interface; | ||
| 51 | CAddonGUIControlBase* m_Window; | ||
| 52 | |||
| 53 | private: | ||
| 54 | CAddonGUIControlBase() = delete; | ||
| 55 | CAddonGUIControlBase(const CAddonGUIControlBase&) = delete; | ||
| 56 | CAddonGUIControlBase &operator=(const CAddonGUIControlBase&) = delete; | ||
| 57 | }; | ||
| 58 | |||
| 59 | class CListItem; | ||
| 60 | typedef std::shared_ptr<CListItem> ListItemPtr; | ||
| 61 | |||
| 62 | //============================================================================ | ||
| 63 | /// | ||
| 64 | /// \defgroup cpp_kodi_gui_CListItem List Item | ||
| 65 | /// \ingroup cpp_kodi_gui | ||
| 66 | /// @brief \cpp_class{ kodi::gui::CListItem } | ||
| 67 | /// **Selectable window list item** | ||
| 68 | /// | ||
| 69 | /// The list item control is used for creating item lists in Kodi | ||
| 70 | /// | ||
| 71 | /// The with \ref ListItem.h "#include <kodi/gui/ListItem.h>" given | ||
| 72 | /// class is used to create a item entry for a list on window and to support it's | ||
| 73 | /// control. | ||
| 74 | /// | ||
| 75 | |||
| 76 | //============================================================================ | ||
| 77 | /// | ||
| 78 | /// \defgroup cpp_kodi_gui_CListItem_Defs Definitions, structures and enumerators | ||
| 79 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 80 | /// @brief **Library definition values** | ||
| 81 | /// | ||
| 82 | |||
| 83 | class CListItem : public CAddonGUIControlBase | ||
| 84 | { | ||
| 85 | public: | ||
| 86 | //========================================================================== | ||
| 87 | /// | ||
| 88 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 89 | /// @brief Class constructor with parameters | ||
| 90 | /// | ||
| 91 | /// @param[in] label Item label | ||
| 92 | /// @param[in] label2 Second Item label (if needed) | ||
| 93 | /// @param[in] iconImage Item icon image (if needed) | ||
| 94 | /// @param[in] thumbnailImage Thumbnail Image of item (if needed) | ||
| 95 | /// @param[in] path Path to where item is defined | ||
| 96 | /// | ||
| 97 | CListItem( | ||
| 98 | const std::string& label = "", | ||
| 99 | const std::string& label2 = "", | ||
| 100 | const std::string& iconImage = "", | ||
| 101 | const std::string& thumbnailImage = "", | ||
| 102 | const std::string& path = "") | ||
| 103 | : CAddonGUIControlBase(nullptr) | ||
| 104 | { | ||
| 105 | m_controlHandle = m_interface->kodi_gui->listItem->create(m_interface->kodiBase, label.c_str(), | ||
| 106 | label2.c_str(), iconImage.c_str(), | ||
| 107 | thumbnailImage.c_str(), path.c_str()); | ||
| 108 | } | ||
| 109 | |||
| 110 | /* | ||
| 111 | * Constructor used for parts given by list items from addon window | ||
| 112 | * | ||
| 113 | * Related to call of "ListItemPtr kodi::gui::CWindow::GetListItem(int listPos)" | ||
| 114 | * Not needed for addon development itself | ||
| 115 | */ | ||
| 116 | CListItem(GUIHANDLE listItemHandle) | ||
| 117 | : CAddonGUIControlBase(nullptr) | ||
| 118 | { | ||
| 119 | m_controlHandle = listItemHandle; | ||
| 120 | } | ||
| 121 | |||
| 122 | //========================================================================== | ||
| 123 | /// | ||
| 124 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 125 | /// @brief Class destructor | ||
| 126 | /// | ||
| 127 | virtual ~CListItem() | ||
| 128 | { | ||
| 129 | m_interface->kodi_gui->listItem->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 130 | } | ||
| 131 | //-------------------------------------------------------------------------- | ||
| 132 | |||
| 133 | //========================================================================== | ||
| 134 | /// | ||
| 135 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 136 | /// @brief Returns the listitem label. | ||
| 137 | /// | ||
| 138 | /// @return Label of item | ||
| 139 | /// | ||
| 140 | std::string GetLabel() | ||
| 141 | { | ||
| 142 | std::string label; | ||
| 143 | char* ret = m_interface->kodi_gui->listItem->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 144 | if (ret != nullptr) | ||
| 145 | { | ||
| 146 | if (std::strlen(ret)) | ||
| 147 | label = ret; | ||
| 148 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 149 | } | ||
| 150 | return label; | ||
| 151 | } | ||
| 152 | //-------------------------------------------------------------------------- | ||
| 153 | |||
| 154 | //========================================================================== | ||
| 155 | /// | ||
| 156 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 157 | /// @brief Sets the listitem label. | ||
| 158 | /// | ||
| 159 | /// @param[in] label string or unicode - text string. | ||
| 160 | /// | ||
| 161 | void SetLabel(const std::string& label) | ||
| 162 | { | ||
| 163 | m_interface->kodi_gui->listItem->set_label(m_interface->kodiBase, m_controlHandle, label.c_str()); | ||
| 164 | } | ||
| 165 | //-------------------------------------------------------------------------- | ||
| 166 | |||
| 167 | //========================================================================== | ||
| 168 | /// | ||
| 169 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 170 | /// @brief Returns the second listitem label. | ||
| 171 | /// | ||
| 172 | /// @return Second label of item | ||
| 173 | /// | ||
| 174 | std::string GetLabel2() | ||
| 175 | { | ||
| 176 | std::string label; | ||
| 177 | char* ret = m_interface->kodi_gui->listItem->get_label2(m_interface->kodiBase, m_controlHandle); | ||
| 178 | if (ret != nullptr) | ||
| 179 | { | ||
| 180 | if (std::strlen(ret)) | ||
| 181 | label = ret; | ||
| 182 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 183 | } | ||
| 184 | return label; | ||
| 185 | } | ||
| 186 | //-------------------------------------------------------------------------- | ||
| 187 | |||
| 188 | //========================================================================== | ||
| 189 | /// | ||
| 190 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 191 | /// @brief Sets the listitem's label2. | ||
| 192 | /// | ||
| 193 | /// @param[in] label string or unicode - text string. | ||
| 194 | /// | ||
| 195 | void SetLabel2(const std::string& label) | ||
| 196 | { | ||
| 197 | m_interface->kodi_gui->listItem->set_label2(m_interface->kodiBase, m_controlHandle, label.c_str()); | ||
| 198 | } | ||
| 199 | //-------------------------------------------------------------------------- | ||
| 200 | |||
| 201 | //========================================================================== | ||
| 202 | /// | ||
| 203 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 204 | /// @brief To get current icon image of entry | ||
| 205 | /// | ||
| 206 | /// @return The current icon image path (if present) | ||
| 207 | /// | ||
| 208 | std::string GetIconImage() | ||
| 209 | { | ||
| 210 | std::string image; | ||
| 211 | char* ret = m_interface->kodi_gui->listItem->get_icon_image(m_interface->kodiBase, m_controlHandle); | ||
| 212 | if (ret != nullptr) | ||
| 213 | { | ||
| 214 | if (std::strlen(ret)) | ||
| 215 | image = ret; | ||
| 216 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 217 | } | ||
| 218 | return image; | ||
| 219 | } | ||
| 220 | //-------------------------------------------------------------------------- | ||
| 221 | |||
| 222 | //========================================================================== | ||
| 223 | /// | ||
| 224 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 225 | /// @brief To set icon image of entry | ||
| 226 | /// | ||
| 227 | /// @param image The image to use for. | ||
| 228 | /// | ||
| 229 | /// @note Alternative can be \ref SetArt used | ||
| 230 | /// | ||
| 231 | /// | ||
| 232 | void SetIconImage(const std::string& image) | ||
| 233 | { | ||
| 234 | m_interface->kodi_gui->listItem->set_icon_image(m_interface->kodiBase, m_controlHandle, image.c_str()); | ||
| 235 | } | ||
| 236 | //-------------------------------------------------------------------------- | ||
| 237 | |||
| 238 | //========================================================================== | ||
| 239 | /// | ||
| 240 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 241 | /// @brief Sets the listitem's art | ||
| 242 | /// | ||
| 243 | /// @param[in] type Type of Art to set | ||
| 244 | /// - Some default art values (any string possible): | ||
| 245 | /// | value (type) | Type | | ||
| 246 | /// |:-------------:|:--------------------------------------------------| | ||
| 247 | /// | thumb | string - image filename | ||
| 248 | /// | poster | string - image filename | ||
| 249 | /// | banner | string - image filename | ||
| 250 | /// | fanart | string - image filename | ||
| 251 | /// | clearart | string - image filename | ||
| 252 | /// | clearlogo | string - image filename | ||
| 253 | /// | landscape | string - image filename | ||
| 254 | /// | icon | string - image filename | ||
| 255 | /// @return The url to use for Art | ||
| 256 | /// | ||
| 257 | std::string GetArt(const std::string& type) | ||
| 258 | { | ||
| 259 | std::string strReturn; | ||
| 260 | char* ret = m_interface->kodi_gui->listItem->get_art(m_interface->kodiBase, m_controlHandle, type.c_str()); | ||
| 261 | if (ret != nullptr) | ||
| 262 | { | ||
| 263 | if (std::strlen(ret)) | ||
| 264 | strReturn = ret; | ||
| 265 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 266 | } | ||
| 267 | return strReturn; | ||
| 268 | } | ||
| 269 | //-------------------------------------------------------------------------- | ||
| 270 | |||
| 271 | //========================================================================== | ||
| 272 | /// | ||
| 273 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 274 | /// @brief Sets the listitem's art | ||
| 275 | /// | ||
| 276 | /// @param[in] type Type of Art to set | ||
| 277 | /// @param[in] url The url to use for Art | ||
| 278 | /// - Some default art values (any string possible): | ||
| 279 | /// | value (type) | Type | | ||
| 280 | /// |:-------------:|:--------------------------------------------------| | ||
| 281 | /// | thumb | string - image filename | ||
| 282 | /// | poster | string - image filename | ||
| 283 | /// | banner | string - image filename | ||
| 284 | /// | fanart | string - image filename | ||
| 285 | /// | clearart | string - image filename | ||
| 286 | /// | clearlogo | string - image filename | ||
| 287 | /// | landscape | string - image filename | ||
| 288 | /// | icon | string - image filename | ||
| 289 | /// | ||
| 290 | void SetArt(const std::string& type, const std::string& url) | ||
| 291 | { | ||
| 292 | m_interface->kodi_gui->listItem->set_art(m_interface->kodiBase, m_controlHandle, type.c_str(), url.c_str()); | ||
| 293 | } | ||
| 294 | //-------------------------------------------------------------------------- | ||
| 295 | |||
| 296 | //========================================================================== | ||
| 297 | /// | ||
| 298 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 299 | /// @brief Returns the path / filename of this listitem. | ||
| 300 | /// | ||
| 301 | /// @return Path string | ||
| 302 | /// | ||
| 303 | std::string GetPath() | ||
| 304 | { | ||
| 305 | std::string strReturn; | ||
| 306 | char* ret = m_interface->kodi_gui->listItem->get_path(m_interface->kodiBase, m_controlHandle); | ||
| 307 | if (ret != nullptr) | ||
| 308 | { | ||
| 309 | if (std::strlen(ret)) | ||
| 310 | strReturn = ret; | ||
| 311 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 312 | } | ||
| 313 | return strReturn; | ||
| 314 | } | ||
| 315 | //-------------------------------------------------------------------------- | ||
| 316 | |||
| 317 | //========================================================================== | ||
| 318 | /// | ||
| 319 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 320 | /// @brief Sets the listitem's path. | ||
| 321 | /// | ||
| 322 | /// @param[in] path string or unicode - path, activated when | ||
| 323 | /// item is clicked. | ||
| 324 | /// | ||
| 325 | /// @note You can use the above as keywords for arguments. | ||
| 326 | /// | ||
| 327 | void SetPath(const std::string& path) | ||
| 328 | { | ||
| 329 | m_interface->kodi_gui->listItem->set_path(m_interface->kodiBase, m_controlHandle, path.c_str()); | ||
| 330 | } | ||
| 331 | //-------------------------------------------------------------------------- | ||
| 332 | |||
| 333 | }; | ||
| 334 | |||
| 335 | } /* namespace gui */ | ||
| 336 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h new file mode 100644 index 0000000..7069e63 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h | |||
| @@ -0,0 +1,503 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team Kodi | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "../AddonBase.h" | ||
| 23 | #include "ListItem.h" | ||
| 24 | |||
| 25 | #ifdef BUILD_KODI_ADDON | ||
| 26 | #include "../ActionIDs.h" | ||
| 27 | #else | ||
| 28 | #include "input/ActionIDs.h" | ||
| 29 | #endif | ||
| 30 | |||
| 31 | namespace kodi | ||
| 32 | { | ||
| 33 | namespace gui | ||
| 34 | { | ||
| 35 | |||
| 36 | class CListItem; | ||
| 37 | |||
| 38 | //============================================================================ | ||
| 39 | /// | ||
| 40 | /// \defgroup cpp_kodi_gui_CWindow Window | ||
| 41 | /// \ingroup cpp_kodi_gui | ||
| 42 | /// @brief \cpp_class{ kodi::gui::CWindow } | ||
| 43 | /// **Main window control class** | ||
| 44 | /// | ||
| 45 | /// The with \ref Window.h "#include <kodi/gui/Window.h>" | ||
| 46 | /// included file brings support to create a window or dialog on Kodi. | ||
| 47 | /// | ||
| 48 | /// -------------------------------------------------------------------------- | ||
| 49 | /// | ||
| 50 | /// On functions defined input variable <b><tt>controlId</tt> (GUI control identifier)</b> | ||
| 51 | /// is the on window.xml defined value behind type added with <tt><b>id="..."</b></tt> and | ||
| 52 | /// used to identify for changes there and on callbacks. | ||
| 53 | /// | ||
| 54 | /// ~~~~~~~~~~~~~{.xml} | ||
| 55 | /// <control type="label" id="31"> | ||
| 56 | /// <description>Title Label</description> | ||
| 57 | /// ... | ||
| 58 | /// </control> | ||
| 59 | /// <control type="progress" id="32"> | ||
| 60 | /// <description>progress control</description> | ||
| 61 | /// ... | ||
| 62 | /// </control> | ||
| 63 | /// ~~~~~~~~~~~~~ | ||
| 64 | /// | ||
| 65 | /// | ||
| 66 | |||
| 67 | //============================================================================ | ||
| 68 | /// | ||
| 69 | /// \defgroup cpp_kodi_gui_CWindow_Defs Definitions, structures and enumerators | ||
| 70 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 71 | /// @brief <b>Library definition values</b> | ||
| 72 | /// | ||
| 73 | |||
| 74 | class CWindow : public CAddonGUIControlBase | ||
| 75 | { | ||
| 76 | public: | ||
| 77 | //========================================================================== | ||
| 78 | /// | ||
| 79 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 80 | /// @brief Class constructor with needed values for window / dialog. | ||
| 81 | /// | ||
| 82 | /// Creates a new Window class. | ||
| 83 | /// | ||
| 84 | /// @param[in] xmlFilename XML file for the skin | ||
| 85 | /// @param[in] defaultSkin default skin to use if needed not available | ||
| 86 | /// @param[in] asDialog Use window as dialog if set | ||
| 87 | /// @param[in] isMedia [opt] bool - if False, create a regular window. | ||
| 88 | /// if True, create a mediawindow. | ||
| 89 | /// (default=false) | ||
| 90 | /// @note only usable for windows not for dialogs. | ||
| 91 | /// | ||
| 92 | /// | ||
| 93 | CWindow(const std::string& xmlFilename, const std::string& defaultSkin, bool asDialog, bool isMedia = false) | ||
| 94 | : CAddonGUIControlBase(nullptr) | ||
| 95 | { | ||
| 96 | m_controlHandle = m_interface->kodi_gui->window->create(m_interface->kodiBase, xmlFilename.c_str(), | ||
| 97 | defaultSkin.c_str(), asDialog, isMedia); | ||
| 98 | if (!m_controlHandle) | ||
| 99 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow can't create window class from Kodi !!!"); | ||
| 100 | m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, this, | ||
| 101 | CBOnInit, CBOnFocus, CBOnClick, CBOnAction, | ||
| 102 | CBGetContextButtons, CBOnContextButton); | ||
| 103 | } | ||
| 104 | //-------------------------------------------------------------------------- | ||
| 105 | |||
| 106 | //========================================================================== | ||
| 107 | /// | ||
| 108 | /// \ingroup CWindow | ||
| 109 | /// @brief Class destructor | ||
| 110 | /// | ||
| 111 | /// | ||
| 112 | /// | ||
| 113 | virtual ~CWindow() | ||
| 114 | { | ||
| 115 | if (m_controlHandle) | ||
| 116 | m_interface->kodi_gui->window->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 117 | } | ||
| 118 | //-------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //========================================================================== | ||
| 121 | /// | ||
| 122 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 123 | /// @brief Show this window. | ||
| 124 | /// | ||
| 125 | /// Shows this window by activating it, calling close() after it wil activate the | ||
| 126 | /// current window again. | ||
| 127 | /// | ||
| 128 | /// @note If your Add-On ends this window will be closed to. To show it forever, | ||
| 129 | /// make a loop at the end of your Add-On or use doModal() instead. | ||
| 130 | /// | ||
| 131 | /// @return Return true if call and show is successed, | ||
| 132 | /// if false was something failed to get needed | ||
| 133 | /// skin parts. | ||
| 134 | /// | ||
| 135 | bool Show() | ||
| 136 | { | ||
| 137 | return m_interface->kodi_gui->window->show(m_interface->kodiBase, m_controlHandle); | ||
| 138 | } | ||
| 139 | //-------------------------------------------------------------------------- | ||
| 140 | |||
| 141 | //========================================================================== | ||
| 142 | /// | ||
| 143 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 144 | /// @brief Closes this window. | ||
| 145 | /// | ||
| 146 | /// Closes this window by activating the old window. | ||
| 147 | /// @note The window is not deleted with this method. | ||
| 148 | /// | ||
| 149 | void Close() | ||
| 150 | { | ||
| 151 | m_interface->kodi_gui->window->close(m_interface->kodiBase, m_controlHandle); | ||
| 152 | } | ||
| 153 | //-------------------------------------------------------------------------- | ||
| 154 | |||
| 155 | //========================================================================== | ||
| 156 | /// | ||
| 157 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 158 | /// @brief Display this window until close() is called. | ||
| 159 | /// | ||
| 160 | void DoModal() | ||
| 161 | { | ||
| 162 | m_interface->kodi_gui->window->do_modal(m_interface->kodiBase, m_controlHandle); | ||
| 163 | } | ||
| 164 | //-------------------------------------------------------------------------- | ||
| 165 | |||
| 166 | //========================================================================== | ||
| 167 | /// | ||
| 168 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 169 | /// @brief Function delete all entries in integrated list. | ||
| 170 | /// | ||
| 171 | /// | ||
| 172 | /// | ||
| 173 | void ClearList() | ||
| 174 | { | ||
| 175 | m_interface->kodi_gui->window->clear_item_list(m_interface->kodiBase, m_controlHandle); | ||
| 176 | } | ||
| 177 | //-------------------------------------------------------------------------- | ||
| 178 | |||
| 179 | //========================================================================== | ||
| 180 | /// | ||
| 181 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 182 | /// @brief To add a list item in the on window integrated list. | ||
| 183 | /// | ||
| 184 | /// @param[in] item List item to add | ||
| 185 | /// @param[in] itemPosition [opt] The position for item, default is on end | ||
| 186 | /// | ||
| 187 | /// | ||
| 188 | void AddListItem(ListItemPtr item, int itemPosition = -1) | ||
| 189 | { | ||
| 190 | m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle, item->m_controlHandle, itemPosition); | ||
| 191 | } | ||
| 192 | //-------------------------------------------------------------------------- | ||
| 193 | |||
| 194 | //========================================================================== | ||
| 195 | /// | ||
| 196 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 197 | /// @brief To add a list item based upon string in the on window integrated list. | ||
| 198 | /// | ||
| 199 | /// @param[in] item List item to add | ||
| 200 | /// @param[in] itemPosition [opt] The position for item, default is on end | ||
| 201 | /// | ||
| 202 | /// | ||
| 203 | void AddListItem(const std::string item, int itemPosition = -1) | ||
| 204 | { | ||
| 205 | m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle, std::make_shared<kodi::gui::CListItem>(item)->m_controlHandle, itemPosition); | ||
| 206 | } | ||
| 207 | //-------------------------------------------------------------------------- | ||
| 208 | |||
| 209 | //========================================================================== | ||
| 210 | /// | ||
| 211 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 212 | /// @brief To get list item control class on wanted position. | ||
| 213 | /// | ||
| 214 | /// @param[in] listPos Position from where control is needed | ||
| 215 | /// @return The list item control class or null if not found | ||
| 216 | /// | ||
| 217 | /// @warning Function returns a new generated **CListItem** class! | ||
| 218 | /// | ||
| 219 | ListItemPtr GetListItem(int listPos) | ||
| 220 | { | ||
| 221 | GUIHANDLE handle = m_interface->kodi_gui->window->get_list_item(m_interface->kodiBase, m_controlHandle, listPos); | ||
| 222 | if (!handle) | ||
| 223 | return ListItemPtr(); | ||
| 224 | |||
| 225 | return std::make_shared<kodi::gui::CListItem>(handle); | ||
| 226 | } | ||
| 227 | //-------------------------------------------------------------------------- | ||
| 228 | |||
| 229 | //========================================================================== | ||
| 230 | // | ||
| 231 | /// @defgroup cpp_kodi_gui_CWindow_callbacks Callback functions from Kodi to add-on | ||
| 232 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 233 | //@{ | ||
| 234 | /// @brief <b>GUI window callback functions.</b> | ||
| 235 | /// | ||
| 236 | /// Functions to handle control callbacks from Kodi | ||
| 237 | /// | ||
| 238 | /// ------------------------------------------------------------------------ | ||
| 239 | /// | ||
| 240 | /// @link cpp_kodi_gui_CWindow Go back to normal functions from CWindow@endlink | ||
| 241 | // | ||
| 242 | |||
| 243 | //========================================================================== | ||
| 244 | /// | ||
| 245 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 246 | /// @brief OnInit method. | ||
| 247 | /// | ||
| 248 | /// @return Return true if initialize was done successful | ||
| 249 | /// | ||
| 250 | /// | ||
| 251 | virtual bool OnInit() { return false; } | ||
| 252 | //-------------------------------------------------------------------------- | ||
| 253 | |||
| 254 | //========================================================================== | ||
| 255 | /// | ||
| 256 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 257 | /// @brief OnFocus method. | ||
| 258 | /// | ||
| 259 | /// @param[in] controlId GUI control identifier | ||
| 260 | /// @return Return true if focus condition was handled there or false to handle them by Kodi itself | ||
| 261 | /// | ||
| 262 | /// | ||
| 263 | virtual bool OnFocus(int controlId) { return false; } | ||
| 264 | //-------------------------------------------------------------------------- | ||
| 265 | |||
| 266 | //========================================================================== | ||
| 267 | /// | ||
| 268 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 269 | /// @brief OnClick method. | ||
| 270 | /// | ||
| 271 | /// @param[in] controlId GUI control identifier | ||
| 272 | /// @return Return true if click was handled there | ||
| 273 | /// or false to handle them by Kodi itself | ||
| 274 | /// | ||
| 275 | /// | ||
| 276 | virtual bool OnClick(int controlId) { return false; } | ||
| 277 | //-------------------------------------------------------------------------- | ||
| 278 | |||
| 279 | //========================================================================== | ||
| 280 | /// | ||
| 281 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 282 | /// @brief OnAction method. | ||
| 283 | /// | ||
| 284 | /// @param[in] actionId The action id to perform, see | ||
| 285 | /// \ref kodi_key_action_ids to get list of | ||
| 286 | /// them | ||
| 287 | /// @return Return true if action was handled there | ||
| 288 | /// or false to handle them by Kodi itself | ||
| 289 | /// | ||
| 290 | /// | ||
| 291 | /// This method will receive all actions that the main program will send | ||
| 292 | /// to this window. | ||
| 293 | /// | ||
| 294 | /// @note | ||
| 295 | /// - By default, only the \c PREVIOUS_MENU and \c NAV_BACK actions are handled. | ||
| 296 | /// - Overwrite this method to let your code handle all actions. | ||
| 297 | /// - Don't forget to capture \c ACTION_PREVIOUS_MENU or \c ACTION_NAV_BACK, else the user can't close this window. | ||
| 298 | /// | ||
| 299 | /// | ||
| 300 | ///-------------------------------------------------------------------------- | ||
| 301 | /// | ||
| 302 | /// **Example:** | ||
| 303 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 304 | /// .. | ||
| 305 | /// /* Window used with parent / child way */ | ||
| 306 | /// bool cYOUR_CLASS::OnAction(int actionId) | ||
| 307 | /// { | ||
| 308 | /// switch (action) | ||
| 309 | /// { | ||
| 310 | /// case ACTION_PREVIOUS_MENU: | ||
| 311 | /// case ACTION_NAV_BACK: | ||
| 312 | /// printf("action recieved: previous"); | ||
| 313 | /// Close(); | ||
| 314 | /// return true; | ||
| 315 | /// case ACTION_SHOW_INFO: | ||
| 316 | /// printf("action recieved: show info"); | ||
| 317 | /// break; | ||
| 318 | /// case ACTION_STOP: | ||
| 319 | /// printf("action recieved: stop"); | ||
| 320 | /// break; | ||
| 321 | /// case ACTION_PAUSE: | ||
| 322 | /// printf("action recieved: pause"); | ||
| 323 | /// break; | ||
| 324 | /// default: | ||
| 325 | /// break; | ||
| 326 | /// } | ||
| 327 | /// return false; | ||
| 328 | /// } | ||
| 329 | /// .. | ||
| 330 | /// ~~~~~~~~~~~~~ | ||
| 331 | /// | ||
| 332 | virtual bool OnAction(int actionId) | ||
| 333 | { | ||
| 334 | switch (actionId) | ||
| 335 | { | ||
| 336 | case ACTION_PREVIOUS_MENU: | ||
| 337 | case ACTION_NAV_BACK: | ||
| 338 | Close(); | ||
| 339 | return true; | ||
| 340 | default: | ||
| 341 | break; | ||
| 342 | } | ||
| 343 | return false; | ||
| 344 | } | ||
| 345 | //-------------------------------------------------------------------------- | ||
| 346 | |||
| 347 | //========================================================================== | ||
| 348 | /// | ||
| 349 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 350 | /// @brief Get context menu buttons for list entry | ||
| 351 | /// | ||
| 352 | /// @param[in] itemNumber selected list item entry | ||
| 353 | /// @param[in] buttons list where context menus becomes added with his | ||
| 354 | /// identifier and name. | ||
| 355 | /// | ||
| 356 | virtual void GetContextButtons(int itemNumber, std::vector< std::pair<unsigned int, std::string> > &buttons) | ||
| 357 | { | ||
| 358 | } | ||
| 359 | //-------------------------------------------------------------------------- | ||
| 360 | |||
| 361 | //========================================================================== | ||
| 362 | /// | ||
| 363 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 364 | /// @brief Called after selection in context menu | ||
| 365 | /// | ||
| 366 | /// @param[in] itemNumber selected list item entry | ||
| 367 | /// @param[in] button the pressed button id | ||
| 368 | /// @return true if handled, otherwise false | ||
| 369 | /// | ||
| 370 | virtual bool OnContextButton(int itemNumber, unsigned int button) | ||
| 371 | { | ||
| 372 | return false; | ||
| 373 | } | ||
| 374 | //-------------------------------------------------------------------------- | ||
| 375 | |||
| 376 | //========================================================================== | ||
| 377 | /// | ||
| 378 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 379 | /// @brief **Set independent callbacks** | ||
| 380 | /// | ||
| 381 | /// If the class is used independent (with "new CWindow") and | ||
| 382 | /// not as parent (with "cCLASS_own : CWindow") from own must be the | ||
| 383 | /// callback from Kodi to add-on overdriven with own functions! | ||
| 384 | /// | ||
| 385 | /// @param[in] cbhdl The pointer to own handle data | ||
| 386 | /// structure / class | ||
| 387 | /// @param[in] CBOnInit Own defined window init function | ||
| 388 | /// @param[in] CBOnFocus Own defined focus function | ||
| 389 | /// @param[in] CBOnClick Own defined click function | ||
| 390 | /// @param[in] CBOnAction Own defined action function | ||
| 391 | /// @param[in] CBGetContextButtons [opt] To get context menu entries for | ||
| 392 | /// lists function | ||
| 393 | /// @param[in] CBOnContextButton [opt] Used context menu entry function | ||
| 394 | /// | ||
| 395 | /// | ||
| 396 | ///-------------------------------------------------------------------------- | ||
| 397 | /// | ||
| 398 | /// **Example:** | ||
| 399 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 400 | /// ... | ||
| 401 | /// | ||
| 402 | /// bool OnInit(GUIHANDLE cbhdl) | ||
| 403 | /// { | ||
| 404 | /// ... | ||
| 405 | /// return true; | ||
| 406 | /// } | ||
| 407 | /// | ||
| 408 | /// bool OnFocus(GUIHANDLE cbhdl, int controlId) | ||
| 409 | /// { | ||
| 410 | /// ... | ||
| 411 | /// return true; | ||
| 412 | /// } | ||
| 413 | /// | ||
| 414 | /// bool OnClick(GUIHANDLE cbhdl, int controlId) | ||
| 415 | /// { | ||
| 416 | /// ... | ||
| 417 | /// return true; | ||
| 418 | /// } | ||
| 419 | /// | ||
| 420 | /// bool OnAction(GUIHANDLE cbhdl, int actionId) | ||
| 421 | /// { | ||
| 422 | /// ... | ||
| 423 | /// return true; | ||
| 424 | /// } | ||
| 425 | /// | ||
| 426 | /// ... | ||
| 427 | /// /* Somewhere where you create the window */ | ||
| 428 | /// CWindow myWindow = new CWindow; | ||
| 429 | /// myWindow->SetIndependentCallbacks(myWindow, OnInit, OnFocus, OnClick, OnAction); | ||
| 430 | /// ... | ||
| 431 | /// ~~~~~~~~~~~~~ | ||
| 432 | /// | ||
| 433 | void SetIndependentCallbacks( | ||
| 434 | GUIHANDLE cbhdl, | ||
| 435 | bool (*CBOnInit) (GUIHANDLE cbhdl), | ||
| 436 | bool (*CBOnFocus) (GUIHANDLE cbhdl, int controlId), | ||
| 437 | bool (*CBOnClick) (GUIHANDLE cbhdl, int controlId), | ||
| 438 | bool (*CBOnAction) (GUIHANDLE cbhdl, int actionId), | ||
| 439 | void (*CBGetContextButtons) (GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) = nullptr, | ||
| 440 | bool (*CBOnContextButton) (GUIHANDLE cbhdl, int itemNumber, unsigned int button) = nullptr) | ||
| 441 | { | ||
| 442 | if (!cbhdl || | ||
| 443 | !CBOnInit || !CBOnFocus || !CBOnClick || !CBOnAction) | ||
| 444 | { | ||
| 445 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow::%s called with nullptr !!!", __FUNCTION__); | ||
| 446 | return; | ||
| 447 | } | ||
| 448 | |||
| 449 | m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl, | ||
| 450 | CBOnInit, CBOnFocus, CBOnClick, CBOnAction, | ||
| 451 | CBGetContextButtons, CBOnContextButton); | ||
| 452 | } | ||
| 453 | //-------------------------------------------------------------------------- | ||
| 454 | //@} | ||
| 455 | |||
| 456 | private: | ||
| 457 | static bool CBOnInit(GUIHANDLE cbhdl) | ||
| 458 | { | ||
| 459 | return static_cast<CWindow*>(cbhdl)->OnInit(); | ||
| 460 | } | ||
| 461 | |||
| 462 | static bool CBOnFocus(GUIHANDLE cbhdl, int controlId) | ||
| 463 | { | ||
| 464 | return static_cast<CWindow*>(cbhdl)->OnFocus(controlId); | ||
| 465 | } | ||
| 466 | |||
| 467 | static bool CBOnClick(GUIHANDLE cbhdl, int controlId) | ||
| 468 | { | ||
| 469 | return static_cast<CWindow*>(cbhdl)->OnClick(controlId); | ||
| 470 | } | ||
| 471 | |||
| 472 | static bool CBOnAction(GUIHANDLE cbhdl, int actionId) | ||
| 473 | { | ||
| 474 | return static_cast<CWindow*>(cbhdl)->OnAction(actionId); | ||
| 475 | } | ||
| 476 | |||
| 477 | static void CBGetContextButtons(GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) | ||
| 478 | { | ||
| 479 | std::vector< std::pair<unsigned int, std::string> > buttonList; | ||
| 480 | static_cast<CWindow*>(cbhdl)->GetContextButtons(itemNumber, buttonList); | ||
| 481 | if (!buttonList.empty()) | ||
| 482 | { | ||
| 483 | unsigned int presentSize = buttonList.size(); | ||
| 484 | if (presentSize > *size) | ||
| 485 | kodi::Log(ADDON_LOG_WARNING, "GetContextButtons: More as allowed '%i' entries present!", *size); | ||
| 486 | else | ||
| 487 | *size = presentSize; | ||
| 488 | for (unsigned int i = 0; i < *size; ++i) | ||
| 489 | { | ||
| 490 | buttons[i].id = buttonList[i].first; | ||
| 491 | strncpy(buttons[i].name, buttonList[i].second.c_str(), ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH); | ||
| 492 | } | ||
| 493 | } | ||
| 494 | } | ||
| 495 | |||
| 496 | static bool CBOnContextButton(GUIHANDLE cbhdl, int itemNumber, unsigned int button) | ||
| 497 | { | ||
| 498 | return static_cast<CWindow*>(cbhdl)->OnContextButton(itemNumber, button); | ||
| 499 | } | ||
| 500 | }; | ||
| 501 | |||
| 502 | } /* namespace gui */ | ||
| 503 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h new file mode 100644 index 0000000..a4cf963 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h | |||
| @@ -0,0 +1,209 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <string> | ||
| 23 | #include <time.h> | ||
| 24 | |||
| 25 | /* | ||
| 26 | * Internal Structures to have "C"-Style data transfer | ||
| 27 | */ | ||
| 28 | extern "C" | ||
| 29 | { | ||
| 30 | |||
| 31 | typedef struct AddonToKodiFuncTable_kodi_gui_general | ||
| 32 | { | ||
| 33 | void (*lock)(); | ||
| 34 | void (*unlock)(); | ||
| 35 | int (*get_screen_height)(void* kodiBase); | ||
| 36 | int (*get_screen_width)(void* kodiBase); | ||
| 37 | int (*get_video_resolution)(void* kodiBase); | ||
| 38 | int (*get_current_window_dialog_id)(void* kodiBase); | ||
| 39 | int (*get_current_window_id)(void* kodiBase); | ||
| 40 | } AddonToKodiFuncTable_kodi_gui_general; | ||
| 41 | |||
| 42 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogContextMenu | ||
| 43 | { | ||
| 44 | int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size); | ||
| 45 | } AddonToKodiFuncTable_kodi_gui_dialogContextMenu; | ||
| 46 | |||
| 47 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress | ||
| 48 | { | ||
| 49 | void* (*new_dialog)(void* kodiBase, const char *title); | ||
| 50 | void (*delete_dialog)(void* kodiBase, void* handle); | ||
| 51 | char* (*get_title)(void* kodiBase, void* handle); | ||
| 52 | void (*set_title)(void* kodiBase, void* handle, const char *title); | ||
| 53 | char* (*get_text)(void* kodiBase, void* handle); | ||
| 54 | void (*set_text)(void* kodiBase, void* handle, const char *text); | ||
| 55 | bool (*is_finished)(void* kodiBase, void* handle); | ||
| 56 | void (*mark_finished)(void* kodiBase, void* handle); | ||
| 57 | float (*get_percentage)(void* kodiBase, void* handle); | ||
| 58 | void (*set_percentage)(void* kodiBase, void* handle, float percentage); | ||
| 59 | void (*set_progress)(void* kodiBase, void* handle, int currentItem, int itemCount); | ||
| 60 | } AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress; | ||
| 61 | |||
| 62 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser | ||
| 63 | { | ||
| 64 | bool (*show_and_get_directory)(void* kodiBase, const char* shares, const char* heading, const char* path_in, char** path_out, bool writeOnly); | ||
| 65 | bool (*show_and_get_file)(void* kodiBase, const char* shares, const char* mask, const char* heading, const char* path_in, char** path_out, bool use_thumbs, bool use_file_directories); | ||
| 66 | bool (*show_and_get_file_from_dir)(void* kodiBase, const char* directory, const char* mask, const char* heading, const char* path_in, char** path_out, bool use_thumbs, bool use_file_directories, bool singleList); | ||
| 67 | bool (*show_and_get_file_list)(void* kodiBase, const char* shares, const char* mask, const char* heading, char*** file_list, unsigned int* entries, bool use_thumbs, bool use_file_directories); | ||
| 68 | bool (*show_and_get_source)(void* kodiBase, const char* path_in, char** path_out, bool allow_network_shares, const char* additional_share, const char* type); | ||
| 69 | bool (*show_and_get_image)(void* kodiBase, const char* shares, const char* heading, const char* path_in, char** path_out); | ||
| 70 | bool (*show_and_get_image_list)(void* kodiBase, const char* shares, const char* heading, char*** file_list, unsigned int* entries); | ||
| 71 | void (*clear_file_list)(void* kodiBase, char*** file_list, unsigned int entries); | ||
| 72 | } AddonToKodiFuncTable_kodi_gui_dialogFileBrowser; | ||
| 73 | |||
| 74 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard | ||
| 75 | { | ||
| 76 | bool (*show_and_get_input_with_head)(void* kodiBase, const char* text_in, char** text_out, const char* heading, bool allow_empty_result, bool hiddenInput, unsigned int auto_close_ms); | ||
| 77 | bool (*show_and_get_input)(void* kodiBase, const char* text_in, char** text_out, bool allow_empty_result, unsigned int auto_close_ms); | ||
| 78 | bool (*show_and_get_new_password_with_head)(void* kodiBase, const char* password_in, char** password_out, const char* heading, bool allow_empty_result, unsigned int auto_close_ms); | ||
| 79 | bool (*show_and_get_new_password)(void* kodiBase, const char* password_in, char** password_out, unsigned int auto_close_ms); | ||
| 80 | bool (*show_and_verify_new_password_with_head)(void* kodiBase, char** password_out, const char* heading, bool allow_empty_result, unsigned int auto_close_ms); | ||
| 81 | bool (*show_and_verify_new_password)(void* kodiBase, char** password_out, unsigned int auto_close_ms); | ||
| 82 | int (*show_and_verify_password)(void* kodiBase, const char* password_in, char** password_out, const char* heading, int retries, unsigned int auto_close_ms); | ||
| 83 | bool (*show_and_get_filter)(void* kodiBase, const char* text_in, char** text_out, bool searching, unsigned int auto_close_ms); | ||
| 84 | bool (*send_text_to_active_keyboard)(void* kodiBase, const char* text, bool close_keyboard); | ||
| 85 | bool (*is_keyboard_activated)(void* kodiBase); | ||
| 86 | } AddonToKodiFuncTable_kodi_gui_dialogKeyboard; | ||
| 87 | |||
| 88 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogNumeric | ||
| 89 | { | ||
| 90 | bool (*show_and_verify_new_password)(void* kodiBase, char** password); | ||
| 91 | int (*show_and_verify_password)(void* kodiBase, const char* password, const char *heading, int retries); | ||
| 92 | bool (*show_and_verify_input)(void* kodiBase, const char* verify_in, char** verify_out, const char* heading, bool verify_input); | ||
| 93 | bool (*show_and_get_time)(void* kodiBase, tm *time, const char *heading); | ||
| 94 | bool (*show_and_get_date)(void* kodiBase, tm *date, const char *heading); | ||
| 95 | bool (*show_and_get_ip_address)(void* kodiBase, const char* ip_address_in, char** ip_address_out, const char *heading); | ||
| 96 | bool (*show_and_get_number)(void* kodiBase, const char* input_in, char** input_out, const char *heading, unsigned int auto_close_ms); | ||
| 97 | bool (*show_and_get_seconds)(void* kodiBase, const char* time_in, char** time_out, const char *heading); | ||
| 98 | } AddonToKodiFuncTable_kodi_gui_dialogNumeric; | ||
| 99 | |||
| 100 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogOK | ||
| 101 | { | ||
| 102 | void (*show_and_get_input_single_text)(void* kodiBase, const char *heading, const char *text); | ||
| 103 | void (*show_and_get_input_line_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2); | ||
| 104 | } AddonToKodiFuncTable_kodi_gui_dialogOK; | ||
| 105 | |||
| 106 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogProgress | ||
| 107 | { | ||
| 108 | void* (*new_dialog)(void* kodiBase); | ||
| 109 | void (*delete_dialog)(void* kodiBase, void* handle); | ||
| 110 | void (*open)(void* kodiBase, void* handle); | ||
| 111 | void (*set_heading)(void* kodiBase, void* handle, const char* heading); | ||
| 112 | void (*set_line)(void* kodiBase, void* handle, unsigned int lineNo, const char* line); | ||
| 113 | void (*set_can_cancel)(void* kodiBase, void* handle, bool canCancel); | ||
| 114 | bool (*is_canceled)(void* kodiBase, void* handle); | ||
| 115 | void (*set_percentage)(void* kodiBase, void* handle, int percentage); | ||
| 116 | int (*get_percentage)(void* kodiBase, void* handle); | ||
| 117 | void (*show_progress_bar)(void* kodiBase, void* handle, bool pnOff); | ||
| 118 | void (*set_progress_max)(void* kodiBase, void* handle, int max); | ||
| 119 | void (*set_progress_advance)(void* kodiBase, void* handle, int nSteps); | ||
| 120 | bool (*abort)(void* kodiBase, void* handle); | ||
| 121 | } AddonToKodiFuncTable_kodi_gui_dialogProgress; | ||
| 122 | |||
| 123 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogSelect | ||
| 124 | { | ||
| 125 | int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size, int selected, bool autoclose); | ||
| 126 | } AddonToKodiFuncTable_kodi_gui_dialogSelect; | ||
| 127 | |||
| 128 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogTextViewer | ||
| 129 | { | ||
| 130 | void (*open)(void* kodiBase, const char *heading, const char *text); | ||
| 131 | } AddonToKodiFuncTable_kodi_gui_dialogTextViewer; | ||
| 132 | |||
| 133 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogYesNo | ||
| 134 | { | ||
| 135 | bool (*show_and_get_input_single_text)(void* kodiBase, const char *heading, const char *text, bool *canceled, const char *noLabel, const char *yesLabel); | ||
| 136 | bool (*show_and_get_input_line_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel); | ||
| 137 | bool (*show_and_get_input_line_button_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2, bool *canceled, const char *noLabel, const char *yesLabel); | ||
| 138 | } AddonToKodiFuncTable_kodi_gui_dialogYesNo; | ||
| 139 | |||
| 140 | typedef struct AddonToKodiFuncTable_kodi_gui_listItem | ||
| 141 | { | ||
| 142 | void* (*create)(void* kodiBase, const char* label, const char* label2, const char* icon_image, const char* thumbnail_image, const char* path); | ||
| 143 | void (*destroy)(void* kodiBase, void* handle); | ||
| 144 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 145 | void (*set_label)(void* kodiBase, void* handle, const char* label); | ||
| 146 | char* (*get_label2)(void* kodiBase, void* handle); | ||
| 147 | void (*set_label2)(void* kodiBase, void* handle, const char* label); | ||
| 148 | char* (*get_icon_image)(void* kodiBase, void* handle); | ||
| 149 | void (*set_icon_image)(void* kodiBase, void* handle, const char* image); | ||
| 150 | char* (*get_art)(void* kodiBase, void* handle, const char* type); | ||
| 151 | void (*set_art)(void* kodiBase, void* handle, const char* type, const char* image); | ||
| 152 | char* (*get_path)(void* kodiBase, void* handle); | ||
| 153 | void (*set_path)(void* kodiBase, void* handle, const char* path); | ||
| 154 | } AddonToKodiFuncTable_kodi_gui_listItem; | ||
| 155 | |||
| 156 | #define ADDON_MAX_CONTEXT_ENTRIES 20 | ||
| 157 | #define ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH 80 | ||
| 158 | typedef struct gui_context_menu_pair | ||
| 159 | { | ||
| 160 | unsigned int id; | ||
| 161 | char name[ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH]; | ||
| 162 | } gui_context_menu_pair; | ||
| 163 | |||
| 164 | typedef struct AddonToKodiFuncTable_kodi_gui_window | ||
| 165 | { | ||
| 166 | void* (*create)(void* kodiBase, const char* xml_filename, const char* default_skin, bool as_dialog, bool is_media); | ||
| 167 | void (*destroy)(void* kodiBase, void* handle); | ||
| 168 | void (*set_callbacks)(void* kodiBase, void* handle, void* clienthandle, | ||
| 169 | bool (*)(void* handle), | ||
| 170 | bool (*)(void* handle, int), | ||
| 171 | bool (*)(void* handle, int), | ||
| 172 | bool (*)(void* handle, int), | ||
| 173 | void (*)(void* handle, int, gui_context_menu_pair*, unsigned int*), | ||
| 174 | bool (*)(void* handle, int, unsigned int)); | ||
| 175 | bool (*show)(void* kodiBase, void* handle); | ||
| 176 | bool (*close)(void* kodiBase, void* handle); | ||
| 177 | bool (*do_modal)(void* kodiBase, void* handle); | ||
| 178 | void (*clear_item_list)(void* kodiBase, void* handle); | ||
| 179 | void (*add_list_item)(void* kodiBase, void* handle, void* item, int item_position); | ||
| 180 | void* (*get_list_item)(void* kodiBase, void* handle, int listPos); | ||
| 181 | } AddonToKodiFuncTable_kodi_gui_window; | ||
| 182 | |||
| 183 | typedef struct AddonToKodiFuncTable_kodi_gui | ||
| 184 | { | ||
| 185 | AddonToKodiFuncTable_kodi_gui_general* general; | ||
| 186 | AddonToKodiFuncTable_kodi_gui_dialogContextMenu* dialogContextMenu; | ||
| 187 | AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress* dialogExtendedProgress; | ||
| 188 | AddonToKodiFuncTable_kodi_gui_dialogFileBrowser* dialogFileBrowser; | ||
| 189 | AddonToKodiFuncTable_kodi_gui_dialogKeyboard* dialogKeyboard; | ||
| 190 | AddonToKodiFuncTable_kodi_gui_dialogNumeric* dialogNumeric; | ||
| 191 | AddonToKodiFuncTable_kodi_gui_dialogOK* dialogOK; | ||
| 192 | AddonToKodiFuncTable_kodi_gui_dialogProgress* dialogProgress; | ||
| 193 | AddonToKodiFuncTable_kodi_gui_dialogSelect* dialogSelect; | ||
| 194 | AddonToKodiFuncTable_kodi_gui_dialogTextViewer* dialogTextViewer; | ||
| 195 | AddonToKodiFuncTable_kodi_gui_dialogYesNo* dialogYesNo; | ||
| 196 | AddonToKodiFuncTable_kodi_gui_listItem* listItem; | ||
| 197 | AddonToKodiFuncTable_kodi_gui_window* window; | ||
| 198 | } AddonToKodiFuncTable_kodi_gui; | ||
| 199 | |||
| 200 | } /* extern "C" */ | ||
| 201 | |||
| 202 | //============================================================================ | ||
| 203 | /// | ||
| 204 | /// \ingroup cpp_kodi_gui_CControlRendering_Defs cpp_kodi_gui_CWindow_Defs | ||
| 205 | /// @{ | ||
| 206 | /// @brief Handle to use as independent pointer for GUI | ||
| 207 | typedef void* GUIHANDLE; | ||
| 208 | /// @} | ||
| 209 | //---------------------------------------------------------------------------- | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_dll.h index c1d8238..b0ecb8b 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_dll.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_dll.h | |||
| @@ -49,7 +49,7 @@ | |||
| 49 | * to his type) about his given sample rate. | 49 | * to his type) about his given sample rate. |
| 50 | * - About the from user selected master processing mode the related addon | 50 | * - About the from user selected master processing mode the related addon |
| 51 | * becomes called now with MasterProcessSetMode(...) to handle it's | 51 | * becomes called now with MasterProcessSetMode(...) to handle it's |
| 52 | * selectionon the addon given by the own addon type identifier or by | 52 | * selection on the addon given by the own addon type identifier or by |
| 53 | * KODI's useddatabase id, also the currently used stream type (e.g. | 53 | * KODI's useddatabase id, also the currently used stream type (e.g. |
| 54 | * Music or Video) is send. | 54 | * Music or Video) is send. |
| 55 | * - If the addon supports only one master mode it can ignore this function | 55 | * - If the addon supports only one master mode it can ignore this function |
| @@ -97,39 +97,6 @@ extern "C" | |||
| 97 | /*! @name Audio DSP add-on methods */ | 97 | /*! @name Audio DSP add-on methods */ |
| 98 | //@{ | 98 | //@{ |
| 99 | /*! | 99 | /*! |
| 100 | * Get the KODI_AE_DSP_API_VERSION that was used to compile this add-on. | ||
| 101 | * Used to check if this add-on is compatible with KODI. | ||
| 102 | * @return The KODI_AE_DSP_API_VERSION that was used to compile this add-on. | ||
| 103 | * @remarks Valid implementation required. | ||
| 104 | */ | ||
| 105 | const char* GetAudioDSPAPIVersion(void); | ||
| 106 | |||
| 107 | /*! | ||
| 108 | * Get the KODI_AE_DSP_MIN_API_VERSION that was used to compile this add-on. | ||
| 109 | * Used to check if this add-on is compatible with KODI. | ||
| 110 | * @return The KODI_AE_DSP_MIN_API_VERSION that was used to compile this add-on. | ||
| 111 | * @remarks Valid implementation required. | ||
| 112 | */ | ||
| 113 | const char* GetMinimumAudioDSPAPIVersion(void); | ||
| 114 | |||
| 115 | /*! | ||
| 116 | * @brief Get the KODI_GUI_API_VERSION that was used to compile this add-on. | ||
| 117 | * Used to check if this add-on is compatible with KODI. | ||
| 118 | * @return The KODI_GUI_API_VERSION that was used to compile this add-on. | ||
| 119 | * @remarks Valid implementation required. | ||
| 120 | */ | ||
| 121 | const char* GetGUIAPIVersion(void); | ||
| 122 | |||
| 123 | /*! | ||
| 124 | * @brief Get the KODI_GUI_MIN_API_VERSION that was used to compile this | ||
| 125 | * add-on. | ||
| 126 | * Used to check if this add-on is compatible with KODI. | ||
| 127 | * @return The KODI_GUI_MIN_API_VERSION that was used to compile this add-on. | ||
| 128 | * @remarks Valid implementation required. | ||
| 129 | */ | ||
| 130 | const char* GetMinimumGUIAPIVersion(void); | ||
| 131 | |||
| 132 | /*! | ||
| 133 | * @brief Get the list of features that this add-on provides. | 100 | * @brief Get the list of features that this add-on provides. |
| 134 | * Called by KODI to query the add-ons capabilities. | 101 | * Called by KODI to query the add-ons capabilities. |
| 135 | * Used to check which options should be presented in the DSP, which methods | 102 | * Used to check which options should be presented in the DSP, which methods |
| @@ -179,7 +146,7 @@ extern "C" | |||
| 179 | * surround upmix not needed on 5.1 audio stream. | 146 | * surround upmix not needed on 5.1 audio stream. |
| 180 | * @param addonSettings The add-ons audio settings. | 147 | * @param addonSettings The add-ons audio settings. |
| 181 | * @param pProperties The properties of the currently playing stream. | 148 | * @param pProperties The properties of the currently playing stream. |
| 182 | * @param handle On this becomes addon informated about stream id and can set function addresses which need on calls | 149 | * @param handle On this becomes addon informed about stream id and can set function addresses which need on calls |
| 183 | * @return AE_DSP_ERROR_NO_ERROR if the properties were fetched successfully | 150 | * @return AE_DSP_ERROR_NO_ERROR if the properties were fetched successfully |
| 184 | * and data can be performed. AE_DSP_ERROR_IGNORE_ME if format is not | 151 | * and data can be performed. AE_DSP_ERROR_IGNORE_ME if format is not |
| 185 | * supported, but without fault. | 152 | * supported, but without fault. |
| @@ -517,12 +484,10 @@ extern "C" | |||
| 517 | //@} | 484 | //@} |
| 518 | 485 | ||
| 519 | // function to export the above structure to KODI | 486 | // function to export the above structure to KODI |
| 520 | void __declspec(dllexport) get_addon(struct AudioDSP* pDSP) | 487 | void __declspec(dllexport) get_addon(void* ptr) |
| 521 | { | 488 | { |
| 522 | pDSP->GetAudioDSPAPIVersion = GetAudioDSPAPIVersion; | 489 | KodiToAddonFuncTable_AudioDSP* pDSP = static_cast<KodiToAddonFuncTable_AudioDSP*>(ptr); |
| 523 | pDSP->GetMinimumAudioDSPAPIVersion = GetMinimumAudioDSPAPIVersion; | 490 | |
| 524 | pDSP->GetGUIAPIVersion = GetGUIAPIVersion; | ||
| 525 | pDSP->GetMinimumGUIAPIVersion = GetMinimumGUIAPIVersion; | ||
| 526 | pDSP->GetAddonCapabilities = GetAddonCapabilities; | 491 | pDSP->GetAddonCapabilities = GetAddonCapabilities; |
| 527 | pDSP->GetDSPName = GetDSPName; | 492 | pDSP->GetDSPName = GetDSPName; |
| 528 | pDSP->GetDSPVersion = GetDSPVersion; | 493 | pDSP->GetDSPVersion = GetDSPVersion; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_types.h index 6e492c8..7dc7ae8 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_types.h | |||
| @@ -24,9 +24,7 @@ | |||
| 24 | * Common data structures shared between KODI and KODI's audio DSP add-ons | 24 | * Common data structures shared between KODI and KODI's audio DSP add-ons |
| 25 | */ | 25 | */ |
| 26 | 26 | ||
| 27 | #ifdef TARGET_WINDOWS | 27 | #ifndef TARGET_WINDOWS |
| 28 | #include <windows.h> | ||
| 29 | #else | ||
| 30 | #ifndef __cdecl | 28 | #ifndef __cdecl |
| 31 | #define __cdecl | 29 | #define __cdecl |
| 32 | #endif | 30 | #endif |
| @@ -38,7 +36,6 @@ | |||
| 38 | #include <cstddef> | 36 | #include <cstddef> |
| 39 | 37 | ||
| 40 | #include "xbmc_addon_types.h" | 38 | #include "xbmc_addon_types.h" |
| 41 | #include "xbmc_codec_types.h" | ||
| 42 | 39 | ||
| 43 | #undef ATTRIBUTE_PACKED | 40 | #undef ATTRIBUTE_PACKED |
| 44 | #undef PRAGMA_PACK_BEGIN | 41 | #undef PRAGMA_PACK_BEGIN |
| @@ -61,16 +58,11 @@ | |||
| 61 | #define AE_DSP_STREAM_MAX_STREAMS 8 | 58 | #define AE_DSP_STREAM_MAX_STREAMS 8 |
| 62 | #define AE_DSP_STREAM_MAX_MODES 32 | 59 | #define AE_DSP_STREAM_MAX_MODES 32 |
| 63 | 60 | ||
| 64 | /* current Audio DSP API version */ | ||
| 65 | #define KODI_AE_DSP_API_VERSION "0.1.8" | ||
| 66 | |||
| 67 | /* min. Audio DSP API version */ | ||
| 68 | #define KODI_AE_DSP_MIN_API_VERSION "0.1.8" | ||
| 69 | |||
| 70 | #ifdef __cplusplus | 61 | #ifdef __cplusplus |
| 71 | extern "C" { | 62 | extern "C" { |
| 72 | #endif | 63 | #endif |
| 73 | 64 | ||
| 65 | typedef void* ADSPHANDLE; | ||
| 74 | typedef unsigned int AE_DSP_STREAM_ID; | 66 | typedef unsigned int AE_DSP_STREAM_ID; |
| 75 | 67 | ||
| 76 | /*! | 68 | /*! |
| @@ -261,15 +253,6 @@ extern "C" { | |||
| 261 | } ATTRIBUTE_PACKED AE_DSP_MENUHOOK; | 253 | } ATTRIBUTE_PACKED AE_DSP_MENUHOOK; |
| 262 | 254 | ||
| 263 | /*! | 255 | /*! |
| 264 | * @brief Properties passed to the Create() method of an add-on. | ||
| 265 | */ | ||
| 266 | typedef struct AE_DSP_PROPERTIES | ||
| 267 | { | ||
| 268 | const char* strUserPath; /*!< @brief path to the user profile */ | ||
| 269 | const char* strAddonPath; /*!< @brief path to this add-on */ | ||
| 270 | } AE_DSP_PROPERTIES; | ||
| 271 | |||
| 272 | /*! | ||
| 273 | * @brief Audio DSP add-on capabilities. All capabilities are set to "false" as default. | 256 | * @brief Audio DSP add-on capabilities. All capabilities are set to "false" as default. |
| 274 | * If a capability is set to true, then the corresponding methods from kodi_audiodsp_dll.h need to be implemented. | 257 | * If a capability is set to true, then the corresponding methods from kodi_audiodsp_dll.h need to be implemented. |
| 275 | */ | 258 | */ |
| @@ -442,7 +425,7 @@ extern "C" { | |||
| 442 | struct AE_DSP_MODE | 425 | struct AE_DSP_MODE |
| 443 | { | 426 | { |
| 444 | int iUniqueDBModeId; /*!< @brief (required) the inside add-on used identifier for the mode, set by KODI's audio DSP database */ | 427 | int iUniqueDBModeId; /*!< @brief (required) the inside add-on used identifier for the mode, set by KODI's audio DSP database */ |
| 445 | AE_DSP_MODE_TYPE iModeType; /*!< @brief (required) the processong mode type, see AE_DSP_MODE_TYPE */ | 428 | AE_DSP_MODE_TYPE iModeType; /*!< @brief (required) the processing mode type, see AE_DSP_MODE_TYPE */ |
| 446 | char strModeName[AE_DSP_ADDON_STRING_LENGTH]; /*!< @brief (required) the addon name of the mode, used on KODI's logs */ | 429 | char strModeName[AE_DSP_ADDON_STRING_LENGTH]; /*!< @brief (required) the addon name of the mode, used on KODI's logs */ |
| 447 | 430 | ||
| 448 | unsigned int iModeNumber; /*!< @brief (required) number of this mode on the add-on, is used on process functions with value "mode_id" */ | 431 | unsigned int iModeNumber; /*!< @brief (required) number of this mode on the add-on, is used on process functions with value "mode_id" */ |
| @@ -474,7 +457,36 @@ extern "C" { | |||
| 474 | /*! | 457 | /*! |
| 475 | * @brief Structure to transfer the methods from kodi_audiodsp_dll.h to KODI | 458 | * @brief Structure to transfer the methods from kodi_audiodsp_dll.h to KODI |
| 476 | */ | 459 | */ |
| 477 | struct AudioDSP | 460 | |
| 461 | typedef struct AddonProps_AudioDSP | ||
| 462 | { | ||
| 463 | const char* strUserPath; /*!< @brief path to the user profile */ | ||
| 464 | const char* strAddonPath; /*!< @brief path to this add-on */ | ||
| 465 | } AddonProps_AudioDSP; | ||
| 466 | |||
| 467 | typedef AddonProps_AudioDSP AE_DSP_PROPERTIES; | ||
| 468 | |||
| 469 | typedef struct AddonToKodiFuncTable_AudioDSP | ||
| 470 | { | ||
| 471 | KODI_HANDLE kodiInstance; | ||
| 472 | |||
| 473 | void (*AddMenuHook)(void* kodiInstance, AE_DSP_MENUHOOK *hook); | ||
| 474 | void (*RemoveMenuHook)(void* kodiInstance, AE_DSP_MENUHOOK *hook); | ||
| 475 | void (*RegisterMode)(void* kodiInstance, AE_DSP_MODES::AE_DSP_MODE *mode); | ||
| 476 | void (*UnregisterMode)(void* kodiInstance, AE_DSP_MODES::AE_DSP_MODE *mode); | ||
| 477 | |||
| 478 | ADSPHANDLE (*SoundPlay_GetHandle)(void* kodiInstance, const char *filename); | ||
| 479 | void (*SoundPlay_ReleaseHandle)(void* kodiInstance, ADSPHANDLE handle); | ||
| 480 | void (*SoundPlay_Play)(void* kodiInstance, ADSPHANDLE handle); | ||
| 481 | void (*SoundPlay_Stop)(void* kodiInstance, ADSPHANDLE handle); | ||
| 482 | bool (*SoundPlay_IsPlaying)(void* kodiInstance, ADSPHANDLE handle); | ||
| 483 | void (*SoundPlay_SetChannel)(void* kodiInstance, ADSPHANDLE handle, AE_DSP_CHANNEL channel); | ||
| 484 | AE_DSP_CHANNEL (*SoundPlay_GetChannel)(void* kodiInstance, ADSPHANDLE handle); | ||
| 485 | void (*SoundPlay_SetVolume)(void* kodiInstance, ADSPHANDLE handle, float volume); | ||
| 486 | float (*SoundPlay_GetVolume)(void* kodiInstance, ADSPHANDLE handle); | ||
| 487 | } AddonToKodiFuncTable_AudioDSP; | ||
| 488 | |||
| 489 | typedef struct KodiToAddonFuncTable_AudioDSP | ||
| 478 | { | 490 | { |
| 479 | const char* (__cdecl* GetAudioDSPAPIVersion) (void); | 491 | const char* (__cdecl* GetAudioDSPAPIVersion) (void); |
| 480 | const char* (__cdecl* GetMinimumAudioDSPAPIVersion) (void); | 492 | const char* (__cdecl* GetMinimumAudioDSPAPIVersion) (void); |
| @@ -516,7 +528,14 @@ extern "C" { | |||
| 516 | unsigned int (__cdecl* OutputResampleProcess) (const ADDON_HANDLE, float**, float**, unsigned int); | 528 | unsigned int (__cdecl* OutputResampleProcess) (const ADDON_HANDLE, float**, float**, unsigned int); |
| 517 | float (__cdecl* OutputResampleGetDelay) (const ADDON_HANDLE); | 529 | float (__cdecl* OutputResampleGetDelay) (const ADDON_HANDLE); |
| 518 | int (__cdecl* OutputResampleSampleRate) (const ADDON_HANDLE); | 530 | int (__cdecl* OutputResampleSampleRate) (const ADDON_HANDLE); |
| 519 | }; | 531 | } KodiToAddonFuncTable_AudioDSP; |
| 532 | |||
| 533 | typedef struct AddonInstance_AudioDSP | ||
| 534 | { | ||
| 535 | AddonProps_AudioDSP props; | ||
| 536 | AddonToKodiFuncTable_AudioDSP toKodi; | ||
| 537 | KodiToAddonFuncTable_AudioDSP toAddon; | ||
| 538 | } AddonInstance_AudioDSP; | ||
| 520 | 539 | ||
| 521 | #ifdef __cplusplus | 540 | #ifdef __cplusplus |
| 522 | } | 541 | } |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_dll.h index 78bc3cc..5232947 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_dll.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_dll.h | |||
| @@ -48,13 +48,15 @@ extern "C" | |||
| 48 | bool DeInit(void* context); | 48 | bool DeInit(void* context); |
| 49 | 49 | ||
| 50 | // function to export the above structure to XBMC | 50 | // function to export the above structure to XBMC |
| 51 | void __declspec(dllexport) get_addon(struct AudioDecoder* pScr) | 51 | void __declspec(dllexport) get_addon(void* ptr) |
| 52 | { | 52 | { |
| 53 | pScr->Init = Init; | 53 | AddonInstance_AudioDecoder* pScr = static_cast<AddonInstance_AudioDecoder*>(ptr); |
| 54 | pScr->ReadPCM = ReadPCM; | 54 | |
| 55 | pScr->Seek = Seek; | 55 | pScr->toAddon.Init = Init; |
| 56 | pScr->ReadTag = ReadTag; | 56 | pScr->toAddon.ReadPCM = ReadPCM; |
| 57 | pScr->TrackCount = TrackCount; | 57 | pScr->toAddon.Seek = Seek; |
| 58 | pScr->DeInit = DeInit; | 58 | pScr->toAddon.ReadTag = ReadTag; |
| 59 | pScr->toAddon.TrackCount = TrackCount; | ||
| 60 | pScr->toAddon.DeInit = DeInit; | ||
| 59 | }; | 61 | }; |
| 60 | }; | 62 | }; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_types.h index 82d71e5..6820b91 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_types.h | |||
| @@ -34,12 +34,17 @@ extern "C" | |||
| 34 | int dummy; | 34 | int dummy; |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | struct AUDIODEC_PROPS | 37 | typedef struct AddonProps_AudioDecoder |
| 38 | { | 38 | { |
| 39 | int dummy; | 39 | const char* mimetype; |
| 40 | }; | 40 | } AddonProps_AudioDecoder; |
| 41 | |||
| 42 | typedef struct AddonToKodiFuncTable_AudioDecoder | ||
| 43 | { | ||
| 44 | KODI_HANDLE kodiInstance; | ||
| 45 | } AddonToKodiFuncTable_AudioDecoder; | ||
| 41 | 46 | ||
| 42 | struct AudioDecoder | 47 | typedef struct KodiToAddonFuncTable_AudioDecoder |
| 43 | { | 48 | { |
| 44 | //! \brief Initialize a decoder | 49 | //! \brief Initialize a decoder |
| 45 | //! \param file The file to read | 50 | //! \param file The file to read |
| @@ -97,5 +102,12 @@ extern "C" | |||
| 97 | //! \return True on success, false on failure | 102 | //! \return True on success, false on failure |
| 98 | //! \sa ICodec::DeInit | 103 | //! \sa ICodec::DeInit |
| 99 | bool (__cdecl* DeInit)(void* context); | 104 | bool (__cdecl* DeInit)(void* context); |
| 100 | }; | 105 | } KodiToAddonFuncTable_AudioDecoder; |
| 106 | |||
| 107 | typedef struct AddonInstance_AudioDecoder | ||
| 108 | { | ||
| 109 | AddonProps_AudioDecoder props; | ||
| 110 | AddonToKodiFuncTable_AudioDecoder toKodi; | ||
| 111 | KodiToAddonFuncTable_AudioDecoder toAddon; | ||
| 112 | } AddonInstance_AudioDecoder; | ||
| 101 | } | 113 | } |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audioengine_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audioengine_types.h deleted file mode 100644 index 0402ace..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audioengine_types.h +++ /dev/null | |||
| @@ -1,165 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (C) 2005-2015 Team Kodi | ||
| 5 | * http://kodi.tv | ||
| 6 | * | ||
| 7 | * This Program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 10 | * any later version. | ||
| 11 | * | ||
| 12 | * This Program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with Kodi; see the file COPYING. If not, see | ||
| 19 | * <http://www.gnu.org/licenses/>. | ||
| 20 | * | ||
| 21 | */ | ||
| 22 | |||
| 23 | /*! | ||
| 24 | * Common data structures shared between KODI and KODI's binary add-ons | ||
| 25 | */ | ||
| 26 | |||
| 27 | #ifdef BUILD_KODI_ADDON | ||
| 28 | #include "kodi/AudioEngine/AEChannelInfo.h" | ||
| 29 | #else | ||
| 30 | #include "cores/AudioEngine/Utils/AEChannelInfo.h" | ||
| 31 | #endif | ||
| 32 | |||
| 33 | #ifdef TARGET_WINDOWS | ||
| 34 | #include <windows.h> | ||
| 35 | #else | ||
| 36 | #ifndef __cdecl | ||
| 37 | #define __cdecl | ||
| 38 | #endif | ||
| 39 | #ifndef __declspec | ||
| 40 | #define __declspec(X) | ||
| 41 | #endif | ||
| 42 | #endif | ||
| 43 | |||
| 44 | #include <cstddef> | ||
| 45 | |||
| 46 | #undef ATTRIBUTE_PACKED | ||
| 47 | #undef PRAGMA_PACK_BEGIN | ||
| 48 | #undef PRAGMA_PACK_END | ||
| 49 | |||
| 50 | #if defined(__GNUC__) | ||
| 51 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) | ||
| 52 | #define ATTRIBUTE_PACKED __attribute__ ((packed)) | ||
| 53 | #define PRAGMA_PACK 0 | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if !defined(ATTRIBUTE_PACKED) | ||
| 58 | #define ATTRIBUTE_PACKED | ||
| 59 | #define PRAGMA_PACK 1 | ||
| 60 | #endif | ||
| 61 | |||
| 62 | /* current Audio DSP API version */ | ||
| 63 | #define KODI_AUDIOENGINE_API_VERSION "0.0.1" | ||
| 64 | |||
| 65 | /* min. Audio DSP API version */ | ||
| 66 | #define KODI_AUDIOENGINE_MIN_API_VERSION "0.0.1" | ||
| 67 | |||
| 68 | |||
| 69 | #ifdef __cplusplus | ||
| 70 | extern "C" { | ||
| 71 | #endif | ||
| 72 | |||
| 73 | /** | ||
| 74 | * A stream handle pointer, which is only used internally by the addon stream handle | ||
| 75 | */ | ||
| 76 | typedef void AEStreamHandle; | ||
| 77 | |||
| 78 | /** | ||
| 79 | * The audio format structure that fully defines a stream's audio information | ||
| 80 | */ | ||
| 81 | typedef struct AudioEngineFormat | ||
| 82 | { | ||
| 83 | /** | ||
| 84 | * The stream's data format (eg, AE_FMT_S16LE) | ||
| 85 | */ | ||
| 86 | enum AEDataFormat m_dataFormat; | ||
| 87 | |||
| 88 | /** | ||
| 89 | * The stream's sample rate (eg, 48000) | ||
| 90 | */ | ||
| 91 | unsigned int m_sampleRate; | ||
| 92 | |||
| 93 | /** | ||
| 94 | * The encoded streams sample rate if a bitstream, otherwise undefined | ||
| 95 | */ | ||
| 96 | unsigned int m_encodedRate; | ||
| 97 | |||
| 98 | /** | ||
| 99 | * The amount of used speaker channels | ||
| 100 | */ | ||
| 101 | unsigned int m_channelCount; | ||
| 102 | |||
| 103 | /** | ||
| 104 | * The stream's channel layout | ||
| 105 | */ | ||
| 106 | enum AEChannel m_channels[AE_CH_MAX]; | ||
| 107 | |||
| 108 | /** | ||
| 109 | * The number of frames per period | ||
| 110 | */ | ||
| 111 | unsigned int m_frames; | ||
| 112 | |||
| 113 | /** | ||
| 114 | * The size of one frame in bytes | ||
| 115 | */ | ||
| 116 | unsigned int m_frameSize; | ||
| 117 | |||
| 118 | AudioEngineFormat() | ||
| 119 | { | ||
| 120 | m_dataFormat = AE_FMT_INVALID; | ||
| 121 | m_sampleRate = 0; | ||
| 122 | m_encodedRate = 0; | ||
| 123 | m_frames = 0; | ||
| 124 | m_frameSize = 0; | ||
| 125 | m_channelCount = 0; | ||
| 126 | |||
| 127 | for (unsigned int ch = 0; ch < AE_CH_MAX; ch++) | ||
| 128 | { | ||
| 129 | m_channels[ch] = AE_CH_NULL; | ||
| 130 | } | ||
| 131 | } | ||
| 132 | |||
| 133 | bool compareFormat(const AudioEngineFormat *fmt) | ||
| 134 | { | ||
| 135 | if (!fmt) | ||
| 136 | { | ||
| 137 | return false; | ||
| 138 | } | ||
| 139 | |||
| 140 | if (m_dataFormat != fmt->m_dataFormat || | ||
| 141 | m_sampleRate != fmt->m_sampleRate || | ||
| 142 | m_encodedRate != fmt->m_encodedRate || | ||
| 143 | m_frames != fmt->m_frames || | ||
| 144 | m_frameSize != fmt->m_frameSize || | ||
| 145 | m_channelCount != fmt->m_channelCount) | ||
| 146 | { | ||
| 147 | return false; | ||
| 148 | } | ||
| 149 | |||
| 150 | for (unsigned int ch = 0; ch < AE_CH_MAX; ch++) | ||
| 151 | { | ||
| 152 | if (fmt->m_channels[ch] != m_channels[ch]) | ||
| 153 | { | ||
| 154 | return false; | ||
| 155 | } | ||
| 156 | } | ||
| 157 | |||
| 158 | return true; | ||
| 159 | } | ||
| 160 | } AudioEngineFormat; | ||
| 161 | |||
| 162 | #ifdef __cplusplus | ||
| 163 | } | ||
| 164 | #endif | ||
| 165 | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_callbacks.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_callbacks.h deleted file mode 100644 index 6057f46..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_callbacks.h +++ /dev/null | |||
| @@ -1,161 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2016 Team Kodi | ||
| 3 | * http://kodi.tv | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this Program; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | #ifndef KODI_GAME_CALLBACKS_H_ | ||
| 21 | #define KODI_GAME_CALLBACKS_H_ | ||
| 22 | |||
| 23 | #include "kodi_game_types.h" | ||
| 24 | |||
| 25 | #ifdef __cplusplus | ||
| 26 | extern "C" { | ||
| 27 | #endif | ||
| 28 | |||
| 29 | typedef struct CB_GameLib | ||
| 30 | { | ||
| 31 | // --- Game callbacks -------------------------------------------------------- | ||
| 32 | |||
| 33 | /*! | ||
| 34 | * \brief Requests the frontend to stop the current game | ||
| 35 | */ | ||
| 36 | void (*CloseGame)(void* addonData); | ||
| 37 | |||
| 38 | /*! | ||
| 39 | * \brief Create a video stream for pixel data | ||
| 40 | * | ||
| 41 | * \param format The type of pixel data accepted by this stream | ||
| 42 | * \param width The frame width | ||
| 43 | * \param height The frame height | ||
| 44 | * \param rotation The rotation (counter-clockwise) of the video frames | ||
| 45 | * | ||
| 46 | * \return 0 on success or -1 if a video stream is already created | ||
| 47 | */ | ||
| 48 | int (*OpenPixelStream)(void* addonData, GAME_PIXEL_FORMAT format, unsigned int width, unsigned int height, GAME_VIDEO_ROTATION rotation); | ||
| 49 | |||
| 50 | /*! | ||
| 51 | * \brief Create a video stream for encoded video data | ||
| 52 | * | ||
| 53 | * \param codec The video format accepted by this stream | ||
| 54 | * | ||
| 55 | * \return 0 on success or -1 if a video stream is already created | ||
| 56 | */ | ||
| 57 | int (*OpenVideoStream)(void* addonData, GAME_VIDEO_CODEC codec); | ||
| 58 | |||
| 59 | /*! | ||
| 60 | * \brief Create an audio stream for PCM audio data | ||
| 61 | * | ||
| 62 | * \param format The type of audio data accepted by this stream | ||
| 63 | * \param channel_map The channel layout terminated by GAME_CH_NULL | ||
| 64 | * | ||
| 65 | * \return 0 on success or -1 if an audio stream is already created | ||
| 66 | */ | ||
| 67 | int (*OpenPCMStream)(void* addonData, GAME_PCM_FORMAT format, const GAME_AUDIO_CHANNEL* channel_map); | ||
| 68 | |||
| 69 | /*! | ||
| 70 | * \brief Create an audio stream for encoded audio data | ||
| 71 | * | ||
| 72 | * \param codec The audio format accepted by this stream | ||
| 73 | * \param channel_map The channel layout terminated by GAME_CH_NULL | ||
| 74 | * | ||
| 75 | * \return 0 on success or -1 if an audio stream is already created | ||
| 76 | */ | ||
| 77 | int(*OpenAudioStream)(void* addonData, GAME_AUDIO_CODEC codec, const GAME_AUDIO_CHANNEL* channel_map); | ||
| 78 | |||
| 79 | /*! | ||
| 80 | * \brief Add a data packet to an audio or video stream | ||
| 81 | * | ||
| 82 | * \param stream The target stream | ||
| 83 | * \param data The data packet | ||
| 84 | * \param size The size of the data | ||
| 85 | */ | ||
| 86 | void (*AddStreamData)(void* addonData, GAME_STREAM_TYPE stream, const uint8_t* data, unsigned int size); | ||
| 87 | |||
| 88 | /*! | ||
| 89 | * \brief Free the specified stream | ||
| 90 | * | ||
| 91 | * \param stream The stream to close | ||
| 92 | */ | ||
| 93 | void (*CloseStream)(void* addonData, GAME_STREAM_TYPE stream); | ||
| 94 | |||
| 95 | // -- Hardware rendering callbacks ------------------------------------------- | ||
| 96 | |||
| 97 | /*! | ||
| 98 | * \brief Enable hardware rendering | ||
| 99 | * | ||
| 100 | * \param hw_info A struct of properties for the hardware rendering system | ||
| 101 | */ | ||
| 102 | void (*EnableHardwareRendering)(void* addonData, const game_hw_info* hw_info); | ||
| 103 | |||
| 104 | /*! | ||
| 105 | * \brief Get the framebuffer for rendering | ||
| 106 | * | ||
| 107 | * \return The framebuffer | ||
| 108 | */ | ||
| 109 | uintptr_t (*HwGetCurrentFramebuffer)(void* addonData); | ||
| 110 | |||
| 111 | /*! | ||
| 112 | * \brief Get a symbol from the hardware context | ||
| 113 | * | ||
| 114 | * \param symbol The symbol's name | ||
| 115 | * | ||
| 116 | * \return A function pointer for the specified symbol | ||
| 117 | */ | ||
| 118 | game_proc_address_t (*HwGetProcAddress)(void* addonData, const char* symbol); | ||
| 119 | |||
| 120 | /*! | ||
| 121 | * \brief Called when a frame is being rendered | ||
| 122 | */ | ||
| 123 | void (*RenderFrame)(void* addonData); | ||
| 124 | |||
| 125 | // --- Input callbacks ------------------------------------------------------- | ||
| 126 | |||
| 127 | /*! | ||
| 128 | * \brief Begin reporting events for the specified joystick port | ||
| 129 | * | ||
| 130 | * \param port The zero-indexed port number | ||
| 131 | * | ||
| 132 | * \return true if the port was opened, false otherwise | ||
| 133 | */ | ||
| 134 | bool (*OpenPort)(void* addonData, unsigned int port); | ||
| 135 | |||
| 136 | /*! | ||
| 137 | * \brief End reporting events for the specified port | ||
| 138 | * | ||
| 139 | * \param port The port number passed to OpenPort() | ||
| 140 | */ | ||
| 141 | void (*ClosePort)(void* addonData, unsigned int port); | ||
| 142 | |||
| 143 | /*! | ||
| 144 | * \brief Notify the port of an input event | ||
| 145 | * | ||
| 146 | * \param event The input event | ||
| 147 | * | ||
| 148 | * Input events can arrive for the following sources: | ||
| 149 | * - GAME_INPUT_EVENT_MOTOR | ||
| 150 | * | ||
| 151 | * \return true if the event was handled, false otherwise | ||
| 152 | */ | ||
| 153 | bool (*InputEvent)(void* addonData, const game_input_event* event); | ||
| 154 | |||
| 155 | } CB_GameLib; | ||
| 156 | |||
| 157 | #ifdef __cplusplus | ||
| 158 | } | ||
| 159 | #endif | ||
| 160 | |||
| 161 | #endif // KODI_GAME_CALLBACKS_H_ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h index 247f24b..4ce5bbc 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2014-2016 Team Kodi | 2 | * Copyright (C) 2014-2017 Team Kodi |
| 3 | * http://kodi.tv | 3 | * http://kodi.tv |
| 4 | * | 4 | * |
| 5 | * This Program is free software; you can redistribute it and/or modify | 5 | * This Program is free software; you can redistribute it and/or modify |
| @@ -26,28 +26,6 @@ | |||
| 26 | extern "C" { | 26 | extern "C" { |
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | // --- Game API operations ----------------------------------------------------- | ||
| 30 | |||
| 31 | /*! | ||
| 32 | * \brief Return GAME_API_VERSION_STRING | ||
| 33 | * | ||
| 34 | * The add-on is backwards compatible with the frontend if this API version is | ||
| 35 | * is at least the frontend's minimum API version. | ||
| 36 | * | ||
| 37 | * \return Must be GAME_API_VERSION_STRING | ||
| 38 | */ | ||
| 39 | const char* GetGameAPIVersion(void); | ||
| 40 | |||
| 41 | /*! | ||
| 42 | * \brief Return GAME_MIN_API_VERSION_STRING | ||
| 43 | * | ||
| 44 | * The add-on is forwards compatible with the frontend if this minimum version | ||
| 45 | * is no more than the frontend's API version. | ||
| 46 | * | ||
| 47 | * \return Must be GAME_MIN_API_VERSION_STRING | ||
| 48 | */ | ||
| 49 | const char* GetMininumGameAPIVersion(void); | ||
| 50 | |||
| 51 | // --- Game operations --------------------------------------------------------- | 29 | // --- Game operations --------------------------------------------------------- |
| 52 | 30 | ||
| 53 | /*! | 31 | /*! |
| @@ -233,7 +211,7 @@ GAME_ERROR CheatReset(void); | |||
| 233 | * | 211 | * |
| 234 | * \return the error, or GAME_ERROR_NO_ERROR if data was set to a valid buffer | 212 | * \return the error, or GAME_ERROR_NO_ERROR if data was set to a valid buffer |
| 235 | */ | 213 | */ |
| 236 | GAME_ERROR GetMemory(GAME_MEMORY type, const uint8_t** data, size_t* size); | 214 | GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t** data, size_t* size); |
| 237 | 215 | ||
| 238 | /*! | 216 | /*! |
| 239 | * \brief Set a cheat code | 217 | * \brief Set a cheat code |
| @@ -254,30 +232,30 @@ GAME_ERROR SetCheat(unsigned int index, bool enabled, const char* code); | |||
| 254 | * Note that get_addon() is defined here, so it will be available in all | 232 | * Note that get_addon() is defined here, so it will be available in all |
| 255 | * compiled game clients. | 233 | * compiled game clients. |
| 256 | */ | 234 | */ |
| 257 | void __declspec(dllexport) get_addon(GameClient* pClient) | 235 | void __declspec(dllexport) get_addon(void* ptr) |
| 258 | { | 236 | { |
| 259 | pClient->GetGameAPIVersion = GetGameAPIVersion; | 237 | AddonInstance_Game* pClient = static_cast<AddonInstance_Game*>(ptr); |
| 260 | pClient->GetMininumGameAPIVersion = GetMininumGameAPIVersion; | 238 | |
| 261 | pClient->LoadGame = LoadGame; | 239 | pClient->toAddon.LoadGame = LoadGame; |
| 262 | pClient->LoadGameSpecial = LoadGameSpecial; | 240 | pClient->toAddon.LoadGameSpecial = LoadGameSpecial; |
| 263 | pClient->LoadStandalone = LoadStandalone; | 241 | pClient->toAddon.LoadStandalone = LoadStandalone; |
| 264 | pClient->UnloadGame = UnloadGame; | 242 | pClient->toAddon.UnloadGame = UnloadGame; |
| 265 | pClient->GetGameInfo = GetGameInfo; | 243 | pClient->toAddon.GetGameInfo = GetGameInfo; |
| 266 | pClient->GetRegion = GetRegion; | 244 | pClient->toAddon.GetRegion = GetRegion; |
| 267 | pClient->RequiresGameLoop = RequiresGameLoop; | 245 | pClient->toAddon.RequiresGameLoop = RequiresGameLoop; |
| 268 | pClient->RunFrame = RunFrame; | 246 | pClient->toAddon.RunFrame = RunFrame; |
| 269 | pClient->Reset = Reset; | 247 | pClient->toAddon.Reset = Reset; |
| 270 | pClient->HwContextReset = HwContextReset; | 248 | pClient->toAddon.HwContextReset = HwContextReset; |
| 271 | pClient->HwContextDestroy = HwContextDestroy; | 249 | pClient->toAddon.HwContextDestroy = HwContextDestroy; |
| 272 | pClient->UpdatePort = UpdatePort; | 250 | pClient->toAddon.UpdatePort = UpdatePort; |
| 273 | pClient->HasFeature = HasFeature; | 251 | pClient->toAddon.HasFeature = HasFeature; |
| 274 | pClient->InputEvent = InputEvent; | 252 | pClient->toAddon.InputEvent = InputEvent; |
| 275 | pClient->SerializeSize = SerializeSize; | 253 | pClient->toAddon.SerializeSize = SerializeSize; |
| 276 | pClient->Serialize = Serialize; | 254 | pClient->toAddon.Serialize = Serialize; |
| 277 | pClient->Deserialize = Deserialize; | 255 | pClient->toAddon.Deserialize = Deserialize; |
| 278 | pClient->CheatReset = CheatReset; | 256 | pClient->toAddon.CheatReset = CheatReset; |
| 279 | pClient->GetMemory = GetMemory; | 257 | pClient->toAddon.GetMemory = GetMemory; |
| 280 | pClient->SetCheat = SetCheat; | 258 | pClient->toAddon.SetCheat = SetCheat; |
| 281 | } | 259 | } |
| 282 | 260 | ||
| 283 | #ifdef __cplusplus | 261 | #ifdef __cplusplus |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h index fa2762d..da02f6f 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2014-2016 Team Kodi | 2 | * Copyright (C) 2014-2017 Team Kodi |
| 3 | * http://kodi.tv | 3 | * http://kodi.tv |
| 4 | * | 4 | * |
| 5 | * This Program is free software; you can redistribute it and/or modify | 5 | * This Program is free software; you can redistribute it and/or modify |
| @@ -20,18 +20,13 @@ | |||
| 20 | #ifndef KODI_GAME_TYPES_H_ | 20 | #ifndef KODI_GAME_TYPES_H_ |
| 21 | #define KODI_GAME_TYPES_H_ | 21 | #define KODI_GAME_TYPES_H_ |
| 22 | 22 | ||
| 23 | /* current game API version */ | 23 | #include "versions.h" |
| 24 | #define GAME_API_VERSION "1.0.28" | 24 | #include "xbmc_addon_types.h" |
| 25 | |||
| 26 | /* min. game API version */ | ||
| 27 | #define GAME_MIN_API_VERSION "1.0.28" | ||
| 28 | 25 | ||
| 29 | #include <stddef.h> | 26 | #include <stddef.h> |
| 30 | #include <stdint.h> | 27 | #include <stdint.h> |
| 31 | 28 | ||
| 32 | #ifdef TARGET_WINDOWS | 29 | #ifndef TARGET_WINDOWS |
| 33 | #include <windows.h> | ||
| 34 | #else | ||
| 35 | #ifndef __cdecl | 30 | #ifndef __cdecl |
| 36 | #define __cdecl | 31 | #define __cdecl |
| 37 | #endif | 32 | #endif |
| @@ -402,7 +397,7 @@ struct game_hw_info | |||
| 402 | }; | 397 | }; |
| 403 | 398 | ||
| 404 | /*! Properties passed to the ADDON_Create() method of a game client */ | 399 | /*! Properties passed to the ADDON_Create() method of a game client */ |
| 405 | typedef struct game_client_properties | 400 | typedef struct AddonProps_Game |
| 406 | { | 401 | { |
| 407 | /*! | 402 | /*! |
| 408 | * The path of the game client being loaded. | 403 | * The path of the game client being loaded. |
| @@ -451,13 +446,35 @@ typedef struct game_client_properties | |||
| 451 | * Number of extensions provided | 446 | * Number of extensions provided |
| 452 | */ | 447 | */ |
| 453 | unsigned int extension_count; | 448 | unsigned int extension_count; |
| 454 | } game_client_properties; | 449 | } AddonProps_Game; |
| 455 | 450 | ||
| 451 | typedef AddonProps_Game game_client_properties; | ||
| 452 | |||
| 456 | /*! Structure to transfer the methods from kodi_game_dll.h to Kodi */ | 453 | /*! Structure to transfer the methods from kodi_game_dll.h to Kodi */ |
| 457 | typedef struct GameClient | 454 | |
| 455 | typedef struct AddonToKodiFuncTable_Game | ||
| 456 | { | ||
| 457 | KODI_HANDLE kodiInstance; | ||
| 458 | |||
| 459 | void (*CloseGame)(void* kodiInstance); | ||
| 460 | int (*OpenPixelStream)(void* kodiInstance, GAME_PIXEL_FORMAT format, unsigned int width, unsigned int height, GAME_VIDEO_ROTATION rotation); | ||
| 461 | int (*OpenVideoStream)(void* kodiInstance, GAME_VIDEO_CODEC codec); | ||
| 462 | int (*OpenPCMStream)(void* kodiInstance, GAME_PCM_FORMAT format, const GAME_AUDIO_CHANNEL* channel_map); | ||
| 463 | int(*OpenAudioStream)(void* kodiInstance, GAME_AUDIO_CODEC codec, const GAME_AUDIO_CHANNEL* channel_map); | ||
| 464 | void (*AddStreamData)(void* kodiInstance, GAME_STREAM_TYPE stream, const uint8_t* data, unsigned int size); | ||
| 465 | void (*CloseStream)(void* kodiInstance, GAME_STREAM_TYPE stream); | ||
| 466 | void (*EnableHardwareRendering)(void* kodiInstance, const game_hw_info* hw_info); | ||
| 467 | uintptr_t (*HwGetCurrentFramebuffer)(void* kodiInstance); | ||
| 468 | game_proc_address_t (*HwGetProcAddress)(void* kodiInstance, const char* symbol); | ||
| 469 | void (*RenderFrame)(void* kodiInstance); | ||
| 470 | bool (*OpenPort)(void* kodiInstance, unsigned int port); | ||
| 471 | void (*ClosePort)(void* kodiInstance, unsigned int port); | ||
| 472 | bool (*InputEvent)(void* kodiInstance, const game_input_event* event); | ||
| 473 | |||
| 474 | } AddonToKodiFuncTable_Game; | ||
| 475 | |||
| 476 | typedef struct KodiToAddonFuncTable_Game | ||
| 458 | { | 477 | { |
| 459 | const char* (__cdecl* GetGameAPIVersion)(void); | ||
| 460 | const char* (__cdecl* GetMininumGameAPIVersion)(void); | ||
| 461 | GAME_ERROR (__cdecl* LoadGame)(const char*); | 478 | GAME_ERROR (__cdecl* LoadGame)(const char*); |
| 462 | GAME_ERROR (__cdecl* LoadGameSpecial)(SPECIAL_GAME_TYPE, const char**, size_t); | 479 | GAME_ERROR (__cdecl* LoadGameSpecial)(SPECIAL_GAME_TYPE, const char**, size_t); |
| 463 | GAME_ERROR (__cdecl* LoadStandalone)(void); | 480 | GAME_ERROR (__cdecl* LoadStandalone)(void); |
| @@ -476,9 +493,16 @@ typedef struct GameClient | |||
| 476 | GAME_ERROR (__cdecl* Serialize)(uint8_t*, size_t); | 493 | GAME_ERROR (__cdecl* Serialize)(uint8_t*, size_t); |
| 477 | GAME_ERROR (__cdecl* Deserialize)(const uint8_t*, size_t); | 494 | GAME_ERROR (__cdecl* Deserialize)(const uint8_t*, size_t); |
| 478 | GAME_ERROR (__cdecl* CheatReset)(void); | 495 | GAME_ERROR (__cdecl* CheatReset)(void); |
| 479 | GAME_ERROR (__cdecl* GetMemory)(GAME_MEMORY, const uint8_t**, size_t*); | 496 | GAME_ERROR (__cdecl* GetMemory)(GAME_MEMORY, uint8_t**, size_t*); |
| 480 | GAME_ERROR (__cdecl* SetCheat)(unsigned int, bool, const char*); | 497 | GAME_ERROR (__cdecl* SetCheat)(unsigned int, bool, const char*); |
| 481 | } GameClient; | 498 | } KodiToAddonFuncTable_Game; |
| 499 | |||
| 500 | typedef struct AddonInstance_Game | ||
| 501 | { | ||
| 502 | AddonProps_Game props; | ||
| 503 | AddonToKodiFuncTable_Game toKodi; | ||
| 504 | KodiToAddonFuncTable_Game toAddon; | ||
| 505 | } AddonInstance_Game; | ||
| 482 | 506 | ||
| 483 | #ifdef __cplusplus | 507 | #ifdef __cplusplus |
| 484 | } | 508 | } |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_imagedec_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_imagedec_dll.h new file mode 100644 index 0000000..a87c9c0 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_imagedec_dll.h | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2013 Team XBMC | ||
| 3 | * http://xbmc.org | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with XBMC; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | |||
| 21 | #pragma once | ||
| 22 | |||
| 23 | #include <stdint.h> | ||
| 24 | #include "xbmc_addon_dll.h" | ||
| 25 | #include "kodi_imagedec_types.h" | ||
| 26 | |||
| 27 | extern "C" | ||
| 28 | { | ||
| 29 | void* LoadImage(unsigned char* buffer, unsigned int bufSize, | ||
| 30 | unsigned int* width, unsigned int* height); | ||
| 31 | |||
| 32 | bool Decode(void* image, unsigned char* pixels, | ||
| 33 | unsigned int width, unsigned int height, | ||
| 34 | unsigned int pitch, unsigned int format); | ||
| 35 | |||
| 36 | void Close(void* image); | ||
| 37 | |||
| 38 | // function to export the above structure to Kodi | ||
| 39 | void __declspec(dllexport) get_addon(void* ptr) | ||
| 40 | { | ||
| 41 | AddonInstance_ImageDecoder* img = static_cast<AddonInstance_ImageDecoder*>(ptr); | ||
| 42 | img->toAddon.LoadImage = LoadImage; | ||
| 43 | img->toAddon.Decode = Decode; | ||
| 44 | img->toAddon.Close = Close; | ||
| 45 | } | ||
| 46 | }; | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_imagedec_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_imagedec_types.h new file mode 100644 index 0000000..7af585c --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_imagedec_types.h | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2013 Team XBMC | ||
| 3 | * http://xbmc.org | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with XBMC; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | |||
| 21 | #pragma once | ||
| 22 | |||
| 23 | #include <stdint.h> | ||
| 24 | |||
| 25 | #define ADDON_IMG_FMT_A8R8G8B8 1 | ||
| 26 | #define ADDON_IMG_FMT_A8 2 | ||
| 27 | #define ADDON_IMG_FMT_RGBA8 3 | ||
| 28 | #define ADDON_IMG_FMT_RGB8 4 | ||
| 29 | |||
| 30 | extern "C" | ||
| 31 | { | ||
| 32 | typedef struct AddonProps_ImageDecoder | ||
| 33 | { | ||
| 34 | const char* mimetype; | ||
| 35 | } AddonProps_ImageDecoder; | ||
| 36 | |||
| 37 | typedef struct AddonToKodiFuncTable_ImageDecoder | ||
| 38 | { | ||
| 39 | KODI_HANDLE kodiInstance; | ||
| 40 | } AddonToKodiFuncTable_ImageDecoder; | ||
| 41 | |||
| 42 | typedef struct KodiToAddonFuncTable_ImageDecoder | ||
| 43 | { | ||
| 44 | //! \brief Initialize an encoder | ||
| 45 | //! \param buffer The data to read from memory | ||
| 46 | //! \param bufSize The buffer size | ||
| 47 | //! \param width The optimal width of image on entry, obtained width on return | ||
| 48 | //! \param height The optimal height of image, actual obtained height on return | ||
| 49 | //! \return Image or nullptr on error | ||
| 50 | void* (__cdecl* LoadImage) (unsigned char* buffer, unsigned int bufSize, | ||
| 51 | unsigned int* width, unsigned int* height); | ||
| 52 | |||
| 53 | //! \brief Decode previously loaded image | ||
| 54 | //! \param image Image to decode | ||
| 55 | //! \param pixels Output buffer | ||
| 56 | //! \param width Width of output image | ||
| 57 | //! \param height Height of output image | ||
| 58 | //! \param pitch Pitch of output image | ||
| 59 | //! \param format Format of output image | ||
| 60 | bool (__cdecl* Decode) (void* image, unsigned char* pixels, | ||
| 61 | unsigned int width, unsigned int height, | ||
| 62 | unsigned int pitch, unsigned int format); | ||
| 63 | |||
| 64 | //! \brief Close an opened image | ||
| 65 | //! \param image Image to close | ||
| 66 | //! \return True on success, false on failure | ||
| 67 | void (__cdecl* Close)(void* image); | ||
| 68 | } KodiToAddonFuncTable_ImageDecoder; | ||
| 69 | |||
| 70 | typedef struct AddonInstance_ImageDecoder | ||
| 71 | { | ||
| 72 | AddonProps_ImageDecoder props; | ||
| 73 | AddonToKodiFuncTable_ImageDecoder toKodi; | ||
| 74 | KodiToAddonFuncTable_ImageDecoder toAddon; | ||
| 75 | } AddonInstance_ImageDecoder; | ||
| 76 | } | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h index 8dc49c0..ab8475d 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h | |||
| @@ -214,48 +214,43 @@ extern "C" | |||
| 214 | */ | 214 | */ |
| 215 | bool IsRealTimeStream(); | 215 | bool IsRealTimeStream(); |
| 216 | 216 | ||
| 217 | const char* GetApiVersion() | ||
| 218 | { | ||
| 219 | static const char *ApiVersion = INPUTSTREAM_API_VERSION; | ||
| 220 | return ApiVersion; | ||
| 221 | } | ||
| 222 | |||
| 223 | /*! | 217 | /*! |
| 224 | * Called by XBMC to assign the function pointers of this add-on to pClient. | 218 | * Called by XBMC to assign the function pointers of this add-on to pClient. |
| 225 | * @param pClient The struct to assign the function pointers to. | 219 | * @param pClient The struct to assign the function pointers to. |
| 226 | */ | 220 | */ |
| 227 | void __declspec(dllexport) get_addon(struct InputStreamAddonFunctions* pClient) | 221 | void __declspec(dllexport) get_addon(void* ptr) |
| 228 | { | 222 | { |
| 229 | pClient->Open = Open; | 223 | AddonInstance_InputStream* pClient = static_cast<AddonInstance_InputStream*>(ptr); |
| 230 | pClient->Close = Close; | 224 | |
| 231 | pClient->GetPathList = GetPathList; | 225 | pClient->toAddon.Open = Open; |
| 232 | pClient->GetCapabilities = GetCapabilities; | 226 | pClient->toAddon.Close = Close; |
| 233 | pClient->GetApiVersion = GetApiVersion; | 227 | pClient->toAddon.GetPathList = GetPathList; |
| 234 | 228 | pClient->toAddon.GetCapabilities = GetCapabilities; | |
| 235 | pClient->GetStreamIds = GetStreamIds; | 229 | |
| 236 | pClient->GetStream = GetStream; | 230 | pClient->toAddon.GetStreamIds = GetStreamIds; |
| 237 | pClient->EnableStream = EnableStream; | 231 | pClient->toAddon.GetStream = GetStream; |
| 238 | pClient->DemuxReset = DemuxReset; | 232 | pClient->toAddon.EnableStream = EnableStream; |
| 239 | pClient->DemuxAbort = DemuxAbort; | 233 | pClient->toAddon.DemuxReset = DemuxReset; |
| 240 | pClient->DemuxFlush = DemuxFlush; | 234 | pClient->toAddon.DemuxAbort = DemuxAbort; |
| 241 | pClient->DemuxRead = DemuxRead; | 235 | pClient->toAddon.DemuxFlush = DemuxFlush; |
| 242 | pClient->DemuxSeekTime = DemuxSeekTime; | 236 | pClient->toAddon.DemuxRead = DemuxRead; |
| 243 | pClient->DemuxSetSpeed = DemuxSetSpeed; | 237 | pClient->toAddon.DemuxSeekTime = DemuxSeekTime; |
| 244 | pClient->SetVideoResolution = SetVideoResolution; | 238 | pClient->toAddon.DemuxSetSpeed = DemuxSetSpeed; |
| 245 | 239 | pClient->toAddon.SetVideoResolution = SetVideoResolution; | |
| 246 | pClient->GetTotalTime = GetTotalTime; | 240 | |
| 247 | pClient->GetTime = GetTime; | 241 | pClient->toAddon.GetTotalTime = GetTotalTime; |
| 248 | 242 | pClient->toAddon.GetTime = GetTime; | |
| 249 | pClient->PosTime = PosTime; | 243 | |
| 250 | 244 | pClient->toAddon.PosTime = PosTime; | |
| 251 | pClient->CanPauseStream = CanPauseStream; | 245 | |
| 252 | pClient->CanSeekStream = CanSeekStream; | 246 | pClient->toAddon.CanPauseStream = CanPauseStream; |
| 253 | 247 | pClient->toAddon.CanSeekStream = CanSeekStream; | |
| 254 | pClient->ReadStream = ReadStream; | 248 | |
| 255 | pClient->SeekStream = SeekStream; | 249 | pClient->toAddon.ReadStream = ReadStream; |
| 256 | pClient->PositionStream = PositionStream; | 250 | pClient->toAddon.SeekStream = SeekStream; |
| 257 | pClient->LengthStream = LengthStream; | 251 | pClient->toAddon.PositionStream = PositionStream; |
| 258 | pClient->PauseStream = PauseStream; | 252 | pClient->toAddon.LengthStream = LengthStream; |
| 259 | pClient->IsRealTimeStream = IsRealTimeStream; | 253 | pClient->toAddon.PauseStream = PauseStream; |
| 254 | pClient->toAddon.IsRealTimeStream = IsRealTimeStream; | ||
| 260 | }; | 255 | }; |
| 261 | }; | 256 | }; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h index 46e9d03..9597e8a 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h | |||
| @@ -20,9 +20,7 @@ | |||
| 20 | * | 20 | * |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #ifdef TARGET_WINDOWS | 23 | #ifndef TARGET_WINDOWS |
| 24 | #include <windows.h> | ||
| 25 | #else | ||
| 26 | #ifndef __cdecl | 24 | #ifndef __cdecl |
| 27 | #define __cdecl | 25 | #define __cdecl |
| 28 | #endif | 26 | #endif |
| @@ -31,24 +29,16 @@ | |||
| 31 | #endif | 29 | #endif |
| 32 | #endif | 30 | #endif |
| 33 | 31 | ||
| 32 | #include "xbmc_addon_types.h" | ||
| 33 | |||
| 34 | #ifdef BUILD_KODI_ADDON | 34 | #ifdef BUILD_KODI_ADDON |
| 35 | #include "DVDDemuxPacket.h" | 35 | #include "DVDDemuxPacket.h" |
| 36 | #else | 36 | #else |
| 37 | #include "cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h" | 37 | #include "cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h" |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | /* current API version */ | ||
| 41 | #define INPUTSTREAM_API_VERSION "1.0.6" | ||
| 42 | |||
| 43 | extern "C" { | 40 | extern "C" { |
| 44 | 41 | ||
| 45 | // this are properties given to the addon on create | ||
| 46 | // at this time we have no parameters for the addon | ||
| 47 | typedef struct INPUTSTREAM_PROPS | ||
| 48 | { | ||
| 49 | int dummy; | ||
| 50 | } INPUTSTREAM_PROPS; | ||
| 51 | |||
| 52 | /*! | 42 | /*! |
| 53 | * @brief InputStream add-on capabilities. All capabilities are set to "false" as default. | 43 | * @brief InputStream add-on capabilities. All capabilities are set to "false" as default. |
| 54 | */ | 44 | */ |
| @@ -108,7 +98,6 @@ extern "C" { | |||
| 108 | char m_codecName[32]; /*!< @brief (required) name of codec according to ffmpeg */ | 98 | char m_codecName[32]; /*!< @brief (required) name of codec according to ffmpeg */ |
| 109 | char m_codecInternalName[32]; /*!< @brief (optional) internal name of codec (selectionstream info) */ | 99 | char m_codecInternalName[32]; /*!< @brief (optional) internal name of codec (selectionstream info) */ |
| 110 | unsigned int m_pID; /*!< @brief (required) physical index */ | 100 | unsigned int m_pID; /*!< @brief (required) physical index */ |
| 111 | unsigned int m_Bandwidth; /*!< @brief (optional) bandwidth of the stream (selectionstream info) */ | ||
| 112 | 101 | ||
| 113 | const uint8_t *m_ExtraData; | 102 | const uint8_t *m_ExtraData; |
| 114 | unsigned int m_ExtraSize; | 103 | unsigned int m_ExtraSize; |
| @@ -131,13 +120,29 @@ extern "C" { | |||
| 131 | /*! | 120 | /*! |
| 132 | * @brief Structure to transfer the methods from xbmc_inputstream_dll.h to XBMC | 121 | * @brief Structure to transfer the methods from xbmc_inputstream_dll.h to XBMC |
| 133 | */ | 122 | */ |
| 134 | typedef struct InputStreamAddonFunctions | 123 | |
| 124 | // this are properties given to the addon on create | ||
| 125 | // at this time we have no parameters for the addon | ||
| 126 | typedef struct AddonProps_InputStream | ||
| 127 | { | ||
| 128 | int dummy; | ||
| 129 | } AddonProps_InputStream; | ||
| 130 | |||
| 131 | typedef AddonProps_InputStream INPUTSTREAM_PROPS; | ||
| 132 | |||
| 133 | typedef struct AddonToKodiFuncTable_InputStream | ||
| 134 | { | ||
| 135 | KODI_HANDLE kodiInstance; | ||
| 136 | DemuxPacket* (*AllocateDemuxPacket)(void* kodiInstance, int iDataSize); | ||
| 137 | void (*FreeDemuxPacket)(void* kodiInstance, DemuxPacket* pPacket); | ||
| 138 | } AddonToKodiFuncTable_InputStream; | ||
| 139 | |||
| 140 | typedef struct KodiToAddonFuncTable_InputStream | ||
| 135 | { | 141 | { |
| 136 | bool (__cdecl* Open)(INPUTSTREAM&); | 142 | bool (__cdecl* Open)(INPUTSTREAM&); |
| 137 | void (__cdecl* Close)(void); | 143 | void (__cdecl* Close)(void); |
| 138 | const char* (__cdecl* GetPathList)(void); | 144 | const char* (__cdecl* GetPathList)(void); |
| 139 | struct INPUTSTREAM_CAPABILITIES (__cdecl* GetCapabilities)(void); | 145 | struct INPUTSTREAM_CAPABILITIES (__cdecl* GetCapabilities)(void); |
| 140 | const char* (__cdecl* GetApiVersion)(void); | ||
| 141 | 146 | ||
| 142 | // IDemux | 147 | // IDemux |
| 143 | struct INPUTSTREAM_IDS (__cdecl* GetStreamIds)(); | 148 | struct INPUTSTREAM_IDS (__cdecl* GetStreamIds)(); |
| @@ -168,7 +173,15 @@ extern "C" { | |||
| 168 | int64_t (__cdecl* LengthStream)(void); | 173 | int64_t (__cdecl* LengthStream)(void); |
| 169 | void (__cdecl* PauseStream)(double); | 174 | void (__cdecl* PauseStream)(double); |
| 170 | bool (__cdecl* IsRealTimeStream)(void); | 175 | bool (__cdecl* IsRealTimeStream)(void); |
| 171 | } InputStreamAddonFunctions; | 176 | } KodiToAddonFuncTable_InputStream; |
| 177 | |||
| 178 | typedef struct AddonInstance_InputStream | ||
| 179 | { | ||
| 180 | AddonProps_InputStream props; | ||
| 181 | AddonToKodiFuncTable_InputStream toKodi; | ||
| 182 | KodiToAddonFuncTable_InputStream toAddon; | ||
| 183 | } AddonInstance_InputStream; | ||
| 184 | |||
| 172 | } | 185 | } |
| 173 | 186 | ||
| 174 | 187 | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h deleted file mode 100644 index 2dfc571..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h +++ /dev/null | |||
| @@ -1,63 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2016 Team Kodi | ||
| 3 | * http://kodi.tv | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this Program; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | #ifndef __PERIPHERAL_CALLBACKS_H__ | ||
| 21 | #define __PERIPHERAL_CALLBACKS_H__ | ||
| 22 | |||
| 23 | #include "kodi_peripheral_types.h" | ||
| 24 | |||
| 25 | #ifdef __cplusplus | ||
| 26 | extern "C" | ||
| 27 | { | ||
| 28 | #endif | ||
| 29 | |||
| 30 | typedef struct CB_PeripheralLib | ||
| 31 | { | ||
| 32 | /*! | ||
| 33 | * @brief Trigger a scan for peripherals | ||
| 34 | * | ||
| 35 | * The add-on calls this if a change in hardware is detected. | ||
| 36 | */ | ||
| 37 | void (*TriggerScan)(void* addonData); | ||
| 38 | |||
| 39 | /*! | ||
| 40 | * @brief Notify the frontend that button maps have changed | ||
| 41 | * | ||
| 42 | * @param[optional] deviceName The name of the device to refresh, or empty/null for all devices | ||
| 43 | * @param[optional] controllerId The controller ID to refresh, or empty/null for all controllers | ||
| 44 | */ | ||
| 45 | void (*RefreshButtonMaps)(void* addonData, const char* deviceName, const char* controllerId); | ||
| 46 | |||
| 47 | /*! | ||
| 48 | * @brief Return the number of features belonging to the specified controller | ||
| 49 | * | ||
| 50 | * @param controllerId The controller ID to enumerate | ||
| 51 | * @param type[optional] Type to filter by, or JOYSTICK_FEATURE_TYPE_UNKNOWN for all features | ||
| 52 | * | ||
| 53 | * @return The number of features matching the request parameters | ||
| 54 | */ | ||
| 55 | unsigned int (*FeatureCount)(void* addonData, const char* controllerId, JOYSTICK_FEATURE_TYPE type); | ||
| 56 | |||
| 57 | } CB_PeripheralLib; | ||
| 58 | |||
| 59 | #ifdef __cplusplus | ||
| 60 | } | ||
| 61 | #endif | ||
| 62 | |||
| 63 | #endif // __PERIPHERAL_CALLBACKS_H__ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h index f9d7482..b353316 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2014-2016 Team Kodi | 2 | * Copyright (C) 2014-2017 Team Kodi |
| 3 | * http://kodi.tv | 3 | * http://kodi.tv |
| 4 | * | 4 | * |
| 5 | * This Program is free software; you can redistribute it and/or modify | 5 | * This Program is free software; you can redistribute it and/or modify |
| @@ -32,24 +32,6 @@ extern "C" | |||
| 32 | /// @name Peripheral operations | 32 | /// @name Peripheral operations |
| 33 | ///{ | 33 | ///{ |
| 34 | /*! | 34 | /*! |
| 35 | * @brief Get the PERIPHERAL_API_VERSION used to compile this peripheral add-on | ||
| 36 | * @return KODI_PERIPHERAL_API_VERSION from kodi_peripheral_types.h | ||
| 37 | * @remarks Valid implementation required | ||
| 38 | * | ||
| 39 | * Used to check if the implementation is compatible with the frontend. | ||
| 40 | */ | ||
| 41 | const char* GetPeripheralAPIVersion(void); | ||
| 42 | |||
| 43 | /*! | ||
| 44 | * @brief Get the KODI_PERIPHERAL_MIN_API_VERSION used to compile this peripheral add-on | ||
| 45 | * @return KODI_PERIPHERAL_MIN_API_VERSION from kodi_peripheral_types.h | ||
| 46 | * @remarks Valid implementation required | ||
| 47 | * | ||
| 48 | * Used to check if the implementation is compatible with the frontend. | ||
| 49 | */ | ||
| 50 | const char* GetMinimumPeripheralAPIVersion(void); | ||
| 51 | |||
| 52 | /*! | ||
| 53 | * @brief Get the list of features that this add-on provides | 35 | * @brief Get the list of features that this add-on provides |
| 54 | * @param pCapabilities The add-on's capabilities. | 36 | * @param pCapabilities The add-on's capabilities. |
| 55 | * @return PERIPHERAL_NO_ERROR if the properties were fetched successfully. | 37 | * @return PERIPHERAL_NO_ERROR if the properties were fetched successfully. |
| @@ -230,30 +212,30 @@ extern "C" | |||
| 230 | * pClient. Note that get_addon() is defined here, so it will be available in | 212 | * pClient. Note that get_addon() is defined here, so it will be available in |
| 231 | * all compiled peripheral add-ons. | 213 | * all compiled peripheral add-ons. |
| 232 | */ | 214 | */ |
| 233 | void __declspec(dllexport) get_addon(struct PeripheralAddon* pClient) | 215 | void __declspec(dllexport) get_addon(void* ptr) |
| 234 | { | 216 | { |
| 235 | pClient->GetPeripheralAPIVersion = GetPeripheralAPIVersion; | 217 | AddonInstance_Peripheral* pClient = static_cast<AddonInstance_Peripheral*>(ptr); |
| 236 | pClient->GetMinimumPeripheralAPIVersion = GetMinimumPeripheralAPIVersion; | 218 | |
| 237 | pClient->GetAddonCapabilities = GetAddonCapabilities; | 219 | pClient->toAddon.GetAddonCapabilities = GetAddonCapabilities; |
| 238 | pClient->PerformDeviceScan = PerformDeviceScan; | 220 | pClient->toAddon.PerformDeviceScan = PerformDeviceScan; |
| 239 | pClient->FreeScanResults = FreeScanResults; | 221 | pClient->toAddon.FreeScanResults = FreeScanResults; |
| 240 | pClient->GetEvents = GetEvents; | 222 | pClient->toAddon.GetEvents = GetEvents; |
| 241 | pClient->FreeEvents = FreeEvents; | 223 | pClient->toAddon.FreeEvents = FreeEvents; |
| 242 | pClient->SendEvent = SendEvent; | 224 | pClient->toAddon.SendEvent = SendEvent; |
| 243 | 225 | ||
| 244 | #ifdef PERIPHERAL_ADDON_JOYSTICKS | 226 | #ifdef PERIPHERAL_ADDON_JOYSTICKS |
| 245 | pClient->GetJoystickInfo = GetJoystickInfo; | 227 | pClient->toAddon.GetJoystickInfo = GetJoystickInfo; |
| 246 | pClient->FreeJoystickInfo = FreeJoystickInfo; | 228 | pClient->toAddon.FreeJoystickInfo = FreeJoystickInfo; |
| 247 | pClient->GetFeatures = GetFeatures; | 229 | pClient->toAddon.GetFeatures = GetFeatures; |
| 248 | pClient->FreeFeatures = FreeFeatures; | 230 | pClient->toAddon.FreeFeatures = FreeFeatures; |
| 249 | pClient->MapFeatures = MapFeatures; | 231 | pClient->toAddon.MapFeatures = MapFeatures; |
| 250 | pClient->GetIgnoredPrimitives = GetIgnoredPrimitives; | 232 | pClient->toAddon.GetIgnoredPrimitives = GetIgnoredPrimitives; |
| 251 | pClient->FreePrimitives = FreePrimitives; | 233 | pClient->toAddon.FreePrimitives = FreePrimitives; |
| 252 | pClient->SetIgnoredPrimitives = SetIgnoredPrimitives; | 234 | pClient->toAddon.SetIgnoredPrimitives = SetIgnoredPrimitives; |
| 253 | pClient->SaveButtonMap = SaveButtonMap; | 235 | pClient->toAddon.SaveButtonMap = SaveButtonMap; |
| 254 | pClient->RevertButtonMap = RevertButtonMap; | 236 | pClient->toAddon.RevertButtonMap = RevertButtonMap; |
| 255 | pClient->ResetButtonMap = ResetButtonMap; | 237 | pClient->toAddon.ResetButtonMap = ResetButtonMap; |
| 256 | pClient->PowerOffJoystick = PowerOffJoystick; | 238 | pClient->toAddon.PowerOffJoystick = PowerOffJoystick; |
| 257 | #endif | 239 | #endif |
| 258 | } | 240 | } |
| 259 | 241 | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h index d7c4282..0786aa8 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | |||
| 2 | /* | 1 | /* |
| 3 | * Copyright (C) 2014-2016 Team Kodi | 2 | * Copyright (C) 2014-2017 Team Kodi |
| 4 | * http://kodi.tv | 3 | * http://kodi.tv |
| 5 | * | 4 | * |
| 6 | * This Program is free software; you can redistribute it and/or modify | 5 | * This Program is free software; you can redistribute it and/or modify |
| @@ -21,9 +20,10 @@ | |||
| 21 | #ifndef __PERIPHERAL_TYPES_H__ | 20 | #ifndef __PERIPHERAL_TYPES_H__ |
| 22 | #define __PERIPHERAL_TYPES_H__ | 21 | #define __PERIPHERAL_TYPES_H__ |
| 23 | 22 | ||
| 24 | #ifdef TARGET_WINDOWS | 23 | #include "versions.h" |
| 25 | #include <windows.h> | 24 | #include "xbmc_addon_types.h" |
| 26 | #else | 25 | |
| 26 | #ifndef TARGET_WINDOWS | ||
| 27 | #ifndef __cdecl | 27 | #ifndef __cdecl |
| 28 | #define __cdecl | 28 | #define __cdecl |
| 29 | #endif | 29 | #endif |
| @@ -50,12 +50,6 @@ | |||
| 50 | #define PRAGMA_PACK 1 | 50 | #define PRAGMA_PACK 1 |
| 51 | #endif | 51 | #endif |
| 52 | 52 | ||
| 53 | /* current Peripheral API version */ | ||
| 54 | #define PERIPHERAL_API_VERSION "1.2.1" | ||
| 55 | |||
| 56 | /* min. Peripheral API version */ | ||
| 57 | #define PERIPHERAL_MIN_API_VERSION "1.2.0" | ||
| 58 | |||
| 59 | /* indicates a joystick has no preference for port number */ | 53 | /* indicates a joystick has no preference for port number */ |
| 60 | #define NO_PORT_REQUESTED (-1) | 54 | #define NO_PORT_REQUESTED (-1) |
| 61 | 55 | ||
| @@ -113,6 +107,8 @@ extern "C" | |||
| 113 | typedef struct PERIPHERAL_CAPABILITIES | 107 | typedef struct PERIPHERAL_CAPABILITIES |
| 114 | { | 108 | { |
| 115 | bool provides_joysticks; /*!< @brief true if the add-on provides joysticks */ | 109 | bool provides_joysticks; /*!< @brief true if the add-on provides joysticks */ |
| 110 | bool provides_joystick_rumble; | ||
| 111 | bool provides_joystick_power_off; | ||
| 116 | bool provides_buttonmaps; /*!< @brief true if the add-on provides button maps */ | 112 | bool provides_buttonmaps; /*!< @brief true if the add-on provides button maps */ |
| 117 | } ATTRIBUTE_PACKED PERIPHERAL_CAPABILITIES; | 113 | } ATTRIBUTE_PACKED PERIPHERAL_CAPABILITIES; |
| 118 | ///} | 114 | ///} |
| @@ -223,7 +219,9 @@ extern "C" | |||
| 223 | typedef struct JOYSTICK_DRIVER_SEMIAXIS | 219 | typedef struct JOYSTICK_DRIVER_SEMIAXIS |
| 224 | { | 220 | { |
| 225 | int index; | 221 | int index; |
| 222 | int center; | ||
| 226 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction; | 223 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction; |
| 224 | unsigned int range; | ||
| 227 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_SEMIAXIS; | 225 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_SEMIAXIS; |
| 228 | 226 | ||
| 229 | typedef struct JOYSTICK_DRIVER_MOTOR | 227 | typedef struct JOYSTICK_DRIVER_MOTOR |
| @@ -288,10 +286,19 @@ extern "C" | |||
| 288 | /*! | 286 | /*! |
| 289 | * @brief Structure to transfer the methods from kodi_peripheral_dll.h to the frontend | 287 | * @brief Structure to transfer the methods from kodi_peripheral_dll.h to the frontend |
| 290 | */ | 288 | */ |
| 291 | typedef struct PeripheralAddon | 289 | |
| 290 | typedef PERIPHERAL_PROPERTIES AddonProps_Peripheral; | ||
| 291 | |||
| 292 | typedef struct AddonToKodiFuncTable_Peripheral | ||
| 293 | { | ||
| 294 | KODI_HANDLE kodiInstance; | ||
| 295 | void (*TriggerScan)(void* kodiInstance); | ||
| 296 | void (*RefreshButtonMaps)(void* kodiInstance, const char* deviceName, const char* controllerId); | ||
| 297 | unsigned int (*FeatureCount)(void* kodiInstance, const char* controllerId, JOYSTICK_FEATURE_TYPE type); | ||
| 298 | } AddonToKodiFuncTable_Peripheral; | ||
| 299 | |||
| 300 | typedef struct KodiToAddonFuncTable_Peripheral | ||
| 292 | { | 301 | { |
| 293 | const char* (__cdecl* GetPeripheralAPIVersion)(void); | ||
| 294 | const char* (__cdecl* GetMinimumPeripheralAPIVersion)(void); | ||
| 295 | PERIPHERAL_ERROR (__cdecl* GetAddonCapabilities)(PERIPHERAL_CAPABILITIES*); | 302 | PERIPHERAL_ERROR (__cdecl* GetAddonCapabilities)(PERIPHERAL_CAPABILITIES*); |
| 296 | PERIPHERAL_ERROR (__cdecl* PerformDeviceScan)(unsigned int*, PERIPHERAL_INFO**); | 303 | PERIPHERAL_ERROR (__cdecl* PerformDeviceScan)(unsigned int*, PERIPHERAL_INFO**); |
| 297 | void (__cdecl* FreeScanResults)(unsigned int, PERIPHERAL_INFO*); | 304 | void (__cdecl* FreeScanResults)(unsigned int, PERIPHERAL_INFO*); |
| @@ -314,7 +321,14 @@ extern "C" | |||
| 314 | void (__cdecl* ResetButtonMap)(const JOYSTICK_INFO*, const char*); | 321 | void (__cdecl* ResetButtonMap)(const JOYSTICK_INFO*, const char*); |
| 315 | void (__cdecl* PowerOffJoystick)(unsigned int); | 322 | void (__cdecl* PowerOffJoystick)(unsigned int); |
| 316 | ///} | 323 | ///} |
| 317 | } PeripheralAddon; | 324 | } KodiToAddonFuncTable_Peripheral; |
| 325 | |||
| 326 | typedef struct AddonInstance_Peripheral | ||
| 327 | { | ||
| 328 | AddonProps_Peripheral props; | ||
| 329 | AddonToKodiFuncTable_Peripheral toKodi; | ||
| 330 | KodiToAddonFuncTable_Peripheral toAddon; | ||
| 331 | } AddonInstance_Peripheral; | ||
| 318 | 332 | ||
| 319 | #ifdef __cplusplus | 333 | #ifdef __cplusplus |
| 320 | } | 334 | } |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp index f01180b..2106d19 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2014-2016 Team Kodi | 2 | * Copyright (C) 2014-2017 Team Kodi |
| 3 | * http://kodi.tv | 3 | * http://kodi.tv |
| 4 | * | 4 | * |
| 5 | * This Program is free software; you can redistribute it and/or modify | 5 | * This Program is free software; you can redistribute it and/or modify |
| @@ -362,7 +362,9 @@ namespace ADDON | |||
| 362 | * | 362 | * |
| 363 | * Semiaxis: | 363 | * Semiaxis: |
| 364 | * - driver index | 364 | * - driver index |
| 365 | * - center | ||
| 365 | * - semiaxis direction | 366 | * - semiaxis direction |
| 367 | * - range | ||
| 366 | * | 368 | * |
| 367 | * Motor: | 369 | * Motor: |
| 368 | * - driver index | 370 | * - driver index |
| @@ -377,7 +379,9 @@ namespace ADDON | |||
| 377 | m_type(type), | 379 | m_type(type), |
| 378 | m_driverIndex(driverIndex), | 380 | m_driverIndex(driverIndex), |
| 379 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), | 381 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), |
| 380 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN) | 382 | m_center(0), |
| 383 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), | ||
| 384 | m_range(1) | ||
| 381 | { | 385 | { |
| 382 | } | 386 | } |
| 383 | 387 | ||
| @@ -389,7 +393,9 @@ namespace ADDON | |||
| 389 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN), | 393 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN), |
| 390 | m_driverIndex(0), | 394 | m_driverIndex(0), |
| 391 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), | 395 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), |
| 392 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN) | 396 | m_center(0), |
| 397 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), | ||
| 398 | m_range(1) | ||
| 393 | { | 399 | { |
| 394 | } | 400 | } |
| 395 | 401 | ||
| @@ -409,7 +415,9 @@ namespace ADDON | |||
| 409 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION), | 415 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION), |
| 410 | m_driverIndex(hatIndex), | 416 | m_driverIndex(hatIndex), |
| 411 | m_hatDirection(direction), | 417 | m_hatDirection(direction), |
| 412 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN) | 418 | m_center(0), |
| 419 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), | ||
| 420 | m_range(1) | ||
| 413 | { | 421 | { |
| 414 | } | 422 | } |
| 415 | 423 | ||
| @@ -417,11 +425,13 @@ namespace ADDON | |||
| 417 | * \brief Construct a driver primitive representing the positive or negative | 425 | * \brief Construct a driver primitive representing the positive or negative |
| 418 | * half of an axis | 426 | * half of an axis |
| 419 | */ | 427 | */ |
| 420 | DriverPrimitive(unsigned int axisIndex, JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction) : | 428 | DriverPrimitive(unsigned int axisIndex, int center, JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction, unsigned int range) : |
| 421 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS), | 429 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS), |
| 422 | m_driverIndex(axisIndex), | 430 | m_driverIndex(axisIndex), |
| 423 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), | 431 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), |
| 424 | m_semiAxisDirection(direction) | 432 | m_center(center), |
| 433 | m_semiAxisDirection(direction), | ||
| 434 | m_range(range) | ||
| 425 | { | 435 | { |
| 426 | } | 436 | } |
| 427 | 437 | ||
| @@ -437,7 +447,9 @@ namespace ADDON | |||
| 437 | m_type(primitive.type), | 447 | m_type(primitive.type), |
| 438 | m_driverIndex(0), | 448 | m_driverIndex(0), |
| 439 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), | 449 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), |
| 440 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN) | 450 | m_center(0), |
| 451 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), | ||
| 452 | m_range(1) | ||
| 441 | { | 453 | { |
| 442 | switch (m_type) | 454 | switch (m_type) |
| 443 | { | 455 | { |
| @@ -455,7 +467,9 @@ namespace ADDON | |||
| 455 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: | 467 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: |
| 456 | { | 468 | { |
| 457 | m_driverIndex = primitive.semiaxis.index; | 469 | m_driverIndex = primitive.semiaxis.index; |
| 470 | m_center = primitive.semiaxis.center; | ||
| 458 | m_semiAxisDirection = primitive.semiaxis.direction; | 471 | m_semiAxisDirection = primitive.semiaxis.direction; |
| 472 | m_range = primitive.semiaxis.range; | ||
| 459 | break; | 473 | break; |
| 460 | } | 474 | } |
| 461 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: | 475 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: |
| @@ -471,7 +485,9 @@ namespace ADDON | |||
| 471 | JOYSTICK_DRIVER_PRIMITIVE_TYPE Type(void) const { return m_type; } | 485 | JOYSTICK_DRIVER_PRIMITIVE_TYPE Type(void) const { return m_type; } |
| 472 | unsigned int DriverIndex(void) const { return m_driverIndex; } | 486 | unsigned int DriverIndex(void) const { return m_driverIndex; } |
| 473 | JOYSTICK_DRIVER_HAT_DIRECTION HatDirection(void) const { return m_hatDirection; } | 487 | JOYSTICK_DRIVER_HAT_DIRECTION HatDirection(void) const { return m_hatDirection; } |
| 488 | int Center(void) const { return m_center; } | ||
| 474 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION SemiAxisDirection(void) const { return m_semiAxisDirection; } | 489 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION SemiAxisDirection(void) const { return m_semiAxisDirection; } |
| 490 | unsigned int Range(void) const { return m_range; } | ||
| 475 | 491 | ||
| 476 | bool operator==(const DriverPrimitive& other) const | 492 | bool operator==(const DriverPrimitive& other) const |
| 477 | { | 493 | { |
| @@ -492,7 +508,9 @@ namespace ADDON | |||
| 492 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: | 508 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: |
| 493 | { | 509 | { |
| 494 | return m_driverIndex == other.m_driverIndex && | 510 | return m_driverIndex == other.m_driverIndex && |
| 495 | m_semiAxisDirection == other.m_semiAxisDirection; | 511 | m_center == other.m_center && |
| 512 | m_semiAxisDirection == other.m_semiAxisDirection && | ||
| 513 | m_range == other.m_range; | ||
| 496 | } | 514 | } |
| 497 | default: | 515 | default: |
| 498 | break; | 516 | break; |
| @@ -520,7 +538,9 @@ namespace ADDON | |||
| 520 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: | 538 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: |
| 521 | { | 539 | { |
| 522 | driver_primitive.semiaxis.index = m_driverIndex; | 540 | driver_primitive.semiaxis.index = m_driverIndex; |
| 541 | driver_primitive.semiaxis.center = m_center; | ||
| 523 | driver_primitive.semiaxis.direction = m_semiAxisDirection; | 542 | driver_primitive.semiaxis.direction = m_semiAxisDirection; |
| 543 | driver_primitive.semiaxis.range = m_range; | ||
| 524 | break; | 544 | break; |
| 525 | } | 545 | } |
| 526 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: | 546 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: |
| @@ -542,7 +562,9 @@ namespace ADDON | |||
| 542 | JOYSTICK_DRIVER_PRIMITIVE_TYPE m_type; | 562 | JOYSTICK_DRIVER_PRIMITIVE_TYPE m_type; |
| 543 | unsigned int m_driverIndex; | 563 | unsigned int m_driverIndex; |
| 544 | JOYSTICK_DRIVER_HAT_DIRECTION m_hatDirection; | 564 | JOYSTICK_DRIVER_HAT_DIRECTION m_hatDirection; |
| 565 | int m_center; | ||
| 545 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION m_semiAxisDirection; | 566 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION m_semiAxisDirection; |
| 567 | unsigned int m_range; | ||
| 546 | }; | 568 | }; |
| 547 | 569 | ||
| 548 | typedef PeripheralVector<DriverPrimitive, JOYSTICK_DRIVER_PRIMITIVE> DriverPrimitives; | 570 | typedef PeripheralVector<DriverPrimitive, JOYSTICK_DRIVER_PRIMITIVE> DriverPrimitives; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_dll.h new file mode 100644 index 0000000..30741a6 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_dll.h | |||
| @@ -0,0 +1,126 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2013 Arne Morten Kvarving | ||
| 3 | * | ||
| 4 | * This Program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 7 | * any later version. | ||
| 8 | * | ||
| 9 | * This Program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with XBMC; see the file COPYING. If not, see | ||
| 16 | * <http://www.gnu.org/licenses/>. | ||
| 17 | * | ||
| 18 | */ | ||
| 19 | #pragma once | ||
| 20 | |||
| 21 | #include <stdint.h> | ||
| 22 | #include "xbmc_addon_dll.h" | ||
| 23 | #include "kodi_vfs_types.h" | ||
| 24 | |||
| 25 | extern "C" | ||
| 26 | { | ||
| 27 | //! \copydoc KodiToAddonFuncTable_VFSEntry::Open | ||
| 28 | void* Open(VFSURL* url); | ||
| 29 | |||
| 30 | //! \copydoc KodiToAddonFuncTable_VFSEntry::OpenForWrite | ||
| 31 | void* OpenForWrite(VFSURL* url, bool bOverWrite); | ||
| 32 | |||
| 33 | //! \copydoc KodiToAddonFuncTable_VFSEntry::Read | ||
| 34 | ssize_t Read(void* context, void* buffer, size_t size); | ||
| 35 | |||
| 36 | //! \copydoc KodiToAddonFuncTable_VFSEntry::Write | ||
| 37 | ssize_t Write(void* context, const void* buffer, size_t size); | ||
| 38 | |||
| 39 | //! \copydoc KodiToAddonFuncTable_VFSEntry::Seek | ||
| 40 | int64_t Seek(void* context, int64_t position, int whence); | ||
| 41 | |||
| 42 | //! \copydoc KodiToAddonFuncTable_VFSEntry::Truncate | ||
| 43 | int Truncate(void* context, int64_t size); | ||
| 44 | |||
| 45 | //! \copydoc KodiToAddonFuncTable_VFSEntry::GetLength | ||
| 46 | int64_t GetLength(void* context); | ||
| 47 | |||
| 48 | //! \copydoc KodiToAddonFuncTable_VFSEntry::GetPosition | ||
| 49 | int64_t GetPosition(void* context); | ||
| 50 | |||
| 51 | //! \copydoc KodiToAddonFuncTable_VFSEntry::GetChunkSize | ||
| 52 | int GetChunkSize(void* context); | ||
| 53 | |||
| 54 | //! \copydoc KodiToAddonFuncTable_VFSEntry::IoControl | ||
| 55 | int IoControl(void* context, XFILE::EIoControl request, void* param); | ||
| 56 | |||
| 57 | //! \copydoc KodiToAddonFuncTable_VFSEntry::Stat | ||
| 58 | int Stat(VFSURL* url, struct __stat64* buffer); | ||
| 59 | |||
| 60 | //! \copydoc KodiToAddonFuncTable_VFSEntry::Close | ||
| 61 | bool Close(void* context); | ||
| 62 | |||
| 63 | //! \copydoc KodiToAddonFuncTable_VFSEntry::Exists | ||
| 64 | bool Exists(VFSURL* url); | ||
| 65 | |||
| 66 | //! \copydoc KodiToAddonFuncTable_VFSEntry::ContainsFiles | ||
| 67 | void* ContainsFiles(VFSURL* url, VFSDirEntry** entries, int* num_entries, | ||
| 68 | char* rootpath); | ||
| 69 | |||
| 70 | //! \copydoc KodiToAddonFuncTable_VFSEntry::ClearOutIdle | ||
| 71 | void ClearOutIdle(); | ||
| 72 | |||
| 73 | //! \copydoc KodiToAddonFuncTable_VFSEntry::DisconnectAll | ||
| 74 | void DisconnectAll(); | ||
| 75 | |||
| 76 | //! \copydoc KodiToAddonFuncTable_VFSEntry::DirectoryExists | ||
| 77 | bool DirectoryExists(VFSURL* url); | ||
| 78 | |||
| 79 | //! \copydoc KodiToAddonFuncTable_VFSEntry::RemoveDirectory | ||
| 80 | bool RemoveDirectory(VFSURL* url); | ||
| 81 | |||
| 82 | //! \copydoc KodiToAddonFuncTable_VFSEntry::CreateDirectory | ||
| 83 | bool CreateDirectory(VFSURL* url); | ||
| 84 | |||
| 85 | //! \copydoc KodiToAddonFuncTable_VFSEntry::GetDirectory | ||
| 86 | void* GetDirectory(VFSURL* url, VFSDirEntry** entries, int* num_entries, | ||
| 87 | VFSCallbacks* callbacks); | ||
| 88 | |||
| 89 | //! \copydoc KodiToAddonFuncTable_VFSEntry::FreeDirectory | ||
| 90 | void FreeDirectory(void* ctx); | ||
| 91 | |||
| 92 | //! \copydoc KodiToAddonFuncTable_VFSEntry::Delete | ||
| 93 | bool Delete(VFSURL* url); | ||
| 94 | |||
| 95 | //! \copydoc KodiToAddonFuncTable_VFSEntry::Rename | ||
| 96 | bool Rename(VFSURL* url, VFSURL* url2); | ||
| 97 | |||
| 98 | //! \brief Function to export the above structure to Kodi | ||
| 99 | void __declspec(dllexport) get_addon(void* ptr) | ||
| 100 | { | ||
| 101 | AddonInstance_VFSEntry* vfs = static_cast<AddonInstance_VFSEntry*>(ptr); | ||
| 102 | vfs->toAddon.Open = Open; | ||
| 103 | vfs->toAddon.OpenForWrite = OpenForWrite; | ||
| 104 | vfs->toAddon.Read = Read; | ||
| 105 | vfs->toAddon.Write = Write; | ||
| 106 | vfs->toAddon.Seek = Seek; | ||
| 107 | vfs->toAddon.GetLength = GetLength; | ||
| 108 | vfs->toAddon.GetPosition = GetPosition; | ||
| 109 | vfs->toAddon.IoControl = IoControl; | ||
| 110 | vfs->toAddon.Stat = Stat; | ||
| 111 | vfs->toAddon.Close = Close; | ||
| 112 | vfs->toAddon.Exists = Exists; | ||
| 113 | vfs->toAddon.ClearOutIdle = ClearOutIdle; | ||
| 114 | vfs->toAddon.DisconnectAll = DisconnectAll; | ||
| 115 | vfs->toAddon.DirectoryExists = DirectoryExists; | ||
| 116 | vfs->toAddon.GetDirectory = GetDirectory; | ||
| 117 | vfs->toAddon.FreeDirectory = FreeDirectory; | ||
| 118 | vfs->toAddon.Truncate = Truncate; | ||
| 119 | vfs->toAddon.Delete = Delete; | ||
| 120 | vfs->toAddon.Rename = Rename; | ||
| 121 | vfs->toAddon.RemoveDirectory = RemoveDirectory; | ||
| 122 | vfs->toAddon.CreateDirectory = CreateDirectory; | ||
| 123 | vfs->toAddon.ContainsFiles = ContainsFiles; | ||
| 124 | vfs->toAddon.GetChunkSize = GetChunkSize; | ||
| 125 | }; | ||
| 126 | }; | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_types.h index b62c7b0..8c02b99 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_types.h | |||
| @@ -18,15 +18,255 @@ | |||
| 18 | */ | 18 | */ |
| 19 | #pragma once | 19 | #pragma once |
| 20 | 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 | |||
| 21 | #include <stdint.h> | 30 | #include <stdint.h> |
| 31 | #include "xbmc_addon_types.h" | ||
| 32 | #ifdef BUILD_KODI_ADDON | ||
| 33 | #include "IFileTypes.h" | ||
| 34 | #else | ||
| 35 | #include "filesystem/IFileTypes.h" | ||
| 36 | #include "PlatformDefs.h" | ||
| 37 | #endif | ||
| 22 | 38 | ||
| 23 | extern "C" | 39 | extern "C" |
| 24 | { | 40 | { |
| 41 | |||
| 42 | struct VFSProperty | ||
| 43 | { | ||
| 44 | char* name; | ||
| 45 | char* val; | ||
| 46 | }; | ||
| 47 | |||
| 25 | struct VFSDirEntry | 48 | struct VFSDirEntry |
| 26 | { | 49 | { |
| 27 | char* label; //!< item label | 50 | char* label; //!< item label |
| 51 | char* title; //!< item title | ||
| 28 | char* path; //!< item path | 52 | char* path; //!< item path |
| 53 | int num_props; //!< Number of properties attached to item | ||
| 54 | VFSProperty* properties; //!< Properties | ||
| 55 | //FILETIME mtime; //!< Mtime for file represented by item | ||
| 29 | bool folder; //!< Item is a folder | 56 | bool folder; //!< Item is a folder |
| 30 | uint64_t size; //!< Size of file represented by item | 57 | uint64_t size; //!< Size of file represented by item |
| 31 | }; | 58 | }; |
| 59 | |||
| 60 | struct VFSURL | ||
| 61 | { | ||
| 62 | const char* url; | ||
| 63 | const char* domain; | ||
| 64 | const char* hostname; | ||
| 65 | const char* filename; | ||
| 66 | unsigned int port; | ||
| 67 | const char* options; | ||
| 68 | const char* username; | ||
| 69 | const char* password; | ||
| 70 | const char* redacted; | ||
| 71 | const char* sharename; | ||
| 72 | }; | ||
| 73 | |||
| 74 | struct VFSCallbacks | ||
| 75 | { | ||
| 76 | //! \brief Require keyboard input | ||
| 77 | //! \param heading The heading of the keyboard dialog | ||
| 78 | //! \param input A pointer to the resulting string. Must be free'd by caller. | ||
| 79 | //! \return True if input was received, false otherwise | ||
| 80 | bool (__cdecl* GetKeyboardInput)(void* ctx, const char* heading, char** input); | ||
| 81 | |||
| 82 | //! \brief Display an error dialog | ||
| 83 | //! \param heading The heading of the error dialog | ||
| 84 | //! \param line1 The first line of the error dialog | ||
| 85 | //! \param line2 The second line of the error dialog. Can be NULL | ||
| 86 | //! \param line3 The third line of the error dialog. Can be NULL | ||
| 87 | void (__cdecl* SetErrorDialog)(void* ctx, const char* heading, const char* line1, const char* line2, const char* line3); | ||
| 88 | |||
| 89 | //! \brief Prompt the user for authentication of a URL | ||
| 90 | //! \param url The URL | ||
| 91 | void (__cdecl* RequireAuthentication)(void* ctx, const char* url); | ||
| 92 | |||
| 93 | //! \brief The context to be passed to the callbacks | ||
| 94 | void* ctx; | ||
| 95 | }; | ||
| 96 | |||
| 97 | typedef struct AddonProps_VFSEntry | ||
| 98 | { | ||
| 99 | int dummy; | ||
| 100 | } AddonProps_VFSEntry; | ||
| 101 | |||
| 102 | typedef AddonProps_VFSEntry VFS_PROPS; | ||
| 103 | |||
| 104 | typedef struct AddonToKodiFuncTable_VFSEntry | ||
| 105 | { | ||
| 106 | KODI_HANDLE kodiInstance; | ||
| 107 | } AddonToKodiFuncTable_VFSEntry; | ||
| 108 | |||
| 109 | typedef struct KodiToAddonFuncTable_VFSEntry | ||
| 110 | { | ||
| 111 | //! \brief Open a file for input | ||
| 112 | //! \param url The URL of the file | ||
| 113 | //! \return Context for the opened file | ||
| 114 | //! \sa IFile::Open | ||
| 115 | void* (__cdecl* Open) (VFSURL* url); | ||
| 116 | |||
| 117 | //! \brief Open a file for output | ||
| 118 | //! \param url The URL of the file | ||
| 119 | //! \param bOverwrite Whether or not to overwrite an existing file | ||
| 120 | //! \return Context for the opened file | ||
| 121 | //! \sa IFile::OpenForWrite | ||
| 122 | void* (__cdecl* OpenForWrite) (VFSURL* url, bool bOverWrite); | ||
| 123 | |||
| 124 | //! \brief Read from a file | ||
| 125 | //! \param context The context of the file | ||
| 126 | //! \param buffer The buffer to read data into | ||
| 127 | //! \param uiBufSize Number of bytes to read | ||
| 128 | //! \return Number of bytes read | ||
| 129 | //! \sa IFile::Read | ||
| 130 | ssize_t (__cdecl* Read) (void* context, void* buffer, size_t uiBufSize); | ||
| 131 | |||
| 132 | //! \brief Write to a file | ||
| 133 | //! \param context The context of the file | ||
| 134 | //! \param buffer The buffer to read data from | ||
| 135 | //! \param uiBufSize Number of bytes to write | ||
| 136 | //! \return Number of bytes written | ||
| 137 | //! \sa IFile::Write | ||
| 138 | ssize_t (__cdecl* Write) (void* context, const void* buffer, size_t uiBufSize); | ||
| 139 | |||
| 140 | //! \brief Seek in a file | ||
| 141 | //! \param context The context of the file | ||
| 142 | //! \param position The position to seek to | ||
| 143 | //! \param whence Position in file 'position' is relative to (SEEK_CUR, SEEK_SET, SEEK_END) | ||
| 144 | //! \return Offset in file after seek | ||
| 145 | //! \sa IFile::Seek | ||
| 146 | int64_t (__cdecl* Seek) (void* context, int64_t position, int whence); | ||
| 147 | |||
| 148 | //! \brief Truncate a file | ||
| 149 | //! \param context The context of the file | ||
| 150 | //! \param size The size to truncate the file to | ||
| 151 | //! \return 0 on success, -1 on error | ||
| 152 | //! \sa IFile::Truncate | ||
| 153 | int (__cdecl* Truncate) (void* context, int64_t size); | ||
| 154 | |||
| 155 | //! \brief Get total size of a file | ||
| 156 | //! \param context The context of the file | ||
| 157 | //! \return Total file size | ||
| 158 | //! \sa IFile::GetLength | ||
| 159 | int64_t (__cdecl* GetLength) (void* context); | ||
| 160 | |||
| 161 | //! \brief Get current position in a file | ||
| 162 | //! \param context The context of the file | ||
| 163 | //! \return Current position | ||
| 164 | //! \sa IFile::GetPosition | ||
| 165 | int64_t (__cdecl* GetPosition) (void* context); | ||
| 166 | |||
| 167 | //! \brief Get chunk size of a file | ||
| 168 | //! \param context The context of the file | ||
| 169 | //! \return Chunk size | ||
| 170 | //! \sa IFile::GetChunkSize() | ||
| 171 | int (__cdecl* GetChunkSize)(void* context); | ||
| 172 | |||
| 173 | //! \brief Perform an IO-control on the file | ||
| 174 | //! \param context The context of the file | ||
| 175 | //! \param request The requested IO-control | ||
| 176 | //! \param param Parameter attached to the IO-control | ||
| 177 | //! \return -1 on error, >= 0 on success | ||
| 178 | //! \sa IFile::IoControl | ||
| 179 | int (__cdecl* IoControl) (void* context, XFILE::EIoControl request, void* param); | ||
| 180 | |||
| 181 | //! \brief Stat a file | ||
| 182 | //! \param url The URL of the file | ||
| 183 | //! \param buffer The buffer to store results in | ||
| 184 | //! \return -1 on error, 0 otherwise | ||
| 185 | //! \sa IFile::Stat | ||
| 186 | int (__cdecl* Stat) (VFSURL* url, struct __stat64* buffer); | ||
| 187 | //! \brief Close a file | ||
| 188 | //! \param context The context of the file | ||
| 189 | //! \return True on success, false on failure | ||
| 190 | //! \sa IFile::Close | ||
| 191 | |||
| 192 | bool (__cdecl* Close) (void* context); | ||
| 193 | |||
| 194 | //! \brief Check for file existence | ||
| 195 | //! \param url The URL of the file | ||
| 196 | //! \return True if file exists, false otherwise | ||
| 197 | //! \sa IFile::Exists | ||
| 198 | bool (__cdecl* Exists) (VFSURL* url); | ||
| 199 | |||
| 200 | //! \brief Clear out any idle connections | ||
| 201 | void (__cdecl* ClearOutIdle) (); | ||
| 202 | |||
| 203 | //! \brief Disconnect all connections | ||
| 204 | void (__cdecl* DisconnectAll) (); | ||
| 205 | |||
| 206 | //! \brief Delete a file | ||
| 207 | //! \param url The URL of the file | ||
| 208 | //! \return True if deletion was successful, false otherwise | ||
| 209 | //! \sa IFile::Delete | ||
| 210 | bool (__cdecl* Delete) (VFSURL* url); | ||
| 211 | |||
| 212 | //! \brief Rename a file | ||
| 213 | //! \param url The URL of the source file | ||
| 214 | //! \param url2 The URL of the destination file | ||
| 215 | //! \return True if deletion was successful, false otherwise | ||
| 216 | //! \sa IFile::Rename | ||
| 217 | bool (__cdecl* Rename) (VFSURL* url, VFSURL* url2); | ||
| 218 | |||
| 219 | //! \brief Check for directory existence | ||
| 220 | //! \param url The URL of the file | ||
| 221 | //! \return True if directory exists, false otherwise | ||
| 222 | //! \sa IDirectory::Exists | ||
| 223 | bool (__cdecl* DirectoryExists) (VFSURL* url); | ||
| 224 | |||
| 225 | //! \brief Remove a directory | ||
| 226 | //! \param url The URL of the directory | ||
| 227 | //! \return True if removal was successful, false otherwise | ||
| 228 | //! \sa IDirectory::Remove | ||
| 229 | bool (__cdecl* RemoveDirectory) (VFSURL* url); | ||
| 230 | |||
| 231 | //! \brief Create a directory | ||
| 232 | //! \param url The URL of the file | ||
| 233 | //! \return True if creation was successful, false otherwise | ||
| 234 | //! \sa IDirectory::Create | ||
| 235 | bool (__cdecl* CreateDirectory) (VFSURL* url); | ||
| 236 | |||
| 237 | //! \brief List a directory | ||
| 238 | //! \param url The URL of the directory | ||
| 239 | //! \param entries The entries in the directory | ||
| 240 | //! \param num_entries Number of entries in the directory | ||
| 241 | //! \param callbacks A callback structure | ||
| 242 | //! \return Context for the directory listing | ||
| 243 | //! \sa IDirectory::GetDirectory | ||
| 244 | void* (__cdecl* GetDirectory) (VFSURL* url, | ||
| 245 | VFSDirEntry** entries, | ||
| 246 | int* num_entries, | ||
| 247 | VFSCallbacks* callbacks); | ||
| 248 | |||
| 249 | //! \brief Free up resources after listing a directory | ||
| 250 | void (__cdecl* FreeDirectory) (void* ctx); | ||
| 251 | |||
| 252 | //! \brief Check if file should be presented as a directory (multiple streams) | ||
| 253 | //! \param url The URL of the file | ||
| 254 | //! \param entries The entries in the directory | ||
| 255 | //! \param num_entries Number of entries in the directory | ||
| 256 | //! \param rootpath Path to root directory if multiple entries | ||
| 257 | //! \return Context for the directory listing | ||
| 258 | //! \sa IFileDirectory::ContainsFiles, FreeDirectory | ||
| 259 | void* (__cdecl* ContainsFiles) (VFSURL* url, | ||
| 260 | VFSDirEntry** entries, | ||
| 261 | int* num_entries, | ||
| 262 | char* rootpath); | ||
| 263 | } KodiToAddonFuncTable_VFSEntry; | ||
| 264 | |||
| 265 | typedef struct AddonInstance_VFSEntry | ||
| 266 | { | ||
| 267 | AddonProps_VFSEntry props; | ||
| 268 | AddonToKodiFuncTable_VFSEntry toKodi; | ||
| 269 | KodiToAddonFuncTable_VFSEntry toAddon; | ||
| 270 | } AddonInstance_VFSEntry; | ||
| 271 | |||
| 32 | } | 272 | } |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h index fb0c15f..d4ea283 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h | |||
| @@ -27,29 +27,104 @@ | |||
| 27 | #include "kodi_adsp_types.h" | 27 | #include "kodi_adsp_types.h" |
| 28 | #include "libXBMC_addon.h" | 28 | #include "libXBMC_addon.h" |
| 29 | 29 | ||
| 30 | typedef void* ADSPHANDLE; | 30 | class CAddonSoundPlay |
| 31 | { | ||
| 32 | public: | ||
| 33 | CAddonSoundPlay(AddonCB* hdl, AddonInstance_AudioDSP* cb, const char* filename) | ||
| 34 | : m_Filename(filename), | ||
| 35 | m_Handle(hdl), | ||
| 36 | m_cb(cb) | ||
| 37 | { | ||
| 38 | m_PlayHandle = nullptr; | ||
| 39 | if (!hdl || !cb) | ||
| 40 | fprintf(stderr, "libKODI_adsp-ERROR: ADSP_get_sound_play is called with NULL handle !!!\n"); | ||
| 41 | else | ||
| 42 | { | ||
| 43 | m_PlayHandle = m_cb->toKodi.SoundPlay_GetHandle(m_cb->toKodi.kodiInstance, m_Filename.c_str()); | ||
| 44 | if (!m_PlayHandle) | ||
| 45 | fprintf(stderr, "libKODI_adsp-ERROR: ADSP_get_sound_play can't get callback table from KODI !!!\n"); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | ~CAddonSoundPlay() | ||
| 50 | { | ||
| 51 | if (m_PlayHandle) | ||
| 52 | m_cb->toKodi.SoundPlay_ReleaseHandle(m_cb->toKodi.kodiInstance, m_PlayHandle); | ||
| 53 | } | ||
| 54 | |||
| 55 | /*! play the sound this object represents */ | ||
| 56 | void Play() | ||
| 57 | { | ||
| 58 | if (m_PlayHandle) | ||
| 59 | m_cb->toKodi.SoundPlay_Play(m_cb->toKodi.kodiInstance, m_PlayHandle); | ||
| 60 | } | ||
| 31 | 61 | ||
| 32 | #define ADSP_HELPER_DLL KODI_DLL("adsp") | ||
| 33 | #define ADSP_HELPER_DLL_NAME KODI_DLL_NAME("adsp") | ||
| 34 | 62 | ||
| 35 | class CAddonSoundPlay; | 63 | /*! stop playing the sound this object represents */ |
| 64 | void Stop() | ||
| 65 | { | ||
| 66 | if (m_PlayHandle) | ||
| 67 | m_cb->toKodi.SoundPlay_Stop(m_cb->toKodi.kodiInstance, m_PlayHandle); | ||
| 68 | } | ||
| 69 | |||
| 70 | /*! return true if the sound is currently playing */ | ||
| 71 | bool IsPlaying() | ||
| 72 | { | ||
| 73 | if (!m_PlayHandle) | ||
| 74 | return false; | ||
| 75 | |||
| 76 | return m_cb->toKodi.SoundPlay_IsPlaying(m_cb->toKodi.kodiInstance, m_PlayHandle); | ||
| 77 | } | ||
| 78 | |||
| 79 | /*! set the playback channel position of this sound, AE_DSP_CH_INVALID for all */ | ||
| 80 | void SetChannel(AE_DSP_CHANNEL channel) | ||
| 81 | { | ||
| 82 | if (m_PlayHandle) | ||
| 83 | m_cb->toKodi.SoundPlay_SetChannel(m_cb->toKodi.kodiInstance, m_PlayHandle, channel); | ||
| 84 | } | ||
| 85 | |||
| 86 | /*! get the current playback volume of this sound, AE_DSP_CH_INVALID for all */ | ||
| 87 | AE_DSP_CHANNEL GetChannel() | ||
| 88 | { | ||
| 89 | if (!m_PlayHandle) | ||
| 90 | return AE_DSP_CH_INVALID; | ||
| 91 | return m_cb->toKodi.SoundPlay_GetChannel(m_cb->toKodi.kodiInstance, m_PlayHandle); | ||
| 92 | } | ||
| 93 | |||
| 94 | /*! set the playback volume of this sound */ | ||
| 95 | void SetVolume(float volume) | ||
| 96 | { | ||
| 97 | if (m_PlayHandle) | ||
| 98 | m_cb->toKodi.SoundPlay_SetVolume(m_cb->toKodi.kodiInstance, m_PlayHandle, volume); | ||
| 99 | } | ||
| 100 | |||
| 101 | /*! get the current playback volume of this sound */ | ||
| 102 | float GetVolume() | ||
| 103 | { | ||
| 104 | if (!m_PlayHandle) | ||
| 105 | return 0.0f; | ||
| 106 | |||
| 107 | return m_cb->toKodi.SoundPlay_GetVolume(m_cb->toKodi.kodiInstance, m_PlayHandle); | ||
| 108 | } | ||
| 109 | |||
| 110 | private: | ||
| 111 | std::string m_Filename; | ||
| 112 | AddonCB* m_Handle; | ||
| 113 | AddonInstance_AudioDSP *m_cb; | ||
| 114 | ADSPHANDLE m_PlayHandle; | ||
| 115 | }; | ||
| 36 | 116 | ||
| 37 | class CHelper_libKODI_adsp | 117 | class CHelper_libKODI_adsp |
| 38 | { | 118 | { |
| 39 | public: | 119 | public: |
| 40 | CHelper_libKODI_adsp(void) | 120 | CHelper_libKODI_adsp(void) |
| 41 | { | 121 | { |
| 42 | m_libKODI_adsp = NULL; | 122 | m_Handle = nullptr; |
| 43 | m_Handle = NULL; | 123 | m_Callbacks = nullptr; |
| 44 | } | 124 | } |
| 45 | 125 | ||
| 46 | ~CHelper_libKODI_adsp(void) | 126 | ~CHelper_libKODI_adsp(void) |
| 47 | { | 127 | { |
| 48 | if (m_libKODI_adsp) | ||
| 49 | { | ||
| 50 | ADSP_unregister_me(m_Handle, m_Callbacks); | ||
| 51 | dlclose(m_libKODI_adsp); | ||
| 52 | } | ||
| 53 | } | 128 | } |
| 54 | 129 | ||
| 55 | /*! | 130 | /*! |
| @@ -59,53 +134,13 @@ public: | |||
| 59 | */ | 134 | */ |
| 60 | bool RegisterMe(void* handle) | 135 | bool RegisterMe(void* handle) |
| 61 | { | 136 | { |
| 62 | m_Handle = handle; | 137 | m_Handle = static_cast<AddonCB*>(handle); |
| 63 | 138 | if (m_Handle) | |
| 64 | std::string libBasePath; | 139 | m_Callbacks = (AddonInstance_AudioDSP*)m_Handle->ADSPLib_RegisterMe(m_Handle->addonData); |
| 65 | libBasePath = ((cb_array*)m_Handle)->libPath; | 140 | if (!m_Callbacks) |
| 66 | libBasePath += ADSP_HELPER_DLL; | 141 | fprintf(stderr, "libKODI_adsp-ERROR: ADSLib_RegisterMe can't get callback table from Kodi !!!\n"); |
| 67 | |||
| 68 | m_libKODI_adsp = dlopen(libBasePath.c_str(), RTLD_LAZY); | ||
| 69 | if (m_libKODI_adsp == NULL) | ||
| 70 | { | ||
| 71 | fprintf(stderr, "Unable to load %s\n", dlerror()); | ||
| 72 | return false; | ||
| 73 | } | ||
| 74 | |||
| 75 | ADSP_register_me = (void* (*)(void *HANDLE)) | ||
| 76 | dlsym(m_libKODI_adsp, "ADSP_register_me"); | ||
| 77 | if (ADSP_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 78 | |||
| 79 | ADSP_unregister_me = (void (*)(void* HANDLE, void* CB)) | ||
| 80 | dlsym(m_libKODI_adsp, "ADSP_unregister_me"); | ||
| 81 | if (ADSP_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 82 | 142 | ||
| 83 | ADSP_add_menu_hook = (void (*)(void* HANDLE, void* CB, AE_DSP_MENUHOOK *hook)) | 143 | return m_Callbacks != nullptr; |
| 84 | dlsym(m_libKODI_adsp, "ADSP_add_menu_hook"); | ||
| 85 | if (ADSP_add_menu_hook == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 86 | |||
| 87 | ADSP_remove_menu_hook = (void (*)(void* HANDLE, void* CB, AE_DSP_MENUHOOK *hook)) | ||
| 88 | dlsym(m_libKODI_adsp, "ADSP_remove_menu_hook"); | ||
| 89 | if (ADSP_remove_menu_hook == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 90 | |||
| 91 | ADSP_register_mode = (void (*)(void *HANDLE, void* CB, AE_DSP_MODES::AE_DSP_MODE *modes)) | ||
| 92 | dlsym(m_libKODI_adsp, "ADSP_register_mode"); | ||
| 93 | if (ADSP_register_mode == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 94 | |||
| 95 | ADSP_unregister_mode = (void (*)(void* HANDLE, void* CB, AE_DSP_MODES::AE_DSP_MODE *modes)) | ||
| 96 | dlsym(m_libKODI_adsp, "ADSP_unregister_mode"); | ||
| 97 | if (ADSP_unregister_mode == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 98 | |||
| 99 | ADSP_get_sound_play = (CAddonSoundPlay* (*)(void *HANDLE, void *CB, const char *filename)) | ||
| 100 | dlsym(m_libKODI_adsp, "ADSP_get_sound_play"); | ||
| 101 | if (ADSP_get_sound_play == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 102 | |||
| 103 | ADSP_release_sound_play = (void (*)(CAddonSoundPlay* p)) | ||
| 104 | dlsym(m_libKODI_adsp, "ADSP_release_sound_play"); | ||
| 105 | if (ADSP_release_sound_play == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 106 | |||
| 107 | m_Callbacks = ADSP_register_me(m_Handle); | ||
| 108 | return m_Callbacks != NULL; | ||
| 109 | } | 144 | } |
| 110 | 145 | ||
| 111 | /*! | 146 | /*! |
| @@ -114,7 +149,7 @@ public: | |||
| 114 | */ | 149 | */ |
| 115 | void AddMenuHook(AE_DSP_MENUHOOK* hook) | 150 | void AddMenuHook(AE_DSP_MENUHOOK* hook) |
| 116 | { | 151 | { |
| 117 | return ADSP_add_menu_hook(m_Handle, m_Callbacks, hook); | 152 | return m_Callbacks->toKodi.AddMenuHook(m_Callbacks->toKodi.kodiInstance, hook); |
| 118 | } | 153 | } |
| 119 | 154 | ||
| 120 | /*! | 155 | /*! |
| @@ -123,7 +158,7 @@ public: | |||
| 123 | */ | 158 | */ |
| 124 | void RemoveMenuHook(AE_DSP_MENUHOOK* hook) | 159 | void RemoveMenuHook(AE_DSP_MENUHOOK* hook) |
| 125 | { | 160 | { |
| 126 | return ADSP_remove_menu_hook(m_Handle, m_Callbacks, hook); | 161 | return m_Callbacks->toKodi.RemoveMenuHook(m_Callbacks->toKodi.kodiInstance, hook); |
| 127 | } | 162 | } |
| 128 | 163 | ||
| 129 | /*! | 164 | /*! |
| @@ -133,7 +168,7 @@ public: | |||
| 133 | */ | 168 | */ |
| 134 | void RegisterMode(AE_DSP_MODES::AE_DSP_MODE* mode) | 169 | void RegisterMode(AE_DSP_MODES::AE_DSP_MODE* mode) |
| 135 | { | 170 | { |
| 136 | return ADSP_register_mode(m_Handle, m_Callbacks, mode); | 171 | return m_Callbacks->toKodi.RegisterMode(m_Callbacks->toKodi.kodiInstance, mode); |
| 137 | } | 172 | } |
| 138 | 173 | ||
| 139 | /*! | 174 | /*! |
| @@ -142,7 +177,7 @@ public: | |||
| 142 | */ | 177 | */ |
| 143 | void UnregisterMode(AE_DSP_MODES::AE_DSP_MODE* mode) | 178 | void UnregisterMode(AE_DSP_MODES::AE_DSP_MODE* mode) |
| 144 | { | 179 | { |
| 145 | return ADSP_unregister_mode(m_Handle, m_Callbacks, mode); | 180 | return m_Callbacks->toKodi.UnregisterMode(m_Callbacks->toKodi.kodiInstance, mode); |
| 146 | } | 181 | } |
| 147 | 182 | ||
| 148 | /*! | 183 | /*! |
| @@ -151,7 +186,7 @@ public: | |||
| 151 | */ | 186 | */ |
| 152 | CAddonSoundPlay* GetSoundPlay(const char *filename) | 187 | CAddonSoundPlay* GetSoundPlay(const char *filename) |
| 153 | { | 188 | { |
| 154 | return ADSP_get_sound_play(m_Handle, m_Callbacks, filename); | 189 | return new CAddonSoundPlay(m_Handle, m_Callbacks, filename); |
| 155 | } | 190 | } |
| 156 | 191 | ||
| 157 | /*! | 192 | /*! |
| @@ -160,60 +195,10 @@ public: | |||
| 160 | */ | 195 | */ |
| 161 | void ReleaseSoundPlay(CAddonSoundPlay* p) | 196 | void ReleaseSoundPlay(CAddonSoundPlay* p) |
| 162 | { | 197 | { |
| 163 | return ADSP_release_sound_play(p); | 198 | delete p; |
| 164 | } | 199 | } |
| 165 | 200 | ||
| 166 | protected: | ||
| 167 | void* (*ADSP_register_me)(void*); | ||
| 168 | |||
| 169 | void (*ADSP_unregister_me)(void*, void*); | ||
| 170 | void (*ADSP_add_menu_hook)(void*, void*, AE_DSP_MENUHOOK*); | ||
| 171 | void (*ADSP_remove_menu_hook)(void*, void*, AE_DSP_MENUHOOK*); | ||
| 172 | void (*ADSP_register_mode)(void*, void*, AE_DSP_MODES::AE_DSP_MODE*); | ||
| 173 | void (*ADSP_unregister_mode)(void*, void*, AE_DSP_MODES::AE_DSP_MODE*); | ||
| 174 | CAddonSoundPlay* (*ADSP_get_sound_play)(void*, void*, const char *); | ||
| 175 | void (*ADSP_release_sound_play)(CAddonSoundPlay*); | ||
| 176 | |||
| 177 | private: | 201 | private: |
| 178 | void* m_libKODI_adsp; | 202 | AddonCB* m_Handle; |
| 179 | void* m_Handle; | 203 | AddonInstance_AudioDSP *m_Callbacks; |
| 180 | void* m_Callbacks; | ||
| 181 | struct cb_array | ||
| 182 | { | ||
| 183 | const char* libPath; | ||
| 184 | }; | ||
| 185 | }; | ||
| 186 | |||
| 187 | class CAddonSoundPlay | ||
| 188 | { | ||
| 189 | public: | ||
| 190 | CAddonSoundPlay(void *hdl, void *cb, const char *filename); | ||
| 191 | virtual ~CAddonSoundPlay(); | ||
| 192 | |||
| 193 | /*! play the sound this object represents */ | ||
| 194 | virtual void Play(); | ||
| 195 | |||
| 196 | /*! stop playing the sound this object represents */ | ||
| 197 | virtual void Stop(); | ||
| 198 | |||
| 199 | /*! return true if the sound is currently playing */ | ||
| 200 | virtual bool IsPlaying(); | ||
| 201 | |||
| 202 | /*! set the playback channel position of this sound, AE_DSP_CH_INVALID for all */ | ||
| 203 | virtual void SetChannel(AE_DSP_CHANNEL channel); | ||
| 204 | |||
| 205 | /*! get the current playback volume of this sound, AE_DSP_CH_INVALID for all */ | ||
| 206 | virtual AE_DSP_CHANNEL GetChannel(); | ||
| 207 | |||
| 208 | /*! set the playback volume of this sound */ | ||
| 209 | virtual void SetVolume(float volume); | ||
| 210 | |||
| 211 | /*! get the current playback volume of this sound */ | ||
| 212 | virtual float GetVolume(); | ||
| 213 | |||
| 214 | private: | ||
| 215 | std::string m_Filename; | ||
| 216 | void *m_Handle; | ||
| 217 | void *m_cb; | ||
| 218 | ADSPHANDLE m_PlayHandle; | ||
| 219 | }; | 204 | }; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h deleted file mode 100644 index 7dbf7af..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h +++ /dev/null | |||
| @@ -1,306 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2014 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <stdio.h> | ||
| 23 | #include <stdlib.h> | ||
| 24 | #include <string> | ||
| 25 | #include <string.h> | ||
| 26 | #include <vector> | ||
| 27 | |||
| 28 | #include "kodi_audioengine_types.h" | ||
| 29 | #ifdef BUILD_KODI_ADDON | ||
| 30 | #include "kodi/AudioEngine/AEChannelData.h" | ||
| 31 | #include "kodi/AudioEngine/AEChannelInfo.h" | ||
| 32 | #include "kodi/AudioEngine/AEStreamData.h" | ||
| 33 | #else | ||
| 34 | #include "cores/AudioEngine/Utils/AEChannelData.h" | ||
| 35 | #include "cores/AudioEngine/Utils/AEChannelInfo.h" | ||
| 36 | #include "cores/AudioEngine/Utils/AEStreamData.h" | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #include "libXBMC_addon.h" | ||
| 40 | |||
| 41 | #define AUDIOENGINE_HELPER_DLL KODI_DLL("audioengine") | ||
| 42 | #define AUDIOENGINE_HELPER_DLL_NAME KODI_DLL_NAME("audioengine") | ||
| 43 | |||
| 44 | class CAddonAEStream; | ||
| 45 | |||
| 46 | class CHelper_libKODI_audioengine | ||
| 47 | { | ||
| 48 | public: | ||
| 49 | CHelper_libKODI_audioengine(void) | ||
| 50 | { | ||
| 51 | m_libKODI_audioengine = NULL; | ||
| 52 | m_Handle = NULL; | ||
| 53 | } | ||
| 54 | |||
| 55 | ~CHelper_libKODI_audioengine(void) | ||
| 56 | { | ||
| 57 | if (m_libKODI_audioengine) | ||
| 58 | { | ||
| 59 | AudioEngine_unregister_me(m_Handle, m_Callbacks); | ||
| 60 | dlclose(m_libKODI_audioengine); | ||
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 | /*! | ||
| 65 | * @brief Resolve all callback methods | ||
| 66 | * @param handle Pointer to the add-on | ||
| 67 | * @return True when all methods were resolved, false otherwise. | ||
| 68 | */ | ||
| 69 | bool RegisterMe(void* handle) | ||
| 70 | { | ||
| 71 | m_Handle = handle; | ||
| 72 | |||
| 73 | std::string libBasePath; | ||
| 74 | libBasePath = ((cb_array*)m_Handle)->libPath; | ||
| 75 | libBasePath += AUDIOENGINE_HELPER_DLL; | ||
| 76 | |||
| 77 | m_libKODI_audioengine = dlopen(libBasePath.c_str(), RTLD_LAZY); | ||
| 78 | if (m_libKODI_audioengine == NULL) | ||
| 79 | { | ||
| 80 | fprintf(stderr, "Unable to load %s\n", dlerror()); | ||
| 81 | return false; | ||
| 82 | } | ||
| 83 | |||
| 84 | AudioEngine_register_me = (void* (*)(void *HANDLE)) | ||
| 85 | dlsym(m_libKODI_audioengine, "AudioEngine_register_me"); | ||
| 86 | if (AudioEngine_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 87 | |||
| 88 | AudioEngine_unregister_me = (void(*)(void* HANDLE, void* CB)) | ||
| 89 | dlsym(m_libKODI_audioengine, "AudioEngine_unregister_me"); | ||
| 90 | if (AudioEngine_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 91 | |||
| 92 | AudioEngine_MakeStream = (CAddonAEStream* (*)(void*, void*, AudioEngineFormat, unsigned int)) | ||
| 93 | dlsym(m_libKODI_audioengine, "AudioEngine_make_stream"); | ||
| 94 | if (AudioEngine_MakeStream == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 95 | |||
| 96 | AudioEngine_FreeStream = (void(*)(CAddonAEStream*)) | ||
| 97 | dlsym(m_libKODI_audioengine, "AudioEngine_free_stream"); | ||
| 98 | if (AudioEngine_FreeStream == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 99 | |||
| 100 | AudioEngine_GetCurrentSinkFormat = (bool(*)(void*, void*, AudioEngineFormat*)) | ||
| 101 | dlsym(m_libKODI_audioengine, "AudioEngine_get_current_sink_Format"); | ||
| 102 | if (AudioEngine_GetCurrentSinkFormat == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 103 | |||
| 104 | m_Callbacks = AudioEngine_register_me(m_Handle); | ||
| 105 | return m_Callbacks != NULL; | ||
| 106 | } | ||
| 107 | |||
| 108 | /** | ||
| 109 | * Creates and returns a new handle to an IAEStream in the format specified, this function should never fail | ||
| 110 | * @param DataFormat The data format the incoming audio will be in (eg, AE_FMT_S16LE) | ||
| 111 | * @param SampleRate The sample rate of the audio data (eg, 48000) | ||
| 112 | * @param ChannelLayout The order of the channels in the audio data | ||
| 113 | * @param Options A bit field of stream options (see: enum AEStreamOptions) | ||
| 114 | * @return a new Handle to an IAEStream that will accept data in the requested format | ||
| 115 | */ | ||
| 116 | CAddonAEStream* MakeStream(AudioEngineFormat Format, unsigned int Options = 0) | ||
| 117 | { | ||
| 118 | return AudioEngine_MakeStream(m_Handle, m_Callbacks, Format, Options); | ||
| 119 | } | ||
| 120 | |||
| 121 | /** | ||
| 122 | * This method will remove the specifyed stream from the engine. | ||
| 123 | * For OSX/IOS this is essential to reconfigure the audio output. | ||
| 124 | * @param stream The stream to be altered | ||
| 125 | * @return NULL | ||
| 126 | */ | ||
| 127 | void FreeStream(CAddonAEStream **Stream) | ||
| 128 | { | ||
| 129 | AudioEngine_FreeStream(*Stream); | ||
| 130 | *Stream = NULL; | ||
| 131 | } | ||
| 132 | |||
| 133 | /** | ||
| 134 | * Get the current sink data format | ||
| 135 | * | ||
| 136 | * @param Current sink data format. For more details see AudioEngineFormat. | ||
| 137 | * @return Returns true on success, else false. | ||
| 138 | */ | ||
| 139 | bool GetCurrentSinkFormat(AudioEngineFormat &SinkFormat) | ||
| 140 | { | ||
| 141 | return AudioEngine_GetCurrentSinkFormat(m_Handle, m_Callbacks, &SinkFormat); | ||
| 142 | } | ||
| 143 | |||
| 144 | protected: | ||
| 145 | void* (*AudioEngine_register_me)(void*); | ||
| 146 | void (*AudioEngine_unregister_me)(void*, void*); | ||
| 147 | CAddonAEStream* (*AudioEngine_MakeStream)(void*, void*, AudioEngineFormat, unsigned int); | ||
| 148 | bool (*AudioEngine_GetCurrentSinkFormat)(void*, void*, AudioEngineFormat *SinkFormat); | ||
| 149 | void (*AudioEngine_FreeStream)(CAddonAEStream*); | ||
| 150 | |||
| 151 | private: | ||
| 152 | void* m_libKODI_audioengine; | ||
| 153 | void* m_Handle; | ||
| 154 | void* m_Callbacks; | ||
| 155 | struct cb_array | ||
| 156 | { | ||
| 157 | const char* libPath; | ||
| 158 | }; | ||
| 159 | }; | ||
| 160 | |||
| 161 | // Audio Engine Stream Class | ||
| 162 | class CAddonAEStream | ||
| 163 | { | ||
| 164 | public: | ||
| 165 | CAddonAEStream(void *Addon, void *Callbacks, AEStreamHandle *StreamHandle); | ||
| 166 | virtual ~CAddonAEStream(); | ||
| 167 | |||
| 168 | /** | ||
| 169 | * Returns the amount of space available in the stream | ||
| 170 | * @return The number of bytes AddData will consume | ||
| 171 | */ | ||
| 172 | virtual unsigned int GetSpace(); | ||
| 173 | |||
| 174 | /** | ||
| 175 | * Add planar or interleaved PCM data to the stream | ||
| 176 | * @param Data array of pointers to the planes | ||
| 177 | * @param Offset to frame in frames | ||
| 178 | * @param Frames number of frames | ||
| 179 | * @return The number of frames consumed | ||
| 180 | */ | ||
| 181 | virtual unsigned int AddData(uint8_t* const *Data, unsigned int Offset, unsigned int Frames); | ||
| 182 | |||
| 183 | /** | ||
| 184 | * Returns the time in seconds that it will take | ||
| 185 | * for the next added packet to be heard from the speakers. | ||
| 186 | * @return seconds | ||
| 187 | */ | ||
| 188 | virtual double GetDelay(); | ||
| 189 | |||
| 190 | /** | ||
| 191 | * Returns if the stream is buffering | ||
| 192 | * @return True if the stream is buffering | ||
| 193 | */ | ||
| 194 | virtual bool IsBuffering(); | ||
| 195 | |||
| 196 | /** | ||
| 197 | * Returns the time in seconds of the stream's | ||
| 198 | * cached audio samples. Engine buffers excluded. | ||
| 199 | * @return seconds | ||
| 200 | */ | ||
| 201 | virtual double GetCacheTime(); | ||
| 202 | |||
| 203 | /** | ||
| 204 | * Returns the total time in seconds of the cache | ||
| 205 | * @return seconds | ||
| 206 | */ | ||
| 207 | virtual double GetCacheTotal(); | ||
| 208 | |||
| 209 | /** | ||
| 210 | * Pauses the stream playback | ||
| 211 | */ | ||
| 212 | virtual void Pause(); | ||
| 213 | |||
| 214 | /** | ||
| 215 | * Resumes the stream after pausing | ||
| 216 | */ | ||
| 217 | virtual void Resume(); | ||
| 218 | |||
| 219 | /** | ||
| 220 | * Start draining the stream | ||
| 221 | * @note Once called AddData will not consume more data. | ||
| 222 | */ | ||
| 223 | virtual void Drain(bool Wait); | ||
| 224 | |||
| 225 | /** | ||
| 226 | * Returns true if the is stream draining | ||
| 227 | */ | ||
| 228 | virtual bool IsDraining(); | ||
| 229 | |||
| 230 | /** | ||
| 231 | * Returns true if the is stream has finished draining | ||
| 232 | */ | ||
| 233 | virtual bool IsDrained(); | ||
| 234 | |||
| 235 | /** | ||
| 236 | * Flush all buffers dropping the audio data | ||
| 237 | */ | ||
| 238 | virtual void Flush(); | ||
| 239 | |||
| 240 | /** | ||
| 241 | * Return the stream's current volume level | ||
| 242 | * @return The volume level between 0.0 and 1.0 | ||
| 243 | */ | ||
| 244 | virtual float GetVolume(); | ||
| 245 | |||
| 246 | /** | ||
| 247 | * Set the stream's volume level | ||
| 248 | * @param volume The new volume level between 0.0 and 1.0 | ||
| 249 | */ | ||
| 250 | virtual void SetVolume(float Volume); | ||
| 251 | |||
| 252 | /** | ||
| 253 | * Gets the stream's volume amplification in linear units. | ||
| 254 | * @return The volume amplification factor between 1.0 and 1000.0 | ||
| 255 | */ | ||
| 256 | virtual float GetAmplification(); | ||
| 257 | |||
| 258 | /** | ||
| 259 | * Sets the stream's volume amplification in linear units. | ||
| 260 | * @param The volume amplification factor between 1.0 and 1000.0 | ||
| 261 | */ | ||
| 262 | virtual void SetAmplification(float Amplify); | ||
| 263 | |||
| 264 | /** | ||
| 265 | * Returns the size of one audio frame in bytes (channelCount * resolution) | ||
| 266 | * @return The size in bytes of one frame | ||
| 267 | */ | ||
| 268 | virtual const unsigned int GetFrameSize() const; | ||
| 269 | |||
| 270 | /** | ||
| 271 | * Returns the number of channels the stream is configured to accept | ||
| 272 | * @return The channel count | ||
| 273 | */ | ||
| 274 | virtual const unsigned int GetChannelCount() const; | ||
| 275 | |||
| 276 | /** | ||
| 277 | * Returns the stream's sample rate, if the stream is using a dynamic sample rate, this value will NOT reflect any changes made by calls to SetResampleRatio() | ||
| 278 | * @return The stream's sample rate (eg, 48000) | ||
| 279 | */ | ||
| 280 | virtual const unsigned int GetSampleRate() const; | ||
| 281 | |||
| 282 | /** | ||
| 283 | * Return the data format the stream has been configured with | ||
| 284 | * @return The stream's data format (eg, AE_FMT_S16LE) | ||
| 285 | */ | ||
| 286 | virtual const AEDataFormat GetDataFormat() const; | ||
| 287 | |||
| 288 | /** | ||
| 289 | * Return the resample ratio | ||
| 290 | * @note This will return an undefined value if the stream is not resampling | ||
| 291 | * @return the current resample ratio or undefined if the stream is not resampling | ||
| 292 | */ | ||
| 293 | virtual double GetResampleRatio(); | ||
| 294 | |||
| 295 | /** | ||
| 296 | * Sets the resample ratio | ||
| 297 | * @note This function may return false if the stream is not resampling, if you wish to use this be sure to set the AESTREAM_FORCE_RESAMPLE option | ||
| 298 | * @param ratio the new sample rate ratio, calculated by ((double)desiredRate / (double)GetSampleRate()) | ||
| 299 | */ | ||
| 300 | virtual void SetResampleRatio(double Ratio); | ||
| 301 | |||
| 302 | private: | ||
| 303 | AEStreamHandle *m_StreamHandle; | ||
| 304 | void *m_Callbacks; | ||
| 305 | void *m_AddonHandle; | ||
| 306 | }; | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h index b5a46dd..1ca91a4 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2014-2016 Team Kodi | 2 | * Copyright (C) 2014-2017 Team Kodi |
| 3 | * http://kodi.tv | 3 | * http://kodi.tv |
| 4 | * | 4 | * |
| 5 | * This Program is free software; you can redistribute it and/or modify | 5 | * This Program is free software; you can redistribute it and/or modify |
| @@ -20,7 +20,7 @@ | |||
| 20 | #pragma once | 20 | #pragma once |
| 21 | 21 | ||
| 22 | #include "libXBMC_addon.h" | 22 | #include "libXBMC_addon.h" |
| 23 | #include "kodi_game_callbacks.h" | 23 | #include "kodi_game_types.h" |
| 24 | 24 | ||
| 25 | #include <string> | 25 | #include <string> |
| 26 | #include <stdio.h> | 26 | #include <stdio.h> |
| @@ -29,55 +29,17 @@ | |||
| 29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | #ifdef _WIN32 | ||
| 33 | #define GAME_HELPER_DLL "\\library.kodi.game\\libKODI_game" ADDON_HELPER_EXT | ||
| 34 | #else | ||
| 35 | #define GAME_HELPER_DLL_NAME "libKODI_game-" ADDON_HELPER_ARCH ADDON_HELPER_EXT | ||
| 36 | #define GAME_HELPER_DLL "/library.kodi.game/" GAME_HELPER_DLL_NAME | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #define GAME_REGISTER_SYMBOL(dll, functionPtr) \ | ||
| 40 | CHelper_libKODI_game::RegisterSymbol(dll, functionPtr, #functionPtr) | ||
| 41 | |||
| 42 | class CHelper_libKODI_game | 32 | class CHelper_libKODI_game |
| 43 | { | 33 | { |
| 44 | public: | 34 | public: |
| 45 | CHelper_libKODI_game(void) : | 35 | CHelper_libKODI_game(void) : |
| 46 | GAME_register_me(nullptr), | ||
| 47 | GAME_unregister_me(nullptr), | ||
| 48 | GAME_close_game(nullptr), | ||
| 49 | GAME_open_pixel_stream(nullptr), | ||
| 50 | GAME_open_video_stream(nullptr), | ||
| 51 | GAME_open_pcm_stream(nullptr), | ||
| 52 | GAME_open_audio_stream(nullptr), | ||
| 53 | GAME_add_stream_data(nullptr), | ||
| 54 | GAME_close_stream(nullptr), | ||
| 55 | GAME_enable_hardware_rendering(nullptr), | ||
| 56 | GAME_hw_get_current_framebuffer(nullptr), | ||
| 57 | GAME_hw_get_proc_address(nullptr), | ||
| 58 | GAME_render_frame(nullptr), | ||
| 59 | GAME_open_port(nullptr), | ||
| 60 | GAME_close_port(nullptr), | ||
| 61 | GAME_input_event(nullptr), | ||
| 62 | m_handle(nullptr), | 36 | m_handle(nullptr), |
| 63 | m_callbacks(nullptr), | 37 | m_callbacks(nullptr) |
| 64 | m_libKODI_game(nullptr) | ||
| 65 | { | 38 | { |
| 66 | } | 39 | } |
| 67 | 40 | ||
| 68 | ~CHelper_libKODI_game(void) | 41 | ~CHelper_libKODI_game(void) |
| 69 | { | 42 | { |
| 70 | if (m_libKODI_game) | ||
| 71 | { | ||
| 72 | GAME_unregister_me(m_handle, m_callbacks); | ||
| 73 | dlclose(m_libKODI_game); | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | template <typename T> | ||
| 78 | static bool RegisterSymbol(void* dll, T& functionPtr, const char* strFunctionPtr) | ||
| 79 | { | ||
| 80 | return (functionPtr = (T)dlsym(dll, strFunctionPtr)) != NULL; | ||
| 81 | } | 43 | } |
| 82 | 44 | ||
| 83 | /*! | 45 | /*! |
| @@ -87,152 +49,182 @@ public: | |||
| 87 | */ | 49 | */ |
| 88 | bool RegisterMe(void* handle) | 50 | bool RegisterMe(void* handle) |
| 89 | { | 51 | { |
| 90 | m_handle = handle; | 52 | m_handle = static_cast<AddonCB*>(handle); |
| 53 | if (m_handle) | ||
| 54 | m_callbacks = (AddonInstance_Game*)m_handle->GameLib_RegisterMe(m_handle->addonData); | ||
| 55 | if (!m_callbacks) | ||
| 56 | fprintf(stderr, "libKODI_game-ERROR: GameLib_RegisterMe can't get callback table from Kodi !!!\n"); | ||
| 91 | 57 | ||
| 92 | std::string libBasePath; | 58 | return m_callbacks != nullptr; |
| 93 | libBasePath = ((cb_array*)m_handle)->libBasePath; | ||
| 94 | libBasePath += GAME_HELPER_DLL; | ||
| 95 | |||
| 96 | #if defined(ANDROID) | ||
| 97 | struct stat st; | ||
| 98 | if (stat(libBasePath.c_str(),&st) != 0) | ||
| 99 | { | ||
| 100 | std::string tempbin = getenv("XBMC_ANDROID_LIBS"); | ||
| 101 | libBasePath = tempbin + "/" + GAME_HELPER_DLL_NAME; | ||
| 102 | } | ||
| 103 | #endif | ||
| 104 | |||
| 105 | m_libKODI_game = dlopen(libBasePath.c_str(), RTLD_LAZY); | ||
| 106 | if (m_libKODI_game == NULL) | ||
| 107 | { | ||
| 108 | fprintf(stderr, "Unable to load %s\n", dlerror()); | ||
| 109 | return false; | ||
| 110 | } | ||
| 111 | |||
| 112 | try | ||
| 113 | { | ||
| 114 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_register_me)) throw false; | ||
| 115 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_unregister_me)) throw false; | ||
| 116 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_close_game)) throw false; | ||
| 117 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_pixel_stream)) throw false; | ||
| 118 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_video_stream)) throw false; | ||
| 119 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_pcm_stream)) throw false; | ||
| 120 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_audio_stream)) throw false; | ||
| 121 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_add_stream_data)) throw false; | ||
| 122 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_close_stream)) throw false; | ||
| 123 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_enable_hardware_rendering)) throw false; | ||
| 124 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_hw_get_current_framebuffer)) throw false; | ||
| 125 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_hw_get_proc_address)) throw false; | ||
| 126 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_render_frame)) throw false; | ||
| 127 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_port)) throw false; | ||
| 128 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_close_port)) throw false; | ||
| 129 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_input_event)) throw false; | ||
| 130 | } | ||
| 131 | catch (const bool& bSuccess) | ||
| 132 | { | ||
| 133 | fprintf(stderr, "ERROR: Unable to assign function %s\n", dlerror()); | ||
| 134 | return bSuccess; | ||
| 135 | } | ||
| 136 | |||
| 137 | m_callbacks = GAME_register_me(m_handle); | ||
| 138 | return m_callbacks != NULL; | ||
| 139 | } | 59 | } |
| 140 | 60 | ||
| 61 | // --- Game callbacks -------------------------------------------------------- | ||
| 62 | |||
| 63 | /*! | ||
| 64 | * \brief Requests the frontend to stop the current game | ||
| 65 | */ | ||
| 141 | void CloseGame(void) | 66 | void CloseGame(void) |
| 142 | { | 67 | { |
| 143 | return GAME_close_game(m_handle, m_callbacks); | 68 | return m_callbacks->toKodi.CloseGame(m_callbacks->toKodi.kodiInstance); |
| 144 | } | 69 | } |
| 145 | 70 | ||
| 71 | /*! | ||
| 72 | * \brief Create a video stream for pixel data | ||
| 73 | * | ||
| 74 | * \param format The type of pixel data accepted by this stream | ||
| 75 | * \param width The frame width | ||
| 76 | * \param height The frame height | ||
| 77 | * \param rotation The rotation (counter-clockwise) of the video frames | ||
| 78 | * | ||
| 79 | * \return 0 on success or -1 if a video stream is already created | ||
| 80 | */ | ||
| 146 | bool OpenPixelStream(GAME_PIXEL_FORMAT format, unsigned int width, unsigned int height, GAME_VIDEO_ROTATION rotation) | 81 | bool OpenPixelStream(GAME_PIXEL_FORMAT format, unsigned int width, unsigned int height, GAME_VIDEO_ROTATION rotation) |
| 147 | { | 82 | { |
| 148 | return GAME_open_pixel_stream(m_handle, m_callbacks, format, width, height, rotation) == 0; | 83 | return m_callbacks->toKodi.OpenPixelStream(m_callbacks->toKodi.kodiInstance, format, width, height, rotation) == 0; |
| 149 | } | 84 | } |
| 150 | 85 | ||
| 86 | /*! | ||
| 87 | * \brief Create a video stream for encoded video data | ||
| 88 | * | ||
| 89 | * \param codec The video format accepted by this stream | ||
| 90 | * | ||
| 91 | * \return 0 on success or -1 if a video stream is already created | ||
| 92 | */ | ||
| 151 | bool OpenVideoStream(GAME_VIDEO_CODEC codec) | 93 | bool OpenVideoStream(GAME_VIDEO_CODEC codec) |
| 152 | { | 94 | { |
| 153 | return GAME_open_video_stream(m_handle, m_callbacks, codec) == 0; | 95 | return m_callbacks->toKodi.OpenVideoStream(m_callbacks->toKodi.kodiInstance, codec) == 0; |
| 154 | } | 96 | } |
| 155 | 97 | ||
| 98 | /*! | ||
| 99 | * \brief Create an audio stream for PCM audio data | ||
| 100 | * | ||
| 101 | * \param format The type of audio data accepted by this stream | ||
| 102 | * \param channel_map The channel layout terminated by GAME_CH_NULL | ||
| 103 | * | ||
| 104 | * \return 0 on success or -1 if an audio stream is already created | ||
| 105 | */ | ||
| 156 | bool OpenPCMStream(GAME_PCM_FORMAT format, const GAME_AUDIO_CHANNEL* channel_map) | 106 | bool OpenPCMStream(GAME_PCM_FORMAT format, const GAME_AUDIO_CHANNEL* channel_map) |
| 157 | { | 107 | { |
| 158 | return GAME_open_pcm_stream(m_handle, m_callbacks, format, channel_map) == 0; | 108 | return m_callbacks->toKodi.OpenPCMStream(m_callbacks->toKodi.kodiInstance, format, channel_map) == 0; |
| 159 | } | 109 | } |
| 160 | 110 | ||
| 111 | /*! | ||
| 112 | * \brief Create an audio stream for encoded audio data | ||
| 113 | * | ||
| 114 | * \param codec The audio format accepted by this stream | ||
| 115 | * \param channel_map The channel layout terminated by GAME_CH_NULL | ||
| 116 | * | ||
| 117 | * \return 0 on success or -1 if an audio stream is already created | ||
| 118 | */ | ||
| 161 | bool OpenAudioStream(GAME_AUDIO_CODEC codec, const GAME_AUDIO_CHANNEL* channel_map) | 119 | bool OpenAudioStream(GAME_AUDIO_CODEC codec, const GAME_AUDIO_CHANNEL* channel_map) |
| 162 | { | 120 | { |
| 163 | return GAME_open_audio_stream(m_handle, m_callbacks, codec, channel_map) == 0; | 121 | return m_callbacks->toKodi.OpenAudioStream(m_callbacks->toKodi.kodiInstance, codec, channel_map) == 0; |
| 164 | } | 122 | } |
| 165 | 123 | ||
| 124 | /*! | ||
| 125 | * \brief Add a data packet to an audio or video stream | ||
| 126 | * | ||
| 127 | * \param stream The target stream | ||
| 128 | * \param data The data packet | ||
| 129 | * \param size The size of the data | ||
| 130 | */ | ||
| 166 | void AddStreamData(GAME_STREAM_TYPE stream, const uint8_t* data, unsigned int size) | 131 | void AddStreamData(GAME_STREAM_TYPE stream, const uint8_t* data, unsigned int size) |
| 167 | { | 132 | { |
| 168 | GAME_add_stream_data(m_handle, m_callbacks, stream, data, size); | 133 | m_callbacks->toKodi.AddStreamData(m_callbacks->toKodi.kodiInstance, stream, data, size); |
| 169 | } | 134 | } |
| 170 | 135 | ||
| 136 | /*! | ||
| 137 | * \brief Free the specified stream | ||
| 138 | * | ||
| 139 | * \param stream The stream to close | ||
| 140 | */ | ||
| 171 | void CloseStream(GAME_STREAM_TYPE stream) | 141 | void CloseStream(GAME_STREAM_TYPE stream) |
| 172 | { | 142 | { |
| 173 | GAME_close_stream(m_handle, m_callbacks, stream); | 143 | m_callbacks->toKodi.CloseStream(m_callbacks->toKodi.kodiInstance, stream); |
| 174 | } | 144 | } |
| 175 | 145 | ||
| 146 | // -- Hardware rendering callbacks ------------------------------------------- | ||
| 147 | |||
| 148 | /*! | ||
| 149 | * \brief Enable hardware rendering | ||
| 150 | * | ||
| 151 | * \param hw_info A struct of properties for the hardware rendering system | ||
| 152 | */ | ||
| 176 | void EnableHardwareRendering(const struct game_hw_info* hw_info) | 153 | void EnableHardwareRendering(const struct game_hw_info* hw_info) |
| 177 | { | 154 | { |
| 178 | return GAME_enable_hardware_rendering(m_handle, m_callbacks, hw_info); | 155 | return m_callbacks->toKodi.EnableHardwareRendering(m_callbacks->toKodi.kodiInstance, hw_info); |
| 179 | } | 156 | } |
| 180 | 157 | ||
| 158 | /*! | ||
| 159 | * \brief Get the framebuffer for rendering | ||
| 160 | * | ||
| 161 | * \return The framebuffer | ||
| 162 | */ | ||
| 181 | uintptr_t HwGetCurrentFramebuffer(void) | 163 | uintptr_t HwGetCurrentFramebuffer(void) |
| 182 | { | 164 | { |
| 183 | return GAME_hw_get_current_framebuffer(m_handle, m_callbacks); | 165 | return m_callbacks->toKodi.HwGetCurrentFramebuffer(m_callbacks->toKodi.kodiInstance); |
| 184 | } | 166 | } |
| 185 | 167 | ||
| 168 | /*! | ||
| 169 | * \brief Get a symbol from the hardware context | ||
| 170 | * | ||
| 171 | * \param symbol The symbol's name | ||
| 172 | * | ||
| 173 | * \return A function pointer for the specified symbol | ||
| 174 | */ | ||
| 186 | game_proc_address_t HwGetProcAddress(const char* sym) | 175 | game_proc_address_t HwGetProcAddress(const char* sym) |
| 187 | { | 176 | { |
| 188 | return GAME_hw_get_proc_address(m_handle, m_callbacks, sym); | 177 | return m_callbacks->toKodi.HwGetProcAddress(m_callbacks->toKodi.kodiInstance, sym); |
| 189 | } | 178 | } |
| 190 | 179 | ||
| 180 | /*! | ||
| 181 | * \brief Called when a frame is being rendered | ||
| 182 | */ | ||
| 191 | void RenderFrame() | 183 | void RenderFrame() |
| 192 | { | 184 | { |
| 193 | return GAME_render_frame(m_handle, m_callbacks); | 185 | return m_callbacks->toKodi.RenderFrame(m_callbacks->toKodi.kodiInstance); |
| 194 | } | 186 | } |
| 195 | 187 | ||
| 188 | // --- Input callbacks ------------------------------------------------------- | ||
| 189 | |||
| 190 | /*! | ||
| 191 | * \brief Begin reporting events for the specified joystick port | ||
| 192 | * | ||
| 193 | * \param port The zero-indexed port number | ||
| 194 | * | ||
| 195 | * \return true if the port was opened, false otherwise | ||
| 196 | */ | ||
| 196 | bool OpenPort(unsigned int port) | 197 | bool OpenPort(unsigned int port) |
| 197 | { | 198 | { |
| 198 | return GAME_open_port(m_handle, m_callbacks, port); | 199 | return m_callbacks->toKodi.OpenPort(m_callbacks->toKodi.kodiInstance, port); |
| 199 | } | 200 | } |
| 200 | 201 | ||
| 202 | /*! | ||
| 203 | * \brief End reporting events for the specified port | ||
| 204 | * | ||
| 205 | * \param port The port number passed to OpenPort() | ||
| 206 | */ | ||
| 201 | void ClosePort(unsigned int port) | 207 | void ClosePort(unsigned int port) |
| 202 | { | 208 | { |
| 203 | return GAME_close_port(m_handle, m_callbacks, port); | 209 | return m_callbacks->toKodi.ClosePort(m_callbacks->toKodi.kodiInstance, port); |
| 204 | } | 210 | } |
| 205 | 211 | ||
| 212 | /*! | ||
| 213 | * \brief Notify the port of an input event | ||
| 214 | * | ||
| 215 | * \param event The input event | ||
| 216 | * | ||
| 217 | * Input events can arrive for the following sources: | ||
| 218 | * - GAME_INPUT_EVENT_MOTOR | ||
| 219 | * | ||
| 220 | * \return true if the event was handled, false otherwise | ||
| 221 | */ | ||
| 206 | bool InputEvent(const game_input_event& event) | 222 | bool InputEvent(const game_input_event& event) |
| 207 | { | 223 | { |
| 208 | return GAME_input_event(m_handle, m_callbacks, &event); | 224 | return m_callbacks->toKodi.InputEvent(m_callbacks->toKodi.kodiInstance, &event); |
| 209 | } | 225 | } |
| 210 | |||
| 211 | protected: | ||
| 212 | CB_GameLib* (*GAME_register_me)(void* handle); | ||
| 213 | void (*GAME_unregister_me)(void* handle, CB_GameLib* cb); | ||
| 214 | void (*GAME_close_game)(void* handle, CB_GameLib* cb); | ||
| 215 | int (*GAME_open_pixel_stream)(void* handle, CB_GameLib* cb, GAME_PIXEL_FORMAT, unsigned int, unsigned int, GAME_VIDEO_ROTATION); | ||
| 216 | int (*GAME_open_video_stream)(void* handle, CB_GameLib* cb, GAME_VIDEO_CODEC); | ||
| 217 | int (*GAME_open_pcm_stream)(void* handle, CB_GameLib* cb, GAME_PCM_FORMAT, const GAME_AUDIO_CHANNEL*); | ||
| 218 | int (*GAME_open_audio_stream)(void* handle, CB_GameLib* cb, GAME_AUDIO_CODEC, const GAME_AUDIO_CHANNEL*); | ||
| 219 | int (*GAME_add_stream_data)(void* handle, CB_GameLib* cb, GAME_STREAM_TYPE, const uint8_t*, unsigned int); | ||
| 220 | int (*GAME_close_stream)(void* handle, CB_GameLib* cb, GAME_STREAM_TYPE); | ||
| 221 | void (*GAME_enable_hardware_rendering)(void* handle, CB_GameLib* cb, const struct game_hw_info*); | ||
| 222 | uintptr_t (*GAME_hw_get_current_framebuffer)(void* handle, CB_GameLib* cb); | ||
| 223 | game_proc_address_t (*GAME_hw_get_proc_address)(void* handle, CB_GameLib* cb, const char*); | ||
| 224 | void (*GAME_render_frame)(void* handle, CB_GameLib* cb); | ||
| 225 | bool (*GAME_open_port)(void* handle, CB_GameLib* cb, unsigned int); | ||
| 226 | void (*GAME_close_port)(void* handle, CB_GameLib* cb, unsigned int); | ||
| 227 | bool (*GAME_input_event)(void* handle, CB_GameLib* cb, const game_input_event* event); | ||
| 228 | 226 | ||
| 229 | private: | 227 | private: |
| 230 | void* m_handle; | 228 | AddonCB* m_handle; |
| 231 | CB_GameLib* m_callbacks; | 229 | AddonInstance_Game* m_callbacks; |
| 232 | void* m_libKODI_game; | ||
| 233 | |||
| 234 | struct cb_array | ||
| 235 | { | ||
| 236 | const char* libBasePath; | ||
| 237 | }; | ||
| 238 | }; | 230 | }; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h index b699fa0..d6f0f4f 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h | |||
| @@ -28,416 +28,1068 @@ | |||
| 28 | 28 | ||
| 29 | typedef void* GUIHANDLE; | 29 | typedef void* GUIHANDLE; |
| 30 | 30 | ||
| 31 | #define GUI_HELPER_DLL KODI_DLL("guilib") | 31 | namespace KodiAPI |
| 32 | #define GUI_HELPER_DLL_NAME KODI_DLL_NAME("guilib") | 32 | { |
| 33 | namespace GUI | ||
| 34 | { | ||
| 33 | 35 | ||
| 34 | /* current ADDONGUI API version */ | 36 | typedef struct CB_GUILib |
| 35 | #define KODI_GUILIB_API_VERSION "5.11.0" | 37 | { |
| 38 | void (*Lock)(); | ||
| 39 | void (*Unlock)(); | ||
| 40 | int (*GetScreenHeight)(); | ||
| 41 | int (*GetScreenWidth)(); | ||
| 42 | int (*GetVideoResolution)(); | ||
| 43 | GUIHANDLE (*Window_New)(void *addonData, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog); | ||
| 44 | void (*Window_Delete)(void *addonData, GUIHANDLE handle); | ||
| 45 | void (*Window_SetCallbacks)(void *addonData, GUIHANDLE handle, GUIHANDLE clienthandle, bool (*)(GUIHANDLE handle), bool (*)(GUIHANDLE handle, int), bool (*)(GUIHANDLE handle, int), bool (*)(GUIHANDLE handle, int)); | ||
| 46 | bool (*Window_Show)(void *addonData, GUIHANDLE handle); | ||
| 47 | bool (*Window_Close)(void *addonData, GUIHANDLE handle); | ||
| 48 | bool (*Window_DoModal)(void *addonData, GUIHANDLE handle); | ||
| 49 | bool (*Window_SetFocusId)(void *addonData, GUIHANDLE handle, int iControlId); | ||
| 50 | int (*Window_GetFocusId)(void *addonData, GUIHANDLE handle); | ||
| 51 | bool (*Window_SetCoordinateResolution)(void *addonData, GUIHANDLE handle, int res); | ||
| 52 | void (*Window_SetProperty)(void *addonData, GUIHANDLE handle, const char *key, const char *value); | ||
| 53 | void (*Window_SetPropertyInt)(void *addonData, GUIHANDLE handle, const char *key, int value); | ||
| 54 | void (*Window_SetPropertyBool)(void *addonData, GUIHANDLE handle, const char *key, bool value); | ||
| 55 | void (*Window_SetPropertyDouble)(void *addonData, GUIHANDLE handle, const char *key, double value); | ||
| 56 | const char* (*Window_GetProperty)(void *addonData, GUIHANDLE handle, const char *key); | ||
| 57 | int (*Window_GetPropertyInt)(void *addonData, GUIHANDLE handle, const char *key); | ||
| 58 | bool (*Window_GetPropertyBool)(void *addonData, GUIHANDLE handle, const char *key); | ||
| 59 | double (*Window_GetPropertyDouble)(void *addonData, GUIHANDLE handle, const char *key); | ||
| 60 | void (*Window_ClearProperties)(void *addonData, GUIHANDLE handle); | ||
| 61 | int (*Window_GetListSize)(void *addonData, GUIHANDLE handle); | ||
| 62 | void (*Window_ClearList)(void *addonData, GUIHANDLE handle); | ||
| 63 | GUIHANDLE (*Window_AddItem)(void *addonData, GUIHANDLE handle, GUIHANDLE item, int itemPosition); | ||
| 64 | GUIHANDLE (*Window_AddStringItem)(void *addonData, GUIHANDLE handle, const char *itemName, int itemPosition); | ||
| 65 | void (*Window_RemoveItem)(void *addonData, GUIHANDLE handle, int itemPosition); | ||
| 66 | GUIHANDLE (*Window_GetListItem)(void *addonData, GUIHANDLE handle, int listPos); | ||
| 67 | void (*Window_SetCurrentListPosition)(void *addonData, GUIHANDLE handle, int listPos); | ||
| 68 | int (*Window_GetCurrentListPosition)(void *addonData, GUIHANDLE handle); | ||
| 69 | GUIHANDLE (*Window_GetControl_Spin)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 70 | GUIHANDLE (*Window_GetControl_Button)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 71 | GUIHANDLE (*Window_GetControl_RadioButton)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 72 | GUIHANDLE (*Window_GetControl_Edit)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 73 | GUIHANDLE (*Window_GetControl_Progress)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 74 | GUIHANDLE (*Window_GetControl_RenderAddon)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 75 | void (*Window_SetControlLabel)(void *addonData, GUIHANDLE handle, int controlId, const char *label); | ||
| 76 | void (*Window_MarkDirtyRegion)(void *addonData, GUIHANDLE handle); | ||
| 77 | void (*Control_Spin_SetVisible)(void *addonData, GUIHANDLE spinhandle, bool yesNo); | ||
| 78 | void (*Control_Spin_SetText)(void *addonData, GUIHANDLE spinhandle, const char *label); | ||
| 79 | void (*Control_Spin_Clear)(void *addonData, GUIHANDLE spinhandle); | ||
| 80 | void (*Control_Spin_AddLabel)(void *addonData, GUIHANDLE spinhandle, const char *label, int iValue); | ||
| 81 | int (*Control_Spin_GetValue)(void *addonData, GUIHANDLE spinhandle); | ||
| 82 | void (*Control_Spin_SetValue)(void *addonData, GUIHANDLE spinhandle, int iValue); | ||
| 83 | void (*Control_RadioButton_SetVisible)(void *addonData, GUIHANDLE handle, bool yesNo); | ||
| 84 | void (*Control_RadioButton_SetText)(void *addonData, GUIHANDLE handle, const char *label); | ||
| 85 | void (*Control_RadioButton_SetSelected)(void *addonData, GUIHANDLE handle, bool yesNo); | ||
| 86 | bool (*Control_RadioButton_IsSelected)(void *addonData, GUIHANDLE handle); | ||
| 87 | void (*Control_Progress_SetPercentage)(void *addonData, GUIHANDLE handle, float fPercent); | ||
| 88 | float (*Control_Progress_GetPercentage)(void *addonData, GUIHANDLE handle); | ||
| 89 | void (*Control_Progress_SetInfo)(void *addonData, GUIHANDLE handle, int iInfo); | ||
| 90 | int (*Control_Progress_GetInfo)(void *addonData, GUIHANDLE handle); | ||
| 91 | const char* (*Control_Progress_GetDescription)(void *addonData, GUIHANDLE handle); | ||
| 92 | GUIHANDLE (*Window_GetControl_Slider)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 93 | void (*Control_Slider_SetVisible)(void *addonData, GUIHANDLE handle, bool yesNo); | ||
| 94 | const char *(*Control_Slider_GetDescription)(void *addonData, GUIHANDLE handle); | ||
| 95 | void (*Control_Slider_SetIntRange)(void *addonData, GUIHANDLE handle, int iStart, int iEnd); | ||
| 96 | void (*Control_Slider_SetIntValue)(void *addonData, GUIHANDLE handle, int iValue); | ||
| 97 | int (*Control_Slider_GetIntValue)(void *addonData, GUIHANDLE handle); | ||
| 98 | void (*Control_Slider_SetIntInterval)(void *addonData, GUIHANDLE handle, int iInterval); | ||
| 99 | void (*Control_Slider_SetPercentage)(void *addonData, GUIHANDLE handle, float fPercent); | ||
| 100 | float (*Control_Slider_GetPercentage)(void *addonData, GUIHANDLE handle); | ||
| 101 | void (*Control_Slider_SetFloatRange)(void *addonData, GUIHANDLE handle, float fStart, float fEnd); | ||
| 102 | void (*Control_Slider_SetFloatValue)(void *addonData, GUIHANDLE handle, float fValue); | ||
| 103 | float (*Control_Slider_GetFloatValue)(void *addonData, GUIHANDLE handle); | ||
| 104 | void (*Control_Slider_SetFloatInterval)(void *addonData, GUIHANDLE handle, float fInterval); | ||
| 105 | GUIHANDLE (*Window_GetControl_SettingsSlider)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 106 | void (*Control_SettingsSlider_SetVisible)(void *addonData, GUIHANDLE handle, bool yesNo); | ||
| 107 | void (*Control_SettingsSlider_SetText)(void *addonData, GUIHANDLE handle, const char *label); | ||
| 108 | const char *(*Control_SettingsSlider_GetDescription)(void *addonData, GUIHANDLE handle); | ||
| 109 | void (*Control_SettingsSlider_SetIntRange)(void *addonData, GUIHANDLE handle, int iStart, int iEnd); | ||
| 110 | void (*Control_SettingsSlider_SetIntValue)(void *addonData, GUIHANDLE handle, int iValue); | ||
| 111 | int (*Control_SettingsSlider_GetIntValue)(void *addonData, GUIHANDLE handle); | ||
| 112 | void (*Control_SettingsSlider_SetIntInterval)(void *addonData, GUIHANDLE handle, int iInterval); | ||
| 113 | void (*Control_SettingsSlider_SetPercentage)(void *addonData, GUIHANDLE handle, float fPercent); | ||
| 114 | float (*Control_SettingsSlider_GetPercentage)(void *addonData, GUIHANDLE handle); | ||
| 115 | void (*Control_SettingsSlider_SetFloatRange)(void *addonData, GUIHANDLE handle, float fStart, float fEnd); | ||
| 116 | void (*Control_SettingsSlider_SetFloatValue)(void *addonData, GUIHANDLE handle, float fValue); | ||
| 117 | float (*Control_SettingsSlider_GetFloatValue)(void *addonData, GUIHANDLE handle); | ||
| 118 | void (*Control_SettingsSlider_SetFloatInterval)(void *addonData, GUIHANDLE handle, float fInterval); | ||
| 119 | GUIHANDLE (*ListItem_Create)(void *addonData, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path); | ||
| 120 | const char* (*ListItem_GetLabel)(void *addonData, GUIHANDLE handle); | ||
| 121 | void (*ListItem_SetLabel)(void *addonData, GUIHANDLE handle, const char *label); | ||
| 122 | const char* (*ListItem_GetLabel2)(void *addonData, GUIHANDLE handle); | ||
| 123 | void (*ListItem_SetLabel2)(void *addonData, GUIHANDLE handle, const char *label); | ||
| 124 | void (*ListItem_SetIconImage)(void *addonData, GUIHANDLE handle, const char *image); | ||
| 125 | void (*ListItem_SetThumbnailImage)(void *addonData, GUIHANDLE handle, const char *image); | ||
| 126 | void (*ListItem_SetInfo)(void *addonData, GUIHANDLE handle, const char *info); | ||
| 127 | void (*ListItem_SetProperty)(void *addonData, GUIHANDLE handle, const char *key, const char *value); | ||
| 128 | const char* (*ListItem_GetProperty)(void *addonData, GUIHANDLE handle, const char *key); | ||
| 129 | void (*ListItem_SetPath)(void *addonData, GUIHANDLE handle, const char *path); | ||
| 130 | void (*RenderAddon_SetCallbacks)(void *addonData, GUIHANDLE handle, GUIHANDLE clienthandle, bool (*createCB)(GUIHANDLE,int,int,int,int,void*), void (*renderCB)(GUIHANDLE), void (*stopCB)(GUIHANDLE), bool (*dirtyCB)(GUIHANDLE)); | ||
| 131 | void (*RenderAddon_Delete)(void *addonData, GUIHANDLE handle); | ||
| 132 | void (*RenderAddon_MarkDirty)(void *addonData, GUIHANDLE handle); | ||
| 133 | |||
| 134 | bool (*Dialog_Keyboard_ShowAndGetInputWithHead)(char &strTextString, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs); | ||
| 135 | bool (*Dialog_Keyboard_ShowAndGetInput)(char &strTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs); | ||
| 136 | bool (*Dialog_Keyboard_ShowAndGetNewPasswordWithHead)(char &newPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs); | ||
| 137 | bool (*Dialog_Keyboard_ShowAndGetNewPassword)(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); | ||
| 138 | bool (*Dialog_Keyboard_ShowAndVerifyNewPasswordWithHead)(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmpty, unsigned int autoCloseMs); | ||
| 139 | bool (*Dialog_Keyboard_ShowAndVerifyNewPassword)(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); | ||
| 140 | int (*Dialog_Keyboard_ShowAndVerifyPassword)(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs); | ||
| 141 | bool (*Dialog_Keyboard_ShowAndGetFilter)(char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs); | ||
| 142 | bool (*Dialog_Keyboard_SendTextToActiveKeyboard)(const char *aTextString, bool closeKeyboard); | ||
| 143 | bool (*Dialog_Keyboard_isKeyboardActivated)(); | ||
| 144 | |||
| 145 | bool (*Dialog_Numeric_ShowAndVerifyNewPassword)(char &strNewPassword, unsigned int iMaxStringSize); | ||
| 146 | int (*Dialog_Numeric_ShowAndVerifyPassword)(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries); | ||
| 147 | bool (*Dialog_Numeric_ShowAndVerifyInput)(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput); | ||
| 148 | bool (*Dialog_Numeric_ShowAndGetTime)(tm &time, const char *strHeading); | ||
| 149 | bool (*Dialog_Numeric_ShowAndGetDate)(tm &date, const char *strHeading); | ||
| 150 | bool (*Dialog_Numeric_ShowAndGetIPAddress)(char &strIPAddress, unsigned int iMaxStringSize, const char *strHeading); | ||
| 151 | bool (*Dialog_Numeric_ShowAndGetNumber)(char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs); | ||
| 152 | bool (*Dialog_Numeric_ShowAndGetSeconds)(char &timeString, unsigned int iMaxStringSize, const char *strHeading); | ||
| 153 | |||
| 154 | bool (*Dialog_FileBrowser_ShowAndGetFile)(const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList); | ||
| 155 | |||
| 156 | void (*Dialog_OK_ShowAndGetInputSingleText)(const char *heading, const char *text); | ||
| 157 | void (*Dialog_OK_ShowAndGetInputLineText)(const char *heading, const char *line0, const char *line1, const char *line2); | ||
| 158 | |||
| 159 | bool (*Dialog_YesNo_ShowAndGetInputSingleText)(const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel); | ||
| 160 | bool (*Dialog_YesNo_ShowAndGetInputLineText)(const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel); | ||
| 161 | bool (*Dialog_YesNo_ShowAndGetInputLineButtonText)(const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel); | ||
| 162 | |||
| 163 | void (*Dialog_TextViewer)(const char *heading, const char *text); | ||
| 164 | |||
| 165 | int (*Dialog_Select)(const char *heading, const char *entries[], unsigned int size, int selected); | ||
| 166 | } CB_GUILib; | ||
| 167 | |||
| 168 | } /* namespace GUI */ | ||
| 169 | } /* namespace KodiAPI */ | ||
| 36 | 170 | ||
| 37 | /* min. ADDONGUI API version */ | ||
| 38 | #define KODI_GUILIB_MIN_API_VERSION "5.10.0" | ||
| 39 | 171 | ||
| 40 | #define ADDON_ACTION_PREVIOUS_MENU 10 | 172 | #define ADDON_ACTION_PREVIOUS_MENU 10 |
| 41 | #define ADDON_ACTION_CLOSE_DIALOG 51 | 173 | #define ADDON_ACTION_CLOSE_DIALOG 51 |
| 42 | #define ADDON_ACTION_NAV_BACK 92 | 174 | #define ADDON_ACTION_NAV_BACK 92 |
| 43 | 175 | ||
| 44 | class CAddonGUIWindow; | 176 | class CAddonGUIControlBase |
| 45 | class CAddonGUISpinControl; | 177 | { |
| 46 | class CAddonGUIRadioButton; | 178 | public: |
| 47 | class CAddonGUIProgressControl; | 179 | GUIHANDLE GetControlHandle() const { return m_controlHandle; } |
| 48 | class CAddonListItem; | ||
| 49 | class CAddonGUIRenderingControl; | ||
| 50 | class CAddonGUISliderControl; | ||
| 51 | class CAddonGUISettingsSliderControl; | ||
| 52 | 180 | ||
| 53 | class CHelper_libKODI_guilib | 181 | protected: |
| 182 | CAddonGUIControlBase(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIControlBase* window) | ||
| 183 | : m_controlHandle(nullptr), m_Handle(hdl), m_cb(cb), m_Window(window) {} | ||
| 184 | virtual ~CAddonGUIControlBase() = default; | ||
| 185 | |||
| 186 | GUIHANDLE m_controlHandle; | ||
| 187 | AddonCB* m_Handle; | ||
| 188 | KodiAPI::GUI::CB_GUILib* m_cb; | ||
| 189 | CAddonGUIControlBase* m_Window; | ||
| 190 | |||
| 191 | private: | ||
| 192 | CAddonGUIControlBase() = delete; | ||
| 193 | CAddonGUIControlBase(const CAddonGUIControlBase&) = delete; | ||
| 194 | CAddonGUIControlBase &operator=(const CAddonGUIControlBase&) = delete; | ||
| 195 | }; | ||
| 196 | |||
| 197 | class CAddonListItem : public CAddonGUIControlBase | ||
| 54 | { | 198 | { |
| 55 | public: | 199 | public: |
| 56 | CHelper_libKODI_guilib() | 200 | CAddonListItem(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path) |
| 201 | : CAddonGUIControlBase(hdl, cb, nullptr) | ||
| 57 | { | 202 | { |
| 58 | m_libKODI_guilib = NULL; | 203 | m_controlHandle = m_cb->ListItem_Create(m_Handle->addonData, label, label2, iconImage, thumbnailImage, path); |
| 59 | m_Handle = NULL; | ||
| 60 | } | 204 | } |
| 61 | 205 | ||
| 62 | ~CHelper_libKODI_guilib() | 206 | virtual ~CAddonListItem() = default; |
| 207 | |||
| 208 | const char *GetLabel() | ||
| 209 | { | ||
| 210 | if (!m_controlHandle) | ||
| 211 | return ""; | ||
| 212 | |||
| 213 | return m_cb->ListItem_GetLabel(m_Handle->addonData, m_controlHandle); | ||
| 214 | } | ||
| 215 | |||
| 216 | void SetLabel(const char *label) | ||
| 217 | { | ||
| 218 | if (m_controlHandle) | ||
| 219 | m_cb->ListItem_SetLabel(m_Handle->addonData, m_controlHandle, label); | ||
| 220 | } | ||
| 221 | |||
| 222 | const char *GetLabel2() | ||
| 223 | { | ||
| 224 | if (!m_controlHandle) | ||
| 225 | return ""; | ||
| 226 | |||
| 227 | return m_cb->ListItem_GetLabel2(m_Handle->addonData, m_controlHandle); | ||
| 228 | } | ||
| 229 | |||
| 230 | void SetLabel2(const char *label) | ||
| 231 | { | ||
| 232 | if (m_controlHandle) | ||
| 233 | m_cb->ListItem_SetLabel2(m_Handle->addonData, m_controlHandle, label); | ||
| 234 | } | ||
| 235 | |||
| 236 | void SetIconImage(const char *image) | ||
| 237 | { | ||
| 238 | if (m_controlHandle) | ||
| 239 | m_cb->ListItem_SetIconImage(m_Handle->addonData, m_controlHandle, image); | ||
| 240 | } | ||
| 241 | |||
| 242 | void SetThumbnailImage(const char *image) | ||
| 243 | { | ||
| 244 | if (m_controlHandle) | ||
| 245 | m_cb->ListItem_SetThumbnailImage(m_Handle->addonData, m_controlHandle, image); | ||
| 246 | } | ||
| 247 | |||
| 248 | void SetInfo(const char *Info) | ||
| 249 | { | ||
| 250 | if (m_controlHandle) | ||
| 251 | m_cb->ListItem_SetInfo(m_Handle->addonData, m_controlHandle, Info); | ||
| 252 | } | ||
| 253 | |||
| 254 | void SetProperty(const char *key, const char *value) | ||
| 255 | { | ||
| 256 | if (m_controlHandle) | ||
| 257 | m_cb->ListItem_SetProperty(m_Handle->addonData, m_controlHandle, key, value); | ||
| 258 | } | ||
| 259 | |||
| 260 | const char *GetProperty(const char *key) const | ||
| 261 | { | ||
| 262 | if (!m_controlHandle) | ||
| 263 | return ""; | ||
| 264 | |||
| 265 | return m_cb->ListItem_GetProperty(m_Handle->addonData, m_controlHandle, key); | ||
| 266 | } | ||
| 267 | |||
| 268 | void SetPath(const char *Path) | ||
| 269 | { | ||
| 270 | if (m_controlHandle) | ||
| 271 | m_cb->ListItem_SetPath(m_Handle->addonData, m_controlHandle, Path); | ||
| 272 | } | ||
| 273 | }; | ||
| 274 | |||
| 275 | class CAddonGUIWindow : public CAddonGUIControlBase | ||
| 276 | { | ||
| 277 | public: | ||
| 278 | CAddonGUIWindow(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog) | ||
| 279 | : CAddonGUIControlBase(hdl, cb, nullptr) | ||
| 280 | , m_cbhdl(nullptr) | ||
| 281 | , CBOnInit(nullptr) | ||
| 282 | , CBOnFocus(nullptr) | ||
| 283 | , CBOnClick(nullptr) | ||
| 284 | , CBOnAction(nullptr) | ||
| 285 | { | ||
| 286 | if (hdl && cb) | ||
| 287 | { | ||
| 288 | m_controlHandle = m_cb->Window_New(m_Handle->addonData, xmlFilename, defaultSkin, forceFallback, asDialog); | ||
| 289 | if (!m_controlHandle) | ||
| 290 | fprintf(stderr, "libKODI_guilib: ERROR: Can't create window class !!!\n"); | ||
| 291 | |||
| 292 | m_cb->Window_SetCallbacks(m_Handle->addonData, m_controlHandle, this, OnInitCB, OnClickCB, OnFocusCB, OnActionCB); | ||
| 293 | } | ||
| 294 | } | ||
| 295 | |||
| 296 | virtual ~CAddonGUIWindow() | ||
| 63 | { | 297 | { |
| 64 | if (m_libKODI_guilib) | 298 | if (m_Handle && m_cb && m_controlHandle) |
| 65 | { | 299 | { |
| 66 | GUI_unregister_me(m_Handle, m_Callbacks); | 300 | m_cb->Window_Delete(m_Handle->addonData, m_controlHandle); |
| 67 | dlclose(m_libKODI_guilib); | 301 | m_controlHandle = nullptr; |
| 68 | } | 302 | } |
| 69 | } | 303 | } |
| 70 | 304 | ||
| 71 | bool RegisterMe(void *Handle) | 305 | bool Show() |
| 72 | { | 306 | { |
| 73 | m_Handle = Handle; | 307 | return m_cb->Window_Show(m_Handle->addonData, m_controlHandle); |
| 308 | } | ||
| 74 | 309 | ||
| 75 | std::string libBasePath; | 310 | void Close() |
| 76 | libBasePath = ((cb_array*)m_Handle)->libPath; | 311 | { |
| 77 | libBasePath += GUI_HELPER_DLL; | 312 | m_cb->Window_Close(m_Handle->addonData, m_controlHandle); |
| 313 | } | ||
| 78 | 314 | ||
| 79 | m_libKODI_guilib = dlopen(libBasePath.c_str(), RTLD_LAZY); | 315 | void DoModal() |
| 80 | if (m_libKODI_guilib == NULL) | 316 | { |
| 81 | { | 317 | m_cb->Window_DoModal(m_Handle->addonData, m_controlHandle); |
| 82 | fprintf(stderr, "Unable to load %s\n", dlerror()); | 318 | } |
| 319 | |||
| 320 | bool SetFocusId(int iControlId) | ||
| 321 | { | ||
| 322 | return m_cb->Window_SetFocusId(m_Handle->addonData, m_controlHandle, iControlId); | ||
| 323 | } | ||
| 324 | |||
| 325 | int GetFocusId() | ||
| 326 | { | ||
| 327 | return m_cb->Window_GetFocusId(m_Handle->addonData, m_controlHandle); | ||
| 328 | } | ||
| 329 | |||
| 330 | bool SetCoordinateResolution(int res) | ||
| 331 | { | ||
| 332 | return m_cb->Window_SetCoordinateResolution(m_Handle->addonData, m_controlHandle, res); | ||
| 333 | } | ||
| 334 | |||
| 335 | void SetProperty(const char *key, const char *value) | ||
| 336 | { | ||
| 337 | m_cb->Window_SetProperty(m_Handle->addonData, m_controlHandle, key, value); | ||
| 338 | } | ||
| 339 | |||
| 340 | void SetPropertyInt(const char *key, int value) | ||
| 341 | { | ||
| 342 | m_cb->Window_SetPropertyInt(m_Handle->addonData, m_controlHandle, key, value); | ||
| 343 | } | ||
| 344 | |||
| 345 | void SetPropertyBool(const char *key, bool value) | ||
| 346 | { | ||
| 347 | m_cb->Window_SetPropertyBool(m_Handle->addonData, m_controlHandle, key, value); | ||
| 348 | } | ||
| 349 | |||
| 350 | void SetPropertyDouble(const char *key, double value) | ||
| 351 | { | ||
| 352 | m_cb->Window_SetPropertyDouble(m_Handle->addonData, m_controlHandle, key, value); | ||
| 353 | } | ||
| 354 | |||
| 355 | const char *GetProperty(const char *key) const | ||
| 356 | { | ||
| 357 | return m_cb->Window_GetProperty(m_Handle->addonData, m_controlHandle, key); | ||
| 358 | } | ||
| 359 | |||
| 360 | int GetPropertyInt(const char *key) const | ||
| 361 | { | ||
| 362 | return m_cb->Window_GetPropertyInt(m_Handle->addonData, m_controlHandle, key); | ||
| 363 | } | ||
| 364 | |||
| 365 | bool GetPropertyBool(const char *key) const | ||
| 366 | { | ||
| 367 | return m_cb->Window_GetPropertyBool(m_Handle->addonData, m_controlHandle, key); | ||
| 368 | } | ||
| 369 | |||
| 370 | double GetPropertyDouble(const char *key) const | ||
| 371 | { | ||
| 372 | return m_cb->Window_GetPropertyDouble(m_Handle->addonData, m_controlHandle, key); | ||
| 373 | } | ||
| 374 | |||
| 375 | void ClearProperties() | ||
| 376 | { | ||
| 377 | m_cb->Window_ClearProperties(m_Handle->addonData, m_controlHandle); | ||
| 378 | } | ||
| 379 | |||
| 380 | int GetListSize() | ||
| 381 | { | ||
| 382 | return m_cb->Window_GetListSize(m_Handle->addonData, m_controlHandle); | ||
| 383 | } | ||
| 384 | |||
| 385 | void ClearList() | ||
| 386 | { | ||
| 387 | m_cb->Window_ClearList(m_Handle->addonData, m_controlHandle); | ||
| 388 | } | ||
| 389 | |||
| 390 | GUIHANDLE AddStringItem(const char *name, int itemPosition = -1) | ||
| 391 | { | ||
| 392 | return m_cb->Window_AddStringItem(m_Handle->addonData, m_controlHandle, name, itemPosition); | ||
| 393 | } | ||
| 394 | |||
| 395 | void AddItem(GUIHANDLE item, int itemPosition = -1) | ||
| 396 | { | ||
| 397 | m_cb->Window_AddItem(m_Handle->addonData, m_controlHandle, item, itemPosition); | ||
| 398 | } | ||
| 399 | |||
| 400 | void AddItem(CAddonListItem *item, int itemPosition = -1) | ||
| 401 | { | ||
| 402 | m_cb->Window_AddItem(m_Handle->addonData, m_controlHandle, item->GetControlHandle(), itemPosition); | ||
| 403 | } | ||
| 404 | |||
| 405 | void RemoveItem(int itemPosition) | ||
| 406 | { | ||
| 407 | m_cb->Window_RemoveItem(m_Handle->addonData, m_controlHandle, itemPosition); | ||
| 408 | } | ||
| 409 | |||
| 410 | GUIHANDLE GetListItem(int listPos) | ||
| 411 | { | ||
| 412 | return m_cb->Window_GetListItem(m_Handle->addonData, m_controlHandle, listPos); | ||
| 413 | } | ||
| 414 | |||
| 415 | void SetCurrentListPosition(int listPos) | ||
| 416 | { | ||
| 417 | m_cb->Window_SetCurrentListPosition(m_Handle->addonData, m_controlHandle, listPos); | ||
| 418 | } | ||
| 419 | |||
| 420 | int GetCurrentListPosition() | ||
| 421 | { | ||
| 422 | return m_cb->Window_GetCurrentListPosition(m_Handle->addonData, m_controlHandle); | ||
| 423 | } | ||
| 424 | |||
| 425 | void SetControlLabel(int controlId, const char *label) | ||
| 426 | { | ||
| 427 | m_cb->Window_SetControlLabel(m_Handle->addonData, m_controlHandle, controlId, label); | ||
| 428 | } | ||
| 429 | |||
| 430 | void MarkDirtyRegion() | ||
| 431 | { | ||
| 432 | m_cb->Window_MarkDirtyRegion(m_Handle->addonData, m_controlHandle); | ||
| 433 | } | ||
| 434 | |||
| 435 | bool OnClick(int controlId) | ||
| 436 | { | ||
| 437 | if (!CBOnClick) | ||
| 83 | return false; | 438 | return false; |
| 84 | } | ||
| 85 | 439 | ||
| 86 | GUI_register_me = (void* (*)(void *HANDLE)) | 440 | return CBOnClick(m_cbhdl, controlId); |
| 87 | dlsym(m_libKODI_guilib, "GUI_register_me"); | 441 | } |
| 88 | if (GUI_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 442 | |
| 443 | bool OnFocus(int controlId) | ||
| 444 | { | ||
| 445 | if (!CBOnFocus) | ||
| 446 | return false; | ||
| 447 | |||
| 448 | return CBOnFocus(m_cbhdl, controlId); | ||
| 449 | } | ||
| 450 | |||
| 451 | bool OnInit() | ||
| 452 | { | ||
| 453 | if (!CBOnInit) | ||
| 454 | return false; | ||
| 455 | |||
| 456 | return CBOnInit(m_cbhdl); | ||
| 457 | } | ||
| 458 | |||
| 459 | bool OnAction(int actionId) | ||
| 460 | { | ||
| 461 | if (!CBOnAction) | ||
| 462 | return false; | ||
| 463 | |||
| 464 | return CBOnAction(m_cbhdl, actionId); | ||
| 465 | } | ||
| 466 | |||
| 467 | GUIHANDLE m_cbhdl; | ||
| 468 | bool (*CBOnInit)(GUIHANDLE cbhdl); | ||
| 469 | bool (*CBOnFocus)(GUIHANDLE cbhdl, int controlId); | ||
| 470 | bool (*CBOnClick)(GUIHANDLE cbhdl, int controlId); | ||
| 471 | bool (*CBOnAction)(GUIHANDLE cbhdl, int actionId); | ||
| 472 | |||
| 473 | protected: | ||
| 474 | static bool OnInitCB(GUIHANDLE cbhdl); | ||
| 475 | static bool OnFocusCB(GUIHANDLE cbhdl, int controlId); | ||
| 476 | static bool OnClickCB(GUIHANDLE cbhdl, int controlId); | ||
| 477 | static bool OnActionCB(GUIHANDLE cbhdl, int actionId); | ||
| 478 | }; | ||
| 479 | |||
| 480 | |||
| 481 | inline bool CAddonGUIWindow::OnInitCB(GUIHANDLE cbhdl) | ||
| 482 | { | ||
| 483 | return static_cast<CAddonGUIWindow*>(cbhdl)->OnInit(); | ||
| 484 | } | ||
| 485 | |||
| 486 | inline bool CAddonGUIWindow::OnClickCB(GUIHANDLE cbhdl, int controlId) | ||
| 487 | { | ||
| 488 | return static_cast<CAddonGUIWindow*>(cbhdl)->OnClick(controlId); | ||
| 489 | } | ||
| 490 | |||
| 491 | inline bool CAddonGUIWindow::OnFocusCB(GUIHANDLE cbhdl, int controlId) | ||
| 492 | { | ||
| 493 | return static_cast<CAddonGUIWindow*>(cbhdl)->OnFocus(controlId); | ||
| 494 | } | ||
| 495 | |||
| 496 | inline bool CAddonGUIWindow::OnActionCB(GUIHANDLE cbhdl, int actionId) | ||
| 497 | { | ||
| 498 | return static_cast<CAddonGUIWindow*>(cbhdl)->OnAction(actionId); | ||
| 499 | } | ||
| 500 | |||
| 501 | class CAddonGUISpinControl: public CAddonGUIControlBase | ||
| 502 | { | ||
| 503 | public: | ||
| 504 | CAddonGUISpinControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) | ||
| 505 | : CAddonGUIControlBase(hdl, cb, window) | ||
| 506 | { | ||
| 507 | m_controlHandle = m_cb->Window_GetControl_Spin(m_Handle->addonData, m_Window->GetControlHandle(), controlId); | ||
| 508 | } | ||
| 509 | ~CAddonGUISpinControl(void) {} | ||
| 510 | |||
| 511 | void SetVisible(bool yesNo) | ||
| 512 | { | ||
| 513 | if (m_controlHandle) | ||
| 514 | m_cb->Control_Spin_SetVisible(m_Handle->addonData, m_controlHandle, yesNo); | ||
| 515 | } | ||
| 516 | |||
| 517 | void SetText(const char *label) | ||
| 518 | { | ||
| 519 | if (m_controlHandle) | ||
| 520 | m_cb->Control_Spin_SetText(m_Handle->addonData, m_controlHandle, label); | ||
| 521 | } | ||
| 522 | |||
| 523 | void Clear() | ||
| 524 | { | ||
| 525 | if (m_controlHandle) | ||
| 526 | m_cb->Control_Spin_Clear(m_Handle->addonData, m_controlHandle); | ||
| 527 | } | ||
| 528 | |||
| 529 | void AddLabel(const char *label, int iValue) | ||
| 530 | { | ||
| 531 | if (m_controlHandle) | ||
| 532 | m_cb->Control_Spin_AddLabel(m_Handle->addonData, m_controlHandle, label, iValue); | ||
| 533 | } | ||
| 534 | |||
| 535 | int GetValue() | ||
| 536 | { | ||
| 537 | if (!m_controlHandle) | ||
| 538 | return -1; | ||
| 539 | |||
| 540 | return m_cb->Control_Spin_GetValue(m_Handle->addonData, m_controlHandle); | ||
| 541 | } | ||
| 542 | |||
| 543 | void SetValue(int iValue) | ||
| 544 | { | ||
| 545 | if (m_controlHandle) | ||
| 546 | m_cb->Control_Spin_SetValue(m_Handle->addonData, m_controlHandle, iValue); | ||
| 547 | } | ||
| 548 | }; | ||
| 549 | |||
| 550 | class CAddonGUIRadioButton : public CAddonGUIControlBase | ||
| 551 | { | ||
| 552 | public: | ||
| 553 | CAddonGUIRadioButton(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) | ||
| 554 | : CAddonGUIControlBase(hdl, cb, window) | ||
| 555 | { | ||
| 556 | m_controlHandle = m_cb->Window_GetControl_RadioButton(m_Handle->addonData, m_Window->GetControlHandle(), controlId); | ||
| 557 | } | ||
| 558 | ~CAddonGUIRadioButton() {} | ||
| 559 | |||
| 560 | void SetVisible(bool yesNo) | ||
| 561 | { | ||
| 562 | if (m_controlHandle) | ||
| 563 | m_cb->Control_RadioButton_SetVisible(m_Handle->addonData, m_controlHandle, yesNo); | ||
| 564 | } | ||
| 565 | |||
| 566 | void SetText(const char *label) | ||
| 567 | { | ||
| 568 | if (m_controlHandle) | ||
| 569 | m_cb->Control_RadioButton_SetText(m_Handle->addonData, m_controlHandle, label); | ||
| 570 | } | ||
| 571 | |||
| 572 | void SetSelected(bool yesNo) | ||
| 573 | { | ||
| 574 | if (m_controlHandle) | ||
| 575 | m_cb->Control_RadioButton_SetSelected(m_Handle->addonData, m_controlHandle, yesNo); | ||
| 576 | } | ||
| 577 | |||
| 578 | bool IsSelected() | ||
| 579 | { | ||
| 580 | if (!m_controlHandle) | ||
| 581 | return false; | ||
| 582 | |||
| 583 | return m_cb->Control_RadioButton_IsSelected(m_Handle->addonData, m_controlHandle); | ||
| 584 | } | ||
| 585 | }; | ||
| 586 | |||
| 587 | class CAddonGUIProgressControl : public CAddonGUIControlBase | ||
| 588 | { | ||
| 589 | public: | ||
| 590 | CAddonGUIProgressControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) | ||
| 591 | : CAddonGUIControlBase(hdl, cb, window) | ||
| 592 | { | ||
| 593 | m_controlHandle = m_cb->Window_GetControl_Progress(m_Handle->addonData, m_Window->GetControlHandle(), controlId); | ||
| 594 | } | ||
| 595 | |||
| 596 | ~CAddonGUIProgressControl(void) {} | ||
| 597 | |||
| 598 | void SetPercentage(float fPercent) | ||
| 599 | { | ||
| 600 | if (m_controlHandle) | ||
| 601 | m_cb->Control_Progress_SetPercentage(m_Handle->addonData, m_controlHandle, fPercent); | ||
| 602 | } | ||
| 603 | |||
| 604 | float GetPercentage() const | ||
| 605 | { | ||
| 606 | if (!m_controlHandle) | ||
| 607 | return 0.0f; | ||
| 608 | |||
| 609 | return m_cb->Control_Progress_GetPercentage(m_Handle->addonData, m_controlHandle); | ||
| 610 | } | ||
| 611 | |||
| 612 | void SetInfo(int iInfo) | ||
| 613 | { | ||
| 614 | if (m_controlHandle) | ||
| 615 | m_cb->Control_Progress_SetInfo(m_Handle->addonData, m_controlHandle, iInfo); | ||
| 616 | } | ||
| 617 | |||
| 618 | int GetInfo() const | ||
| 619 | { | ||
| 620 | if (!m_controlHandle) | ||
| 621 | return -1; | ||
| 622 | |||
| 623 | return m_cb->Control_Progress_GetInfo(m_Handle->addonData, m_controlHandle); | ||
| 624 | } | ||
| 625 | |||
| 626 | std::string GetDescription() const | ||
| 627 | { | ||
| 628 | if (!m_controlHandle) | ||
| 629 | return ""; | ||
| 89 | 630 | ||
| 90 | GUI_unregister_me = (void (*)(void *HANDLE, void *CB)) | 631 | return m_cb->Control_Progress_GetDescription(m_Handle->addonData, m_controlHandle); |
| 91 | dlsym(m_libKODI_guilib, "GUI_unregister_me"); | 632 | } |
| 92 | if (GUI_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 633 | }; |
| 93 | 634 | ||
| 94 | GUI_lock = (void (*)(void *HANDLE, void *CB)) | 635 | class CAddonGUISliderControl : public CAddonGUIControlBase |
| 95 | dlsym(m_libKODI_guilib, "GUI_lock"); | 636 | { |
| 96 | if (GUI_lock == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 637 | public: |
| 638 | CAddonGUISliderControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) | ||
| 639 | : CAddonGUIControlBase(hdl, cb, window) | ||
| 640 | { | ||
| 641 | m_controlHandle = m_cb->Window_GetControl_Slider(m_Handle->addonData, m_Window->GetControlHandle(), controlId); | ||
| 642 | } | ||
| 643 | |||
| 644 | ~CAddonGUISliderControl(void) {} | ||
| 645 | |||
| 646 | void SetVisible(bool yesNo) | ||
| 647 | { | ||
| 648 | if (m_controlHandle) | ||
| 649 | m_cb->Control_Slider_SetVisible(m_Handle->addonData, m_controlHandle, yesNo); | ||
| 650 | } | ||
| 651 | |||
| 652 | std::string GetDescription() const | ||
| 653 | { | ||
| 654 | if (!m_controlHandle) | ||
| 655 | return ""; | ||
| 97 | 656 | ||
| 98 | GUI_unlock = (void (*)(void *HANDLE, void *CB)) | 657 | return m_cb->Control_Slider_GetDescription(m_Handle->addonData, m_controlHandle); |
| 99 | dlsym(m_libKODI_guilib, "GUI_unlock"); | 658 | } |
| 100 | if (GUI_unlock == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 101 | 659 | ||
| 102 | GUI_get_screen_height = (int (*)(void *HANDLE, void *CB)) | 660 | void SetIntRange(int iStart, int iEnd) |
| 103 | dlsym(m_libKODI_guilib, "GUI_get_screen_height"); | 661 | { |
| 104 | if (GUI_get_screen_height == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 662 | if (m_controlHandle) |
| 663 | m_cb->Control_Slider_SetIntRange(m_Handle->addonData, m_controlHandle, iStart, iEnd); | ||
| 664 | } | ||
| 105 | 665 | ||
| 106 | GUI_get_screen_width = (int (*)(void *HANDLE, void *CB)) | 666 | void SetIntValue(int iValue) |
| 107 | dlsym(m_libKODI_guilib, "GUI_get_screen_width"); | 667 | { |
| 108 | if (GUI_get_screen_width == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 668 | if (m_controlHandle) |
| 669 | m_cb->Control_Slider_SetIntValue(m_Handle->addonData, m_controlHandle, iValue); | ||
| 670 | } | ||
| 109 | 671 | ||
| 110 | GUI_get_video_resolution = (int (*)(void *HANDLE, void *CB)) | 672 | int GetIntValue() const |
| 111 | dlsym(m_libKODI_guilib, "GUI_get_video_resolution"); | 673 | { |
| 112 | if (GUI_get_video_resolution == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 674 | if (!m_controlHandle) |
| 675 | return 0; | ||
| 676 | return m_cb->Control_Slider_GetIntValue(m_Handle->addonData, m_controlHandle); | ||
| 677 | } | ||
| 113 | 678 | ||
| 114 | GUI_Window_create = (CAddonGUIWindow* (*)(void *HANDLE, void *CB, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog)) | 679 | void SetIntInterval(int iInterval) |
| 115 | dlsym(m_libKODI_guilib, "GUI_Window_create"); | 680 | { |
| 116 | if (GUI_Window_create == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 681 | if (m_controlHandle) |
| 682 | m_cb->Control_Slider_SetIntInterval(m_Handle->addonData, m_controlHandle, iInterval); | ||
| 683 | } | ||
| 117 | 684 | ||
| 118 | GUI_Window_destroy = (void (*)(CAddonGUIWindow* p)) | 685 | void SetPercentage(float fPercent) |
| 119 | dlsym(m_libKODI_guilib, "GUI_Window_destroy"); | 686 | { |
| 120 | if (GUI_Window_destroy == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 687 | if (m_controlHandle) |
| 688 | m_cb->Control_Slider_SetPercentage(m_Handle->addonData, m_controlHandle, fPercent); | ||
| 689 | } | ||
| 121 | 690 | ||
| 122 | GUI_control_get_spin = (CAddonGUISpinControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) | 691 | float GetPercentage() const |
| 123 | dlsym(m_libKODI_guilib, "GUI_control_get_spin"); | 692 | { |
| 124 | if (GUI_control_get_spin == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 693 | if (!m_controlHandle) |
| 694 | return 0.0f; | ||
| 125 | 695 | ||
| 126 | GUI_control_release_spin = (void (*)(CAddonGUISpinControl* p)) | 696 | return m_cb->Control_Slider_GetPercentage(m_Handle->addonData, m_controlHandle); |
| 127 | dlsym(m_libKODI_guilib, "GUI_control_release_spin"); | 697 | } |
| 128 | if (GUI_control_release_spin == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 129 | 698 | ||
| 130 | GUI_control_get_radiobutton = (CAddonGUIRadioButton* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) | 699 | void SetFloatRange(float fStart, float fEnd) |
| 131 | dlsym(m_libKODI_guilib, "GUI_control_get_radiobutton"); | 700 | { |
| 132 | if (GUI_control_get_radiobutton == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 701 | if (m_controlHandle) |
| 702 | m_cb->Control_Slider_SetFloatRange(m_Handle->addonData, m_controlHandle, fStart, fEnd); | ||
| 703 | } | ||
| 133 | 704 | ||
| 134 | GUI_control_release_radiobutton = (void (*)(CAddonGUIRadioButton* p)) | 705 | void SetFloatValue(float fValue) |
| 135 | dlsym(m_libKODI_guilib, "GUI_control_release_radiobutton"); | 706 | { |
| 136 | if (GUI_control_release_radiobutton == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 707 | if (m_controlHandle) |
| 708 | m_cb->Control_Slider_SetFloatValue(m_Handle->addonData, m_controlHandle, fValue); | ||
| 709 | } | ||
| 137 | 710 | ||
| 138 | GUI_control_get_progress = (CAddonGUIProgressControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) | 711 | float GetFloatValue() const |
| 139 | dlsym(m_libKODI_guilib, "GUI_control_get_progress"); | 712 | { |
| 140 | if (GUI_control_get_progress == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 713 | if (!m_controlHandle) |
| 714 | return 0.0f; | ||
| 715 | return m_cb->Control_Slider_GetFloatValue(m_Handle->addonData, m_controlHandle); | ||
| 716 | } | ||
| 141 | 717 | ||
| 142 | GUI_control_release_progress = (void (*)(CAddonGUIProgressControl* p)) | 718 | void SetFloatInterval(float fInterval) |
| 143 | dlsym(m_libKODI_guilib, "GUI_control_release_progress"); | 719 | { |
| 144 | if (GUI_control_release_progress == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 720 | if (m_controlHandle) |
| 721 | m_cb->Control_Slider_SetFloatInterval(m_Handle->addonData, m_controlHandle, fInterval); | ||
| 722 | } | ||
| 723 | }; | ||
| 145 | 724 | ||
| 146 | GUI_ListItem_create = (CAddonListItem* (*)(void *HANDLE, void *CB, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path)) | 725 | class CAddonGUISettingsSliderControl : public CAddonGUIControlBase |
| 147 | dlsym(m_libKODI_guilib, "GUI_ListItem_create"); | 726 | { |
| 148 | if (GUI_ListItem_create == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 727 | public: |
| 728 | CAddonGUISettingsSliderControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) | ||
| 729 | : CAddonGUIControlBase(hdl, cb, window) | ||
| 730 | { | ||
| 731 | m_controlHandle = m_cb->Window_GetControl_SettingsSlider(m_Handle->addonData, m_Window->GetControlHandle(), controlId); | ||
| 732 | } | ||
| 733 | |||
| 734 | ~CAddonGUISettingsSliderControl(void) {} | ||
| 149 | 735 | ||
| 150 | GUI_ListItem_destroy = (void (*)(CAddonListItem* p)) | 736 | void SetVisible(bool yesNo) |
| 151 | dlsym(m_libKODI_guilib, "GUI_ListItem_destroy"); | 737 | { |
| 152 | if (GUI_ListItem_destroy == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 738 | if (m_controlHandle) |
| 739 | m_cb->Control_SettingsSlider_SetVisible(m_Handle->addonData, m_controlHandle, yesNo); | ||
| 740 | } | ||
| 153 | 741 | ||
| 154 | GUI_control_get_rendering = (CAddonGUIRenderingControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) | 742 | void SetText(const char *label) |
| 155 | dlsym(m_libKODI_guilib, "GUI_control_get_rendering"); | 743 | { |
| 156 | if (GUI_control_get_rendering == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 744 | if (m_controlHandle) |
| 745 | m_cb->Control_SettingsSlider_SetText(m_Handle->addonData, m_controlHandle, label); | ||
| 746 | } | ||
| 157 | 747 | ||
| 158 | GUI_control_release_rendering = (void (*)(CAddonGUIRenderingControl* p)) | 748 | std::string GetDescription() const |
| 159 | dlsym(m_libKODI_guilib, "GUI_control_release_rendering"); | 749 | { |
| 160 | if (GUI_control_release_rendering == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 750 | if (!m_controlHandle) |
| 751 | return ""; | ||
| 161 | 752 | ||
| 162 | GUI_control_get_slider = (CAddonGUISliderControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) | 753 | return m_cb->Control_SettingsSlider_GetDescription(m_Handle->addonData, m_controlHandle); |
| 163 | dlsym(m_libKODI_guilib, "GUI_control_get_slider"); | 754 | } |
| 164 | if (GUI_control_get_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 165 | 755 | ||
| 166 | GUI_control_release_slider = (void (*)(CAddonGUISliderControl* p)) | 756 | void SetIntRange(int iStart, int iEnd) |
| 167 | dlsym(m_libKODI_guilib, "GUI_control_release_slider"); | 757 | { |
| 168 | if (GUI_control_release_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 758 | if (m_controlHandle) |
| 759 | m_cb->Control_SettingsSlider_SetIntRange(m_Handle->addonData, m_controlHandle, iStart, iEnd); | ||
| 760 | } | ||
| 169 | 761 | ||
| 170 | GUI_control_get_settings_slider = (CAddonGUISettingsSliderControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) | 762 | void SetIntValue(int iValue) |
| 171 | dlsym(m_libKODI_guilib, "GUI_control_get_settings_slider"); | 763 | { |
| 172 | if (GUI_control_get_settings_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 764 | if (m_controlHandle) |
| 765 | m_cb->Control_SettingsSlider_SetIntValue(m_Handle->addonData, m_controlHandle, iValue); | ||
| 766 | } | ||
| 173 | 767 | ||
| 174 | GUI_control_release_settings_slider = (void (*)(CAddonGUISettingsSliderControl* p)) | 768 | int GetIntValue() const |
| 175 | dlsym(m_libKODI_guilib, "GUI_control_release_settings_slider"); | 769 | { |
| 176 | if (GUI_control_release_settings_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 770 | if (!m_controlHandle) |
| 771 | return 0; | ||
| 772 | return m_cb->Control_SettingsSlider_GetIntValue(m_Handle->addonData, m_controlHandle); | ||
| 773 | } | ||
| 177 | 774 | ||
| 178 | GUI_dialog_keyboard_show_and_get_input_with_head = (bool (*)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs)) | 775 | void SetIntInterval(int iInterval) |
| 179 | dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_input_with_head"); | 776 | { |
| 180 | if (GUI_dialog_keyboard_show_and_get_input_with_head == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 777 | if (m_controlHandle) |
| 778 | m_cb->Control_SettingsSlider_SetIntInterval(m_Handle->addonData, m_controlHandle, iInterval); | ||
| 779 | } | ||
| 181 | 780 | ||
| 182 | GUI_dialog_keyboard_show_and_get_input = (bool (*)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs)) | 781 | void SetPercentage(float fPercent) |
| 183 | dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_input"); | 782 | { |
| 184 | if (GUI_dialog_keyboard_show_and_get_input == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 783 | if (m_controlHandle) |
| 784 | m_cb->Control_SettingsSlider_SetPercentage(m_Handle->addonData, m_controlHandle, fPercent); | ||
| 785 | } | ||
| 185 | 786 | ||
| 186 | GUI_dialog_keyboard_show_and_get_new_password_with_head = (bool (*)(void *HANDLE, void *CB, char &newPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs)) | 787 | float GetPercentage() const |
| 187 | dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_new_password_with_head"); | 788 | { |
| 188 | if (GUI_dialog_keyboard_show_and_get_new_password_with_head == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 789 | if (!m_controlHandle) |
| 790 | return 0.0f; | ||
| 189 | 791 | ||
| 190 | GUI_dialog_keyboard_show_and_get_new_password = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs)) | 792 | return m_cb->Control_SettingsSlider_GetPercentage(m_Handle->addonData, m_controlHandle); |
| 191 | dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_new_password"); | 793 | } |
| 192 | if (GUI_dialog_keyboard_show_and_get_new_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 193 | 794 | ||
| 194 | GUI_dialog_keyboard_show_and_verify_new_password_with_head = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs)) | 795 | void SetFloatRange(float fStart, float fEnd) |
| 195 | dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_verify_new_password_with_head"); | 796 | { |
| 196 | if (GUI_dialog_keyboard_show_and_verify_new_password_with_head == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 797 | if (m_controlHandle) |
| 798 | m_cb->Control_SettingsSlider_SetFloatRange(m_Handle->addonData, m_controlHandle, fStart, fEnd); | ||
| 799 | } | ||
| 197 | 800 | ||
| 198 | GUI_dialog_keyboard_show_and_verify_new_password = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs)) | 801 | void SetFloatValue(float fValue) |
| 199 | dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_verify_new_password"); | 802 | { |
| 200 | if (GUI_dialog_keyboard_show_and_verify_new_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 803 | if (m_controlHandle) |
| 804 | m_cb->Control_SettingsSlider_SetFloatValue(m_Handle->addonData, m_controlHandle, fValue); | ||
| 805 | } | ||
| 201 | 806 | ||
| 202 | GUI_dialog_keyboard_show_and_verify_password = (int (*)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs)) | 807 | float GetFloatValue() const |
| 203 | dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_verify_password"); | 808 | { |
| 204 | if (GUI_dialog_keyboard_show_and_verify_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 809 | if (!m_controlHandle) |
| 810 | return 0.0f; | ||
| 811 | return m_cb->Control_SettingsSlider_GetFloatValue(m_Handle->addonData, m_controlHandle); | ||
| 812 | } | ||
| 205 | 813 | ||
| 206 | GUI_dialog_keyboard_show_and_get_filter = (bool (*)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs)) | 814 | void SetFloatInterval(float fInterval) |
| 207 | dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_filter"); | 815 | { |
| 208 | if (GUI_dialog_keyboard_show_and_get_filter == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 816 | if (m_controlHandle) |
| 817 | m_cb->Control_SettingsSlider_SetFloatInterval(m_Handle->addonData, m_controlHandle, fInterval); | ||
| 818 | } | ||
| 819 | }; | ||
| 209 | 820 | ||
| 210 | GUI_dialog_keyboard_send_text_to_active_keyboard = (bool (*)(void *HANDLE, void *CB, const char *aTextString, bool closeKeyboard)) | 821 | class CAddonGUIRenderingControl : public CAddonGUIControlBase |
| 211 | dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_send_text_to_active_keyboard"); | 822 | { |
| 212 | if (GUI_dialog_keyboard_send_text_to_active_keyboard == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 823 | public: |
| 824 | CAddonGUIRenderingControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) | ||
| 825 | : CAddonGUIControlBase(hdl, cb, window) | ||
| 826 | , m_cbhdl(nullptr) | ||
| 827 | , CBCreate(nullptr) | ||
| 828 | , CBRender(nullptr) | ||
| 829 | , CBStop(nullptr) | ||
| 830 | , CBDirty(nullptr) | ||
| 831 | { | ||
| 832 | m_controlHandle = m_cb->Window_GetControl_RenderAddon(m_Handle->addonData, m_Window->GetControlHandle(), controlId); | ||
| 833 | } | ||
| 213 | 834 | ||
| 214 | GUI_dialog_keyboard_is_activated = (bool (*)(void *HANDLE, void *CB)) | 835 | virtual ~CAddonGUIRenderingControl() |
| 215 | dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_is_activated"); | 836 | { |
| 216 | if (GUI_dialog_keyboard_is_activated == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 837 | m_cb->RenderAddon_Delete(m_Handle->addonData, m_controlHandle); |
| 838 | } | ||
| 217 | 839 | ||
| 218 | GUI_dialog_numeric_show_and_verify_new_password = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize)) | 840 | void Init() |
| 219 | dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_verify_new_password"); | 841 | { |
| 220 | if (GUI_dialog_numeric_show_and_verify_new_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 842 | m_cb->RenderAddon_SetCallbacks(m_Handle->addonData, m_controlHandle, this, OnCreateCB, OnRenderCB, OnStopCB, OnDirtyCB); |
| 843 | } | ||
| 221 | 844 | ||
| 222 | GUI_dialog_numeric_show_and_verify_password = (int (*)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries)) | 845 | bool Create(int x, int y, int w, int h, void *device) |
| 223 | dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_verify_password"); | 846 | { |
| 224 | if (GUI_dialog_numeric_show_and_verify_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 847 | if (!CBCreate) |
| 848 | return false; | ||
| 225 | 849 | ||
| 226 | GUI_dialog_numeric_show_and_verify_input = (bool (*)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput)) | 850 | return CBCreate(m_cbhdl, x, y, w, h, device); |
| 227 | dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_verify_input"); | 851 | } |
| 228 | if (GUI_dialog_numeric_show_and_verify_input == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 229 | 852 | ||
| 230 | GUI_dialog_numeric_show_and_get_time = (bool (*)(void *HANDLE, void *CB, tm &time, const char *strHeading)) | 853 | void Render() |
| 231 | dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_time"); | 854 | { |
| 232 | if (GUI_dialog_numeric_show_and_get_time == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 855 | if (!CBRender) |
| 856 | return; | ||
| 233 | 857 | ||
| 234 | GUI_dialog_numeric_show_and_get_date = (bool (*)(void *HANDLE, void *CB, tm &date, const char *strHeading)) | 858 | CBRender(m_cbhdl); |
| 235 | dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_date"); | 859 | } |
| 236 | if (GUI_dialog_numeric_show_and_get_date == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 237 | 860 | ||
| 238 | GUI_dialog_numeric_show_and_get_ipaddress = (bool (*)(void *HANDLE, void *CB, char &IPAddress, unsigned int iMaxStringSize, const char *strHeading)) | 861 | void Stop() |
| 239 | dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_ipaddress"); | 862 | { |
| 240 | if (GUI_dialog_numeric_show_and_get_ipaddress == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 863 | if (!CBStop) |
| 864 | return; | ||
| 241 | 865 | ||
| 242 | GUI_dialog_numeric_show_and_get_number = (bool (*)(void *HANDLE, void *CB, char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs)) | 866 | CBStop(m_cbhdl); |
| 243 | dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_number"); | 867 | } |
| 244 | if (GUI_dialog_numeric_show_and_get_number == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 245 | 868 | ||
| 246 | GUI_dialog_numeric_show_and_get_seconds = (bool (*)(void *HANDLE, void *CB, char &strTime, unsigned int iMaxStringSize, const char *strHeading)) | 869 | bool Dirty() |
| 247 | dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_seconds"); | 870 | { |
| 248 | if (GUI_dialog_numeric_show_and_get_seconds == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 871 | if (!CBDirty) |
| 872 | return true; | ||
| 249 | 873 | ||
| 250 | GUI_dialog_filebrowser_show_and_get_file = (bool (*)(void *HANDLE, void *CB, const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList)) | 874 | return CBDirty(m_cbhdl); |
| 251 | dlsym(m_libKODI_guilib, "GUI_dialog_filebrowser_show_and_get_file"); | 875 | } |
| 252 | if (GUI_dialog_filebrowser_show_and_get_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 253 | 876 | ||
| 254 | GUI_dialog_ok_show_and_get_input_single_text = (void (*)(void *HANDLE, void *CB, const char *heading, const char *text)) | 877 | GUIHANDLE m_cbhdl; |
| 255 | dlsym(m_libKODI_guilib, "GUI_dialog_ok_show_and_get_input_single_text"); | 878 | bool (*CBCreate)(GUIHANDLE cbhdl, int x, int y, int w, int h, void *device); |
| 256 | if (GUI_dialog_ok_show_and_get_input_single_text == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 879 | void (*CBRender)(GUIHANDLE cbhdl); |
| 880 | void (*CBStop)(GUIHANDLE cbhdl); | ||
| 881 | bool (*CBDirty)(GUIHANDLE cbhdl); | ||
| 257 | 882 | ||
| 258 | GUI_dialog_ok_show_and_get_input_line_text = (void (*)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2)) | 883 | private: |
| 259 | dlsym(m_libKODI_guilib, "GUI_dialog_ok_show_and_get_input_line_text"); | 884 | static bool OnCreateCB(GUIHANDLE cbhdl, int x, int y, int w, int h, void* device); |
| 260 | if (GUI_dialog_ok_show_and_get_input_line_text == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 885 | static void OnRenderCB(GUIHANDLE cbhdl); |
| 886 | static void OnStopCB(GUIHANDLE cbhdl); | ||
| 887 | static bool OnDirtyCB(GUIHANDLE cbhdl); | ||
| 888 | }; | ||
| 261 | 889 | ||
| 262 | GUI_dialog_yesno_show_and_get_input_singletext = (bool (*)(void *HANDLE, void *CB, const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel)) | 890 | inline bool CAddonGUIRenderingControl::OnCreateCB(GUIHANDLE cbhdl, int x, int y, int w, int h, void* device) |
| 263 | dlsym(m_libKODI_guilib, "GUI_dialog_yesno_show_and_get_input_singletext"); | 891 | { |
| 264 | if (GUI_dialog_yesno_show_and_get_input_singletext == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 892 | return static_cast<CAddonGUIRenderingControl*>(cbhdl)->Create(x, y, w, h, device); |
| 893 | } | ||
| 265 | 894 | ||
| 266 | GUI_dialog_yesno_show_and_get_input_linetext = (bool (*)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel)) | 895 | inline void CAddonGUIRenderingControl::OnRenderCB(GUIHANDLE cbhdl) |
| 267 | dlsym(m_libKODI_guilib, "GUI_dialog_yesno_show_and_get_input_linetext"); | 896 | { |
| 268 | if (GUI_dialog_yesno_show_and_get_input_linetext == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 897 | static_cast<CAddonGUIRenderingControl*>(cbhdl)->Render(); |
| 898 | } | ||
| 269 | 899 | ||
| 270 | GUI_dialog_yesno_show_and_get_input_linebuttontext = (bool (*)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel)) | 900 | inline void CAddonGUIRenderingControl::OnStopCB(GUIHANDLE cbhdl) |
| 271 | dlsym(m_libKODI_guilib, "GUI_dialog_yesno_show_and_get_input_linebuttontext"); | 901 | { |
| 272 | if (GUI_dialog_yesno_show_and_get_input_linebuttontext == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 902 | static_cast<CAddonGUIRenderingControl*>(cbhdl)->Stop(); |
| 903 | } | ||
| 273 | 904 | ||
| 274 | GUI_dialog_text_viewer = (void (*)(void *hdl, void *cb, const char *heading, const char *text)) | 905 | inline bool CAddonGUIRenderingControl::OnDirtyCB(GUIHANDLE cbhdl) |
| 275 | dlsym(m_libKODI_guilib, "GUI_dialog_text_viewer"); | 906 | { |
| 276 | if (GUI_dialog_text_viewer == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 907 | return static_cast<CAddonGUIRenderingControl*>(cbhdl)->Dirty(); |
| 908 | } | ||
| 909 | |||
| 910 | class CHelper_libKODI_guilib | ||
| 911 | { | ||
| 912 | public: | ||
| 913 | CHelper_libKODI_guilib() | ||
| 914 | { | ||
| 915 | m_Handle = nullptr; | ||
| 916 | m_Callbacks = nullptr; | ||
| 917 | } | ||
| 277 | 918 | ||
| 278 | GUI_dialog_select = (int (*)(void *hdl, void *cb, const char *heading, const char *entries[], unsigned int size, int selected)) | 919 | ~CHelper_libKODI_guilib() |
| 279 | dlsym(m_libKODI_guilib, "GUI_dialog_select"); | 920 | { |
| 280 | if (GUI_dialog_select == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | 921 | if (m_Handle && m_Callbacks) |
| 922 | { | ||
| 923 | m_Handle->GUILib_UnRegisterMe(m_Handle->addonData, m_Callbacks); | ||
| 924 | } | ||
| 925 | } | ||
| 281 | 926 | ||
| 282 | m_Callbacks = GUI_register_me(m_Handle); | 927 | bool RegisterMe(void *handle) |
| 283 | return m_Callbacks != NULL; | 928 | { |
| 929 | m_Handle = static_cast<AddonCB*>(handle); | ||
| 930 | if (m_Handle) | ||
| 931 | m_Callbacks = (KodiAPI::GUI::CB_GUILib*)m_Handle->GUILib_RegisterMe(m_Handle->addonData); | ||
| 932 | if (!m_Callbacks) | ||
| 933 | fprintf(stderr, "libKODI_guilib-ERROR: GUILib_RegisterMe can't get callback table from Kodi !!!\n"); | ||
| 934 | |||
| 935 | return m_Callbacks != nullptr; | ||
| 284 | } | 936 | } |
| 285 | 937 | ||
| 286 | void Lock() | 938 | void Lock() |
| 287 | { | 939 | { |
| 288 | return GUI_lock(m_Handle, m_Callbacks); | 940 | m_Callbacks->Lock(); |
| 289 | } | 941 | } |
| 290 | 942 | ||
| 291 | void Unlock() | 943 | void Unlock() |
| 292 | { | 944 | { |
| 293 | return GUI_unlock(m_Handle, m_Callbacks); | 945 | m_Callbacks->Unlock(); |
| 294 | } | 946 | } |
| 295 | 947 | ||
| 296 | int GetScreenHeight() | 948 | int GetScreenHeight() |
| 297 | { | 949 | { |
| 298 | return GUI_get_screen_height(m_Handle, m_Callbacks); | 950 | return m_Callbacks->GetScreenHeight(); |
| 299 | } | 951 | } |
| 300 | 952 | ||
| 301 | int GetScreenWidth() | 953 | int GetScreenWidth() |
| 302 | { | 954 | { |
| 303 | return GUI_get_screen_width(m_Handle, m_Callbacks); | 955 | return m_Callbacks->GetScreenWidth(); |
| 304 | } | 956 | } |
| 305 | 957 | ||
| 306 | int GetVideoResolution() | 958 | int GetVideoResolution() |
| 307 | { | 959 | { |
| 308 | return GUI_get_video_resolution(m_Handle, m_Callbacks); | 960 | return m_Callbacks->GetVideoResolution(); |
| 309 | } | 961 | } |
| 310 | 962 | ||
| 311 | CAddonGUIWindow* Window_create(const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog) | 963 | CAddonGUIWindow* Window_create(const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog) |
| 312 | { | 964 | { |
| 313 | return GUI_Window_create(m_Handle, m_Callbacks, xmlFilename, defaultSkin, forceFallback, asDialog); | 965 | return new CAddonGUIWindow(m_Handle, m_Callbacks, xmlFilename, defaultSkin, forceFallback, asDialog); |
| 314 | } | 966 | } |
| 315 | 967 | ||
| 316 | void Window_destroy(CAddonGUIWindow* p) | 968 | void Window_destroy(CAddonGUIWindow* p) |
| 317 | { | 969 | { |
| 318 | return GUI_Window_destroy(p); | 970 | delete p; |
| 319 | } | 971 | } |
| 320 | 972 | ||
| 321 | CAddonGUISpinControl* Control_getSpin(CAddonGUIWindow *window, int controlId) | 973 | CAddonGUISpinControl* Control_getSpin(CAddonGUIWindow *window, int controlId) |
| 322 | { | 974 | { |
| 323 | return GUI_control_get_spin(m_Handle, m_Callbacks, window, controlId); | 975 | return new CAddonGUISpinControl(m_Handle, m_Callbacks, window, controlId); |
| 324 | } | 976 | } |
| 325 | 977 | ||
| 326 | void Control_releaseSpin(CAddonGUISpinControl* p) | 978 | void Control_releaseSpin(CAddonGUISpinControl* p) |
| 327 | { | 979 | { |
| 328 | return GUI_control_release_spin(p); | 980 | delete p; |
| 329 | } | 981 | } |
| 330 | 982 | ||
| 331 | CAddonGUIRadioButton* Control_getRadioButton(CAddonGUIWindow *window, int controlId) | 983 | CAddonGUIRadioButton* Control_getRadioButton(CAddonGUIWindow *window, int controlId) |
| 332 | { | 984 | { |
| 333 | return GUI_control_get_radiobutton(m_Handle, m_Callbacks, window, controlId); | 985 | return new CAddonGUIRadioButton(m_Handle, m_Callbacks, window, controlId); |
| 334 | } | 986 | } |
| 335 | 987 | ||
| 336 | void Control_releaseRadioButton(CAddonGUIRadioButton* p) | 988 | void Control_releaseRadioButton(CAddonGUIRadioButton* p) |
| 337 | { | 989 | { |
| 338 | return GUI_control_release_radiobutton(p); | 990 | delete p; |
| 339 | } | 991 | } |
| 340 | 992 | ||
| 341 | CAddonGUIProgressControl* Control_getProgress(CAddonGUIWindow *window, int controlId) | 993 | CAddonGUIProgressControl* Control_getProgress(CAddonGUIWindow *window, int controlId) |
| 342 | { | 994 | { |
| 343 | return GUI_control_get_progress(m_Handle, m_Callbacks, window, controlId); | 995 | return new CAddonGUIProgressControl(m_Handle, m_Callbacks, window, controlId); |
| 344 | } | 996 | } |
| 345 | 997 | ||
| 346 | void Control_releaseProgress(CAddonGUIProgressControl* p) | 998 | void Control_releaseProgress(CAddonGUIProgressControl* p) |
| 347 | { | 999 | { |
| 348 | return GUI_control_release_progress(p); | 1000 | delete p; |
| 349 | } | 1001 | } |
| 350 | 1002 | ||
| 351 | CAddonListItem* ListItem_create(const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path) | 1003 | CAddonListItem* ListItem_create(const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path) |
| 352 | { | 1004 | { |
| 353 | return GUI_ListItem_create(m_Handle, m_Callbacks, label, label2, iconImage, thumbnailImage, path); | 1005 | return new CAddonListItem(m_Handle, m_Callbacks, label, label2, iconImage, thumbnailImage, path); |
| 354 | } | 1006 | } |
| 355 | 1007 | ||
| 356 | void ListItem_destroy(CAddonListItem* p) | 1008 | void ListItem_destroy(CAddonListItem* p) |
| 357 | { | 1009 | { |
| 358 | return GUI_ListItem_destroy(p); | 1010 | delete p; |
| 359 | } | 1011 | } |
| 360 | 1012 | ||
| 361 | CAddonGUIRenderingControl* Control_getRendering(CAddonGUIWindow *window, int controlId) | 1013 | CAddonGUIRenderingControl* Control_getRendering(CAddonGUIWindow *window, int controlId) |
| 362 | { | 1014 | { |
| 363 | return GUI_control_get_rendering(m_Handle, m_Callbacks, window, controlId); | 1015 | return new CAddonGUIRenderingControl(m_Handle, m_Callbacks, window, controlId); |
| 364 | } | 1016 | } |
| 365 | 1017 | ||
| 366 | void Control_releaseRendering(CAddonGUIRenderingControl* p) | 1018 | void Control_releaseRendering(CAddonGUIRenderingControl* p) |
| 367 | { | 1019 | { |
| 368 | return GUI_control_release_rendering(p); | 1020 | delete p; |
| 369 | } | 1021 | } |
| 370 | 1022 | ||
| 371 | CAddonGUISliderControl* Control_getSlider(CAddonGUIWindow *window, int controlId) | 1023 | CAddonGUISliderControl* Control_getSlider(CAddonGUIWindow *window, int controlId) |
| 372 | { | 1024 | { |
| 373 | return GUI_control_get_slider(m_Handle, m_Callbacks, window, controlId); | 1025 | return new CAddonGUISliderControl(m_Handle, m_Callbacks, window, controlId); |
| 374 | } | 1026 | } |
| 375 | 1027 | ||
| 376 | void Control_releaseSlider(CAddonGUISliderControl* p) | 1028 | void Control_releaseSlider(CAddonGUISliderControl* p) |
| 377 | { | 1029 | { |
| 378 | return GUI_control_release_slider(p); | 1030 | delete p; |
| 379 | } | 1031 | } |
| 380 | 1032 | ||
| 381 | CAddonGUISettingsSliderControl* Control_getSettingsSlider(CAddonGUIWindow *window, int controlId) | 1033 | CAddonGUISettingsSliderControl* Control_getSettingsSlider(CAddonGUIWindow *window, int controlId) |
| 382 | { | 1034 | { |
| 383 | return GUI_control_get_settings_slider(m_Handle, m_Callbacks, window, controlId); | 1035 | return new CAddonGUISettingsSliderControl(m_Handle, m_Callbacks, window, controlId); |
| 384 | } | 1036 | } |
| 385 | 1037 | ||
| 386 | void Control_releaseSettingsSlider(CAddonGUISettingsSliderControl* p) | 1038 | void Control_releaseSettingsSlider(CAddonGUISettingsSliderControl* p) |
| 387 | { | 1039 | { |
| 388 | return GUI_control_release_settings_slider(p); | 1040 | delete p; |
| 389 | } | 1041 | } |
| 390 | 1042 | ||
| 391 | /*! @name GUI Keyboard functions */ | 1043 | /*! @name GUI Keyboard functions */ |
| 392 | //@{ | 1044 | //@{ |
| 393 | bool Dialog_Keyboard_ShowAndGetInput(char &strText, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs = 0) | 1045 | bool Dialog_Keyboard_ShowAndGetInput(char &strText, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs = 0) |
| 394 | { | 1046 | { |
| 395 | return GUI_dialog_keyboard_show_and_get_input_with_head(m_Handle, m_Callbacks, strText, iMaxStringSize, strHeading, allowEmptyResult, hiddenInput, autoCloseMs); | 1047 | return m_Callbacks->Dialog_Keyboard_ShowAndGetInputWithHead(strText, iMaxStringSize, strHeading, allowEmptyResult, hiddenInput, autoCloseMs); |
| 396 | } | 1048 | } |
| 397 | 1049 | ||
| 398 | bool Dialog_Keyboard_ShowAndGetInput(char &strText, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs = 0) | 1050 | bool Dialog_Keyboard_ShowAndGetInput(char &strText, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs = 0) |
| 399 | { | 1051 | { |
| 400 | return GUI_dialog_keyboard_show_and_get_input(m_Handle, m_Callbacks, strText, iMaxStringSize, allowEmptyResult, autoCloseMs); | 1052 | return m_Callbacks->Dialog_Keyboard_ShowAndGetInput(strText, iMaxStringSize, allowEmptyResult, autoCloseMs); |
| 401 | } | 1053 | } |
| 402 | 1054 | ||
| 403 | bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs = 0) | 1055 | bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs = 0) |
| 404 | { | 1056 | { |
| 405 | return GUI_dialog_keyboard_show_and_get_new_password_with_head(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs); | 1057 | return m_Callbacks->Dialog_Keyboard_ShowAndGetNewPasswordWithHead(strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs); |
| 406 | } | 1058 | } |
| 407 | 1059 | ||
| 408 | bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs = 0) | 1060 | bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs = 0) |
| 409 | { | 1061 | { |
| 410 | return GUI_dialog_keyboard_show_and_get_new_password(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, autoCloseMs); | 1062 | return m_Callbacks->Dialog_Keyboard_ShowAndGetNewPassword(strNewPassword, iMaxStringSize, autoCloseMs); |
| 411 | } | 1063 | } |
| 412 | 1064 | ||
| 413 | bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs = 0) | 1065 | bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs = 0) |
| 414 | { | 1066 | { |
| 415 | return GUI_dialog_keyboard_show_and_verify_new_password_with_head(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs); | 1067 | return m_Callbacks->Dialog_Keyboard_ShowAndVerifyNewPasswordWithHead(strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs); |
| 416 | } | 1068 | } |
| 417 | 1069 | ||
| 418 | bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs = 0) | 1070 | bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs = 0) |
| 419 | { | 1071 | { |
| 420 | return GUI_dialog_keyboard_show_and_verify_new_password(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, autoCloseMs); | 1072 | return m_Callbacks->Dialog_Keyboard_ShowAndVerifyNewPassword(strNewPassword, iMaxStringSize, autoCloseMs); |
| 421 | } | 1073 | } |
| 422 | 1074 | ||
| 423 | int Dialog_Keyboard_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs = 0) | 1075 | int Dialog_Keyboard_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs = 0) |
| 424 | { | 1076 | { |
| 425 | return GUI_dialog_keyboard_show_and_verify_password(m_Handle, m_Callbacks, strPassword, iMaxStringSize, strHeading, iRetries, autoCloseMs); | 1077 | return m_Callbacks->Dialog_Keyboard_ShowAndVerifyPassword(strPassword, iMaxStringSize, strHeading, iRetries, autoCloseMs); |
| 426 | } | 1078 | } |
| 427 | 1079 | ||
| 428 | bool Dialog_Keyboard_ShowAndGetFilter(char &strText, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs = 0) | 1080 | bool Dialog_Keyboard_ShowAndGetFilter(char &strText, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs = 0) |
| 429 | { | 1081 | { |
| 430 | return GUI_dialog_keyboard_show_and_get_filter(m_Handle, m_Callbacks, strText, iMaxStringSize, searching, autoCloseMs); | 1082 | return m_Callbacks->Dialog_Keyboard_ShowAndGetFilter(strText, iMaxStringSize, searching, autoCloseMs); |
| 431 | } | 1083 | } |
| 432 | 1084 | ||
| 433 | bool Dialog_Keyboard_SendTextToActiveKeyboard(const char *aTextString, bool closeKeyboard = false) | 1085 | bool Dialog_Keyboard_SendTextToActiveKeyboard(const char *aTextString, bool closeKeyboard = false) |
| 434 | { | 1086 | { |
| 435 | return GUI_dialog_keyboard_send_text_to_active_keyboard(m_Handle, m_Callbacks, aTextString, closeKeyboard); | 1087 | return m_Callbacks->Dialog_Keyboard_SendTextToActiveKeyboard(aTextString, closeKeyboard); |
| 436 | } | 1088 | } |
| 437 | 1089 | ||
| 438 | bool Dialog_Keyboard_isKeyboardActivated() | 1090 | bool Dialog_Keyboard_isKeyboardActivated() |
| 439 | { | 1091 | { |
| 440 | return GUI_dialog_keyboard_is_activated(m_Handle, m_Callbacks); | 1092 | return m_Callbacks->Dialog_Keyboard_isKeyboardActivated(); |
| 441 | } | 1093 | } |
| 442 | //@} | 1094 | //@} |
| 443 | 1095 | ||
| @@ -445,42 +1097,42 @@ public: | |||
| 445 | //@{ | 1097 | //@{ |
| 446 | bool Dialog_Numeric_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize) | 1098 | bool Dialog_Numeric_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize) |
| 447 | { | 1099 | { |
| 448 | return GUI_dialog_numeric_show_and_verify_new_password(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize); | 1100 | return m_Callbacks->Dialog_Numeric_ShowAndVerifyNewPassword(strNewPassword, iMaxStringSize); |
| 449 | } | 1101 | } |
| 450 | 1102 | ||
| 451 | int Dialog_Numeric_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries) | 1103 | int Dialog_Numeric_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries) |
| 452 | { | 1104 | { |
| 453 | return GUI_dialog_numeric_show_and_verify_password(m_Handle, m_Callbacks, strPassword, iMaxStringSize, strHeading, iRetries); | 1105 | return m_Callbacks->Dialog_Numeric_ShowAndVerifyPassword(strPassword, iMaxStringSize, strHeading, iRetries); |
| 454 | } | 1106 | } |
| 455 | 1107 | ||
| 456 | bool Dialog_Numeric_ShowAndVerifyInput(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput) | 1108 | bool Dialog_Numeric_ShowAndVerifyInput(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput) |
| 457 | { | 1109 | { |
| 458 | return GUI_dialog_numeric_show_and_verify_input(m_Handle, m_Callbacks, strPassword, iMaxStringSize, strHeading, bGetUserInput); | 1110 | return m_Callbacks->Dialog_Numeric_ShowAndVerifyInput(strPassword, iMaxStringSize, strHeading, bGetUserInput); |
| 459 | } | 1111 | } |
| 460 | 1112 | ||
| 461 | bool Dialog_Numeric_ShowAndGetTime(tm &time, const char *strHeading) | 1113 | bool Dialog_Numeric_ShowAndGetTime(tm &time, const char *strHeading) |
| 462 | { | 1114 | { |
| 463 | return GUI_dialog_numeric_show_and_get_time(m_Handle, m_Callbacks, time, strHeading); | 1115 | return m_Callbacks->Dialog_Numeric_ShowAndGetTime(time, strHeading); |
| 464 | } | 1116 | } |
| 465 | 1117 | ||
| 466 | bool Dialog_Numeric_ShowAndGetDate(tm &date, const char *strHeading) | 1118 | bool Dialog_Numeric_ShowAndGetDate(tm &date, const char *strHeading) |
| 467 | { | 1119 | { |
| 468 | return GUI_dialog_numeric_show_and_get_date(m_Handle, m_Callbacks, date, strHeading); | 1120 | return m_Callbacks->Dialog_Numeric_ShowAndGetDate(date, strHeading); |
| 469 | } | 1121 | } |
| 470 | 1122 | ||
| 471 | bool Dialog_Numeric_ShowAndGetIPAddress(char &strIPAddress, unsigned int iMaxStringSize, const char *strHeading) | 1123 | bool Dialog_Numeric_ShowAndGetIPAddress(char &strIPAddress, unsigned int iMaxStringSize, const char *strHeading) |
| 472 | { | 1124 | { |
| 473 | return GUI_dialog_numeric_show_and_get_ipaddress(m_Handle, m_Callbacks, strIPAddress, iMaxStringSize, strHeading); | 1125 | return m_Callbacks->Dialog_Numeric_ShowAndGetIPAddress(strIPAddress, iMaxStringSize, strHeading); |
| 474 | } | 1126 | } |
| 475 | 1127 | ||
| 476 | bool Dialog_Numeric_ShowAndGetNumber(char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs = 0) | 1128 | bool Dialog_Numeric_ShowAndGetNumber(char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs = 0) |
| 477 | { | 1129 | { |
| 478 | return GUI_dialog_numeric_show_and_get_number(m_Handle, m_Callbacks, strInput, iMaxStringSize, strHeading, iAutoCloseTimeoutMs); | 1130 | return m_Callbacks->Dialog_Numeric_ShowAndGetNumber(strInput, iMaxStringSize, strHeading, iAutoCloseTimeoutMs); |
| 479 | } | 1131 | } |
| 480 | 1132 | ||
| 481 | bool Dialog_Numeric_ShowAndGetSeconds(char &strTime, unsigned int iMaxStringSize, const char *strHeading) | 1133 | bool Dialog_Numeric_ShowAndGetSeconds(char &strTime, unsigned int iMaxStringSize, const char *strHeading) |
| 482 | { | 1134 | { |
| 483 | return GUI_dialog_numeric_show_and_get_seconds(m_Handle, m_Callbacks, strTime, iMaxStringSize, strHeading); | 1135 | return m_Callbacks->Dialog_Numeric_ShowAndGetSeconds(strTime, iMaxStringSize, strHeading); |
| 484 | } | 1136 | } |
| 485 | //@} | 1137 | //@} |
| 486 | 1138 | ||
| @@ -488,7 +1140,7 @@ public: | |||
| 488 | //@{ | 1140 | //@{ |
| 489 | bool Dialog_FileBrowser_ShowAndGetFile(const char *directory, const char *mask, const char *heading, char &strPath, unsigned int iMaxStringSize, bool useThumbs = false, bool useFileDirectories = false, bool singleList = false) | 1141 | bool Dialog_FileBrowser_ShowAndGetFile(const char *directory, const char *mask, const char *heading, char &strPath, unsigned int iMaxStringSize, bool useThumbs = false, bool useFileDirectories = false, bool singleList = false) |
| 490 | { | 1142 | { |
| 491 | return GUI_dialog_filebrowser_show_and_get_file(m_Handle, m_Callbacks, directory, mask, heading, strPath, iMaxStringSize, useThumbs, useFileDirectories, singleList); | 1143 | return m_Callbacks->Dialog_FileBrowser_ShowAndGetFile(directory, mask, heading, strPath, iMaxStringSize, useThumbs, useFileDirectories, singleList); |
| 492 | } | 1144 | } |
| 493 | //@} | 1145 | //@} |
| 494 | 1146 | ||
| @@ -496,12 +1148,12 @@ public: | |||
| 496 | //@{ | 1148 | //@{ |
| 497 | void Dialog_OK_ShowAndGetInput(const char *heading, const char *text) | 1149 | void Dialog_OK_ShowAndGetInput(const char *heading, const char *text) |
| 498 | { | 1150 | { |
| 499 | GUI_dialog_ok_show_and_get_input_single_text(m_Handle, m_Callbacks, heading, text); | 1151 | return m_Callbacks->Dialog_OK_ShowAndGetInputSingleText(heading, text); |
| 500 | } | 1152 | } |
| 501 | 1153 | ||
| 502 | void Dialog_OK_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2) | 1154 | void Dialog_OK_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2) |
| 503 | { | 1155 | { |
| 504 | GUI_dialog_ok_show_and_get_input_line_text(m_Handle, m_Callbacks, heading, line0, line1, line2); | 1156 | return m_Callbacks->Dialog_OK_ShowAndGetInputLineText(heading, line0, line1, line2); |
| 505 | } | 1157 | } |
| 506 | //@} | 1158 | //@} |
| 507 | 1159 | ||
| @@ -509,17 +1161,17 @@ public: | |||
| 509 | //@{ | 1161 | //@{ |
| 510 | bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *text, bool& bCanceled, const char *noLabel = "", const char *yesLabel = "") | 1162 | bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *text, bool& bCanceled, const char *noLabel = "", const char *yesLabel = "") |
| 511 | { | 1163 | { |
| 512 | return GUI_dialog_yesno_show_and_get_input_singletext(m_Handle, m_Callbacks, heading, text, bCanceled, noLabel, yesLabel); | 1164 | return m_Callbacks->Dialog_YesNo_ShowAndGetInputSingleText(heading, text, bCanceled, noLabel, yesLabel); |
| 513 | } | 1165 | } |
| 514 | 1166 | ||
| 515 | bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel = "", const char *yesLabel = "") | 1167 | bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel = "", const char *yesLabel = "") |
| 516 | { | 1168 | { |
| 517 | return GUI_dialog_yesno_show_and_get_input_linetext(m_Handle, m_Callbacks, heading, line0, line1, line2, noLabel, yesLabel); | 1169 | return m_Callbacks->Dialog_YesNo_ShowAndGetInputLineText(heading, line0, line1, line2, noLabel, yesLabel); |
| 518 | } | 1170 | } |
| 519 | 1171 | ||
| 520 | bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel = "", const char *yesLabel = "") | 1172 | bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel = "", const char *yesLabel = "") |
| 521 | { | 1173 | { |
| 522 | return GUI_dialog_yesno_show_and_get_input_linebuttontext(m_Handle, m_Callbacks, heading, line0, line1, line2, bCanceled, noLabel, yesLabel); | 1174 | return m_Callbacks->Dialog_YesNo_ShowAndGetInputLineButtonText(heading, line0, line1, line2, bCanceled, noLabel, yesLabel); |
| 523 | } | 1175 | } |
| 524 | //@} | 1176 | //@} |
| 525 | 1177 | ||
| @@ -527,7 +1179,7 @@ public: | |||
| 527 | //@{ | 1179 | //@{ |
| 528 | void Dialog_TextViewer(const char *heading, const char *text) | 1180 | void Dialog_TextViewer(const char *heading, const char *text) |
| 529 | { | 1181 | { |
| 530 | return GUI_dialog_text_viewer(m_Handle, m_Callbacks, heading, text); | 1182 | return m_Callbacks->Dialog_TextViewer(heading, text); |
| 531 | } | 1183 | } |
| 532 | //@} | 1184 | //@} |
| 533 | 1185 | ||
| @@ -535,292 +1187,11 @@ public: | |||
| 535 | //@{ | 1187 | //@{ |
| 536 | int Dialog_Select(const char *heading, const char *entries[], unsigned int size, int selected = -1) | 1188 | int Dialog_Select(const char *heading, const char *entries[], unsigned int size, int selected = -1) |
| 537 | { | 1189 | { |
| 538 | return GUI_dialog_select(m_Handle, m_Callbacks, heading, entries, size, selected); | 1190 | return m_Callbacks->Dialog_Select(heading, entries, size, selected); |
| 539 | } | 1191 | } |
| 540 | //@} | 1192 | //@} |
| 541 | 1193 | ||
| 542 | protected: | ||
| 543 | void* (*GUI_register_me)(void *HANDLE); | ||
| 544 | void (*GUI_unregister_me)(void *HANDLE, void* CB); | ||
| 545 | void (*GUI_lock)(void *HANDLE, void* CB); | ||
| 546 | void (*GUI_unlock)(void *HANDLE, void* CB); | ||
| 547 | int (*GUI_get_screen_height)(void *HANDLE, void* CB); | ||
| 548 | int (*GUI_get_screen_width)(void *HANDLE, void* CB); | ||
| 549 | int (*GUI_get_video_resolution)(void *HANDLE, void* CB); | ||
| 550 | CAddonGUIWindow* (*GUI_Window_create)(void *HANDLE, void* CB, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog); | ||
| 551 | void (*GUI_Window_destroy)(CAddonGUIWindow* p); | ||
| 552 | CAddonGUISpinControl* (*GUI_control_get_spin)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); | ||
| 553 | void (*GUI_control_release_spin)(CAddonGUISpinControl* p); | ||
| 554 | CAddonGUIRadioButton* (*GUI_control_get_radiobutton)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); | ||
| 555 | void (*GUI_control_release_radiobutton)(CAddonGUIRadioButton* p); | ||
| 556 | CAddonGUIProgressControl* (*GUI_control_get_progress)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); | ||
| 557 | void (*GUI_control_release_progress)(CAddonGUIProgressControl* p); | ||
| 558 | CAddonListItem* (*GUI_ListItem_create)(void *HANDLE, void* CB, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path); | ||
| 559 | void (*GUI_ListItem_destroy)(CAddonListItem* p); | ||
| 560 | CAddonGUIRenderingControl* (*GUI_control_get_rendering)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); | ||
| 561 | void (*GUI_control_release_rendering)(CAddonGUIRenderingControl* p); | ||
| 562 | CAddonGUISliderControl* (*GUI_control_get_slider)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); | ||
| 563 | void (*GUI_control_release_slider)(CAddonGUISliderControl* p); | ||
| 564 | CAddonGUISettingsSliderControl* (*GUI_control_get_settings_slider)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); | ||
| 565 | void (*GUI_control_release_settings_slider)(CAddonGUISettingsSliderControl* p); | ||
| 566 | bool (*GUI_dialog_keyboard_show_and_get_input_with_head)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs); | ||
| 567 | bool (*GUI_dialog_keyboard_show_and_get_input)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs); | ||
| 568 | bool (*GUI_dialog_keyboard_show_and_get_new_password_with_head)(void *HANDLE, void *CB, char &newPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs); | ||
| 569 | bool (*GUI_dialog_keyboard_show_and_get_new_password)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); | ||
| 570 | bool (*GUI_dialog_keyboard_show_and_verify_new_password_with_head)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs); | ||
| 571 | bool (*GUI_dialog_keyboard_show_and_verify_new_password)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); | ||
| 572 | int (*GUI_dialog_keyboard_show_and_verify_password)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs); | ||
| 573 | bool (*GUI_dialog_keyboard_show_and_get_filter)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs); | ||
| 574 | bool (*GUI_dialog_keyboard_send_text_to_active_keyboard)(void *HANDLE, void *CB, const char *aTextString, bool closeKeyboard); | ||
| 575 | bool (*GUI_dialog_keyboard_is_activated)(void *HANDLE, void *CB); | ||
| 576 | bool (*GUI_dialog_numeric_show_and_verify_new_password)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize); | ||
| 577 | int (*GUI_dialog_numeric_show_and_verify_password)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries); | ||
| 578 | bool (*GUI_dialog_numeric_show_and_verify_input)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput); | ||
| 579 | bool (*GUI_dialog_numeric_show_and_get_time)(void *HANDLE, void *CB, tm &time, const char *strHeading); | ||
| 580 | bool (*GUI_dialog_numeric_show_and_get_date)(void *HANDLE, void *CB, tm &date, const char *strHeading); | ||
| 581 | bool (*GUI_dialog_numeric_show_and_get_ipaddress)(void *HANDLE, void *CB, char &IPAddress, unsigned int iMaxStringSize, const char *strHeading); | ||
| 582 | bool (*GUI_dialog_numeric_show_and_get_number)(void *HANDLE, void *CB, char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs); | ||
| 583 | bool (*GUI_dialog_numeric_show_and_get_seconds)(void *HANDLE, void *CB, char &strTime, unsigned int iMaxStringSize, const char *strHeading); | ||
| 584 | bool (*GUI_dialog_filebrowser_show_and_get_file)(void *HANDLE, void *CB, const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList); | ||
| 585 | void (*GUI_dialog_ok_show_and_get_input_single_text)(void *HANDLE, void *CB, const char *heading, const char *text); | ||
| 586 | void (*GUI_dialog_ok_show_and_get_input_line_text)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2); | ||
| 587 | bool (*GUI_dialog_yesno_show_and_get_input_singletext)(void *HANDLE, void *CB, const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel); | ||
| 588 | bool (*GUI_dialog_yesno_show_and_get_input_linetext)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel); | ||
| 589 | bool (*GUI_dialog_yesno_show_and_get_input_linebuttontext)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel); | ||
| 590 | void (*GUI_dialog_text_viewer)(void *hdl, void *cb, const char *heading, const char *text); | ||
| 591 | int (*GUI_dialog_select)(void *hdl, void *cb, const char *heading, const char *entries[], unsigned int size, int selected); | ||
| 592 | |||
| 593 | private: | ||
| 594 | void *m_libKODI_guilib; | ||
| 595 | void *m_Handle; | ||
| 596 | void *m_Callbacks; | ||
| 597 | struct cb_array | ||
| 598 | { | ||
| 599 | const char* libPath; | ||
| 600 | }; | ||
| 601 | }; | ||
| 602 | |||
| 603 | class CAddonGUISpinControl | ||
| 604 | { | ||
| 605 | public: | ||
| 606 | CAddonGUISpinControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); | ||
| 607 | virtual ~CAddonGUISpinControl(void) {} | ||
| 608 | |||
| 609 | virtual void SetVisible(bool yesNo); | ||
| 610 | virtual void SetText(const char *label); | ||
| 611 | virtual void Clear(); | ||
| 612 | virtual void AddLabel(const char *label, int iValue); | ||
| 613 | virtual int GetValue(); | ||
| 614 | virtual void SetValue(int iValue); | ||
| 615 | |||
| 616 | private: | ||
| 617 | CAddonGUIWindow *m_Window; | ||
| 618 | GUIHANDLE m_SpinHandle; | ||
| 619 | void *m_Handle; | ||
| 620 | void *m_cb; | ||
| 621 | }; | ||
| 622 | |||
| 623 | class CAddonGUIRadioButton | ||
| 624 | { | ||
| 625 | public: | ||
| 626 | CAddonGUIRadioButton(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); | ||
| 627 | virtual ~CAddonGUIRadioButton() {} | ||
| 628 | |||
| 629 | virtual void SetVisible(bool yesNo); | ||
| 630 | virtual void SetText(const char *label); | ||
| 631 | virtual void SetSelected(bool yesNo); | ||
| 632 | virtual bool IsSelected(); | ||
| 633 | |||
| 634 | private: | ||
| 635 | CAddonGUIWindow *m_Window; | ||
| 636 | GUIHANDLE m_ButtonHandle; | ||
| 637 | void *m_Handle; | ||
| 638 | void *m_cb; | ||
| 639 | }; | ||
| 640 | |||
| 641 | class CAddonGUIProgressControl | ||
| 642 | { | ||
| 643 | public: | ||
| 644 | CAddonGUIProgressControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); | ||
| 645 | virtual ~CAddonGUIProgressControl(void) {} | ||
| 646 | |||
| 647 | virtual void SetPercentage(float fPercent); | ||
| 648 | virtual float GetPercentage() const; | ||
| 649 | virtual void SetInfo(int iInfo); | ||
| 650 | virtual int GetInfo() const; | ||
| 651 | virtual std::string GetDescription() const; | ||
| 652 | |||
| 653 | private: | ||
| 654 | CAddonGUIWindow *m_Window; | ||
| 655 | GUIHANDLE m_ProgressHandle; | ||
| 656 | void *m_Handle; | ||
| 657 | void *m_cb; | ||
| 658 | }; | ||
| 659 | |||
| 660 | class CAddonGUISliderControl | ||
| 661 | { | ||
| 662 | public: | ||
| 663 | CAddonGUISliderControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); | ||
| 664 | virtual ~CAddonGUISliderControl(void) {} | ||
| 665 | |||
| 666 | virtual void SetVisible(bool yesNo); | ||
| 667 | virtual std::string GetDescription() const; | ||
| 668 | |||
| 669 | virtual void SetIntRange(int iStart, int iEnd); | ||
| 670 | virtual void SetIntValue(int iValue); | ||
| 671 | virtual int GetIntValue() const; | ||
| 672 | virtual void SetIntInterval(int iInterval); | ||
| 673 | |||
| 674 | virtual void SetPercentage(float fPercent); | ||
| 675 | virtual float GetPercentage() const; | ||
| 676 | |||
| 677 | virtual void SetFloatRange(float fStart, float fEnd); | ||
| 678 | virtual void SetFloatValue(float fValue); | ||
| 679 | virtual float GetFloatValue() const; | ||
| 680 | virtual void SetFloatInterval(float fInterval); | ||
| 681 | |||
| 682 | private: | ||
| 683 | CAddonGUIWindow *m_Window; | ||
| 684 | GUIHANDLE m_SliderHandle; | ||
| 685 | void *m_Handle; | ||
| 686 | void *m_cb; | ||
| 687 | }; | ||
| 688 | |||
| 689 | class CAddonGUISettingsSliderControl | ||
| 690 | { | ||
| 691 | public: | ||
| 692 | CAddonGUISettingsSliderControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); | ||
| 693 | virtual ~CAddonGUISettingsSliderControl(void) {} | ||
| 694 | |||
| 695 | virtual void SetVisible(bool yesNo); | ||
| 696 | virtual void SetText(const char *label); | ||
| 697 | virtual std::string GetDescription() const; | ||
| 698 | |||
| 699 | virtual void SetIntRange(int iStart, int iEnd); | ||
| 700 | virtual void SetIntValue(int iValue); | ||
| 701 | virtual int GetIntValue() const; | ||
| 702 | virtual void SetIntInterval(int iInterval); | ||
| 703 | |||
| 704 | virtual void SetPercentage(float fPercent); | ||
| 705 | virtual float GetPercentage() const; | ||
| 706 | |||
| 707 | virtual void SetFloatRange(float fStart, float fEnd); | ||
| 708 | virtual void SetFloatValue(float fValue); | ||
| 709 | virtual float GetFloatValue() const; | ||
| 710 | virtual void SetFloatInterval(float fInterval); | ||
| 711 | |||
| 712 | private: | ||
| 713 | CAddonGUIWindow *m_Window; | ||
| 714 | GUIHANDLE m_SettingsSliderHandle; | ||
| 715 | void *m_Handle; | ||
| 716 | void *m_cb; | ||
| 717 | }; | ||
| 718 | |||
| 719 | class CAddonListItem | ||
| 720 | { | ||
| 721 | friend class CAddonGUIWindow; | ||
| 722 | |||
| 723 | public: | ||
| 724 | CAddonListItem(void *hdl, void *cb, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path); | ||
| 725 | virtual ~CAddonListItem(void) {} | ||
| 726 | |||
| 727 | virtual const char *GetLabel(); | ||
| 728 | virtual void SetLabel(const char *label); | ||
| 729 | virtual const char *GetLabel2(); | ||
| 730 | virtual void SetLabel2(const char *label); | ||
| 731 | virtual void SetIconImage(const char *image); | ||
| 732 | virtual void SetThumbnailImage(const char *image); | ||
| 733 | virtual void SetInfo(const char *Info); | ||
| 734 | virtual void SetProperty(const char *key, const char *value); | ||
| 735 | virtual const char *GetProperty(const char *key) const; | ||
| 736 | virtual void SetPath(const char *Path); | ||
| 737 | |||
| 738 | // {(char*)"select(); | ||
| 739 | // {(char*)"isSelected(); | ||
| 740 | protected: | ||
| 741 | GUIHANDLE m_ListItemHandle; | ||
| 742 | void *m_Handle; | ||
| 743 | void *m_cb; | ||
| 744 | }; | ||
| 745 | |||
| 746 | class CAddonGUIWindow | ||
| 747 | { | ||
| 748 | friend class CAddonGUISpinControl; | ||
| 749 | friend class CAddonGUIRadioButton; | ||
| 750 | friend class CAddonGUIProgressControl; | ||
| 751 | friend class CAddonGUIRenderingControl; | ||
| 752 | friend class CAddonGUISliderControl; | ||
| 753 | friend class CAddonGUISettingsSliderControl; | ||
| 754 | |||
| 755 | public: | ||
| 756 | CAddonGUIWindow(void *hdl, void *cb, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog); | ||
| 757 | virtual ~CAddonGUIWindow(); | ||
| 758 | |||
| 759 | virtual bool Show(); | ||
| 760 | virtual void Close(); | ||
| 761 | virtual void DoModal(); | ||
| 762 | virtual bool SetFocusId(int iControlId); | ||
| 763 | virtual int GetFocusId(); | ||
| 764 | virtual bool SetCoordinateResolution(int res); | ||
| 765 | virtual void SetProperty(const char *key, const char *value); | ||
| 766 | virtual void SetPropertyInt(const char *key, int value); | ||
| 767 | virtual void SetPropertyBool(const char *key, bool value); | ||
| 768 | virtual void SetPropertyDouble(const char *key, double value); | ||
| 769 | virtual const char *GetProperty(const char *key) const; | ||
| 770 | virtual int GetPropertyInt(const char *key) const; | ||
| 771 | virtual bool GetPropertyBool(const char *key) const; | ||
| 772 | virtual double GetPropertyDouble(const char *key) const; | ||
| 773 | virtual void ClearProperties(); | ||
| 774 | virtual int GetListSize(); | ||
| 775 | virtual void ClearList(); | ||
| 776 | virtual GUIHANDLE AddStringItem(const char *name, int itemPosition = -1); | ||
| 777 | virtual void AddItem(GUIHANDLE item, int itemPosition = -1); | ||
| 778 | virtual void AddItem(CAddonListItem *item, int itemPosition = -1); | ||
| 779 | virtual void RemoveItem(int itemPosition); | ||
| 780 | virtual GUIHANDLE GetListItem(int listPos); | ||
| 781 | virtual void SetCurrentListPosition(int listPos); | ||
| 782 | virtual int GetCurrentListPosition(); | ||
| 783 | virtual void SetControlLabel(int controlId, const char *label); | ||
| 784 | virtual void MarkDirtyRegion(); | ||
| 785 | |||
| 786 | virtual bool OnClick(int controlId); | ||
| 787 | virtual bool OnFocus(int controlId); | ||
| 788 | virtual bool OnInit(); | ||
| 789 | virtual bool OnAction(int actionId); | ||
| 790 | |||
| 791 | GUIHANDLE m_cbhdl; | ||
| 792 | bool (*CBOnInit)(GUIHANDLE cbhdl); | ||
| 793 | bool (*CBOnFocus)(GUIHANDLE cbhdl, int controlId); | ||
| 794 | bool (*CBOnClick)(GUIHANDLE cbhdl, int controlId); | ||
| 795 | bool (*CBOnAction)(GUIHANDLE cbhdl, int actionId); | ||
| 796 | |||
| 797 | protected: | ||
| 798 | GUIHANDLE m_WindowHandle; | ||
| 799 | void *m_Handle; | ||
| 800 | void *m_cb; | ||
| 801 | }; | ||
| 802 | |||
| 803 | class CAddonGUIRenderingControl | ||
| 804 | { | ||
| 805 | public: | ||
| 806 | CAddonGUIRenderingControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); | ||
| 807 | virtual ~CAddonGUIRenderingControl(); | ||
| 808 | virtual void Init(); | ||
| 809 | |||
| 810 | virtual bool Create(int x, int y, int w, int h, void *device); | ||
| 811 | virtual void Render(); | ||
| 812 | virtual void Stop(); | ||
| 813 | virtual bool Dirty(); | ||
| 814 | |||
| 815 | GUIHANDLE m_cbhdl; | ||
| 816 | bool (*CBCreate)(GUIHANDLE cbhdl, int x, int y, int w, int h, void *device); | ||
| 817 | void (*CBRender)(GUIHANDLE cbhdl); | ||
| 818 | void (*CBStop)(GUIHANDLE cbhdl); | ||
| 819 | bool (*CBDirty)(GUIHANDLE cbhdl); | ||
| 820 | |||
| 821 | private: | 1194 | private: |
| 822 | CAddonGUIWindow *m_Window; | 1195 | AddonCB* m_Handle; |
| 823 | GUIHANDLE m_RenderingHandle; | 1196 | KodiAPI::GUI::CB_GUILib* m_Callbacks; |
| 824 | void *m_Handle; | ||
| 825 | void *m_cb; | ||
| 826 | }; | 1197 | }; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h index c55a42b..d37d24e 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h | |||
| @@ -25,7 +25,9 @@ | |||
| 25 | #include <string.h> | 25 | #include <string.h> |
| 26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
| 27 | #include <stdio.h> | 27 | #include <stdio.h> |
| 28 | #include "libXBMC_addon.h" | 28 | |
| 29 | #include "kodi_inputstream_types.h" | ||
| 30 | #include "versions.h" | ||
| 29 | 31 | ||
| 30 | #ifdef BUILD_KODI_ADDON | 32 | #ifdef BUILD_KODI_ADDON |
| 31 | #include "DVDDemuxPacket.h" | 33 | #include "DVDDemuxPacket.h" |
| @@ -33,26 +35,6 @@ | |||
| 33 | #include "cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h" | 35 | #include "cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h" |
| 34 | #endif | 36 | #endif |
| 35 | 37 | ||
| 36 | /* current input stream API version */ | ||
| 37 | #define KODI_INPUTSTREAM_API_VERSION "1.0.0" | ||
| 38 | |||
| 39 | namespace KodiAPI | ||
| 40 | { | ||
| 41 | namespace V1 | ||
| 42 | { | ||
| 43 | namespace InputStream | ||
| 44 | { | ||
| 45 | |||
| 46 | typedef struct CB_INPUTSTREAMLib | ||
| 47 | { | ||
| 48 | void (*FreeDemuxPacket)(void *addonData, DemuxPacket* pPacket); | ||
| 49 | DemuxPacket* (*AllocateDemuxPacket)(void *addonData, int iDataSize); | ||
| 50 | } CB_INPUTSTREAMLib; | ||
| 51 | |||
| 52 | } /* namespace InputStream */ | ||
| 53 | } /* namespace V1 */ | ||
| 54 | } /* namespace KodiAPI */ | ||
| 55 | |||
| 56 | class CHelper_libKODI_inputstream | 38 | class CHelper_libKODI_inputstream |
| 57 | { | 39 | { |
| 58 | public: | 40 | public: |
| @@ -64,10 +46,6 @@ public: | |||
| 64 | 46 | ||
| 65 | ~CHelper_libKODI_inputstream(void) | 47 | ~CHelper_libKODI_inputstream(void) |
| 66 | { | 48 | { |
| 67 | if (m_Handle && m_Callbacks) | ||
| 68 | { | ||
| 69 | m_Handle->INPUTSTREAMLib_UnRegisterMe(m_Handle->addonData, m_Callbacks); | ||
| 70 | } | ||
| 71 | } | 49 | } |
| 72 | 50 | ||
| 73 | /*! | 51 | /*! |
| @@ -79,7 +57,7 @@ public: | |||
| 79 | { | 57 | { |
| 80 | m_Handle = static_cast<AddonCB*>(handle); | 58 | m_Handle = static_cast<AddonCB*>(handle); |
| 81 | if (m_Handle) | 59 | if (m_Handle) |
| 82 | m_Callbacks = (KodiAPI::V1::InputStream::CB_INPUTSTREAMLib*)m_Handle->INPUTSTREAMLib_RegisterMe(m_Handle->addonData); | 60 | m_Callbacks = (AddonInstance_InputStream*)m_Handle->INPUTSTREAMLib_RegisterMe(m_Handle->addonData); |
| 83 | if (!m_Callbacks) | 61 | if (!m_Callbacks) |
| 84 | fprintf(stderr, "libKODI_inputstream-ERROR: InputStream_RegisterMe can't get callback table from Kodi !!!\n"); | 62 | fprintf(stderr, "libKODI_inputstream-ERROR: InputStream_RegisterMe can't get callback table from Kodi !!!\n"); |
| 85 | 63 | ||
| @@ -93,7 +71,7 @@ public: | |||
| 93 | */ | 71 | */ |
| 94 | DemuxPacket* AllocateDemuxPacket(int iDataSize) | 72 | DemuxPacket* AllocateDemuxPacket(int iDataSize) |
| 95 | { | 73 | { |
| 96 | return m_Callbacks->AllocateDemuxPacket(m_Handle->addonData, iDataSize); | 74 | return m_Callbacks->toKodi.AllocateDemuxPacket(m_Callbacks->toKodi.kodiInstance, iDataSize); |
| 97 | } | 75 | } |
| 98 | 76 | ||
| 99 | /*! | 77 | /*! |
| @@ -102,10 +80,10 @@ public: | |||
| 102 | */ | 80 | */ |
| 103 | void FreeDemuxPacket(DemuxPacket* pPacket) | 81 | void FreeDemuxPacket(DemuxPacket* pPacket) |
| 104 | { | 82 | { |
| 105 | return m_Callbacks->FreeDemuxPacket(m_Handle->addonData, pPacket); | 83 | return m_Callbacks->toKodi.FreeDemuxPacket(m_Callbacks->toKodi.kodiInstance, pPacket); |
| 106 | } | 84 | } |
| 107 | 85 | ||
| 108 | private: | 86 | private: |
| 109 | AddonCB* m_Handle; | 87 | AddonCB* m_Handle; |
| 110 | KodiAPI::V1::InputStream::CB_INPUTSTREAMLib* m_Callbacks; | 88 | AddonInstance_InputStream* m_Callbacks; |
| 111 | }; | 89 | }; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h index a28e48d..d1d8e4b 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2014-2016 Team Kodi | 2 | * Copyright (C) 2014-2017 Team Kodi |
| 3 | * http://kodi.tv | 3 | * http://kodi.tv |
| 4 | * | 4 | * |
| 5 | * This Program is free software; you can redistribute it and/or modify | 5 | * This Program is free software; you can redistribute it and/or modify |
| @@ -20,7 +20,7 @@ | |||
| 20 | #pragma once | 20 | #pragma once |
| 21 | 21 | ||
| 22 | #include "libXBMC_addon.h" | 22 | #include "libXBMC_addon.h" |
| 23 | #include "kodi_peripheral_callbacks.h" | 23 | #include "kodi_peripheral_types.h" |
| 24 | 24 | ||
| 25 | #include <string> | 25 | #include <string> |
| 26 | #include <stdio.h> | 26 | #include <stdio.h> |
| @@ -29,16 +29,6 @@ | |||
| 29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | #ifdef _WIN32 | ||
| 33 | #define PERIPHERAL_HELPER_DLL "\\library.kodi.peripheral\\libKODI_peripheral" ADDON_HELPER_EXT | ||
| 34 | #else | ||
| 35 | #define PERIPHERAL_HELPER_DLL_NAME "libKODI_peripheral-" ADDON_HELPER_ARCH ADDON_HELPER_EXT | ||
| 36 | #define PERIPHERAL_HELPER_DLL "/library.kodi.peripheral/" PERIPHERAL_HELPER_DLL_NAME | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #define PERIPHERAL_REGISTER_SYMBOL(dll, functionPtr) \ | ||
| 40 | CHelper_libKODI_peripheral::RegisterSymbol(dll, functionPtr, #functionPtr) | ||
| 41 | |||
| 42 | namespace ADDON | 32 | namespace ADDON |
| 43 | { | 33 | { |
| 44 | 34 | ||
| @@ -47,29 +37,12 @@ class CHelper_libKODI_peripheral | |||
| 47 | public: | 37 | public: |
| 48 | CHelper_libKODI_peripheral(void) | 38 | CHelper_libKODI_peripheral(void) |
| 49 | { | 39 | { |
| 50 | m_handle = NULL; | 40 | m_Handle = nullptr; |
| 51 | m_callbacks = NULL; | 41 | m_Callbacks = nullptr; |
| 52 | m_libKODI_peripheral = NULL; | ||
| 53 | } | 42 | } |
| 54 | 43 | ||
| 55 | ~CHelper_libKODI_peripheral(void) | 44 | ~CHelper_libKODI_peripheral(void) |
| 56 | { | 45 | { |
| 57 | if (m_libKODI_peripheral) | ||
| 58 | { | ||
| 59 | PERIPHERAL_unregister_me(m_handle, m_callbacks); | ||
| 60 | dlclose(m_libKODI_peripheral); | ||
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 | template <typename T> | ||
| 65 | static bool RegisterSymbol(void* dll, T& functionPtr, const char* strFunctionPtr) | ||
| 66 | { | ||
| 67 | if ((functionPtr = (T)dlsym(dll, strFunctionPtr)) == NULL) | ||
| 68 | { | ||
| 69 | fprintf(stderr, "ERROR: Unable to assign function %s: %s\n", strFunctionPtr, dlerror()); | ||
| 70 | return false; | ||
| 71 | } | ||
| 72 | return true; | ||
| 73 | } | 46 | } |
| 74 | 47 | ||
| 75 | /*! | 48 | /*! |
| @@ -79,69 +52,52 @@ public: | |||
| 79 | */ | 52 | */ |
| 80 | bool RegisterMe(void* handle) | 53 | bool RegisterMe(void* handle) |
| 81 | { | 54 | { |
| 82 | m_handle = handle; | 55 | m_Handle = static_cast<AddonCB*>(handle); |
| 83 | 56 | if (m_Handle) | |
| 84 | std::string libBasePath; | 57 | m_Callbacks = (AddonInstance_Peripheral*)m_Handle->PeripheralLib_RegisterMe(m_Handle->addonData); |
| 85 | libBasePath = ((cb_array*)m_handle)->libPath; | 58 | if (!m_Callbacks) |
| 86 | libBasePath += PERIPHERAL_HELPER_DLL; | 59 | fprintf(stderr, "libKODI_peripheral-ERROR: PeripheralLib_register_me can't get callback table from Kodi !!!\n"); |
| 87 | |||
| 88 | #if defined(ANDROID) | ||
| 89 | struct stat st; | ||
| 90 | if (stat(libBasePath.c_str(),&st) != 0) | ||
| 91 | { | ||
| 92 | std::string tempbin = getenv("XBMC_ANDROID_LIBS"); | ||
| 93 | libBasePath = tempbin + "/" + PERIPHERAL_HELPER_DLL_NAME; | ||
| 94 | } | ||
| 95 | #endif | ||
| 96 | |||
| 97 | m_libKODI_peripheral = dlopen(libBasePath.c_str(), RTLD_LAZY); | ||
| 98 | if (m_libKODI_peripheral == NULL) | ||
| 99 | { | ||
| 100 | fprintf(stderr, "Unable to load %s\n", dlerror()); | ||
| 101 | return false; | ||
| 102 | } | ||
| 103 | |||
| 104 | if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_register_me)) return false; | ||
| 105 | if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_unregister_me)) return false; | ||
| 106 | if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_trigger_scan)) return false; | ||
| 107 | if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_refresh_button_maps)) return false; | ||
| 108 | if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_feature_count)) return false; | ||
| 109 | 60 | ||
| 110 | m_callbacks = PERIPHERAL_register_me(m_handle); | 61 | return m_Callbacks != nullptr; |
| 111 | return m_callbacks != NULL; | ||
| 112 | } | 62 | } |
| 113 | 63 | ||
| 64 | /*! | ||
| 65 | * @brief Trigger a scan for peripherals | ||
| 66 | * | ||
| 67 | * The add-on calls this if a change in hardware is detected. | ||
| 68 | */ | ||
| 114 | void TriggerScan(void) | 69 | void TriggerScan(void) |
| 115 | { | 70 | { |
| 116 | return PERIPHERAL_trigger_scan(m_handle, m_callbacks); | 71 | return m_Callbacks->toKodi.TriggerScan(m_Callbacks->toKodi.kodiInstance); |
| 117 | } | 72 | } |
| 118 | 73 | ||
| 74 | /*! | ||
| 75 | * @brief Notify the frontend that button maps have changed | ||
| 76 | * | ||
| 77 | * @param[optional] deviceName The name of the device to refresh, or empty/null for all devices | ||
| 78 | * @param[optional] controllerId The controller ID to refresh, or empty/null for all controllers | ||
| 79 | */ | ||
| 119 | void RefreshButtonMaps(const std::string& strDeviceName = "", const std::string& strControllerId = "") | 80 | void RefreshButtonMaps(const std::string& strDeviceName = "", const std::string& strControllerId = "") |
| 120 | { | 81 | { |
| 121 | return PERIPHERAL_refresh_button_maps(m_handle, m_callbacks, strDeviceName.c_str(), strControllerId.c_str()); | 82 | return m_Callbacks->toKodi.RefreshButtonMaps(m_Callbacks->toKodi.kodiInstance, strDeviceName.c_str(), strControllerId.c_str()); |
| 122 | } | 83 | } |
| 123 | 84 | ||
| 85 | /*! | ||
| 86 | * @brief Return the number of features belonging to the specified controller | ||
| 87 | * | ||
| 88 | * @param controllerId The controller ID to enumerate | ||
| 89 | * @param type[optional] Type to filter by, or JOYSTICK_FEATURE_TYPE_UNKNOWN for all features | ||
| 90 | * | ||
| 91 | * @return The number of features matching the request parameters | ||
| 92 | */ | ||
| 124 | unsigned int FeatureCount(const std::string& strControllerId, JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN) | 93 | unsigned int FeatureCount(const std::string& strControllerId, JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN) |
| 125 | { | 94 | { |
| 126 | return PERIPHERAL_feature_count(m_handle, m_callbacks, strControllerId.c_str(), type); | 95 | return m_Callbacks->toKodi.FeatureCount(m_Callbacks->toKodi.kodiInstance, strControllerId.c_str(), type); |
| 127 | } | 96 | } |
| 128 | 97 | ||
| 129 | protected: | ||
| 130 | CB_PeripheralLib* (*PERIPHERAL_register_me)(void* handle); | ||
| 131 | void (*PERIPHERAL_unregister_me)(void* handle, CB_PeripheralLib* cb); | ||
| 132 | void (*PERIPHERAL_trigger_scan)(void* handle, CB_PeripheralLib* cb); | ||
| 133 | void (*PERIPHERAL_refresh_button_maps)(void* handle, CB_PeripheralLib* cb, const char* deviceName, const char* controllerId); | ||
| 134 | unsigned int (*PERIPHERAL_feature_count)(void* handle, CB_PeripheralLib* cb, const char* controllerId, JOYSTICK_FEATURE_TYPE type); | ||
| 135 | |||
| 136 | private: | 98 | private: |
| 137 | void* m_handle; | 99 | AddonCB* m_Handle; |
| 138 | CB_PeripheralLib* m_callbacks; | 100 | AddonInstance_Peripheral* m_Callbacks; |
| 139 | void* m_libKODI_peripheral; | ||
| 140 | |||
| 141 | struct cb_array | ||
| 142 | { | ||
| 143 | const char* libPath; | ||
| 144 | }; | ||
| 145 | }; | 101 | }; |
| 146 | 102 | ||
| 147 | } | 103 | } /* namespace ADDON */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h index d9f72c1..8b02e33 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <stdint.h> | 27 | #include <stdint.h> |
| 28 | #include <stdarg.h> | 28 | #include <stdarg.h> |
| 29 | 29 | ||
| 30 | #include "versions.h" | ||
| 30 | #if defined(BUILD_KODI_ADDON) | 31 | #if defined(BUILD_KODI_ADDON) |
| 31 | #include "IFileTypes.h" | 32 | #include "IFileTypes.h" |
| 32 | #else | 33 | #else |
| @@ -44,62 +45,11 @@ typedef intptr_t ssize_t; | |||
| 44 | 45 | ||
| 45 | #if defined(BUILD_KODI_ADDON) | 46 | #if defined(BUILD_KODI_ADDON) |
| 46 | #include "p8-platform/windows/dlfcn-win32.h" | 47 | #include "p8-platform/windows/dlfcn-win32.h" |
| 47 | #else | ||
| 48 | #include "dlfcn-win32.h" | ||
| 49 | #endif | 48 | #endif |
| 50 | |||
| 51 | #define ADDON_HELPER_EXT ".dll" | ||
| 52 | #define ADDON_HELPER_PATHSEP "\\" | ||
| 53 | #define ADDON_HELPER_ARCHSEP "" | ||
| 54 | #define ADDON_HELPER_ARCH "" | ||
| 55 | |||
| 56 | #else // windows | 49 | #else // windows |
| 57 | #define ADDON_HELPER_PATHSEP "/" | ||
| 58 | #define ADDON_HELPER_ARCHSEP "-" | ||
| 59 | // the ADDON_HELPER_ARCH is the platform dependend name which is used | ||
| 60 | // as part of the name of dynamic addon libraries. It has to match the | ||
| 61 | // strings which are set in configure.ac for the "ARCH" variable. | ||
| 62 | #if defined(__APPLE__) // osx | ||
| 63 | #if defined(__arm__) || defined(__aarch64__) | ||
| 64 | #define ADDON_HELPER_ARCH "arm-osx" | ||
| 65 | #else | ||
| 66 | #define ADDON_HELPER_ARCH "x86-osx" | ||
| 67 | #endif | ||
| 68 | #define ADDON_HELPER_EXT ".dylib" | ||
| 69 | #else // linux | ||
| 70 | #if defined(__x86_64__) | ||
| 71 | #define ADDON_HELPER_ARCH "x86_64-linux" | ||
| 72 | #elif defined(_POWERPC) | ||
| 73 | #define ADDON_HELPER_ARCH "powerpc-linux" | ||
| 74 | #elif defined(_POWERPC64) | ||
| 75 | #define ADDON_HELPER_ARCH "powerpc64-linux" | ||
| 76 | #elif defined(__ARMEL__) | ||
| 77 | #define ADDON_HELPER_ARCH "arm" | ||
| 78 | #elif defined(__aarch64__) | ||
| 79 | #define ADDON_HELPER_ARCH "aarch64" | ||
| 80 | #elif defined(__mips__) | ||
| 81 | #define ADDON_HELPER_ARCH "mips" | ||
| 82 | #else | ||
| 83 | #define ADDON_HELPER_ARCH "i486-linux" | ||
| 84 | #endif | ||
| 85 | #define ADDON_HELPER_EXT ".so" | ||
| 86 | #endif | ||
| 87 | #include <dlfcn.h> // linux+osx | 50 | #include <dlfcn.h> // linux+osx |
| 88 | #endif | 51 | #endif |
| 89 | 52 | ||
| 90 | #define KODI_DLL_NAME(name) "libKODI_" name ADDON_HELPER_ARCHSEP ADDON_HELPER_ARCH ADDON_HELPER_EXT | ||
| 91 | #define XBMC_DLL_NAME(name) "libXBMC_" name ADDON_HELPER_ARCHSEP ADDON_HELPER_ARCH ADDON_HELPER_EXT | ||
| 92 | #if defined(ANDROID) | ||
| 93 | #define KODI_DLL(name) ADDON_HELPER_PATHSEP KODI_DLL_NAME(name) | ||
| 94 | #define XBMC_DLL(name) ADDON_HELPER_PATHSEP XBMC_DLL_NAME(name) | ||
| 95 | #else | ||
| 96 | #define KODI_DLL(name) ADDON_HELPER_PATHSEP "library.kodi." name ADDON_HELPER_PATHSEP KODI_DLL_NAME(name) | ||
| 97 | #define XBMC_DLL(name) ADDON_HELPER_PATHSEP "library.xbmc." name ADDON_HELPER_PATHSEP XBMC_DLL_NAME(name) | ||
| 98 | #endif | ||
| 99 | |||
| 100 | #define ADDON_DLL_NAME XBMC_DLL_NAME("addon") | ||
| 101 | #define ADDON_DLL XBMC_DLL("addon") | ||
| 102 | |||
| 103 | #ifdef LOG_DEBUG | 53 | #ifdef LOG_DEBUG |
| 104 | #undef LOG_DEBUG | 54 | #undef LOG_DEBUG |
| 105 | #endif | 55 | #endif |
| @@ -113,9 +63,6 @@ typedef intptr_t ssize_t; | |||
| 113 | #undef LOG_ERROR | 63 | #undef LOG_ERROR |
| 114 | #endif | 64 | #endif |
| 115 | 65 | ||
| 116 | /* current addon API version */ | ||
| 117 | #define KODI_ADDON_API_VERSION "1.0.0" | ||
| 118 | |||
| 119 | typedef void* (*KODIAddOnLib_RegisterMe)(void *addonData); | 66 | typedef void* (*KODIAddOnLib_RegisterMe)(void *addonData); |
| 120 | typedef void (*KODIAddOnLib_UnRegisterMe)(void *addonData, void *cbTable); | 67 | typedef void (*KODIAddOnLib_UnRegisterMe)(void *addonData, void *cbTable); |
| 121 | typedef void* (*KODIAudioEngineLib_RegisterMe)(void *addonData); | 68 | typedef void* (*KODIAudioEngineLib_RegisterMe)(void *addonData); |
| @@ -175,186 +122,82 @@ namespace ADDON | |||
| 175 | QUEUE_WARNING, | 122 | QUEUE_WARNING, |
| 176 | QUEUE_ERROR | 123 | QUEUE_ERROR |
| 177 | } queue_msg_t; | 124 | } queue_msg_t; |
| 125 | } | ||
| 126 | |||
| 127 | namespace KodiAPI | ||
| 128 | { | ||
| 129 | namespace AddOn | ||
| 130 | { | ||
| 131 | typedef struct CB_AddOn | ||
| 132 | { | ||
| 133 | void (*Log)(void *addonData, const ADDON::addon_log_t loglevel, const char *msg); | ||
| 134 | void (*QueueNotification)(void *addonData, const ADDON::queue_msg_t type, const char *msg); | ||
| 135 | bool (*WakeOnLan)(const char* mac); | ||
| 136 | bool (*GetSetting)(void *addonData, const char *settingName, void *settingValue); | ||
| 137 | char* (*TranslateSpecialProtocol)(const char *strSource); | ||
| 138 | char* (*UnknownToUTF8)(const char *sourceDest); | ||
| 139 | char* (*GetLocalizedString)(const void* addonData, long dwCode); | ||
| 140 | char* (*GetDVDMenuLanguage)(const void* addonData); | ||
| 141 | void (*FreeString)(const void* addonData, char* str); | ||
| 142 | |||
| 143 | void* (*OpenFile)(const void* addonData, const char* strFileName, unsigned int flags); | ||
| 144 | void* (*OpenFileForWrite)(const void* addonData, const char* strFileName, bool bOverWrite); | ||
| 145 | ssize_t (*ReadFile)(const void* addonData, void* file, void* lpBuf, size_t uiBufSize); | ||
| 146 | bool (*ReadFileString)(const void* addonData, void* file, char *szLine, int iLineLength); | ||
| 147 | ssize_t (*WriteFile)(const void* addonData, void* file, const void* lpBuf, size_t uiBufSize); | ||
| 148 | void (*FlushFile)(const void* addonData, void* file); | ||
| 149 | int64_t (*SeekFile)(const void* addonData, void* file, int64_t iFilePosition, int iWhence); | ||
| 150 | int (*TruncateFile)(const void* addonData, void* file, int64_t iSize); | ||
| 151 | int64_t (*GetFilePosition)(const void* addonData, void* file); | ||
| 152 | int64_t (*GetFileLength)(const void* addonData, void* file); | ||
| 153 | double (*GetFileDownloadSpeed)(const void* addonData, void* file); | ||
| 154 | void (*CloseFile)(const void* addonData, void* file); | ||
| 155 | int (*GetFileChunkSize)(const void* addonData, void* file); | ||
| 156 | bool (*FileExists)(const void* addonData, const char *strFileName, bool bUseCache); | ||
| 157 | int (*StatFile)(const void* addonData, const char *strFileName, struct __stat64* buffer); | ||
| 158 | bool (*DeleteFile)(const void* addonData, const char *strFileName); | ||
| 159 | bool (*CanOpenDirectory)(const void* addonData, const char* strURL); | ||
| 160 | bool (*CreateDirectory)(const void* addonData, const char *strPath); | ||
| 161 | bool (*DirectoryExists)(const void* addonData, const char *strPath); | ||
| 162 | bool (*RemoveDirectory)(const void* addonData, const char *strPath); | ||
| 163 | bool (*GetDirectory)(const void* addonData, const char *strPath, const char* mask, VFSDirEntry** items, unsigned int* num_items); | ||
| 164 | void (*FreeDirectory)(const void* addonData, VFSDirEntry* items, unsigned int num_items); | ||
| 165 | void* (*CURLCreate)(const void* addonData, const char* strURL); | ||
| 166 | bool (*CURLAddOption)(const void* addonData, void* file, XFILE::CURLOPTIONTYPE type, const char* name, const char * value); | ||
| 167 | bool (*CURLOpen)(const void* addonData, void* file, unsigned int flags); | ||
| 168 | } CB_AddOnLib; | ||
| 169 | |||
| 170 | } /* namespace AddOn */ | ||
| 171 | } /* namespace KodiAPI */ | ||
| 178 | 172 | ||
| 173 | namespace ADDON | ||
| 174 | { | ||
| 179 | class CHelper_libXBMC_addon | 175 | class CHelper_libXBMC_addon |
| 180 | { | 176 | { |
| 181 | public: | 177 | public: |
| 182 | CHelper_libXBMC_addon() | 178 | CHelper_libXBMC_addon() |
| 183 | { | 179 | { |
| 184 | m_libXBMC_addon = NULL; | 180 | m_Handle = nullptr; |
| 185 | m_Handle = NULL; | 181 | m_Callbacks = nullptr; |
| 186 | } | 182 | } |
| 187 | 183 | ||
| 188 | ~CHelper_libXBMC_addon() | 184 | ~CHelper_libXBMC_addon() |
| 189 | { | 185 | { |
| 190 | if (m_libXBMC_addon) | 186 | if (m_Handle && m_Callbacks) |
| 191 | { | 187 | { |
| 192 | XBMC_unregister_me(m_Handle, m_Callbacks); | 188 | m_Handle->AddOnLib_UnRegisterMe(m_Handle->addonData, m_Callbacks); |
| 193 | dlclose(m_libXBMC_addon); | ||
| 194 | } | 189 | } |
| 195 | } | 190 | } |
| 196 | 191 | ||
| 197 | bool RegisterMe(void *Handle) | 192 | bool RegisterMe(void *handle) |
| 198 | { | 193 | { |
| 199 | m_Handle = Handle; | 194 | m_Handle = static_cast<AddonCB*>(handle); |
| 200 | 195 | if (m_Handle) | |
| 201 | std::string libBasePath; | 196 | m_Callbacks = (KodiAPI::AddOn::CB_AddOnLib*)m_Handle->AddOnLib_RegisterMe(m_Handle->addonData); |
| 202 | libBasePath = ((cb_array*)m_Handle)->libPath; | 197 | if (!m_Callbacks) |
| 203 | libBasePath += ADDON_DLL; | 198 | fprintf(stderr, "libXBMC_addon-ERROR: AddOnLib_RegisterMe can't get callback table from Kodi !!!\n"); |
| 204 | 199 | ||
| 205 | m_libXBMC_addon = dlopen(libBasePath.c_str(), RTLD_LAZY); | 200 | return m_Callbacks != nullptr; |
| 206 | if (m_libXBMC_addon == NULL) | ||
| 207 | { | ||
| 208 | fprintf(stderr, "Unable to load %s\n", dlerror()); | ||
| 209 | return false; | ||
| 210 | } | ||
| 211 | |||
| 212 | XBMC_register_me = (void* (*)(void *HANDLE)) | ||
| 213 | dlsym(m_libXBMC_addon, "XBMC_register_me"); | ||
| 214 | if (XBMC_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 215 | |||
| 216 | XBMC_unregister_me = (void (*)(void* HANDLE, void* CB)) | ||
| 217 | dlsym(m_libXBMC_addon, "XBMC_unregister_me"); | ||
| 218 | if (XBMC_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 219 | |||
| 220 | XBMC_log = (void (*)(void* HANDLE, void* CB, const addon_log_t loglevel, const char *msg)) | ||
| 221 | dlsym(m_libXBMC_addon, "XBMC_log"); | ||
| 222 | if (XBMC_log == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 223 | |||
| 224 | XBMC_get_setting = (bool (*)(void* HANDLE, void* CB, const char* settingName, void *settingValue)) | ||
| 225 | dlsym(m_libXBMC_addon, "XBMC_get_setting"); | ||
| 226 | if (XBMC_get_setting == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 227 | |||
| 228 | XBMC_translate_special = (char* (*)(void* HANDLE, void* CB, const char* source)) | ||
| 229 | dlsym(m_libXBMC_addon, "XBMC_translate_special"); | ||
| 230 | if (XBMC_translate_special == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 231 | |||
| 232 | XBMC_queue_notification = (void (*)(void* HANDLE, void* CB, const queue_msg_t loglevel, const char *msg)) | ||
| 233 | dlsym(m_libXBMC_addon, "XBMC_queue_notification"); | ||
| 234 | if (XBMC_queue_notification == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 235 | |||
| 236 | XBMC_wake_on_lan = (bool (*)(void* HANDLE, void *CB, const char *mac)) | ||
| 237 | dlsym(m_libXBMC_addon, "XBMC_wake_on_lan"); | ||
| 238 | if (XBMC_wake_on_lan == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 239 | |||
| 240 | XBMC_unknown_to_utf8 = (char* (*)(void* HANDLE, void* CB, const char* str)) | ||
| 241 | dlsym(m_libXBMC_addon, "XBMC_unknown_to_utf8"); | ||
| 242 | if (XBMC_unknown_to_utf8 == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 243 | |||
| 244 | XBMC_get_localized_string = (char* (*)(void* HANDLE, void* CB, int dwCode)) | ||
| 245 | dlsym(m_libXBMC_addon, "XBMC_get_localized_string"); | ||
| 246 | if (XBMC_get_localized_string == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 247 | |||
| 248 | XBMC_free_string = (void (*)(void* HANDLE, void* CB, char* str)) | ||
| 249 | dlsym(m_libXBMC_addon, "XBMC_free_string"); | ||
| 250 | if (XBMC_free_string == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 251 | |||
| 252 | XBMC_get_dvd_menu_language = (char* (*)(void* HANDLE, void* CB)) | ||
| 253 | dlsym(m_libXBMC_addon, "XBMC_get_dvd_menu_language"); | ||
| 254 | if (XBMC_get_dvd_menu_language == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 255 | |||
| 256 | XBMC_open_file = (void* (*)(void* HANDLE, void* CB, const char* strFileName, unsigned int flags)) | ||
| 257 | dlsym(m_libXBMC_addon, "XBMC_open_file"); | ||
| 258 | if (XBMC_open_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 259 | |||
| 260 | XBMC_open_file_for_write = (void* (*)(void* HANDLE, void* CB, const char* strFileName, bool bOverWrite)) | ||
| 261 | dlsym(m_libXBMC_addon, "XBMC_open_file_for_write"); | ||
| 262 | if (XBMC_open_file_for_write == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 263 | |||
| 264 | XBMC_read_file = (ssize_t (*)(void* HANDLE, void* CB, void* file, void* lpBuf, size_t uiBufSize)) | ||
| 265 | dlsym(m_libXBMC_addon, "XBMC_read_file"); | ||
| 266 | if (XBMC_read_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 267 | |||
| 268 | XBMC_read_file_string = (bool (*)(void* HANDLE, void* CB, void* file, char *szLine, int iLineLength)) | ||
| 269 | dlsym(m_libXBMC_addon, "XBMC_read_file_string"); | ||
| 270 | if (XBMC_read_file_string == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 271 | |||
| 272 | XBMC_write_file = (ssize_t (*)(void* HANDLE, void* CB, void* file, const void* lpBuf, size_t uiBufSize)) | ||
| 273 | dlsym(m_libXBMC_addon, "XBMC_write_file"); | ||
| 274 | if (XBMC_write_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 275 | |||
| 276 | XBMC_flush_file = (void (*)(void* HANDLE, void* CB, void* file)) | ||
| 277 | dlsym(m_libXBMC_addon, "XBMC_flush_file"); | ||
| 278 | if (XBMC_flush_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 279 | |||
| 280 | XBMC_seek_file = (int64_t (*)(void* HANDLE, void* CB, void* file, int64_t iFilePosition, int iWhence)) | ||
| 281 | dlsym(m_libXBMC_addon, "XBMC_seek_file"); | ||
| 282 | if (XBMC_seek_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 283 | |||
| 284 | XBMC_truncate_file = (int (*)(void* HANDLE, void* CB, void* file, int64_t iSize)) | ||
| 285 | dlsym(m_libXBMC_addon, "XBMC_truncate_file"); | ||
| 286 | if (XBMC_truncate_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 287 | |||
| 288 | XBMC_get_file_position = (int64_t (*)(void* HANDLE, void* CB, void* file)) | ||
| 289 | dlsym(m_libXBMC_addon, "XBMC_get_file_position"); | ||
| 290 | if (XBMC_get_file_position == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 291 | |||
| 292 | XBMC_get_file_length = (int64_t (*)(void* HANDLE, void* CB, void* file)) | ||
| 293 | dlsym(m_libXBMC_addon, "XBMC_get_file_length"); | ||
| 294 | if (XBMC_get_file_length == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 295 | |||
| 296 | XBMC_get_file_download_speed = (double(*)(void* HANDLE, void* CB, void* file)) | ||
| 297 | dlsym(m_libXBMC_addon, "XBMC_get_file_download_speed"); | ||
| 298 | if (XBMC_get_file_download_speed == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 299 | |||
| 300 | XBMC_close_file = (void (*)(void* HANDLE, void* CB, void* file)) | ||
| 301 | dlsym(m_libXBMC_addon, "XBMC_close_file"); | ||
| 302 | if (XBMC_close_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 303 | |||
| 304 | XBMC_get_file_chunk_size = (int (*)(void* HANDLE, void* CB, void* file)) | ||
| 305 | dlsym(m_libXBMC_addon, "XBMC_get_file_chunk_size"); | ||
| 306 | if (XBMC_get_file_chunk_size == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 307 | |||
| 308 | XBMC_file_exists = (bool (*)(void* HANDLE, void* CB, const char *strFileName, bool bUseCache)) | ||
| 309 | dlsym(m_libXBMC_addon, "XBMC_file_exists"); | ||
| 310 | if (XBMC_file_exists == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 311 | |||
| 312 | XBMC_stat_file = (int (*)(void* HANDLE, void* CB, const char *strFileName, struct __stat64* buffer)) | ||
| 313 | dlsym(m_libXBMC_addon, "XBMC_stat_file"); | ||
| 314 | if (XBMC_stat_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 315 | |||
| 316 | XBMC_delete_file = (bool (*)(void* HANDLE, void* CB, const char *strFileName)) | ||
| 317 | dlsym(m_libXBMC_addon, "XBMC_delete_file"); | ||
| 318 | if (XBMC_delete_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 319 | |||
| 320 | XBMC_can_open_directory = (bool (*)(void* HANDLE, void* CB, const char* strURL)) | ||
| 321 | dlsym(m_libXBMC_addon, "XBMC_can_open_directory"); | ||
| 322 | if (XBMC_can_open_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 323 | |||
| 324 | XBMC_create_directory = (bool (*)(void* HANDLE, void* CB, const char* strPath)) | ||
| 325 | dlsym(m_libXBMC_addon, "XBMC_create_directory"); | ||
| 326 | if (XBMC_create_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 327 | |||
| 328 | XBMC_directory_exists = (bool (*)(void* HANDLE, void* CB, const char* strPath)) | ||
| 329 | dlsym(m_libXBMC_addon, "XBMC_directory_exists"); | ||
| 330 | if (XBMC_directory_exists == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 331 | |||
| 332 | XBMC_remove_directory = (bool (*)(void* HANDLE, void* CB, const char* strPath)) | ||
| 333 | dlsym(m_libXBMC_addon, "XBMC_remove_directory"); | ||
| 334 | if (XBMC_remove_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 335 | |||
| 336 | XBMC_get_directory = (bool (*)(void* HANDLE, void* CB, const char* strPath, const char* mask, VFSDirEntry** items, unsigned int* num_items)) | ||
| 337 | dlsym(m_libXBMC_addon, "XBMC_get_directory"); | ||
| 338 | if (XBMC_get_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 339 | |||
| 340 | XBMC_free_directory = (void (*)(void* HANDLE, void* CB, VFSDirEntry* items, unsigned int num_items)) | ||
| 341 | dlsym(m_libXBMC_addon, "XBMC_free_directory"); | ||
| 342 | if (XBMC_free_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 343 | |||
| 344 | XBMC_curl_create = (void* (*)(void *HANDLE, void* CB, const char* strURL)) | ||
| 345 | dlsym(m_libXBMC_addon, "XBMC_curl_create"); | ||
| 346 | if (XBMC_curl_create == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 347 | |||
| 348 | XBMC_curl_add_option = (bool (*)(void *HANDLE, void* CB, void *file, XFILE::CURLOPTIONTYPE type, const char* name, const char *value)) | ||
| 349 | dlsym(m_libXBMC_addon, "XBMC_curl_add_option"); | ||
| 350 | if (XBMC_curl_add_option == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 351 | |||
| 352 | XBMC_curl_open = (bool (*)(void *HANDLE, void* CB, void *file, unsigned int flags)) | ||
| 353 | dlsym(m_libXBMC_addon, "XBMC_curl_open"); | ||
| 354 | if (XBMC_curl_open == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 355 | |||
| 356 | m_Callbacks = XBMC_register_me(m_Handle); | ||
| 357 | return m_Callbacks != NULL; | ||
| 358 | } | 201 | } |
| 359 | 202 | ||
| 360 | /*! | 203 | /*! |
| @@ -369,7 +212,7 @@ namespace ADDON | |||
| 369 | va_start (args, format); | 212 | va_start (args, format); |
| 370 | vsprintf (buffer, format, args); | 213 | vsprintf (buffer, format, args); |
| 371 | va_end (args); | 214 | va_end (args); |
| 372 | return XBMC_log(m_Handle, m_Callbacks, loglevel, buffer); | 215 | m_Callbacks->Log(m_Handle->addonData, loglevel, buffer); |
| 373 | } | 216 | } |
| 374 | 217 | ||
| 375 | /*! | 218 | /*! |
| @@ -380,7 +223,7 @@ namespace ADDON | |||
| 380 | */ | 223 | */ |
| 381 | bool GetSetting(const char* settingName, void *settingValue) | 224 | bool GetSetting(const char* settingName, void *settingValue) |
| 382 | { | 225 | { |
| 383 | return XBMC_get_setting(m_Handle, m_Callbacks, settingName, settingValue); | 226 | return m_Callbacks->GetSetting(m_Handle->addonData, settingName, settingValue); |
| 384 | } | 227 | } |
| 385 | 228 | ||
| 386 | /*! | 229 | /*! |
| @@ -390,7 +233,7 @@ namespace ADDON | |||
| 390 | */ | 233 | */ |
| 391 | char *TranslateSpecialProtocol(const char *source) | 234 | char *TranslateSpecialProtocol(const char *source) |
| 392 | { | 235 | { |
| 393 | return XBMC_translate_special(m_Handle, m_Callbacks, source); | 236 | return m_Callbacks->TranslateSpecialProtocol(source); |
| 394 | } | 237 | } |
| 395 | 238 | ||
| 396 | /*! | 239 | /*! |
| @@ -405,7 +248,7 @@ namespace ADDON | |||
| 405 | va_start (args, format); | 248 | va_start (args, format); |
| 406 | vsprintf (buffer, format, args); | 249 | vsprintf (buffer, format, args); |
| 407 | va_end (args); | 250 | va_end (args); |
| 408 | return XBMC_queue_notification(m_Handle, m_Callbacks, type, buffer); | 251 | m_Callbacks->QueueNotification(m_Handle->addonData, type, buffer); |
| 409 | } | 252 | } |
| 410 | 253 | ||
| 411 | /*! | 254 | /*! |
| @@ -415,7 +258,7 @@ namespace ADDON | |||
| 415 | */ | 258 | */ |
| 416 | bool WakeOnLan(const char* mac) | 259 | bool WakeOnLan(const char* mac) |
| 417 | { | 260 | { |
| 418 | return XBMC_wake_on_lan(m_Handle, m_Callbacks, mac); | 261 | return m_Callbacks->WakeOnLan(mac); |
| 419 | } | 262 | } |
| 420 | 263 | ||
| 421 | /*! | 264 | /*! |
| @@ -425,7 +268,7 @@ namespace ADDON | |||
| 425 | */ | 268 | */ |
| 426 | char* UnknownToUTF8(const char* str) | 269 | char* UnknownToUTF8(const char* str) |
| 427 | { | 270 | { |
| 428 | return XBMC_unknown_to_utf8(m_Handle, m_Callbacks, str); | 271 | return m_Callbacks->UnknownToUTF8(str); |
| 429 | } | 272 | } |
| 430 | 273 | ||
| 431 | /*! | 274 | /*! |
| @@ -435,17 +278,16 @@ namespace ADDON | |||
| 435 | */ | 278 | */ |
| 436 | char* GetLocalizedString(int dwCode) | 279 | char* GetLocalizedString(int dwCode) |
| 437 | { | 280 | { |
| 438 | return XBMC_get_localized_string(m_Handle, m_Callbacks, dwCode); | 281 | return m_Callbacks->GetLocalizedString(m_Handle->addonData, dwCode); |
| 439 | } | 282 | } |
| 440 | 283 | ||
| 441 | |||
| 442 | /*! | 284 | /*! |
| 443 | * @brief Get the DVD menu language. | 285 | * @brief Get the DVD menu language. |
| 444 | * @return The language. Must be freed by calling FreeString() when done. | 286 | * @return The language. Must be freed by calling FreeString() when done. |
| 445 | */ | 287 | */ |
| 446 | char* GetDVDMenuLanguage() | 288 | char* GetDVDMenuLanguage() |
| 447 | { | 289 | { |
| 448 | return XBMC_get_dvd_menu_language(m_Handle, m_Callbacks); | 290 | return m_Callbacks->GetDVDMenuLanguage(m_Handle->addonData); |
| 449 | } | 291 | } |
| 450 | 292 | ||
| 451 | /*! | 293 | /*! |
| @@ -454,7 +296,7 @@ namespace ADDON | |||
| 454 | */ | 296 | */ |
| 455 | void FreeString(char* str) | 297 | void FreeString(char* str) |
| 456 | { | 298 | { |
| 457 | return XBMC_free_string(m_Handle, m_Callbacks, str); | 299 | m_Callbacks->FreeString(m_Handle->addonData, str); |
| 458 | } | 300 | } |
| 459 | 301 | ||
| 460 | /*! | 302 | /*! |
| @@ -465,7 +307,7 @@ namespace ADDON | |||
| 465 | */ | 307 | */ |
| 466 | void* OpenFile(const char* strFileName, unsigned int flags) | 308 | void* OpenFile(const char* strFileName, unsigned int flags) |
| 467 | { | 309 | { |
| 468 | return XBMC_open_file(m_Handle, m_Callbacks, strFileName, flags); | 310 | return m_Callbacks->OpenFile(m_Handle->addonData, strFileName, flags); |
| 469 | } | 311 | } |
| 470 | 312 | ||
| 471 | /*! | 313 | /*! |
| @@ -476,7 +318,7 @@ namespace ADDON | |||
| 476 | */ | 318 | */ |
| 477 | void* OpenFileForWrite(const char* strFileName, bool bOverWrite) | 319 | void* OpenFileForWrite(const char* strFileName, bool bOverWrite) |
| 478 | { | 320 | { |
| 479 | return XBMC_open_file_for_write(m_Handle, m_Callbacks, strFileName, bOverWrite); | 321 | return m_Callbacks->OpenFileForWrite(m_Handle->addonData, strFileName, bOverWrite); |
| 480 | } | 322 | } |
| 481 | 323 | ||
| 482 | /*! | 324 | /*! |
| @@ -490,7 +332,7 @@ namespace ADDON | |||
| 490 | */ | 332 | */ |
| 491 | ssize_t ReadFile(void* file, void* lpBuf, size_t uiBufSize) | 333 | ssize_t ReadFile(void* file, void* lpBuf, size_t uiBufSize) |
| 492 | { | 334 | { |
| 493 | return XBMC_read_file(m_Handle, m_Callbacks, file, lpBuf, uiBufSize); | 335 | return m_Callbacks->ReadFile(m_Handle->addonData, file, lpBuf, uiBufSize); |
| 494 | } | 336 | } |
| 495 | 337 | ||
| 496 | /*! | 338 | /*! |
| @@ -502,7 +344,7 @@ namespace ADDON | |||
| 502 | */ | 344 | */ |
| 503 | bool ReadFileString(void* file, char *szLine, int iLineLength) | 345 | bool ReadFileString(void* file, char *szLine, int iLineLength) |
| 504 | { | 346 | { |
| 505 | return XBMC_read_file_string(m_Handle, m_Callbacks, file, szLine, iLineLength); | 347 | return m_Callbacks->ReadFileString(m_Handle->addonData, file, szLine, iLineLength); |
| 506 | } | 348 | } |
| 507 | 349 | ||
| 508 | /*! | 350 | /*! |
| @@ -516,7 +358,7 @@ namespace ADDON | |||
| 516 | */ | 358 | */ |
| 517 | ssize_t WriteFile(void* file, const void* lpBuf, size_t uiBufSize) | 359 | ssize_t WriteFile(void* file, const void* lpBuf, size_t uiBufSize) |
| 518 | { | 360 | { |
| 519 | return XBMC_write_file(m_Handle, m_Callbacks, file, lpBuf, uiBufSize); | 361 | return m_Callbacks->WriteFile(m_Handle->addonData, file, lpBuf, uiBufSize); |
| 520 | } | 362 | } |
| 521 | 363 | ||
| 522 | /*! | 364 | /*! |
| @@ -525,7 +367,7 @@ namespace ADDON | |||
| 525 | */ | 367 | */ |
| 526 | void FlushFile(void* file) | 368 | void FlushFile(void* file) |
| 527 | { | 369 | { |
| 528 | return XBMC_flush_file(m_Handle, m_Callbacks, file); | 370 | m_Callbacks->FlushFile(m_Handle->addonData, file); |
| 529 | } | 371 | } |
| 530 | 372 | ||
| 531 | /*! | 373 | /*! |
| @@ -537,7 +379,7 @@ namespace ADDON | |||
| 537 | */ | 379 | */ |
| 538 | int64_t SeekFile(void* file, int64_t iFilePosition, int iWhence) | 380 | int64_t SeekFile(void* file, int64_t iFilePosition, int iWhence) |
| 539 | { | 381 | { |
| 540 | return XBMC_seek_file(m_Handle, m_Callbacks, file, iFilePosition, iWhence); | 382 | return m_Callbacks->SeekFile(m_Handle->addonData, file, iFilePosition, iWhence); |
| 541 | } | 383 | } |
| 542 | 384 | ||
| 543 | /*! | 385 | /*! |
| @@ -548,7 +390,7 @@ namespace ADDON | |||
| 548 | */ | 390 | */ |
| 549 | int TruncateFile(void* file, int64_t iSize) | 391 | int TruncateFile(void* file, int64_t iSize) |
| 550 | { | 392 | { |
| 551 | return XBMC_truncate_file(m_Handle, m_Callbacks, file, iSize); | 393 | return m_Callbacks->TruncateFile(m_Handle->addonData, file, iSize); |
| 552 | } | 394 | } |
| 553 | 395 | ||
| 554 | /*! | 396 | /*! |
| @@ -558,7 +400,7 @@ namespace ADDON | |||
| 558 | */ | 400 | */ |
| 559 | int64_t GetFilePosition(void* file) | 401 | int64_t GetFilePosition(void* file) |
| 560 | { | 402 | { |
| 561 | return XBMC_get_file_position(m_Handle, m_Callbacks, file); | 403 | return m_Callbacks->GetFilePosition(m_Handle->addonData, file); |
| 562 | } | 404 | } |
| 563 | 405 | ||
| 564 | /*! | 406 | /*! |
| @@ -568,7 +410,7 @@ namespace ADDON | |||
| 568 | */ | 410 | */ |
| 569 | int64_t GetFileLength(void* file) | 411 | int64_t GetFileLength(void* file) |
| 570 | { | 412 | { |
| 571 | return XBMC_get_file_length(m_Handle, m_Callbacks, file); | 413 | return m_Callbacks->GetFileLength(m_Handle->addonData, file); |
| 572 | } | 414 | } |
| 573 | 415 | ||
| 574 | /*! | 416 | /*! |
| @@ -578,7 +420,7 @@ namespace ADDON | |||
| 578 | */ | 420 | */ |
| 579 | double GetFileDownloadSpeed(void* file) | 421 | double GetFileDownloadSpeed(void* file) |
| 580 | { | 422 | { |
| 581 | return XBMC_get_file_download_speed(m_Handle, m_Callbacks, file); | 423 | return m_Callbacks->GetFileDownloadSpeed(m_Handle->addonData, file); |
| 582 | } | 424 | } |
| 583 | 425 | ||
| 584 | /*! | 426 | /*! |
| @@ -587,7 +429,7 @@ namespace ADDON | |||
| 587 | */ | 429 | */ |
| 588 | void CloseFile(void* file) | 430 | void CloseFile(void* file) |
| 589 | { | 431 | { |
| 590 | return XBMC_close_file(m_Handle, m_Callbacks, file); | 432 | m_Callbacks->CloseFile(m_Handle->addonData, file); |
| 591 | } | 433 | } |
| 592 | 434 | ||
| 593 | /*! | 435 | /*! |
| @@ -597,7 +439,7 @@ namespace ADDON | |||
| 597 | */ | 439 | */ |
| 598 | int GetFileChunkSize(void* file) | 440 | int GetFileChunkSize(void* file) |
| 599 | { | 441 | { |
| 600 | return XBMC_get_file_chunk_size(m_Handle, m_Callbacks, file); | 442 | return m_Callbacks->GetFileChunkSize(m_Handle->addonData, file); |
| 601 | } | 443 | } |
| 602 | 444 | ||
| 603 | /*! | 445 | /*! |
| @@ -608,7 +450,7 @@ namespace ADDON | |||
| 608 | */ | 450 | */ |
| 609 | bool FileExists(const char *strFileName, bool bUseCache) | 451 | bool FileExists(const char *strFileName, bool bUseCache) |
| 610 | { | 452 | { |
| 611 | return XBMC_file_exists(m_Handle, m_Callbacks, strFileName, bUseCache); | 453 | return m_Callbacks->FileExists(m_Handle->addonData, strFileName, bUseCache); |
| 612 | } | 454 | } |
| 613 | 455 | ||
| 614 | /*! | 456 | /*! |
| @@ -619,7 +461,7 @@ namespace ADDON | |||
| 619 | */ | 461 | */ |
| 620 | int StatFile(const char *strFileName, struct __stat64* buffer) | 462 | int StatFile(const char *strFileName, struct __stat64* buffer) |
| 621 | { | 463 | { |
| 622 | return XBMC_stat_file(m_Handle, m_Callbacks, strFileName, buffer); | 464 | return m_Callbacks->StatFile(m_Handle->addonData, strFileName, buffer); |
| 623 | } | 465 | } |
| 624 | 466 | ||
| 625 | /*! | 467 | /*! |
| @@ -629,7 +471,7 @@ namespace ADDON | |||
| 629 | */ | 471 | */ |
| 630 | bool DeleteFile(const char *strFileName) | 472 | bool DeleteFile(const char *strFileName) |
| 631 | { | 473 | { |
| 632 | return XBMC_delete_file(m_Handle, m_Callbacks, strFileName); | 474 | return m_Callbacks->DeleteFile(m_Handle->addonData, strFileName); |
| 633 | } | 475 | } |
| 634 | 476 | ||
| 635 | /*! | 477 | /*! |
| @@ -639,7 +481,7 @@ namespace ADDON | |||
| 639 | */ | 481 | */ |
| 640 | bool CanOpenDirectory(const char* strUrl) | 482 | bool CanOpenDirectory(const char* strUrl) |
| 641 | { | 483 | { |
| 642 | return XBMC_can_open_directory(m_Handle, m_Callbacks, strUrl); | 484 | return m_Callbacks->CanOpenDirectory(m_Handle->addonData, strUrl); |
| 643 | } | 485 | } |
| 644 | 486 | ||
| 645 | /*! | 487 | /*! |
| @@ -649,7 +491,7 @@ namespace ADDON | |||
| 649 | */ | 491 | */ |
| 650 | bool CreateDirectory(const char *strPath) | 492 | bool CreateDirectory(const char *strPath) |
| 651 | { | 493 | { |
| 652 | return XBMC_create_directory(m_Handle, m_Callbacks, strPath); | 494 | return m_Callbacks->CreateDirectory(m_Handle->addonData, strPath); |
| 653 | } | 495 | } |
| 654 | 496 | ||
| 655 | /*! | 497 | /*! |
| @@ -659,7 +501,7 @@ namespace ADDON | |||
| 659 | */ | 501 | */ |
| 660 | bool DirectoryExists(const char *strPath) | 502 | bool DirectoryExists(const char *strPath) |
| 661 | { | 503 | { |
| 662 | return XBMC_directory_exists(m_Handle, m_Callbacks, strPath); | 504 | return m_Callbacks->DirectoryExists(m_Handle->addonData, strPath); |
| 663 | } | 505 | } |
| 664 | 506 | ||
| 665 | /*! | 507 | /*! |
| @@ -669,7 +511,7 @@ namespace ADDON | |||
| 669 | */ | 511 | */ |
| 670 | bool RemoveDirectory(const char *strPath) | 512 | bool RemoveDirectory(const char *strPath) |
| 671 | { | 513 | { |
| 672 | return XBMC_remove_directory(m_Handle, m_Callbacks, strPath); | 514 | return m_Callbacks->RemoveDirectory(m_Handle->addonData, strPath); |
| 673 | } | 515 | } |
| 674 | 516 | ||
| 675 | /*! | 517 | /*! |
| @@ -682,7 +524,7 @@ namespace ADDON | |||
| 682 | */ | 524 | */ |
| 683 | bool GetDirectory(const char *strPath, const char* mask, VFSDirEntry** items, unsigned int* num_items) | 525 | bool GetDirectory(const char *strPath, const char* mask, VFSDirEntry** items, unsigned int* num_items) |
| 684 | { | 526 | { |
| 685 | return XBMC_get_directory(m_Handle, m_Callbacks, strPath, mask, items, num_items); | 527 | return m_Callbacks->GetDirectory(m_Handle->addonData, strPath, mask, items, num_items); |
| 686 | } | 528 | } |
| 687 | 529 | ||
| 688 | /*! | 530 | /*! |
| @@ -692,7 +534,7 @@ namespace ADDON | |||
| 692 | */ | 534 | */ |
| 693 | void FreeDirectory(VFSDirEntry* items, unsigned int num_items) | 535 | void FreeDirectory(VFSDirEntry* items, unsigned int num_items) |
| 694 | { | 536 | { |
| 695 | return XBMC_free_directory(m_Handle, m_Callbacks, items, num_items); | 537 | m_Callbacks->FreeDirectory(m_Handle->addonData, items, num_items); |
| 696 | } | 538 | } |
| 697 | 539 | ||
| 698 | /*! | 540 | /*! |
| @@ -701,7 +543,7 @@ namespace ADDON | |||
| 701 | */ | 543 | */ |
| 702 | void* CURLCreate(const char* strURL) | 544 | void* CURLCreate(const char* strURL) |
| 703 | { | 545 | { |
| 704 | return XBMC_curl_create(m_Handle, m_Callbacks, strURL); | 546 | return m_Callbacks->CURLCreate(m_Handle->addonData, strURL); |
| 705 | } | 547 | } |
| 706 | 548 | ||
| 707 | /*! | 549 | /*! |
| @@ -713,7 +555,7 @@ namespace ADDON | |||
| 713 | */ | 555 | */ |
| 714 | bool CURLAddOption(void* file, XFILE::CURLOPTIONTYPE type, const char* name, const char * value) | 556 | bool CURLAddOption(void* file, XFILE::CURLOPTIONTYPE type, const char* name, const char * value) |
| 715 | { | 557 | { |
| 716 | return XBMC_curl_add_option(m_Handle, m_Callbacks, file, type, name, value); | 558 | return m_Callbacks->CURLAddOption(m_Handle->addonData, file, type, name, value); |
| 717 | } | 559 | } |
| 718 | 560 | ||
| 719 | /*! | 561 | /*! |
| @@ -723,54 +565,11 @@ namespace ADDON | |||
| 723 | */ | 565 | */ |
| 724 | bool CURLOpen(void* file, unsigned int flags) | 566 | bool CURLOpen(void* file, unsigned int flags) |
| 725 | { | 567 | { |
| 726 | return XBMC_curl_open(m_Handle, m_Callbacks, file, flags); | 568 | return m_Callbacks->CURLOpen(m_Handle->addonData, file, flags); |
| 727 | } | 569 | } |
| 728 | |||
| 729 | protected: | ||
| 730 | void* (*XBMC_register_me)(void *HANDLE); | ||
| 731 | void (*XBMC_unregister_me)(void *HANDLE, void* CB); | ||
| 732 | void (*XBMC_log)(void *HANDLE, void* CB, const addon_log_t loglevel, const char *msg); | ||
| 733 | bool (*XBMC_get_setting)(void *HANDLE, void* CB, const char* settingName, void *settingValue); | ||
| 734 | char*(*XBMC_translate_special)(void *HANDLE, void* CB, const char* source); | ||
| 735 | void (*XBMC_queue_notification)(void *HANDLE, void* CB, const queue_msg_t type, const char *msg); | ||
| 736 | bool (*XBMC_wake_on_lan)(void *HANDLE, void* CB, const char* mac); | ||
| 737 | char* (*XBMC_unknown_to_utf8)(void *HANDLE, void* CB, const char* str); | ||
| 738 | char* (*XBMC_get_localized_string)(void *HANDLE, void* CB, int dwCode); | ||
| 739 | char* (*XBMC_get_dvd_menu_language)(void *HANDLE, void* CB); | ||
| 740 | void (*XBMC_free_string)(void *HANDLE, void* CB, char* str); | ||
| 741 | void* (*XBMC_open_file)(void *HANDLE, void* CB, const char* strFileName, unsigned int flags); | ||
| 742 | void* (*XBMC_open_file_for_write)(void *HANDLE, void* CB, const char* strFileName, bool bOverWrite); | ||
| 743 | ssize_t (*XBMC_read_file)(void *HANDLE, void* CB, void* file, void* lpBuf, size_t uiBufSize); | ||
| 744 | bool (*XBMC_read_file_string)(void *HANDLE, void* CB, void* file, char *szLine, int iLineLength); | ||
| 745 | ssize_t(*XBMC_write_file)(void *HANDLE, void* CB, void* file, const void* lpBuf, size_t uiBufSize); | ||
| 746 | void (*XBMC_flush_file)(void *HANDLE, void* CB, void* file); | ||
| 747 | int64_t (*XBMC_seek_file)(void *HANDLE, void* CB, void* file, int64_t iFilePosition, int iWhence); | ||
| 748 | int (*XBMC_truncate_file)(void *HANDLE, void* CB, void* file, int64_t iSize); | ||
| 749 | int64_t (*XBMC_get_file_position)(void *HANDLE, void* CB, void* file); | ||
| 750 | int64_t (*XBMC_get_file_length)(void *HANDLE, void* CB, void* file); | ||
| 751 | double(*XBMC_get_file_download_speed)(void *HANDLE, void* CB, void* file); | ||
| 752 | void (*XBMC_close_file)(void *HANDLE, void* CB, void* file); | ||
| 753 | int (*XBMC_get_file_chunk_size)(void *HANDLE, void* CB, void* file); | ||
| 754 | bool (*XBMC_file_exists)(void *HANDLE, void* CB, const char *strFileName, bool bUseCache); | ||
| 755 | int (*XBMC_stat_file)(void *HANDLE, void* CB, const char *strFileName, struct __stat64* buffer); | ||
| 756 | bool (*XBMC_delete_file)(void *HANDLE, void* CB, const char *strFileName); | ||
| 757 | bool (*XBMC_can_open_directory)(void *HANDLE, void* CB, const char* strURL); | ||
| 758 | bool (*XBMC_create_directory)(void *HANDLE, void* CB, const char* strPath); | ||
| 759 | bool (*XBMC_directory_exists)(void *HANDLE, void* CB, const char* strPath); | ||
| 760 | bool (*XBMC_remove_directory)(void *HANDLE, void* CB, const char* strPath); | ||
| 761 | bool (*XBMC_get_directory)(void *HANDLE, void* CB, const char* strPath, const char* mask, VFSDirEntry** items, unsigned int* num_items); | ||
| 762 | void (*XBMC_free_directory)(void *HANDLE, void* CB, VFSDirEntry* items, unsigned int num_items); | ||
| 763 | void* (*XBMC_curl_create)(void *HANDLE, void* CB, const char* strURL); | ||
| 764 | bool (*XBMC_curl_add_option)(void *HANDLE, void* CB, void *file, XFILE::CURLOPTIONTYPE type, const char* name, const char *value); | ||
| 765 | bool (*XBMC_curl_open)(void *m_Handle, void *m_Callbacks, void *file, unsigned int flags); | ||
| 766 | 570 | ||
| 767 | private: | 571 | private: |
| 768 | void *m_libXBMC_addon; | 572 | AddonCB* m_Handle; |
| 769 | void *m_Handle; | 573 | KodiAPI::AddOn::CB_AddOnLib *m_Callbacks; |
| 770 | void *m_Callbacks; | ||
| 771 | struct cb_array | ||
| 772 | { | ||
| 773 | const char* libPath; | ||
| 774 | }; | ||
| 775 | }; | 574 | }; |
| 776 | }; | 575 | }; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_codec.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_codec.h deleted file mode 100644 index 0e64b11..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_codec.h +++ /dev/null | |||
| @@ -1,111 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2013 Team XBMC | ||
| 4 | * http://xbmc.org | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with XBMC; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <string> | ||
| 23 | #include <vector> | ||
| 24 | #include <string.h> | ||
| 25 | #include <stdlib.h> | ||
| 26 | #include <stdio.h> | ||
| 27 | #include "xbmc_codec_types.h" | ||
| 28 | #include "libXBMC_addon.h" | ||
| 29 | |||
| 30 | #define CODEC_HELPER_DLL_NAME XBMC_DLL_NAME("codec") | ||
| 31 | #define CODEC_HELPER_DLL XBMC_DLL("codec") | ||
| 32 | |||
| 33 | class CHelper_libXBMC_codec | ||
| 34 | { | ||
| 35 | public: | ||
| 36 | CHelper_libXBMC_codec(void) | ||
| 37 | { | ||
| 38 | m_libXBMC_codec = NULL; | ||
| 39 | m_Handle = NULL; | ||
| 40 | } | ||
| 41 | |||
| 42 | ~CHelper_libXBMC_codec(void) | ||
| 43 | { | ||
| 44 | if (m_libXBMC_codec) | ||
| 45 | { | ||
| 46 | CODEC_unregister_me(m_Handle, m_Callbacks); | ||
| 47 | dlclose(m_libXBMC_codec); | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | /*! | ||
| 52 | * @brief Resolve all callback methods | ||
| 53 | * @param handle Pointer to the add-on | ||
| 54 | * @return True when all methods were resolved, false otherwise. | ||
| 55 | */ | ||
| 56 | bool RegisterMe(void* handle) | ||
| 57 | { | ||
| 58 | m_Handle = handle; | ||
| 59 | |||
| 60 | std::string libBasePath; | ||
| 61 | libBasePath = ((cb_array*)m_Handle)->libPath; | ||
| 62 | libBasePath += CODEC_HELPER_DLL; | ||
| 63 | |||
| 64 | m_libXBMC_codec = dlopen(libBasePath.c_str(), RTLD_LAZY); | ||
| 65 | if (m_libXBMC_codec == NULL) | ||
| 66 | { | ||
| 67 | fprintf(stderr, "Unable to load %s\n", dlerror()); | ||
| 68 | return false; | ||
| 69 | } | ||
| 70 | |||
| 71 | CODEC_register_me = (void* (*)(void *HANDLE)) | ||
| 72 | dlsym(m_libXBMC_codec, "CODEC_register_me"); | ||
| 73 | if (CODEC_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 74 | |||
| 75 | CODEC_unregister_me = (void (*)(void* HANDLE, void* CB)) | ||
| 76 | dlsym(m_libXBMC_codec, "CODEC_unregister_me"); | ||
| 77 | if (CODEC_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 78 | |||
| 79 | CODEC_get_codec_by_name = (xbmc_codec_t (*)(void* HANDLE, void* CB, const char* strCodecName)) | ||
| 80 | dlsym(m_libXBMC_codec, "CODEC_get_codec_by_name"); | ||
| 81 | if (CODEC_get_codec_by_name == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 82 | |||
| 83 | m_Callbacks = CODEC_register_me(m_Handle); | ||
| 84 | return m_Callbacks != NULL; | ||
| 85 | } | ||
| 86 | |||
| 87 | /*! | ||
| 88 | * @brief Get the codec id used by XBMC | ||
| 89 | * @param strCodecName The name of the codec | ||
| 90 | * @return The codec_id, or a codec_id with 0 values when not supported | ||
| 91 | */ | ||
| 92 | xbmc_codec_t GetCodecByName(const char* strCodecName) | ||
| 93 | { | ||
| 94 | return CODEC_get_codec_by_name(m_Handle, m_Callbacks, strCodecName); | ||
| 95 | } | ||
| 96 | |||
| 97 | protected: | ||
| 98 | void* (*CODEC_register_me)(void*); | ||
| 99 | void (*CODEC_unregister_me)(void*, void*); | ||
| 100 | xbmc_codec_t (*CODEC_get_codec_by_name)(void *HANDLE, void* CB, const char* strCodecName); | ||
| 101 | |||
| 102 | private: | ||
| 103 | void* m_libXBMC_codec; | ||
| 104 | void* m_Handle; | ||
| 105 | void* m_Callbacks; | ||
| 106 | struct cb_array | ||
| 107 | { | ||
| 108 | const char* libPath; | ||
| 109 | }; | ||
| 110 | }; | ||
| 111 | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h index 3ae30a7..6a9145e 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h | |||
| @@ -32,41 +32,6 @@ | |||
| 32 | //! @todo original definition is in DVDClock.h | 32 | //! @todo original definition is in DVDClock.h |
| 33 | #define DVD_NOPTS_VALUE 0xFFF0000000000000 | 33 | #define DVD_NOPTS_VALUE 0xFFF0000000000000 |
| 34 | 34 | ||
| 35 | namespace KodiAPI | ||
| 36 | { | ||
| 37 | namespace V1 | ||
| 38 | { | ||
| 39 | namespace PVR | ||
| 40 | { | ||
| 41 | |||
| 42 | typedef struct CB_PVRLib | ||
| 43 | { | ||
| 44 | void (*TransferEpgEntry)(void *userData, const ADDON_HANDLE handle, const EPG_TAG *epgentry); | ||
| 45 | void (*TransferChannelEntry)(void *userData, const ADDON_HANDLE handle, const PVR_CHANNEL *chan); | ||
| 46 | void (*TransferTimerEntry)(void *userData, const ADDON_HANDLE handle, const PVR_TIMER *timer); | ||
| 47 | void (*TransferRecordingEntry)(void *userData, const ADDON_HANDLE handle, const PVR_RECORDING *recording); | ||
| 48 | void (*AddMenuHook)(void *addonData, PVR_MENUHOOK *hook); | ||
| 49 | void (*Recording)(void *addonData, const char *Name, const char *FileName, bool On); | ||
| 50 | void (*TriggerChannelUpdate)(void *addonData); | ||
| 51 | void (*TriggerTimerUpdate)(void *addonData); | ||
| 52 | void (*TriggerRecordingUpdate)(void *addonData); | ||
| 53 | void (*TriggerChannelGroupsUpdate)(void *addonData); | ||
| 54 | void (*TriggerEpgUpdate)(void *addonData, unsigned int iChannelUid); | ||
| 55 | |||
| 56 | void (*TransferChannelGroup)(void *addonData, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP *group); | ||
| 57 | void (*TransferChannelGroupMember)(void *addonData, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER *member); | ||
| 58 | |||
| 59 | void (*FreeDemuxPacket)(void *addonData, DemuxPacket* pPacket); | ||
| 60 | DemuxPacket* (*AllocateDemuxPacket)(void *addonData, int iDataSize); | ||
| 61 | |||
| 62 | void (*ConnectionStateChange)(void* addonData, const char* strConnectionString, PVR_CONNECTION_STATE newState, const char *strMessage); | ||
| 63 | void (*EpgEventStateChange)(void* addonData, EPG_TAG* tag, unsigned int iUniqueChannelId, EPG_EVENT_STATE newState); | ||
| 64 | } CB_PVRLib; | ||
| 65 | |||
| 66 | } /* namespace PVR */ | ||
| 67 | } /* namespace V1 */ | ||
| 68 | } /* namespace KodiAPI */ | ||
| 69 | |||
| 70 | class CHelper_libXBMC_pvr | 35 | class CHelper_libXBMC_pvr |
| 71 | { | 36 | { |
| 72 | public: | 37 | public: |
| @@ -93,7 +58,7 @@ public: | |||
| 93 | { | 58 | { |
| 94 | m_Handle = static_cast<AddonCB*>(handle); | 59 | m_Handle = static_cast<AddonCB*>(handle); |
| 95 | if (m_Handle) | 60 | if (m_Handle) |
| 96 | m_Callbacks = (KodiAPI::V1::PVR::CB_PVRLib*)m_Handle->PVRLib_RegisterMe(m_Handle->addonData); | 61 | m_Callbacks = (AddonInstance_PVR*)m_Handle->PVRLib_RegisterMe(m_Handle->addonData); |
| 97 | if (!m_Callbacks) | 62 | if (!m_Callbacks) |
| 98 | fprintf(stderr, "libXBMC_pvr-ERROR: PVRLib_register_me can't get callback table from Kodi !!!\n"); | 63 | fprintf(stderr, "libXBMC_pvr-ERROR: PVRLib_register_me can't get callback table from Kodi !!!\n"); |
| 99 | 64 | ||
| @@ -107,7 +72,7 @@ public: | |||
| 107 | */ | 72 | */ |
| 108 | void TransferEpgEntry(const ADDON_HANDLE handle, const EPG_TAG* entry) | 73 | void TransferEpgEntry(const ADDON_HANDLE handle, const EPG_TAG* entry) |
| 109 | { | 74 | { |
| 110 | return m_Callbacks->TransferEpgEntry(m_Handle->addonData, handle, entry); | 75 | return m_Callbacks->toKodi.TransferEpgEntry(m_Callbacks->toKodi.kodiInstance, handle, entry); |
| 111 | } | 76 | } |
| 112 | 77 | ||
| 113 | /*! | 78 | /*! |
| @@ -117,7 +82,7 @@ public: | |||
| 117 | */ | 82 | */ |
| 118 | void TransferChannelEntry(const ADDON_HANDLE handle, const PVR_CHANNEL* entry) | 83 | void TransferChannelEntry(const ADDON_HANDLE handle, const PVR_CHANNEL* entry) |
| 119 | { | 84 | { |
| 120 | return m_Callbacks->TransferChannelEntry(m_Handle->addonData, handle, entry); | 85 | return m_Callbacks->toKodi.TransferChannelEntry(m_Callbacks->toKodi.kodiInstance, handle, entry); |
| 121 | } | 86 | } |
| 122 | 87 | ||
| 123 | /*! | 88 | /*! |
| @@ -127,7 +92,7 @@ public: | |||
| 127 | */ | 92 | */ |
| 128 | void TransferTimerEntry(const ADDON_HANDLE handle, const PVR_TIMER* entry) | 93 | void TransferTimerEntry(const ADDON_HANDLE handle, const PVR_TIMER* entry) |
| 129 | { | 94 | { |
| 130 | return m_Callbacks->TransferTimerEntry(m_Handle->addonData, handle, entry); | 95 | return m_Callbacks->toKodi.TransferTimerEntry(m_Callbacks->toKodi.kodiInstance, handle, entry); |
| 131 | } | 96 | } |
| 132 | 97 | ||
| 133 | /*! | 98 | /*! |
| @@ -137,7 +102,7 @@ public: | |||
| 137 | */ | 102 | */ |
| 138 | void TransferRecordingEntry(const ADDON_HANDLE handle, const PVR_RECORDING* entry) | 103 | void TransferRecordingEntry(const ADDON_HANDLE handle, const PVR_RECORDING* entry) |
| 139 | { | 104 | { |
| 140 | return m_Callbacks->TransferRecordingEntry(m_Handle->addonData, handle, entry); | 105 | return m_Callbacks->toKodi.TransferRecordingEntry(m_Callbacks->toKodi.kodiInstance, handle, entry); |
| 141 | } | 106 | } |
| 142 | 107 | ||
| 143 | /*! | 108 | /*! |
| @@ -147,7 +112,7 @@ public: | |||
| 147 | */ | 112 | */ |
| 148 | void TransferChannelGroup(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP* entry) | 113 | void TransferChannelGroup(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP* entry) |
| 149 | { | 114 | { |
| 150 | return m_Callbacks->TransferChannelGroup(m_Handle->addonData, handle, entry); | 115 | return m_Callbacks->toKodi.TransferChannelGroup(m_Callbacks->toKodi.kodiInstance, handle, entry); |
| 151 | } | 116 | } |
| 152 | 117 | ||
| 153 | /*! | 118 | /*! |
| @@ -157,7 +122,7 @@ public: | |||
| 157 | */ | 122 | */ |
| 158 | void TransferChannelGroupMember(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER* entry) | 123 | void TransferChannelGroupMember(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER* entry) |
| 159 | { | 124 | { |
| 160 | return m_Callbacks->TransferChannelGroupMember(m_Handle->addonData, handle, entry); | 125 | return m_Callbacks->toKodi.TransferChannelGroupMember(m_Callbacks->toKodi.kodiInstance, handle, entry); |
| 161 | } | 126 | } |
| 162 | 127 | ||
| 163 | /*! | 128 | /*! |
| @@ -166,7 +131,7 @@ public: | |||
| 166 | */ | 131 | */ |
| 167 | void AddMenuHook(PVR_MENUHOOK* hook) | 132 | void AddMenuHook(PVR_MENUHOOK* hook) |
| 168 | { | 133 | { |
| 169 | return m_Callbacks->AddMenuHook(m_Handle->addonData, hook); | 134 | return m_Callbacks->toKodi.AddMenuHook(m_Callbacks->toKodi.kodiInstance, hook); |
| 170 | } | 135 | } |
| 171 | 136 | ||
| 172 | /*! | 137 | /*! |
| @@ -177,7 +142,7 @@ public: | |||
| 177 | */ | 142 | */ |
| 178 | void Recording(const char* strRecordingName, const char* strFileName, bool bOn) | 143 | void Recording(const char* strRecordingName, const char* strFileName, bool bOn) |
| 179 | { | 144 | { |
| 180 | return m_Callbacks->Recording(m_Handle->addonData, strRecordingName, strFileName, bOn); | 145 | return m_Callbacks->toKodi.Recording(m_Callbacks->toKodi.kodiInstance, strRecordingName, strFileName, bOn); |
| 181 | } | 146 | } |
| 182 | 147 | ||
| 183 | /*! | 148 | /*! |
| @@ -185,7 +150,7 @@ public: | |||
| 185 | */ | 150 | */ |
| 186 | void TriggerTimerUpdate(void) | 151 | void TriggerTimerUpdate(void) |
| 187 | { | 152 | { |
| 188 | return m_Callbacks->TriggerTimerUpdate(m_Handle->addonData); | 153 | return m_Callbacks->toKodi.TriggerTimerUpdate(m_Callbacks->toKodi.kodiInstance); |
| 189 | } | 154 | } |
| 190 | 155 | ||
| 191 | /*! | 156 | /*! |
| @@ -193,7 +158,7 @@ public: | |||
| 193 | */ | 158 | */ |
| 194 | void TriggerRecordingUpdate(void) | 159 | void TriggerRecordingUpdate(void) |
| 195 | { | 160 | { |
| 196 | return m_Callbacks->TriggerRecordingUpdate(m_Handle->addonData); | 161 | return m_Callbacks->toKodi.TriggerRecordingUpdate(m_Callbacks->toKodi.kodiInstance); |
| 197 | } | 162 | } |
| 198 | 163 | ||
| 199 | /*! | 164 | /*! |
| @@ -201,7 +166,7 @@ public: | |||
| 201 | */ | 166 | */ |
| 202 | void TriggerChannelUpdate(void) | 167 | void TriggerChannelUpdate(void) |
| 203 | { | 168 | { |
| 204 | return m_Callbacks->TriggerChannelUpdate(m_Handle->addonData); | 169 | return m_Callbacks->toKodi.TriggerChannelUpdate(m_Callbacks->toKodi.kodiInstance); |
| 205 | } | 170 | } |
| 206 | 171 | ||
| 207 | /*! | 172 | /*! |
| @@ -210,7 +175,7 @@ public: | |||
| 210 | */ | 175 | */ |
| 211 | void TriggerEpgUpdate(unsigned int iChannelUid) | 176 | void TriggerEpgUpdate(unsigned int iChannelUid) |
| 212 | { | 177 | { |
| 213 | return m_Callbacks->TriggerEpgUpdate(m_Handle->addonData, iChannelUid); | 178 | return m_Callbacks->toKodi.TriggerEpgUpdate(m_Callbacks->toKodi.kodiInstance, iChannelUid); |
| 214 | } | 179 | } |
| 215 | 180 | ||
| 216 | /*! | 181 | /*! |
| @@ -218,7 +183,7 @@ public: | |||
| 218 | */ | 183 | */ |
| 219 | void TriggerChannelGroupsUpdate(void) | 184 | void TriggerChannelGroupsUpdate(void) |
| 220 | { | 185 | { |
| 221 | return m_Callbacks->TriggerChannelGroupsUpdate(m_Handle->addonData); | 186 | return m_Callbacks->toKodi.TriggerChannelGroupsUpdate(m_Callbacks->toKodi.kodiInstance); |
| 222 | } | 187 | } |
| 223 | 188 | ||
| 224 | #ifdef USE_DEMUX | 189 | #ifdef USE_DEMUX |
| @@ -228,7 +193,7 @@ public: | |||
| 228 | */ | 193 | */ |
| 229 | void FreeDemuxPacket(DemuxPacket* pPacket) | 194 | void FreeDemuxPacket(DemuxPacket* pPacket) |
| 230 | { | 195 | { |
| 231 | return m_Callbacks->FreeDemuxPacket(m_Handle->addonData, pPacket); | 196 | return m_Callbacks->toKodi.FreeDemuxPacket(m_Callbacks->toKodi.kodiInstance, pPacket); |
| 232 | } | 197 | } |
| 233 | 198 | ||
| 234 | /*! | 199 | /*! |
| @@ -238,7 +203,7 @@ public: | |||
| 238 | */ | 203 | */ |
| 239 | DemuxPacket* AllocateDemuxPacket(int iDataSize) | 204 | DemuxPacket* AllocateDemuxPacket(int iDataSize) |
| 240 | { | 205 | { |
| 241 | return m_Callbacks->AllocateDemuxPacket(m_Handle->addonData, iDataSize); | 206 | return m_Callbacks->toKodi.AllocateDemuxPacket(m_Callbacks->toKodi.kodiInstance, iDataSize); |
| 242 | } | 207 | } |
| 243 | #endif | 208 | #endif |
| 244 | 209 | ||
| @@ -251,7 +216,7 @@ public: | |||
| 251 | */ | 216 | */ |
| 252 | void ConnectionStateChange(const char *strConnectionString, PVR_CONNECTION_STATE newState, const char *strMessage) | 217 | void ConnectionStateChange(const char *strConnectionString, PVR_CONNECTION_STATE newState, const char *strMessage) |
| 253 | { | 218 | { |
| 254 | return m_Callbacks->ConnectionStateChange(m_Handle->addonData, strConnectionString, newState, strMessage); | 219 | return m_Callbacks->toKodi.ConnectionStateChange(m_Callbacks->toKodi.kodiInstance, strConnectionString, newState, strMessage); |
| 255 | } | 220 | } |
| 256 | 221 | ||
| 257 | /*! | 222 | /*! |
| @@ -263,10 +228,20 @@ public: | |||
| 263 | */ | 228 | */ |
| 264 | void EpgEventStateChange(EPG_TAG *tag, unsigned int iUniqueChannelId, EPG_EVENT_STATE newState) | 229 | void EpgEventStateChange(EPG_TAG *tag, unsigned int iUniqueChannelId, EPG_EVENT_STATE newState) |
| 265 | { | 230 | { |
| 266 | return m_Callbacks->EpgEventStateChange(m_Handle->addonData, tag, iUniqueChannelId, newState); | 231 | return m_Callbacks->toKodi.EpgEventStateChange(m_Callbacks->toKodi.kodiInstance, tag, iUniqueChannelId, newState); |
| 232 | } | ||
| 233 | |||
| 234 | /*! | ||
| 235 | * @brief Get the codec id used by XBMC | ||
| 236 | * @param strCodecName The name of the codec | ||
| 237 | * @return The codec_id, or a codec_id with 0 values when not supported | ||
| 238 | */ | ||
| 239 | xbmc_codec_t GetCodecByName(const char* strCodecName) | ||
| 240 | { | ||
| 241 | return m_Callbacks->toKodi.GetCodecByName(m_Callbacks->toKodi.kodiInstance, strCodecName); | ||
| 267 | } | 242 | } |
| 268 | 243 | ||
| 269 | private: | 244 | private: |
| 270 | AddonCB* m_Handle; | 245 | AddonCB* m_Handle; |
| 271 | KodiAPI::V1::PVR::CB_PVRLib *m_Callbacks; | 246 | AddonInstance_PVR *m_Callbacks; |
| 272 | }; | 247 | }; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h new file mode 100644 index 0000000..fa90f77 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h | |||
| @@ -0,0 +1,436 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2016-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <string.h> | ||
| 23 | |||
| 24 | #define STR_HELPER(x) #x | ||
| 25 | #define STR(x) STR_HELPER(x) | ||
| 26 | |||
| 27 | /* | ||
| 28 | *------------------------------------------------------------------------------ | ||
| 29 | * Some parts on headers are only be used for Kodi itself and internally (not | ||
| 30 | * for add-on development). | ||
| 31 | * | ||
| 32 | * For this reason also no doxygen part with "///" defined there. | ||
| 33 | * ----------------------------------------------------------------------------- | ||
| 34 | */ | ||
| 35 | |||
| 36 | /* | ||
| 37 | * Versions of all add-on globals and instances are defined below. | ||
| 38 | * | ||
| 39 | * This is added here and not in related header to prevent not | ||
| 40 | * needed includes during compile. Also have it here a better | ||
| 41 | * overview. | ||
| 42 | */ | ||
| 43 | |||
| 44 | #define ADDON_GLOBAL_VERSION_MAIN "1.0.7" | ||
| 45 | #define ADDON_GLOBAL_VERSION_MAIN_MIN "1.0.2" | ||
| 46 | #define ADDON_GLOBAL_VERSION_MAIN_XML_ID "kodi.binary.global.main" | ||
| 47 | #define ADDON_GLOBAL_VERSION_MAIN_DEPENDS "AddonBase.h" \ | ||
| 48 | "xbmc_addon_dll.h" \ | ||
| 49 | "xbmc_addon_types.h" \ | ||
| 50 | "libXBMC_addon.h" \ | ||
| 51 | "addon-instance/" | ||
| 52 | |||
| 53 | #define ADDON_GLOBAL_VERSION_GENERAL "1.0.0" | ||
| 54 | #define ADDON_GLOBAL_VERSION_GENERAL_MIN "1.0.0" | ||
| 55 | #define ADDON_GLOBAL_VERSION_GENERAL_XML_ID "kodi.binary.global.general" | ||
| 56 | #define ADDON_GLOBAL_VERSION_GENERAL_DEPENDS "General.h" | ||
| 57 | |||
| 58 | #define ADDON_GLOBAL_VERSION_GUI "5.11.0" | ||
| 59 | #define ADDON_GLOBAL_VERSION_GUI_MIN "5.10.0" | ||
| 60 | #define ADDON_GLOBAL_VERSION_GUI_XML_ID "kodi.binary.global.gui" | ||
| 61 | #define ADDON_GLOBAL_VERSION_GUI_DEPENDS "libKODI_guilib.h" | ||
| 62 | |||
| 63 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE "1.0.0" | ||
| 64 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE_MIN "1.0.0" | ||
| 65 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE_XML_ID "kodi.binary.global.audioengine" | ||
| 66 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE_DEPENDS "AudioEngine.h" | ||
| 67 | |||
| 68 | #define ADDON_GLOBAL_VERSION_FILESYSTEM "1.0.0" | ||
| 69 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_MIN "1.0.0" | ||
| 70 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_XML_ID "kodi.binary.global.filesystem" | ||
| 71 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_DEPENDS "Filesystem.h" | ||
| 72 | |||
| 73 | #define ADDON_GLOBAL_VERSION_NETWORK "1.0.0" | ||
| 74 | #define ADDON_GLOBAL_VERSION_NETWORK_MIN "1.0.0" | ||
| 75 | #define ADDON_GLOBAL_VERSION_NETWORK_XML_ID "kodi.binary.global.network" | ||
| 76 | #define ADDON_GLOBAL_VERSION_NETWORK_DEPENDS "Network.h" | ||
| 77 | |||
| 78 | #define ADDON_INSTANCE_VERSION_ADSP "0.1.10" | ||
| 79 | #define ADDON_INSTANCE_VERSION_ADSP_MIN "0.1.10" | ||
| 80 | #define ADDON_INSTANCE_VERSION_ADSP_XML_ID "kodi.binary.instance.adsp" | ||
| 81 | #define ADDON_INSTANCE_VERSION_ADSP_DEPENDS "kodi_adsp_dll.h" \ | ||
| 82 | "kodi_adsp_types.h" \ | ||
| 83 | "libKODI_adsp.h" | ||
| 84 | |||
| 85 | #define ADDON_INSTANCE_VERSION_AUDIODECODER "1.0.1" | ||
| 86 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_MIN "1.0.1" | ||
| 87 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_XML_ID "kodi.binary.instance.audiodecoder" | ||
| 88 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_DEPENDS "kodi_audiodec_dll.h" \ | ||
| 89 | "kodi_audiodec_types.h" | ||
| 90 | |||
| 91 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER "1.0.1" | ||
| 92 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_MIN "1.0.1" | ||
| 93 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_XML_ID "kodi.binary.instance.audioencoder" | ||
| 94 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_DEPENDS "xbmc_audioenc_dll.h" \ | ||
| 95 | "xbmc_audioenc_types.h" | ||
| 96 | |||
| 97 | #define ADDON_INSTANCE_VERSION_GAME "1.0.32" | ||
| 98 | #define ADDON_INSTANCE_VERSION_GAME_MIN "1.0.32" | ||
| 99 | #define ADDON_INSTANCE_VERSION_GAME_XML_ID "kodi.binary.instance.game" | ||
| 100 | #define ADDON_INSTANCE_VERSION_GAME_DEPENDS "kodi_game_dll.h" \ | ||
| 101 | "kodi_game_types.h" \ | ||
| 102 | "libKODI_game.h" | ||
| 103 | |||
| 104 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER "1.0.1" | ||
| 105 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_MIN "1.0.1" | ||
| 106 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_XML_ID "kodi.binary.instance.imagedecoder" | ||
| 107 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_DEPENDS "kodi_imagedec_dll.h" \ | ||
| 108 | "kodi_imagedec_types.h" | ||
| 109 | |||
| 110 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM "1.0.8" | ||
| 111 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN "1.0.8" | ||
| 112 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_XML_ID "kodi.binary.instance.inputstream" | ||
| 113 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_DEPENDS "libKODI_inputstream.h" \ | ||
| 114 | "kodi_inputstream_dll.h" \ | ||
| 115 | "kodi_inputstream_types.h" | ||
| 116 | |||
| 117 | #define ADDON_INSTANCE_VERSION_PERIPHERAL "1.3.3" | ||
| 118 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_MIN "1.3.3" | ||
| 119 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_XML_ID "kodi.binary.instance.peripheral" | ||
| 120 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_DEPENDS "kodi_peripheral_dll.h" \ | ||
| 121 | "kodi_peripheral_types.h" \ | ||
| 122 | "kodi_peripheral_utils.hpp" \ | ||
| 123 | "libKODI_peripheral.h" | ||
| 124 | |||
| 125 | #define ADDON_INSTANCE_VERSION_PVR "5.2.4" | ||
| 126 | #define ADDON_INSTANCE_VERSION_PVR_MIN "5.2.4" | ||
| 127 | #define ADDON_INSTANCE_VERSION_PVR_XML_ID "kodi.binary.instance.pvr" | ||
| 128 | #define ADDON_INSTANCE_VERSION_PVR_DEPENDS "xbmc_pvr_dll.h" \ | ||
| 129 | "xbmc_pvr_types.h" \ | ||
| 130 | "xbmc_epg_types.h" \ | ||
| 131 | "libXBMC_pvr.h" | ||
| 132 | |||
| 133 | #define ADDON_INSTANCE_VERSION_SCREENSAVER "2.0.0" | ||
| 134 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_MIN "2.0.0" | ||
| 135 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_XML_ID "kodi.binary.instance.screensaver" | ||
| 136 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_DEPENDS "addon-instance/Screensaver.h" | ||
| 137 | |||
| 138 | #define ADDON_INSTANCE_VERSION_VFS "1.0.1" | ||
| 139 | #define ADDON_INSTANCE_VERSION_VFS_MIN "1.0.1" | ||
| 140 | #define ADDON_INSTANCE_VERSION_VFS_XML_ID "kodi.binary.instance.vfs" | ||
| 141 | #define ADDON_INSTANCE_VERSION_VFS_DEPENDS "kodi_vfs_dll.h" \ | ||
| 142 | "kodi_vfs_types.h" \ | ||
| 143 | "kodi_vfs_utils.hpp" | ||
| 144 | |||
| 145 | #define ADDON_INSTANCE_VERSION_VISUALIZATION "1.0.1" | ||
| 146 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_MIN "1.0.1" | ||
| 147 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_XML_ID "kodi.binary.instance.visualization" | ||
| 148 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_DEPENDS "xbmc_vis_dll.h" \ | ||
| 149 | "xbmc_vis_types.h" | ||
| 150 | |||
| 151 | /// | ||
| 152 | /// The currently available instance types for Kodi add-ons | ||
| 153 | /// | ||
| 154 | /// \internal | ||
| 155 | /// @note For add of new types take a new number on end. To change | ||
| 156 | /// existing numbers can be make problems on already compiled add-ons. | ||
| 157 | /// \endinternal | ||
| 158 | /// | ||
| 159 | typedef enum ADDON_TYPE | ||
| 160 | { | ||
| 161 | /* addon global parts */ | ||
| 162 | ADDON_GLOBAL_MAIN = 0, | ||
| 163 | ADDON_GLOBAL_GUI = 1, | ||
| 164 | ADDON_GLOBAL_AUDIOENGINE = 2, | ||
| 165 | ADDON_GLOBAL_GENERAL = 3, | ||
| 166 | ADDON_GLOBAL_NETWORK = 4, | ||
| 167 | ADDON_GLOBAL_FILESYSTEM = 5, | ||
| 168 | ADDON_GLOBAL_MAX = 5, // Last used global id, used in loops to check versions. Need to change if new global type becomes added. | ||
| 169 | |||
| 170 | /* addon type instances */ | ||
| 171 | ADDON_INSTANCE_ADSP = 101, | ||
| 172 | ADDON_INSTANCE_AUDIODECODER = 102, | ||
| 173 | ADDON_INSTANCE_AUDIOENCODER = 103, | ||
| 174 | ADDON_INSTANCE_GAME = 104, | ||
| 175 | ADDON_INSTANCE_INPUTSTREAM = 105, | ||
| 176 | ADDON_INSTANCE_PERIPHERAL = 106, | ||
| 177 | ADDON_INSTANCE_PVR = 107, | ||
| 178 | ADDON_INSTANCE_SCREENSAVER = 108, | ||
| 179 | ADDON_INSTANCE_VISUALIZATION = 109, | ||
| 180 | ADDON_INSTANCE_VFS = 110, | ||
| 181 | ADDON_INSTANCE_IMAGEDECODER = 111, | ||
| 182 | } ADDON_TYPE; | ||
| 183 | |||
| 184 | #ifdef __cplusplus | ||
| 185 | extern "C" { | ||
| 186 | namespace kodi { | ||
| 187 | namespace addon { | ||
| 188 | #endif | ||
| 189 | |||
| 190 | /// | ||
| 191 | /// This is used from Kodi to get the active version of add-on parts. | ||
| 192 | /// It is compiled in add-on and also in Kodi itself, with this can be Kodi | ||
| 193 | /// compare the version from him with them on add-on. | ||
| 194 | /// | ||
| 195 | /// @param[in] type The with 'enum ADDON_TYPE' type to ask | ||
| 196 | /// @return version The current version of asked type | ||
| 197 | /// | ||
| 198 | inline const char* GetTypeVersion(int type) | ||
| 199 | { | ||
| 200 | /* | ||
| 201 | * #ifdef's below becomes set by cmake, no set by hand needed. | ||
| 202 | */ | ||
| 203 | switch (type) | ||
| 204 | { | ||
| 205 | /* addon global parts */ | ||
| 206 | case ADDON_GLOBAL_MAIN: | ||
| 207 | return ADDON_GLOBAL_VERSION_MAIN; | ||
| 208 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_GLOBAL_VERSION_GENERAL_USED) | ||
| 209 | case ADDON_GLOBAL_GENERAL: | ||
| 210 | return ADDON_GLOBAL_VERSION_GENERAL; | ||
| 211 | #endif | ||
| 212 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_GLOBAL_VERSION_GUI_USED) | ||
| 213 | case ADDON_GLOBAL_GUI: | ||
| 214 | return ADDON_GLOBAL_VERSION_GUI; | ||
| 215 | #endif | ||
| 216 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_GLOBAL_VERSION_AUDIOENGINE_USED) | ||
| 217 | case ADDON_GLOBAL_AUDIOENGINE: | ||
| 218 | return ADDON_GLOBAL_VERSION_AUDIOENGINE; | ||
| 219 | #endif | ||
| 220 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_GLOBAL_VERSION_FILESYSTEM_USED) | ||
| 221 | case ADDON_GLOBAL_FILESYSTEM: | ||
| 222 | return ADDON_GLOBAL_VERSION_FILESYSTEM; | ||
| 223 | #endif | ||
| 224 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_GLOBAL_VERSION_NETWORK_USED) | ||
| 225 | case ADDON_GLOBAL_NETWORK: | ||
| 226 | return ADDON_GLOBAL_VERSION_NETWORK; | ||
| 227 | #endif | ||
| 228 | |||
| 229 | /* addon type instances */ | ||
| 230 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_ADSP_USED) | ||
| 231 | case ADDON_INSTANCE_ADSP: | ||
| 232 | return ADDON_INSTANCE_VERSION_ADSP; | ||
| 233 | #endif | ||
| 234 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_AUDIODECODER_USED) | ||
| 235 | case ADDON_INSTANCE_AUDIODECODER: | ||
| 236 | return ADDON_INSTANCE_VERSION_AUDIODECODER; | ||
| 237 | #endif | ||
| 238 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_AUDIOENCODER_USED) | ||
| 239 | case ADDON_INSTANCE_AUDIOENCODER: | ||
| 240 | return ADDON_INSTANCE_VERSION_AUDIOENCODER; | ||
| 241 | #endif | ||
| 242 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_GAME_USED) | ||
| 243 | case ADDON_INSTANCE_GAME: | ||
| 244 | return ADDON_INSTANCE_VERSION_GAME; | ||
| 245 | #endif | ||
| 246 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_IMAGEDECODER_USED) | ||
| 247 | case ADDON_INSTANCE_IMAGEDECODER: | ||
| 248 | return ADDON_INSTANCE_VERSION_IMAGEDECODER; | ||
| 249 | #endif | ||
| 250 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_INPUTSTREAM_USED) | ||
| 251 | case ADDON_INSTANCE_INPUTSTREAM: | ||
| 252 | return ADDON_INSTANCE_VERSION_INPUTSTREAM; | ||
| 253 | #endif | ||
| 254 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_PERIPHERAL_USED) | ||
| 255 | case ADDON_INSTANCE_PERIPHERAL: | ||
| 256 | return ADDON_INSTANCE_VERSION_PERIPHERAL; | ||
| 257 | #endif | ||
| 258 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_PVR_USED) | ||
| 259 | case ADDON_INSTANCE_PVR: | ||
| 260 | return ADDON_INSTANCE_VERSION_PVR; | ||
| 261 | #endif | ||
| 262 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_SCREENSAVER_USED) | ||
| 263 | case ADDON_INSTANCE_SCREENSAVER: | ||
| 264 | return ADDON_INSTANCE_VERSION_SCREENSAVER; | ||
| 265 | #endif | ||
| 266 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_VFS_USED) | ||
| 267 | case ADDON_INSTANCE_VFS: | ||
| 268 | return ADDON_INSTANCE_VERSION_VFS; | ||
| 269 | #endif | ||
| 270 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_VISUALIZATION_USED) | ||
| 271 | case ADDON_INSTANCE_VISUALIZATION: | ||
| 272 | return ADDON_INSTANCE_VERSION_VISUALIZATION; | ||
| 273 | #endif | ||
| 274 | } | ||
| 275 | return "0.0.0"; | ||
| 276 | } | ||
| 277 | |||
| 278 | /// | ||
| 279 | /// This is used from Kodi to get the minimum supported version of add-on parts. | ||
| 280 | /// It is compiled in add-on and also in Kodi itself, with this can be Kodi | ||
| 281 | /// compare the version from him with them on add-on. | ||
| 282 | /// | ||
| 283 | /// @param[in] type The with 'enum ADDON_TYPE' type to ask | ||
| 284 | /// @return version The minimum version of asked type | ||
| 285 | /// | ||
| 286 | inline const char* GetTypeMinVersion(int type) | ||
| 287 | { | ||
| 288 | switch (type) | ||
| 289 | { | ||
| 290 | /* addon global parts */ | ||
| 291 | case ADDON_GLOBAL_MAIN: | ||
| 292 | return ADDON_GLOBAL_VERSION_MAIN_MIN; | ||
| 293 | case ADDON_GLOBAL_GUI: | ||
| 294 | return ADDON_GLOBAL_VERSION_GUI_MIN; | ||
| 295 | case ADDON_GLOBAL_GENERAL: | ||
| 296 | return ADDON_GLOBAL_VERSION_GENERAL_MIN; | ||
| 297 | case ADDON_GLOBAL_AUDIOENGINE: | ||
| 298 | return ADDON_GLOBAL_VERSION_AUDIOENGINE_MIN; | ||
| 299 | case ADDON_GLOBAL_FILESYSTEM: | ||
| 300 | return ADDON_GLOBAL_VERSION_FILESYSTEM_MIN; | ||
| 301 | case ADDON_GLOBAL_NETWORK: | ||
| 302 | return ADDON_GLOBAL_VERSION_NETWORK_MIN; | ||
| 303 | |||
| 304 | /* addon type instances */ | ||
| 305 | case ADDON_INSTANCE_ADSP: | ||
| 306 | return ADDON_INSTANCE_VERSION_ADSP_MIN; | ||
| 307 | case ADDON_INSTANCE_AUDIODECODER: | ||
| 308 | return ADDON_INSTANCE_VERSION_AUDIODECODER_MIN; | ||
| 309 | case ADDON_INSTANCE_AUDIOENCODER: | ||
| 310 | return ADDON_INSTANCE_VERSION_AUDIOENCODER_MIN; | ||
| 311 | case ADDON_INSTANCE_GAME: | ||
| 312 | return ADDON_INSTANCE_VERSION_GAME_MIN; | ||
| 313 | case ADDON_INSTANCE_IMAGEDECODER: | ||
| 314 | return ADDON_INSTANCE_VERSION_IMAGEDECODER_MIN; | ||
| 315 | case ADDON_INSTANCE_INPUTSTREAM: | ||
| 316 | return ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN; | ||
| 317 | case ADDON_INSTANCE_PERIPHERAL: | ||
| 318 | return ADDON_INSTANCE_VERSION_PERIPHERAL_MIN; | ||
| 319 | case ADDON_INSTANCE_PVR: | ||
| 320 | return ADDON_INSTANCE_VERSION_PVR_MIN; | ||
| 321 | case ADDON_INSTANCE_SCREENSAVER: | ||
| 322 | return ADDON_INSTANCE_VERSION_SCREENSAVER_MIN; | ||
| 323 | case ADDON_INSTANCE_VFS: | ||
| 324 | return ADDON_INSTANCE_VERSION_VFS_MIN; | ||
| 325 | case ADDON_INSTANCE_VISUALIZATION: | ||
| 326 | return ADDON_INSTANCE_VERSION_VISUALIZATION_MIN; | ||
| 327 | } | ||
| 328 | return "0.0.0"; | ||
| 329 | } | ||
| 330 | |||
| 331 | /// | ||
| 332 | /// Function used internally on add-on and in Kodi itself to get name | ||
| 333 | /// about given type. | ||
| 334 | /// | ||
| 335 | /// @param[in] type The with 'enum ADDON_TYPE' defined type to ask | ||
| 336 | /// @return Name of the asked instance type | ||
| 337 | /// | ||
| 338 | inline const char* GetTypeName(int type) | ||
| 339 | { | ||
| 340 | switch (type) | ||
| 341 | { | ||
| 342 | /* addon global parts */ | ||
| 343 | case ADDON_GLOBAL_MAIN: | ||
| 344 | return "Addon"; | ||
| 345 | case ADDON_GLOBAL_GUI: | ||
| 346 | return "GUI"; | ||
| 347 | case ADDON_GLOBAL_GENERAL: | ||
| 348 | return "General"; | ||
| 349 | case ADDON_GLOBAL_AUDIOENGINE: | ||
| 350 | return "AudioEngine"; | ||
| 351 | case ADDON_GLOBAL_FILESYSTEM: | ||
| 352 | return "Filesystem"; | ||
| 353 | case ADDON_GLOBAL_NETWORK: | ||
| 354 | return "Network"; | ||
| 355 | |||
| 356 | /* addon type instances */ | ||
| 357 | case ADDON_INSTANCE_ADSP: | ||
| 358 | return "ADSP"; | ||
| 359 | case ADDON_INSTANCE_AUDIODECODER: | ||
| 360 | return "AudioDecoder"; | ||
| 361 | case ADDON_INSTANCE_AUDIOENCODER: | ||
| 362 | return "AudioEncoder"; | ||
| 363 | case ADDON_INSTANCE_GAME: | ||
| 364 | return "Game"; | ||
| 365 | case ADDON_INSTANCE_IMAGEDECODER: | ||
| 366 | return "ImageDecoder"; | ||
| 367 | case ADDON_INSTANCE_INPUTSTREAM: | ||
| 368 | return "Inputstream"; | ||
| 369 | case ADDON_INSTANCE_PERIPHERAL: | ||
| 370 | return "Peripheral"; | ||
| 371 | case ADDON_INSTANCE_PVR: | ||
| 372 | return "PVR"; | ||
| 373 | case ADDON_INSTANCE_SCREENSAVER: | ||
| 374 | return "ScreenSaver"; | ||
| 375 | case ADDON_INSTANCE_VISUALIZATION: | ||
| 376 | return "Visualization"; | ||
| 377 | } | ||
| 378 | return "unknown"; | ||
| 379 | } | ||
| 380 | |||
| 381 | /// | ||
| 382 | /// Function used internally on add-on and in Kodi itself to get id number | ||
| 383 | /// about given type name. | ||
| 384 | /// | ||
| 385 | /// @param[in] name The type name string to ask | ||
| 386 | /// @return Id number of the asked instance type | ||
| 387 | /// | ||
| 388 | /// @warning String must be lower case here! | ||
| 389 | /// | ||
| 390 | inline int GetTypeId(const char* name) | ||
| 391 | { | ||
| 392 | if (name) | ||
| 393 | { | ||
| 394 | if (strcmp(name, "addon") == 0) | ||
| 395 | return ADDON_GLOBAL_MAIN; | ||
| 396 | else if (strcmp(name, "general") == 0) | ||
| 397 | return ADDON_GLOBAL_GENERAL; | ||
| 398 | else if (strcmp(name, "gui") == 0) | ||
| 399 | return ADDON_GLOBAL_GUI; | ||
| 400 | else if (strcmp(name, "audioengine") == 0) | ||
| 401 | return ADDON_GLOBAL_AUDIOENGINE; | ||
| 402 | else if (strcmp(name, "filesystem") == 0) | ||
| 403 | return ADDON_GLOBAL_FILESYSTEM; | ||
| 404 | else if (strcmp(name, "network") == 0) | ||
| 405 | return ADDON_GLOBAL_NETWORK; | ||
| 406 | else if (strcmp(name, "adsp") == 0) | ||
| 407 | return ADDON_INSTANCE_ADSP; | ||
| 408 | else if (strcmp(name, "audiodecoder") == 0) | ||
| 409 | return ADDON_INSTANCE_AUDIODECODER; | ||
| 410 | else if (strcmp(name, "audioencoder") == 0) | ||
| 411 | return ADDON_INSTANCE_AUDIOENCODER; | ||
| 412 | else if (strcmp(name, "game") == 0) | ||
| 413 | return ADDON_INSTANCE_GAME; | ||
| 414 | else if (strcmp(name, "imagedecoder") == 0) | ||
| 415 | return ADDON_INSTANCE_IMAGEDECODER; | ||
| 416 | else if (strcmp(name, "inputstream") == 0) | ||
| 417 | return ADDON_INSTANCE_INPUTSTREAM; | ||
| 418 | else if (strcmp(name, "peripheral") == 0) | ||
| 419 | return ADDON_INSTANCE_PERIPHERAL; | ||
| 420 | else if (strcmp(name, "pvr") == 0) | ||
| 421 | return ADDON_INSTANCE_PVR; | ||
| 422 | else if (strcmp(name, "screensaver") == 0) | ||
| 423 | return ADDON_INSTANCE_SCREENSAVER; | ||
| 424 | else if (strcmp(name, "vfs") == 0) | ||
| 425 | return ADDON_INSTANCE_VFS; | ||
| 426 | else if (strcmp(name, "visualization") == 0) | ||
| 427 | return ADDON_INSTANCE_VISUALIZATION; | ||
| 428 | } | ||
| 429 | return -1; | ||
| 430 | } | ||
| 431 | |||
| 432 | #ifdef __cplusplus | ||
| 433 | } /* namespace addon */ | ||
| 434 | } /* namespace kodi */ | ||
| 435 | } /* extern "C" */ | ||
| 436 | #endif | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_cpp_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_cpp_dll.h deleted file mode 100644 index 2eb972e..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_cpp_dll.h +++ /dev/null | |||
| @@ -1,189 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (C) 2005-2015 Team Kodi | ||
| 5 | * http://kodi.tv | ||
| 6 | * | ||
| 7 | * This Program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 10 | * any later version. | ||
| 11 | * | ||
| 12 | * This Program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with Kodi; see the file COPYING. If not, see | ||
| 19 | * <http://www.gnu.org/licenses/>. | ||
| 20 | * | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include "xbmc_addon_types.h" | ||
| 24 | |||
| 25 | #include <vector> | ||
| 26 | #include <string.h> | ||
| 27 | #include <stdlib.h> | ||
| 28 | |||
| 29 | class DllSetting | ||
| 30 | { | ||
| 31 | public: | ||
| 32 | enum SETTING_TYPE { NONE=0, CHECK, SPIN }; | ||
| 33 | |||
| 34 | DllSetting(SETTING_TYPE t, const char *n, const char *l) | ||
| 35 | { | ||
| 36 | id = NULL; | ||
| 37 | label = NULL; | ||
| 38 | if (n) | ||
| 39 | { | ||
| 40 | id = new char[strlen(n)+1]; | ||
| 41 | strcpy(id, n); | ||
| 42 | } | ||
| 43 | if (l) | ||
| 44 | { | ||
| 45 | label = new char[strlen(l)+1]; | ||
| 46 | strcpy(label, l); | ||
| 47 | } | ||
| 48 | current = 0; | ||
| 49 | type = t; | ||
| 50 | } | ||
| 51 | |||
| 52 | DllSetting(const DllSetting &rhs) // copy constructor | ||
| 53 | { | ||
| 54 | id = NULL; | ||
| 55 | label = NULL; | ||
| 56 | if (rhs.id) | ||
| 57 | { | ||
| 58 | id = new char[strlen(rhs.id)+1]; | ||
| 59 | strcpy(id, rhs.id); | ||
| 60 | } | ||
| 61 | if (rhs.label) | ||
| 62 | { | ||
| 63 | label = new char[strlen(rhs.label)+1]; | ||
| 64 | strcpy(label, rhs.label); | ||
| 65 | } | ||
| 66 | current = rhs.current; | ||
| 67 | type = rhs.type; | ||
| 68 | for (unsigned int i = 0; i < rhs.entry.size(); i++) | ||
| 69 | { | ||
| 70 | char *lab = new char[strlen(rhs.entry[i]) + 1]; | ||
| 71 | strcpy(lab, rhs.entry[i]); | ||
| 72 | entry.push_back(lab); | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 76 | ~DllSetting() | ||
| 77 | { | ||
| 78 | delete[] id; | ||
| 79 | delete[] label; | ||
| 80 | for (unsigned int i=0; i < entry.size(); i++) | ||
| 81 | delete[] entry[i]; | ||
| 82 | } | ||
| 83 | |||
| 84 | void AddEntry(const char *label) | ||
| 85 | { | ||
| 86 | if (!label || type != SPIN) return; | ||
| 87 | char *lab = new char[strlen(label) + 1]; | ||
| 88 | strcpy(lab, label); | ||
| 89 | entry.push_back(lab); | ||
| 90 | } | ||
| 91 | |||
| 92 | // data members | ||
| 93 | SETTING_TYPE type; | ||
| 94 | char* id; | ||
| 95 | char* label; | ||
| 96 | int current; | ||
| 97 | std::vector<const char *> entry; | ||
| 98 | }; | ||
| 99 | |||
| 100 | class DllUtils | ||
| 101 | { | ||
| 102 | public: | ||
| 103 | |||
| 104 | static unsigned int VecToStruct(std::vector<DllSetting> &vecSet, ADDON_StructSetting*** sSet) | ||
| 105 | { | ||
| 106 | *sSet = NULL; | ||
| 107 | if (vecSet.empty()) | ||
| 108 | return 0; | ||
| 109 | |||
| 110 | unsigned int uiElements=0; | ||
| 111 | |||
| 112 | *sSet = (ADDON_StructSetting**)malloc(vecSet.size()*sizeof(ADDON_StructSetting*)); | ||
| 113 | for(unsigned int i=0;i<vecSet.size();i++) | ||
| 114 | { | ||
| 115 | (*sSet)[i] = NULL; | ||
| 116 | (*sSet)[i] = (ADDON_StructSetting*)malloc(sizeof(ADDON_StructSetting)); | ||
| 117 | (*sSet)[i]->id = NULL; | ||
| 118 | (*sSet)[i]->label = NULL; | ||
| 119 | uiElements++; | ||
| 120 | |||
| 121 | if (vecSet[i].id && vecSet[i].label) | ||
| 122 | { | ||
| 123 | (*sSet)[i]->id = strdup(vecSet[i].id); | ||
| 124 | (*sSet)[i]->label = strdup(vecSet[i].label); | ||
| 125 | (*sSet)[i]->type = vecSet[i].type; | ||
| 126 | (*sSet)[i]->current = vecSet[i].current; | ||
| 127 | (*sSet)[i]->entry_elements = 0; | ||
| 128 | (*sSet)[i]->entry = NULL; | ||
| 129 | if(vecSet[i].type == DllSetting::SPIN && !vecSet[i].entry.empty()) | ||
| 130 | { | ||
| 131 | (*sSet)[i]->entry = (char**)malloc(vecSet[i].entry.size()*sizeof(char**)); | ||
| 132 | for(unsigned int j=0;j<vecSet[i].entry.size();j++) | ||
| 133 | { | ||
| 134 | if(strlen(vecSet[i].entry[j]) > 0) | ||
| 135 | { | ||
| 136 | (*sSet)[i]->entry[j] = strdup(vecSet[i].entry[j]); | ||
| 137 | (*sSet)[i]->entry_elements++; | ||
| 138 | } | ||
| 139 | } | ||
| 140 | } | ||
| 141 | } | ||
| 142 | } | ||
| 143 | return uiElements; | ||
| 144 | } | ||
| 145 | |||
| 146 | static void StructToVec(unsigned int iElements, ADDON_StructSetting*** sSet, std::vector<DllSetting> *vecSet) | ||
| 147 | { | ||
| 148 | if(iElements == 0) | ||
| 149 | return; | ||
| 150 | |||
| 151 | vecSet->clear(); | ||
| 152 | for(unsigned int i=0;i<iElements;i++) | ||
| 153 | { | ||
| 154 | DllSetting vSet((DllSetting::SETTING_TYPE)(*sSet)[i]->type, (*sSet)[i]->id, (*sSet)[i]->label); | ||
| 155 | if((*sSet)[i]->type == DllSetting::SPIN) | ||
| 156 | { | ||
| 157 | for(unsigned int j=0;j<(*sSet)[i]->entry_elements;j++) | ||
| 158 | { | ||
| 159 | vSet.AddEntry((*sSet)[i]->entry[j]); | ||
| 160 | } | ||
| 161 | } | ||
| 162 | vSet.current = (*sSet)[i]->current; | ||
| 163 | vecSet->push_back(vSet); | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | static void FreeStruct(unsigned int iElements, ADDON_StructSetting*** sSet) | ||
| 168 | { | ||
| 169 | if(iElements == 0) | ||
| 170 | return; | ||
| 171 | |||
| 172 | for(unsigned int i=0;i<iElements;i++) | ||
| 173 | { | ||
| 174 | if((*sSet)[i]->type == DllSetting::SPIN) | ||
| 175 | { | ||
| 176 | for(unsigned int j=0;j<(*sSet)[i]->entry_elements;j++) | ||
| 177 | { | ||
| 178 | free((*sSet)[i]->entry[j]); | ||
| 179 | } | ||
| 180 | free((*sSet)[i]->entry); | ||
| 181 | } | ||
| 182 | free((*sSet)[i]->id); | ||
| 183 | free((*sSet)[i]->label); | ||
| 184 | free((*sSet)[i]); | ||
| 185 | } | ||
| 186 | free(*sSet); | ||
| 187 | } | ||
| 188 | }; | ||
| 189 | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_dll.h index e3c8785..f8247d9 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_dll.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_dll.h | |||
| @@ -20,31 +20,20 @@ | |||
| 20 | * | 20 | * |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #ifdef TARGET_WINDOWS | 23 | #include "AddonBase.h" |
| 24 | #include <windows.h> | ||
| 25 | #else | ||
| 26 | #ifndef __cdecl | ||
| 27 | #define __cdecl | ||
| 28 | #endif | ||
| 29 | #ifndef __declspec | ||
| 30 | #define __declspec(X) | ||
| 31 | #endif | ||
| 32 | #endif | ||
| 33 | |||
| 34 | #include "xbmc_addon_types.h" | ||
| 35 | 24 | ||
| 36 | #ifdef __cplusplus | 25 | #ifdef __cplusplus |
| 37 | extern "C" { | 26 | extern "C" { |
| 38 | #endif | 27 | #endif |
| 39 | 28 | ||
| 40 | ADDON_STATUS __declspec(dllexport) ADDON_Create(void *callbacks, void* props); | 29 | ADDON_STATUS __declspec(dllexport) ADDON_Create(void *callbacks, void* props); |
| 41 | void __declspec(dllexport) ADDON_Stop(); | ||
| 42 | void __declspec(dllexport) ADDON_Destroy(); | 30 | void __declspec(dllexport) ADDON_Destroy(); |
| 43 | ADDON_STATUS __declspec(dllexport) ADDON_GetStatus(); | 31 | ADDON_STATUS __declspec(dllexport) ADDON_GetStatus(); |
| 44 | bool __declspec(dllexport) ADDON_HasSettings(); | ||
| 45 | unsigned int __declspec(dllexport) ADDON_GetSettings(ADDON_StructSetting ***sSet); | ||
| 46 | ADDON_STATUS __declspec(dllexport) ADDON_SetSetting(const char *settingName, const void *settingValue); | 32 | ADDON_STATUS __declspec(dllexport) ADDON_SetSetting(const char *settingName, const void *settingValue); |
| 47 | void __declspec(dllexport) ADDON_FreeSettings(); | 33 | __declspec(dllexport) const char* ADDON_GetTypeVersion(int type) |
| 34 | { | ||
| 35 | return kodi::addon::GetTypeVersion(type); | ||
| 36 | } | ||
| 48 | 37 | ||
| 49 | #ifdef __cplusplus | 38 | #ifdef __cplusplus |
| 50 | }; | 39 | }; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_types.h index 2ceb5c5..d1e7a50 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_types.h | |||
| @@ -20,43 +20,4 @@ | |||
| 20 | * | 20 | * |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #ifdef __cplusplus | 23 | #include "AddonBase.h" // compatibility fallback |
| 24 | extern "C" { | ||
| 25 | #endif | ||
| 26 | |||
| 27 | enum ADDON_STATUS | ||
| 28 | { | ||
| 29 | ADDON_STATUS_OK, | ||
| 30 | ADDON_STATUS_LOST_CONNECTION, | ||
| 31 | ADDON_STATUS_NEED_RESTART, | ||
| 32 | ADDON_STATUS_NEED_SETTINGS, | ||
| 33 | ADDON_STATUS_UNKNOWN, | ||
| 34 | ADDON_STATUS_NEED_SAVEDSETTINGS, | ||
| 35 | ADDON_STATUS_PERMANENT_FAILURE /**< permanent failure, like failing to resolve methods */ | ||
| 36 | }; | ||
| 37 | |||
| 38 | typedef struct | ||
| 39 | { | ||
| 40 | int type; | ||
| 41 | char* id; | ||
| 42 | char* label; | ||
| 43 | int current; | ||
| 44 | char** entry; | ||
| 45 | unsigned int entry_elements; | ||
| 46 | } ADDON_StructSetting; | ||
| 47 | |||
| 48 | /*! | ||
| 49 | * @brief Handle used to return data from the PVR add-on to CPVRClient | ||
| 50 | */ | ||
| 51 | struct ADDON_HANDLE_STRUCT | ||
| 52 | { | ||
| 53 | void *callerAddress; /*!< address of the caller */ | ||
| 54 | void *dataAddress; /*!< address to store data in */ | ||
| 55 | int dataIdentifier; /*!< parameter to pass back when calling the callback */ | ||
| 56 | }; | ||
| 57 | typedef ADDON_HANDLE_STRUCT *ADDON_HANDLE; | ||
| 58 | |||
| 59 | #ifdef __cplusplus | ||
| 60 | }; | ||
| 61 | #endif | ||
| 62 | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_dll.h index 932d34f..9ba259c 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_dll.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_dll.h | |||
| @@ -46,13 +46,15 @@ extern "C" | |||
| 46 | void Free(void* context); | 46 | void Free(void* context); |
| 47 | 47 | ||
| 48 | // function to export the above structure to XBMC | 48 | // function to export the above structure to XBMC |
| 49 | void __declspec(dllexport) get_addon(struct AudioEncoder* pScr) | 49 | void __declspec(dllexport) get_addon(void* enc) |
| 50 | { | 50 | { |
| 51 | pScr->Create = Create; | 51 | AddonInstance_AudioEncoder* pScr = static_cast<AddonInstance_AudioEncoder*>(enc); |
| 52 | pScr->Start = Start; | 52 | |
| 53 | pScr->Encode = Encode; | 53 | pScr->toAddon.Create = Create; |
| 54 | pScr->Finish = Finish; | 54 | pScr->toAddon.Start = Start; |
| 55 | pScr->Free = Free; | 55 | pScr->toAddon.Encode = Encode; |
| 56 | pScr->toAddon.Finish = Finish; | ||
| 57 | pScr->toAddon.Free = Free; | ||
| 56 | }; | 58 | }; |
| 57 | }; | 59 | }; |
| 58 | 60 | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_types.h index df5164e..25142c2 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_types.h | |||
| @@ -20,9 +20,7 @@ | |||
| 20 | * | 20 | * |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #ifdef TARGET_WINDOWS | 23 | #ifndef TARGET_WINDOWS |
| 24 | #include <windows.h> | ||
| 25 | #else | ||
| 26 | #ifndef __cdecl | 24 | #ifndef __cdecl |
| 27 | #define __cdecl | 25 | #define __cdecl |
| 28 | #endif | 26 | #endif |
| @@ -31,6 +29,7 @@ | |||
| 31 | #endif | 29 | #endif |
| 32 | #endif | 30 | #endif |
| 33 | 31 | ||
| 32 | #include "xbmc_addon_types.h" | ||
| 34 | #include <stdint.h> | 33 | #include <stdint.h> |
| 35 | 34 | ||
| 36 | extern "C" | 35 | extern "C" |
| @@ -40,11 +39,6 @@ extern "C" | |||
| 40 | int dummy; | 39 | int dummy; |
| 41 | }; | 40 | }; |
| 42 | 41 | ||
| 43 | struct AUDIOENC_PROPS | ||
| 44 | { | ||
| 45 | int dummy; | ||
| 46 | }; | ||
| 47 | |||
| 48 | typedef int (*audioenc_write_callback)(void* opaque, uint8_t* data, int len); | 42 | typedef int (*audioenc_write_callback)(void* opaque, uint8_t* data, int len); |
| 49 | typedef int64_t (*audioenc_seek_callback)(void* opaque, int64_t pos, int whence); | 43 | typedef int64_t (*audioenc_seek_callback)(void* opaque, int64_t pos, int whence); |
| 50 | 44 | ||
| @@ -55,7 +49,17 @@ extern "C" | |||
| 55 | audioenc_seek_callback seek; | 49 | audioenc_seek_callback seek; |
| 56 | } audioenc_callbacks; | 50 | } audioenc_callbacks; |
| 57 | 51 | ||
| 58 | struct AudioEncoder | 52 | typedef struct AddonProps_AudioEncoder |
| 53 | { | ||
| 54 | int dummy; | ||
| 55 | } AddonProps_AudioEncoder; | ||
| 56 | |||
| 57 | typedef struct AddonToKodiFuncTable_AudioEncoder | ||
| 58 | { | ||
| 59 | KODI_HANDLE kodiInstance; | ||
| 60 | } AddonToKodiFuncTable_AudioEncoder; | ||
| 61 | |||
| 62 | typedef struct KodiToAddonFuncTable_AudioEncoder | ||
| 59 | { | 63 | { |
| 60 | /*! \brief Create encoder context | 64 | /*! \brief Create encoder context |
| 61 | \param callbacks Pointer to audioenc_callbacks structure. | 65 | \param callbacks Pointer to audioenc_callbacks structure. |
| @@ -105,6 +109,13 @@ extern "C" | |||
| 105 | \param context Encoder context to free. | 109 | \param context Encoder context to free. |
| 106 | */ | 110 | */ |
| 107 | void (__cdecl* Free)(void* context); | 111 | void (__cdecl* Free)(void* context); |
| 108 | }; | 112 | } KodiToAddonFuncTable_AudioEncoder; |
| 113 | |||
| 114 | typedef struct AddonInstance_AudioEncoder | ||
| 115 | { | ||
| 116 | AddonProps_AudioEncoder props; | ||
| 117 | AddonToKodiFuncTable_AudioEncoder toKodi; | ||
| 118 | KodiToAddonFuncTable_AudioEncoder toAddon; | ||
| 119 | } AddonInstance_AudioEncoder; | ||
| 109 | } | 120 | } |
| 110 | 121 | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h deleted file mode 100644 index b1f43f9..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h +++ /dev/null | |||
| @@ -1,55 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (C) 2005-2015 Team Kodi | ||
| 5 | * http://kodi.tv | ||
| 6 | * | ||
| 7 | * This Program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 10 | * any later version. | ||
| 11 | * | ||
| 12 | * This Program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with Kodi; see the file COPYING. If not, see | ||
| 19 | * <http://www.gnu.org/licenses/>. | ||
| 20 | * | ||
| 21 | */ | ||
| 22 | |||
| 23 | #ifdef __cplusplus | ||
| 24 | extern "C" { | ||
| 25 | #endif | ||
| 26 | |||
| 27 | /* current codec API version */ | ||
| 28 | #define KODI_CODEC_API_VERSION "1.0.0" | ||
| 29 | |||
| 30 | typedef unsigned int xbmc_codec_id_t; | ||
| 31 | |||
| 32 | typedef enum | ||
| 33 | { | ||
| 34 | XBMC_CODEC_TYPE_UNKNOWN = -1, | ||
| 35 | XBMC_CODEC_TYPE_VIDEO, | ||
| 36 | XBMC_CODEC_TYPE_AUDIO, | ||
| 37 | XBMC_CODEC_TYPE_DATA, | ||
| 38 | XBMC_CODEC_TYPE_SUBTITLE, | ||
| 39 | XBMC_CODEC_TYPE_RDS, | ||
| 40 | XBMC_CODEC_TYPE_NB | ||
| 41 | } xbmc_codec_type_t; | ||
| 42 | |||
| 43 | typedef struct | ||
| 44 | { | ||
| 45 | xbmc_codec_type_t codec_type; | ||
| 46 | xbmc_codec_id_t codec_id; | ||
| 47 | } xbmc_codec_t; | ||
| 48 | |||
| 49 | #define XBMC_INVALID_CODEC_ID 0 | ||
| 50 | #define XBMC_INVALID_CODEC { XBMC_CODEC_TYPE_UNKNOWN, XBMC_INVALID_CODEC_ID } | ||
| 51 | |||
| 52 | #ifdef __cplusplus | ||
| 53 | }; | ||
| 54 | #endif | ||
| 55 | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h index 57bb129..d504f4b 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h | |||
| @@ -34,40 +34,6 @@ extern "C" | |||
| 34 | /*! @name PVR add-on methods */ | 34 | /*! @name PVR add-on methods */ |
| 35 | //@{ | 35 | //@{ |
| 36 | /*! | 36 | /*! |
| 37 | * Get the XBMC_PVR_API_VERSION that was used to compile this add-on. | ||
| 38 | * Used to check if this add-on is compatible with XBMC. | ||
| 39 | * @return The XBMC_PVR_API_VERSION that was used to compile this add-on. | ||
| 40 | * @remarks Valid implementation required. | ||
| 41 | */ | ||
| 42 | const char* GetPVRAPIVersion(void); | ||
| 43 | |||
| 44 | /*! | ||
| 45 | * Get the XBMC_PVR_MIN_API_VERSION that was used to compile this add-on. | ||
| 46 | * Used to check if this add-on is compatible with XBMC. | ||
| 47 | * @return The XBMC_PVR_MIN_API_VERSION that was used to compile this add-on. | ||
| 48 | * @remarks Valid implementation required. | ||
| 49 | */ | ||
| 50 | const char* GetMininumPVRAPIVersion(void); | ||
| 51 | |||
| 52 | /*! | ||
| 53 | * Get the XBMC_GUI_API_VERSION that was used to compile this add-on. | ||
| 54 | * Used to check if this add-on is compatible with XBMC. | ||
| 55 | * @return The XBMC_GUI_API_VERSION that was used to compile this add-on or empty string if this add-on does not depend on Kodi GUI API. | ||
| 56 | * @remarks Valid implementation required. | ||
| 57 | * @note see libKODI_guilib.h about related parts | ||
| 58 | */ | ||
| 59 | const char* GetGUIAPIVersion(void); | ||
| 60 | |||
| 61 | /*! | ||
| 62 | * Get the XBMC_GUI_MIN_API_VERSION that was used to compile this add-on. | ||
| 63 | * Used to check if this add-on is compatible with XBMC. | ||
| 64 | * @return The XBMC_GUI_MIN_API_VERSION that was used to compile this add-on or empty string if this add-on does not depend on Kodi GUI API. | ||
| 65 | * @remarks Valid implementation required. | ||
| 66 | * @note see libKODI_guilib.h about related parts | ||
| 67 | */ | ||
| 68 | const char* GetMininumGUIAPIVersion(void); | ||
| 69 | |||
| 70 | /*! | ||
| 71 | * Get the list of features that this add-on provides. | 37 | * Get the list of features that this add-on provides. |
| 72 | * Called by XBMC to query the add-on's capabilities. | 38 | * Called by XBMC to query the add-on's capabilities. |
| 73 | * Used to check which options should be presented in the UI, which methods to call, etc. | 39 | * Used to check which options should be presented in the UI, which methods to call, etc. |
| @@ -657,98 +623,98 @@ extern "C" | |||
| 657 | 623 | ||
| 658 | /*! | 624 | /*! |
| 659 | * Called by XBMC to assign the function pointers of this add-on to pClient. | 625 | * Called by XBMC to assign the function pointers of this add-on to pClient. |
| 660 | * @param pClient The struct to assign the function pointers to. | 626 | * @param ptr The struct to assign the function pointers to. |
| 661 | */ | 627 | */ |
| 662 | void __declspec(dllexport) get_addon(struct PVRClient* pClient) | 628 | void __declspec(dllexport) get_addon(void* ptr) |
| 663 | { | 629 | { |
| 664 | pClient->GetPVRAPIVersion = GetPVRAPIVersion; | 630 | AddonInstance_PVR* pClient = static_cast<AddonInstance_PVR*>(ptr); |
| 665 | pClient->GetMininumPVRAPIVersion = GetMininumPVRAPIVersion; | 631 | |
| 666 | pClient->GetGUIAPIVersion = GetGUIAPIVersion; | 632 | pClient->toAddon.addonInstance = nullptr; // used in future |
| 667 | pClient->GetMininumGUIAPIVersion = GetMininumGUIAPIVersion; | 633 | |
| 668 | pClient->GetAddonCapabilities = GetAddonCapabilities; | 634 | pClient->toAddon.GetAddonCapabilities = GetAddonCapabilities; |
| 669 | pClient->GetStreamProperties = GetStreamProperties; | 635 | pClient->toAddon.GetStreamProperties = GetStreamProperties; |
| 670 | pClient->GetConnectionString = GetConnectionString; | 636 | pClient->toAddon.GetConnectionString = GetConnectionString; |
| 671 | pClient->GetBackendName = GetBackendName; | 637 | pClient->toAddon.GetBackendName = GetBackendName; |
| 672 | pClient->GetBackendVersion = GetBackendVersion; | 638 | pClient->toAddon.GetBackendVersion = GetBackendVersion; |
| 673 | pClient->GetDriveSpace = GetDriveSpace; | 639 | pClient->toAddon.GetDriveSpace = GetDriveSpace; |
| 674 | pClient->OpenDialogChannelScan = OpenDialogChannelScan; | 640 | pClient->toAddon.OpenDialogChannelScan = OpenDialogChannelScan; |
| 675 | pClient->MenuHook = CallMenuHook; | 641 | pClient->toAddon.MenuHook = CallMenuHook; |
| 676 | 642 | ||
| 677 | pClient->GetEpg = GetEPGForChannel; | 643 | pClient->toAddon.GetEpg = GetEPGForChannel; |
| 678 | 644 | ||
| 679 | pClient->GetChannelGroupsAmount = GetChannelGroupsAmount; | 645 | pClient->toAddon.GetChannelGroupsAmount = GetChannelGroupsAmount; |
| 680 | pClient->GetChannelGroups = GetChannelGroups; | 646 | pClient->toAddon.GetChannelGroups = GetChannelGroups; |
| 681 | pClient->GetChannelGroupMembers = GetChannelGroupMembers; | 647 | pClient->toAddon.GetChannelGroupMembers = GetChannelGroupMembers; |
| 682 | 648 | ||
| 683 | pClient->GetChannelsAmount = GetChannelsAmount; | 649 | pClient->toAddon.GetChannelsAmount = GetChannelsAmount; |
| 684 | pClient->GetChannels = GetChannels; | 650 | pClient->toAddon.GetChannels = GetChannels; |
| 685 | pClient->DeleteChannel = DeleteChannel; | 651 | pClient->toAddon.DeleteChannel = DeleteChannel; |
| 686 | pClient->RenameChannel = RenameChannel; | 652 | pClient->toAddon.RenameChannel = RenameChannel; |
| 687 | pClient->MoveChannel = MoveChannel; | 653 | pClient->toAddon.MoveChannel = MoveChannel; |
| 688 | pClient->OpenDialogChannelSettings = OpenDialogChannelSettings; | 654 | pClient->toAddon.OpenDialogChannelSettings = OpenDialogChannelSettings; |
| 689 | pClient->OpenDialogChannelAdd = OpenDialogChannelAdd; | 655 | pClient->toAddon.OpenDialogChannelAdd = OpenDialogChannelAdd; |
| 690 | 656 | ||
| 691 | pClient->GetRecordingsAmount = GetRecordingsAmount; | 657 | pClient->toAddon.GetRecordingsAmount = GetRecordingsAmount; |
| 692 | pClient->GetRecordings = GetRecordings; | 658 | pClient->toAddon.GetRecordings = GetRecordings; |
| 693 | pClient->DeleteRecording = DeleteRecording; | 659 | pClient->toAddon.DeleteRecording = DeleteRecording; |
| 694 | pClient->UndeleteRecording = UndeleteRecording; | 660 | pClient->toAddon.UndeleteRecording = UndeleteRecording; |
| 695 | pClient->DeleteAllRecordingsFromTrash = DeleteAllRecordingsFromTrash; | 661 | pClient->toAddon.DeleteAllRecordingsFromTrash = DeleteAllRecordingsFromTrash; |
| 696 | pClient->RenameRecording = RenameRecording; | 662 | pClient->toAddon.RenameRecording = RenameRecording; |
| 697 | pClient->SetRecordingPlayCount = SetRecordingPlayCount; | 663 | pClient->toAddon.SetRecordingPlayCount = SetRecordingPlayCount; |
| 698 | pClient->SetRecordingLastPlayedPosition = SetRecordingLastPlayedPosition; | 664 | pClient->toAddon.SetRecordingLastPlayedPosition = SetRecordingLastPlayedPosition; |
| 699 | pClient->GetRecordingLastPlayedPosition = GetRecordingLastPlayedPosition; | 665 | pClient->toAddon.GetRecordingLastPlayedPosition = GetRecordingLastPlayedPosition; |
| 700 | pClient->GetRecordingEdl = GetRecordingEdl; | 666 | pClient->toAddon.GetRecordingEdl = GetRecordingEdl; |
| 701 | 667 | ||
| 702 | pClient->GetTimerTypes = GetTimerTypes; | 668 | pClient->toAddon.GetTimerTypes = GetTimerTypes; |
| 703 | pClient->GetTimersAmount = GetTimersAmount; | 669 | pClient->toAddon.GetTimersAmount = GetTimersAmount; |
| 704 | pClient->GetTimers = GetTimers; | 670 | pClient->toAddon.GetTimers = GetTimers; |
| 705 | pClient->AddTimer = AddTimer; | 671 | pClient->toAddon.AddTimer = AddTimer; |
| 706 | pClient->DeleteTimer = DeleteTimer; | 672 | pClient->toAddon.DeleteTimer = DeleteTimer; |
| 707 | pClient->UpdateTimer = UpdateTimer; | 673 | pClient->toAddon.UpdateTimer = UpdateTimer; |
| 708 | 674 | ||
| 709 | pClient->OpenLiveStream = OpenLiveStream; | 675 | pClient->toAddon.OpenLiveStream = OpenLiveStream; |
| 710 | pClient->CloseLiveStream = CloseLiveStream; | 676 | pClient->toAddon.CloseLiveStream = CloseLiveStream; |
| 711 | pClient->ReadLiveStream = ReadLiveStream; | 677 | pClient->toAddon.ReadLiveStream = ReadLiveStream; |
| 712 | pClient->SeekLiveStream = SeekLiveStream; | 678 | pClient->toAddon.SeekLiveStream = SeekLiveStream; |
| 713 | pClient->PositionLiveStream = PositionLiveStream; | 679 | pClient->toAddon.PositionLiveStream = PositionLiveStream; |
| 714 | pClient->LengthLiveStream = LengthLiveStream; | 680 | pClient->toAddon.LengthLiveStream = LengthLiveStream; |
| 715 | pClient->SwitchChannel = SwitchChannel; | 681 | pClient->toAddon.SwitchChannel = SwitchChannel; |
| 716 | pClient->SignalStatus = SignalStatus; | 682 | pClient->toAddon.SignalStatus = SignalStatus; |
| 717 | pClient->GetLiveStreamURL = GetLiveStreamURL; | 683 | pClient->toAddon.GetLiveStreamURL = GetLiveStreamURL; |
| 718 | pClient->GetChannelSwitchDelay = GetChannelSwitchDelay; | 684 | pClient->toAddon.GetChannelSwitchDelay = GetChannelSwitchDelay; |
| 719 | pClient->CanPauseStream = CanPauseStream; | 685 | pClient->toAddon.CanPauseStream = CanPauseStream; |
| 720 | pClient->PauseStream = PauseStream; | 686 | pClient->toAddon.PauseStream = PauseStream; |
| 721 | pClient->CanSeekStream = CanSeekStream; | 687 | pClient->toAddon.CanSeekStream = CanSeekStream; |
| 722 | pClient->SeekTime = SeekTime; | 688 | pClient->toAddon.SeekTime = SeekTime; |
| 723 | pClient->SetSpeed = SetSpeed; | 689 | pClient->toAddon.SetSpeed = SetSpeed; |
| 724 | 690 | ||
| 725 | pClient->OpenRecordedStream = OpenRecordedStream; | 691 | pClient->toAddon.OpenRecordedStream = OpenRecordedStream; |
| 726 | pClient->CloseRecordedStream = CloseRecordedStream; | 692 | pClient->toAddon.CloseRecordedStream = CloseRecordedStream; |
| 727 | pClient->ReadRecordedStream = ReadRecordedStream; | 693 | pClient->toAddon.ReadRecordedStream = ReadRecordedStream; |
| 728 | pClient->SeekRecordedStream = SeekRecordedStream; | 694 | pClient->toAddon.SeekRecordedStream = SeekRecordedStream; |
| 729 | pClient->PositionRecordedStream = PositionRecordedStream; | 695 | pClient->toAddon.PositionRecordedStream = PositionRecordedStream; |
| 730 | pClient->LengthRecordedStream = LengthRecordedStream; | 696 | pClient->toAddon.LengthRecordedStream = LengthRecordedStream; |
| 731 | 697 | ||
| 732 | pClient->DemuxReset = DemuxReset; | 698 | pClient->toAddon.DemuxReset = DemuxReset; |
| 733 | pClient->DemuxAbort = DemuxAbort; | 699 | pClient->toAddon.DemuxAbort = DemuxAbort; |
| 734 | pClient->DemuxFlush = DemuxFlush; | 700 | pClient->toAddon.DemuxFlush = DemuxFlush; |
| 735 | pClient->DemuxRead = DemuxRead; | 701 | pClient->toAddon.DemuxRead = DemuxRead; |
| 736 | 702 | ||
| 737 | pClient->GetPlayingTime = GetPlayingTime; | 703 | pClient->toAddon.GetPlayingTime = GetPlayingTime; |
| 738 | pClient->GetBufferTimeStart = GetBufferTimeStart; | 704 | pClient->toAddon.GetBufferTimeStart = GetBufferTimeStart; |
| 739 | pClient->GetBufferTimeEnd = GetBufferTimeEnd; | 705 | pClient->toAddon.GetBufferTimeEnd = GetBufferTimeEnd; |
| 740 | 706 | ||
| 741 | pClient->GetBackendHostname = GetBackendHostname; | 707 | pClient->toAddon.GetBackendHostname = GetBackendHostname; |
| 742 | 708 | ||
| 743 | pClient->IsTimeshifting = IsTimeshifting; | 709 | pClient->toAddon.IsTimeshifting = IsTimeshifting; |
| 744 | pClient->IsRealTimeStream = IsRealTimeStream; | 710 | pClient->toAddon.IsRealTimeStream = IsRealTimeStream; |
| 745 | 711 | ||
| 746 | pClient->SetEPGTimeFrame = SetEPGTimeFrame; | 712 | pClient->toAddon.SetEPGTimeFrame = SetEPGTimeFrame; |
| 747 | 713 | ||
| 748 | pClient->OnSystemSleep = OnSystemSleep; | 714 | pClient->toAddon.OnSystemSleep = OnSystemSleep; |
| 749 | pClient->OnSystemWake = OnSystemWake; | 715 | pClient->toAddon.OnSystemWake = OnSystemWake; |
| 750 | pClient->OnPowerSavingActivated = OnPowerSavingActivated; | 716 | pClient->toAddon.OnPowerSavingActivated = OnPowerSavingActivated; |
| 751 | pClient->OnPowerSavingDeactivated = OnPowerSavingDeactivated; | 717 | pClient->toAddon.OnPowerSavingDeactivated = OnPowerSavingDeactivated; |
| 752 | }; | 718 | }; |
| 753 | }; | 719 | }; |
| 754 | 720 | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h index dbc7217..f3a4ccf 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h | |||
| @@ -20,9 +20,7 @@ | |||
| 20 | * | 20 | * |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #ifdef TARGET_WINDOWS | 23 | #ifndef TARGET_WINDOWS |
| 24 | #include <windows.h> | ||
| 25 | #else | ||
| 26 | #ifndef __cdecl | 24 | #ifndef __cdecl |
| 27 | #define __cdecl | 25 | #define __cdecl |
| 28 | #endif | 26 | #endif |
| @@ -36,7 +34,6 @@ | |||
| 36 | 34 | ||
| 37 | #include "xbmc_addon_types.h" | 35 | #include "xbmc_addon_types.h" |
| 38 | #include "xbmc_epg_types.h" | 36 | #include "xbmc_epg_types.h" |
| 39 | #include "xbmc_codec_types.h" | ||
| 40 | 37 | ||
| 41 | /*! @note Define "USE_DEMUX" at compile time if demuxing in the PVR add-on is used. | 38 | /*! @note Define "USE_DEMUX" at compile time if demuxing in the PVR add-on is used. |
| 42 | * Also XBMC's "DVDDemuxPacket.h" file must be in the include path of the add-on, | 39 | * Also XBMC's "DVDDemuxPacket.h" file must be in the include path of the add-on, |
| @@ -74,19 +71,35 @@ struct DemuxPacket; | |||
| 74 | #define PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE_SMALL 128 | 71 | #define PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE_SMALL 128 |
| 75 | #define PVR_ADDON_TIMERTYPE_STRING_LENGTH 64 | 72 | #define PVR_ADDON_TIMERTYPE_STRING_LENGTH 64 |
| 76 | 73 | ||
| 74 | #define XBMC_INVALID_CODEC_ID 0 | ||
| 75 | #define XBMC_INVALID_CODEC { XBMC_CODEC_TYPE_UNKNOWN, XBMC_INVALID_CODEC_ID } | ||
| 76 | |||
| 77 | /* using the default avformat's MAX_STREAMS value to be safe */ | 77 | /* using the default avformat's MAX_STREAMS value to be safe */ |
| 78 | #define PVR_STREAM_MAX_STREAMS 20 | 78 | #define PVR_STREAM_MAX_STREAMS 20 |
| 79 | 79 | ||
| 80 | /* current PVR API version */ | ||
| 81 | #define XBMC_PVR_API_VERSION "5.2.1" | ||
| 82 | |||
| 83 | /* min. PVR API version */ | ||
| 84 | #define XBMC_PVR_MIN_API_VERSION "5.2.1" | ||
| 85 | |||
| 86 | #ifdef __cplusplus | 80 | #ifdef __cplusplus |
| 87 | extern "C" { | 81 | extern "C" { |
| 88 | #endif | 82 | #endif |
| 89 | 83 | ||
| 84 | typedef unsigned int xbmc_codec_id_t; | ||
| 85 | |||
| 86 | typedef enum | ||
| 87 | { | ||
| 88 | XBMC_CODEC_TYPE_UNKNOWN = -1, | ||
| 89 | XBMC_CODEC_TYPE_VIDEO, | ||
| 90 | XBMC_CODEC_TYPE_AUDIO, | ||
| 91 | XBMC_CODEC_TYPE_DATA, | ||
| 92 | XBMC_CODEC_TYPE_SUBTITLE, | ||
| 93 | XBMC_CODEC_TYPE_RDS, | ||
| 94 | XBMC_CODEC_TYPE_NB | ||
| 95 | } xbmc_codec_type_t; | ||
| 96 | |||
| 97 | typedef struct | ||
| 98 | { | ||
| 99 | xbmc_codec_type_t codec_type; | ||
| 100 | xbmc_codec_id_t codec_id; | ||
| 101 | } xbmc_codec_t; | ||
| 102 | |||
| 90 | /*! | 103 | /*! |
| 91 | * @brief numeric PVR timer type definitions (PVR_TIMER.iTimerType values) | 104 | * @brief numeric PVR timer type definitions (PVR_TIMER.iTimerType values) |
| 92 | */ | 105 | */ |
| @@ -122,7 +135,7 @@ extern "C" { | |||
| 122 | const unsigned int PVR_TIMER_TYPE_IS_READONLY = 0x00000004; /*!< @brief timers of this type must not be edited by Kodi */ | 135 | const unsigned int PVR_TIMER_TYPE_IS_READONLY = 0x00000004; /*!< @brief timers of this type must not be edited by Kodi */ |
| 123 | const unsigned int PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES = 0x00000008; /*!< @brief timers of this type must not be created by Kodi. All other operations are allowed, though */ | 136 | const unsigned int PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES = 0x00000008; /*!< @brief timers of this type must not be created by Kodi. All other operations are allowed, though */ |
| 124 | 137 | ||
| 125 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE = 0x00000010; /*!< @brief this type supports enabling/disabling of the timer (PVR_TIMER.state SCHEDULED|DISBALED) */ | 138 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE = 0x00000010; /*!< @brief this type supports enabling/disabling of the timer (PVR_TIMER.state SCHEDULED|DISABLED) */ |
| 126 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_CHANNELS = 0x00000020; /*!< @brief this type supports channels (PVR_TIMER.iClientChannelUid) */ | 139 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_CHANNELS = 0x00000020; /*!< @brief this type supports channels (PVR_TIMER.iClientChannelUid) */ |
| 127 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_START_TIME = 0x00000040; /*!< @brief this type supports a recording start time (PVR_TIMER.startTime) */ | 140 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_START_TIME = 0x00000040; /*!< @brief this type supports a recording start time (PVR_TIMER.startTime) */ |
| 128 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH = 0x00000080; /*!< @brief this type supports matching epg episode title using PVR_TIMER.strEpgSearchString */ | 141 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH = 0x00000080; /*!< @brief this type supports matching epg episode title using PVR_TIMER.strEpgSearchString */ |
| @@ -166,7 +179,7 @@ extern "C" { | |||
| 166 | /*! | 179 | /*! |
| 167 | * @brief special PVR_TIMER.iClientChannelUid and PVR_RECORDING.iChannelUid value to indicate that no channel uid is available. | 180 | * @brief special PVR_TIMER.iClientChannelUid and PVR_RECORDING.iChannelUid value to indicate that no channel uid is available. |
| 168 | */ | 181 | */ |
| 169 | const int PVR_CHANNEL_INVALID_UID = -1; /*!< @brief denotes that no channel uid is avaliable. */ | 182 | const int PVR_CHANNEL_INVALID_UID = -1; /*!< @brief denotes that no channel uid is available. */ |
| 170 | 183 | ||
| 171 | /*! | 184 | /*! |
| 172 | * @brief PVR add-on error codes | 185 | * @brief PVR add-on error codes |
| @@ -254,7 +267,7 @@ extern "C" { | |||
| 254 | 267 | ||
| 255 | /*! | 268 | /*! |
| 256 | * @brief PVR add-on capabilities. All capabilities are set to "false" as default. | 269 | * @brief PVR add-on capabilities. All capabilities are set to "false" as default. |
| 257 | * If a capabilty is set to true, then the corresponding methods from xbmc_pvr_dll.h need to be implemented. | 270 | * If a capability is set to true, then the corresponding methods from xbmc_pvr_dll.h need to be implemented. |
| 258 | */ | 271 | */ |
| 259 | typedef struct PVR_ADDON_CAPABILITIES | 272 | typedef struct PVR_ADDON_CAPABILITIES |
| 260 | { | 273 | { |
| @@ -500,7 +513,7 @@ extern "C" { | |||
| 500 | */ | 513 | */ |
| 501 | typedef enum | 514 | typedef enum |
| 502 | { | 515 | { |
| 503 | PVR_EDL_TYPE_CUT = 0, /*!< @brief cut (completly remove content) */ | 516 | PVR_EDL_TYPE_CUT = 0, /*!< @brief cut (completely remove content) */ |
| 504 | PVR_EDL_TYPE_MUTE = 1, /*!< @brief mute audio */ | 517 | PVR_EDL_TYPE_MUTE = 1, /*!< @brief mute audio */ |
| 505 | PVR_EDL_TYPE_SCENE = 2, /*!< @brief scene markers (chapter seeking) */ | 518 | PVR_EDL_TYPE_SCENE = 2, /*!< @brief scene markers (chapter seeking) */ |
| 506 | PVR_EDL_TYPE_COMBREAK = 3 /*!< @brief commercial breaks */ | 519 | PVR_EDL_TYPE_COMBREAK = 3 /*!< @brief commercial breaks */ |
| @@ -527,87 +540,120 @@ extern "C" { | |||
| 527 | } data; | 540 | } data; |
| 528 | } ATTRIBUTE_PACKED PVR_MENUHOOK_DATA; | 541 | } ATTRIBUTE_PACKED PVR_MENUHOOK_DATA; |
| 529 | 542 | ||
| 543 | typedef struct AddonToKodiFuncTable_PVR | ||
| 544 | { | ||
| 545 | KODI_HANDLE kodiInstance; | ||
| 546 | |||
| 547 | void (*TransferEpgEntry)(void* kodiInstance, const ADDON_HANDLE handle, const EPG_TAG *epgentry); | ||
| 548 | void (*TransferChannelEntry)(void* kodiInstance, const ADDON_HANDLE handle, const PVR_CHANNEL *chan); | ||
| 549 | void (*TransferTimerEntry)(void* kodiInstance, const ADDON_HANDLE handle, const PVR_TIMER *timer); | ||
| 550 | void (*TransferRecordingEntry)(void* kodiInstance, const ADDON_HANDLE handle, const PVR_RECORDING *recording); | ||
| 551 | void (*AddMenuHook)(void* kodiInstance, PVR_MENUHOOK *hook); | ||
| 552 | void (*Recording)(void* kodiInstance, const char *Name, const char *FileName, bool On); | ||
| 553 | void (*TriggerChannelUpdate)(void* kodiInstance); | ||
| 554 | void (*TriggerTimerUpdate)(void* kodiInstance); | ||
| 555 | void (*TriggerRecordingUpdate)(void* kodiInstance); | ||
| 556 | void (*TriggerChannelGroupsUpdate)(void* kodiInstance); | ||
| 557 | void (*TriggerEpgUpdate)(void* kodiInstance, unsigned int iChannelUid); | ||
| 558 | |||
| 559 | void (*TransferChannelGroup)(void* kodiInstance, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP *group); | ||
| 560 | void (*TransferChannelGroupMember)(void* kodiInstance, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER *member); | ||
| 561 | |||
| 562 | void (*FreeDemuxPacket)(void* kodiInstance, DemuxPacket* pPacket); | ||
| 563 | DemuxPacket* (*AllocateDemuxPacket)(void* kodiInstance, int iDataSize); | ||
| 564 | |||
| 565 | void (*ConnectionStateChange)(void* kodiInstance, const char* strConnectionString, PVR_CONNECTION_STATE newState, const char *strMessage); | ||
| 566 | void (*EpgEventStateChange)(void* kodiInstance, EPG_TAG* tag, unsigned int iUniqueChannelId, EPG_EVENT_STATE newState); | ||
| 567 | |||
| 568 | xbmc_codec_t (*GetCodecByName)(const void* kodiInstance, const char* strCodecName); | ||
| 569 | } AddonToKodiFuncTable_PVR; | ||
| 570 | |||
| 530 | /*! | 571 | /*! |
| 531 | * @brief Structure to transfer the methods from xbmc_pvr_dll.h to XBMC | 572 | * @brief Structure to transfer the methods from xbmc_pvr_dll.h to XBMC |
| 532 | */ | 573 | */ |
| 533 | typedef struct PVRClient | 574 | typedef struct KodiToAddonFuncTable_PVR |
| 534 | { | 575 | { |
| 535 | const char* (__cdecl* GetPVRAPIVersion)(void); | 576 | KODI_HANDLE addonInstance; |
| 536 | const char* (__cdecl* GetMininumPVRAPIVersion)(void); | 577 | |
| 537 | const char* (__cdecl* GetGUIAPIVersion)(void); | 578 | PVR_ERROR (__cdecl* GetAddonCapabilities)(PVR_ADDON_CAPABILITIES*); |
| 538 | const char* (__cdecl* GetMininumGUIAPIVersion)(void); | 579 | PVR_ERROR (__cdecl* GetStreamProperties)(PVR_STREAM_PROPERTIES*); |
| 539 | PVR_ERROR (__cdecl* GetAddonCapabilities)(PVR_ADDON_CAPABILITIES*); | 580 | const char* (__cdecl* GetBackendName)(void); |
| 540 | PVR_ERROR (__cdecl* GetStreamProperties)(PVR_STREAM_PROPERTIES*); | 581 | const char* (__cdecl* GetBackendVersion)(void); |
| 541 | const char* (__cdecl* GetBackendName)(void); | 582 | const char* (__cdecl* GetConnectionString)(void); |
| 542 | const char* (__cdecl* GetBackendVersion)(void); | 583 | PVR_ERROR (__cdecl* GetDriveSpace)(long long*, long long*); |
| 543 | const char* (__cdecl* GetConnectionString)(void); | 584 | PVR_ERROR (__cdecl* MenuHook)(const PVR_MENUHOOK&, const PVR_MENUHOOK_DATA&); |
| 544 | PVR_ERROR (__cdecl* GetDriveSpace)(long long*, long long*); | 585 | PVR_ERROR (__cdecl* GetEpg)(ADDON_HANDLE, const PVR_CHANNEL&, time_t, time_t); |
| 545 | PVR_ERROR (__cdecl* MenuHook)(const PVR_MENUHOOK&, const PVR_MENUHOOK_DATA&); | 586 | int (__cdecl* GetChannelGroupsAmount)(void); |
| 546 | PVR_ERROR (__cdecl* GetEpg)(ADDON_HANDLE, const PVR_CHANNEL&, time_t, time_t); | 587 | PVR_ERROR (__cdecl* GetChannelGroups)(ADDON_HANDLE, bool); |
| 547 | int (__cdecl* GetChannelGroupsAmount)(void); | 588 | PVR_ERROR (__cdecl* GetChannelGroupMembers)(ADDON_HANDLE, const PVR_CHANNEL_GROUP&); |
| 548 | PVR_ERROR (__cdecl* GetChannelGroups)(ADDON_HANDLE, bool); | 589 | PVR_ERROR (__cdecl* OpenDialogChannelScan)(void); |
| 549 | PVR_ERROR (__cdecl* GetChannelGroupMembers)(ADDON_HANDLE, const PVR_CHANNEL_GROUP&); | 590 | int (__cdecl* GetChannelsAmount)(void); |
| 550 | PVR_ERROR (__cdecl* OpenDialogChannelScan)(void); | 591 | PVR_ERROR (__cdecl* GetChannels)(ADDON_HANDLE, bool); |
| 551 | int (__cdecl* GetChannelsAmount)(void); | 592 | PVR_ERROR (__cdecl* DeleteChannel)(const PVR_CHANNEL&); |
| 552 | PVR_ERROR (__cdecl* GetChannels)(ADDON_HANDLE, bool); | 593 | PVR_ERROR (__cdecl* RenameChannel)(const PVR_CHANNEL&); |
| 553 | PVR_ERROR (__cdecl* DeleteChannel)(const PVR_CHANNEL&); | 594 | PVR_ERROR (__cdecl* MoveChannel)(const PVR_CHANNEL&); |
| 554 | PVR_ERROR (__cdecl* RenameChannel)(const PVR_CHANNEL&); | 595 | PVR_ERROR (__cdecl* OpenDialogChannelSettings)(const PVR_CHANNEL&); |
| 555 | PVR_ERROR (__cdecl* MoveChannel)(const PVR_CHANNEL&); | 596 | PVR_ERROR (__cdecl* OpenDialogChannelAdd)(const PVR_CHANNEL&); |
| 556 | PVR_ERROR (__cdecl* OpenDialogChannelSettings)(const PVR_CHANNEL&); | 597 | int (__cdecl* GetRecordingsAmount)(bool); |
| 557 | PVR_ERROR (__cdecl* OpenDialogChannelAdd)(const PVR_CHANNEL&); | 598 | PVR_ERROR (__cdecl* GetRecordings)(ADDON_HANDLE, bool); |
| 558 | int (__cdecl* GetRecordingsAmount)(bool); | 599 | PVR_ERROR (__cdecl* DeleteRecording)(const PVR_RECORDING&); |
| 559 | PVR_ERROR (__cdecl* GetRecordings)(ADDON_HANDLE, bool); | 600 | PVR_ERROR (__cdecl* UndeleteRecording)(const PVR_RECORDING&); |
| 560 | PVR_ERROR (__cdecl* DeleteRecording)(const PVR_RECORDING&); | 601 | PVR_ERROR (__cdecl* DeleteAllRecordingsFromTrash)(void); |
| 561 | PVR_ERROR (__cdecl* UndeleteRecording)(const PVR_RECORDING&); | 602 | PVR_ERROR (__cdecl* RenameRecording)(const PVR_RECORDING&); |
| 562 | PVR_ERROR (__cdecl* DeleteAllRecordingsFromTrash)(void); | 603 | PVR_ERROR (__cdecl* SetRecordingPlayCount)(const PVR_RECORDING&, int); |
| 563 | PVR_ERROR (__cdecl* RenameRecording)(const PVR_RECORDING&); | 604 | PVR_ERROR (__cdecl* SetRecordingLastPlayedPosition)(const PVR_RECORDING&, int); |
| 564 | PVR_ERROR (__cdecl* SetRecordingPlayCount)(const PVR_RECORDING&, int); | 605 | int (__cdecl* GetRecordingLastPlayedPosition)(const PVR_RECORDING&); |
| 565 | PVR_ERROR (__cdecl* SetRecordingLastPlayedPosition)(const PVR_RECORDING&, int); | 606 | PVR_ERROR (__cdecl* GetRecordingEdl)(const PVR_RECORDING&, PVR_EDL_ENTRY[], int*); |
| 566 | int (__cdecl* GetRecordingLastPlayedPosition)(const PVR_RECORDING&); | 607 | PVR_ERROR (__cdecl* GetTimerTypes)(PVR_TIMER_TYPE[], int*); |
| 567 | PVR_ERROR (__cdecl* GetRecordingEdl)(const PVR_RECORDING&, PVR_EDL_ENTRY[], int*); | 608 | int (__cdecl* GetTimersAmount)(void); |
| 568 | PVR_ERROR (__cdecl* GetTimerTypes)(PVR_TIMER_TYPE[], int*); | 609 | PVR_ERROR (__cdecl* GetTimers)(ADDON_HANDLE); |
| 569 | int (__cdecl* GetTimersAmount)(void); | 610 | PVR_ERROR (__cdecl* AddTimer)(const PVR_TIMER&); |
| 570 | PVR_ERROR (__cdecl* GetTimers)(ADDON_HANDLE); | 611 | PVR_ERROR (__cdecl* DeleteTimer)(const PVR_TIMER&, bool); |
| 571 | PVR_ERROR (__cdecl* AddTimer)(const PVR_TIMER&); | 612 | PVR_ERROR (__cdecl* UpdateTimer)(const PVR_TIMER&); |
| 572 | PVR_ERROR (__cdecl* DeleteTimer)(const PVR_TIMER&, bool); | 613 | bool (__cdecl* OpenLiveStream)(const PVR_CHANNEL&); |
| 573 | PVR_ERROR (__cdecl* UpdateTimer)(const PVR_TIMER&); | 614 | void (__cdecl* CloseLiveStream)(void); |
| 574 | bool (__cdecl* OpenLiveStream)(const PVR_CHANNEL&); | 615 | int (__cdecl* ReadLiveStream)(unsigned char*, unsigned int); |
| 575 | void (__cdecl* CloseLiveStream)(void); | 616 | long long (__cdecl* SeekLiveStream)(long long, int); |
| 576 | int (__cdecl* ReadLiveStream)(unsigned char*, unsigned int); | 617 | long long (__cdecl* PositionLiveStream)(void); |
| 577 | long long (__cdecl* SeekLiveStream)(long long, int); | 618 | long long (__cdecl* LengthLiveStream)(void); |
| 578 | long long (__cdecl* PositionLiveStream)(void); | 619 | bool (__cdecl* SwitchChannel)(const PVR_CHANNEL&); |
| 579 | long long (__cdecl* LengthLiveStream)(void); | 620 | PVR_ERROR (__cdecl* SignalStatus)(PVR_SIGNAL_STATUS&); |
| 580 | bool (__cdecl* SwitchChannel)(const PVR_CHANNEL&); | ||
| 581 | PVR_ERROR (__cdecl* SignalStatus)(PVR_SIGNAL_STATUS&); | ||
| 582 | const char* (__cdecl* GetLiveStreamURL)(const PVR_CHANNEL&); | 621 | const char* (__cdecl* GetLiveStreamURL)(const PVR_CHANNEL&); |
| 583 | bool (__cdecl* OpenRecordedStream)(const PVR_RECORDING&); | 622 | bool (__cdecl* OpenRecordedStream)(const PVR_RECORDING&); |
| 584 | void (__cdecl* CloseRecordedStream)(void); | 623 | void (__cdecl* CloseRecordedStream)(void); |
| 585 | int (__cdecl* ReadRecordedStream)(unsigned char*, unsigned int); | 624 | int (__cdecl* ReadRecordedStream)(unsigned char*, unsigned int); |
| 586 | long long (__cdecl* SeekRecordedStream)(long long, int); | 625 | long long (__cdecl* SeekRecordedStream)(long long, int); |
| 587 | long long (__cdecl* PositionRecordedStream)(void); | 626 | long long (__cdecl* PositionRecordedStream)(void); |
| 588 | long long (__cdecl* LengthRecordedStream)(void); | 627 | long long (__cdecl* LengthRecordedStream)(void); |
| 589 | void (__cdecl* DemuxReset)(void); | 628 | void (__cdecl* DemuxReset)(void); |
| 590 | void (__cdecl* DemuxAbort)(void); | 629 | void (__cdecl* DemuxAbort)(void); |
| 591 | void (__cdecl* DemuxFlush)(void); | 630 | void (__cdecl* DemuxFlush)(void); |
| 592 | DemuxPacket* (__cdecl* DemuxRead)(void); | 631 | DemuxPacket* (__cdecl* DemuxRead)(void); |
| 593 | unsigned int (__cdecl* GetChannelSwitchDelay)(void); | 632 | unsigned int (__cdecl* GetChannelSwitchDelay)(void); |
| 594 | bool (__cdecl* CanPauseStream)(void); | 633 | bool (__cdecl* CanPauseStream)(void); |
| 595 | void (__cdecl* PauseStream)(bool); | 634 | void (__cdecl* PauseStream)(bool); |
| 596 | bool (__cdecl* CanSeekStream)(void); | 635 | bool (__cdecl* CanSeekStream)(void); |
| 597 | bool (__cdecl* SeekTime)(double, bool, double*); | 636 | bool (__cdecl* SeekTime)(double, bool, double*); |
| 598 | void (__cdecl* SetSpeed)(int); | 637 | void (__cdecl* SetSpeed)(int); |
| 599 | time_t (__cdecl* GetPlayingTime)(void); | 638 | time_t (__cdecl* GetPlayingTime)(void); |
| 600 | time_t (__cdecl* GetBufferTimeStart)(void); | 639 | time_t (__cdecl* GetBufferTimeStart)(void); |
| 601 | time_t (__cdecl* GetBufferTimeEnd)(void); | 640 | time_t (__cdecl* GetBufferTimeEnd)(void); |
| 602 | const char* (__cdecl* GetBackendHostname)(void); | 641 | const char* (__cdecl* GetBackendHostname)(void); |
| 603 | bool (__cdecl* IsTimeshifting)(void); | 642 | bool (__cdecl* IsTimeshifting)(void); |
| 604 | bool (__cdecl* IsRealTimeStream)(void); | 643 | bool (__cdecl* IsRealTimeStream)(void); |
| 605 | PVR_ERROR (__cdecl* SetEPGTimeFrame)(int); | 644 | PVR_ERROR (__cdecl* SetEPGTimeFrame)(int); |
| 606 | void (__cdecl* OnSystemSleep)(void); | 645 | void (__cdecl* OnSystemSleep)(void); |
| 607 | void (__cdecl* OnSystemWake)(void); | 646 | void (__cdecl* OnSystemWake)(void); |
| 608 | void (__cdecl* OnPowerSavingActivated)(void); | 647 | void (__cdecl* OnPowerSavingActivated)(void); |
| 609 | void (__cdecl* OnPowerSavingDeactivated)(void); | 648 | void (__cdecl* OnPowerSavingDeactivated)(void); |
| 610 | } PVRClient; | 649 | } KodiToAddonFuncTable_PVR; |
| 650 | |||
| 651 | typedef struct AddonInstance_PVR | ||
| 652 | { | ||
| 653 | PVR_PROPERTIES props; | ||
| 654 | AddonToKodiFuncTable_PVR toKodi; | ||
| 655 | KodiToAddonFuncTable_PVR toAddon; | ||
| 656 | } AddonInstance_PVR; | ||
| 611 | 657 | ||
| 612 | #ifdef __cplusplus | 658 | #ifdef __cplusplus |
| 613 | } | 659 | } |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_dll.h deleted file mode 100644 index 8652a0a..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_dll.h +++ /dev/null | |||
| @@ -1,42 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (C) 2005-2015 Team Kodi | ||
| 5 | * http://kodi.tv | ||
| 6 | * | ||
| 7 | * This Program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 10 | * any later version. | ||
| 11 | * | ||
| 12 | * This Program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with Kodi; see the file COPYING. If not, see | ||
| 19 | * <http://www.gnu.org/licenses/>. | ||
| 20 | * | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include "xbmc_addon_dll.h" | ||
| 24 | #include "xbmc_scr_types.h" | ||
| 25 | |||
| 26 | extern "C" | ||
| 27 | { | ||
| 28 | |||
| 29 | // Functions that your visualisation must implement | ||
| 30 | void Start(); | ||
| 31 | void Render(); | ||
| 32 | void GetInfo(SCR_INFO* pInfo); | ||
| 33 | |||
| 34 | // function to export the above structure to XBMC | ||
| 35 | void __declspec(dllexport) get_addon(struct ScreenSaver* pScr) | ||
| 36 | { | ||
| 37 | pScr->Start = Start; | ||
| 38 | pScr->Render = Render; | ||
| 39 | pScr->GetInfo = GetInfo; | ||
| 40 | }; | ||
| 41 | }; | ||
| 42 | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_types.h deleted file mode 100644 index 5785b25..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_types.h +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (C) 2005-2015 Team Kodi | ||
| 5 | * http://kodi.tv | ||
| 6 | * | ||
| 7 | * This Program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 10 | * any later version. | ||
| 11 | * | ||
| 12 | * This Program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with Kodi; see the file COPYING. If not, see | ||
| 19 | * <http://www.gnu.org/licenses/>. | ||
| 20 | * | ||
| 21 | */ | ||
| 22 | |||
| 23 | extern "C" | ||
| 24 | { | ||
| 25 | struct SCR_INFO | ||
| 26 | { | ||
| 27 | int dummy; | ||
| 28 | }; | ||
| 29 | |||
| 30 | struct SCR_PROPS | ||
| 31 | { | ||
| 32 | void *device; | ||
| 33 | int x; | ||
| 34 | int y; | ||
| 35 | int width; | ||
| 36 | int height; | ||
| 37 | float pixelRatio; | ||
| 38 | const char *name; | ||
| 39 | const char *presets; | ||
| 40 | const char *profile; | ||
| 41 | }; | ||
| 42 | |||
| 43 | struct ScreenSaver | ||
| 44 | { | ||
| 45 | void (__cdecl* Start) (); | ||
| 46 | void (__cdecl* Render) (); | ||
| 47 | void (__cdecl* GetInfo)(SCR_INFO *info); | ||
| 48 | }; | ||
| 49 | } | ||
| 50 | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_stream_utils.hpp b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_stream_utils.hpp deleted file mode 100644 index 099776a..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_stream_utils.hpp +++ /dev/null | |||
| @@ -1,264 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2013 Team XBMC | ||
| 4 | * http://xbmc.org | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with XBMC; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "xbmc_pvr_types.h" | ||
| 23 | #include <algorithm> | ||
| 24 | #include <map> | ||
| 25 | |||
| 26 | namespace ADDON | ||
| 27 | { | ||
| 28 | /** | ||
| 29 | * Represents a single stream. It extends the PODS to provide some operators | ||
| 30 | * overloads. | ||
| 31 | */ | ||
| 32 | class XbmcPvrStream : public PVR_STREAM_PROPERTIES::PVR_STREAM | ||
| 33 | { | ||
| 34 | public: | ||
| 35 | XbmcPvrStream() | ||
| 36 | { | ||
| 37 | Clear(); | ||
| 38 | } | ||
| 39 | |||
| 40 | XbmcPvrStream(const XbmcPvrStream &other) | ||
| 41 | { | ||
| 42 | memcpy(this, &other, sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); | ||
| 43 | } | ||
| 44 | |||
| 45 | XbmcPvrStream& operator=(const XbmcPvrStream &other) | ||
| 46 | { | ||
| 47 | memcpy(this, &other, sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); | ||
| 48 | return *this; | ||
| 49 | } | ||
| 50 | |||
| 51 | /** | ||
| 52 | * Compares this stream based on another stream | ||
| 53 | * @param other | ||
| 54 | * @return | ||
| 55 | */ | ||
| 56 | inline bool operator==(const XbmcPvrStream &other) const | ||
| 57 | { | ||
| 58 | return iPhysicalId == other.iPhysicalId && iCodecId == other.iCodecId; | ||
| 59 | } | ||
| 60 | |||
| 61 | /** | ||
| 62 | * Compares this stream with another one so that video streams are sorted | ||
| 63 | * before any other streams and the others are sorted by the physical ID | ||
| 64 | * @param other | ||
| 65 | * @return | ||
| 66 | */ | ||
| 67 | bool operator<(const XbmcPvrStream &other) const | ||
| 68 | { | ||
| 69 | if (iCodecType == XBMC_CODEC_TYPE_VIDEO) | ||
| 70 | return true; | ||
| 71 | else if (other.iCodecType != XBMC_CODEC_TYPE_VIDEO) | ||
| 72 | return iPhysicalId < other.iPhysicalId; | ||
| 73 | else | ||
| 74 | return false; | ||
| 75 | } | ||
| 76 | |||
| 77 | /** | ||
| 78 | * Clears the stream | ||
| 79 | */ | ||
| 80 | void Clear() | ||
| 81 | { | ||
| 82 | memset(this, 0, sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); | ||
| 83 | iCodecId = XBMC_INVALID_CODEC_ID; | ||
| 84 | iCodecType = XBMC_CODEC_TYPE_UNKNOWN; | ||
| 85 | } | ||
| 86 | |||
| 87 | /** | ||
| 88 | * Checks whether the stream has been cleared | ||
| 89 | * @return | ||
| 90 | */ | ||
| 91 | inline bool IsCleared() const | ||
| 92 | { | ||
| 93 | return iCodecId == XBMC_INVALID_CODEC_ID && | ||
| 94 | iCodecType == XBMC_CODEC_TYPE_UNKNOWN; | ||
| 95 | } | ||
| 96 | }; | ||
| 97 | |||
| 98 | class XbmcStreamProperties | ||
| 99 | { | ||
| 100 | public: | ||
| 101 | typedef std::vector<XbmcPvrStream> stream_vector; | ||
| 102 | |||
| 103 | XbmcStreamProperties(void) | ||
| 104 | { | ||
| 105 | // make sure the vector won't have to resize itself later | ||
| 106 | m_streamVector = new stream_vector(); | ||
| 107 | m_streamVector->reserve(PVR_STREAM_MAX_STREAMS); | ||
| 108 | } | ||
| 109 | |||
| 110 | virtual ~XbmcStreamProperties(void) | ||
| 111 | { | ||
| 112 | delete m_streamVector; | ||
| 113 | } | ||
| 114 | |||
| 115 | /** | ||
| 116 | * Resets the streams | ||
| 117 | */ | ||
| 118 | void Clear(void) | ||
| 119 | { | ||
| 120 | m_streamVector->clear(); | ||
| 121 | m_streamIndex.clear(); | ||
| 122 | } | ||
| 123 | |||
| 124 | /** | ||
| 125 | * Returns the index of the stream with the specified physical ID, or -1 if | ||
| 126 | * there no stream is found. This method is called very often which is why | ||
| 127 | * we keep a separate map for this. | ||
| 128 | * @param iPhysicalId | ||
| 129 | * @return | ||
| 130 | */ | ||
| 131 | int GetStreamId(unsigned int iPhysicalId) const | ||
| 132 | { | ||
| 133 | std::map<unsigned int, int>::const_iterator it = m_streamIndex.find(iPhysicalId); | ||
| 134 | if (it != m_streamIndex.end()) | ||
| 135 | return it->second; | ||
| 136 | |||
| 137 | return -1; | ||
| 138 | } | ||
| 139 | |||
| 140 | /** | ||
| 141 | * Returns the stream with the specified physical ID, or null if no such | ||
| 142 | * stream exists | ||
| 143 | * @param iPhysicalId | ||
| 144 | * @return | ||
| 145 | */ | ||
| 146 | XbmcPvrStream* GetStreamById(unsigned int iPhysicalId) const | ||
| 147 | { | ||
| 148 | int position = GetStreamId(iPhysicalId); | ||
| 149 | return position != -1 ? &m_streamVector->at(position) : NULL; | ||
| 150 | } | ||
| 151 | |||
| 152 | /** | ||
| 153 | * Populates the specified stream with the stream having the specified | ||
| 154 | * physical ID. If the stream is not found only target stream's physical ID | ||
| 155 | * will be populated. | ||
| 156 | * @param iPhysicalId | ||
| 157 | * @param stream | ||
| 158 | */ | ||
| 159 | void GetStreamData(unsigned int iPhysicalId, XbmcPvrStream* stream) | ||
| 160 | { | ||
| 161 | XbmcPvrStream *foundStream = GetStreamById(iPhysicalId); | ||
| 162 | if (foundStream) | ||
| 163 | *stream = *foundStream; | ||
| 164 | else | ||
| 165 | { | ||
| 166 | stream->iIdentifier = -1; | ||
| 167 | stream->iPhysicalId = iPhysicalId; | ||
| 168 | } | ||
| 169 | } | ||
| 170 | |||
| 171 | /** | ||
| 172 | * Populates props with the current streams and returns whether there are | ||
| 173 | * any streams at the moment or not. | ||
| 174 | * @param props | ||
| 175 | * @return | ||
| 176 | */ | ||
| 177 | bool GetProperties(PVR_STREAM_PROPERTIES* props) | ||
| 178 | { | ||
| 179 | unsigned int i = 0; | ||
| 180 | for (stream_vector::const_iterator it = m_streamVector->begin(); | ||
| 181 | it != m_streamVector->end(); ++it, ++i) | ||
| 182 | { | ||
| 183 | memcpy(&props->stream[i], &(*it), sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); | ||
| 184 | } | ||
| 185 | |||
| 186 | props->iStreamCount = m_streamVector->size(); | ||
| 187 | return (props->iStreamCount > 0); | ||
| 188 | } | ||
| 189 | |||
| 190 | /** | ||
| 191 | * Merges new streams into the current list of streams. Identical streams | ||
| 192 | * will retain their respective indexes and new streams will replace unused | ||
| 193 | * indexes or be appended. | ||
| 194 | * @param newStreams | ||
| 195 | */ | ||
| 196 | void UpdateStreams(stream_vector &newStreams) | ||
| 197 | { | ||
| 198 | // sort the new streams | ||
| 199 | std::sort(newStreams.begin(), newStreams.end()); | ||
| 200 | |||
| 201 | // ensure we never have more than PVR_STREAMS_MAX_STREAMS streams | ||
| 202 | if (newStreams.size() > PVR_STREAM_MAX_STREAMS) | ||
| 203 | { | ||
| 204 | while (newStreams.size() > PVR_STREAM_MAX_STREAMS) | ||
| 205 | newStreams.pop_back(); | ||
| 206 | |||
| 207 | XBMC->Log(LOG_ERROR, "%s - max amount of streams reached", __FUNCTION__); | ||
| 208 | } | ||
| 209 | |||
| 210 | stream_vector::iterator newStreamPosition; | ||
| 211 | for (stream_vector::iterator it = m_streamVector->begin(); it != m_streamVector->end(); ++it) | ||
| 212 | { | ||
| 213 | newStreamPosition = std::find(newStreams.begin(), newStreams.end(), *it); | ||
| 214 | |||
| 215 | // if the current stream no longer exists we clear it, otherwise we | ||
| 216 | // copy it and remove it from newStreams | ||
| 217 | if (newStreamPosition == newStreams.end()) | ||
| 218 | it->Clear(); | ||
| 219 | else | ||
| 220 | { | ||
| 221 | *it = *newStreamPosition; | ||
| 222 | newStreams.erase(newStreamPosition); | ||
| 223 | } | ||
| 224 | } | ||
| 225 | |||
| 226 | // replace cleared streams with new streams | ||
| 227 | for (stream_vector::iterator it = m_streamVector->begin(); | ||
| 228 | it != m_streamVector->end() && !newStreams.empty(); ++it) | ||
| 229 | { | ||
| 230 | if (it->IsCleared()) | ||
| 231 | { | ||
| 232 | *it = newStreams.front(); | ||
| 233 | newStreams.erase(newStreams.begin()); | ||
| 234 | } | ||
| 235 | } | ||
| 236 | |||
| 237 | // append any remaining new streams | ||
| 238 | m_streamVector->insert(m_streamVector->end(), newStreams.begin(), newStreams.end()); | ||
| 239 | |||
| 240 | // remove trailing cleared streams | ||
| 241 | while (m_streamVector->back().IsCleared()) | ||
| 242 | m_streamVector->pop_back(); | ||
| 243 | |||
| 244 | // update the index | ||
| 245 | UpdateIndex(); | ||
| 246 | } | ||
| 247 | |||
| 248 | private: | ||
| 249 | stream_vector *m_streamVector; | ||
| 250 | std::map<unsigned int, int> m_streamIndex; | ||
| 251 | |||
| 252 | /** | ||
| 253 | * Updates the stream index | ||
| 254 | */ | ||
| 255 | void UpdateIndex() | ||
| 256 | { | ||
| 257 | m_streamIndex.clear(); | ||
| 258 | |||
| 259 | int i = 0; | ||
| 260 | for (stream_vector::const_iterator it = m_streamVector->begin(); it != m_streamVector->end(); ++it, ++i) | ||
| 261 | m_streamIndex[it->iPhysicalId] = i; | ||
| 262 | } | ||
| 263 | }; | ||
| 264 | } | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_dll.h index 50452c2..7252721 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_dll.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_dll.h | |||
| @@ -27,6 +27,7 @@ extern "C" | |||
| 27 | { | 27 | { |
| 28 | // Functions that your visualisation must implement | 28 | // Functions that your visualisation must implement |
| 29 | void Start(int iChannels, int iSamplesPerSec, int iBitsPerSample, const char* szSongName); | 29 | void Start(int iChannels, int iSamplesPerSec, int iBitsPerSample, const char* szSongName); |
| 30 | void Stop(); | ||
| 30 | void AudioData(const float* pAudioData, int iAudioDataLength, float *pFreqData, int iFreqDataLength); | 31 | void AudioData(const float* pAudioData, int iAudioDataLength, float *pFreqData, int iFreqDataLength); |
| 31 | void Render(); | 32 | void Render(); |
| 32 | bool OnAction(long action, const void *param); | 33 | bool OnAction(long action, const void *param); |
| @@ -37,17 +38,20 @@ extern "C" | |||
| 37 | bool IsLocked(); | 38 | bool IsLocked(); |
| 38 | 39 | ||
| 39 | // function to export the above structure to XBMC | 40 | // function to export the above structure to XBMC |
| 40 | void __declspec(dllexport) get_addon(struct Visualisation* pVisz) | 41 | void __declspec(dllexport) get_addon(void* ptr) |
| 41 | { | 42 | { |
| 42 | pVisz->Start = Start; | 43 | AddonInstance_Visualization* pVisz = static_cast<AddonInstance_Visualization*>(ptr); |
| 43 | pVisz->AudioData = AudioData; | 44 | |
| 44 | pVisz->Render = Render; | 45 | pVisz->toAddon.Start = Start; |
| 45 | pVisz->OnAction = OnAction; | 46 | pVisz->toAddon.Stop = Stop; |
| 46 | pVisz->GetInfo = GetInfo; | 47 | pVisz->toAddon.AudioData = AudioData; |
| 47 | pVisz->GetPresets = GetPresets; | 48 | pVisz->toAddon.Render = Render; |
| 48 | pVisz->GetPreset = GetPreset; | 49 | pVisz->toAddon.OnAction = OnAction; |
| 49 | pVisz->GetSubModules = GetSubModules; | 50 | pVisz->toAddon.GetInfo = GetInfo; |
| 50 | pVisz->IsLocked = IsLocked; | 51 | pVisz->toAddon.GetPresets = GetPresets; |
| 52 | pVisz->toAddon.GetPreset = GetPreset; | ||
| 53 | pVisz->toAddon.GetSubModules = GetSubModules; | ||
| 54 | pVisz->toAddon.IsLocked = IsLocked; | ||
| 51 | }; | 55 | }; |
| 52 | }; | 56 | }; |
| 53 | 57 | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_types.h index 708ffef..be11c89 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_types.h | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | Common data structures shared between Kodi and Kodi's visualisations | 24 | Common data structures shared between Kodi and Kodi's visualisations |
| 25 | */ | 25 | */ |
| 26 | 26 | ||
| 27 | #include "xbmc_addon_types.h" | ||
| 27 | #include <cstddef> | 28 | #include <cstddef> |
| 28 | 29 | ||
| 29 | extern "C" | 30 | extern "C" |
| @@ -34,20 +35,6 @@ extern "C" | |||
| 34 | int iSyncDelay; | 35 | int iSyncDelay; |
| 35 | }; | 36 | }; |
| 36 | 37 | ||
| 37 | struct VIS_PROPS | ||
| 38 | { | ||
| 39 | void *device; | ||
| 40 | int x; | ||
| 41 | int y; | ||
| 42 | int width; | ||
| 43 | int height; | ||
| 44 | float pixelRatio; | ||
| 45 | const char *name; | ||
| 46 | const char *presets; | ||
| 47 | const char *profile; | ||
| 48 | const char *submodule; | ||
| 49 | }; | ||
| 50 | |||
| 51 | enum VIS_ACTION | 38 | enum VIS_ACTION |
| 52 | { | 39 | { |
| 53 | VIS_ACTION_NONE = 0, | 40 | VIS_ACTION_NONE = 0, |
| @@ -93,9 +80,29 @@ extern "C" | |||
| 93 | int reserved4; | 80 | int reserved4; |
| 94 | }; | 81 | }; |
| 95 | 82 | ||
| 96 | struct Visualisation | 83 | typedef struct AddonProps_Visualization /* internal */ |
| 84 | { | ||
| 85 | void *device; | ||
| 86 | int x; | ||
| 87 | int y; | ||
| 88 | int width; | ||
| 89 | int height; | ||
| 90 | float pixelRatio; | ||
| 91 | const char *name; | ||
| 92 | const char *presets; | ||
| 93 | const char *profile; | ||
| 94 | const char *submodule; | ||
| 95 | } AddonProps_Visualization; | ||
| 96 | |||
| 97 | typedef struct AddonToKodiFuncTable_Visualization /* internal */ | ||
| 98 | { | ||
| 99 | KODI_HANDLE kodiInstance; | ||
| 100 | } AddonToKodiFuncTable_Visualization; | ||
| 101 | |||
| 102 | typedef struct KodiToAddonFuncTable_Visualization /* internal */ | ||
| 97 | { | 103 | { |
| 98 | void (__cdecl* Start)(int iChannels, int iSamplesPerSec, int iBitsPerSample, const char* szSongName); | 104 | void (__cdecl* Start)(int iChannels, int iSamplesPerSec, int iBitsPerSample, const char* szSongName); |
| 105 | void (__cdecl* Stop)(); | ||
| 99 | void (__cdecl* AudioData)(const float* pAudioData, int iAudioDataLength, float *pFreqData, int iFreqDataLength); | 106 | void (__cdecl* AudioData)(const float* pAudioData, int iAudioDataLength, float *pFreqData, int iFreqDataLength); |
| 100 | void (__cdecl* Render) (); | 107 | void (__cdecl* Render) (); |
| 101 | void (__cdecl* GetInfo)(VIS_INFO *info); | 108 | void (__cdecl* GetInfo)(VIS_INFO *info); |
| @@ -105,6 +112,13 @@ extern "C" | |||
| 105 | unsigned int (__cdecl *GetPreset)(); | 112 | unsigned int (__cdecl *GetPreset)(); |
| 106 | unsigned int (__cdecl *GetSubModules)(char ***modules); | 113 | unsigned int (__cdecl *GetSubModules)(char ***modules); |
| 107 | bool (__cdecl* IsLocked)(); | 114 | bool (__cdecl* IsLocked)(); |
| 108 | }; | 115 | } KodiToAddonFuncTable_Visualization; |
| 116 | |||
| 117 | typedef struct AddonInstance_Visualization /* internal */ | ||
| 118 | { | ||
| 119 | AddonProps_Visualization props; | ||
| 120 | AddonToKodiFuncTable_Visualization toKodi; | ||
| 121 | KodiToAddonFuncTable_Visualization toAddon; | ||
| 122 | } AddonInstance_Visualization; | ||
| 109 | } | 123 | } |
| 110 | 124 | ||
