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"
29 #include <media-util-noti.h>
37 @defgroup MEDIA_SVC Media Information Service
40 * @brief This file defines API's for media service.
45 @defgroup MEDIA_SVC_API Media Database API
49 manage the service database.
55 * Connect to the media database. This is the function that an user who wants to get a handle to access the media database.
57 * @param handle [out] Handle to access database.
58 * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
59 * Please refer 'media-info-error.h' to know the exact meaning of the error.
60 * @see media_svc_disconnect
62 * @post call media_svc_disconnect to disconnect media database.
63 * @remark The database name is "/opt/usr/dbspace/.media.db".
67 #include <media-info.h>
69 void connect_media_db()
71 int ret = MEDIA_INFO_ERROR_NONE;
72 MediaSvcHandle* my_handle = NULL;
74 // connect to the media database
75 ret = media_svc_connect(&my_handle);
79 printf("Fatal error to connect DB\n");
88 int media_svc_connect(MediaSvcHandle **handle,uid_t uid);
92 * media_svc_disconnect:
93 * Disconnect to the media database. This is the function that an user who wants to disconnect the media database.
95 * @param handle [in] Handle to access database.
96 * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
97 * Please refer 'media-info-error.h' to know the exact meaning of the error.
98 * @see media_svc_connect
99 * @pre call media_svc_connect to connect media database.
101 * @remark The database name is "/opt/usr/dbspace/.media.db".
105 #include <media-info.h>
107 void disconnect_media_db()
109 int ret = MEDIA_INFO_ERROR_NONE;
110 MediaSvcHandle* my_handle = NULL;
112 // connect to the media database
113 ret = media_svc_connect(&my_handle);
117 printf("Fatal error to connect DB\n");
122 // Do something using my_handle
126 ret = media_svc_disconnect(my_handle);
129 printf("Fatal error to disconnect DB\n");
137 int media_svc_disconnect(MediaSvcHandle *handle);
141 * media_svc_create_table:
142 * Create table of media database and set Index and Triggers.
144 * @param handle [in] Handle to access database.
145 * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
146 * Please refer 'media-info-error.h' to know the exact meaning of the error.
148 * @pre call media_svc_connect to connect media database.
149 * @post call media_svc_disconnect to disconnect media database.
150 * @remark The database name is "/opt/usr/dbspace/.media.db".
154 #include <media-info.h>
156 void create_media_db_table()
158 int ret = MEDIA_INFO_ERROR_NONE;
159 MediaSvcHandle* my_handle = NULL;
161 // connect to the media database
162 ret = media_svc_connect(&my_handle);
166 printf("Fatal error to connect DB\n");
170 ret = media_svc_create_table(my_handle);
173 printf("Fatal error to create DB table\n");
176 ret = media_svc_disconnect(my_handle);
179 printf("Fatal error to disconnect DB\n");
188 int media_svc_create_table(MediaSvcHandle *handle, uid_t uid);
190 int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *path);
192 int media_svc_insert_folder(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
194 int media_svc_insert_item_begin(MediaSvcHandle *handle, int with_noti, int data_cnt, int from_pid);
196 int media_svc_insert_item_end(MediaSvcHandle *handle, uid_t uid);
198 int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, int is_burst, uid_t uid);
200 int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
202 int media_svc_move_item_begin(MediaSvcHandle *handle, int data_cnt);
204 int media_svc_move_item_end(MediaSvcHandle *handle, uid_t uid);
206 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, uid_t uid);
208 int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt);
210 int media_svc_set_item_validity_end(MediaSvcHandle *handle, uid_t uid);
212 int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int validity, uid_t uid);
214 int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path, uid_t uid);
216 int media_svc_delete_all_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, uid_t uid);
218 int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, uid_t uid);
220 int media_svc_delete_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path, uid_t uid);
222 int media_svc_set_all_storage_items_validity(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, int validity, uid_t uid);
224 int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *folder_path, int validity, int recursive, uid_t uid);
226 int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
228 int media_svc_rename_folder(MediaSvcHandle *handle, const char *src_path, const char *dst_path, uid_t uid);
230 int media_svc_request_update_db(const char *db_query, uid_t uid);
232 int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *storage_type);
234 int media_svc_get_mime_type(const char *path, char *mimetype);
236 int media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type);
238 int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *dir_path);
240 int media_svc_count_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path, int *count);
242 int media_svc_get_pinyin(MediaSvcHandle *handle, const char * src_str, char **pinyin_str);
243 int media_svc_check_pinyin_support(bool *support);
254 #endif /*_MEDIA_SVC_H_*/