[ACR-1249] Deprecate APIs related with storage id and type
[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_CONTENT_MEDIA_FOLDER_H__
19 #define __TIZEN_CONTENT_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 the media filter
49  * @param[out] folder_count The count of the media folder
50  *
51  * @return @c 0 on success,
52  *         otherwise a negative error value
53  *
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
58  *
59  * @pre This function requires opened connection to content service by media_content_connect().
60  *
61  * @see media_content_connect()
62  */
63 int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count);
64
65 /**
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.
70  *
71  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
72  *
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.
76  *
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
80  *
81  * @return @c 0 on success,
82  *         otherwise a negative error value
83  *
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
89  *
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().
93  *
94  * @see media_content_connect()
95  * @see media_folder_cb()
96  * @see media_filter_create()
97  */
98 int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data);
99
100 /**
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
103  *
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
107  *
108  * @return @c 0 on success,
109  *         otherwise a negative error value
110  *
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
115  *
116  * @pre This function requires opened connection to content service by media_content_connect().
117  *
118  * @see media_content_connect()
119  */
120 int media_folder_get_media_count_from_db(const char *folder_id, filter_h filter, int *media_count);
121
122 /**
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.
127  *
128  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
129  *
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.
134  *
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
139  *
140  * @return @c 0 on success,
141  *         otherwise a negative error value
142  *
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
148  *
149  * @pre  This function requires opened connection to content service by media_content_connect().
150  * @post This function invokes media_info_cb().
151  *
152  * @see #media_info_cb
153  * @see media_content_connect()
154  * @see media_filter_create()
155  */
156 int media_folder_foreach_media_from_db(const char *folder_id, filter_h filter, media_info_cb callback, void *user_data);
157
158 /**
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,
163  *          use this function.
164  *
165  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
166  *
167  * @remarks The @a dst should be released using media_folder_destroy().
168  *
169  * @param[out] dst The destination handle to the media folder
170  * @param[in] src The source handle to the media folder
171  *
172  * @return @c 0 on success,
173  *         otherwise a negative error value
174  *
175  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
176  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
177  *
178  * @see media_folder_destroy()
179  * @see media_folder_foreach_folder_from_db()
180  */
181 int media_folder_clone(media_folder_h *dst, media_folder_h src);
182
183 /**
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.
188  *
189  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
190  *
191  * @param[in] folder The handle to the media folder
192  *
193  * @return @c 0 on success,
194  *         otherwise a negative error value
195  *
196  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
197  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
198  *
199  * @pre A copy of the media folder handle created by calling media_folder_clone().
200  *
201  * @see media_folder_clone()
202  */
203 int media_folder_destroy(media_folder_h folder);
204
205 /**
206  * @brief Gets the media folder ID.
207  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
208  *
209  * @remarks The @a folder_id should be released using free().
210  *
211  * @param[in] folder The handle to the media folder
212  * @param[out] folder_id The ID of the media folder
213  *
214  * @return @c 0 on success,
215  *         otherwise a negative error value
216  *
217  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
218  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
219  */
220 int media_folder_get_folder_id(media_folder_h folder, char **folder_id);
221
222 /**
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
226  *
227  * @remarks The @a parent_folder_id should be released using free().
228  *
229  * @param[in] folder The handle to the media folder
230  * @param[out] parent_folder_id The ID of the upper media folder
231  *
232  * @return @c 0 on success,
233  *         otherwise a negative error value
234  *
235  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
236  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
237  */
238 int media_folder_get_parent_folder_id(media_folder_h folder, char **parent_folder_id) TIZEN_DEPRECATED_API;
239
240 /**
241  * @brief Gets the absolute path to the media folder.
242  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
243  *
244  * @remarks The @a path should be released using free().
245  *
246  * @param[in] folder The handle to the media folder
247  * @param[out] path The path of the media folder
248  *
249  * @return @c 0 on success,
250  *         otherwise a negative error value
251  *
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
255  *
256  */
257 int media_folder_get_path(media_folder_h folder, char **path);
258
259 /**
260  * @brief Gets the media folder name.
261  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
262  *
263  * @remarks The @a folder_name should be released using free().
264  *
265  * @param[in] folder The handle to the media folder
266  * @param[out] folder_name The name of the media folder
267  *
268  * @return @c 0 on success,
269  *         otherwise a negative error value
270  *
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  */
275 int media_folder_get_name(media_folder_h folder, char **folder_name);
276
277 /**
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
281  *
282  * @param[in] folder The handle to the media folder
283  * @param[out] date The modified date of the media folder
284  *
285  * @return @c 0 on success,
286  *         otherwise a negative error value
287  *
288  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
289  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
290  */
291 int media_folder_get_modified_time(media_folder_h folder, time_t *date) TIZEN_DEPRECATED_API;
292
293 /**
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
297  *
298  * @param[in] folder The handle to the media folder
299  * @param[out] storage_type The storage type of the media folder
300  *
301  * @return @c 0 on success,
302  *         otherwise a negative error value
303  *
304  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
305  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
306  */
307 int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e *storage_type) TIZEN_DEPRECATED_API;
308
309 /**
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
313  *
314  * @remarks The @a storage_id should be released using free().
315  *
316  * @param[in] folder The handle to the media folder
317  * @param[out] storage_id The storage id of the media folder
318  *
319  * @return @c 0 on success,
320  *         otherwise a negative error value
321  *
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
325  */
326 int media_folder_get_storage_id(media_folder_h folder, char **storage_id) TIZEN_DEPRECATED_API;
327
328 /**
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.
331  *
332  * @brief Gets the folder viewing order.
333  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
334  *
335  * @param[in] folder The handle to the media folder
336  * @param[out] order The viewing order of the media folder
337  *
338  * @return @c 0 on success,
339  *         otherwise a negative error value
340  *
341  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
342  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
343  *
344  * @post media_folder_update_to_db()
345  */
346 int media_folder_get_order(media_folder_h folder, int *order) TIZEN_DEPRECATED_API;
347
348 /**
349  * @brief Gets the media folder from the media database.
350  *
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
354  *
355  * @remarks The @a folder should be released using media_folder_destroy().
356  *
357  * @param[in] folder_id The ID of the media folder
358  * @param[out] folder The handle to the media folder
359  *
360  * @return @c 0 on success,
361  *         otherwise a negative error value
362  *
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
368  *
369  * @pre This function requires opened connection to content service by media_content_connect().
370  *
371  * @see media_content_connect()
372  * @see media_folder_destroy()
373  *
374  */
375 int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder);
376
377 /**
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
381  *
382  * @param[in] folder The handle to the media folder
383  * @param[in] name The name of the media folder
384  *
385  * @return @c 0 on success,
386  *         otherwise a negative error value
387  *
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
392  */
393 int media_folder_set_name(media_folder_h folder, const char *name) TIZEN_DEPRECATED_API;
394
395 /**
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
401  *
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.
405  *
406  * @param[in] folder The handle to the media folder
407  * @param[in] order The viewing order of the media folder
408  *
409  * @return @c 0 on success,
410  *         otherwise a negative error value
411  *
412  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
413  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
414  */
415 int media_folder_set_order(media_folder_h folder, int order) TIZEN_DEPRECATED_API;
416
417 /**
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.
420  *
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
422  *          database.
423  *
424  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
425  *
426  * @privlevel public
427  * @privilege %http://tizen.org/privilege/content.write
428  *
429  * @param[in] folder The handle to the media folder
430  *
431  * @return @c 0 on success,
432  *         otherwise a negative error value
433  *
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
442  *
443  * @pre This function requires opened connection to content service by media_content_connect().
444  *
445  * @see media_content_connect()
446  * @see media_folder_destroy()
447  */
448 int media_folder_update_to_db(media_folder_h folder) TIZEN_DEPRECATED_API;
449
450 /**
451  * @}
452  */
453
454 #ifdef __cplusplus
455 }
456 #endif /* __cplusplus */
457
458 #endif /* __TIZEN_CONTENT_MEDIA_FOLDER_H__ */