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 and date \n
35 * and updating the media folder to the media database.
39 * @addtogroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
45 * @brief Gets the count of folder for the passed @a filter from the media database.
46 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
48 * @param[in] filter The handle to the media filter
49 * @param[out] folder_count The count of the media folder
51 * @return @c 0 on success,
52 * otherwise a negative error value
54 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
55 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
56 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
57 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
59 * @pre This function requires opened connection to content service by media_content_connect().
61 * @see media_content_connect()
63 int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count);
66 * @brief Iterates through available media folders with optional @a filter from the media database.
67 * @details This function gets the media folder meeting the given @a filter.
68 * The @a callback function will be invoked for every retrieved
69 * folder. If @c NULL is passed to the @a filter, no filtering is applied.
71 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
73 * @remarks Do not call updating DB function like media_folder_update_to_db() in your callback function, your callback function is invoked as inline function.\n
74 * So, your callback function is in read state in SQLite. When you are in read state, sometimes you do not update DB. \n
75 * We do not recommend you call updating DB function in callback of foreach function.
77 * @param[in] filter The handle to the media filter
78 * @param[in] callback The callback function to be invoked
79 * @param[in] user_data The user data to be passed to the callback function
81 * @return @c 0 on success,
82 * otherwise a negative error value
84 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
85 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
86 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
87 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
88 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
90 * @pre This function requires opened connection to content service by media_content_connect().
91 * @pre A filter handle has to be created by calling media_filter_create().
92 * @post This function invokes media_folder_cb().
94 * @see media_content_connect()
95 * @see media_folder_cb()
96 * @see media_filter_create()
98 int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data);
101 * @brief Gets the count of media files for the passed @a filter in the given @a folder_id from the media database.
102 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
104 * @param[in] folder_id The ID of the media folder
105 * @param[in] filter The handle to the media filter
106 * @param[out] media_count The count of media folder items
108 * @return @c 0 on success,
109 * otherwise a negative error value
111 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
112 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
113 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
114 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
116 * @pre This function requires opened connection to content service by media_content_connect().
118 * @see media_content_connect()
120 int media_folder_get_media_count_from_db(const char *folder_id, filter_h filter, int *media_count);
123 * @brief Iterates through the media files with an optional @a filter in the given @a folder_id from the media database.
124 * @details This function gets all media files associated with the given folder and
125 * meeting desired filter option and calls @a callback for
126 * every retrieved media item. If @c NULL is passed to the @a filter, no filtering is applied.
128 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
130 * @remarks Do not call updating DB function like media_info_update_to_db(), media_info_refresh_metadata_to_db(), audio_meta_update_to_db(), image_meta_update_to_db() and video_meta_update_to_db() in your callback function,
131 * your callback function is invoked as inline function. \n
132 * So, your callback function is in read state in SQLite. When you are in read state, sometimes you do not update DB. \n
133 * We do not recommend you call updating DB function in callback of foreach function.
135 * @param[in] folder_id The ID of the media folder
136 * @param[in] filter The handle to the media filter
137 * @param[in] callback The callback function to be invoked
138 * @param[in] user_data The user data to be passed to the callback function
140 * @return @c 0 on success,
141 * otherwise a negative error value
143 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
144 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
145 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
146 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
147 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
149 * @pre This function requires opened connection to content service by media_content_connect().
150 * @post This function invokes media_info_cb().
152 * @see #media_info_cb
153 * @see media_content_connect()
154 * @see media_filter_create()
156 int media_folder_foreach_media_from_db(const char *folder_id, filter_h filter, media_info_cb callback, void *user_data);
159 * @brief Clones the media folder.
160 * @details This function copies the media folder handle from a source to
161 * destination. There is no media_folder_create() function. The media_folder_h is created internally and available through
162 * media folder foreach function such as media_folder_foreach_folder_from_db(). To use this handle outside of these foreach functions,
165 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
167 * @remarks The @a dst should be released using media_folder_destroy().
169 * @param[out] dst The destination handle to the media folder
170 * @param[in] src The source handle to the media folder
172 * @return @c 0 on success,
173 * otherwise a negative error value
175 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
176 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
178 * @see media_folder_destroy()
179 * @see media_folder_foreach_folder_from_db()
181 int media_folder_clone(media_folder_h *dst, media_folder_h src);
184 * @brief Destroys the media folder.
185 * @details The function frees all resources related to the folder handle. This handle
186 * no longer can be used to perform any operations. A new handle has to
187 * be created before the next use.
189 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
191 * @param[in] folder The handle to the media folder
193 * @return @c 0 on success,
194 * otherwise a negative error value
196 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
197 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
199 * @pre A copy of the media folder handle created by calling media_folder_clone().
201 * @see media_folder_clone()
203 int media_folder_destroy(media_folder_h folder);
206 * @brief Gets the media folder ID.
207 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
209 * @remarks The @a folder_id should be released using free().
211 * @param[in] folder The handle to the media folder
212 * @param[out] folder_id The ID of the media folder
214 * @return @c 0 on success,
215 * otherwise a negative error value
217 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
218 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
220 int media_folder_get_folder_id(media_folder_h folder, char **folder_id);
223 * @deprecated Deprecated since 4.0.
224 * @brief Gets the parent folder ID.
225 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
227 * @remarks The @a parent_folder_id should be released using free().
229 * @param[in] folder The handle to the media folder
230 * @param[out] parent_folder_id The ID of the upper media folder
232 * @return @c 0 on success,
233 * otherwise a negative error value
235 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
236 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
238 int media_folder_get_parent_folder_id(media_folder_h folder, char **parent_folder_id) TIZEN_DEPRECATED_API;
241 * @brief Gets the absolute path to the media folder.
242 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
244 * @remarks The @a path should be released using free().
246 * @param[in] folder The handle to the media folder
247 * @param[out] path The path of the media folder
249 * @return @c 0 on success,
250 * otherwise a negative error value
252 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
253 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
254 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
257 int media_folder_get_path(media_folder_h folder, char **path);
260 * @brief Gets the media folder name.
261 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
263 * @remarks The @a folder_name should be released using free().
265 * @param[in] folder The handle to the media folder
266 * @param[out] folder_name The name of 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
275 int media_folder_get_name(media_folder_h folder, char **folder_name);
278 * @deprecated Deprecated since 4.0.
279 * @brief Gets the modified date of the folder.
280 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
282 * @param[in] folder The handle to the media folder
283 * @param[out] date The modified date of the media folder
285 * @return @c 0 on success,
286 * otherwise a negative error value
288 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
289 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
291 int media_folder_get_modified_time(media_folder_h folder, time_t *date) TIZEN_DEPRECATED_API;
294 * @deprecated Deprecated since 5.0. Use storage_get_type_dev() instead.
295 * @brief Gets the folder storage type.
296 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
298 * @param[in] folder The handle to the media folder
299 * @param[out] storage_type The storage type of the media folder
301 * @return @c 0 on success,
302 * otherwise a negative error value
304 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
305 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
307 int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e *storage_type) TIZEN_DEPRECATED_API;
310 * @deprecated Deprecated since 5.0.
311 * @brief Gets the storage id of the folder.
312 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
314 * @remarks The @a storage_id should be released using free().
316 * @param[in] folder The handle to the media folder
317 * @param[out] storage_id The storage id of the media folder
319 * @return @c 0 on success,
320 * otherwise a negative error value
322 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
323 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
324 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
326 int media_folder_get_storage_id(media_folder_h folder, char **storage_id) TIZEN_DEPRECATED_API;
329 * @deprecated Deprecated since 4.0. \n
330 * This function does not guarantee order independence between applications. It is recommended that the viewing order is managed by the application.
332 * @brief Gets the folder viewing order.
333 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
335 * @param[in] folder The handle to the media folder
336 * @param[out] order The viewing order of the media folder
338 * @return @c 0 on success,
339 * otherwise a negative error value
341 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
342 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
344 * @post media_folder_update_to_db()
346 int media_folder_get_order(media_folder_h folder, int *order) TIZEN_DEPRECATED_API;
349 * @brief Gets the media folder from the media database.
351 * @details This function creates a new media folder handle from the media database by the given @a folder_id.
352 * Media folder will be created, which is filled with folder information.
353 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
355 * @remarks The @a folder should be released using media_folder_destroy().
357 * @param[in] folder_id The ID of the media folder
358 * @param[out] folder The handle to the media folder
360 * @return @c 0 on success,
361 * otherwise a negative error value
363 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
364 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
365 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
366 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
367 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
369 * @pre This function requires opened connection to content service by media_content_connect().
371 * @see media_content_connect()
372 * @see media_folder_destroy()
375 int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder);
378 * @deprecated Deprecated since 4.0. Use media_content_scan_folder() or media_info_move_to_db() instead.
379 * @brief Sets the folder name.
380 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
382 * @param[in] folder The handle to the media folder
383 * @param[in] name The name of the media folder
385 * @return @c 0 on success,
386 * otherwise a negative error value
388 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
389 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
390 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
391 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
393 int media_folder_set_name(media_folder_h folder, const char *name) TIZEN_DEPRECATED_API;
396 * @deprecated Deprecated since 4.0. \n
397 * This function does not guarantee order independence between applications. It is recommended that the viewing order is managed by the application.
398 * @brief Sets the folder viewing order.
399 * @details If you set the order value for each folder, you can sort in ascending or descending order as the set order values using the filter. \n
400 * Moreover, more detailed settings are possible when used with the filter. \n
402 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
403 * @remarks If you don't set the order value, the order value will be set default value. Default is 0. \n
404 * If you don't use the filter, the set order value does not effect the folder viewing order.
406 * @param[in] folder The handle to the media folder
407 * @param[in] order The viewing order of the media folder
409 * @return @c 0 on success,
410 * otherwise a negative error value
412 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
413 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
415 int media_folder_set_order(media_folder_h folder, int order) TIZEN_DEPRECATED_API;
418 * @deprecated Deprecated since 4.0. Related setter functions are deprecated, therefore this function is not needed anymore.
419 * @brief Updates the media folder to the media database.
421 * @details The function updates the given media folder in the media database. The function should be called after any change in folder attributes, to be updated to the media
424 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
427 * @privilege %http://tizen.org/privilege/content.write
429 * @param[in] folder The handle to the media folder
431 * @return @c 0 on success,
432 * otherwise a negative error value
434 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
435 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
436 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
437 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
438 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
439 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
440 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
441 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
443 * @pre This function requires opened connection to content service by media_content_connect().
445 * @see media_content_connect()
446 * @see media_folder_destroy()
448 int media_folder_update_to_db(media_folder_h folder) TIZEN_DEPRECATED_API;
456 #endif /* __cplusplus */
458 #endif /* __TIZEN_CONTENT_MEDIA_FOLDER_H__ */