2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef __TIZEN_MEDIA_FOLDER_H__
19 #define __TIZEN_MEDIA_FOLDER_H__
22 #include <media_content_type.h>
27 #endif /* __cplusplus */
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.
39 * @addtogroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
45 * @brief Gets the count of folder for the passed @a filter from the media database.
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
52 * @return @c 0 on success,
53 * otherwise a negative error value
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
60 * @pre This function requires opened connection to content service by media_content_connect().
62 * @see media_content_connect()
64 int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count);
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.
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.
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
82 * @return @c 0 on success,
83 * otherwise a negative error value
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
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().
94 * @see media_content_connect()
95 * @see media_folder_cb()
96 * @see media_filter_create()
98 int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data);
101 * @brief Gets the count of media files for the passed @a filter in the given @a folder from the media database.
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
108 * @return @c 0 on success,
109 * otherwise a negative error value
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
116 * @pre This function requires opened connection to content service by media_content_connect().
118 * @see media_content_connect()
120 int media_folder_get_media_count_from_db(const char *folder_id, filter_h filter, int *media_count);
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.
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.
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
140 * @return @c 0 on success,
141 * otherwise a negative error value
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
148 * @pre This function requires opened connection to content service by media_content_connect().
149 * @post This function invokes media_info_cb().
151 * @see #media_info_cb
152 * @see media_content_connect()
153 * @see media_filter_create()
155 int media_folder_foreach_media_from_db(const char *folder_id, filter_h filter, media_info_cb callback, void *user_data);
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,
166 * @remarks The destination handle must be released with media_folder_destroy().
168 * @param[out] dst The destination handle to the media folder
169 * @param[in] src The source handle to the media folder
171 * @return @c 0 on success,
172 * otherwise a negative error value
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
178 * @see media_folder_destroy()
179 * @see media_folder_foreach_folder_from_db()
181 int media_folder_clone(media_folder_h *dst, media_folder_h src);
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.
191 * @param[in] folder The handle to the media folder
193 * @return @c 0 on success,
194 * otherwise a negative error value
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
200 * @pre A copy of the media folder handle created by calling media_folder_clone().
202 * @see media_folder_clone()
204 int media_folder_destroy(media_folder_h folder);
207 * @brief Gets the media folder ID.
210 * @remarks You must release @a folder_id using free().
212 * @param[in] folder The handle to the media folder
213 * @param[out] folder_id The ID of the media folder
215 * @return @c 0 on success,
216 * otherwise a negative error value
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
222 int media_folder_get_folder_id(media_folder_h folder, char **folder_id);
225 * @brief Gets the absolute path to the media folder.
228 * @remarks You must release @a path using free().
230 * @param[in] folder The handle to the media folder
231 * @param[out] path The path of the media folder
233 * @return @c 0 on success,
234 * otherwise a negative error value
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
242 int media_folder_get_path(media_folder_h folder, char **path);
245 * @brief Gets the media folder name.
248 * @remarks You must release @a folder_name using free().
250 * @param[in] folder The handle to the media folder
251 * @param[out] folder_name The name of the media folder
253 * @return @c 0 on success,
254 * otherwise a negative error value
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
261 int media_folder_get_name(media_folder_h folder, char **folder_name);
264 * @brief Gets the modified date of the folder.
267 * @param[in] folder The handle to the media folder
268 * @param[out] date The modified date of the folder
270 * @return @c 0 on success,
271 * otherwise a negative error value
273 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
274 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
276 int media_folder_get_modified_time(media_folder_h folder, time_t *date);
279 * @brief Gets the folder storage type.
282 * @param[in] folder The handle to the media folder
283 * @param[out] storage_type The storage type of the media folder
285 * @return @c 0 on success,
286 * otherwise a negative error value
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
292 int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e *storage_type);
295 * @brief Gets the media folder from the media database.
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.
301 * @remarks You must release @a folder using media_folder_destroy().
303 * @param[in] folder_id The ID of the media folder
304 * @param[out] folder The media folder handle associated with the folder ID
306 * @return @c 0 on success,
307 * otherwise a negative error value
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
313 * @pre This function requires opened connection to content service by media_content_connect().
315 * @see media_content_connect()
316 * @see media_folder_destroy()
319 int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder);
322 * @brief Updates the media folder to the media database.
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.
331 * @privilege %http://tizen.org/privilege/content.write
333 * @param[in] folder The handle to the media folder
335 * @return @c 0 on success,
336 * otherwise a negative error value
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
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.
345 * @see media_content_connect()
346 * @see media_folder_destroy()
347 * @see media_folder_set_name()
349 int media_folder_update_to_db(media_folder_h folder);
352 * @brief Sets the folder name.
355 * @param[in] folder The handle to the media folder
356 * @param[in] name The name of the media folder
358 * @return @c 0 on success,
359 * otherwise a negative error value
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
366 * @post media_folder_update_to_db()
368 int media_folder_set_name(media_folder_h folder, const char *name);
376 #endif /* __cplusplus */
378 #endif /* __TIZEN_MEDIA_FOLDER_H__ */