Delete err_msg
[platform/core/multimedia/libmedia-service.git] / plugin / media-content-plugin.c
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 #include <string.h>
23 #include <sys/stat.h>
24 #include <mm_file.h>
25 #include <media-util.h>
26 #include "media-svc.h"
27 #include "media-svc-util.h"
28
29 int connect_db(void **handle, uid_t uid)
30 {
31         return media_svc_connect(handle, uid, FALSE);
32 }
33
34 int disconnect_db(void *handle)
35 {
36         return media_svc_disconnect(handle);
37 }
38
39 int cleanup_db(void *handle, uid_t uid)
40 {
41         return media_svc_cleanup_db(handle, uid);
42 }
43
44 int check_item_exist(void *handle, const char *storage_id, const char *file_path, bool *modified)
45 {
46         int ret = MS_MEDIA_ERR_NONE;
47         *modified = TRUE;
48
49         time_t modified_time = 0;
50         unsigned long long file_size = 0;
51         struct stat st;
52
53         ret = media_svc_get_file_info(handle, storage_id, file_path, &modified_time, &file_size);
54         if (ret == MS_MEDIA_ERR_NONE) {
55                 memset(&st, 0, sizeof(struct stat));
56                 if (stat(file_path, &st) == 0) {
57                         if ((st.st_mtime != modified_time) || (st.st_size != file_size))
58                                 *modified = TRUE;
59                         else
60                                 *modified = FALSE;
61                 }
62
63                 return ret;
64         }
65
66         return ret;
67 }
68
69 int insert_item_begin(void *handle, int item_cnt, int with_noti, int from_pid)
70 {
71         return media_svc_insert_item_begin(item_cnt, with_noti, from_pid);
72 }
73
74 int insert_item_end(void *handle, uid_t uid)
75 {
76         return media_svc_insert_item_end(uid);
77 }
78
79 int insert_item(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
80 {
81         return media_svc_insert_item_bulk(handle, storage_id, storage_type, file_path, uid);
82 }
83
84 int set_all_storage_items_validity(void *handle, const char *storage_id, int storage_type, int validity, uid_t uid)
85 {
86         return media_svc_set_all_storage_items_validity(storage_id, storage_type, validity, uid);
87 }
88
89 int set_folder_item_validity(void *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid)
90 {
91         return media_svc_set_folder_items_validity(handle, storage_id, folder_path, validity, recursive, uid);
92 }
93
94 int set_item_validity_begin(void *handle, int item_cnt)
95 {
96         return media_svc_set_item_validity_begin(item_cnt);
97 }
98
99 int set_item_validity_end(void *handle, uid_t uid)
100 {
101         return media_svc_set_item_validity_end(uid);
102 }
103
104 int set_item_validity(void *handle, const char *storage_id, const char *file_path, int storage_type, int validity, uid_t uid)
105 {
106         return media_svc_set_item_validity(storage_id, file_path, validity, uid);
107 }
108
109 int delete_item(void *handle, const char *storage_id, const char *file_path, uid_t uid)
110 {
111         return media_svc_delete_item_by_path(handle, storage_id, file_path, uid);
112 }
113
114 int delete_all_invalid_items_in_storage(void *handle, const char *storage_id, int storage_type, uid_t uid)
115 {
116         return media_svc_delete_invalid_items_in_storage(handle, storage_id, storage_type, uid);
117 }
118
119 int send_dir_update_noti(void *handle, const char *storage_id, const char *dir_path, const char *folder_id, int update_type, int pid)
120 {
121         return media_svc_send_dir_update_noti(handle, storage_id, dir_path, folder_id, (media_item_update_type_e)update_type, pid);
122 }
123
124 int check_db(void *handle, uid_t uid)
125 {
126         int ret = MS_MEDIA_ERR_NONE;
127         int user_version = -1;
128
129         ret = media_svc_get_user_version(handle, &user_version);
130         if (ret != MS_MEDIA_ERR_NONE)
131                 return ret;
132
133         if (user_version == 0)
134                 ret = media_svc_create_table(uid);
135         else
136                 ret = media_svc_check_db_upgrade(handle, user_version, uid);
137
138         return ret;
139 }
140
141 int update_folder_time(void *handle, const char *storage_id, char *folder_path, uid_t uid)
142 {
143         /* For scanner V2 */
144         return MS_MEDIA_ERR_NONE;
145 }
146
147 int get_uuid(void * handle, char **uuid)
148 {
149         return media_svc_generate_uuid(uuid);
150 }
151
152 int check_storage(void * handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
153 {
154         return media_svc_check_storage(handle, storage_id, storage_path, validity, uid);
155 }
156
157 int insert_storage(void *handle, const char *storage_id, int storage_type, const char *storage_path, uid_t uid)
158 {
159         return media_svc_insert_storage(handle, storage_id, storage_path, storage_type, uid);
160 }
161
162 int update_storage(void *handle, const char *storage_id, const char *storage_path, uid_t uid)
163 {
164         return media_svc_update_storage(handle, storage_id, storage_path, uid);
165 }
166
167 int set_storage_validity(void * handle, const char *storage_id, int validity, uid_t uid)
168 {
169         return media_svc_set_storage_validity(handle, storage_id, validity, uid);
170 }
171
172 int set_all_storage_validity(void * handle, int validity, uid_t uid)
173 {
174         return media_svc_set_storage_validity(handle, NULL, validity, uid);
175 }
176
177 int get_storage_id(void * handle, const char *path, char *storage_id, uid_t uid)
178 {
179         return media_svc_get_storage_id(handle, path, storage_id, uid);
180 }
181
182 int set_storage_scan_status(void *handle, const char *storage_id, int status, uid_t uid)
183 {
184         /* For scanner V2 */
185         return MS_MEDIA_ERR_NONE;
186 }
187
188 int get_storage_list(void *handle, char ***storage_list, char ***storage_id_list, int *count)
189 {
190         return media_svc_get_storage_list(handle, storage_list, storage_id_list, count);
191 }
192
193 int update_item_begin(void *handle, int item_cnt)
194 {
195         return media_svc_update_item_begin(item_cnt);
196 }
197
198 int update_item_end(void *handle, uid_t uid)
199 {
200         return media_svc_update_item_end(uid);
201 }
202
203 int update_item_meta(void *handle, const char *file_path, const char *storage_id, int storage_type, uid_t uid)
204 {
205         return media_svc_update_item_meta(handle, file_path, storage_id, storage_type, uid);
206 }
207
208 int insert_item_scan(void * handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
209 {
210         /* For scanner V2 */
211         return MS_MEDIA_ERR_NONE;
212 }
213
214 int get_extract_list(void* handle, const char* storage_id, int storage_type, int scan_type, const char* path, uid_t uid, void* array)
215 {
216         /* For scanner V2 */
217         return MS_MEDIA_ERR_NONE;
218 }
219
220 int update_one_extract_item(void* handle, const char* storage_id, int storage_type, void* data)
221 {
222         /* For scanner V2 */
223         return MS_MEDIA_ERR_NONE;
224 }
225
226 int query_do_update_list(void* handle)
227 {
228         /* For scanner V2 */
229         return MS_MEDIA_ERR_NONE;
230 }
231
232 int delete_all_invalid_items_in_folder(void **handle, const char* storage_id, const char*path, bool is_recursive, uid_t uid)
233 {
234         /* For scanner V2 */
235         return MS_MEDIA_ERR_NONE;
236 }
237
238 int delete_invalid_folder_by_path(void **handle, const char *storage_id, const char *folder_path, uid_t uid)
239 {
240         /* For scanner V2 */
241         return MS_MEDIA_ERR_NONE;
242 }
243
244 int insert_folder_begin(void * handle, int item_cnt)
245 {
246         return media_svc_insert_folder_begin(item_cnt);
247 }
248
249 int insert_folder_end(void *handle, uid_t uid)
250 {
251         return media_svc_insert_folder_end(uid);
252 }
253
254 int insert_folder(void * handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
255 {
256         return media_svc_insert_folder(handle, storage_id, storage_type, file_path, uid);
257 }
258
259 int delete_invalid_folder(void * handle, const char *storage_id, int storage_type, uid_t uid)
260 {
261         return media_svc_delete_invalid_folder(storage_id, storage_type, uid);
262 }
263
264 int set_folder_validity(void * handle, const char *storage_id, const char* start_path, int validity, bool is_recursive, uid_t uid)
265 {
266         return media_svc_set_folder_validity(handle, storage_id, start_path, validity, is_recursive, uid);
267 }
268
269 int get_folder_scan_status(void *handle, const char *storage_id, const char *path, int *status)
270 {
271         /* For scanner V2 */
272         return MS_MEDIA_ERR_NONE;
273 }
274
275 int set_folder_scan_status(void *handle, const char *storage_id, const char *path, int status, uid_t uid)
276 {
277         /* For scanner V2 */
278         return MS_MEDIA_ERR_NONE;
279 }
280
281 int check_folder_modified(void *handle, const char *path, const char *storage_id, bool *modified)
282 {
283         /* For scanner V2 */
284         return MS_MEDIA_ERR_NONE;
285 }
286
287 int get_null_scan_folder_list(void *handle, const char *storage_id, const char *folder_path, char ***folder_list, int *count)
288 {
289         /* For scanner V2 */
290         return MS_MEDIA_ERR_NONE;
291 }
292
293 int change_validity_item_batch(void **handle, const char *storage_id, const char *path, int des_validity, int src_validity, uid_t uid)
294 {
295         /* For scanner V2 */
296         return MS_MEDIA_ERR_NONE;
297 }
298
299 int check_folder_exist(void * handle, const char *storage_id, const char *folder_path)
300 {
301         return media_svc_check_folder_exist_by_path(handle, storage_id, folder_path);
302 }
303
304 int get_folder_id(void * handle, const char *storage_id, const char *path, char *folder_id)
305 {
306         return media_svc_get_folder_id(handle, storage_id, path, folder_id);
307 }
308
309 int get_media_type(void *handle, const char *path, int *mediatype)
310 {
311         return media_svc_get_media_type(path, mediatype);
312 }