4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
27 #include "media-svc-types.h"
28 #include "media-svc-error.h"
36 @defgroup MEDIA_SVC Media Information Service
39 * @brief This file defines API's for media service.
44 @defgroup MEDIA_SVC_API Media Database API
48 manage the service database.
54 * Connect to the media database. This is the function that an user who wants to get a handle to access the media database.
56 * @param handle [out] Handle to access database.
57 * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
58 * Please refer 'media-info-error.h' to know the exact meaning of the error.
59 * @see media_svc_disconnect
61 * @post call media_svc_disconnect to disconnect media database.
62 * @remark The database name is "/opt/usr/dbspace/.media.db".
66 #include <media-info.h>
68 void connect_media_db()
70 int ret = MEDIA_INFO_ERROR_NONE;
71 MediaSvcHandle* my_handle = NULL;
73 // connect to the media database
74 ret = media_svc_connect(&my_handle);
78 printf("Fatal error to connect DB\n");
87 int media_svc_connect(MediaSvcHandle **handle);
91 * media_svc_disconnect:
92 * Disconnect to the media database. This is the function that an user who wants to disconnect the media database.
94 * @param handle [in] Handle to access database.
95 * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
96 * Please refer 'media-info-error.h' to know the exact meaning of the error.
97 * @see media_svc_connect
98 * @pre call media_svc_connect to connect media database.
100 * @remark The database name is "/opt/usr/dbspace/.media.db".
104 #include <media-info.h>
106 void disconnect_media_db()
108 int ret = MEDIA_INFO_ERROR_NONE;
109 MediaSvcHandle* my_handle = NULL;
111 // connect to the media database
112 ret = media_svc_connect(&my_handle);
116 printf("Fatal error to connect DB\n");
121 // Do something using my_handle
125 ret = media_svc_disconnect(my_handle);
128 printf("Fatal error to disconnect DB\n");
136 int media_svc_disconnect(MediaSvcHandle *handle);
140 * media_svc_create_table:
141 * Create table of media database and set Index and Triggers.
143 * @param handle [in] Handle to access database.
144 * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
145 * Please refer 'media-info-error.h' to know the exact meaning of the error.
147 * @pre call media_svc_connect to connect media database.
148 * @post call media_svc_disconnect to disconnect media database.
149 * @remark The database name is "/opt/usr/dbspace/.media.db".
153 #include <media-info.h>
155 void create_media_db_table()
157 int ret = MEDIA_INFO_ERROR_NONE;
158 MediaSvcHandle* my_handle = NULL;
160 // connect to the media database
161 ret = media_svc_connect(&my_handle);
165 printf("Fatal error to connect DB\n");
169 ret = media_svc_create_table(my_handle);
172 printf("Fatal error to create DB table\n");
175 ret = media_svc_disconnect(my_handle);
178 printf("Fatal error to disconnect DB\n");
187 int media_svc_create_table(MediaSvcHandle *handle);
189 int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *path);
191 int media_svc_insert_folder(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path);
193 int media_svc_insert_item_begin(MediaSvcHandle *handle, int data_cnt);
195 int media_svc_insert_item_end(MediaSvcHandle *handle);
197 int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, const char *mime_type, media_svc_media_type_e media_type);
199 int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, const char *mime_type, media_svc_media_type_e media_type);
201 int media_svc_move_item_begin(MediaSvcHandle *handle, int data_cnt);
203 int media_svc_move_item_end(MediaSvcHandle *handle);
205 int media_svc_move_item(MediaSvcHandle *handle, media_svc_storage_type_e src_storage, const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path);
207 int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt);
209 int media_svc_set_item_validity_end(MediaSvcHandle *handle);
211 int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int validity);
213 int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path);
215 int media_svc_delete_all_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type);
217 int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type);
219 int media_svc_delete_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path);
221 int media_svc_set_all_storage_items_validity(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, int validity);
223 int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *folder_path, int validity, int recursive);
225 int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, media_svc_media_type_e media_type);
227 int media_svc_rename_folder(MediaSvcHandle *handle, const char *src_path, const char *dst_path);
229 int media_svc_request_update_db(const char *db_query);
231 int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *storage_type);
233 int media_svc_get_mime_type(const char *path, char *mimetype);
235 int media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type);
247 #endif /*_MEDIA_SVC_H_*/