2 * Copyright (c) 2011 - 2021 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __TIZEN_CONTENT_MIME_TYPE_H__
18 #define __TIZEN_CONTENT_MIME_TYPE_H__
20 #include <sys/types.h>
29 * @addtogroup CAPI_CONTENT_MIME_TYPE_MODULE
35 * @brief Enumeration of error code.
36 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
39 MIME_TYPE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
40 MIME_TYPE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
41 MIME_TYPE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
42 MIME_TYPE_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */
43 MIME_TYPE_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< No access for the file (Since 4.0) */
48 * @brief Gets the MIME type for the given file extension.
50 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
51 * @remarks The @a mime_type must be released with free() by you.
52 * @param[in] file_extension The file extension without the leading dot ('.')
53 * @param[out] mime_type The MIME type for the given file extension \n
54 * The MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats
55 * @return 0 on success, otherwise a negative error value.
56 * @retval #MIME_TYPE_ERROR_NONE Successful
57 * @retval #MIME_TYPE_ERROR_INVALID_PARAMETER Invalid parameter
58 * @retval #MIME_TYPE_ERROR_OUT_OF_MEMORY Out of memory
59 * @retval #MIME_TYPE_ERROR_IO_ERROR Internal I/O error
60 * @see mime_type_get_file_extension()
62 int mime_type_get_mime_type(const char *file_extension, char **mime_type);
66 * @brief Gets the file extensions for the given MIME type.
68 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
69 * @remarks The @a file_extension must be released with free() by you.
70 * @param[in] mime_type The MIME type
71 * @param[out] file_extension The array of file extension without the leading dot ('.')
72 * @param[out] length The length of the array of file extension or zero if there is none
73 * @return 0 on success, otherwise a negative error value.
74 * @retval #MIME_TYPE_ERROR_NONE Successful
75 * @retval #MIME_TYPE_ERROR_INVALID_PARAMETER Invalid parameter
76 * @retval #MIME_TYPE_ERROR_OUT_OF_MEMORY Out of memory
77 * @retval #MIME_TYPE_ERROR_IO_ERROR Internal I/O error
78 * @see mime_type_get_mime_type()
80 int mime_type_get_file_extension(const char *mime_type, char ***file_extension, int *length);
83 * @brief Gets the MIME type for the given data.
86 * @remarks The @a mime_type must be released with free() by you.
87 * @param[in] data The stream of file data
88 * @param[in] len The length of data
89 * @param[out] mime_type The MIME type for the given file extension \n
90 * The MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats
91 * @return 0 on success, otherwise a negative error value.
92 * @retval #MIME_TYPE_ERROR_NONE Successful
93 * @retval #MIME_TYPE_ERROR_INVALID_PARAMETER Invalid parameter
94 * @retval #MIME_TYPE_ERROR_OUT_OF_MEMORY Out of memory
95 * @retval #MIME_TYPE_ERROR_IO_ERROR Internal I/O error
97 int mime_type_get_mime_type_for_data(const void *data, size_t len, char **mime_type);
100 * @brief Gets the MIME type for the given file path.
103 * @remarks The @a mime_type must be released with free() by you.
104 * @remarks %http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.
105 * @remarks %http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
106 * @param[in] file_path The path of target file
107 * @param[out] mime_type The MIME type for the given file extension \n
108 * The MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats
109 * @return 0 on success, otherwise a negative error value.
110 * @retval #MIME_TYPE_ERROR_NONE Successful
111 * @retval #MIME_TYPE_ERROR_INVALID_PARAMETER Invalid parameter
112 * @retval #MIME_TYPE_ERROR_OUT_OF_MEMORY Out of memory
113 * @retval #MIME_TYPE_ERROR_IO_ERROR Internal I/O error
114 * @retval #MIME_TYPE_ERROR_PERMISSION_DENIED Permission denied
116 int mime_type_get_mime_type_for_file(const char *file_path, char **mime_type);
126 #endif /* __TIZEN_CONTENT_MIME_TYPE_H__ */