Modify external storage scan
[platform/core/api/media-content.git] / include / media_storage.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_STORAGE_H__
19 #define __TIZEN_MEDIA_STORAGE_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_storage.h
31  * @brief This file contains API on main functional operations with storage that are related to media resources in the media database. \n
32  *        Operations include: getting number of storages, cloning and destroying storage, getting storage`s ID, name, path and type.
33  */
34
35 /**
36  * @addtogroup CAPI_CONTENT_MEDIA_STORAGE_MODULE
37  * @{
38  */
39
40 /**
41 * @brief Gets media storage from database.
42 * @since_tizen 2.4
43 *
44 * @param[in] storage_id The storage id to get media storage info
45 * @param[out] storage The media storage handle
46 *
47 * @return @c 0 on success,
48 *           otherwise a negative error value
49 *
50 * @retval #MEDIA_CONTENT_ERROR_NONE                      Successful
51 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
52 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
53 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED                 DB Operation failed
54 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY                   DB Operation busy
55 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
56
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_storage_get_storage_info_from_db(const char *storage_id, media_storage_h *storage);
63
64 /**
65 * @brief Gets the count of media storage for the passed @a filter from the media database.
66 * @since_tizen 2.4
67 *
68 * @param[in] filter The handle to filter
69 * @param[out] storage_count The count of storage
70 *
71 * @return @c 0 on success,
72 *           otherwise a negative error value
73 *
74 * @retval #MEDIA_CONTENT_ERROR_NONE                      Successful
75 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
76 * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
77 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED                 DB Operation failed
78 * @retval #MEDIA_CONTENT_ERROR_DB_BUSY                   DB Operation busy
79 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
80 *
81 * @pre This function requires opened connection to content service by media_content_connect().
82 *
83 * @see media_content_connect()
84 */
85 int media_storage_get_storage_count_from_db(filter_h filter, int *storage_count);
86
87 /**
88  * @brief Iterates through media storage from the media database.
89  * @details This function gets all media storage handles meeting the given @a filter.
90  *          The @a callback function will be invoked for every retrieved media storage.
91  *          If @c NULL is passed to the @a filter, then no filtering is applied.
92  *
93  * @since_tizen 2.4
94  *
95  * @param[in] filter    The media storage handle filter
96  * @param[in] callback  The callback function to be invoked
97  * @param[in] user_data The user data to be passed to the callback function
98  *
99  * @return @c 0 on success,
100  *         otherwise a negative error value
101  *
102  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
103  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
104  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
105  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
106  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
107  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
108  *
109  * @pre  This function requires opened connection to content service by media_content_connect().
110  * @post This function invokes media_storage_destroy().
111  *
112  * @see media_content_connect()
113  * @see media_storage_destroy()
114  */
115 int media_storage_foreach_storage_from_db(filter_h filter, media_storage_cb callback, void *user_data);
116
117 /**
118  * @brief Gets the count of media files for the passed @a filter in the given @a storage from the media database.
119  * @since_tizen 2.4
120  *
121  * @param[in] storage_id    The ID of the media storage
122  * @param[in] filter       The filter of the media content
123  * @param[out] media_count The count of media storage items
124  *
125  * @return @c 0 on success,
126  *         otherwise a negative error value
127  *
128  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
129  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
130  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
131  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
132  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
133  *
134  * @pre This function requires opened connection to content service by media_content_connect().
135  *
136  * @see media_content_connect()
137  */
138 int media_storage_get_media_count_from_db(const char *storage_id, filter_h filter, int *media_count);
139
140 /**
141  * @brief Iterates through the media files with an optional @a filter in the given @a storage from the media database.
142  * @details This function gets all media files associated with the given storage and
143  *          meeting desired filter option and calls registered callback function for
144  *          every retrieved media item. If @c NULL is passed to the @a filter, no filtering is applied.
145  *
146  * @since_tizen 2.4
147  *
148  * @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,
149  *                    your callback function is invoked as inline function. \n
150  *                    So, your callback function is in read state in SQLite. When you are in read state, sometimes you do not update DB. \n
151  *                    We do not recommend you call updating DB function in callback of foreach function.
152  *
153  * @param[in] storage_id The ID of the media storage
154  * @param[in] filter    The handle to the media info filter
155  * @param[in] callback  The callback function to be invoked
156  * @param[in] user_data The user data to be passed to the callback function
157  *
158  * @return @c 0 on success,
159  *         otherwise a negative error value
160  *
161  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
162  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
163  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
164  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
165  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
166  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
167  *
168  * @pre  This function requires opened connection to content service by media_content_connect().
169  * @post This function invokes media_info_cb().
170  *
171  * @see #media_info_cb
172  * @see media_content_connect()
173  * @see media_filter_create()
174  */
175 int media_storage_foreach_media_from_db(const char *storage_id, filter_h filter, media_info_cb callback, void *user_data);
176
177 /**
178  * @brief Destroys media storage handle.
179  * @details The function frees all resources related to the media storage handle. This handle
180  *          can no longer be used to perform any operation. New media storage handle has to
181  *          be created before the next usage.
182  *
183  * @since_tizen 2.4
184  *
185  * @param[in]  storage  The media storage handle
186  *
187  * @return @c 0 on success,
188  *         otherwise a negative error value
189  *
190  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
191  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
192  *
193  * @pre Get copy of media_storage_h handle by calling media_storage_clone().
194  *
195  * @see media_storage_clone()
196  */
197 int media_storage_destroy(media_storage_h storage);
198
199 /**
200  * @brief Clones the media storage handle.
201  *
202  * @details This function copies the media storage handle from a source to the destination.
203  *          There is no media_storage_create() function. The media_storage_h is created internally and
204  *          available through media storage foreach function such as media_storage_foreach_storage_from_db().
205  *          To use this handle outside of these foreach functions, use this function.
206  *
207  * @since_tizen 2.4
208  *
209  * @remarks You must release the destination handle using media_storage_destroy().
210  *
211  * @param[out] dst  The destination handle to the media storage
212  * @param[in]  src  The source handle to media storage
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_OUT_OF_MEMORY     Out of memory
219  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
220  *
221  * @see media_storage_destroy()
222  * @see media_storage_foreach_storage_from_db()
223  * @see media_storage_get_storage_info_from_db()
224  */
225 int media_storage_clone(media_storage_h *dst, media_storage_h src);
226
227 /**
228  * @brief Gets the storage id of media storage.
229  * @since_tizen 2.4
230  *
231  * @remarks You must release @a storage_id using free().
232  *
233  * @param[in]  storage The media storage handle
234  * @param[out] storage_id  The storage id of the media storage
235  *
236  * @return @c 0 on success,
237  *         otherwise a negative error value
238  *
239  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
240  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
241  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
242  */
243 int media_storage_get_id(media_storage_h storage, char **storage_id);
244
245 /**
246  * @brief Gets the storage name of media storage.
247  * @since_tizen 2.4
248  *
249  * @remarks You must release @a storage_name using free().
250  *
251  * @param[in]  storage The media storage handle
252  * @param[out] storage_name  The storage name of the media storage
253  *
254  * @return @c 0 on success,
255  *         otherwise a negative error value
256  *
257  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
258  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
259  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
260  */
261 int media_storage_get_name(media_storage_h storage, char **storage_name);
262
263 /**
264  * @brief Gets the storage path of media storage.
265  * @since_tizen 2.4
266  *
267  * @remarks You must release @a storage_path using free().
268  *
269  * @param[in]  storage The media storage handle
270  * @param[out] storage_path  The storage path of the media storage
271  *
272  * @return @c 0 on success,
273  *         otherwise a negative error value
274  *
275  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
276  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
277  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
278  */
279 int media_storage_get_path(media_storage_h storage, char **storage_path);
280
281 /**
282  * @brief Gets the storage type of media storage.
283  * @since_tizen 2.4
284  *
285  * @param[in]  storage The media storage handle
286  * @param[out] storage_type  The storage type of the media storage
287  *
288  * @return @c 0 on success,
289  *         otherwise a negative error value
290  *
291  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
292  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
293  */
294 int media_storage_get_type(media_storage_h storage, media_content_storage_e *storage_type);
295
296 /**
297  * @}
298  */
299
300 #ifdef __cplusplus
301 }
302 #endif /* __cplusplus */
303
304 #endif /* __TIZEN_MEDIA_STORAGE_H__ */