Revert "Modify error type, remove unused code, and replace uuid code to uuid library."
[platform/core/multimedia/libmedia-service.git] / include / media-svc.h
1 /*
2  * libmedia-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22
23
24 #ifndef _MEDIA_SVC_H_
25 #define _MEDIA_SVC_H_
26
27 #include "media-svc-types.h"
28 #include "media-svc-error.h"
29 #include <media-util-noti.h>
30 #include <stdbool.h>
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35
36 /**
37         @defgroup       MEDIA_SVC       Media Information Service
38          @{
39           * @file                       media-svc.h
40           * @brief              This file defines API's for media service.
41           * @version            1.0
42  */
43
44 /**
45         @defgroup MEDIA_SVC_API    Media Database API
46         @{
47
48         @par
49         manage the service database.
50  */
51
52
53 /**
54  *      media_svc_connect:
55  *      Connect to the media database. This is the function that an user who wants to get a handle to access the media database. 
56  *
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
61  *      @pre            None
62  *      @post           call media_svc_disconnect to disconnect media database.
63  *      @remark The database name is "/opt/usr/dbspace/.media.db".
64  *      @par example
65  *      @code
66
67 #include <media-info.h>
68
69 void connect_media_db()
70 {
71         int ret = MEDIA_INFO_ERROR_NONE;
72         MediaSvcHandle* my_handle = NULL;
73
74         // connect to the media database
75         ret = media_svc_connect(&my_handle);
76
77         if (ret < 0)
78         {
79                 printf("Fatal error to connect DB\n");
80                 return;
81         }
82
83         return;
84 }
85
86  *      @endcode
87  */
88 int media_svc_connect(MediaSvcHandle **handle,uid_t uid);
89
90
91 /**
92  *      media_svc_disconnect:
93  *      Disconnect to the media database. This is the function that an user who wants to disconnect the media database. 
94  *
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.
100  *      @post           None
101  *      @remark The database name is "/opt/usr/dbspace/.media.db".
102  *      @par example
103  *      @code
104
105 #include <media-info.h>
106
107 void disconnect_media_db()
108 {
109         int ret = MEDIA_INFO_ERROR_NONE;
110         MediaSvcHandle* my_handle = NULL;
111
112         // connect to the media database
113         ret = media_svc_connect(&my_handle);
114
115         if (ret < 0)
116         {
117                 printf("Fatal error to connect DB\n");
118                 return;
119         }
120
121         //
122         // Do something using my_handle
123         //
124         
125
126         ret = media_svc_disconnect(my_handle);
127         if (ret < 0)
128         {
129                 printf("Fatal error to disconnect DB\n");
130         }
131
132         return;
133 }
134
135  *      @endcode
136  */
137 int media_svc_disconnect(MediaSvcHandle *handle);
138
139
140 /**
141  *      media_svc_create_table:
142  *      Create table of media database and set Index and Triggers.
143  *
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.
147  *      @see            None
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".
151  *      @par example
152  *      @code
153
154 #include <media-info.h>
155
156 void create_media_db_table()
157 {
158         int ret = MEDIA_INFO_ERROR_NONE;
159         MediaSvcHandle* my_handle = NULL;
160
161         // connect to the media database
162         ret = media_svc_connect(&my_handle);
163
164         if (ret < 0)
165         {
166                 printf("Fatal error to connect DB\n");
167                 return;
168         }
169
170         ret = media_svc_create_table(my_handle);
171         if (ret < 0)
172         {
173                 printf("Fatal error to create DB table\n");
174         }
175
176         ret = media_svc_disconnect(my_handle);
177         if (ret < 0)
178         {
179                 printf("Fatal error to disconnect DB\n");
180         }
181
182         return;
183 }
184
185  *      @endcode
186  */
187
188 int media_svc_create_table(MediaSvcHandle *handle, uid_t uid);
189
190 int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *path);
191
192 int media_svc_insert_folder(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
193
194 int media_svc_insert_item_begin(MediaSvcHandle *handle, int with_noti, int data_cnt, int from_pid);
195
196 int media_svc_insert_item_end(MediaSvcHandle *handle, uid_t uid);
197
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);
199
200 int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
201
202 int media_svc_move_item_begin(MediaSvcHandle *handle, int data_cnt);
203
204 int media_svc_move_item_end(MediaSvcHandle *handle, uid_t uid);
205
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);
207
208 int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt);
209
210 int media_svc_set_item_validity_end(MediaSvcHandle *handle, uid_t uid);
211
212 int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int validity, uid_t uid);
213
214 int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path, uid_t uid);
215
216 int media_svc_delete_all_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, uid_t uid);
217
218 int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, uid_t uid);
219
220 int media_svc_delete_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path, uid_t uid);
221
222 int media_svc_set_all_storage_items_validity(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, int validity, uid_t uid);
223
224 int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *folder_path, int validity, int recursive, uid_t uid);
225
226 int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
227
228 int media_svc_rename_folder(MediaSvcHandle *handle, const char *src_path, const char *dst_path, uid_t uid);
229
230 int media_svc_request_update_db(const char *db_query, uid_t uid);
231
232 int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *storage_type);
233
234 int media_svc_get_mime_type(const char *path, char *mimetype);
235
236 int media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type);
237
238 int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *dir_path);
239
240 int media_svc_count_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path, int *count);
241
242 int media_svc_get_pinyin(MediaSvcHandle *handle, const char * src_str, char **pinyin_str);
243 int media_svc_check_pinyin_support(bool *support);
244 /** @} */
245
246 /**
247         @}
248  */
249
250 #ifdef __cplusplus
251 }
252 #endif
253
254 #endif /*_MEDIA_SVC_H_*/