53cff8f6d84939a0bfab3cdf5e174efd7ceee2f5
[platform/core/api/media-content.git] / include / 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 2.3
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_PERMISSION_DENIED Permission denied
59  *
60  * @pre This function requires opened connection to content service by media_content_connect().
61  *
62  * @see media_content_connect()
63  */
64 int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count);
65
66 /**
67  * @brief Iterates through available media folders with optional @a filter from the media database.
68  * @details This function gets the media folder meeting the given @a filter.
69  *          The @a callback function will be invoked for every retrieved
70  *          folder. If @c NULL is passed to the @a filter, no filtering is applied.
71  *
72  * @since_tizen 2.3
73  *
74  * @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
75  *                   So, your callback function is in read state in SQLite. When you are in read state, sometimes you do not update DB. \n
76  *                   We do not recommend you call updating DB function in callback of foreach function.
77  *
78  * @param[in] filter    The handle to the media folder filter
79  * @param[in] callback  The callback function to be invoked
80  * @param[in] user_data The user data to be passed to the callback function
81  *
82  * @return @c 0 on success,
83  *         otherwise a negative error value
84  *
85  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
86  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
87  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
88  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
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 from the media database.
102  * @since_tizen 2.3
103  *
104  * @param[in] folder_id    The ID of the media folder
105  * @param[in] filter       The filter of the media content
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_PERMISSION_DENIED Permission denied
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 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 registered callback function for
126  *          every retrieved media item. If @c NULL is passed to the @a filter, no filtering is applied.
127  *
128  * @since_tizen 2.3
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 info 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_PERMISSION_DENIED Permission denied
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 destination handle must be released with 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  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
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 operation. A new handle has to
187  *          be created before the next use.
188  *
189  * @since_tizen 2.3
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  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
199  *
200  * @pre A copy of the media folder handle created by calling media_folder_clone().
201  *
202  * @see media_folder_clone()
203  */
204 int media_folder_destroy(media_folder_h folder);
205
206 /**
207  * @brief Gets the media folder ID.
208  * @since_tizen 2.3
209  *
210  * @remarks You must release @a folder_id using free().
211  *
212  * @param[in]  folder    The handle to the media folder
213  * @param[out] folder_id The ID of the media folder
214  *
215  * @return @c 0 on success,
216  *         otherwise a negative error value
217  *
218  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
219  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
220  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
221  */
222 int media_folder_get_folder_id(media_folder_h folder, char **folder_id);
223
224 /**
225  * @brief Gets the absolute path to the media folder.
226  * @since_tizen 2.3
227  *
228  * @remarks You must release @a path using free().
229  *
230  * @param[in]  folder The handle to the media folder
231  * @param[out] path   The path of the media folder
232  *
233  * @return @c 0 on success,
234  *         otherwise a negative error value
235  *
236  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
237  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
238  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
239  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
240  *
241  */
242 int media_folder_get_path(media_folder_h folder, char **path);
243
244 /**
245  * @brief Gets the media folder name.
246  * @since_tizen 2.3
247  *
248  * @remarks You must release @a folder_name using free().
249  *
250  * @param[in]  folder      The handle to the media folder
251  * @param[out] folder_name The name 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  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
260  */
261 int media_folder_get_name(media_folder_h folder, char **folder_name);
262
263 /**
264  * @brief Gets the modified date of the folder.
265  * @since_tizen 2.3
266  *
267  * @param[in]  folder The handle to the media folder
268  * @param[out] date   The modified date of the 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  */
276 int media_folder_get_modified_time(media_folder_h folder, time_t *date);
277
278 /**
279  * @brief Gets the folder storage type.
280  * @since_tizen 2.3
281  *
282  * @param[in]  folder       The handle to the media folder
283  * @param[out] storage_type The storage type 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  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
291  */
292 int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e *storage_type);
293
294 /**
295  * @brief Gets the media folder from the media database.
296  *
297  * @details This function creates a new media folder handle from the media database by the given @a folder_id.
298  *          Media folder will be created, which is filled with folder information.
299  * @since_tizen 2.3
300  *
301  * @remarks You must release @a folder using media_folder_destroy().
302  *
303  * @param[in]  folder_id The ID of the media folder
304  * @param[out] folder    The media folder handle associated with the folder ID
305  *
306  * @return @c 0 on success,
307  *         otherwise a negative error value
308  *
309  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
310  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
311  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
312  *
313  * @pre This function requires opened connection to content service by media_content_connect().
314  *
315  * @see media_content_connect()
316  * @see media_folder_destroy()
317  *
318  */
319 int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder);
320
321 /**
322  * @brief Updates the media folder to the media database.
323  *
324  * @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
325  *          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
326  *          the given folder attributes in the media database.
327  *
328  * @since_tizen 2.3
329  *
330  * @privlevel public
331  * @privilege %http://tizen.org/privilege/content.write
332  *
333  * @param[in] folder The handle to the media folder
334  *
335  * @return @c 0 on success,
336  *         otherwise a negative error value
337  *
338  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
339  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
340  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
341  *
342  * @pre This function requires opened connection to content service by media_content_connect().
343  * @pre If you do not set new name of folder by using media_folder_set_name(), your updating function is failed.
344  *
345  * @see media_content_connect()
346  * @see media_folder_destroy()
347  * @see media_folder_set_name()
348  */
349 int media_folder_update_to_db(media_folder_h folder);
350
351 /**
352  * @brief Sets the folder name.
353  * @since_tizen 2.3
354  *
355  * @param[in] folder The handle to the media folder
356  * @param[in] name   The name of the media folder
357  *
358  * @return @c 0 on success,
359  *         otherwise a negative error value
360  *
361  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
362  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
363  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
364  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
365  *
366  * @post media_folder_update_to_db()
367  */
368 int media_folder_set_name(media_folder_h folder, const char *name);
369
370 /**
371  * @}
372  */
373
374 #ifdef __cplusplus
375 }
376 #endif /* __cplusplus */
377
378 #endif /* __TIZEN_MEDIA_FOLDER_H__ */