diff options
| author | manuel <manuel@mausz.at> | 2020-07-02 23:09:26 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2020-07-02 23:09:26 +0200 |
| commit | 5f8335c1e49ce108ef3481863833c98efa00411b (patch) | |
| tree | f02b5c1c9765bb6a14c8eb42bb4f81b9face0b55 /xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h | |
| parent | e317daf081a1048904fdf0b548946fa3ba6593a7 (diff) | |
| download | kodi-pvr-build-5f8335c1e49ce108ef3481863833c98efa00411b.tar.gz kodi-pvr-build-5f8335c1e49ce108ef3481863833c98efa00411b.tar.bz2 kodi-pvr-build-5f8335c1e49ce108ef3481863833c98efa00411b.zip | |
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h')
| -rw-r--r-- | xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h | 602 |
1 files changed, 0 insertions, 602 deletions
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 deleted file mode 100644 index 43e3022..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h +++ /dev/null | |||
| @@ -1,602 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include <string> | ||
| 12 | #include <vector> | ||
| 13 | #include <string.h> | ||
| 14 | #include <stdlib.h> | ||
| 15 | #include <stdio.h> | ||
| 16 | #include <stdint.h> | ||
| 17 | #include <stdarg.h> | ||
| 18 | |||
| 19 | #include "versions.h" | ||
| 20 | #if defined(BUILD_KODI_ADDON) | ||
| 21 | #include "IFileTypes.h" | ||
| 22 | #else | ||
| 23 | #include "filesystem/IFileTypes.h" | ||
| 24 | #endif | ||
| 25 | |||
| 26 | struct VFSDirEntry; | ||
| 27 | struct __stat64; | ||
| 28 | |||
| 29 | #ifdef _WIN32 // windows | ||
| 30 | #ifndef _SSIZE_T_DEFINED | ||
| 31 | typedef intptr_t ssize_t; | ||
| 32 | #define _SSIZE_T_DEFINED | ||
| 33 | #endif // !_SSIZE_T_DEFINED | ||
| 34 | |||
| 35 | #if defined(BUILD_KODI_ADDON) | ||
| 36 | #include "p8-platform/windows/dlfcn-win32.h" | ||
| 37 | #endif | ||
| 38 | #else // windows | ||
| 39 | #include <dlfcn.h> // linux+osx | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #ifdef LOG_DEBUG | ||
| 43 | #undef LOG_DEBUG | ||
| 44 | #endif | ||
| 45 | #ifdef LOG_INFO | ||
| 46 | #undef LOG_INFO | ||
| 47 | #endif | ||
| 48 | #ifdef LOG_NOTICE | ||
| 49 | #undef LOG_NOTICE | ||
| 50 | #endif | ||
| 51 | #ifdef LOG_ERROR | ||
| 52 | #undef LOG_ERROR | ||
| 53 | #endif | ||
| 54 | |||
| 55 | typedef void* (*KODIAddOnLib_RegisterMe)(void *addonData); | ||
| 56 | typedef void (*KODIAddOnLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 57 | typedef void* (*KODIAudioEngineLib_RegisterMe)(void *addonData); | ||
| 58 | typedef void (*KODIAudioEngineLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 59 | typedef void* (*KODIGUILib_RegisterMe)(void *addonData); | ||
| 60 | typedef void (*KODIGUILib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 61 | typedef void* (*KODIPVRLib_RegisterMe)(void *addonData); | ||
| 62 | typedef void (*KODIPVRLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 63 | typedef void* (*KODICodecLib_RegisterMe)(void *addonData); | ||
| 64 | typedef void (*KODICodecLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 65 | typedef void* (*KODIINPUTSTREAMLib_RegisterMe)(void *addonData); | ||
| 66 | typedef void (*KODIINPUTSTREAMLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 67 | typedef void* (*KODIPeripheralLib_RegisterMe)(void *addonData); | ||
| 68 | typedef void (*KODIPeripheralLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 69 | typedef void* (*KODIGameLib_RegisterMe)(void *addonData); | ||
| 70 | typedef void (*KODIGameLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 71 | |||
| 72 | typedef struct AddonCB | ||
| 73 | { | ||
| 74 | const char* libBasePath; ///< Never, never change this!!! | ||
| 75 | void* addonData; | ||
| 76 | KODIAddOnLib_RegisterMe AddOnLib_RegisterMe; | ||
| 77 | KODIAddOnLib_UnRegisterMe AddOnLib_UnRegisterMe; | ||
| 78 | KODIAudioEngineLib_RegisterMe AudioEngineLib_RegisterMe; | ||
| 79 | KODIAudioEngineLib_UnRegisterMe AudioEngineLib_UnRegisterMe; | ||
| 80 | KODICodecLib_RegisterMe CodecLib_RegisterMe; | ||
| 81 | KODICodecLib_UnRegisterMe CodecLib_UnRegisterMe; | ||
| 82 | KODIGUILib_RegisterMe GUILib_RegisterMe; | ||
| 83 | KODIGUILib_UnRegisterMe GUILib_UnRegisterMe; | ||
| 84 | KODIPVRLib_RegisterMe PVRLib_RegisterMe; | ||
| 85 | KODIPVRLib_UnRegisterMe PVRLib_UnRegisterMe; | ||
| 86 | KODIINPUTSTREAMLib_RegisterMe INPUTSTREAMLib_RegisterMe; | ||
| 87 | KODIINPUTSTREAMLib_UnRegisterMe INPUTSTREAMLib_UnRegisterMe; | ||
| 88 | KODIPeripheralLib_RegisterMe PeripheralLib_RegisterMe; | ||
| 89 | KODIPeripheralLib_UnRegisterMe PeripheralLib_UnRegisterMe; | ||
| 90 | KODIGameLib_RegisterMe GameLib_RegisterMe; | ||
| 91 | KODIGameLib_UnRegisterMe GameLib_UnRegisterMe; | ||
| 92 | } AddonCB; | ||
| 93 | |||
| 94 | namespace ADDON | ||
| 95 | { | ||
| 96 | typedef enum addon_log | ||
| 97 | { | ||
| 98 | LOG_DEBUG, | ||
| 99 | LOG_INFO, | ||
| 100 | LOG_NOTICE, | ||
| 101 | LOG_ERROR | ||
| 102 | } addon_log_t; | ||
| 103 | |||
| 104 | typedef enum queue_msg | ||
| 105 | { | ||
| 106 | QUEUE_INFO, | ||
| 107 | QUEUE_WARNING, | ||
| 108 | QUEUE_ERROR | ||
| 109 | } queue_msg_t; | ||
| 110 | } | ||
| 111 | |||
| 112 | namespace KodiAPI | ||
| 113 | { | ||
| 114 | namespace AddOn | ||
| 115 | { | ||
| 116 | typedef struct CB_AddOn | ||
| 117 | { | ||
| 118 | void (*Log)(void *addonData, const ADDON::addon_log_t loglevel, const char *msg); | ||
| 119 | void (*QueueNotification)(void *addonData, const ADDON::queue_msg_t type, const char *msg); | ||
| 120 | bool (*WakeOnLan)(const char* mac); | ||
| 121 | bool (*GetSetting)(void *addonData, const char *settingName, void *settingValue); | ||
| 122 | char* (*TranslateSpecialProtocol)(const char *strSource); | ||
| 123 | char* (*UnknownToUTF8)(const char *sourceDest); | ||
| 124 | char* (*GetLocalizedString)(const void* addonData, long dwCode); | ||
| 125 | char* (*GetDVDMenuLanguage)(const void* addonData); | ||
| 126 | void (*FreeString)(const void* addonData, char* str); | ||
| 127 | void (*FreeStringArray)(const void* addonData, char** arr, int numElements); | ||
| 128 | |||
| 129 | void* (*OpenFile)(const void* addonData, const char* strFileName, unsigned int flags); | ||
| 130 | void* (*OpenFileForWrite)(const void* addonData, const char* strFileName, bool bOverWrite); | ||
| 131 | ssize_t (*ReadFile)(const void* addonData, void* file, void* lpBuf, size_t uiBufSize); | ||
| 132 | bool (*ReadFileString)(const void* addonData, void* file, char *szLine, int iLineLength); | ||
| 133 | ssize_t (*WriteFile)(const void* addonData, void* file, const void* lpBuf, size_t uiBufSize); | ||
| 134 | void (*FlushFile)(const void* addonData, void* file); | ||
| 135 | int64_t (*SeekFile)(const void* addonData, void* file, int64_t iFilePosition, int iWhence); | ||
| 136 | int (*TruncateFile)(const void* addonData, void* file, int64_t iSize); | ||
| 137 | int64_t (*GetFilePosition)(const void* addonData, void* file); | ||
| 138 | int64_t (*GetFileLength)(const void* addonData, void* file); | ||
| 139 | double (*GetFileDownloadSpeed)(const void* addonData, void* file); | ||
| 140 | void (*CloseFile)(const void* addonData, void* file); | ||
| 141 | int (*GetFileChunkSize)(const void* addonData, void* file); | ||
| 142 | bool (*FileExists)(const void* addonData, const char *strFileName, bool bUseCache); | ||
| 143 | int (*StatFile)(const void* addonData, const char *strFileName, struct __stat64* buffer); | ||
| 144 | char *(*GetFilePropertyValue)(const void* addonData, void* file, XFILE::FileProperty type, const char *name); | ||
| 145 | char **(*GetFilePropertyValues)(const void* addonData, void* file, XFILE::FileProperty type, const char *name, int *numPorperties); | ||
| 146 | bool (*DeleteFile)(const void* addonData, const char *strFileName); | ||
| 147 | bool (*CanOpenDirectory)(const void* addonData, const char* strURL); | ||
| 148 | bool (*CreateDirectory)(const void* addonData, const char *strPath); | ||
| 149 | bool (*DirectoryExists)(const void* addonData, const char *strPath); | ||
| 150 | bool (*RemoveDirectory)(const void* addonData, const char *strPath); | ||
| 151 | bool (*GetDirectory)(const void* addonData, const char *strPath, const char* mask, VFSDirEntry** items, unsigned int* num_items); | ||
| 152 | void (*FreeDirectory)(const void* addonData, VFSDirEntry* items, unsigned int num_items); | ||
| 153 | void* (*CURLCreate)(const void* addonData, const char* strURL); | ||
| 154 | bool (*CURLAddOption)(const void* addonData, void* file, XFILE::CURLOPTIONTYPE type, const char* name, const char * value); | ||
| 155 | bool (*CURLOpen)(const void* addonData, void* file, unsigned int flags); | ||
| 156 | } CB_AddOnLib; | ||
| 157 | |||
| 158 | } /* namespace AddOn */ | ||
| 159 | } /* namespace KodiAPI */ | ||
| 160 | |||
| 161 | namespace ADDON | ||
| 162 | { | ||
| 163 | class CHelper_libXBMC_addon | ||
| 164 | { | ||
| 165 | public: | ||
| 166 | CHelper_libXBMC_addon() | ||
| 167 | { | ||
| 168 | m_Handle = nullptr; | ||
| 169 | m_Callbacks = nullptr; | ||
| 170 | } | ||
| 171 | |||
| 172 | ~CHelper_libXBMC_addon() | ||
| 173 | { | ||
| 174 | if (m_Handle && m_Callbacks) | ||
| 175 | { | ||
| 176 | m_Handle->AddOnLib_UnRegisterMe(m_Handle->addonData, m_Callbacks); | ||
| 177 | } | ||
| 178 | } | ||
| 179 | |||
| 180 | bool RegisterMe(void *handle) | ||
| 181 | { | ||
| 182 | m_Handle = static_cast<AddonCB*>(handle); | ||
| 183 | if (m_Handle) | ||
| 184 | m_Callbacks = (KodiAPI::AddOn::CB_AddOnLib*)m_Handle->AddOnLib_RegisterMe(m_Handle->addonData); | ||
| 185 | if (!m_Callbacks) | ||
| 186 | fprintf(stderr, "libXBMC_addon-ERROR: AddOnLib_RegisterMe can't get callback table from Kodi !!!\n"); | ||
| 187 | |||
| 188 | return m_Callbacks != nullptr; | ||
| 189 | } | ||
| 190 | |||
| 191 | /*! | ||
| 192 | * @brief Add a message to XBMC's log. | ||
| 193 | * @param loglevel The log level of the message. | ||
| 194 | * @param format The format of the message to pass to XBMC. | ||
| 195 | * @note This method uses limited buffer (16k) for the formatted output. | ||
| 196 | * So data, which will not fit into it, will be silently discarded. | ||
| 197 | */ | ||
| 198 | void Log(const addon_log_t loglevel, const char *format, ... ) | ||
| 199 | { | ||
| 200 | char buffer[16384]; | ||
| 201 | static constexpr size_t len = sizeof (buffer) - 1; | ||
| 202 | va_list args; | ||
| 203 | va_start (args, format); | ||
| 204 | vsnprintf (buffer, len, format, args); | ||
| 205 | va_end (args); | ||
| 206 | buffer[len] = '\0'; // to be sure it's null-terminated | ||
| 207 | m_Callbacks->Log(m_Handle->addonData, loglevel, buffer); | ||
| 208 | } | ||
| 209 | |||
| 210 | /*! | ||
| 211 | * @brief Get a settings value for this add-on. | ||
| 212 | * @param settingName The name of the setting to get. | ||
| 213 | * @param settingValue The value. | ||
| 214 | * @return True if the settings was fetched successfully, false otherwise. | ||
| 215 | */ | ||
| 216 | bool GetSetting(const char* settingName, void *settingValue) | ||
| 217 | { | ||
| 218 | return m_Callbacks->GetSetting(m_Handle->addonData, settingName, settingValue); | ||
| 219 | } | ||
| 220 | |||
| 221 | /*! | ||
| 222 | * @brief Translates a special protocol folder. | ||
| 223 | * @param source The file / folder to translate. | ||
| 224 | * @return The string translated to resolved path. Must be freed by calling FreeString() when done. | ||
| 225 | */ | ||
| 226 | char *TranslateSpecialProtocol(const char *source) | ||
| 227 | { | ||
| 228 | return m_Callbacks->TranslateSpecialProtocol(source); | ||
| 229 | } | ||
| 230 | |||
| 231 | /*! | ||
| 232 | * @brief Queue a notification in the GUI. | ||
| 233 | * @param type The message type. | ||
| 234 | * @param format The format of the message to pass to display in XBMC. | ||
| 235 | */ | ||
| 236 | void QueueNotification(const queue_msg_t type, const char *format, ... ) | ||
| 237 | { | ||
| 238 | char buffer[16384]; | ||
| 239 | va_list args; | ||
| 240 | va_start (args, format); | ||
| 241 | vsprintf (buffer, format, args); | ||
| 242 | va_end (args); | ||
| 243 | m_Callbacks->QueueNotification(m_Handle->addonData, type, buffer); | ||
| 244 | } | ||
| 245 | |||
| 246 | /*! | ||
| 247 | * @brief Send WakeOnLan magic packet. | ||
| 248 | * @param mac Network address of the host to wake. | ||
| 249 | * @return True if the magic packet was successfully sent, false otherwise. | ||
| 250 | */ | ||
| 251 | bool WakeOnLan(const char* mac) | ||
| 252 | { | ||
| 253 | return m_Callbacks->WakeOnLan(mac); | ||
| 254 | } | ||
| 255 | |||
| 256 | /*! | ||
| 257 | * @brief Translate a string with an unknown encoding to UTF8. | ||
| 258 | * @param str The string to translate. | ||
| 259 | * @return The string translated to UTF8. Must be freed by calling FreeString() when done. | ||
| 260 | */ | ||
| 261 | char* UnknownToUTF8(const char* str) | ||
| 262 | { | ||
| 263 | return m_Callbacks->UnknownToUTF8(str); | ||
| 264 | } | ||
| 265 | |||
| 266 | /*! | ||
| 267 | * @brief Get a localised message. | ||
| 268 | * @param dwCode The code of the message to get. | ||
| 269 | * @return The message. Must be freed by calling FreeString() when done. | ||
| 270 | */ | ||
| 271 | char* GetLocalizedString(int dwCode) | ||
| 272 | { | ||
| 273 | return m_Callbacks->GetLocalizedString(m_Handle->addonData, dwCode); | ||
| 274 | } | ||
| 275 | |||
| 276 | /*! | ||
| 277 | * @brief Get the DVD menu language. | ||
| 278 | * @return The language. Must be freed by calling FreeString() when done. | ||
| 279 | */ | ||
| 280 | char* GetDVDMenuLanguage() | ||
| 281 | { | ||
| 282 | return m_Callbacks->GetDVDMenuLanguage(m_Handle->addonData); | ||
| 283 | } | ||
| 284 | |||
| 285 | /*! | ||
| 286 | * @brief Free the memory used by str | ||
| 287 | * @param str The string to free | ||
| 288 | */ | ||
| 289 | void FreeString(char* str) | ||
| 290 | { | ||
| 291 | m_Callbacks->FreeString(m_Handle->addonData, str); | ||
| 292 | } | ||
| 293 | |||
| 294 | /*! | ||
| 295 | * @brief Free the memory used by arr including its elements | ||
| 296 | * @param arr The string array to free | ||
| 297 | * @param numElements The length of the array | ||
| 298 | */ | ||
| 299 | void FreeStringArray(char** arr, int numElements) | ||
| 300 | { | ||
| 301 | m_Callbacks->FreeStringArray(m_Handle->addonData, arr, numElements); | ||
| 302 | } | ||
| 303 | |||
| 304 | /*! | ||
| 305 | * @brief Open the file with filename via XBMC's CFile. Needs to be closed by calling CloseFile() when done. | ||
| 306 | * @param strFileName The filename to open. | ||
| 307 | * @param flags The flags to pass. Documented in XBMC's File.h | ||
| 308 | * @return A handle for the file, or NULL if it couldn't be opened. | ||
| 309 | */ | ||
| 310 | void* OpenFile(const char* strFileName, unsigned int flags) | ||
| 311 | { | ||
| 312 | return m_Callbacks->OpenFile(m_Handle->addonData, strFileName, flags); | ||
| 313 | } | ||
| 314 | |||
| 315 | /*! | ||
| 316 | * @brief Open the file with filename via XBMC's CFile in write mode. Needs to be closed by calling CloseFile() when done. | ||
| 317 | * @param strFileName The filename to open. | ||
| 318 | * @param bOverWrite True to overwrite, false otherwise. | ||
| 319 | * @return A handle for the file, or NULL if it couldn't be opened. | ||
| 320 | */ | ||
| 321 | void* OpenFileForWrite(const char* strFileName, bool bOverWrite) | ||
| 322 | { | ||
| 323 | return m_Callbacks->OpenFileForWrite(m_Handle->addonData, strFileName, bOverWrite); | ||
| 324 | } | ||
| 325 | |||
| 326 | /*! | ||
| 327 | * @brief Read from an open file. | ||
| 328 | * @param file The file handle to read from. | ||
| 329 | * @param lpBuf The buffer to store the data in. | ||
| 330 | * @param uiBufSize The size of the buffer. | ||
| 331 | * @return number of successfully read bytes if any bytes were read and stored in | ||
| 332 | * buffer, zero if no bytes are available to read (end of file was reached) | ||
| 333 | * or undetectable error occur, -1 in case of any explicit error | ||
| 334 | */ | ||
| 335 | ssize_t ReadFile(void* file, void* lpBuf, size_t uiBufSize) | ||
| 336 | { | ||
| 337 | return m_Callbacks->ReadFile(m_Handle->addonData, file, lpBuf, uiBufSize); | ||
| 338 | } | ||
| 339 | |||
| 340 | /*! | ||
| 341 | * @brief Read a string from an open file. | ||
| 342 | * @param file The file handle to read from. | ||
| 343 | * @param szLine The buffer to store the data in. | ||
| 344 | * @param iLineLength The size of the buffer. | ||
| 345 | * @return True when a line was read, false otherwise. | ||
| 346 | */ | ||
| 347 | bool ReadFileString(void* file, char *szLine, int iLineLength) | ||
| 348 | { | ||
| 349 | return m_Callbacks->ReadFileString(m_Handle->addonData, file, szLine, iLineLength); | ||
| 350 | } | ||
| 351 | |||
| 352 | /*! | ||
| 353 | * @brief Write to a file opened in write mode. | ||
| 354 | * @param file The file handle to write to. | ||
| 355 | * @param lpBuf The data to write. | ||
| 356 | * @param uiBufSize Size of the data to write. | ||
| 357 | * @return number of successfully written bytes if any bytes were written, | ||
| 358 | * zero if no bytes were written and no detectable error occur, | ||
| 359 | * -1 in case of any explicit error | ||
| 360 | */ | ||
| 361 | ssize_t WriteFile(void* file, const void* lpBuf, size_t uiBufSize) | ||
| 362 | { | ||
| 363 | return m_Callbacks->WriteFile(m_Handle->addonData, file, lpBuf, uiBufSize); | ||
| 364 | } | ||
| 365 | |||
| 366 | /*! | ||
| 367 | * @brief Flush buffered data. | ||
| 368 | * @param file The file handle to flush the data for. | ||
| 369 | */ | ||
| 370 | void FlushFile(void* file) | ||
| 371 | { | ||
| 372 | m_Callbacks->FlushFile(m_Handle->addonData, file); | ||
| 373 | } | ||
| 374 | |||
| 375 | /*! | ||
| 376 | * @brief Seek in an open file. | ||
| 377 | * @param file The file handle to see in. | ||
| 378 | * @param iFilePosition The new position. | ||
| 379 | * @param iWhence Seek argument. See stdio.h for possible values. | ||
| 380 | * @return The new position. | ||
| 381 | */ | ||
| 382 | int64_t SeekFile(void* file, int64_t iFilePosition, int iWhence) | ||
| 383 | { | ||
| 384 | return m_Callbacks->SeekFile(m_Handle->addonData, file, iFilePosition, iWhence); | ||
| 385 | } | ||
| 386 | |||
| 387 | /*! | ||
| 388 | * @brief Truncate a file to the requested size. | ||
| 389 | * @param file The file handle to truncate. | ||
| 390 | * @param iSize The new max size. | ||
| 391 | * @return New size? | ||
| 392 | */ | ||
| 393 | int TruncateFile(void* file, int64_t iSize) | ||
| 394 | { | ||
| 395 | return m_Callbacks->TruncateFile(m_Handle->addonData, file, iSize); | ||
| 396 | } | ||
| 397 | |||
| 398 | /*! | ||
| 399 | * @brief The current position in an open file. | ||
| 400 | * @param file The file handle to get the position for. | ||
| 401 | * @return The requested position. | ||
| 402 | */ | ||
| 403 | int64_t GetFilePosition(void* file) | ||
| 404 | { | ||
| 405 | return m_Callbacks->GetFilePosition(m_Handle->addonData, file); | ||
| 406 | } | ||
| 407 | |||
| 408 | /*! | ||
| 409 | * @brief Get the file size of an open file. | ||
| 410 | * @param file The file to get the size for. | ||
| 411 | * @return The requested size. | ||
| 412 | */ | ||
| 413 | int64_t GetFileLength(void* file) | ||
| 414 | { | ||
| 415 | return m_Callbacks->GetFileLength(m_Handle->addonData, file); | ||
| 416 | } | ||
| 417 | |||
| 418 | /*! | ||
| 419 | * @brief Get the download speed of an open file if available. | ||
| 420 | * @param file The file to get the size for. | ||
| 421 | * @return The download speed in seconds. | ||
| 422 | */ | ||
| 423 | double GetFileDownloadSpeed(void* file) | ||
| 424 | { | ||
| 425 | return m_Callbacks->GetFileDownloadSpeed(m_Handle->addonData, file); | ||
| 426 | } | ||
| 427 | |||
| 428 | /*! | ||
| 429 | * @brief Close an open file. | ||
| 430 | * @param file The file handle to close. | ||
| 431 | */ | ||
| 432 | void CloseFile(void* file) | ||
| 433 | { | ||
| 434 | m_Callbacks->CloseFile(m_Handle->addonData, file); | ||
| 435 | } | ||
| 436 | |||
| 437 | /*! | ||
| 438 | * @brief Get the chunk size for an open file. | ||
| 439 | * @param file the file handle to get the size for. | ||
| 440 | * @return The requested size. | ||
| 441 | */ | ||
| 442 | int GetFileChunkSize(void* file) | ||
| 443 | { | ||
| 444 | return m_Callbacks->GetFileChunkSize(m_Handle->addonData, file); | ||
| 445 | } | ||
| 446 | |||
| 447 | /*! | ||
| 448 | * @brief Check if a file exists. | ||
| 449 | * @param strFileName The filename to check. | ||
| 450 | * @param bUseCache Check in file cache. | ||
| 451 | * @return true if the file exists false otherwise. | ||
| 452 | */ | ||
| 453 | bool FileExists(const char *strFileName, bool bUseCache) | ||
| 454 | { | ||
| 455 | return m_Callbacks->FileExists(m_Handle->addonData, strFileName, bUseCache); | ||
| 456 | } | ||
| 457 | |||
| 458 | /*! | ||
| 459 | * @brief Reads file status. | ||
| 460 | * @param strFileName The filename to read the status from. | ||
| 461 | * @param buffer The file status is written into this buffer. | ||
| 462 | * @return The file status was successfully read. | ||
| 463 | */ | ||
| 464 | int StatFile(const char *strFileName, struct __stat64* buffer) | ||
| 465 | { | ||
| 466 | return m_Callbacks->StatFile(m_Handle->addonData, strFileName, buffer); | ||
| 467 | } | ||
| 468 | |||
| 469 | /*! | ||
| 470 | * @brief Get a property from an open file. | ||
| 471 | * @param file The file to get an property for | ||
| 472 | * @param type Type of the requested property. | ||
| 473 | * @param name Name of the requested property / can be null. | ||
| 474 | * @return The value of the requested property, must be FreeString'ed. | ||
| 475 | */ | ||
| 476 | char *GetFilePropertyValue(void* file, XFILE::FileProperty type, const char *name) | ||
| 477 | { | ||
| 478 | return m_Callbacks->GetFilePropertyValue(m_Handle->addonData, file, type, name); | ||
| 479 | } | ||
| 480 | |||
| 481 | /*! | ||
| 482 | * @brief Get multiple property values from an open file. | ||
| 483 | * @param file The file to get the property values for | ||
| 484 | * @param type Type of the requested property. | ||
| 485 | * @param name Name of the requested property / can be null. | ||
| 486 | * @param numValues Number of property values returned. | ||
| 487 | * @return List of values of the requested property, must be FreeStringArray'ed. | ||
| 488 | */ | ||
| 489 | char **GetFilePropertyValues(void* file, XFILE::FileProperty type, const char *name, int *numValues) | ||
| 490 | { | ||
| 491 | return m_Callbacks->GetFilePropertyValues(m_Handle->addonData, file, type, name, numValues); | ||
| 492 | } | ||
| 493 | |||
| 494 | /*! | ||
| 495 | * @brief Deletes a file. | ||
| 496 | * @param strFileName The filename to delete. | ||
| 497 | * @return The file was successfully deleted. | ||
| 498 | */ | ||
| 499 | bool DeleteFile(const char *strFileName) | ||
| 500 | { | ||
| 501 | return m_Callbacks->DeleteFile(m_Handle->addonData, strFileName); | ||
| 502 | } | ||
| 503 | |||
| 504 | /*! | ||
| 505 | * @brief Checks whether a directory can be opened. | ||
| 506 | * @param strUrl The URL of the directory to check. | ||
| 507 | * @return True when it can be opened, false otherwise. | ||
| 508 | */ | ||
| 509 | bool CanOpenDirectory(const char* strUrl) | ||
| 510 | { | ||
| 511 | return m_Callbacks->CanOpenDirectory(m_Handle->addonData, strUrl); | ||
| 512 | } | ||
| 513 | |||
| 514 | /*! | ||
| 515 | * @brief Creates a directory. | ||
| 516 | * @param strPath Path to the directory. | ||
| 517 | * @return True when it was created, false otherwise. | ||
| 518 | */ | ||
| 519 | bool CreateDirectory(const char *strPath) | ||
| 520 | { | ||
| 521 | return m_Callbacks->CreateDirectory(m_Handle->addonData, strPath); | ||
| 522 | } | ||
| 523 | |||
| 524 | /*! | ||
| 525 | * @brief Checks if a directory exists. | ||
| 526 | * @param strPath Path to the directory. | ||
| 527 | * @return True when it exists, false otherwise. | ||
| 528 | */ | ||
| 529 | bool DirectoryExists(const char *strPath) | ||
| 530 | { | ||
| 531 | return m_Callbacks->DirectoryExists(m_Handle->addonData, strPath); | ||
| 532 | } | ||
| 533 | |||
| 534 | /*! | ||
| 535 | * @brief Removes a directory. | ||
| 536 | * @param strPath Path to the directory. | ||
| 537 | * @return True when it was removed, false otherwise. | ||
| 538 | */ | ||
| 539 | bool RemoveDirectory(const char *strPath) | ||
| 540 | { | ||
| 541 | return m_Callbacks->RemoveDirectory(m_Handle->addonData, strPath); | ||
| 542 | } | ||
| 543 | |||
| 544 | /*! | ||
| 545 | * @brief Lists a directory. | ||
| 546 | * @param strPath Path to the directory. | ||
| 547 | * @param mask File mask | ||
| 548 | * @param items The directory entries | ||
| 549 | * @param num_items Number of entries in directory | ||
| 550 | * @return True if listing was successful, false otherwise. | ||
| 551 | */ | ||
| 552 | bool GetDirectory(const char *strPath, const char* mask, VFSDirEntry** items, unsigned int* num_items) | ||
| 553 | { | ||
| 554 | return m_Callbacks->GetDirectory(m_Handle->addonData, strPath, mask, items, num_items); | ||
| 555 | } | ||
| 556 | |||
| 557 | /*! | ||
| 558 | * @brief Free a directory list | ||
| 559 | * @param items The directory entries | ||
| 560 | * @param num_items Number of entries in directory | ||
| 561 | */ | ||
| 562 | void FreeDirectory(VFSDirEntry* items, unsigned int num_items) | ||
| 563 | { | ||
| 564 | m_Callbacks->FreeDirectory(m_Handle->addonData, items, num_items); | ||
| 565 | } | ||
| 566 | |||
| 567 | /*! | ||
| 568 | * @brief Create a Curl representation | ||
| 569 | * @param strURL the URL of the Type. | ||
| 570 | */ | ||
| 571 | void* CURLCreate(const char* strURL) | ||
| 572 | { | ||
| 573 | return m_Callbacks->CURLCreate(m_Handle->addonData, strURL); | ||
| 574 | } | ||
| 575 | |||
| 576 | /*! | ||
| 577 | * @brief Adds options to the curl file created with CURLCeate | ||
| 578 | * @param file file pointer to the file returned by CURLCeate | ||
| 579 | * @param type option type to set | ||
| 580 | * @param name name of the option | ||
| 581 | * @param value value of the option | ||
| 582 | */ | ||
| 583 | bool CURLAddOption(void* file, XFILE::CURLOPTIONTYPE type, const char* name, const char * value) | ||
| 584 | { | ||
| 585 | return m_Callbacks->CURLAddOption(m_Handle->addonData, file, type, name, value); | ||
| 586 | } | ||
| 587 | |||
| 588 | /*! | ||
| 589 | * @brief Opens the curl file created with CURLCeate | ||
| 590 | * @param file file pointer to the file returned by CURLCeate | ||
| 591 | * @param flags one or more bitwise or combinded flags form XFILE | ||
| 592 | */ | ||
| 593 | bool CURLOpen(void* file, unsigned int flags) | ||
| 594 | { | ||
| 595 | return m_Callbacks->CURLOpen(m_Handle->addonData, file, flags); | ||
| 596 | } | ||
| 597 | |||
| 598 | private: | ||
| 599 | AddonCB* m_Handle; | ||
| 600 | KodiAPI::AddOn::CB_AddOnLib *m_Callbacks; | ||
| 601 | }; | ||
| 602 | }; | ||
