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"
35 @defgroup MEDIA_SVC Media Information Service
38 * @brief This file defines API's for media service.
43 @defgroup MEDIA_SVC_API Media Database API
47 manage the service database.
53 * Connect to the media database. This is the function that an user who wants to get a handle to access the media database.
55 * @param handle [out] Handle to access database.
56 * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
57 * Please refer 'media-info-error.h' to know the exact meaning of the error.
58 * @see media_svc_disconnect
60 * @post call media_svc_disconnect to disconnect media database.
61 * @remark The database name is "/opt/usr/dbspace/.media.db".
65 #include <media-info.h>
67 void connect_media_db()
69 int ret = MEDIA_INFO_ERROR_NONE;
70 MediaSvcHandle* my_handle = NULL;
72 // connect to the media database
73 ret = media_svc_connect(&my_handle);
77 printf("Fatal error to connect DB\n");
86 int media_svc_connect(MediaSvcHandle **handle);
90 * media_svc_disconnect:
91 * Disconnect to the media database. This is the function that an user who wants to disconnect the media database.
93 * @param handle [in] Handle to access database.
94 * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
95 * Please refer 'media-info-error.h' to know the exact meaning of the error.
96 * @see media_svc_connect
97 * @pre call media_svc_connect to connect media database.
99 * @remark The database name is "/opt/usr/dbspace/.media.db".
103 #include <media-info.h>
105 void disconnect_media_db()
107 int ret = MEDIA_INFO_ERROR_NONE;
108 MediaSvcHandle* my_handle = NULL;
110 // connect to the media database
111 ret = media_svc_connect(&my_handle);
115 printf("Fatal error to connect DB\n");
120 // Do something using my_handle
124 ret = media_svc_disconnect(my_handle);
127 printf("Fatal error to disconnect DB\n");
135 int media_svc_disconnect(MediaSvcHandle *handle);
139 * media_svc_create_table:
140 * Create table of media database and set Index and Triggers.
142 * @param handle [in] Handle to access database.
143 * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
144 * Please refer 'media-info-error.h' to know the exact meaning of the error.
146 * @pre call media_svc_connect to connect media database.
147 * @post call media_svc_disconnect to disconnect media database.
148 * @remark The database name is "/opt/usr/dbspace/.media.db".
152 #include <media-info.h>
154 void create_media_db_table()
156 int ret = MEDIA_INFO_ERROR_NONE;
157 MediaSvcHandle* my_handle = NULL;
159 // connect to the media database
160 ret = media_svc_connect(&my_handle);
164 printf("Fatal error to connect DB\n");
168 ret = media_svc_create_table(my_handle);
171 printf("Fatal error to create DB table\n");
174 ret = media_svc_disconnect(my_handle);
177 printf("Fatal error to disconnect DB\n");
186 int media_svc_create_table(MediaSvcHandle *handle);
188 int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *path);
190 int media_svc_insert_folder(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path);
192 int media_svc_insert_item_begin(MediaSvcHandle *handle, int with_noti, int data_cnt, int from_pid);
194 int media_svc_insert_item_end(MediaSvcHandle *handle);
196 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, int is_burst);
198 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);
200 int media_svc_move_item_begin(MediaSvcHandle *handle, int data_cnt);
202 int media_svc_move_item_end(MediaSvcHandle *handle);
204 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);
206 int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt);
208 int media_svc_set_item_validity_end(MediaSvcHandle *handle);
210 int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int validity);
212 int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path);
214 int media_svc_delete_all_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type);
216 int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type);
218 int media_svc_delete_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path);
220 int media_svc_set_all_storage_items_validity(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, int validity);
222 int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *folder_path, int validity, int recursive);
224 int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, media_svc_media_type_e media_type);
226 int media_svc_rename_folder(MediaSvcHandle *handle, const char *src_path, const char *dst_path);
228 int media_svc_request_update_db(const char *db_query);
230 int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *storage_type);
232 int media_svc_get_mime_type(const char *path, char *mimetype);
234 int media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type);
236 int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *dir_path);
248 #endif /*_MEDIA_SVC_H_*/