Improve API description
[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 2.3
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 2.3
71  *
72  * @remarks We do not recommend you call updating DB function in callback of foreach function.
73  *
74  * @param[in] filter The handle to the media filter
75  * @param[in] callback The callback function to be invoked
76  * @param[in] user_data The user data to be passed to the callback function
77  *
78  * @return @c 0 on success,
79  *         otherwise a negative error value
80  *
81  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
82  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
83  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
84  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
85  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
86  *
87  * @pre  This function requires opened connection to content service by media_content_connect().
88  * @pre  A filter handle has to be created by calling media_filter_create().
89  * @post This function invokes media_folder_cb().
90  *
91  * @see media_content_connect()
92  * @see media_folder_cb()
93  * @see media_filter_create()
94  */
95 int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data);
96
97 /**
98  * @brief Gets the count of media files for the passed @a filter in the given @a folder_id from the media database.
99  * @details This function gets count of media files associated with the given folder and
100  *          meeting desired filter option. If @c NULL is passed to the @a filter, no filtering is applied.
101  * @since_tizen 2.3
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 2.3
128  *
129  * @remarks   Do not call updating DB function like media_info_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 2.3
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 2.3
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 2.3
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 2.3
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 2.3
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  * @brief Gets the media folder from the media database.
260  *
261  * @details This function creates a new media folder handle from the media database by the given @a folder_id.
262  *          Media folder will be created, which is filled with folder information.
263  * @since_tizen 2.3
264  *
265  * @remarks The @a folder should be released using media_folder_destroy().
266  *
267  * @param[in] folder_id The ID of the media folder
268  * @param[out] folder The handle to the media folder
269  *
270  * @return @c 0 on success,
271  *         otherwise a negative error value
272  *
273  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
274  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
275  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
276  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
277  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
278  *
279  * @pre This function requires opened connection to content service by media_content_connect().
280  *
281  * @see media_content_connect()
282  * @see media_folder_destroy()
283  *
284  */
285 int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder);
286
287 /**
288  * @}
289  */
290
291 #ifdef __cplusplus
292 }
293 #endif /* __cplusplus */
294
295 #endif /* __TIZEN_CONTENT_MEDIA_FOLDER_H__ */