Merge "add service_profile field for pvr table" into tizen
[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.
35  */
36
37 /**
38  * @addtogroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
39  * @{
40  */
41
42
43 /**
44  * @brief Gets the count of folder for the passed @a filter from the media database.
45  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
46  *
47  * @param[in] filter The handle to the media filter
48  * @param[out] folder_count The count of the media folder
49  *
50  * @return @c 0 on success,
51  *         otherwise a negative error value
52  *
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
57  *
58  * @pre This function requires opened connection to content service by media_content_connect().
59  *
60  * @see media_content_connect()
61  */
62 int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count);
63
64 /**
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.
69  *
70  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
71  *
72  * @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
73  *                   So, your callback function is in read state in SQLite. When you are in read state, sometimes you do not update DB. \n
74  *                   We do not recommend you call updating DB function in callback of foreach function.
75  *
76  * @param[in] filter The handle to the media filter
77  * @param[in] callback The callback function to be invoked
78  * @param[in] user_data The user data to be passed to the callback function
79  *
80  * @return @c 0 on success,
81  *         otherwise a negative error value
82  *
83  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
84  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
85  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
86  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
87  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
88  *
89  * @pre  This function requires opened connection to content service by media_content_connect().
90  * @pre  A filter handle has to be created by calling media_filter_create().
91  * @post This function invokes media_folder_cb().
92  *
93  * @see media_content_connect()
94  * @see media_folder_cb()
95  * @see media_filter_create()
96  */
97 int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data);
98
99 /**
100  * @brief Gets the count of media files for the passed @a filter in the given @a folder_id from the media database.
101  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
102  *
103  * @param[in] folder_id The ID of the media folder
104  * @param[in] filter The handle to the media filter
105  * @param[out] media_count The count of media folder items
106  *
107  * @return @c 0 on success,
108  *         otherwise a negative error value
109  *
110  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
111  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
112  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
113  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
114  *
115  * @pre This function requires opened connection to content service by media_content_connect().
116  *
117  * @see media_content_connect()
118  */
119 int media_folder_get_media_count_from_db(const char *folder_id, filter_h filter, int *media_count);
120
121 /**
122  * @brief Iterates through the media files with an optional @a filter in the given @a folder_id from the media database.
123  * @details This function gets all media files associated with the given folder and
124  *          meeting desired filter option and calls @a callback for
125  *          every retrieved media item. If @c NULL is passed to the @a filter, no filtering is applied.
126  *
127  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
128  *
129  * @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,
130  *                    your callback function is invoked as inline function. \n
131  *                    So, your callback function is in read state in SQLite. When you are in read state, sometimes you do not update DB. \n
132  *                    We do not recommend you call updating DB function in callback of foreach function.
133  *
134  * @param[in] folder_id The ID of the media folder
135  * @param[in] filter The handle to the media filter
136  * @param[in] callback The callback function to be invoked
137  * @param[in] user_data The user data to be passed to the callback function
138  *
139  * @return @c 0 on success,
140  *         otherwise a negative error value
141  *
142  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
143  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
144  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
145  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
146  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
147  *
148  * @pre  This function requires opened connection to content service by media_content_connect().
149  * @post This function invokes media_info_cb().
150  *
151  * @see #media_info_cb
152  * @see media_content_connect()
153  * @see media_filter_create()
154  */
155 int media_folder_foreach_media_from_db(const char *folder_id, filter_h filter, media_info_cb callback, void *user_data);
156
157 /**
158  * @brief Clones the media folder.
159  * @details This function copies the media folder handle from a source to
160  *          destination. There is no media_folder_create() function. The media_folder_h is created internally and available through
161  *          media folder foreach function such as media_folder_foreach_folder_from_db(). To use this handle outside of these foreach functions,
162  *          use this function.
163  *
164  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
165  *
166  * @remarks The @a dst should be released using media_folder_destroy().
167  *
168  * @param[out] dst The destination handle to the media folder
169  * @param[in] src The source handle to the media folder
170  *
171  * @return @c 0 on success,
172  *         otherwise a negative error value
173  *
174  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
175  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
176  *
177  * @see media_folder_destroy()
178  * @see media_folder_foreach_folder_from_db()
179  */
180 int media_folder_clone(media_folder_h *dst, media_folder_h src);
181
182 /**
183  * @brief Destroys the media folder.
184  * @details The function frees all resources related to the folder handle. This handle
185  *          no longer can be used to perform any operations. A new handle has to
186  *          be created before the next use.
187  *
188  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
189  *
190  * @param[in] folder The handle to the media folder
191  *
192  * @return @c 0 on success,
193  *         otherwise a negative error value
194  *
195  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
196  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
197  *
198  * @pre A copy of the media folder handle created by calling media_folder_clone().
199  *
200  * @see media_folder_clone()
201  */
202 int media_folder_destroy(media_folder_h folder);
203
204 /**
205  * @brief Gets the media folder ID.
206  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
207  *
208  * @remarks The @a folder_id should be released using free().
209  *
210  * @param[in] folder The handle to the media folder
211  * @param[out] folder_id The ID of the media folder
212  *
213  * @return @c 0 on success,
214  *         otherwise a negative error value
215  *
216  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
217  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
218  */
219 int media_folder_get_folder_id(media_folder_h folder, char **folder_id);
220
221 /**
222  * @brief Gets the absolute path to the media folder.
223  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
224  *
225  * @remarks The @a path should be released using free().
226  *
227  * @param[in] folder The handle to the media folder
228  * @param[out] path The path of the media folder
229  *
230  * @return @c 0 on success,
231  *         otherwise a negative error value
232  *
233  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
234  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
235  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
236  *
237  */
238 int media_folder_get_path(media_folder_h folder, char **path);
239
240 /**
241  * @brief Gets the media folder name.
242  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
243  *
244  * @remarks The @a folder_name should be released using free().
245  *
246  * @param[in] folder The handle to the media folder
247  * @param[out] folder_name The name 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 int media_folder_get_name(media_folder_h folder, char **folder_name);
257
258 /**
259  * @deprecated Deprecated since 5.0. Use storage_get_type_dev() instead.
260  * @brief Gets the folder storage type.
261  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
262  *
263  * @param[in] folder The handle to the media folder
264  * @param[out] storage_type The storage type of the media folder
265  *
266  * @return @c 0 on success,
267  *         otherwise a negative error value
268  *
269  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
270  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
271  */
272 int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e *storage_type) TIZEN_DEPRECATED_API;
273
274 /**
275  * @deprecated Deprecated since 5.0.
276  * @brief Gets the storage id of the folder.
277  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
278  *
279  * @remarks The @a storage_id should be released using free().
280  *
281  * @param[in] folder The handle to the media folder
282  * @param[out] storage_id The storage id of the media folder
283  *
284  * @return @c 0 on success,
285  *         otherwise a negative error value
286  *
287  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
288  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
289  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
290  */
291 int media_folder_get_storage_id(media_folder_h folder, char **storage_id) TIZEN_DEPRECATED_API;
292
293 /**
294  * @brief Gets the media folder from the media database.
295  *
296  * @details This function creates a new media folder handle from the media database by the given @a folder_id.
297  *          Media folder will be created, which is filled with folder information.
298  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
299  *
300  * @remarks The @a folder should be released using media_folder_destroy().
301  *
302  * @param[in] folder_id The ID of the media folder
303  * @param[out] folder The handle to the media folder
304  *
305  * @return @c 0 on success,
306  *         otherwise a negative error value
307  *
308  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
309  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
310  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
311  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
312  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
313  *
314  * @pre This function requires opened connection to content service by media_content_connect().
315  *
316  * @see media_content_connect()
317  * @see media_folder_destroy()
318  *
319  */
320 int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder);
321
322 /**
323  * @}
324  */
325
326 #ifdef __cplusplus
327 }
328 #endif /* __cplusplus */
329
330 #endif /* __TIZEN_CONTENT_MEDIA_FOLDER_H__ */