[ACR-1308] Remove deprecated APIs
[platform/core/multimedia/libmedia-service.git] / src / common / media-svc.c
index 10207c5..d36dcdf 100755 (executable)
@@ -311,7 +311,7 @@ int media_svc_insert_item_end(uid_t uid)
        return ret;
 }
 
-int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, int is_burst, uid_t uid)
+int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3 *db_handle = (sqlite3 *)handle;
@@ -352,7 +352,7 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, m
 
        if (g_media_svc_insert_item_data_cnt == 1) {
 
-               ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, is_burst, FALSE, uid);
+               ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, FALSE, uid);
                media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
 
                if (g_insert_with_noti)
@@ -360,7 +360,7 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, m
 
        } else if (g_media_svc_insert_item_cur_data_cnt < (g_media_svc_insert_item_data_cnt - 1)) {
 
-               ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, is_burst, TRUE, uid);
+               ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, TRUE, uid);
                media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
 
                if (g_insert_with_noti)
@@ -370,7 +370,7 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, m
 
        } else if (g_media_svc_insert_item_cur_data_cnt == (g_media_svc_insert_item_data_cnt - 1)) {
 
-               ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, is_burst, TRUE, uid);
+               ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, TRUE, uid);
                media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
 
                if (g_insert_with_noti)
@@ -452,7 +452,7 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storag
                }
        }
 
-       ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, FALSE, FALSE, uid);
+       ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, FALSE, uid);
 
        if (ret == MS_MEDIA_ERR_NONE) {
                media_svc_debug("Insertion is successful. Sending noti for this");
@@ -678,34 +678,6 @@ int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id
        return MS_MEDIA_ERR_NONE;
 }
 
-int media_svc_delete_all_items_in_storage(const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       char *thumb_path = NULL;
-
-       media_svc_debug("media_svc_delete_all_items_in_storage [%d]", storage_type);
-
-       media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
-       media_svc_retvm_if(__media_svc_check_storage(storage_type) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
-
-       ret = _media_svc_truncate_table(storage_id, storage_type, uid);
-       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-       if (storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB) {
-               ret = ms_user_get_thumb_store_path(uid, (ms_user_storage_type_e)storage_type, &thumb_path);
-               if (!STRING_VALID(thumb_path)) {
-                       media_svc_error("fail to get thumbnail path");
-                       return MS_MEDIA_ERR_INTERNAL;
-               }
-
-               ret = _media_svc_remove_all_files_in_dir(thumb_path);
-               SAFE_FREE(thumb_path);
-               media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-       }
-
-       return MS_MEDIA_ERR_NONE;
-}
-
 int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid)
 {
        sqlite3 *db_handle = (sqlite3 *)handle;
@@ -836,151 +808,6 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media
        return ret;
 }
 
-int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, const char *src_path, const char *dst_path, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       sqlite3 *db_handle = (sqlite3 *)handle;
-       char *name = NULL;
-       char *name_pinyin = NULL;
-       bool pinyin_support = FALSE;
-       char *sql = NULL;
-       int media_type = 0;
-       GArray *query_array = NULL;
-
-       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-       media_svc_retvm_if(src_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "src_path is NULL");
-       media_svc_retvm_if(dst_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "dst_path is NULL");
-
-       media_svc_debug("Src path : %s, Dst Path : %s", src_path, dst_path);
-
-       ret = _media_svc_sql_begin_trans(uid);
-       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-       /*1. Rename directory */
-       /*Update Pinyin If Support Pinyin*/
-       name = g_path_get_basename(dst_path);
-       media_svc_check_pinyin_support(&pinyin_support);
-       if (pinyin_support) {
-               media_svc_get_pinyin(name, &name_pinyin);
-               sql = sqlite3_mprintf("UPDATE %Q SET path='%q', name='%q', name_pinyin='%q' WHERE path = %Q",
-                                               MEDIA_SVC_DB_TABLE_FOLDER, dst_path, name, name_pinyin, src_path);
-       } else {
-               sql = sqlite3_mprintf("UPDATE %Q SET path='%q', name='%q' WHERE path = %Q",
-                                               MEDIA_SVC_DB_TABLE_FOLDER, dst_path, name, src_path);
-       }
-
-       ret = media_db_request_update_db_batch(sql, uid);
-       SQLITE3_SAFE_FREE(sql);
-       SAFE_FREE(name);
-       SAFE_FREE(name_pinyin);
-       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Failed to batch update request");
-
-       /* 2. Update sub-dir, sub-file */
-       /* Sub folder */
-       sql = sqlite3_mprintf("UPDATE folder SET path = REPLACE( path, '%q/', '%q/');", src_path, dst_path);
-       ret = media_db_request_update_db_batch(sql, uid);
-       SQLITE3_SAFE_FREE(sql);
-       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Failed to batch update request");
-
-       /* Sub files */
-       sql = sqlite3_mprintf("UPDATE '%q' SET path = REPLACE( path, '%q/', '%q/');", storage_id, src_path, dst_path);
-       ret = media_db_request_update_db_batch(sql, uid);
-       SQLITE3_SAFE_FREE(sql);
-       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Failed to batch update request");
-
-       ret = _media_svc_sql_end_trans(uid);
-       if (ret != MS_MEDIA_ERR_NONE) {
-               media_svc_error("mb_svc_sqlite3_commit_trans failed.. Now start to rollback");
-               return ret;
-       }
-
-       /*3. Get and update thumbnail_path if exists */
-       sqlite3_stmt *sql_stmt = NULL;
-
-       sql = sqlite3_mprintf("SELECT path, thumbnail_path, media_type from '%q' where path LIKE '%q/%%' AND thumbnail_path is not null", storage_id, dst_path);
-       media_svc_debug("[SQL query] : %s", sql);
-
-       ret = _media_svc_sql_prepare_to_step_simple(db_handle, sql, &sql_stmt);
-       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "error when media_svc_rename_folder. err = [%d]", ret);
-
-
-       query_array = g_array_new(FALSE, FALSE, sizeof(char *));
-       media_svc_retvm_if(query_array == NULL, MS_MEDIA_ERR_INTERNAL, "g_array_new failed");
-
-       while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
-               char media_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
-               char media_thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
-               char media_new_thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
-               char *thumb_query = NULL;
-
-               if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0))) {
-                       SAFE_STRLCPY(media_path, (const char *)sqlite3_column_text(sql_stmt, 0), sizeof(media_path));
-               } else {
-                       media_svc_error("media path is NULL");
-                       SQLITE3_FINALIZE(sql_stmt);
-                       return MS_MEDIA_ERR_DB_INTERNAL;
-               }
-
-               if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 1))) {
-                       SAFE_STRLCPY(media_thumb_path,  (const char *)sqlite3_column_text(sql_stmt, 1), sizeof(media_thumb_path));
-               } else {
-                       media_svc_error("thumbnail path is NULL");
-                       SQLITE3_FINALIZE(sql_stmt);
-                       return MS_MEDIA_ERR_DB_INTERNAL;
-               }
-
-               media_type = sqlite3_column_int(sql_stmt, 2);
-
-               ms_user_storage_type_e storage_type = -1;
-
-               ret = ms_user_get_storage_type(uid, media_path, &storage_type);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       media_svc_sec_error("ms_user_get_storage_type failed : [%d], path[%s] storage_type[%d]", ret, media_path, storage_type);
-                       SQLITE3_FINALIZE(sql_stmt);
-                       return ret;
-               }
-
-               ret = _media_svc_get_thumbnail_path(storage_type, media_type, media_new_thumb_path, media_path, THUMB_EXT, uid);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       media_svc_error("_media_svc_get_thumbnail_path failed : %d", ret);
-                       SQLITE3_FINALIZE(sql_stmt);
-                       return ret;
-               }
-
-               thumb_query = sqlite3_mprintf("UPDATE '%q' SET thumbnail_path='%q' WHERE path='%q'", storage_id, media_new_thumb_path, media_path);
-               g_array_append_val(query_array, thumb_query);
-
-               ret = _media_svc_rename_file(media_thumb_path, media_new_thumb_path);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("_media_svc_rename_file failed : %d", ret);
-       }
-
-       SQLITE3_FINALIZE(sql_stmt);
-
-       while (query_array->len != 0) {
-               sql = g_array_index(query_array , char*, 0);
-               g_array_remove_index(query_array, 0);
-               ret = media_db_request_update_db(sql, uid);
-               SQLITE3_SAFE_FREE(sql);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("media_db_request_update_db failed : %d", ret);
-       }
-
-       g_array_free(query_array, FALSE);
-       query_array = NULL;
-
-       media_svc_debug("Folder update is successful. Sending noti for this");
-       /* Get notification info */
-       media_svc_noti_item *noti_item = NULL;
-       ret = _media_svc_get_noti_info(db_handle, storage_id, dst_path, MS_MEDIA_ITEM_DIRECTORY, &noti_item);
-       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-       _media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, src_path, -1, noti_item->media_uuid, NULL);
-       _media_svc_destroy_noti_item(noti_item);
-
-       return MS_MEDIA_ERR_NONE;
-}
-
 int media_svc_request_update_db(const char *db_query, uid_t uid)
 {
        media_svc_retvm_if(!STRING_VALID(db_query), MS_MEDIA_ERR_INVALID_PARAMETER, "db_query is NULL");
@@ -1032,25 +859,6 @@ int media_svc_check_db_upgrade(MediaSvcHandle *handle, int user_version, uid_t u
        return _media_svc_check_db_upgrade(db_handle, user_version, uid);
 }
 
-int media_svc_update_folder_time(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       sqlite3 *db_handle = (sqlite3 *)handle;
-       time_t sto_time = 0;
-       int cur_time = _media_svc_get_file_time(folder_path);
-       char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
-
-       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-
-       ret = _media_svc_get_folder_info_by_foldername(db_handle, storage_id, folder_path, folder_uuid, &sto_time);
-       if (ret == MS_MEDIA_ERR_NONE) {
-               if (sto_time != cur_time)
-                       ret = _media_svc_update_folder_modified_time_by_folder_uuid(folder_uuid, folder_path, uid);
-       }
-
-       return ret;
-}
-
 int media_svc_update_item_begin(int data_cnt)
 {
        media_svc_debug("Transaction data count : [%d]", data_cnt);
@@ -1190,42 +998,7 @@ int media_svc_get_storage_id(MediaSvcHandle *handle, const char *path, char *sto
        return ret;
 }
 
-int media_svc_get_storage_path(MediaSvcHandle *handle, const char *storage_uuid, char **storage_path)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       sqlite3 * db_handle = (sqlite3 *)handle;
-
-       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-       media_svc_retvm_if(storage_uuid == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_uuid is NULL");
-
-       ret = _media_svc_get_storage_path(db_handle, storage_uuid, storage_path);
-
-       return ret;
-}
-
-int media_svc_get_storage_scan_status(MediaSvcHandle *handle, const char *storage_uuid, media_svc_scan_status_type_e *storage_status)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       sqlite3 * db_handle = (sqlite3 *)handle;
-
-       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-       media_svc_retvm_if(storage_uuid == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_uuid is NULL");
-
-       ret = _media_svc_get_storage_scan_status(db_handle, storage_uuid, storage_status);
-
-       return ret;
-}
-
-int media_svc_set_storage_scan_status(const char *storage_uuid, media_svc_scan_status_type_e storage_status, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-
-       ret = _media_svc_set_storage_scan_status(storage_uuid, storage_status, uid);
-
-       return ret;
-}
-
-int media_svc_get_storage_list(MediaSvcHandle *handle, char ***storage_list, char ***storage_id_list, int **scan_status_list, int *count)
+int media_svc_get_storage_list(MediaSvcHandle *handle, char ***storage_list, char ***storage_id_list, int *count)
 {
        sqlite3 * db_handle = (sqlite3 *)handle;
 
@@ -1234,185 +1007,7 @@ int media_svc_get_storage_list(MediaSvcHandle *handle, char ***storage_list, cha
        media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(count == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "count is NULL");
 
-       return _media_svc_get_all_storage(db_handle, storage_list, storage_id_list, scan_status_list, count);
-}
-
-static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_info, media_svc_content_info_s *new_content_info)
-{
-       media_svc_retvm_if(content_info == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-       media_svc_retvm_if(new_content_info == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-
-       if (content_info->added_time > 0)
-               new_content_info->added_time = content_info->added_time;
-       new_content_info->last_played_time = content_info->last_played_time;
-       new_content_info->played_count = content_info->played_count;
-       new_content_info->favourate = content_info->favourate;
-
-       /* Can be NULL if user not to set display_name using media_info_set_displayname().. */
-       if (STRING_VALID(content_info->file_name)) {
-               /* Already filled in _media_svc_set_media_info() */
-               SAFE_FREE(new_content_info->file_name);
-               new_content_info->file_name = g_strdup(content_info->file_name);
-       }
-       new_content_info->media_meta.title = g_strdup(content_info->media_meta.title);
-       new_content_info->media_meta.album = g_strdup(content_info->media_meta.album);
-       new_content_info->media_meta.artist = g_strdup(content_info->media_meta.artist);
-       new_content_info->media_meta.genre = g_strdup(content_info->media_meta.genre);
-       new_content_info->media_meta.composer = g_strdup(content_info->media_meta.composer);
-       new_content_info->media_meta.year = g_strdup(content_info->media_meta.year);
-       new_content_info->media_meta.recorded_date = g_strdup(content_info->media_meta.recorded_date);
-       new_content_info->media_meta.copyright = g_strdup(content_info->media_meta.copyright);
-       new_content_info->media_meta.track_num = g_strdup(content_info->media_meta.track_num);
-       new_content_info->media_meta.description = g_strdup(content_info->media_meta.description);
-       new_content_info->media_meta.weather = g_strdup(content_info->media_meta.weather);
-       new_content_info->media_meta.category = g_strdup(content_info->media_meta.category);
-       new_content_info->media_meta.keyword = g_strdup(content_info->media_meta.keyword);
-       new_content_info->media_meta.location_tag = g_strdup(content_info->media_meta.location_tag);
-       new_content_info->media_meta.content_name = g_strdup(content_info->media_meta.content_name);
-       new_content_info->media_meta.age_rating = g_strdup(content_info->media_meta.age_rating);
-       new_content_info->media_meta.author = g_strdup(content_info->media_meta.author);
-       new_content_info->media_meta.provider = g_strdup(content_info->media_meta.provider);
-
-       if (STRING_VALID(content_info->media_meta.datetaken)) {
-               new_content_info->media_meta.datetaken = g_strdup(content_info->media_meta.datetaken);
-
-               new_content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.datetaken);
-               if (new_content_info->timeline == 0) {
-                       media_svc_error("Failed to get timeline : %s", new_content_info->media_meta.datetaken);
-                       new_content_info->timeline = new_content_info->modified_time;
-               } else {
-                       media_svc_debug("Timeline : %ld", new_content_info->timeline);
-               }
-       }
-
-       new_content_info->media_meta.is_360 = content_info->media_meta.is_360;
-       /* new_content_info->media_meta.bitrate = content_info->media_meta.bitrate; */
-       /* new_content_info->media_meta.samplerate = content_info->media_meta.samplerate; */
-       /* new_content_info->media_meta.channel = content_info->media_meta.channel; */
-       /* new_content_info->media_meta.orientation = content_info->media_meta.orientation; */
-
-       if (content_info->media_meta.longitude != MEDIA_SVC_DEFAULT_GPS_VALUE)
-               new_content_info->media_meta.longitude = content_info->media_meta.longitude;
-       if (content_info->media_meta.latitude != MEDIA_SVC_DEFAULT_GPS_VALUE)
-               new_content_info->media_meta.latitude = content_info->media_meta.latitude;
-       if (content_info->media_meta.altitude != MEDIA_SVC_DEFAULT_GPS_VALUE)
-               new_content_info->media_meta.altitude = content_info->media_meta.altitude;
-
-       new_content_info->media_meta.rating = content_info->media_meta.rating;
-
-       return MS_MEDIA_ERR_NONE;
-}
-
-int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_svc_content_info_s *content_info, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       sqlite3 *db_handle = (sqlite3 *)handle;
-       char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
-       bool append_album = FALSE;
-
-       /* Checking parameters if they are valid */
-       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-       media_svc_retvm_if(content_info == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "content_info is NULL");
-       media_svc_retvm_if(!STRING_VALID(content_info->path), MS_MEDIA_ERR_INVALID_PARAMETER, "file_path is NULL");
-
-       media_svc_debug("storage[%d], path[%s], media_type[%d]", content_info->storage_type, content_info->path, content_info->media_type);
-
-       media_svc_content_info_s _new_content_info;
-       memset(&_new_content_info, 0, sizeof(media_svc_content_info_s));
-
-       media_svc_media_type_e media_type;
-
-       ret = _media_svc_set_media_info(&_new_content_info, content_info->storage_uuid, content_info->storage_type, content_info->path, &media_type, FALSE);
-       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "fail _media_svc_set_media_info");
-
-       if (media_type == MEDIA_SVC_MEDIA_TYPE_OTHER)
-               media_svc_debug("Do nothing[%d]", media_type);
-       else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
-               ret = _media_svc_extract_image_metadata(db_handle, &_new_content_info);
-       else
-               ret = _media_svc_extract_media_metadata(db_handle, &_new_content_info, uid);
-
-       media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
-
-       /* Extracting thumbnail */
-       if (_new_content_info.thumbnail_path == NULL) {
-               if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
-                       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
-
-                       ret = _media_svc_create_thumbnail(_new_content_info.path, thumb_path, sizeof(thumb_path), media_type, uid);
-                       if (ret == MS_MEDIA_ERR_NONE)
-                               _new_content_info.thumbnail_path = g_strdup(thumb_path);
-               }
-       }
-
-       /* set othere data to the structure, which is passed as parameters */
-       __media_svc_copy_para_to_content(content_info, &_new_content_info);
-
-       /* Set or Get folder id */
-       ret = _media_svc_get_and_append_folder_id_by_path(handle, _new_content_info.storage_uuid, _new_content_info.path, _new_content_info.storage_type, folder_uuid, uid);
-       media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &_new_content_info);
-
-       _new_content_info.folder_uuid = g_strdup(folder_uuid);
-       media_svc_retv_del_if(_new_content_info.folder_uuid == NULL, MS_MEDIA_ERR_INTERNAL, &_new_content_info);
-
-       /* register album table data */
-
-       int album_id = 0;
-       if (_new_content_info.media_type == MEDIA_SVC_MEDIA_TYPE_SOUND || _new_content_info.media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC) {
-               ret = _media_svc_get_album_id(handle, _new_content_info.media_meta.album, _new_content_info.media_meta.artist, &album_id);
-
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
-                               media_svc_debug("album does not exist. So start to make album art");
-                               append_album = TRUE;
-                       } else {
-                               media_svc_debug("other error");
-                               append_album = FALSE;
-                       }
-               } else {
-                       _new_content_info.album_id = album_id;
-                       append_album = FALSE;
-
-                       if ((!g_strcmp0(_new_content_info.media_meta.album, MEDIA_SVC_TAG_UNKNOWN)) ||
-                               (!g_strcmp0(_new_content_info.media_meta.artist, MEDIA_SVC_TAG_UNKNOWN))) {
-                               media_svc_debug("Unknown album or artist already exists. Extract thumbnail for Unknown.");
-                       } else {
-
-                               media_svc_debug("album already exists. don't need to make album art");
-                               ret = _media_svc_get_album_art_by_album_id(handle, album_id, &_new_content_info.thumbnail_path);
-                               media_svc_retv_del_if((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD), ret, &_new_content_info);
-                       }
-               }
-       }
-
-       if (append_album == TRUE) {
-               if ((g_strcmp0(_new_content_info.media_meta.album, MEDIA_SVC_TAG_UNKNOWN)) &&
-                       (g_strcmp0(_new_content_info.media_meta.artist, MEDIA_SVC_TAG_UNKNOWN)))
-                       ret = _media_svc_append_album(handle, _new_content_info.media_meta.album, _new_content_info.media_meta.artist, _new_content_info.thumbnail_path, &album_id, uid);
-               else
-                       ret = _media_svc_append_album(handle, _new_content_info.media_meta.album, _new_content_info.media_meta.artist, NULL, &album_id, uid);
-
-               _new_content_info.album_id = album_id;
-       }
-
-       /* Insert to db - calling _media_svc_insert_item_with_data */
-       ret = _media_svc_insert_item_with_data(db_handle, _new_content_info.storage_uuid, &_new_content_info, FALSE, FALSE, uid);
-
-       if (ret == MS_MEDIA_ERR_NONE)
-               media_svc_debug("Insertion is successful.");
-
-       if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL)
-               media_svc_error("This item is already inserted. This may be normal operation because other process already did this");
-
-       _media_svc_destroy_content_info(&_new_content_info);
-
-       /* handling returned value - important */
-       return ret;
-}
-
-void media_svc_destroy_content_info(media_svc_content_info_s *content_info)
-{
-       _media_svc_destroy_content_info(content_info);
+       return _media_svc_get_all_storage(db_handle, storage_list, storage_id_list, count);
 }
 
 int media_svc_generate_uuid(char **uuid)
@@ -1426,15 +1021,6 @@ int media_svc_generate_uuid(char **uuid)
        return MS_MEDIA_ERR_NONE;
 }
 
-int media_svc_get_mmc_info(MediaSvcHandle *handle, char **storage_name, char **storage_path, int *validity, bool *info_exist)
-{
-       sqlite3 * db_handle = (sqlite3 *)handle;
-
-       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-
-       return _media_svc_get_mmc_info(db_handle, storage_name, storage_path, validity, info_exist);
-}
-
 int media_svc_check_storage(MediaSvcHandle *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
 {
        sqlite3 * db_handle = (sqlite3 *)handle;
@@ -1458,7 +1044,7 @@ int media_svc_update_storage(MediaSvcHandle *handle, const char *storage_id, con
        return _media_svc_update_storage_path(db_handle, storage_id, storage_path, uid);
 }
 
-int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_name, const char *storage_path, media_svc_storage_type_e storage_type, uid_t uid)
+int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, media_svc_storage_type_e storage_type, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3 *db_handle = (sqlite3 *)handle;
@@ -1468,46 +1054,18 @@ int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, con
        media_svc_retvm_if(storage_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_path is NULL");
        media_svc_retvm_if(__media_svc_check_storage(storage_type) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
 
-       ret = _media_svc_append_storage(storage_id, storage_name, storage_path, storage_type, uid);
+       ret = _media_svc_append_storage(storage_id, storage_path, storage_type, uid);
        media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "append storage failed : %d", ret);
 
-       if (strcmp(storage_id, MEDIA_SVC_DB_TABLE_MEDIA)) {
-               ret = _media_svc_create_media_table_with_id(storage_id, uid);
-               media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "create media table failed : %d", ret);
-
-               ret = _media_svc_update_media_view(db_handle, uid);
-               media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "update media view failed : %d", ret);
-       }
-
-       return ret;
-}
-
-int media_svc_delete_storage(MediaSvcHandle *handle, const char *storage_id, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       sqlite3 *db_handle = (sqlite3 *)handle;
-       media_svc_storage_type_e storage_type;
-
-       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-       media_svc_retvm_if(storage_id == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
-
-       ret = _media_svc_get_storage_type(db_handle, storage_id, &storage_type);
-       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_get_storage_type failed : %d", ret);
-
-       ret = _media_svc_delete_storage(storage_id, uid);
-       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "remove storage failed : %d", ret);
-
-       ret = _media_svc_delete_folder_by_storage_id(storage_id, storage_type, uid);
-       if (ret != MS_MEDIA_ERR_NONE)
-               media_svc_error("fail to _media_svc_delete_folder_by_storage_id. error : [%d]", ret);
+       ret = _media_svc_create_media_table_with_id(storage_id, uid);
+       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "create media table failed : %d", ret);
 
-       if (storage_type == MEDIA_SVC_STORAGE_EXTERNAL_USB) {
-               ret = _media_svc_drop_media_table(storage_id, uid);
-               media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "drop table failed : %d", ret);
+       ret = _media_svc_update_media_view(db_handle, uid);
+       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "update media view failed : %d", ret);
 
-               ret = _media_svc_update_media_view(db_handle, uid);
-               media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "update media view failed : %d", ret);
-       }
+       /* Remove external storage that validity is 0 */
+       ret = _media_svc_delete_invalid_storage(db_handle, storage_type, uid);
+       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Delete invalid storage failed : %d", ret);
 
        return ret;
 }
@@ -1600,151 +1158,6 @@ int media_svc_set_folder_validity(MediaSvcHandle *handle, const char *storage_id
        return ret;
 }
 
-int media_svc_insert_item_pass1(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, int is_burst, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       sqlite3 * db_handle = (sqlite3 *)handle;
-       char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,};
-       media_svc_media_type_e media_type;
-
-       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-       media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
-       media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
-       media_svc_retvm_if(__media_svc_check_storage(storage_type) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
-
-       media_svc_content_info_s content_info;
-       memset(&content_info, 0, sizeof(media_svc_content_info_s));
-
-       /*Set basic media info*/
-       ret = _media_svc_set_media_info(&content_info, storage_id, storage_type, path, &media_type, FALSE);
-       if (ret != MS_MEDIA_ERR_NONE) {
-               media_svc_error("_media_svc_set_media_info fail %d", ret);
-               return ret;
-       }
-
-       /*Set or Get folder id*/
-       ret = _media_svc_get_and_append_folder_id_by_path(db_handle, storage_id, path, storage_type, folder_uuid, uid);
-       media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
-
-       content_info.folder_uuid = g_strdup(folder_uuid);
-       media_svc_retv_del_if(content_info.folder_uuid == NULL, MS_MEDIA_ERR_INTERNAL, &content_info);
-
-       if (g_media_svc_insert_item_data_cnt == 1) {
-
-               ret = _media_svc_insert_item_pass1(db_handle, storage_id, &content_info, is_burst, FALSE, uid);
-               media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
-
-               if (g_insert_with_noti)
-                       _media_svc_insert_item_to_noti_list(&content_info, g_media_svc_insert_item_cur_data_cnt++);
-       } else if (g_media_svc_insert_item_cur_data_cnt < (g_media_svc_insert_item_data_cnt - 1)) {
-
-               ret = _media_svc_insert_item_pass1(db_handle, storage_id, &content_info, is_burst, TRUE, uid);
-               media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
-
-               if (g_insert_with_noti)
-                       _media_svc_insert_item_to_noti_list(&content_info, g_media_svc_insert_item_cur_data_cnt);
-
-               media_svc_debug("g_media_svc_insert_item_cur_data_cnt %d", g_media_svc_insert_item_cur_data_cnt);
-               g_media_svc_insert_item_cur_data_cnt++;
-
-       } else if (g_media_svc_insert_item_cur_data_cnt == (g_media_svc_insert_item_data_cnt - 1)) {
-
-               ret = _media_svc_insert_item_pass1(db_handle, storage_id, &content_info, is_burst, TRUE, uid);
-               media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
-
-               if (g_insert_with_noti)
-                       _media_svc_insert_item_to_noti_list(&content_info, g_media_svc_insert_item_cur_data_cnt);
-
-               ret = _media_svc_list_query_do(MEDIA_SVC_QUERY_INSERT_ITEM, uid);
-               media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
-
-               media_svc_debug("_media_svc_list_query_do over");
-
-               if (g_insert_with_noti) {
-                       media_svc_debug("publish noti list %d", g_media_svc_insert_item_cur_data_cnt);
-                       _media_svc_publish_noti_list(g_media_svc_insert_item_cur_data_cnt + 1);
-                       _media_svc_destroy_noti_list(g_media_svc_insert_item_cur_data_cnt + 1);
-
-                       /* Recreate noti list */
-                       ret = _media_svc_create_noti_list(g_media_svc_insert_item_data_cnt);
-                       media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
-               }
-
-               g_media_svc_insert_item_cur_data_cnt = 0;
-
-       } else {
-               media_svc_error("Error in media_svc_insert_item_pass1");
-               _media_svc_destroy_content_info(&content_info);
-               return MS_MEDIA_ERR_INTERNAL;
-       }
-
-       _media_svc_destroy_content_info(&content_info);
-
-       return MS_MEDIA_ERR_NONE;
-}
-
-int media_svc_get_folder_scan_status(MediaSvcHandle *handle, const char *storage_id, const char *path, int *storage_status)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       sqlite3 * db_handle = (sqlite3 *)handle;
-
-       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-       media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
-
-       ret = _media_svc_get_folder_scan_status(db_handle, storage_id, path, storage_status);
-
-       return ret;
-}
-
-int media_svc_set_folder_scan_status(const char *storage_id, const char *path, int storage_status, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-
-       ret = _media_svc_set_folder_scan_status(storage_id, path, storage_status, uid);
-
-       return ret;
-}
-
-int media_svc_get_folder_modified_time(MediaSvcHandle *handle, const char *path, const char *storage_id, bool *modified)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       sqlite3 * db_handle = (sqlite3 *)handle;
-       time_t modified_time = 0;
-       int system_time = 0;
-
-       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-
-       ret = _media_svc_get_folder_modified_time_by_path(db_handle, path, storage_id, &modified_time);
-
-       system_time = _media_svc_get_file_time(path);
-       media_svc_error("modified_time = [%ld], system_time = [%d], path = [%s]", modified_time, system_time, path);
-
-       if (system_time != modified_time && system_time != 0)
-               *modified = TRUE;
-       else
-               *modified = FALSE;
-
-       return ret;
-}
-
-int media_svc_get_null_scan_folder_list(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, char ***folder_list, int *count)
-{
-       sqlite3 * db_handle = (sqlite3 *)handle;
-
-       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-       media_svc_retvm_if(count == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "count is NULL");
-
-       return _media_svc_get_null_scan_folder_list(db_handle, storage_id, folder_path, folder_list, count);
-}
-
-int media_svc_change_validity_item_batch(const char *storage_id, const char *path, int des_validity, int src_validity, uid_t uid)
-{
-       media_svc_retvm_if(storage_id == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
-       media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
-
-       return _media_svc_change_validity_item_batch(storage_id, path, des_validity, src_validity, uid);
-}
-
 int media_svc_check_folder_exist_by_path(MediaSvcHandle *handle, const char *storage_id, const char *folder_path)
 {
        int ret = MS_MEDIA_ERR_NONE;