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_MEDIA_FOLDER_H__
19 #define __TIZEN_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.
48 * @param[in] filter The handle to filter \n
49 * To allow searching over different content types, you should use #filter_h.
50 * @param[out] folder_count The count of the media folder
52 * @return @c 0 on success,
53 * otherwise a negative error value
55 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
56 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
57 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
58 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
59 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
61 * @pre This function requires opened connection to content service by media_content_connect().
63 * @see media_content_connect()
65 int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count);
68 * @brief Iterates through available media folders with optional @a filter from the media database.
69 * @details This function gets the media folder meeting the given @a filter.
70 * The @a callback function will be invoked for every retrieved
71 * folder. If @c NULL is passed to the @a filter, no filtering is applied.
75 * @remarks Do not call updating DB fuction like media_folder_update_to_db() in your callback function, your callback function is invoked as inline function.\n
76 * So, your callback function is in read state in SQLite. When you are in read state, sometimes you do not update DB. \n
77 * We do not recommend you call updating DB function in callback of foreach function.
79 * @param[in] filter The handle to the media folder filter
80 * @param[in] callback The callback function to be invoked
81 * @param[in] user_data The user data to be passed to the callback function
83 * @return @c 0 on success,
84 * otherwise a negative error value
86 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
87 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
88 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
89 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
90 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
91 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
93 * @pre This function requires opened connection to content service by media_content_connect().
94 * @pre A filter handle has to be created by calling media_filter_create().
95 * @post This function invokes media_folder_cb().
97 * @see media_content_connect()
98 * @see media_folder_cb()
99 * @see media_filter_create()
101 int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data);
104 * @brief Gets the count of media files for the passed @a filter in the given @a folder from the media database.
107 * @param[in] folder_id The ID of the media folder
108 * @param[in] filter The filter of the media content
109 * @param[out] media_count The count of media folder items
111 * @return @c 0 on success,
112 * otherwise a negative error value
114 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
115 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
116 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
117 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
118 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
120 * @pre This function requires opened connection to content service by media_content_connect().
122 * @see media_content_connect()
124 int media_folder_get_media_count_from_db(const char *folder_id, filter_h filter, int *media_count);
127 * @brief Iterates through the media files with an optional @a filter in the given @a folder from the media database.
128 * @details This function gets all media files associated with the given folder and
129 * meeting desired filter option and calls registered callback function for
130 * every retrieved media item. If @c NULL is passed to the @a filter, no filtering is applied.
134 * @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,
135 * your callback function is invoked as inline function. \n
136 * So, your callback function is in read state in SQLite. When you are in read state, sometimes you do not update DB. \n
137 * We do not recommend you call updating DB function in callback of foreach function.
139 * @param[in] folder_id The ID of the media folder
140 * @param[in] filter The handle to the media info filter
141 * @param[in] callback The callback function to be invoked
142 * @param[in] user_data The user data to be passed to the callback function
144 * @return @c 0 on success,
145 * otherwise a negative error value
147 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
148 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
149 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
150 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
151 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
152 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
154 * @pre This function requires opened connection to content service by media_content_connect().
155 * @post This function invokes media_info_cb().
157 * @see #media_info_cb
158 * @see media_content_connect()
159 * @see media_filter_create()
161 int media_folder_foreach_media_from_db(const char *folder_id, filter_h filter, media_info_cb callback, void *user_data);
164 * @brief Clones the media folder.
165 * @details This function copies the media folder handle from a source to
166 * destination. There is no media_folder_create() function. The media_folder_h is created internally and available through
167 * media folder foreach function such as media_folder_foreach_folder_from_db(). To use this handle outside of these foreach functions,
172 * @remarks The destination handle must be released with media_folder_destroy().
174 * @param[out] dst The destination handle to the media folder
175 * @param[in] src The source handle to the media folder
177 * @return @c 0 on success,
178 * otherwise a negative error value
180 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
181 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
182 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
184 * @see media_folder_destroy()
185 * @see media_folder_foreach_folder_from_db()
187 int media_folder_clone(media_folder_h *dst, media_folder_h src);
190 * @brief Destroys the media folder.
191 * @details The function frees all resources related to the folder handle. This handle
192 * no longer can be used to perform any operation. A new handle has to
193 * be created before the next use.
197 * @param[in] folder The handle to the media folder
199 * @return @c 0 on success,
200 * otherwise a negative error value
202 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
203 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
204 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
206 * @pre A copy of the media folder handle created by calling media_folder_clone().
208 * @see media_folder_clone()
210 int media_folder_destroy(media_folder_h folder);
213 * @brief Gets the media folder ID.
216 * @remarks You must release @a folder_id using free().
218 * @param[in] folder The handle to the media folder
219 * @param[out] folder_id The ID of the media folder
221 * @return @c 0 on success,
222 * otherwise a negative error value
224 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
225 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
226 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
228 int media_folder_get_folder_id(media_folder_h folder, char **folder_id);
231 * @brief Gets the absolute path to the media folder.
234 * @remarks You must release @a path using free().
236 * @param[in] folder The handle to the media folder
237 * @param[out] path The path of the media folder
239 * @return @c 0 on success,
240 * otherwise a negative error value
242 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
243 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
244 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
245 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
248 int media_folder_get_path(media_folder_h folder, char **path);
251 * @brief Gets the media folder name.
254 * @remarks You must release @a folder_name using free().
256 * @param[in] folder The handle to the media folder
257 * @param[out] folder_name The name of the media folder
259 * @return @c 0 on success,
260 * otherwise a negative error value
262 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
263 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
264 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
265 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
267 int media_folder_get_name(media_folder_h folder, char **folder_name);
270 * @brief Gets the modified date of the folder.
273 * @param[in] folder The handle to the media folder
274 * @param[out] date The modified date of the folder
276 * @return @c 0 on success,
277 * otherwise a negative error value
279 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
280 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
282 int media_folder_get_modified_time(media_folder_h folder, time_t *date);
285 * @brief Gets the folder storage type.
288 * @param[in] folder The handle to the media folder
289 * @param[out] storage_type The storage type of the media folder
291 * @return @c 0 on success,
292 * otherwise a negative error value
294 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
295 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
296 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
298 int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e *storage_type);
301 * @brief Gets the storage id of the folder.
304 * @remarks You must release @a storage_id using free().
306 * @param[in] folder The handle to the media folder
307 * @param[out] storage_id The storage id of the media folder
309 * @return @c 0 on success,
310 * otherwise a negative error value
312 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
313 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
314 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
315 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
317 int media_folder_get_storage_id(media_folder_h folder, char **storage_id);
320 * @brief Gets the folder viewing order.
323 * @param[in] folder The handle to the media folder
324 * @param[out] order The viewing order of the media folder
326 * @return @c 0 on success,
327 * otherwise a negative error value
329 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
330 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
331 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
332 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
334 * @post media_folder_update_to_db()
336 int media_folder_get_order(media_folder_h folder, int *order);
339 * @brief Gets the media folder from the media database.
341 * @details This function creates a new media folder handle from the media database by the given @a folder_id.
342 * Media folder will be created, which is filled with folder information.
345 * @remarks You must release @a folder using media_folder_destroy().
347 * @param[in] folder_id The ID of the media folder
348 * @param[out] folder The media folder handle associated with the folder ID
350 * @return @c 0 on success,
351 * otherwise a negative error value
353 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
354 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
355 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
357 * @pre This function requires opened connection to content service by media_content_connect().
359 * @see media_content_connect()
360 * @see media_folder_destroy()
363 int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder);
366 * @brief Sets the folder name.
369 * @param[in] folder The handle to the media folder
370 * @param[in] name The name of the media folder
372 * @return @c 0 on success,
373 * otherwise a negative error value
375 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
376 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
377 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
378 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
380 * @post media_folder_update_to_db()
382 int media_folder_set_name(media_folder_h folder, const char *name);
385 * @brief Sets the folder viewing order.
386 * @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
387 * Moreover, more detailed settings are possible when used with the filter. \n
390 * @remarks If you don't set the order value, the order value will be set default value. Default is 0. \n
391 * If you don't use the filter, the set order value does not effect the folder viewing order.
393 * @param[in] folder The handle to the media folder
394 * @param[in] order The viewing order of the media folder
396 * @return @c 0 on success,
397 * otherwise a negative error value
399 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
400 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
401 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
402 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
404 * @post media_folder_update_to_db()
406 int media_folder_set_order(media_folder_h folder, int order);
409 * @brief Updates the media folder to the media database.
411 * @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
412 * database. For example, after using media_folder_set_name() for setting the name of the folder, the media_folder_update_to_db() function should be called so as to update
413 * the given folder attributes in the media database.
418 * @privilege %http://tizen.org/privilege/content.write
420 * @param[in] folder The handle to the media folder
422 * @return @c 0 on success,
423 * otherwise a negative error value
425 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
426 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
427 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
428 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
429 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
430 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
431 * @retval #MEDIA_CONTENT_ERROR_NETWORK Network fail
432 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
434 * @pre This function requires opened connection to content service by media_content_connect().
435 * @pre If you do not set new name of folder by using media_folder_set_name(), your updating function is failed.
437 * @see media_content_connect()
438 * @see media_folder_destroy()
439 * @see media_folder_set_name()
441 int media_folder_update_to_db(media_folder_h folder);
449 #endif /* __cplusplus */
451 #endif /* __TIZEN_MEDIA_FOLDER_H__ */