[ACR-1308] Remove deprecated APIs
[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 #define MEDIA_SVC_PLUGIN_ERROR_NONE             0
30 #define MEDIA_SVC_PLUGIN_ERROR                  -1
31
32 #define STRING_VALID(str)       \
33         ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
34 #define STORAGE_VALID(storage)\
35         (((storage == MEDIA_SVC_STORAGE_INTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL_USB)) ? TRUE : FALSE)
36
37
38 typedef enum {
39         ERR_HANDLE = 1,
40         ERR_FILE_PATH,
41         ERR_FOLDER_PATH,
42         ERR_MIME_TYPE,
43         ERR_NOT_MEDIAFILE,
44         ERR_STORAGE_TYPE,
45         ERR_CHECK_ITEM,
46         ERR_MAX,
47 } media_svc_error_type_e;
48
49 static void __set_error_message(int err_type, char **err_msg);
50
51 static void __set_error_message(int err_type, char **err_msg)
52 {
53         if (err_msg)
54                 *err_msg = NULL;
55         else
56                 return;
57
58         if (err_type == ERR_HANDLE)
59                 *err_msg = strdup("invalid handle");
60         else if (err_type == ERR_FILE_PATH)
61                 *err_msg = strdup("invalid file path");
62         else if (err_type == ERR_FOLDER_PATH)
63                 *err_msg = strdup("invalid folder path");
64         else if (err_type == ERR_MIME_TYPE)
65                 *err_msg = strdup("invalid mime type");
66         else if (err_type == ERR_NOT_MEDIAFILE)
67                 *err_msg = strdup("not media content");
68         else if (err_type == ERR_STORAGE_TYPE)
69                 *err_msg = strdup("invalid storage type");
70         else if (err_type == ERR_CHECK_ITEM)
71                 *err_msg = strdup("item does not exist");
72         else if (err_type == MS_MEDIA_ERR_DB_CONNECT_FAIL)
73                 *err_msg = strdup("DB connect error");
74         else if (err_type == MS_MEDIA_ERR_DB_DISCONNECT_FAIL)
75                 *err_msg = strdup("DB disconnect error");
76         else if (err_type == MS_MEDIA_ERR_INVALID_PARAMETER)
77                 *err_msg = strdup("invalid parameter");
78         else if (err_type == MS_MEDIA_ERR_DB_INTERNAL)
79                 *err_msg = strdup("DB internal error");
80         else if (err_type == MS_MEDIA_ERR_DB_NO_RECORD)
81                 *err_msg = strdup("not found in DB");
82         else if (err_type == MS_MEDIA_ERR_INTERNAL)
83                 *err_msg = strdup("media service internal error");
84         else if (err_type == MS_MEDIA_ERR_DB_CORRUPT)
85                 *err_msg = strdup("DB corrupt error");
86         else
87                 *err_msg = strdup("error unknown");
88
89         return;
90 }
91
92 int connect_db(void **handle, uid_t uid, char **err_msg)
93 {
94         int ret = media_svc_connect(handle, uid, FALSE);
95
96         if (ret < 0) {
97                 __set_error_message(ret, err_msg);
98                 return MEDIA_SVC_PLUGIN_ERROR;
99         }
100
101         return MEDIA_SVC_PLUGIN_ERROR_NONE;
102 }
103
104 int disconnect_db(void *handle, char **err_msg)
105 {
106         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
107
108         if (handle == NULL) {
109                 __set_error_message(ERR_HANDLE, err_msg);
110                 return MEDIA_SVC_PLUGIN_ERROR;
111         }
112
113         ret = media_svc_disconnect(handle);
114         if (ret < 0) {
115                 __set_error_message(ret, err_msg);
116                 return MEDIA_SVC_PLUGIN_ERROR;
117         }
118
119         return MEDIA_SVC_PLUGIN_ERROR_NONE;
120 }
121
122 int cleanup_db(void *handle, uid_t uid, char **err_msg)
123 {
124         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
125
126         if (handle == NULL) {
127                 __set_error_message(ERR_HANDLE, err_msg);
128                 return MEDIA_SVC_PLUGIN_ERROR;
129         }
130
131         ret = media_svc_cleanup_db(handle, uid);
132         if (ret < 0) {
133                 __set_error_message(ret, err_msg);
134                 return MEDIA_SVC_PLUGIN_ERROR;
135         }
136
137         return MEDIA_SVC_PLUGIN_ERROR_NONE;
138 }
139
140 int check_item_exist(void *handle, const char *storage_id, const char *file_path, bool *modified, char **err_msg)
141 {
142         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
143         *modified = TRUE;
144
145         if (handle == NULL) {
146                 __set_error_message(ERR_HANDLE, err_msg);
147                 return MEDIA_SVC_PLUGIN_ERROR;
148         }
149
150         if (!STRING_VALID(file_path)) {
151                 __set_error_message(ERR_FILE_PATH, err_msg);
152                 return MEDIA_SVC_PLUGIN_ERROR;
153         }
154
155         time_t modified_time = 0;
156         unsigned long long file_size = 0;
157         struct stat st;
158
159         ret = media_svc_get_file_info(handle, storage_id, file_path, &modified_time, &file_size);
160         if (ret == MS_MEDIA_ERR_NONE) {
161                 memset(&st, 0, sizeof(struct stat));
162                 if (stat(file_path, &st) == 0) {
163                         if ((st.st_mtime != modified_time) || (st.st_size != file_size))
164                                 *modified = TRUE;
165                         else
166                                 *modified = FALSE;
167                 }
168
169                 return MEDIA_SVC_PLUGIN_ERROR_NONE;     /*exist */
170         }
171
172         __set_error_message(ERR_CHECK_ITEM, err_msg);
173
174         return MEDIA_SVC_PLUGIN_ERROR;          /*not exist */
175 }
176
177 int insert_item_begin(void *handle, int item_cnt, int with_noti, int from_pid, char **err_msg)
178 {
179         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
180
181         ret = media_svc_insert_item_begin(item_cnt, with_noti, from_pid);
182         if (ret < 0) {
183                 __set_error_message(ret, err_msg);
184                 return MEDIA_SVC_PLUGIN_ERROR;
185         }
186
187         return MEDIA_SVC_PLUGIN_ERROR_NONE;
188 }
189
190 int insert_item_end(void *handle, uid_t uid, char **err_msg)
191 {
192         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
193
194         ret = media_svc_insert_item_end(uid);
195         if (ret < 0) {
196                 __set_error_message(ret, err_msg);
197                 return MEDIA_SVC_PLUGIN_ERROR;
198         }
199
200         return MEDIA_SVC_PLUGIN_ERROR_NONE;
201 }
202
203 int insert_item(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
204 {
205         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
206
207         if (handle == NULL) {
208                 __set_error_message(ERR_HANDLE, err_msg);
209                 return MEDIA_SVC_PLUGIN_ERROR;
210         }
211
212         if (!STRING_VALID(file_path)) {
213                 __set_error_message(ERR_FILE_PATH, err_msg);
214                 return MEDIA_SVC_PLUGIN_ERROR;
215         }
216
217         if (!STORAGE_VALID(storage_type)) {
218                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
219                 return MEDIA_SVC_PLUGIN_ERROR;
220         }
221
222         ret = media_svc_insert_item_bulk(handle, storage_id, storage_type, file_path, uid);
223         if (ret < 0) {
224                 __set_error_message(ret, err_msg);
225                 return MEDIA_SVC_PLUGIN_ERROR;
226         }
227
228         return MEDIA_SVC_PLUGIN_ERROR_NONE;
229 }
230
231 int set_all_storage_items_validity(void *handle, const char *storage_id, int storage_type, int validity, uid_t uid, char **err_msg)
232 {
233         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
234
235         if (!STORAGE_VALID(storage_type)) {
236                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
237                 return MEDIA_SVC_PLUGIN_ERROR;
238         }
239
240         ret = media_svc_set_all_storage_items_validity(storage_id, storage_type, validity, uid);
241         if (ret < 0) {
242                 __set_error_message(ret, err_msg);
243                 return MEDIA_SVC_PLUGIN_ERROR;
244         }
245
246         return MEDIA_SVC_PLUGIN_ERROR_NONE;
247 }
248
249 int set_folder_item_validity(void *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid, char **err_msg)
250 {
251         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
252
253         if (handle == NULL) {
254                 __set_error_message(ERR_HANDLE, err_msg);
255                 return MEDIA_SVC_PLUGIN_ERROR;
256         }
257
258         if (!STRING_VALID(folder_path)) {
259                 __set_error_message(ERR_FOLDER_PATH, err_msg);
260                 return MEDIA_SVC_PLUGIN_ERROR;
261         }
262
263         ret = media_svc_set_folder_items_validity(handle, storage_id, folder_path, validity, recursive, uid);
264         if (ret < 0) {
265                 __set_error_message(ret, err_msg);
266                 return MEDIA_SVC_PLUGIN_ERROR;
267         }
268
269         return MEDIA_SVC_PLUGIN_ERROR_NONE;
270 }
271
272 int set_item_validity_begin(void *handle, int item_cnt, char **err_msg)
273 {
274         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
275
276         ret = media_svc_set_item_validity_begin(item_cnt);
277         if (ret < 0) {
278                 __set_error_message(ret, err_msg);
279                 return MEDIA_SVC_PLUGIN_ERROR;
280         }
281
282         return MEDIA_SVC_PLUGIN_ERROR_NONE;
283 }
284
285 int set_item_validity_end(void *handle, uid_t uid, char **err_msg)
286 {
287         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
288
289         ret = media_svc_set_item_validity_end(uid);
290         if (ret < 0) {
291                 __set_error_message(ret, err_msg);
292                 return MEDIA_SVC_PLUGIN_ERROR;
293         }
294
295         return MEDIA_SVC_PLUGIN_ERROR_NONE;
296 }
297
298 int set_item_validity(void *handle, const char *storage_id, const char *file_path, int storage_type, int validity, uid_t uid, char **err_msg)
299 {
300         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
301
302         if (!STRING_VALID(file_path)) {
303                 __set_error_message(ERR_FILE_PATH, err_msg);
304                 return MEDIA_SVC_PLUGIN_ERROR;
305         }
306
307         ret = media_svc_set_item_validity(storage_id, file_path, validity, uid);
308
309         if (ret < 0) {
310                 __set_error_message(ret, err_msg);
311                 return MEDIA_SVC_PLUGIN_ERROR;
312         }
313
314         return MEDIA_SVC_PLUGIN_ERROR_NONE;
315 }
316
317 int delete_item(void *handle, const char *storage_id, const char *file_path, uid_t uid, char **err_msg)
318 {
319         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
320
321         if (handle == NULL) {
322                 __set_error_message(ERR_HANDLE, err_msg);
323                 return MEDIA_SVC_PLUGIN_ERROR;
324         }
325
326         if (!STRING_VALID(file_path)) {
327                 __set_error_message(ERR_FILE_PATH, err_msg);
328                 return MEDIA_SVC_PLUGIN_ERROR;
329         }
330
331         ret = media_svc_check_item_exist_by_path(handle, storage_id, file_path);
332         if (ret == 0) {
333                 ret = media_svc_delete_item_by_path(handle, storage_id, file_path, uid);
334
335                 if (ret < 0) {
336                         __set_error_message(ret, err_msg);
337                         return MEDIA_SVC_PLUGIN_ERROR;
338                 } else
339                         return MEDIA_SVC_PLUGIN_ERROR_NONE;
340         }
341
342         __set_error_message(ERR_CHECK_ITEM, err_msg);   /*not exist in DB so can't delete item. */
343         return MEDIA_SVC_PLUGIN_ERROR;
344 }
345
346 int delete_all_invalid_items_in_storage(void *handle, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
347 {
348         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
349
350         if (handle == NULL) {
351                 __set_error_message(ERR_HANDLE, err_msg);
352                 return MEDIA_SVC_PLUGIN_ERROR;
353         }
354
355         if (!STORAGE_VALID(storage_type)) {
356                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
357                 return MEDIA_SVC_PLUGIN_ERROR;
358         }
359
360         ret = media_svc_delete_invalid_items_in_storage(handle, storage_id, storage_type, uid);
361         if (ret < 0) {
362                 __set_error_message(ret, err_msg);
363                 return MEDIA_SVC_PLUGIN_ERROR;
364         }
365
366         return MEDIA_SVC_PLUGIN_ERROR_NONE;
367 }
368
369 int send_dir_update_noti(void *handle, const char *storage_id, const char *dir_path, const char *folder_id, int update_type, int pid, char **err_msg)
370 {
371         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
372
373         if (!STRING_VALID(dir_path)) {
374                 __set_error_message(ERR_FOLDER_PATH, err_msg);
375                 return MEDIA_SVC_PLUGIN_ERROR;
376         }
377
378         ret = media_svc_send_dir_update_noti(handle, storage_id, dir_path, folder_id, (media_item_update_type_e)update_type, pid);
379         if (ret < 0) {
380                 __set_error_message(ret, err_msg);
381                 return MEDIA_SVC_PLUGIN_ERROR;
382         }
383
384         return MEDIA_SVC_PLUGIN_ERROR_NONE;
385 }
386
387 int check_db(void *handle, uid_t uid, char **err_msg)
388 {
389         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
390         int user_version = -1;
391
392         ret = media_svc_get_user_version(handle, &user_version);
393         if (ret < 0) {
394                 __set_error_message(ret, err_msg);
395                 return MEDIA_SVC_PLUGIN_ERROR;
396         }
397
398         if (user_version == 0) {
399                 /*check db schema*/
400                 ret = media_svc_create_table(uid);
401                 if (ret < 0) {
402                         __set_error_message(ret, err_msg);
403                         return MEDIA_SVC_PLUGIN_ERROR;
404                 }
405         } else {
406                 /*check db version*/
407                 ret = media_svc_check_db_upgrade(handle, user_version, uid);
408                 if (ret < 0) {
409                         __set_error_message(ret, err_msg);
410                         return MEDIA_SVC_PLUGIN_ERROR;
411                 }
412         }
413
414         return MEDIA_SVC_PLUGIN_ERROR_NONE;
415 }
416
417 int update_folder_time(void *handle, const char *storage_id, char *folder_path, uid_t uid, char **err_msg)
418 {
419         /* For scanner V2 */
420         return MEDIA_SVC_PLUGIN_ERROR_NONE;
421 }
422
423 int get_uuid(void * handle, char **uuid, char **err_msg)
424 {
425         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
426
427         ret = media_svc_generate_uuid(uuid);
428         if (ret < 0) {
429                 __set_error_message(ret, err_msg);
430                 return MEDIA_SVC_PLUGIN_ERROR;
431         }
432
433         return MEDIA_SVC_PLUGIN_ERROR_NONE;
434 }
435
436 int check_storage(void * handle, const char *storage_id, char **storage_path, int *validity, uid_t uid, char **err_msg)
437 {
438         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
439
440         if (handle == NULL) {
441                 __set_error_message(ERR_HANDLE, err_msg);
442                 return MEDIA_SVC_PLUGIN_ERROR;
443         }
444
445         ret = media_svc_check_storage(handle, storage_id, storage_path, validity, uid);
446         if (ret < 0) {
447                 __set_error_message(ret, err_msg);
448                 return MEDIA_SVC_PLUGIN_ERROR;
449         }
450
451         return MEDIA_SVC_PLUGIN_ERROR_NONE;
452 }
453
454 int insert_storage(void *handle, const char *storage_id, int storage_type, const char *storage_path, uid_t uid, char **err_msg)
455 {
456         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
457
458         if (handle == NULL) {
459                 __set_error_message(ERR_HANDLE, err_msg);
460                 return MEDIA_SVC_PLUGIN_ERROR;
461         }
462
463         ret = media_svc_insert_storage(handle, storage_id, storage_path, storage_type, uid);
464         if (ret < 0) {
465                 __set_error_message(ret, err_msg);
466                 return MEDIA_SVC_PLUGIN_ERROR;
467         }
468
469         return MEDIA_SVC_PLUGIN_ERROR_NONE;
470 }
471
472 int update_storage(void *handle, const char *storage_id, const char *storage_path, uid_t uid, char **err_msg)
473 {
474         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
475
476         if (handle == NULL) {
477                 __set_error_message(ERR_HANDLE, err_msg);
478                 return MEDIA_SVC_PLUGIN_ERROR;
479         }
480
481         ret = media_svc_update_storage(handle, storage_id, storage_path, uid);
482         if (ret < 0) {
483                 __set_error_message(ret, err_msg);
484                 return MEDIA_SVC_PLUGIN_ERROR;
485         }
486
487         return MEDIA_SVC_PLUGIN_ERROR_NONE;
488 }
489
490 int set_storage_validity(void * handle, const char *storage_id, int validity, uid_t uid, char **err_msg)
491 {
492         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
493
494         if (handle == NULL) {
495                 __set_error_message(ERR_HANDLE, err_msg);
496                 return MEDIA_SVC_PLUGIN_ERROR;
497         }
498
499         ret = media_svc_set_storage_validity(handle, storage_id, validity, uid);
500         if (ret < 0) {
501                 __set_error_message(ret, err_msg);
502                 return MEDIA_SVC_PLUGIN_ERROR;
503         }
504
505         return MEDIA_SVC_PLUGIN_ERROR_NONE;
506 }
507
508 int set_all_storage_validity(void * handle, int validity, uid_t uid, char **err_msg)
509 {
510         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
511
512         if (handle == NULL) {
513                 __set_error_message(ERR_HANDLE, err_msg);
514                 return MEDIA_SVC_PLUGIN_ERROR;
515         }
516
517         ret = media_svc_set_storage_validity(handle, NULL, validity, uid);
518         if (ret < 0) {
519                 __set_error_message(ret, err_msg);
520                 return MEDIA_SVC_PLUGIN_ERROR;
521         }
522
523         return MEDIA_SVC_PLUGIN_ERROR_NONE;
524 }
525
526 int get_storage_id(void * handle, const char *path, char *storage_id, uid_t uid, char **err_msg)
527 {
528         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
529
530         if (handle == NULL) {
531                 __set_error_message(ERR_HANDLE, err_msg);
532                 return MEDIA_SVC_PLUGIN_ERROR;
533         }
534
535         ret = media_svc_get_storage_id(handle, path, storage_id, uid);
536         if (ret < 0) {
537                 __set_error_message(ret, err_msg);
538                 return MEDIA_SVC_PLUGIN_ERROR;
539         }
540
541         return MEDIA_SVC_PLUGIN_ERROR_NONE;
542 }
543
544 int set_storage_scan_status(void *handle, const char *storage_id, int status, uid_t uid, char **err_msg)
545 {
546         /* For scanner V2 */
547         return MEDIA_SVC_PLUGIN_ERROR_NONE;
548 }
549
550 int get_storage_list(void *handle, char ***storage_list, char ***storage_id_list, int *count, char **err_msg)
551 {
552         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
553
554         if (handle == NULL) {
555                 __set_error_message(ERR_HANDLE, err_msg);
556                 return MEDIA_SVC_PLUGIN_ERROR;
557         }
558
559         if (count == NULL) {
560                 __set_error_message(ERR_HANDLE, err_msg);
561                 return MEDIA_SVC_PLUGIN_ERROR;
562         }
563
564         ret = media_svc_get_storage_list(handle, storage_list, storage_id_list, count);
565         if (ret < 0) {
566                 __set_error_message(ret, err_msg);
567                 return MEDIA_SVC_PLUGIN_ERROR;
568         }
569
570         return MEDIA_SVC_PLUGIN_ERROR_NONE;
571 }
572
573 int update_item_begin(void *handle, int item_cnt, char **err_msg)
574 {
575         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
576
577         ret = media_svc_update_item_begin(item_cnt);
578         if (ret < 0) {
579                 __set_error_message(ret, err_msg);
580                 return MEDIA_SVC_PLUGIN_ERROR;
581         }
582
583         return MEDIA_SVC_PLUGIN_ERROR_NONE;
584 }
585
586 int update_item_end(void *handle, uid_t uid, char **err_msg)
587 {
588         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
589
590         ret = media_svc_update_item_end(uid);
591         if (ret < 0) {
592                 __set_error_message(ret, err_msg);
593                 return MEDIA_SVC_PLUGIN_ERROR;
594         }
595
596         return MEDIA_SVC_PLUGIN_ERROR_NONE;
597 }
598
599 int update_item_meta(void *handle, const char *file_path, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
600 {
601         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
602
603         if (handle == NULL) {
604                 __set_error_message(ERR_HANDLE, err_msg);
605                 return MEDIA_SVC_PLUGIN_ERROR;
606         }
607
608         if (file_path == NULL) {
609                 __set_error_message(ERR_HANDLE, err_msg);
610                 return MEDIA_SVC_PLUGIN_ERROR;
611         }
612
613         if (storage_id == NULL) {
614                 __set_error_message(ERR_HANDLE, err_msg);
615                 return MEDIA_SVC_PLUGIN_ERROR;
616         }
617
618         ret = media_svc_update_item_meta(handle, file_path, storage_id, storage_type, uid);
619         if (ret < 0) {
620                 __set_error_message(ret, err_msg);
621                 return MEDIA_SVC_PLUGIN_ERROR;
622         }
623
624         return MEDIA_SVC_PLUGIN_ERROR_NONE;
625 }
626
627 int insert_item_scan(void * handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
628 {
629         /* For scanner V2 */
630         return MEDIA_SVC_PLUGIN_ERROR_NONE;
631 }
632
633 int get_extract_list(void* handle, const char* storage_id, int storage_type, int scan_type, const char* path, uid_t uid, void* array, char** err_msg)
634 {
635         /* For scanner V2 */
636         return MEDIA_SVC_PLUGIN_ERROR_NONE;
637 }
638
639 int update_one_extract_item(void* handle, const char* storage_id, int storage_type, void* data, char** err_msg)
640 {
641         /* For scanner V2 */
642         return MEDIA_SVC_PLUGIN_ERROR_NONE;
643 }
644
645 int query_do_update_list(void* handle, char** err_msg)
646 {
647         /* For scanner V2 */
648         return MEDIA_SVC_PLUGIN_ERROR_NONE;
649 }
650
651 int delete_all_invalid_items_in_folder(void **handle, const char* storage_id, const char*path, bool is_recursive, uid_t uid)
652 {
653         /* For scanner V2 */
654         return MEDIA_SVC_PLUGIN_ERROR_NONE;
655 }
656
657 int delete_invalid_folder_by_path(void **handle, const char *storage_id, const char *folder_path, uid_t uid)
658 {
659         /* For scanner V2 */
660         return MEDIA_SVC_PLUGIN_ERROR_NONE;
661 }
662
663 int insert_folder_begin(void * handle, int item_cnt, char **err_msg)
664 {
665         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
666
667         ret = media_svc_insert_folder_begin(item_cnt);
668         if (ret < 0) {
669                 __set_error_message(ret, err_msg);
670                 return MEDIA_SVC_PLUGIN_ERROR;
671         }
672
673         return MEDIA_SVC_PLUGIN_ERROR_NONE;
674 }
675
676 int insert_folder_end(void *handle, uid_t uid, char **err_msg)
677 {
678         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
679
680         ret = media_svc_insert_folder_end(uid);
681         if (ret < 0) {
682                 __set_error_message(ret, err_msg);
683                 return MEDIA_SVC_PLUGIN_ERROR;
684         }
685
686         return MEDIA_SVC_PLUGIN_ERROR_NONE;
687 }
688
689 int insert_folder(void * handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
690 {
691         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
692
693         if (handle == NULL) {
694                 __set_error_message(ERR_HANDLE, err_msg);
695                 return MEDIA_SVC_PLUGIN_ERROR;
696         }
697
698         if (!STRING_VALID(file_path)) {
699                 __set_error_message(ERR_FILE_PATH, err_msg);
700                 return MEDIA_SVC_PLUGIN_ERROR;
701         }
702
703         if (!STORAGE_VALID(storage_type)) {
704                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
705                 return MEDIA_SVC_PLUGIN_ERROR;
706         }
707
708         ret = media_svc_insert_folder(handle, storage_id, storage_type, file_path, uid);
709         if (ret < 0) {
710                 __set_error_message(ret, err_msg);
711                 return MEDIA_SVC_PLUGIN_ERROR;
712         }
713
714         return MEDIA_SVC_PLUGIN_ERROR_NONE;
715 }
716
717 int delete_invalid_folder(void * handle, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
718 {
719         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
720
721         ret = media_svc_delete_invalid_folder(storage_id, storage_type, uid);
722         if (ret < 0) {
723                 __set_error_message(ret, err_msg);
724                 return MEDIA_SVC_PLUGIN_ERROR;
725         }
726
727         return MEDIA_SVC_PLUGIN_ERROR_NONE;
728 }
729
730 int set_folder_validity(void * handle, const char *storage_id, const char* start_path, int validity, bool is_recursive, uid_t uid, char **err_msg)
731 {
732         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
733
734         if (handle == NULL) {
735                 __set_error_message(ERR_HANDLE, err_msg);
736                 return MEDIA_SVC_PLUGIN_ERROR;
737         }
738
739         ret = media_svc_set_folder_validity(handle, storage_id, start_path, validity, is_recursive, uid);
740         if (ret < 0) {
741                 __set_error_message(ret, err_msg);
742                 return MEDIA_SVC_PLUGIN_ERROR;
743         }
744
745         return MEDIA_SVC_PLUGIN_ERROR_NONE;
746 }
747
748 int get_folder_scan_status(void *handle, const char *storage_id, const char *path, int *status, char **err_msg)
749 {
750         /* For scanner V2 */
751         return MEDIA_SVC_PLUGIN_ERROR_NONE;
752 }
753
754 int set_folder_scan_status(void *handle, const char *storage_id, const char *path, int status, uid_t uid, char **err_msg)
755 {
756         /* For scanner V2 */
757         return MEDIA_SVC_PLUGIN_ERROR_NONE;
758 }
759
760 int check_folder_modified(void *handle, const char *path, const char *storage_id, bool *modified, char **err_msg)
761 {
762         /* For scanner V2 */
763         return MEDIA_SVC_PLUGIN_ERROR_NONE;
764 }
765
766 int get_null_scan_folder_list(void *handle, const char *storage_id, const char *folder_path, char ***folder_list, int *count, char **err_msg)
767 {
768         /* For scanner V2 */
769         return MEDIA_SVC_PLUGIN_ERROR_NONE;
770 }
771
772 int change_validity_item_batch(void **handle, const char *storage_id, const char *path, int des_validity, int src_validity, uid_t uid, char **err_msg)
773 {
774         /* For scanner V2 */
775         return MEDIA_SVC_PLUGIN_ERROR_NONE;
776 }
777
778 int check_folder_exist(void * handle, const char *storage_id, const char *folder_path, char **err_msg)
779 {
780         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
781
782         if (handle == NULL) {
783                 __set_error_message(ERR_HANDLE, err_msg);
784                 return MEDIA_SVC_PLUGIN_ERROR;
785         }
786
787         ret = media_svc_check_folder_exist_by_path(handle, storage_id, folder_path);
788         if (ret < 0) {
789                 __set_error_message(ret, err_msg);
790                 return MEDIA_SVC_PLUGIN_ERROR;
791         }
792
793         return MEDIA_SVC_PLUGIN_ERROR_NONE;
794 }
795
796 int get_folder_id(void * handle, const char *storage_id, const char *path, char *folder_id, char **err_msg)
797 {
798         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
799
800         if (handle == NULL) {
801                 __set_error_message(ERR_HANDLE, err_msg);
802                 return MEDIA_SVC_PLUGIN_ERROR;
803         }
804
805         ret = media_svc_get_folder_id(handle, storage_id, path, folder_id);
806         if (ret < 0) {
807                 __set_error_message(ret, err_msg);
808                 return MEDIA_SVC_PLUGIN_ERROR;
809         }
810
811         return MEDIA_SVC_PLUGIN_ERROR_NONE;
812 }
813
814 int get_media_type(void *handle, const char *path, int *mediatype, char **err_msg)
815 {
816         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
817
818         if (handle == NULL) {
819                 __set_error_message(ERR_HANDLE, err_msg);
820                 return MEDIA_SVC_PLUGIN_ERROR;
821         }
822
823         ret = media_svc_get_media_type(path, mediatype);
824         if (ret < 0) {
825                 __set_error_message(ret, err_msg);
826                 return MEDIA_SVC_PLUGIN_ERROR;
827         }
828
829         return MEDIA_SVC_PLUGIN_ERROR_NONE;
830 }
831
832