Add to scan dcm after media scanning was done
[platform/core/multimedia/libmedia-service.git] / plugin / media-content-plugin.c
index 97f59f7..cece7d4 100755 (executable)
  */
 
 #include <string.h>
+#include <sys/stat.h>
 #include <mm_file.h>
 #include <media-thumbnail.h>
+#include <media-util.h>
 #include "media-svc.h"
+#include "media-svc-util.h"
 
 #define MEDIA_SVC_PLUGIN_ERROR_NONE            0
 #define MEDIA_SVC_PLUGIN_ERROR                 -1
 #define STRING_VALID(str)      \
        ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
 #define STORAGE_VALID(storage)\
-       (((storage == MEDIA_SVC_STORAGE_INTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL)) ? TRUE : FALSE)
+       (((storage == MEDIA_SVC_STORAGE_INTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL_USB)) ? TRUE : FALSE)
 
 
-typedef enum{
+typedef enum {
        ERR_HANDLE = 1,
        ERR_FILE_PATH,
        ERR_FOLDER_PATH,
@@ -42,228 +45,56 @@ typedef enum{
        ERR_STORAGE_TYPE,
        ERR_CHECK_ITEM,
        ERR_MAX,
-}media_svc_error_type_e;
-
-#define MS_CATEGORY_UNKNOWN    0x00000000      /**< Default */
-#define MS_CATEGORY_ETC                0x00000001      /**< ETC category */
-#define MS_CATEGORY_IMAGE              0x00000002      /**< Image category */
-#define MS_CATEGORY_VIDEO              0x00000004      /**< Video category */
-#define MS_CATEGORY_MUSIC              0x00000008      /**< Music category */
-#define MS_CATEGORY_SOUND      0x00000010      /**< Sound category */
-
-#define CONTENT_TYPE_NUM 4
-#define MUSIC_MIME_NUM 29
-#define SOUND_MIME_NUM 1
-#define MIME_TYPE_LENGTH 255
-#define MIME_LENGTH 50
-#define _3GP_FILE ".3gp"
-#define _MP4_FILE ".mp4"
-
-
-typedef struct {
-       char content_type[15];
-       int category_by_mime;
-} fex_content_table_t;
-
-static const fex_content_table_t content_category[CONTENT_TYPE_NUM] = {
-       {"audio", MS_CATEGORY_SOUND},
-       {"image", MS_CATEGORY_IMAGE},
-       {"video", MS_CATEGORY_VIDEO},
-       {"application", MS_CATEGORY_ETC},
-};
-
-static const char music_mime_table[MUSIC_MIME_NUM][MIME_LENGTH] = {
-       /*known mime types of normal files*/
-       "mpeg",
-       "ogg",
-       "x-ms-wma",
-       "x-flac",
-       "mp4",
-       /* known mime types of drm files*/
-       "mp3",
-       "x-mp3", /*alias of audio/mpeg*/
-       "x-mpeg", /*alias of audio/mpeg*/
-       "3gpp",
-       "x-ogg", /*alias of  audio/ogg*/
-       "vnd.ms-playready.media.pya:*.pya", /*playready*/
-       "wma",
-       "aac",
-       "x-m4a", /*alias of audio/mp4*/
-       /* below mimes are rare*/
-       "x-vorbis+ogg",
-       "x-flac+ogg",
-       "x-matroska",
-       "ac3",
-       "mp2",
-       "x-ape",
-       "x-ms-asx",
-       "vnd.rn-realaudio",
-
-       "x-vorbis", /*alias of audio/x-vorbis+ogg*/
-       "vorbis", /*alias of audio/x-vorbis+ogg*/
-       "x-oggflac",
-       "x-mp2", /*alias of audio/mp2*/
-       "x-pn-realaudio", /*alias of audio/vnd.rn-realaudio*/
-       "vnd.m-realaudio", /*alias of audio/vnd.rn-realaudio*/
-       "x-wav",
-};
-
-static const char sound_mime_table[SOUND_MIME_NUM][MIME_LENGTH] = {
-       "x-smaf",
-};
-
-static int __get_content_type_from_mime(const char * path, const char * mimetype, int * category);
-static int __get_content_type(const char * file_path, const char * mime_type);
-static void __set_error_message(int err_type, char ** err_msg);
-
-static int __get_content_type_from_mime(const char * path, const char * mimetype, int * category)
-{
-       int i = 0;
-       int err = 0;
-
-       *category = MS_CATEGORY_UNKNOWN;
-
-       //MS_DBG("mime type : %s", mimetype);
-
-       /*categorize from mimetype */
-       for (i = 0; i < CONTENT_TYPE_NUM; i++) {
-               if (strstr(mimetype, content_category[i].content_type) != NULL) {
-                       *category = (*category | content_category[i].category_by_mime);
-                       break;
-               }
-       }
-
-       /*in application type, exitst sound file ex) x-smafs */
-       if (*category & MS_CATEGORY_ETC) {
-               int prefix_len = strlen(content_category[0].content_type);
-
-               for (i = 0; i < SOUND_MIME_NUM; i++) {
-                       if (strstr(mimetype + prefix_len, sound_mime_table[i]) != NULL) {
-                               *category ^= MS_CATEGORY_ETC;
-                               *category |= MS_CATEGORY_SOUND;
-                               break;
-                       }
-               }
-       }
-
-       /*check music file in soun files. */
-       if (*category & MS_CATEGORY_SOUND) {
-               int prefix_len = strlen(content_category[0].content_type) + 1;
-
-               //MS_DBG("mime_type : %s", mimetype + prefix_len);
-
-               for (i = 0; i < MUSIC_MIME_NUM; i++) {
-                       if (strcmp(mimetype + prefix_len, music_mime_table[i]) == 0) {
-                               *category ^= MS_CATEGORY_SOUND;
-                               *category |= MS_CATEGORY_MUSIC;
-                               break;
-                       }
-               }
-
-               /*m3u file is playlist but mime type is "audio/x-mpegurl". but It has to be classified into MS_CATEGORY_ETC since playlist is not a sound track*/
-               if(strncasecmp(mimetype, "audio/x-mpegurl", strlen("audio/x-mpegurl")) == 0) {
-                       *category ^= MS_CATEGORY_SOUND;
-                       *category |= MS_CATEGORY_ETC;
-               }
-       } else if (*category & MS_CATEGORY_VIDEO) {
-               /*some video files don't have video stream. in this case it is categorize as music. */
-               /*"3gp" and "mp4" must check video stream and then categorize in directly. */
-               char file_ext[10] = {0};
-               memset(file_ext, 0, sizeof(file_ext));
-               if((_media_svc_get_file_ext(path, file_ext)) && strlen(file_ext) > 0) {
-                       if ((strncasecmp(file_ext, _3GP_FILE, 4) == 0) || (strncasecmp(file_ext, _MP4_FILE, 5) == 0)) {
-                               int audio = 0;
-                               int video = 0;
-
-                               err = mm_file_get_stream_info(path, &audio, &video);
-                               if (err == 0) {
-                                       if (audio > 0 && video == 0) {
-                                               *category ^= MS_CATEGORY_VIDEO;
-                                               *category |= MS_CATEGORY_MUSIC;
-                                       }
-                               }
-                       }
-               }
-       }
-
-       //MS_DBG("category_from_ext : %d", *category);
-
-       return err;
-}
-
-static int __get_content_type(const char * file_path, const char * mime_type)
-{
-       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
-       int category = 0;
+} media_svc_error_type_e;
 
-       ret = __get_content_type_from_mime(file_path, mime_type, &category);
+static void __set_error_message(int err_type, char **err_msg);
 
-       if (category & MS_CATEGORY_SOUND)               return MEDIA_SVC_MEDIA_TYPE_SOUND;
-       else if (category & MS_CATEGORY_MUSIC)  return MEDIA_SVC_MEDIA_TYPE_MUSIC;
-       else if (category & MS_CATEGORY_IMAGE)  return MEDIA_SVC_MEDIA_TYPE_IMAGE;
-       else if (category & MS_CATEGORY_VIDEO)  return MEDIA_SVC_MEDIA_TYPE_VIDEO;
-       else    return MEDIA_SVC_MEDIA_TYPE_OTHER;
-}
-
-static void __set_error_message(int err_type, char ** err_msg)
+static void __set_error_message(int err_type, char **err_msg)
 {
        if (err_msg)
                *err_msg = NULL;
        else
                return;
 
-       if(err_type == ERR_HANDLE)
+       if (err_type == ERR_HANDLE)
                *err_msg = strdup("invalid handle");
-       else if(err_type == ERR_FILE_PATH)
+       else if (err_type == ERR_FILE_PATH)
                *err_msg = strdup("invalid file path");
-       else if(err_type == ERR_FOLDER_PATH)
+       else if (err_type == ERR_FOLDER_PATH)
                *err_msg = strdup("invalid folder path");
-       else if(err_type == ERR_MIME_TYPE)
+       else if (err_type == ERR_MIME_TYPE)
                *err_msg = strdup("invalid mime type");
-       else if(err_type == ERR_NOT_MEDIAFILE)
+       else if (err_type == ERR_NOT_MEDIAFILE)
                *err_msg = strdup("not media content");
-       else if(err_type == ERR_STORAGE_TYPE)
+       else if (err_type == ERR_STORAGE_TYPE)
                *err_msg = strdup("invalid storage type");
-       else if(err_type == ERR_CHECK_ITEM)
+       else if (err_type == ERR_CHECK_ITEM)
                *err_msg = strdup("item does not exist");
-       else if(err_type == MEDIA_INFO_ERROR_DATABASE_CONNECT)
+       else if (err_type == MS_MEDIA_ERR_DB_CONNECT_FAIL)
                *err_msg = strdup("DB connect error");
-       else if(err_type == MEDIA_INFO_ERROR_DATABASE_DISCONNECT)
+       else if (err_type == MS_MEDIA_ERR_DB_DISCONNECT_FAIL)
                *err_msg = strdup("DB disconnect error");
-       else if(err_type == MEDIA_INFO_ERROR_INVALID_PARAMETER)
+       else if (err_type == MS_MEDIA_ERR_INVALID_PARAMETER)
                *err_msg = strdup("invalid parameter");
-       else if(err_type == MEDIA_INFO_ERROR_DATABASE_INTERNAL)
+       else if (err_type == MS_MEDIA_ERR_DB_INTERNAL)
                *err_msg = strdup("DB internal error");
-       else if(err_type == MEDIA_INFO_ERROR_DATABASE_NO_RECORD)
+       else if (err_type == MS_MEDIA_ERR_DB_NO_RECORD)
                *err_msg = strdup("not found in DB");
-       else if(err_type == MEDIA_INFO_ERROR_INTERNAL)
+       else if (err_type == MS_MEDIA_ERR_INTERNAL)
                *err_msg = strdup("media service internal error");
+       else if (err_type == MS_MEDIA_ERR_DB_CORRUPT)
+               *err_msg = strdup("DB corrupt error");
        else
                *err_msg = strdup("error unknown");
 
        return;
 }
 
-int check_item(const char *file_path, const char * mime_type, char ** err_msg)
-{
-       if (!STRING_VALID(file_path)) {
-               __set_error_message(ERR_FILE_PATH, err_msg);
-               return MEDIA_SVC_PLUGIN_ERROR;
-       }
-
-       if (!STRING_VALID(mime_type)) {
-               __set_error_message(ERR_MIME_TYPE, err_msg);
-               return MEDIA_SVC_PLUGIN_ERROR;
-       }
-
-       return MEDIA_SVC_PLUGIN_ERROR_NONE;
-}
-
-int connect(void ** handle, char ** err_msg)
+int connect_db(void **handle, uid_t uid, char **err_msg)
 {
-       int ret = media_svc_connect(handle);
+       int ret = media_svc_connect(handle, uid, true);
 
-       if(ret < 0) {
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -271,17 +102,17 @@ int connect(void ** handle, char ** err_msg)
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int disconnect(void * handle, char ** err_msg)
+int disconnect_db(void *handle, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
        ret = media_svc_disconnect(handle);
-       if(ret < 0) {
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -289,11 +120,12 @@ int disconnect(void * handle, char ** err_msg)
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int check_item_exist(void* handle, const char *file_path, int storage_type, char ** err_msg)
+int check_item_exist(void *handle, const char *storage_id, const char *file_path, bool *modified, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+       *modified = TRUE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -303,31 +135,47 @@ int check_item_exist(void* handle, const char *file_path, int storage_type, char
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if(!STORAGE_VALID(storage_type)) {
-               __set_error_message(ERR_STORAGE_TYPE, err_msg);
-               return MEDIA_SVC_PLUGIN_ERROR;
-       }
+       time_t modified_time = 0;
+       unsigned long long file_size = 0;
+       struct stat st;
+
+       ret = media_svc_get_file_info(handle, storage_id, file_path, &modified_time, &file_size);
+       if (ret == MS_MEDIA_ERR_NONE) {
+               memset(&st, 0, sizeof(struct stat));
+               if (stat(file_path, &st) == 0) {
+                       if ((st.st_mtime != modified_time) || (st.st_size != file_size))
+                               *modified = TRUE;
+                       else
+                               *modified = FALSE;
+               }
 
-       ret = media_svc_check_item_exist_by_path(handle, file_path);
-       if(ret == MEDIA_INFO_ERROR_NONE)
-               return MEDIA_SVC_PLUGIN_ERROR_NONE;     //exist
+               return MEDIA_SVC_PLUGIN_ERROR_NONE;     /*exist */
+       }
 
        __set_error_message(ERR_CHECK_ITEM, err_msg);
 
-       return MEDIA_SVC_PLUGIN_ERROR;          //not exist
+       return MEDIA_SVC_PLUGIN_ERROR;          /*not exist */
 }
 
-int insert_item_begin(void * handle, int item_cnt, char ** err_msg)
+int insert_item_begin(void *handle, int item_cnt, int with_noti, int from_pid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
-               __set_error_message(ERR_HANDLE, err_msg);
+       ret = media_svc_insert_item_begin(item_cnt, with_noti, from_pid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_insert_item_begin(handle, item_cnt);
-       if(ret < 0) {
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int insert_item_end(void *handle, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       ret = media_svc_insert_item_end(uid);
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -335,17 +183,27 @@ int insert_item_begin(void * handle, int item_cnt, char ** err_msg)
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int insert_item_end(void * handle, char ** err_msg)
+int insert_item(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_insert_item_end(handle);
-       if(ret < 0) {
+       if (!STRING_VALID(file_path)) {
+               __set_error_message(ERR_FILE_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_insert_item_bulk(handle, storage_id, storage_type, file_path, FALSE, uid);
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -353,11 +211,11 @@ int insert_item_end(void * handle, char ** err_msg)
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int insert_item(void * handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg)
+int insert_item_immediately(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -367,20 +225,13 @@ int insert_item(void * handle, const char *file_path, int storage_type, const ch
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if (!STRING_VALID(mime_type)) {
-               __set_error_message(ERR_MIME_TYPE, err_msg);
-               return MEDIA_SVC_PLUGIN_ERROR;
-       }
-
-       if(!STORAGE_VALID(storage_type)) {
+       if (!STORAGE_VALID(storage_type)) {
                __set_error_message(ERR_STORAGE_TYPE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       media_svc_media_type_e content_type = __get_content_type(file_path, mime_type);
-
-       ret = media_svc_insert_item_bulk(handle, storage_type, file_path, mime_type, content_type);
-       if(ret < 0) {
+       ret = media_svc_insert_item_immediately(handle, storage_id, storage_type, file_path, uid);
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -388,11 +239,11 @@ int insert_item(void * handle, const char *file_path, int storage_type, const ch
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int insert_item_immediately(void * handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg)
+int insert_burst_item(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -402,21 +253,31 @@ int insert_item_immediately(void * handle, const char *file_path, int storage_ty
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if (!STRING_VALID(mime_type)) {
-               __set_error_message(ERR_MIME_TYPE, err_msg);
+       if (!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if(!STORAGE_VALID(storage_type)) {
-               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+       ret = media_svc_insert_item_bulk(handle, storage_id, storage_type, file_path, TRUE, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       media_svc_media_type_e content_type = __get_content_type(file_path, mime_type);
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int set_all_storage_items_validity(void *handle, const char *storage_id, int storage_type, int validity, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       ret = media_svc_insert_item_immediately(handle, storage_type, file_path, mime_type, content_type);
+       if (!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
 
-       if(ret < 0) {
+       ret = media_svc_set_all_storage_items_validity(storage_id, storage_type, validity, uid);
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -424,17 +285,22 @@ int insert_item_immediately(void * handle, const char *file_path, int storage_ty
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int move_item_begin(void * handle, int item_cnt, char ** err_msg)
+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)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_move_item_begin(handle, item_cnt);
-       if(ret < 0) {
+       if (!STRING_VALID(folder_path)) {
+               __set_error_message(ERR_FOLDER_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_set_folder_items_validity(handle, storage_id, folder_path, validity, recursive, uid);
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -442,17 +308,44 @@ int move_item_begin(void * handle, int item_cnt, char ** err_msg)
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int move_item_end(void * handle, char ** err_msg)
+int set_item_validity_begin(void *handle, int item_cnt, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
-               __set_error_message(ERR_HANDLE, err_msg);
+       ret = media_svc_set_item_validity_begin(item_cnt);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int set_item_validity_end(void *handle, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       ret = media_svc_set_item_validity_end(uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+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)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (!STRING_VALID(file_path)) {
+               __set_error_message(ERR_FILE_PATH, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_move_item_end(handle);
-       if(ret < 0) {
+       ret = media_svc_set_item_validity(storage_id, file_path, validity, uid);
+
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -460,32 +353,46 @@ int move_item_end(void * handle, char ** err_msg)
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int move_item(void * handle, const char *src_path, int src_storage_type, const char *dest_path, int dest_storage_type, const char * mime_type, char ** err_msg)
+int delete_item(void *handle, const char *storage_id, const char *file_path, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if ((!STRING_VALID(src_path)) || (!STRING_VALID(dest_path))) {
+       if (!STRING_VALID(file_path)) {
                __set_error_message(ERR_FILE_PATH, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if (!STRING_VALID(mime_type)) {
-               __set_error_message(ERR_MIME_TYPE, err_msg);
-               return MEDIA_SVC_PLUGIN_ERROR;
+       ret = media_svc_check_item_exist_by_path(handle, storage_id, file_path);
+       if (ret == 0) {
+               ret = media_svc_delete_item_by_path(handle, storage_id, file_path, uid);
+
+               if (ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               } else
+                       return MEDIA_SVC_PLUGIN_ERROR_NONE;
        }
 
-       if((!STORAGE_VALID(src_storage_type)) || (!STORAGE_VALID(dest_storage_type))) {
+       __set_error_message(ERR_CHECK_ITEM, err_msg);   /*not exist in DB so can't delete item. */
+       return MEDIA_SVC_PLUGIN_ERROR;
+}
+
+int delete_all_items_in_storage(void *handle, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (!STORAGE_VALID(storage_type)) {
                __set_error_message(ERR_STORAGE_TYPE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_move_item(handle, src_storage_type, src_path, dest_storage_type, dest_path);
-       if(ret < 0) {
+       ret = media_svc_delete_all_items_in_storage(storage_id, storage_type, uid);
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -493,22 +400,22 @@ int move_item(void * handle, const char *src_path, int src_storage_type, const c
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int set_all_storage_items_validity(void * handle, int storage_type, int validity, char ** err_msg)
+int delete_all_invalid_items_in_storage(void *handle, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if(!STORAGE_VALID(storage_type)) {
+       if (!STORAGE_VALID(storage_type)) {
                __set_error_message(ERR_STORAGE_TYPE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_set_all_storage_items_validity(handle, storage_type, validity);
-       if(ret < 0) {
+       ret = media_svc_delete_invalid_items_in_storage(handle, storage_id, storage_type, uid);
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -516,11 +423,11 @@ int set_all_storage_items_validity(void * handle, int storage_type, int validity
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int set_folder_item_validity(void * handle, const char * folder_path, int validity, int recursive, char ** err_msg)
+int delete_all_invalid_items_in_folder(void *handle, const char *storage_id, const char *folder_path, bool is_recursve, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -530,8 +437,8 @@ int set_folder_item_validity(void * handle, const char * folder_path, int validi
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_set_folder_items_validity(handle, folder_path, validity, recursive);
-       if(ret < 0) {
+       ret = media_svc_delete_invalid_items_in_folder(handle, storage_id, folder_path, is_recursve, uid);
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -539,35 +446,42 @@ int set_folder_item_validity(void * handle, const char * folder_path, int validi
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int set_item_validity_begin(void * handle, int item_cnt, char ** err_msg)
+
+int update_begin(void)
+{
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int update_end(const char *start_path, uid_t uid)
 {
+#if 0
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
-               __set_error_message(ERR_HANDLE, err_msg);
+       ret = thumbnail_request_extract_all_thumbs(uid);
+       if (ret < 0) {
                return MEDIA_SVC_PLUGIN_ERROR;
        }
+#endif
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       ret = media_svc_set_item_validity_begin(handle, item_cnt);
-       if(ret < 0) {
-               __set_error_message(ret, err_msg);
+       ret = dcm_svc_request_extract_all(uid);
+       if (ret < 0) {
                return MEDIA_SVC_PLUGIN_ERROR;
        }
-
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int set_item_validity_end(void * handle, char ** err_msg)
+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)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
-               __set_error_message(ERR_HANDLE, err_msg);
+       if (!STRING_VALID(dir_path)) {
+               __set_error_message(ERR_FOLDER_PATH, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_set_item_validity_end(handle);
-       if(ret < 0) {
+       ret = media_svc_send_dir_update_noti(handle, storage_id, dir_path, folder_id, (media_item_update_type_e)update_type, pid);
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -575,33 +489,27 @@ int set_item_validity_end(void * handle, char ** err_msg)
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int set_item_validity(void * handle, const char *file_path, int storage_type, const char * mime_type, int validity, char ** err_msg)
+int count_delete_items_in_folder(void *handle, const char *storage_id, const char *folder_path, int *count, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if (!STRING_VALID(file_path)) {
-               __set_error_message(ERR_FILE_PATH, err_msg);
-               return MEDIA_SVC_PLUGIN_ERROR;
-       }
-
-       if (!STRING_VALID(mime_type)) {
-               __set_error_message(ERR_MIME_TYPE, err_msg);
+       if (count == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if(!STORAGE_VALID(storage_type)) {
-               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+       if (!STRING_VALID(folder_path)) {
+               __set_error_message(ERR_FOLDER_PATH, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_set_item_validity(handle, file_path, validity);
-
-       if(ret < 0) {
+       ret = media_svc_count_invalid_items_in_folder(handle, storage_id, folder_path, count);
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -609,159 +517,192 @@ int set_item_validity(void * handle, const char *file_path, int storage_type, co
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int delete_item(void * handle, const char *file_path, int storage_type, char ** err_msg)
+int check_db(void *handle, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+       int user_version = -1;
 
-       if(handle == NULL) {
-               __set_error_message(ERR_HANDLE, err_msg);
+       ret = media_svc_get_user_version(handle, &user_version);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if (!STRING_VALID(file_path)) {
-               __set_error_message(ERR_FILE_PATH, err_msg);
-               return MEDIA_SVC_PLUGIN_ERROR;
+       if (user_version == 0) {
+               /*check db schema*/
+               ret = media_svc_create_table(uid);
+               if (ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+       } else {
+               /*check db version*/
+               ret = media_svc_check_db_upgrade(handle, user_version, uid);
+               if (ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
        }
 
-       if(!STORAGE_VALID(storage_type)) {
-               __set_error_message(ERR_STORAGE_TYPE, err_msg);
-               return MEDIA_SVC_PLUGIN_ERROR;
-       }
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
 
-       ret = media_svc_check_item_exist_by_path(handle, file_path);
-       if(ret == 0) {
-               ret = media_svc_delete_item_by_path(handle, file_path);
+int check_db_corrupt(void *handle, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-               if(ret < 0) {
-                       __set_error_message(ret, err_msg);
-                       return MEDIA_SVC_PLUGIN_ERROR;
-               }
-               else
-                       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+       /*check db version*/
+       ret = media_svc_check_db_corrupt(handle);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       __set_error_message(ERR_CHECK_ITEM, err_msg);   //not exist in DB so can't delete item.
-       return MEDIA_SVC_PLUGIN_ERROR;
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int delete_all_items_in_storage(void * handle, int storage_type, char ** err_msg)
+int get_folder_list(void *handle, const char *storage_id, char *start_path, char ***folder_list, int **modified_time_list, int **item_num_list, int *count, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if(!STORAGE_VALID(storage_type)) {
-               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+       if (count == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_delete_all_items_in_storage(handle, storage_type);
-       if(ret < 0) {
-                       __set_error_message(ret, err_msg);
-                       return MEDIA_SVC_PLUGIN_ERROR;
+       ret = media_svc_get_folder_list(handle, start_path, folder_list, (time_t **)modified_time_list, item_num_list, count);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
        }
 
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int delete_all_invalid_items_in_storage(void * handle, int storage_type, char ** err_msg)
+int update_folder_time(void *handle, const char *storage_id, char *folder_path, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if(!STORAGE_VALID(storage_type)) {
-               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+       if (folder_path == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_delete_invalid_items_in_storage(handle, storage_type);
-       if(ret < 0) {
-                       __set_error_message(ret, err_msg);
-                       return MEDIA_SVC_PLUGIN_ERROR;
+       ret = media_svc_update_folder_time(handle, storage_id, folder_path, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
        }
 
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int delete_all_invalid_items_in_folder(void * handle, const char *folder_path, char ** err_msg)
+int get_uuid(void * handle, char **uuid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
-               __set_error_message(ERR_HANDLE, err_msg);
+       ret = media_svc_generate_uuid(uuid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if (!STRING_VALID(folder_path)) {
-               __set_error_message(ERR_FOLDER_PATH, err_msg);
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int get_mmc_info(void * handle, char **storage_name, char **storage_path, int *validity, bool *info_exist, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_delete_invalid_items_in_folder(handle, folder_path);
-       if(ret < 0) {
-               __set_error_message(ret, err_msg);
+       ret = media_svc_get_mmc_info(handle, storage_name, storage_path, validity, info_exist);
+       if (ret < 0) {
+               __set_error_message(MS_MEDIA_ERR_DB_NO_RECORD, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int delete_all_items(void * handle, char ** err_msg)
+int check_storage(void * handle, const char *storage_id, const char *storage_name, char **storage_path, int *validity, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = delete_all_items_in_storage(handle, MEDIA_SVC_STORAGE_INTERNAL, err_msg);
-       if(ret < 0)
-               return MEDIA_SVC_PLUGIN_ERROR;
-
-       ret = delete_all_items_in_storage(handle, MEDIA_SVC_STORAGE_EXTERNAL, err_msg);
-       if(ret < 0)
+       ret = media_svc_check_storage(handle, storage_id, storage_name, storage_path, validity);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
+       }
 
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int refresh_item(void * handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg)
+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)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if (!STRING_VALID(file_path)) {
-               __set_error_message(ERR_FILE_PATH, err_msg);
+       ret = media_svc_insert_storage(handle, storage_id, storage_name, storage_path, NULL, storage_type, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if (!STRING_VALID(mime_type)) {
-               __set_error_message(ERR_MIME_TYPE, err_msg);
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int update_storage(void *handle, const char *storage_id, const char *storage_path, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if(!STORAGE_VALID(storage_type)) {
-               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+       ret = media_svc_update_storage(handle, storage_id, storage_path, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       media_svc_media_type_e content_type = __get_content_type(file_path, mime_type);
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int delete_storage(void * handle, const char *storage_id, const char *storage_name, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       ret = media_svc_refresh_item(handle, storage_type, file_path, content_type);
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
 
-       if(ret < 0) {
+       ret = media_svc_delete_storage(handle, storage_id, storage_name, uid);
+       if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
@@ -769,19 +710,476 @@ int refresh_item(void * handle, const char *file_path, int storage_type, const c
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int update_begin(void)
+int set_storage_validity(void * handle, const char *storage_id, int validity, uid_t uid, char **err_msg)
 {
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_set_storage_validity(handle, storage_id, validity, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int update_end(void)
+int set_all_storage_validity(void * handle, int validity, char **err_msg, uid_t uid)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
-       ret = thumbnail_request_extract_all_thumbs();
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_set_storage_validity(handle, NULL, validity, uid);
        if (ret < 0) {
+               __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
+
+int get_storage_id(void * handle, const char *path, char *storage_id, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_get_storage_id(handle, path, storage_id);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int get_storage_scan_status(void * handle, const char *storage_id, int *status, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+       media_svc_scan_status_type_e storage_status = 0;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_get_storage_scan_status(handle, storage_id, &storage_status);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       *status = storage_status;
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int set_storage_scan_status(void *handle, const char *storage_id, int status, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+       media_svc_scan_status_type_e storage_status = status;
+
+       ret = media_svc_set_storage_scan_status(storage_id, storage_status, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int get_storage_list(void *handle, char ***storage_list, char ***storage_id_list, int **scan_status_list, int *count, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (count == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_get_storage_list(handle, storage_list, storage_id_list, scan_status_list, count);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int update_item_begin(void *handle, int item_cnt, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       ret = media_svc_update_item_begin(item_cnt);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int update_item_end(void *handle, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       ret = media_svc_update_item_end(uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int update_item_meta(void *handle, const char *file_path, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (file_path == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (storage_id == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_update_item_meta(handle, file_path, storage_id, storage_type, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int insert_item_scan(void * handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(file_path)) {
+               __set_error_message(ERR_FILE_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_insert_item_pass1(handle, storage_id, storage_type, file_path, FALSE, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int update_item_extract(void * handle, const char *storage_id, int storage_type, int scan_type, uid_t uid, const char *path, int burst, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_insert_item_pass2(handle, storage_id, storage_type, scan_type, path, burst, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int insert_folder_begin(void * handle, int item_cnt, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       ret = media_svc_insert_folder_begin(item_cnt);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int insert_folder_end(void *handle, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       ret = media_svc_insert_folder_end(uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int insert_folder(void * handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(file_path)) {
+               __set_error_message(ERR_FILE_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_insert_folder(handle, storage_id, storage_type, file_path, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int delete_invalid_folder(void * handle, const char *storage_id, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       ret = media_svc_delete_invalid_folder(storage_id, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+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)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_set_folder_validity(handle, storage_id, start_path, validity, is_recursive, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int get_folder_scan_status(void *handle, const char *storage_id, const char *path, int *status, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+       int storage_status = 0;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_get_folder_scan_status(handle, storage_id, path, &storage_status);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       *status = storage_status;
+
+       return ret;
+}
+
+int set_folder_scan_status(void *handle, const char *storage_id, const char *path, int status, uid_t uid, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+       int storage_status = status;
+
+       ret = media_svc_set_folder_scan_status(storage_id, path, storage_status, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return ret;
+}
+
+int check_folder_modified(void *handle, const char *path, const char *storage_id, bool *modified, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+       *modified = TRUE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(path)) {
+               __set_error_message(ERR_FILE_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_get_folder_modified_time(handle, path, storage_id, modified);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return ret;
+}
+
+int get_null_scan_folder_list(void *handle, const char *storage_id, const char *folder_path, char ***folder_list, int *count, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (count == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_get_null_scan_folder_list(handle, storage_id, folder_path, folder_list, count);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return ret;
+}
+
+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)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       ret = media_svc_change_validity_item_batch(storage_id, path, des_validity, src_validity, uid);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return ret;
+}
+
+int delete_invalid_folder_by_path(void * handle, const char *storage_id, const char *folder_path, uid_t uid, int *delete_count, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_delete_invalid_folder_by_path(handle, storage_id, folder_path, uid, delete_count);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int check_folder_exist(void * handle, const char *storage_id, const char *folder_path, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_check_folder_exist_by_path(handle, storage_id, folder_path);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int count_subfolder(void *handle, const char *storage_id, const char *folder_path, int *count, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+       int cnt = 0;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_check_subfolder_by_path(handle, storage_id, folder_path, &cnt);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       *count = cnt;
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int get_folder_id(void * handle, const char *storage_id, const char *path, char *folder_id, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if (handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_get_folder_id(handle, storage_id, path, folder_id);
+       if (ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+