From 4830f27a40323fe859dc166337a2b861877b7121 Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 1 Jan 2018 13:40:09 +0100 Subject: sync with upstream --- .../kodi-addon-dev-kit/include/kodi/Filesystem.h | 90 ++++++++++++++++++---- 1 file changed, 76 insertions(+), 14 deletions(-) (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h') diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h index b06770c..b089da3 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h @@ -22,11 +22,16 @@ #include "AddonBase.h" #include +#include #if !defined(_WIN32) #include #if !defined(__stat64) - #define __stat64 stat64 + #if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) + #define __stat64 stat + #else + #define __stat64 stat64 + #endif #endif #endif #ifdef _WIN32 // windows @@ -110,7 +115,7 @@ extern "C" double (*get_file_download_speed)(void* kodiBase, void* file); void (*close_file)(void* kodiBase, void* file); int (*get_file_chunk_size)(void* kodiBase, void* file); - char* (*get_property)(void* kodiBase, void* file, int type, const char *name); + char** (*get_property_values)(void* kodiBase, void* file, int type, const char *name, int *numValues); void* (*curl_create)(void* kodiBase, const char* url); bool (*curl_add_option)(void* kodiBase, void* file, int type, const char* name, const char* value); @@ -180,16 +185,40 @@ typedef enum OpenFileFlags //============================================================================== /// \ingroup cpp_kodi_vfs_Defs -/// @brief Used CURL message types +/// @brief CURL message types +/// +/// Used on kodi::vfs::CFile::CURLAddOption() /// typedef enum CURLOptiontype { /// Set a general option ADDON_CURL_OPTION_OPTION, + /// Set a protocol option + /// + /// The following names for *ADDON_CURL_OPTION_PROTOCOL* are possible: + /// + /// | Option name | Description + /// |---------------------------:|:---------------------------------------------------------- + /// | accept-charset | Set the "accept-charset" header + /// | acceptencoding or encoding | Set the "accept-encoding" header + /// | active-remote | Set the "active-remote" header + /// | auth | Set the authentication method. Possible values: any, anysafe, digest, ntlm + /// | connection-timeout | Set the connection timeout in seconds + /// | cookie | Set the "cookie" header + /// | customrequest | Set a custom HTTP request like DELETE + /// | noshout | Set to true if kodi detects a stream as shoutcast by mistake. + /// | postdata | Set the post body (value needs to be base64 encoded). (Implicitly sets the request to POST) + /// | referer | Set the "referer" header + /// | user-agent | Set the "user-agent" header + /// | seekable | Set the stream seekable. 1: enable, 0: disable + /// | sslcipherlist | Set list of accepted SSL ciphers. + /// ADDON_CURL_OPTION_PROTOCOL, + /// Set User and password ADDON_CURL_OPTION_CREDENTIALS, + /// Add a Header ADDON_CURL_OPTION_HEADER } CURLOptiontype; @@ -197,7 +226,9 @@ typedef enum CURLOptiontype //============================================================================== /// \ingroup cpp_kodi_vfs_Defs -/// @brief Used CURL message types +/// @brief CURL message types +/// +/// Used on kodi::vfs::CFile::GetPropertyValue() and kodi::vfs::CFile::GetPropertyValues() /// typedef enum FilePropertyTypes { @@ -210,7 +241,9 @@ typedef enum FilePropertyTypes /// Get file content charset ADDON_FILE_PROPERTY_CONTENT_CHARSET, /// Get file mime type - ADDON_FILE_PROPERTY_MIME_TYPE + ADDON_FILE_PROPERTY_MIME_TYPE, + /// Get file effective URL (last one if redirected) + ADDON_FILE_PROPERTY_EFFECTIVE_URL } FilePropertyTypes; //------------------------------------------------------------------------------ @@ -1027,7 +1060,7 @@ namespace vfs /// #include /// ... /// STAT_STRUCTURE statFile; - /// int ret = kodi::vfs::StatFile("special://temp/kodi.log", &statFile); + /// int ret = kodi::vfs::StatFile("special://temp/kodi.log", statFile); /// fprintf(stderr, "deviceId (ID of device containing file) = %u\n" /// "size (total size, in bytes) = %lu\n" /// "accessTime (time of last access) = %lu\n" @@ -1540,22 +1573,51 @@ namespace vfs /// @param[in] name The name of a named property value (e.g. Header) /// @return value of requested property, empty on failure / non-existance /// - const std::string GetProperty(FilePropertyTypes type, const std::string &name) const + const std::string GetPropertyValue(FilePropertyTypes type, const std::string &name) const { if (!m_file) { - kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before GetProperty!"); + kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValue!"); + return ""; + } + std::vector values = GetPropertyValues(type, name); + if (values.empty()) { return ""; } - char *res(::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_property( - ::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str())); + return values[0]; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @ingroup cpp_kodi_vfs_CFile + /// @brief retrieve file property values + /// + /// @param[in] type The type of the file property values to retrieve the value for + /// @param[in] name The name of the named property (e.g. Header) + /// @return values of requested property, empty vector on failure / non-existance + /// + const std::vector GetPropertyValues(FilePropertyTypes type, const std::string &name) const + { + if (!m_file) + { + kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValues!"); + return std::vector(); + } + int numValues; + char **res(::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_property_values( + ::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), &numValues)); if (res) { - std::string strReturn(res); - ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, res); - return strReturn; + std::vector vecReturn; + for (int i = 0; i < numValues; ++i) + { + vecReturn.emplace_back(res[i]); + } + ::kodi::addon::CAddonBase::m_interface->toKodi->free_string_array(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, res, numValues); + return vecReturn; } - return ""; + return std::vector(); } //-------------------------------------------------------------------------- -- cgit v1.2.3