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