2 * Copyright (c) 2011 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.
18 #ifndef __TIZEN_CONTENT_MEDIA_FOLDER_H__
19 #define __TIZEN_CONTENT_MEDIA_FOLDER_H__
22 #include <media_content_type.h>
27 #endif /* __cplusplus */
30 * @file media_folder.h
31 * @brief This file contains API related to all operations with media folder in DB. \n
32 * These functions include getting the number of folders and media files filtered from DB, \n
33 * iterating through media files and folders filtered in the given folder from DB; \n
34 * cloning and destroying the media folder, getting its name, ID, absolute path.
38 * @addtogroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
44 * @brief Gets the count of folder for the passed @a filter from the media database.
47 * @param[in] filter The handle to the media filter
48 * @param[out] folder_count The count of the media folder
50 * @return @c 0 on success,
51 * otherwise a negative error value
53 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
54 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
55 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
56 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
58 * @pre This function requires opened connection to content service by media_content_connect().
60 * @see media_content_connect()
62 int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count);
65 * @brief Iterates through available media folders with optional @a filter from the media database.
66 * @details This function gets the media folder meeting the given @a filter.
67 * The @a callback function will be invoked for every retrieved
68 * folder. If @c NULL is passed to the @a filter, no filtering is applied.
72 * @remarks We do not recommend you call updating DB function in callback of foreach function.
74 * @param[in] filter The handle to the media filter
75 * @param[in] callback The callback function to be invoked
76 * @param[in] user_data The user data to be passed to the callback function
78 * @return @c 0 on success,
79 * otherwise a negative error value
81 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
82 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
83 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
84 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
85 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
87 * @pre This function requires opened connection to content service by media_content_connect().
88 * @pre A filter handle has to be created by calling media_filter_create().
89 * @post This function invokes media_folder_cb().
91 * @see media_content_connect()
92 * @see media_folder_cb()
93 * @see media_filter_create()
95 int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data);
98 * @brief Gets the count of media files for the passed @a filter in the given @a folder_id from the media database.
101 * @param[in] folder_id The ID of the media folder
102 * @param[in] filter The handle to the media filter
103 * @param[out] media_count The count of media folder items
105 * @return @c 0 on success,
106 * otherwise a negative error value
108 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
109 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
110 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
111 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
113 * @pre This function requires opened connection to content service by media_content_connect().
115 * @see media_content_connect()
117 int media_folder_get_media_count_from_db(const char *folder_id, filter_h filter, int *media_count);
120 * @brief Iterates through the media files with an optional @a filter in the given @a folder_id from the media database.
121 * @details This function gets all media files associated with the given folder and
122 * meeting desired filter option and calls @a callback for
123 * every retrieved media item. If @c NULL is passed to the @a filter, no filtering is applied.
127 * @remarks Do not call updating DB function like media_info_update_to_db() in your callback function,
128 * your callback function is invoked as inline function. \n
129 * So, your callback function is in read state in SQLite. When you are in read state, sometimes you do not update DB. \n
130 * We do not recommend you call updating DB function in callback of foreach function.
132 * @param[in] folder_id The ID of the media folder
133 * @param[in] filter The handle to the media filter
134 * @param[in] callback The callback function to be invoked
135 * @param[in] user_data The user data to be passed to the callback function
137 * @return @c 0 on success,
138 * otherwise a negative error value
140 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
141 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
142 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
143 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
144 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
146 * @pre This function requires opened connection to content service by media_content_connect().
147 * @post This function invokes media_info_cb().
149 * @see #media_info_cb
150 * @see media_content_connect()
151 * @see media_filter_create()
153 int media_folder_foreach_media_from_db(const char *folder_id, filter_h filter, media_info_cb callback, void *user_data);
156 * @brief Clones the media folder.
157 * @details This function copies the media folder handle from a source to
158 * destination. There is no media_folder_create() function. The media_folder_h is created internally and available through
159 * media folder foreach function such as media_folder_foreach_folder_from_db(). To use this handle outside of these foreach functions,
164 * @remarks The @a dst should be released using media_folder_destroy().
166 * @param[out] dst The destination handle to the media folder
167 * @param[in] src The source handle to the media folder
169 * @return @c 0 on success,
170 * otherwise a negative error value
172 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
173 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
175 * @see media_folder_destroy()
176 * @see media_folder_foreach_folder_from_db()
178 int media_folder_clone(media_folder_h *dst, media_folder_h src);
181 * @brief Destroys the media folder.
182 * @details The function frees all resources related to the folder handle. This handle
183 * no longer can be used to perform any operations. A new handle has to
184 * be created before the next use.
188 * @param[in] folder The handle to the media folder
190 * @return @c 0 on success,
191 * otherwise a negative error value
193 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
194 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
196 * @pre A copy of the media folder handle created by calling media_folder_clone().
198 * @see media_folder_clone()
200 int media_folder_destroy(media_folder_h folder);
203 * @brief Gets the media folder ID.
206 * @remarks The @a folder_id should be released using free().
208 * @param[in] folder The handle to the media folder
209 * @param[out] folder_id The ID of the media folder
211 * @return @c 0 on success,
212 * otherwise a negative error value
214 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
215 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
217 int media_folder_get_folder_id(media_folder_h folder, char **folder_id);
220 * @brief Gets the absolute path to the media folder.
223 * @remarks The @a path should be released using free().
225 * @param[in] folder The handle to the media folder
226 * @param[out] path The path of the media folder
228 * @return @c 0 on success,
229 * otherwise a negative error value
231 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
232 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
233 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
236 int media_folder_get_path(media_folder_h folder, char **path);
239 * @brief Gets the media folder name.
242 * @remarks The @a folder_name should be released using free().
244 * @param[in] folder The handle to the media folder
245 * @param[out] folder_name The name of the media folder
247 * @return @c 0 on success,
248 * otherwise a negative error value
250 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
251 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
252 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
254 int media_folder_get_name(media_folder_h folder, char **folder_name);
257 * @brief Gets the media folder from the media database.
259 * @details This function creates a new media folder handle from the media database by the given @a folder_id.
260 * Media folder will be created, which is filled with folder information.
263 * @remarks The @a folder should be released using media_folder_destroy().
265 * @param[in] folder_id The ID of the media folder
266 * @param[out] folder The handle to the media folder
268 * @return @c 0 on success,
269 * otherwise a negative error value
271 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
272 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
273 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
274 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
275 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
277 * @pre This function requires opened connection to content service by media_content_connect().
279 * @see media_content_connect()
280 * @see media_folder_destroy()
283 int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder);
291 #endif /* __cplusplus */
293 #endif /* __TIZEN_CONTENT_MEDIA_FOLDER_H__ */