summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h90
1 files changed, 76 insertions, 14 deletions
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 @@
22#include "AddonBase.h" 22#include "AddonBase.h"
23 23
24#include <map> 24#include <map>
25#include <vector>
25 26
26#if !defined(_WIN32) 27#if !defined(_WIN32)
27 #include <sys/stat.h> 28 #include <sys/stat.h>
28 #if !defined(__stat64) 29 #if !defined(__stat64)
29 #define __stat64 stat64 30 #if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
31 #define __stat64 stat
32 #else
33 #define __stat64 stat64
34 #endif
30 #endif 35 #endif
31#endif 36#endif
32#ifdef _WIN32 // windows 37#ifdef _WIN32 // windows
@@ -110,7 +115,7 @@ extern "C"
110 double (*get_file_download_speed)(void* kodiBase, void* file); 115 double (*get_file_download_speed)(void* kodiBase, void* file);
111 void (*close_file)(void* kodiBase, void* file); 116 void (*close_file)(void* kodiBase, void* file);
112 int (*get_file_chunk_size)(void* kodiBase, void* file); 117 int (*get_file_chunk_size)(void* kodiBase, void* file);
113 char* (*get_property)(void* kodiBase, void* file, int type, const char *name); 118 char** (*get_property_values)(void* kodiBase, void* file, int type, const char *name, int *numValues);
114 119
115 void* (*curl_create)(void* kodiBase, const char* url); 120 void* (*curl_create)(void* kodiBase, const char* url);
116 bool (*curl_add_option)(void* kodiBase, void* file, int type, const char* name, const char* value); 121 bool (*curl_add_option)(void* kodiBase, void* file, int type, const char* name, const char* value);
@@ -180,16 +185,40 @@ typedef enum OpenFileFlags
180 185
181//============================================================================== 186//==============================================================================
182/// \ingroup cpp_kodi_vfs_Defs 187/// \ingroup cpp_kodi_vfs_Defs
183/// @brief Used CURL message types 188/// @brief CURL message types
189///
190/// Used on kodi::vfs::CFile::CURLAddOption()
184/// 191///
185typedef enum CURLOptiontype 192typedef enum CURLOptiontype
186{ 193{
187 /// Set a general option 194 /// Set a general option
188 ADDON_CURL_OPTION_OPTION, 195 ADDON_CURL_OPTION_OPTION,
196
189 /// Set a protocol option 197 /// Set a protocol option
198 ///
199 /// The following names for *ADDON_CURL_OPTION_PROTOCOL* are possible:
200 ///
201 /// | Option name | Description
202 /// |---------------------------:|:----------------------------------------------------------
203 /// | accept-charset | Set the "accept-charset" header
204 /// | acceptencoding or encoding | Set the "accept-encoding" header
205 /// | active-remote | Set the "active-remote" header
206 /// | auth | Set the authentication method. Possible values: any, anysafe, digest, ntlm
207 /// | connection-timeout | Set the connection timeout in seconds
208 /// | cookie | Set the "cookie" header
209 /// | customrequest | Set a custom HTTP request like DELETE
210 /// | noshout | Set to true if kodi detects a stream as shoutcast by mistake.
211 /// | postdata | Set the post body (value needs to be base64 encoded). (Implicitly sets the request to POST)
212 /// | referer | Set the "referer" header
213 /// | user-agent | Set the "user-agent" header
214 /// | seekable | Set the stream seekable. 1: enable, 0: disable
215 /// | sslcipherlist | Set list of accepted SSL ciphers.
216 ///
190 ADDON_CURL_OPTION_PROTOCOL, 217 ADDON_CURL_OPTION_PROTOCOL,
218
191 /// Set User and password 219 /// Set User and password
192 ADDON_CURL_OPTION_CREDENTIALS, 220 ADDON_CURL_OPTION_CREDENTIALS,
221
193 /// Add a Header 222 /// Add a Header
194 ADDON_CURL_OPTION_HEADER 223 ADDON_CURL_OPTION_HEADER
195} CURLOptiontype; 224} CURLOptiontype;
@@ -197,7 +226,9 @@ typedef enum CURLOptiontype
197 226
198//============================================================================== 227//==============================================================================
199/// \ingroup cpp_kodi_vfs_Defs 228/// \ingroup cpp_kodi_vfs_Defs
200/// @brief Used CURL message types 229/// @brief CURL message types
230///
231/// Used on kodi::vfs::CFile::GetPropertyValue() and kodi::vfs::CFile::GetPropertyValues()
201/// 232///
202typedef enum FilePropertyTypes 233typedef enum FilePropertyTypes
203{ 234{
@@ -210,7 +241,9 @@ typedef enum FilePropertyTypes
210 /// Get file content charset 241 /// Get file content charset
211 ADDON_FILE_PROPERTY_CONTENT_CHARSET, 242 ADDON_FILE_PROPERTY_CONTENT_CHARSET,
212 /// Get file mime type 243 /// Get file mime type
213 ADDON_FILE_PROPERTY_MIME_TYPE 244 ADDON_FILE_PROPERTY_MIME_TYPE,
245 /// Get file effective URL (last one if redirected)
246 ADDON_FILE_PROPERTY_EFFECTIVE_URL
214} FilePropertyTypes; 247} FilePropertyTypes;
215//------------------------------------------------------------------------------ 248//------------------------------------------------------------------------------
216 249
@@ -1027,7 +1060,7 @@ namespace vfs
1027 /// #include <kodi/Filesystem.h> 1060 /// #include <kodi/Filesystem.h>
1028 /// ... 1061 /// ...
1029 /// STAT_STRUCTURE statFile; 1062 /// STAT_STRUCTURE statFile;
1030 /// int ret = kodi::vfs::StatFile("special://temp/kodi.log", &statFile); 1063 /// int ret = kodi::vfs::StatFile("special://temp/kodi.log", statFile);
1031 /// fprintf(stderr, "deviceId (ID of device containing file) = %u\n" 1064 /// fprintf(stderr, "deviceId (ID of device containing file) = %u\n"
1032 /// "size (total size, in bytes) = %lu\n" 1065 /// "size (total size, in bytes) = %lu\n"
1033 /// "accessTime (time of last access) = %lu\n" 1066 /// "accessTime (time of last access) = %lu\n"
@@ -1540,22 +1573,51 @@ namespace vfs
1540 /// @param[in] name The name of a named property value (e.g. Header) 1573 /// @param[in] name The name of a named property value (e.g. Header)
1541 /// @return value of requested property, empty on failure / non-existance 1574 /// @return value of requested property, empty on failure / non-existance
1542 /// 1575 ///
1543 const std::string GetProperty(FilePropertyTypes type, const std::string &name) const 1576 const std::string GetPropertyValue(FilePropertyTypes type, const std::string &name) const
1544 { 1577 {
1545 if (!m_file) 1578 if (!m_file)
1546 { 1579 {
1547 kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before GetProperty!"); 1580 kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValue!");
1581 return "";
1582 }
1583 std::vector<std::string> values = GetPropertyValues(type, name);
1584 if (values.empty()) {
1548 return ""; 1585 return "";
1549 } 1586 }
1550 char *res(::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_property( 1587 return values[0];
1551 ::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str())); 1588 }
1589 //--------------------------------------------------------------------------
1590
1591 //==========================================================================
1592 ///
1593 /// @ingroup cpp_kodi_vfs_CFile
1594 /// @brief retrieve file property values
1595 ///
1596 /// @param[in] type The type of the file property values to retrieve the value for
1597 /// @param[in] name The name of the named property (e.g. Header)
1598 /// @return values of requested property, empty vector on failure / non-existance
1599 ///
1600 const std::vector<std::string> GetPropertyValues(FilePropertyTypes type, const std::string &name) const
1601 {
1602 if (!m_file)
1603 {
1604 kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValues!");
1605 return std::vector<std::string>();
1606 }
1607 int numValues;
1608 char **res(::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_property_values(
1609 ::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), &numValues));
1552 if (res) 1610 if (res)
1553 { 1611 {
1554 std::string strReturn(res); 1612 std::vector<std::string> vecReturn;
1555 ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, res); 1613 for (int i = 0; i < numValues; ++i)
1556 return strReturn; 1614 {
1615 vecReturn.emplace_back(res[i]);
1616 }
1617 ::kodi::addon::CAddonBase::m_interface->toKodi->free_string_array(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, res, numValues);
1618 return vecReturn;
1557 } 1619 }
1558 return ""; 1620 return std::vector<std::string>();
1559 } 1621 }
1560 //-------------------------------------------------------------------------- 1622 //--------------------------------------------------------------------------
1561 1623