Remove unused function
[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, FALSE, 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 insert_burst_item(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
232 {
233         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
234
235         if (handle == NULL) {
236                 __set_error_message(ERR_HANDLE, err_msg);
237                 return MEDIA_SVC_PLUGIN_ERROR;
238         }
239
240         if (!STRING_VALID(file_path)) {
241                 __set_error_message(ERR_FILE_PATH, err_msg);
242                 return MEDIA_SVC_PLUGIN_ERROR;
243         }
244
245         if (!STORAGE_VALID(storage_type)) {
246                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
247                 return MEDIA_SVC_PLUGIN_ERROR;
248         }
249
250         ret = media_svc_insert_item_bulk(handle, storage_id, storage_type, file_path, TRUE, uid);
251         if (ret < 0) {
252                 __set_error_message(ret, err_msg);
253                 return MEDIA_SVC_PLUGIN_ERROR;
254         }
255
256         return MEDIA_SVC_PLUGIN_ERROR_NONE;
257 }
258
259 int set_all_storage_items_validity(void *handle, const char *storage_id, int storage_type, int validity, uid_t uid, char **err_msg)
260 {
261         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
262
263         if (!STORAGE_VALID(storage_type)) {
264                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
265                 return MEDIA_SVC_PLUGIN_ERROR;
266         }
267
268         ret = media_svc_set_all_storage_items_validity(storage_id, storage_type, validity, uid);
269         if (ret < 0) {
270                 __set_error_message(ret, err_msg);
271                 return MEDIA_SVC_PLUGIN_ERROR;
272         }
273
274         return MEDIA_SVC_PLUGIN_ERROR_NONE;
275 }
276
277 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)
278 {
279         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
280
281         if (handle == NULL) {
282                 __set_error_message(ERR_HANDLE, err_msg);
283                 return MEDIA_SVC_PLUGIN_ERROR;
284         }
285
286         if (!STRING_VALID(folder_path)) {
287                 __set_error_message(ERR_FOLDER_PATH, err_msg);
288                 return MEDIA_SVC_PLUGIN_ERROR;
289         }
290
291         ret = media_svc_set_folder_items_validity(handle, storage_id, folder_path, validity, recursive, uid);
292         if (ret < 0) {
293                 __set_error_message(ret, err_msg);
294                 return MEDIA_SVC_PLUGIN_ERROR;
295         }
296
297         return MEDIA_SVC_PLUGIN_ERROR_NONE;
298 }
299
300 int set_item_validity_begin(void *handle, int item_cnt, char **err_msg)
301 {
302         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
303
304         ret = media_svc_set_item_validity_begin(item_cnt);
305         if (ret < 0) {
306                 __set_error_message(ret, err_msg);
307                 return MEDIA_SVC_PLUGIN_ERROR;
308         }
309
310         return MEDIA_SVC_PLUGIN_ERROR_NONE;
311 }
312
313 int set_item_validity_end(void *handle, uid_t uid, char **err_msg)
314 {
315         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
316
317         ret = media_svc_set_item_validity_end(uid);
318         if (ret < 0) {
319                 __set_error_message(ret, err_msg);
320                 return MEDIA_SVC_PLUGIN_ERROR;
321         }
322
323         return MEDIA_SVC_PLUGIN_ERROR_NONE;
324 }
325
326 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)
327 {
328         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
329
330         if (!STRING_VALID(file_path)) {
331                 __set_error_message(ERR_FILE_PATH, err_msg);
332                 return MEDIA_SVC_PLUGIN_ERROR;
333         }
334
335         ret = media_svc_set_item_validity(storage_id, file_path, validity, uid);
336
337         if (ret < 0) {
338                 __set_error_message(ret, err_msg);
339                 return MEDIA_SVC_PLUGIN_ERROR;
340         }
341
342         return MEDIA_SVC_PLUGIN_ERROR_NONE;
343 }
344
345 int delete_item(void *handle, const char *storage_id, const char *file_path, uid_t uid, char **err_msg)
346 {
347         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
348
349         if (handle == NULL) {
350                 __set_error_message(ERR_HANDLE, err_msg);
351                 return MEDIA_SVC_PLUGIN_ERROR;
352         }
353
354         if (!STRING_VALID(file_path)) {
355                 __set_error_message(ERR_FILE_PATH, err_msg);
356                 return MEDIA_SVC_PLUGIN_ERROR;
357         }
358
359         ret = media_svc_check_item_exist_by_path(handle, storage_id, file_path);
360         if (ret == 0) {
361                 ret = media_svc_delete_item_by_path(handle, storage_id, file_path, uid);
362
363                 if (ret < 0) {
364                         __set_error_message(ret, err_msg);
365                         return MEDIA_SVC_PLUGIN_ERROR;
366                 } else
367                         return MEDIA_SVC_PLUGIN_ERROR_NONE;
368         }
369
370         __set_error_message(ERR_CHECK_ITEM, err_msg);   /*not exist in DB so can't delete item. */
371         return MEDIA_SVC_PLUGIN_ERROR;
372 }
373
374 int delete_all_invalid_items_in_storage(void *handle, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
375 {
376         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
377
378         if (handle == NULL) {
379                 __set_error_message(ERR_HANDLE, err_msg);
380                 return MEDIA_SVC_PLUGIN_ERROR;
381         }
382
383         if (!STORAGE_VALID(storage_type)) {
384                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
385                 return MEDIA_SVC_PLUGIN_ERROR;
386         }
387
388         ret = media_svc_delete_invalid_items_in_storage(handle, storage_id, storage_type, uid);
389         if (ret < 0) {
390                 __set_error_message(ret, err_msg);
391                 return MEDIA_SVC_PLUGIN_ERROR;
392         }
393
394         return MEDIA_SVC_PLUGIN_ERROR_NONE;
395 }
396
397 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)
398 {
399         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
400
401         if (!STRING_VALID(dir_path)) {
402                 __set_error_message(ERR_FOLDER_PATH, err_msg);
403                 return MEDIA_SVC_PLUGIN_ERROR;
404         }
405
406         ret = media_svc_send_dir_update_noti(handle, storage_id, dir_path, folder_id, (media_item_update_type_e)update_type, pid);
407         if (ret < 0) {
408                 __set_error_message(ret, err_msg);
409                 return MEDIA_SVC_PLUGIN_ERROR;
410         }
411
412         return MEDIA_SVC_PLUGIN_ERROR_NONE;
413 }
414
415 int check_db(void *handle, uid_t uid, char **err_msg)
416 {
417         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
418         int user_version = -1;
419
420         ret = media_svc_get_user_version(handle, &user_version);
421         if (ret < 0) {
422                 __set_error_message(ret, err_msg);
423                 return MEDIA_SVC_PLUGIN_ERROR;
424         }
425
426         if (user_version == 0) {
427                 /*check db schema*/
428                 ret = media_svc_create_table(uid);
429                 if (ret < 0) {
430                         __set_error_message(ret, err_msg);
431                         return MEDIA_SVC_PLUGIN_ERROR;
432                 }
433         } else {
434                 /*check db version*/
435                 ret = media_svc_check_db_upgrade(handle, user_version, uid);
436                 if (ret < 0) {
437                         __set_error_message(ret, err_msg);
438                         return MEDIA_SVC_PLUGIN_ERROR;
439                 }
440         }
441
442         return MEDIA_SVC_PLUGIN_ERROR_NONE;
443 }
444
445 int update_folder_time(void *handle, const char *storage_id, char *folder_path, uid_t uid, char **err_msg)
446 {
447         /* For scanner V2 */
448         return MEDIA_SVC_PLUGIN_ERROR_NONE;
449 }
450
451 int get_uuid(void * handle, char **uuid, char **err_msg)
452 {
453         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
454
455         ret = media_svc_generate_uuid(uuid);
456         if (ret < 0) {
457                 __set_error_message(ret, err_msg);
458                 return MEDIA_SVC_PLUGIN_ERROR;
459         }
460
461         return MEDIA_SVC_PLUGIN_ERROR_NONE;
462 }
463
464 int check_storage(void * handle, const char *storage_id, char **storage_path, int *validity, uid_t uid, char **err_msg)
465 {
466         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
467
468         if (handle == NULL) {
469                 __set_error_message(ERR_HANDLE, err_msg);
470                 return MEDIA_SVC_PLUGIN_ERROR;
471         }
472
473         ret = media_svc_check_storage(handle, storage_id, storage_path, validity, uid);
474         if (ret < 0) {
475                 __set_error_message(ret, err_msg);
476                 return MEDIA_SVC_PLUGIN_ERROR;
477         }
478
479         return MEDIA_SVC_PLUGIN_ERROR_NONE;
480 }
481
482 int insert_storage(void *handle, const char *storage_id, int storage_type, const char *storage_name, const char *storage_path, uid_t uid, char **err_msg)
483 {
484         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
485
486         if (handle == NULL) {
487                 __set_error_message(ERR_HANDLE, err_msg);
488                 return MEDIA_SVC_PLUGIN_ERROR;
489         }
490
491         ret = media_svc_insert_storage(handle, storage_id, storage_name, storage_path, storage_type, uid);
492         if (ret < 0) {
493                 __set_error_message(ret, err_msg);
494                 return MEDIA_SVC_PLUGIN_ERROR;
495         }
496
497         return MEDIA_SVC_PLUGIN_ERROR_NONE;
498 }
499
500 int update_storage(void *handle, const char *storage_id, const char *storage_path, uid_t uid, char **err_msg)
501 {
502         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
503
504         if (handle == NULL) {
505                 __set_error_message(ERR_HANDLE, err_msg);
506                 return MEDIA_SVC_PLUGIN_ERROR;
507         }
508
509         ret = media_svc_update_storage(handle, storage_id, storage_path, uid);
510         if (ret < 0) {
511                 __set_error_message(ret, err_msg);
512                 return MEDIA_SVC_PLUGIN_ERROR;
513         }
514
515         return MEDIA_SVC_PLUGIN_ERROR_NONE;
516 }
517
518 int set_storage_validity(void * handle, const char *storage_id, int validity, uid_t uid, char **err_msg)
519 {
520         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
521
522         if (handle == NULL) {
523                 __set_error_message(ERR_HANDLE, err_msg);
524                 return MEDIA_SVC_PLUGIN_ERROR;
525         }
526
527         ret = media_svc_set_storage_validity(handle, storage_id, validity, uid);
528         if (ret < 0) {
529                 __set_error_message(ret, err_msg);
530                 return MEDIA_SVC_PLUGIN_ERROR;
531         }
532
533         return MEDIA_SVC_PLUGIN_ERROR_NONE;
534 }
535
536 int set_all_storage_validity(void * handle, int validity, uid_t uid, char **err_msg)
537 {
538         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
539
540         if (handle == NULL) {
541                 __set_error_message(ERR_HANDLE, err_msg);
542                 return MEDIA_SVC_PLUGIN_ERROR;
543         }
544
545         ret = media_svc_set_storage_validity(handle, NULL, validity, uid);
546         if (ret < 0) {
547                 __set_error_message(ret, err_msg);
548                 return MEDIA_SVC_PLUGIN_ERROR;
549         }
550
551         return MEDIA_SVC_PLUGIN_ERROR_NONE;
552 }
553
554 int get_storage_id(void * handle, const char *path, char *storage_id, uid_t uid, char **err_msg)
555 {
556         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
557
558         if (handle == NULL) {
559                 __set_error_message(ERR_HANDLE, err_msg);
560                 return MEDIA_SVC_PLUGIN_ERROR;
561         }
562
563         ret = media_svc_get_storage_id(handle, path, storage_id, uid);
564         if (ret < 0) {
565                 __set_error_message(ret, err_msg);
566                 return MEDIA_SVC_PLUGIN_ERROR;
567         }
568
569         return MEDIA_SVC_PLUGIN_ERROR_NONE;
570 }
571
572 int set_storage_scan_status(void *handle, const char *storage_id, int status, uid_t uid, char **err_msg)
573 {
574         /* For scanner V2 */
575         return MEDIA_SVC_PLUGIN_ERROR_NONE;
576 }
577
578 int get_storage_list(void *handle, char ***storage_list, char ***storage_id_list, int **scan_status_list, int *count, char **err_msg)
579 {
580         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
581
582         if (handle == NULL) {
583                 __set_error_message(ERR_HANDLE, err_msg);
584                 return MEDIA_SVC_PLUGIN_ERROR;
585         }
586
587         if (count == NULL) {
588                 __set_error_message(ERR_HANDLE, err_msg);
589                 return MEDIA_SVC_PLUGIN_ERROR;
590         }
591
592         ret = media_svc_get_storage_list(handle, storage_list, storage_id_list, scan_status_list, count);
593         if (ret < 0) {
594                 __set_error_message(ret, err_msg);
595                 return MEDIA_SVC_PLUGIN_ERROR;
596         }
597
598         return MEDIA_SVC_PLUGIN_ERROR_NONE;
599 }
600
601 int update_item_begin(void *handle, int item_cnt, char **err_msg)
602 {
603         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
604
605         ret = media_svc_update_item_begin(item_cnt);
606         if (ret < 0) {
607                 __set_error_message(ret, err_msg);
608                 return MEDIA_SVC_PLUGIN_ERROR;
609         }
610
611         return MEDIA_SVC_PLUGIN_ERROR_NONE;
612 }
613
614 int update_item_end(void *handle, uid_t uid, char **err_msg)
615 {
616         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
617
618         ret = media_svc_update_item_end(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 update_item_meta(void *handle, const char *file_path, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
628 {
629         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
630
631         if (handle == NULL) {
632                 __set_error_message(ERR_HANDLE, err_msg);
633                 return MEDIA_SVC_PLUGIN_ERROR;
634         }
635
636         if (file_path == NULL) {
637                 __set_error_message(ERR_HANDLE, err_msg);
638                 return MEDIA_SVC_PLUGIN_ERROR;
639         }
640
641         if (storage_id == NULL) {
642                 __set_error_message(ERR_HANDLE, err_msg);
643                 return MEDIA_SVC_PLUGIN_ERROR;
644         }
645
646         ret = media_svc_update_item_meta(handle, file_path, storage_id, storage_type, uid);
647         if (ret < 0) {
648                 __set_error_message(ret, err_msg);
649                 return MEDIA_SVC_PLUGIN_ERROR;
650         }
651
652         return MEDIA_SVC_PLUGIN_ERROR_NONE;
653 }
654
655 int insert_item_scan(void * handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
656 {
657         /* For scanner V2 */
658         return MEDIA_SVC_PLUGIN_ERROR_NONE;
659 }
660
661 int get_extract_list(void* handle, const char* storage_id, int storage_type, int scan_type, const char* path, int burst, uid_t uid, void* array, char** err_msg)
662 {
663         /* For scanner V2 */
664         return MEDIA_SVC_PLUGIN_ERROR_NONE;
665 }
666
667 int update_one_extract_item(void* handle, const char* storage_id, int storage_type, void* data, int burst, char** err_msg)
668 {
669         /* For scanner V2 */
670         return MEDIA_SVC_PLUGIN_ERROR_NONE;
671 }
672
673 int query_do_update_list(void* handle, char** err_msg)
674 {
675         /* For scanner V2 */
676         return MEDIA_SVC_PLUGIN_ERROR_NONE;
677 }
678
679 int delete_all_invalid_items_in_folder(void **handle, const char* storage_id, const char*path, bool is_recursive, uid_t uid)
680 {
681         /* For scanner V2 */
682         return MEDIA_SVC_PLUGIN_ERROR_NONE;
683 }
684
685 int delete_invalid_folder_by_path(void **handle, const char *storage_id, const char *folder_path, uid_t uid)
686 {
687         /* For scanner V2 */
688         return MEDIA_SVC_PLUGIN_ERROR_NONE;
689 }
690
691 int insert_folder_begin(void * handle, int item_cnt, char **err_msg)
692 {
693         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
694
695         ret = media_svc_insert_folder_begin(item_cnt);
696         if (ret < 0) {
697                 __set_error_message(ret, err_msg);
698                 return MEDIA_SVC_PLUGIN_ERROR;
699         }
700
701         return MEDIA_SVC_PLUGIN_ERROR_NONE;
702 }
703
704 int insert_folder_end(void *handle, uid_t uid, char **err_msg)
705 {
706         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
707
708         ret = media_svc_insert_folder_end(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 insert_folder(void * handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
718 {
719         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
720
721         if (handle == NULL) {
722                 __set_error_message(ERR_HANDLE, err_msg);
723                 return MEDIA_SVC_PLUGIN_ERROR;
724         }
725
726         if (!STRING_VALID(file_path)) {
727                 __set_error_message(ERR_FILE_PATH, err_msg);
728                 return MEDIA_SVC_PLUGIN_ERROR;
729         }
730
731         if (!STORAGE_VALID(storage_type)) {
732                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
733                 return MEDIA_SVC_PLUGIN_ERROR;
734         }
735
736         ret = media_svc_insert_folder(handle, storage_id, storage_type, file_path, uid);
737         if (ret < 0) {
738                 __set_error_message(ret, err_msg);
739                 return MEDIA_SVC_PLUGIN_ERROR;
740         }
741
742         return MEDIA_SVC_PLUGIN_ERROR_NONE;
743 }
744
745 int delete_invalid_folder(void * handle, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
746 {
747         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
748
749         ret = media_svc_delete_invalid_folder(storage_id, storage_type, uid);
750         if (ret < 0) {
751                 __set_error_message(ret, err_msg);
752                 return MEDIA_SVC_PLUGIN_ERROR;
753         }
754
755         return MEDIA_SVC_PLUGIN_ERROR_NONE;
756 }
757
758 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)
759 {
760         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
761
762         if (handle == NULL) {
763                 __set_error_message(ERR_HANDLE, err_msg);
764                 return MEDIA_SVC_PLUGIN_ERROR;
765         }
766
767         ret = media_svc_set_folder_validity(handle, storage_id, start_path, validity, is_recursive, uid);
768         if (ret < 0) {
769                 __set_error_message(ret, err_msg);
770                 return MEDIA_SVC_PLUGIN_ERROR;
771         }
772
773         return MEDIA_SVC_PLUGIN_ERROR_NONE;
774 }
775
776 int get_folder_scan_status(void *handle, const char *storage_id, const char *path, int *status, char **err_msg)
777 {
778         /* For scanner V2 */
779         return MEDIA_SVC_PLUGIN_ERROR_NONE;
780 }
781
782 int set_folder_scan_status(void *handle, const char *storage_id, const char *path, int status, uid_t uid, char **err_msg)
783 {
784         /* For scanner V2 */
785         return MEDIA_SVC_PLUGIN_ERROR_NONE;
786 }
787
788 int check_folder_modified(void *handle, const char *path, const char *storage_id, bool *modified, char **err_msg)
789 {
790         /* For scanner V2 */
791         return MEDIA_SVC_PLUGIN_ERROR_NONE;
792 }
793
794 int get_null_scan_folder_list(void *handle, const char *storage_id, const char *folder_path, char ***folder_list, int *count, char **err_msg)
795 {
796         /* For scanner V2 */
797         return MEDIA_SVC_PLUGIN_ERROR_NONE;
798 }
799
800 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)
801 {
802         /* For scanner V2 */
803         return MEDIA_SVC_PLUGIN_ERROR_NONE;
804 }
805
806 int check_folder_exist(void * handle, const char *storage_id, const char *folder_path, char **err_msg)
807 {
808         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
809
810         if (handle == NULL) {
811                 __set_error_message(ERR_HANDLE, err_msg);
812                 return MEDIA_SVC_PLUGIN_ERROR;
813         }
814
815         ret = media_svc_check_folder_exist_by_path(handle, storage_id, folder_path);
816         if (ret < 0) {
817                 __set_error_message(ret, err_msg);
818                 return MEDIA_SVC_PLUGIN_ERROR;
819         }
820
821         return MEDIA_SVC_PLUGIN_ERROR_NONE;
822 }
823
824 int get_folder_id(void * handle, const char *storage_id, const char *path, char *folder_id, char **err_msg)
825 {
826         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
827
828         if (handle == NULL) {
829                 __set_error_message(ERR_HANDLE, err_msg);
830                 return MEDIA_SVC_PLUGIN_ERROR;
831         }
832
833         ret = media_svc_get_folder_id(handle, storage_id, path, folder_id);
834         if (ret < 0) {
835                 __set_error_message(ret, err_msg);
836                 return MEDIA_SVC_PLUGIN_ERROR;
837         }
838
839         return MEDIA_SVC_PLUGIN_ERROR_NONE;
840 }
841
842 int get_media_type(void *handle, const char *path, int *mediatype, char **err_msg)
843 {
844         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
845
846         if (handle == NULL) {
847                 __set_error_message(ERR_HANDLE, err_msg);
848                 return MEDIA_SVC_PLUGIN_ERROR;
849         }
850
851         ret = media_svc_get_media_type(path, mediatype);
852         if (ret < 0) {
853                 __set_error_message(ret, err_msg);
854                 return MEDIA_SVC_PLUGIN_ERROR;
855         }
856
857         return MEDIA_SVC_PLUGIN_ERROR_NONE;
858 }
859
860