add new plugin API for counting invalid items before items are deleted
[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 <mm_file.h>
24 #include <media-thumbnail.h>
25 #include "media-svc.h"
26
27 #define MEDIA_SVC_PLUGIN_ERROR_NONE             0
28 #define MEDIA_SVC_PLUGIN_ERROR                  -1
29
30 #define STRING_VALID(str)       \
31         ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
32 #define STORAGE_VALID(storage)\
33         (((storage == MEDIA_SVC_STORAGE_INTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL)) ? TRUE : FALSE)
34
35
36 typedef enum{
37         ERR_HANDLE = 1,
38         ERR_FILE_PATH,
39         ERR_FOLDER_PATH,
40         ERR_MIME_TYPE,
41         ERR_NOT_MEDIAFILE,
42         ERR_STORAGE_TYPE,
43         ERR_CHECK_ITEM,
44         ERR_MAX,
45 }media_svc_error_type_e;
46
47 #define MS_CATEGORY_UNKNOWN     0x00000000      /**< Default */
48 #define MS_CATEGORY_ETC         0x00000001      /**< ETC category */
49 #define MS_CATEGORY_IMAGE               0x00000002      /**< Image category */
50 #define MS_CATEGORY_VIDEO               0x00000004      /**< Video category */
51 #define MS_CATEGORY_MUSIC               0x00000008      /**< Music category */
52 #define MS_CATEGORY_SOUND       0x00000010      /**< Sound category */
53
54 #define CONTENT_TYPE_NUM 4
55 #define MUSIC_MIME_NUM 29
56 #define SOUND_MIME_NUM 1
57 #define MIME_TYPE_LENGTH 255
58 #define MIME_LENGTH 50
59 #define _3GP_FILE ".3gp"
60 #define _MP4_FILE ".mp4"
61
62
63 typedef struct {
64         char content_type[15];
65         int category_by_mime;
66 } fex_content_table_t;
67
68 static const fex_content_table_t content_category[CONTENT_TYPE_NUM] = {
69         {"audio", MS_CATEGORY_SOUND},
70         {"image", MS_CATEGORY_IMAGE},
71         {"video", MS_CATEGORY_VIDEO},
72         {"application", MS_CATEGORY_ETC},
73 };
74
75 static const char music_mime_table[MUSIC_MIME_NUM][MIME_LENGTH] = {
76         /*known mime types of normal files*/
77         "mpeg",
78         "ogg",
79         "x-ms-wma",
80         "x-flac",
81         "mp4",
82         /* known mime types of drm files*/
83         "mp3",
84         "x-mp3", /*alias of audio/mpeg*/
85         "x-mpeg", /*alias of audio/mpeg*/
86         "3gpp",
87         "x-ogg", /*alias of  audio/ogg*/
88         "vnd.ms-playready.media.pya:*.pya", /*playready*/
89         "wma",
90         "aac",
91         "x-m4a", /*alias of audio/mp4*/
92         /* below mimes are rare*/
93         "x-vorbis+ogg",
94         "x-flac+ogg",
95         "x-matroska",
96         "ac3",
97         "mp2",
98         "x-ape",
99         "x-ms-asx",
100         "vnd.rn-realaudio",
101
102         "x-vorbis", /*alias of audio/x-vorbis+ogg*/
103         "vorbis", /*alias of audio/x-vorbis+ogg*/
104         "x-oggflac",
105         "x-mp2", /*alias of audio/mp2*/
106         "x-pn-realaudio", /*alias of audio/vnd.rn-realaudio*/
107         "vnd.m-realaudio", /*alias of audio/vnd.rn-realaudio*/
108         "x-wav",
109 };
110
111 static const char sound_mime_table[SOUND_MIME_NUM][MIME_LENGTH] = {
112         "x-smaf",
113 };
114
115 static void __set_error_message(int err_type, char ** err_msg);
116
117 static void __set_error_message(int err_type, char ** err_msg)
118 {
119         if (err_msg)
120                 *err_msg = NULL;
121         else
122                 return;
123
124         if(err_type == ERR_HANDLE)
125                 *err_msg = strdup("invalid handle");
126         else if(err_type == ERR_FILE_PATH)
127                 *err_msg = strdup("invalid file path");
128         else if(err_type == ERR_FOLDER_PATH)
129                 *err_msg = strdup("invalid folder path");
130         else if(err_type == ERR_MIME_TYPE)
131                 *err_msg = strdup("invalid mime type");
132         else if(err_type == ERR_NOT_MEDIAFILE)
133                 *err_msg = strdup("not media content");
134         else if(err_type == ERR_STORAGE_TYPE)
135                 *err_msg = strdup("invalid storage type");
136         else if(err_type == ERR_CHECK_ITEM)
137                 *err_msg = strdup("item does not exist");
138         else if(err_type == MEDIA_INFO_ERROR_DATABASE_CONNECT)
139                 *err_msg = strdup("DB connect error");
140         else if(err_type == MEDIA_INFO_ERROR_DATABASE_DISCONNECT)
141                 *err_msg = strdup("DB disconnect error");
142         else if(err_type == MEDIA_INFO_ERROR_INVALID_PARAMETER)
143                 *err_msg = strdup("invalid parameter");
144         else if(err_type == MEDIA_INFO_ERROR_DATABASE_INTERNAL)
145                 *err_msg = strdup("DB internal error");
146         else if(err_type == MEDIA_INFO_ERROR_DATABASE_NO_RECORD)
147                 *err_msg = strdup("not found in DB");
148         else if(err_type == MEDIA_INFO_ERROR_INTERNAL)
149                 *err_msg = strdup("media service internal error");
150         else
151                 *err_msg = strdup("error unknown");
152
153         return;
154 }
155
156 int check_item(const char *file_path, char ** err_msg)
157 {
158         if (!STRING_VALID(file_path)) {
159                 __set_error_message(ERR_FILE_PATH, err_msg);
160                 return MEDIA_SVC_PLUGIN_ERROR;
161         }
162
163         return MEDIA_SVC_PLUGIN_ERROR_NONE;
164 }
165
166 int connect(void ** handle, char ** err_msg)
167 {
168         int ret = media_svc_connect(handle);
169
170         if(ret < 0) {
171                 __set_error_message(ret, err_msg);
172                 return MEDIA_SVC_PLUGIN_ERROR;
173         }
174
175         return MEDIA_SVC_PLUGIN_ERROR_NONE;
176 }
177
178 int disconnect(void * handle, char ** err_msg)
179 {
180         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
181
182         if(handle == NULL) {
183                 __set_error_message(ERR_HANDLE, err_msg);
184                 return MEDIA_SVC_PLUGIN_ERROR;
185         }
186
187         ret = media_svc_disconnect(handle);
188         if(ret < 0) {
189                 __set_error_message(ret, err_msg);
190                 return MEDIA_SVC_PLUGIN_ERROR;
191         }
192
193         return MEDIA_SVC_PLUGIN_ERROR_NONE;
194 }
195
196 int check_item_exist(void* handle, const char *file_path, int storage_type, char ** err_msg)
197 {
198         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
199
200         if(handle == NULL) {
201                 __set_error_message(ERR_HANDLE, err_msg);
202                 return MEDIA_SVC_PLUGIN_ERROR;
203         }
204
205         if (!STRING_VALID(file_path)) {
206                 __set_error_message(ERR_FILE_PATH, err_msg);
207                 return MEDIA_SVC_PLUGIN_ERROR;
208         }
209
210         if(!STORAGE_VALID(storage_type)) {
211                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
212                 return MEDIA_SVC_PLUGIN_ERROR;
213         }
214
215         ret = media_svc_check_item_exist_by_path(handle, file_path);
216         if(ret == MEDIA_INFO_ERROR_NONE)
217                 return MEDIA_SVC_PLUGIN_ERROR_NONE;     //exist
218
219         __set_error_message(ERR_CHECK_ITEM, err_msg);
220
221         return MEDIA_SVC_PLUGIN_ERROR;          //not exist
222 }
223
224 int insert_item_begin(void * handle, int item_cnt, int with_noti, int from_pid, char ** err_msg)
225 {
226         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
227
228         if(handle == NULL) {
229                 __set_error_message(ERR_HANDLE, err_msg);
230                 return MEDIA_SVC_PLUGIN_ERROR;
231         }
232
233         ret = media_svc_insert_item_begin(handle, item_cnt, with_noti, from_pid);
234         if(ret < 0) {
235                 __set_error_message(ret, err_msg);
236                 return MEDIA_SVC_PLUGIN_ERROR;
237         }
238
239         return MEDIA_SVC_PLUGIN_ERROR_NONE;
240 }
241
242 int insert_item_end(void * handle, char ** err_msg)
243 {
244         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
245
246         if(handle == NULL) {
247                 __set_error_message(ERR_HANDLE, err_msg);
248                 return MEDIA_SVC_PLUGIN_ERROR;
249         }
250
251         ret = media_svc_insert_item_end(handle);
252         if(ret < 0) {
253                 __set_error_message(ret, err_msg);
254                 return MEDIA_SVC_PLUGIN_ERROR;
255         }
256
257         return MEDIA_SVC_PLUGIN_ERROR_NONE;
258 }
259
260 int insert_item(void * handle, const char *file_path, int storage_type, char ** err_msg)
261 {
262         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
263
264         if(handle == NULL) {
265                 __set_error_message(ERR_HANDLE, err_msg);
266                 return MEDIA_SVC_PLUGIN_ERROR;
267         }
268
269         if (!STRING_VALID(file_path)) {
270                 __set_error_message(ERR_FILE_PATH, err_msg);
271                 return MEDIA_SVC_PLUGIN_ERROR;
272         }
273
274         if(!STORAGE_VALID(storage_type)) {
275                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
276                 return MEDIA_SVC_PLUGIN_ERROR;
277         }
278
279         ret = media_svc_insert_item_bulk(handle, storage_type, file_path, FALSE);
280         if(ret < 0) {
281                 __set_error_message(ret, err_msg);
282                 return MEDIA_SVC_PLUGIN_ERROR;
283         }
284
285         return MEDIA_SVC_PLUGIN_ERROR_NONE;
286 }
287
288 int insert_item_immediately(void * handle, const char *file_path, int storage_type, char ** err_msg)
289 {
290         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
291
292         if(handle == NULL) {
293                 __set_error_message(ERR_HANDLE, err_msg);
294                 return MEDIA_SVC_PLUGIN_ERROR;
295         }
296
297         if (!STRING_VALID(file_path)) {
298                 __set_error_message(ERR_FILE_PATH, err_msg);
299                 return MEDIA_SVC_PLUGIN_ERROR;
300         }
301
302         if(!STORAGE_VALID(storage_type)) {
303                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
304                 return MEDIA_SVC_PLUGIN_ERROR;
305         }
306
307         ret = media_svc_insert_item_immediately(handle, storage_type, file_path);
308         if(ret < 0) {
309                 __set_error_message(ret, err_msg);
310                 return MEDIA_SVC_PLUGIN_ERROR;
311         }
312
313         return MEDIA_SVC_PLUGIN_ERROR_NONE;
314 }
315
316 int insert_burst_item(void * handle, const char *file_path, int storage_type, char ** err_msg)
317 {
318         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
319
320         if(handle == NULL) {
321                 __set_error_message(ERR_HANDLE, err_msg);
322                 return MEDIA_SVC_PLUGIN_ERROR;
323         }
324
325         if (!STRING_VALID(file_path)) {
326                 __set_error_message(ERR_FILE_PATH, err_msg);
327                 return MEDIA_SVC_PLUGIN_ERROR;
328         }
329
330         if(!STORAGE_VALID(storage_type)) {
331                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
332                 return MEDIA_SVC_PLUGIN_ERROR;
333         }
334
335         ret = media_svc_insert_item_bulk(handle, storage_type, file_path, TRUE);
336         if(ret < 0) {
337                 __set_error_message(ret, err_msg);
338                 return MEDIA_SVC_PLUGIN_ERROR;
339         }
340
341         return MEDIA_SVC_PLUGIN_ERROR_NONE;
342 }
343
344 int move_item_begin(void * handle, int item_cnt, char ** err_msg)
345 {
346         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
347
348         if(handle == NULL) {
349                 __set_error_message(ERR_HANDLE, err_msg);
350                 return MEDIA_SVC_PLUGIN_ERROR;
351         }
352
353         ret = media_svc_move_item_begin(handle, item_cnt);
354         if(ret < 0) {
355                 __set_error_message(ret, err_msg);
356                 return MEDIA_SVC_PLUGIN_ERROR;
357         }
358
359         return MEDIA_SVC_PLUGIN_ERROR_NONE;
360 }
361
362 int move_item_end(void * handle, char ** err_msg)
363 {
364         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
365
366         if(handle == NULL) {
367                 __set_error_message(ERR_HANDLE, err_msg);
368                 return MEDIA_SVC_PLUGIN_ERROR;
369         }
370
371         ret = media_svc_move_item_end(handle);
372         if(ret < 0) {
373                 __set_error_message(ret, err_msg);
374                 return MEDIA_SVC_PLUGIN_ERROR;
375         }
376
377         return MEDIA_SVC_PLUGIN_ERROR_NONE;
378 }
379
380 int move_item(void * handle, const char *src_path, int src_storage_type, const char *dest_path, int dest_storage_type, char ** err_msg)
381 {
382         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
383
384         if(handle == NULL) {
385                 __set_error_message(ERR_HANDLE, err_msg);
386                 return MEDIA_SVC_PLUGIN_ERROR;
387         }
388
389         if ((!STRING_VALID(src_path)) || (!STRING_VALID(dest_path))) {
390                 __set_error_message(ERR_FILE_PATH, err_msg);
391                 return MEDIA_SVC_PLUGIN_ERROR;
392         }
393
394         if((!STORAGE_VALID(src_storage_type)) || (!STORAGE_VALID(dest_storage_type))) {
395                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
396                 return MEDIA_SVC_PLUGIN_ERROR;
397         }
398
399         ret = media_svc_move_item(handle, src_storage_type, src_path, dest_storage_type, dest_path);
400         if(ret < 0) {
401                 __set_error_message(ret, err_msg);
402                 return MEDIA_SVC_PLUGIN_ERROR;
403         }
404
405         return MEDIA_SVC_PLUGIN_ERROR_NONE;
406 }
407
408 int set_all_storage_items_validity(void * handle, int storage_type, int validity, char ** err_msg)
409 {
410         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
411
412         if(handle == NULL) {
413                 __set_error_message(ERR_HANDLE, err_msg);
414                 return MEDIA_SVC_PLUGIN_ERROR;
415         }
416
417         if(!STORAGE_VALID(storage_type)) {
418                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
419                 return MEDIA_SVC_PLUGIN_ERROR;
420         }
421
422         ret = media_svc_set_all_storage_items_validity(handle, storage_type, validity);
423         if(ret < 0) {
424                 __set_error_message(ret, err_msg);
425                 return MEDIA_SVC_PLUGIN_ERROR;
426         }
427
428         return MEDIA_SVC_PLUGIN_ERROR_NONE;
429 }
430
431 int set_folder_item_validity(void * handle, const char * folder_path, int validity, int recursive, char ** err_msg)
432 {
433         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
434
435         if(handle == NULL) {
436                 __set_error_message(ERR_HANDLE, err_msg);
437                 return MEDIA_SVC_PLUGIN_ERROR;
438         }
439
440         if (!STRING_VALID(folder_path)) {
441                 __set_error_message(ERR_FOLDER_PATH, err_msg);
442                 return MEDIA_SVC_PLUGIN_ERROR;
443         }
444
445         ret = media_svc_set_folder_items_validity(handle, folder_path, validity, recursive);
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 set_item_validity_begin(void * handle, int item_cnt, 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_set_item_validity_begin(handle, item_cnt);
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 set_item_validity_end(void * handle, 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_set_item_validity_end(handle);
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_item_validity(void * handle, const char *file_path, int storage_type, int validity, 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         if (!STRING_VALID(file_path)) {
500                 __set_error_message(ERR_FILE_PATH, err_msg);
501                 return MEDIA_SVC_PLUGIN_ERROR;
502         }
503
504         if(!STORAGE_VALID(storage_type)) {
505                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
506                 return MEDIA_SVC_PLUGIN_ERROR;
507         }
508
509         ret = media_svc_set_item_validity(handle, file_path, validity);
510
511         if(ret < 0) {
512                 __set_error_message(ret, err_msg);
513                 return MEDIA_SVC_PLUGIN_ERROR;
514         }
515
516         return MEDIA_SVC_PLUGIN_ERROR_NONE;
517 }
518
519 int delete_item(void * handle, const char *file_path, int storage_type, char ** err_msg)
520 {
521         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
522
523         if(handle == NULL) {
524                 __set_error_message(ERR_HANDLE, err_msg);
525                 return MEDIA_SVC_PLUGIN_ERROR;
526         }
527
528         if (!STRING_VALID(file_path)) {
529                 __set_error_message(ERR_FILE_PATH, err_msg);
530                 return MEDIA_SVC_PLUGIN_ERROR;
531         }
532
533         if(!STORAGE_VALID(storage_type)) {
534                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
535                 return MEDIA_SVC_PLUGIN_ERROR;
536         }
537
538         ret = media_svc_check_item_exist_by_path(handle, file_path);
539         if(ret == 0) {
540                 ret = media_svc_delete_item_by_path(handle, file_path);
541
542                 if(ret < 0) {
543                         __set_error_message(ret, err_msg);
544                         return MEDIA_SVC_PLUGIN_ERROR;
545                 }
546                 else
547                         return MEDIA_SVC_PLUGIN_ERROR_NONE;
548         }
549
550         __set_error_message(ERR_CHECK_ITEM, err_msg);   //not exist in DB so can't delete item.
551         return MEDIA_SVC_PLUGIN_ERROR;
552 }
553
554 int delete_all_items_in_storage(void * handle, int storage_type, 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         if(!STORAGE_VALID(storage_type)) {
564                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
565                 return MEDIA_SVC_PLUGIN_ERROR;
566         }
567
568         ret = media_svc_delete_all_items_in_storage(handle, storage_type);
569         if(ret < 0) {
570                         __set_error_message(ret, err_msg);
571                         return MEDIA_SVC_PLUGIN_ERROR;
572         }
573
574         return MEDIA_SVC_PLUGIN_ERROR_NONE;
575 }
576
577 int delete_all_invalid_items_in_storage(void * handle, int storage_type, char ** err_msg)
578 {
579         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
580
581         if(handle == NULL) {
582                 __set_error_message(ERR_HANDLE, err_msg);
583                 return MEDIA_SVC_PLUGIN_ERROR;
584         }
585
586         if(!STORAGE_VALID(storage_type)) {
587                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
588                 return MEDIA_SVC_PLUGIN_ERROR;
589         }
590
591         ret = media_svc_delete_invalid_items_in_storage(handle, storage_type);
592         if(ret < 0) {
593                         __set_error_message(ret, err_msg);
594                         return MEDIA_SVC_PLUGIN_ERROR;
595         }
596
597         return MEDIA_SVC_PLUGIN_ERROR_NONE;
598 }
599
600 int delete_all_invalid_items_in_folder(void * handle, const char *folder_path, char ** err_msg)
601 {
602         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
603
604         if(handle == NULL) {
605                 __set_error_message(ERR_HANDLE, err_msg);
606                 return MEDIA_SVC_PLUGIN_ERROR;
607         }
608
609         if (!STRING_VALID(folder_path)) {
610                 __set_error_message(ERR_FOLDER_PATH, err_msg);
611                 return MEDIA_SVC_PLUGIN_ERROR;
612         }
613
614         ret = media_svc_delete_invalid_items_in_folder(handle, folder_path);
615         if(ret < 0) {
616                 __set_error_message(ret, err_msg);
617                 return MEDIA_SVC_PLUGIN_ERROR;
618         }
619
620         return MEDIA_SVC_PLUGIN_ERROR_NONE;
621 }
622
623 int delete_all_items(void * handle, char ** err_msg)
624 {
625         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
626
627         if(handle == NULL) {
628                 __set_error_message(ERR_HANDLE, err_msg);
629                 return MEDIA_SVC_PLUGIN_ERROR;
630         }
631
632         ret = delete_all_items_in_storage(handle, MEDIA_SVC_STORAGE_INTERNAL, err_msg);
633         if(ret < 0)
634                 return MEDIA_SVC_PLUGIN_ERROR;
635
636         ret = delete_all_items_in_storage(handle, MEDIA_SVC_STORAGE_EXTERNAL, err_msg);
637         if(ret < 0)
638                 return MEDIA_SVC_PLUGIN_ERROR;
639
640         return MEDIA_SVC_PLUGIN_ERROR_NONE;
641 }
642
643 int refresh_item(void * handle, const char *file_path, int storage_type, char ** err_msg)
644 {
645         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
646
647         if(handle == NULL) {
648                 __set_error_message(ERR_HANDLE, err_msg);
649                 return MEDIA_SVC_PLUGIN_ERROR;
650         }
651
652         if (!STRING_VALID(file_path)) {
653                 __set_error_message(ERR_FILE_PATH, err_msg);
654                 return MEDIA_SVC_PLUGIN_ERROR;
655         }
656
657         if(!STORAGE_VALID(storage_type)) {
658                 __set_error_message(ERR_STORAGE_TYPE, err_msg);
659                 return MEDIA_SVC_PLUGIN_ERROR;
660         }
661
662         ret = media_svc_refresh_item(handle, storage_type, file_path);
663         if(ret < 0) {
664                 __set_error_message(ret, err_msg);
665                 return MEDIA_SVC_PLUGIN_ERROR;
666         }
667
668         return MEDIA_SVC_PLUGIN_ERROR_NONE;
669 }
670
671 int update_begin(void)
672 {
673         return MEDIA_SVC_PLUGIN_ERROR_NONE;
674 }
675
676 int update_end(void)
677 {
678         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
679
680         ret = thumbnail_request_extract_all_thumbs();
681         if (ret < 0) {
682                 return MEDIA_SVC_PLUGIN_ERROR;
683         }
684
685         return MEDIA_SVC_PLUGIN_ERROR_NONE;
686 }
687
688 int send_dir_update_noti(void * handle, const char *dir_path, char **err_msg)
689 {
690         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
691
692         if (!STRING_VALID(dir_path)) {
693                 __set_error_message(ERR_FOLDER_PATH, err_msg);
694                 return MEDIA_SVC_PLUGIN_ERROR;
695         }
696
697         ret = media_svc_send_dir_update_noti(handle, dir_path);
698         if (ret < 0) {
699                 __set_error_message(ret, err_msg);
700                 return MEDIA_SVC_PLUGIN_ERROR;
701         }
702
703         return MEDIA_SVC_PLUGIN_ERROR_NONE;
704 }
705
706 int count_delete_items_in_folder(void * handle, const char *folder_path, int *count, char ** err_msg)
707 {
708         int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
709
710         if(handle == NULL) {
711                 __set_error_message(ERR_HANDLE, err_msg);
712                 return MEDIA_SVC_PLUGIN_ERROR;
713         }
714
715         if(count == NULL) {
716                 __set_error_message(ERR_HANDLE, err_msg);
717                 return MEDIA_SVC_PLUGIN_ERROR;
718         }
719
720         if (!STRING_VALID(folder_path)) {
721                 __set_error_message(ERR_FOLDER_PATH, err_msg);
722                 return MEDIA_SVC_PLUGIN_ERROR;
723         }
724
725         ret = media_svc_count_invalid_items_in_folder(handle, folder_path, count);
726         if(ret < 0) {
727                 __set_error_message(ret, err_msg);
728                 return MEDIA_SVC_PLUGIN_ERROR;
729         }
730
731         return MEDIA_SVC_PLUGIN_ERROR_NONE;
732 }