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_CONTENT_MEDIA_FOLDER_H__
19 #define __TIZEN_CONTENT_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.
38 * @addtogroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
44 * @brief Gets the count of folder for the passed @a filter from the media database.
47 * @param[in] filter The handle to the media filter
48 * @param[out] folder_count The count of the media folder
50 * @return @c 0 on success,
51 * otherwise a negative error value
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
58 * @pre This function requires opened connection to content service by media_content_connect().
60 * @see media_content_connect()
62 int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count);
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.
72 * @remarks We do not recommend you call updating DB function in callback of foreach function.
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
78 * @return @c 0 on success,
79 * otherwise a negative error value
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
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().
91 * @see media_content_connect()
92 * @see media_folder_cb()
93 * @see media_filter_create()
95 int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data);
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.
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
107 * @return @c 0 on success,
108 * otherwise a negative error value
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
115 * @pre This function requires opened connection to content service by media_content_connect().
117 * @see media_content_connect()
119 int media_folder_get_media_count_from_db(const char *folder_id, filter_h filter, int *media_count);
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.
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.
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
139 * @return @c 0 on success,
140 * otherwise a negative error value
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
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 @a dst should be released using 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
177 * @see media_folder_destroy()
178 * @see media_folder_foreach_folder_from_db()
180 int media_folder_clone(media_folder_h *dst, media_folder_h src);
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.
190 * @param[in] folder The handle to the media folder
192 * @return @c 0 on success,
193 * otherwise a negative error value
195 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
196 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
198 * @pre A copy of the media folder handle created by calling media_folder_clone().
200 * @see media_folder_clone()
202 int media_folder_destroy(media_folder_h folder);
205 * @brief Gets the media folder ID.
208 * @remarks The @a folder_id should be released using free().
210 * @param[in] folder The handle to the media folder
211 * @param[out] folder_id The ID of the media folder
213 * @return @c 0 on success,
214 * otherwise a negative error value
216 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
217 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
219 int media_folder_get_folder_id(media_folder_h folder, char **folder_id);
222 * @brief Gets the absolute path to the media folder.
225 * @remarks The @a path should be released using free().
227 * @param[in] folder The handle to the media folder
228 * @param[out] path The path of the media folder
230 * @return @c 0 on success,
231 * otherwise a negative error value
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
238 int media_folder_get_path(media_folder_h folder, char **path);
241 * @brief Gets the media folder name.
244 * @remarks The @a folder_name should be released using free().
246 * @param[in] folder The handle to the media folder
247 * @param[out] folder_name The name of the media folder
249 * @return @c 0 on success,
250 * otherwise a negative error value
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
256 int media_folder_get_name(media_folder_h folder, char **folder_name);
259 * @brief Gets the media folder from the media database.
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.
265 * @remarks The @a folder should be released using media_folder_destroy().
267 * @param[in] folder_id The ID of the media folder
268 * @param[out] folder The handle to the media 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
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
279 * @pre This function requires opened connection to content service by media_content_connect().
281 * @see media_content_connect()
282 * @see media_folder_destroy()
285 int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder);
293 #endif /* __cplusplus */
295 #endif /* __TIZEN_CONTENT_MEDIA_FOLDER_H__ */