Sync to product code
[platform/core/api/media-content.git] / include_product / media_folder.h
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17
18 #ifndef __TIZEN_MEDIA_FOLDER_H__
19 #define __TIZEN_MEDIA_FOLDER_H__
20
21
22 #include <media_content_type.h>
23
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28
29 /**
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.
36  */
37
38 /**
39  * @addtogroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
40  * @{
41  */
42
43
44 /**
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
47  *
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
51  *
52  * @return @c 0 on success,
53  *         otherwise a negative error value
54  *
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
60  *
61  * @pre This function requires opened connection to content service by media_content_connect().
62  *
63  * @see media_content_connect()
64  */
65 int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count);
66
67 /**
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.
72  *
73  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
74  *
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.
78  *
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
82  *
83  * @return @c 0 on success,
84  *         otherwise a negative error value
85  *
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
92  *
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().
96  *
97  * @see media_content_connect()
98  * @see media_folder_cb()
99  * @see media_filter_create()
100  */
101 int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data);
102
103 /**
104  * @brief Gets the count of media files for the passed @a filter in the given @a folder from the media database.
105  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
106  *
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
110  *
111  * @return @c 0 on success,
112  *         otherwise a negative error value
113  *
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
119  *
120  * @pre This function requires opened connection to content service by media_content_connect().
121  *
122  * @see media_content_connect()
123  */
124 int media_folder_get_media_count_from_db(const char *folder_id, filter_h filter, int *media_count);
125
126 /**
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.
131  *
132  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
133  *
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.
138  *
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
143  *
144  * @return @c 0 on success,
145  *         otherwise a negative error value
146  *
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
153  *
154  * @pre  This function requires opened connection to content service by media_content_connect().
155  * @post This function invokes media_info_cb().
156  *
157  * @see #media_info_cb
158  * @see media_content_connect()
159  * @see media_filter_create()
160  */
161 int media_folder_foreach_media_from_db(const char *folder_id, filter_h filter, media_info_cb callback, void *user_data);
162
163 /**
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,
168  *          use this function.
169  *
170  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
171  *
172  * @remarks The destination handle must be released with media_folder_destroy().
173  *
174  * @param[out] dst The destination handle to the media folder
175  * @param[in]  src The source handle to the media folder
176  *
177  * @return @c 0 on success,
178  *         otherwise a negative error value
179  *
180  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
181  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
182  *
183  * @see media_folder_destroy()
184  * @see media_folder_foreach_folder_from_db()
185  */
186 int media_folder_clone(media_folder_h *dst, media_folder_h src);
187
188 /**
189  * @brief Destroys the media folder.
190  * @details The function frees all resources related to the folder handle. This handle
191  *          no longer can be used to perform any operation. A new handle has to
192  *          be created before the next use.
193  *
194  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
195  *
196  * @param[in] folder The handle to the media folder
197  *
198  * @return @c 0 on success,
199  *         otherwise a negative error value
200  *
201  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
202  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
203  *
204  * @pre A copy of the media folder handle created by calling media_folder_clone().
205  *
206  * @see media_folder_clone()
207  */
208 int media_folder_destroy(media_folder_h folder);
209
210 /**
211  * @brief Gets the media folder ID.
212  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
213  *
214  * @remarks You must release @a folder_id using free().
215  *
216  * @param[in]  folder    The handle to the media folder
217  * @param[out] folder_id The ID of the media folder
218  *
219  * @return @c 0 on success,
220  *         otherwise a negative error value
221  *
222  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
223  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
224  */
225 int media_folder_get_folder_id(media_folder_h folder, char **folder_id);
226
227 /**
228  * @brief Gets the parent folder ID.
229  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
230  *
231  * @remarks You must release @a parent_folder_id using free().
232  *
233  * @param[in]  folder    The handle to the media folder
234  * @param[out] parent_folder_id The ID of the upper media folder
235  *
236  * @return @c 0 on success,
237  *         otherwise a negative error value
238  *
239  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
240  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
241  */
242 int media_folder_get_parent_folder_id(media_folder_h folder, char **parent_folder_id);
243
244 /**
245  * @brief Gets the absolute path to the media folder.
246  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
247  *
248  * @remarks You must release @a path using free().
249  *
250  * @param[in]  folder The handle to the media folder
251  * @param[out] path   The path of the media folder
252  *
253  * @return @c 0 on success,
254  *         otherwise a negative error value
255  *
256  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
257  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
258  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
259  *
260  */
261 int media_folder_get_path(media_folder_h folder, char **path);
262
263 /**
264  * @brief Gets the media folder name.
265  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
266  *
267  * @remarks You must release @a folder_name using free().
268  *
269  * @param[in]  folder      The handle to the media folder
270  * @param[out] folder_name The name of the media folder
271  *
272  * @return @c 0 on success,
273  *         otherwise a negative error value
274  *
275  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
276  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
277  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
278  */
279 int media_folder_get_name(media_folder_h folder, char **folder_name);
280
281 /**
282  * @brief Gets the modified date of the folder.
283  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
284  *
285  * @param[in]  folder The handle to the media folder
286  * @param[out] date   The modified date of the folder
287  *
288  * @return @c 0 on success,
289  *         otherwise a negative error value
290  *
291  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
292  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
293  */
294 int media_folder_get_modified_time(media_folder_h folder, time_t *date);
295
296 /**
297  * @brief Gets the folder storage type.
298  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
299  *
300  * @param[in]  folder       The handle to the media folder
301  * @param[out] storage_type The storage type of the media folder
302  *
303  * @return @c 0 on success,
304  *         otherwise a negative error value
305  *
306  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
307  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
308  */
309 int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e *storage_type);
310
311 /**
312  * @brief Gets the storage id of the folder.
313  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
314  *
315  * @remarks You must release @a storage_id using free().
316  *
317  * @param[in]  folder      The handle to the media folder
318  * @param[out] storage_id The storage id of the media folder
319  *
320  * @return @c 0 on success,
321  *         otherwise a negative error value
322  *
323  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
324  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
325  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
326  */
327 int media_folder_get_storage_id(media_folder_h folder, char **storage_id);
328
329 /**
330  * @deprecated Deprecated since 4.0. \n
331  *         This function does not guarantee order independence between applications. It is recommended that the viewing order is managed by the application.
332  *
333  * @brief Gets the folder viewing order.
334  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
335  *
336  * @param[in] folder The handle to the media folder
337  * @param[out] order   The viewing order of the media folder
338  *
339  * @return @c 0 on success,
340  *         otherwise a negative error value
341  *
342  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
343  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
344  *
345  * @post media_folder_update_to_db()
346  */
347 int media_folder_get_order(media_folder_h folder, int *order) TIZEN_DEPRECATED_API;
348
349 /**
350  * @brief Gets the media folder from the media database.
351  *
352  * @details This function creates a new media folder handle from the media database by the given @a folder_id.
353  *          Media folder will be created, which is filled with folder information.
354  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
355  *
356  * @remarks You must release @a folder using media_folder_destroy().
357  *
358  * @param[in]  folder_id The ID of the media folder
359  * @param[out] folder    The media folder handle associated with the folder ID
360  *
361  * @return @c 0 on success,
362  *         otherwise a negative error value
363  *
364  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
365  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
366  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
367  *
368  * @pre This function requires opened connection to content service by media_content_connect().
369  *
370  * @see media_content_connect()
371  * @see media_folder_destroy()
372  *
373  */
374 int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder);
375
376 /**
377  * @deprecated Deprecated since 4.0. Use media_content_scan_folder() or media_info_move_to_db() instead.
378  * @brief Sets the folder name.
379  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
380  *
381  * @param[in] folder The handle to the media folder
382  * @param[in] name   The name of the media folder
383  *
384  * @return @c 0 on success,
385  *         otherwise a negative error value
386  *
387  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
388  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
389  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
390  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
391  */
392 int media_folder_set_name(media_folder_h folder, const char *name) TIZEN_DEPRECATED_API;
393
394 /**
395  * @deprecated Deprecated since 4.0. \n
396  *         This function does not guarantee order independence between applications. It is recommended that the viewing order is managed by the application.
397  * @brief Sets the folder viewing order.
398  * @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
399  *                 Moreover, more detailed settings are possible when used with the filter. \n
400  *
401  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
402  * @remarks  If you don't set the order value, the order value will be set default value. Default is 0. \n
403  *                    If you don't use the filter, the set order value does not effect the folder viewing order.
404  *
405  * @param[in] folder The handle to the media folder
406  * @param[in] order   The viewing order of the media folder
407  *
408  * @return @c 0 on success,
409  *         otherwise a negative error value
410  *
411  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
412  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
413  */
414 int media_folder_set_order(media_folder_h folder, int order) TIZEN_DEPRECATED_API;
415
416 /**
417  * @deprecated Deprecated since 4.0. Related setter functions are deprecated, therefore this function is not needed anymore.
418  * @brief Updates the media folder to the media database.
419  *
420  * @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
421  *          database.
422  *
423  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
424  *
425  * @privlevel public
426  * @privilege %http://tizen.org/privilege/content.write
427  *
428  * @param[in] folder The handle to the media folder
429  *
430  * @return @c 0 on success,
431  *         otherwise a negative error value
432  *
433  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
434  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
435  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
436  * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
437  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
438  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
439  * @retval #MEDIA_CONTENT_ERROR_NETWORK           Network fail
440  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
441  *
442  * @pre This function requires opened connection to content service by media_content_connect().
443  *
444  * @see media_content_connect()
445  * @see media_folder_destroy()
446  */
447 int media_folder_update_to_db(media_folder_h folder) TIZEN_DEPRECATED_API;
448
449 /**
450  * @}
451  */
452
453 #ifdef __cplusplus
454 }
455 #endif /* __cplusplus */
456
457 #endif /* __TIZEN_MEDIA_FOLDER_H__ */