send message to app when recursive scan start
[platform/core/api/media-content.git] / src / media_info.c
old mode 100755 (executable)
new mode 100644 (file)
index cc33fdb..994e253
@@ -47,7 +47,7 @@ static int __media_info_get_media_path_by_id_from_db(const char *media_id, char
 
        select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
 
-       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+       ret = _content_get_result(select_query, &stmt);
        SQLITE3_SAFE_FREE(select_query);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
@@ -71,7 +71,7 @@ static void __media_info_insert_completed_cb(media_request_result_s *result, voi
 
        if (_cb_data) {
                if (result)
-                       ret = _content_error_capi(MEDIA_CONTENT_TYPE, result->result);
+                       ret = _content_error_capi(result->result);
 
                if (_cb_data->insert_completed_cb) {
                        media_content_debug("User callback is being called now");
@@ -107,11 +107,11 @@ static void __media_info_thumbnail_completed_cb(int error, const char *path, voi
                        if (STRING_VALID(path))
                                media->thumbnail_path = g_strdup(path);
                        else
-                               media->thumbnail_path = g_strdup(EMPTY_STR);
+                               media->thumbnail_path = g_strdup(MEDIA_CONTENT_EMPTY_STRING);
                }
 
                media_content_debug("error [%d], thumbnail_path [%s]", error, path);
-               error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
+               error_value = _content_error_capi(error);
                if (_thumb_cb->thumbnail_completed_cb)
                        _thumb_cb->thumbnail_completed_cb(error_value, path, _thumb_cb->user_data);
        }
@@ -143,7 +143,7 @@ static void __media_info_face_completed_cb(int error, const int face_count, void
 
        if (_face_cb != NULL) {
                media_content_debug("error [%d], face_count [%d]", error, face_count);
-               error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
+               error_value = _content_error_capi(error);
                if (_face_cb->face_completed_cb)
                        _face_cb->face_completed_cb(error_value, face_count, _face_cb->user_data);
        }
@@ -243,7 +243,7 @@ static int __media_info_insert_batch(const char **path_array,
                media_content_error("media_files_register failed : %d", ret);
                if (unlink(list_path) < 0)
                        media_content_stderror("failed to delete");
-               return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+               return _content_error_capi(ret);
        }
 
        return ret;
@@ -314,7 +314,6 @@ void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
                        _media->image_meta->iso = sqlite3_column_int(stmt, MEDIA_INFO_ISO);
                        _media->image_meta->date_taken = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
                        _media->image_meta->orientation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
-                       _media->image_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
                        _media->image_meta->exposure_time = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_EXPOSURE_TIME));
                        _media->image_meta->model = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MODEL));
                }
@@ -324,7 +323,6 @@ void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
                        _media->video_meta->media_id = g_strdup(_media->media_id);
                        _media->video_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
                        _media->video_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
-                       _media->video_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
                        _media->video_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
                        _media->video_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
                        _media->video_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
@@ -343,7 +341,6 @@ void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
                _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
                if (_media->audio_meta) {
                        _media->audio_meta->media_id = g_strdup(_media->media_id);
-                       _media->audio_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
                        _media->audio_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
                        _media->audio_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
                        _media->audio_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
@@ -361,7 +358,7 @@ void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
                }
        }
 }
-
+#ifdef _USE_TVPD_MODE
 int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
@@ -373,7 +370,7 @@ int _media_info_get_media_info_from_db(const char *path, const char *storage_id,
 
        select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, storage_id, path);
 
-       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+       ret = _content_get_result(select_query, &stmt);
        SQLITE3_SAFE_FREE(select_query);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
@@ -388,12 +385,42 @@ int _media_info_get_media_info_from_db(const char *path, const char *storage_id,
 
        return ret;
 }
+#else
+int _media_info_get_media_info_from_db(const char *path, media_info_h media)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       char *select_query = NULL;
+       media_info_s *_media = (media_info_s*)media;
+
+       media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
+
+       select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path);
+
+       ret = _content_get_result(select_query, &stmt);
+       SQLITE3_SAFE_FREE(select_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       if (sqlite3_step(stmt) == SQLITE_ROW) {
+               _media_info_item_get_detail(stmt, (media_info_h)_media);
+       } else {
+               media_content_sec_error("No media : path[%s]", path);
+               ret = MEDIA_CONTENT_ERROR_DB_FAILED;
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+#endif
 
 int media_info_insert_to_db(const char *path, media_info_h *info)
 {
        char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
        char repl_path[MAX_PATH_LEN] = {0, };
        int ret = MEDIA_CONTENT_ERROR_NONE;
+       ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
+       int modified_time = 0;
 
        media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
        media_content_retvm_if(info == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
@@ -408,23 +435,31 @@ int media_info_insert_to_db(const char *path, media_info_h *info)
        ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
        if (ret != MS_MEDIA_ERR_NONE) {
                media_content_error("media_svc_get_storage_id failed : %d", ret);
-               return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+               return _content_error_capi(ret);
        }
 
-       ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, repl_path);
-       if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
+       ret = ms_user_get_storage_type(_content_get_uid(), repl_path, &storage_type);
+       if (ret != MS_MEDIA_ERR_NONE) {
+               media_content_sec_error("ms_user_get_storage_type failed : %d", ret);
+               return _content_error_capi(ret);
+       }
+
+       /* Get modified time for check exists */
+       ret = media_svc_get_modified_time(_content_get_db_handle(), storage_id, repl_path, &modified_time);
+       if (ret == MS_MEDIA_ERR_NONE) {
+               /* Refresh if need */
+               if (modified_time != _media_util_get_file_time(repl_path)) {
+                       ret = media_svc_refresh_item(_content_get_db_handle(), false, storage_id, storage_type, repl_path, _content_get_uid());
+                       if (ret != MS_MEDIA_ERR_NONE) {
+                               media_content_error("media_svc_refresh_item failed : %d", ret);
+                               return _content_error_capi(ret);
+                       }
+               }
+       } else if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
                media_content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", repl_path);
                media_content_retvm_if(!_media_util_check_support_media_type(repl_path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
-               ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
-
-               ret = ms_user_get_storage_type(_content_get_uid(), repl_path, &storage_type);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       media_content_sec_error("ms_user_get_storage_type failed : %d", ret);
-                       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
-               }
 
                ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, _content_get_uid());
-
                if (ret != MS_MEDIA_ERR_NONE) {
                        if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
                                media_content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path);
@@ -433,22 +468,27 @@ int media_info_insert_to_db(const char *path, media_info_h *info)
                                media_content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, repl_path);
                        }
 
-                       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+                       return _content_error_capi(ret);
                }
-       } else if (ret != MS_MEDIA_ERR_NONE) {
-               media_content_sec_error("media_svc_check_item_exist_by_path failed : %d (%s)", ret, repl_path);
-               return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+       } else {
+               media_content_sec_error("media_svc_get_modified_time failed : %d (%s)", ret, repl_path);
+               return _content_error_capi(ret);
        }
 
        media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
        media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
+#ifdef _USE_TVPD_MODE
        if (STRING_VALID(storage_id))
                ret = _media_info_get_media_info_from_db(repl_path, storage_id, (media_info_h)_media);
        else
                ret = _media_info_get_media_info_from_db(repl_path, DB_TABLE_MEDIA, (media_info_h)_media);
 
        *info = (media_info_h)_media;
+#else
+       ret = _media_info_get_media_info_from_db(repl_path, (media_info_h)_media);
+
+       *info = (media_info_h)_media;
+#endif
        return ret;
 }
 
@@ -483,12 +523,36 @@ int media_info_insert_batch_to_db(const char **path_array, unsigned int array_le
 
        return ret;
 }
+#ifdef _USE_TVPD_MODE
+int media_info_get_media_info_by_path_from_db(const char* path, media_info_h* media)
+{
+       char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
+       media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
+
+       memset(storage_id, 0x00, sizeof(storage_id));
+       ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, tzplatform_getuid(TZ_USER_NAME));
+       if (ret != MS_MEDIA_ERR_NONE) {
+               media_content_error("media_svc_get_storage_id failed : %d", ret);
+               return _content_error_capi(ret);
+       }
+
+       media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
+       media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+
+       ret =  _media_info_get_media_info_from_db(path, storage_id, (media_info_h)_media);
+       *media = (media_info_h)_media;
+
+       return ret;
+}
+#endif
 
 int media_info_delete_from_db(const char *media_id)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
        char *path = NULL;
-       char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
+       char *storage_id = NULL;
        media_content_warn("DEPRECATION WARNING: media_info_delete_from_db() is deprecated and will be removed from next release. Use media_content_scan_file() instead.");
 
        if (!STRING_VALID(media_id)) {
@@ -496,8 +560,6 @@ int media_info_delete_from_db(const char *media_id)
                return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
        }
 
-       memset(storage_id, 0x00, sizeof(storage_id));
-
        ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
                media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
@@ -505,7 +567,7 @@ int media_info_delete_from_db(const char *media_id)
                return ret;
        }
 
-       ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
+       ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
                media_content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
                SAFE_FREE(path);
@@ -514,8 +576,9 @@ int media_info_delete_from_db(const char *media_id)
 
        ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, _content_get_uid());
        SAFE_FREE(path);
+       SAFE_FREE(storage_id);
 
-       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+       return _content_error_capi(ret);
 }
 
 int media_info_destroy(media_info_h media)
@@ -544,14 +607,12 @@ int media_info_destroy(media_info_h media)
                SAFE_FREE(_media->image_meta->date_taken);
                SAFE_FREE(_media->image_meta->exposure_time);
                SAFE_FREE(_media->image_meta->model);
-               SAFE_FREE(_media->image_meta->title);
 
                SAFE_FREE(_media->image_meta);
        }
 
        if (_media->video_meta) {
                SAFE_FREE(_media->video_meta->media_id);
-               SAFE_FREE(_media->video_meta->title);
                SAFE_FREE(_media->video_meta->album);
                SAFE_FREE(_media->video_meta->artist);
                SAFE_FREE(_media->video_meta->album_artist);
@@ -567,7 +628,6 @@ int media_info_destroy(media_info_h media)
 
        if (_media->audio_meta) {
                SAFE_FREE(_media->audio_meta->media_id);
-               SAFE_FREE(_media->audio_meta->title);
                SAFE_FREE(_media->audio_meta->album);
                SAFE_FREE(_media->audio_meta->artist);
                SAFE_FREE(_media->audio_meta->album_artist);
@@ -708,10 +768,6 @@ int media_info_clone(media_info_h *dst, media_info_h src)
                        _dst->video_meta->media_id = g_strdup(_src->video_meta->media_id);
                        media_content_retv_free_info_if(_dst->video_meta->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
                }
-               if (_src->video_meta->title != NULL) {
-                       _dst->video_meta->title = g_strdup(_src->video_meta->title);
-                       media_content_retv_free_info_if(_dst->video_meta->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
                if (_src->video_meta->album != NULL) {
                        _dst->video_meta->album = g_strdup(_src->video_meta->album);
                        media_content_retv_free_info_if(_dst->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
@@ -763,10 +819,6 @@ int media_info_clone(media_info_h *dst, media_info_h src)
                        _dst->audio_meta->media_id = g_strdup(_src->audio_meta->media_id);
                        media_content_retv_free_info_if(_dst->audio_meta->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
                }
-               if (_src->audio_meta->title != NULL) {
-                       _dst->audio_meta->title = g_strdup(_src->audio_meta->title);
-                       media_content_retv_free_info_if(_dst->audio_meta->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
                if (_src->audio_meta->album != NULL) {
                        _dst->audio_meta->album = g_strdup(_src->audio_meta->album);
                        media_content_retv_free_info_if(_dst->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
@@ -946,7 +998,6 @@ int media_info_get_image(media_info_h media, image_meta_h *image)
        _image->fnumber = _media->image_meta->fnumber;
        _image->iso = _media->image_meta->iso;
        _image->date_taken = g_strdup(_media->image_meta->date_taken);
-       _image->title = g_strdup(_media->image_meta->title);
        _image->exposure_time = g_strdup(_media->image_meta->exposure_time);
        _image->model = g_strdup(_media->image_meta->model);
 
@@ -969,7 +1020,6 @@ int media_info_get_video(media_info_h media, video_meta_h *video)
        media_content_retvm_if(_video == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
 
        _video->media_id = g_strdup(_media->media_id);
-       _video->title = g_strdup(_media->video_meta->title);
        _video->album = g_strdup(_media->video_meta->album);
        _video->artist = g_strdup(_media->video_meta->artist);
        _video->album_artist = g_strdup(_media->video_meta->album_artist);
@@ -1005,7 +1055,6 @@ int media_info_get_audio(media_info_h media, audio_meta_h *audio)
        media_content_retvm_if(_audio == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
 
        _audio->media_id = g_strdup(_media->media_id);
-       _audio->title = g_strdup(_media->audio_meta->title);
        _audio->album = g_strdup(_media->audio_meta->album);
        _audio->artist = g_strdup(_media->audio_meta->artist);
        _audio->album_artist = g_strdup(_media->audio_meta->album_artist);
@@ -1497,15 +1546,13 @@ int media_info_delete_item(const char *media_id)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
        char *path = NULL;
-       char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
+       char *storage_id = NULL;
 
        if (!STRING_VALID(media_id)) {
                media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
                return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
        }
 
-       memset(storage_id, 0x00, sizeof(storage_id));
-
        ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
                media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
@@ -1513,7 +1560,7 @@ int media_info_delete_item(const char *media_id)
                return ret;
        }
 
-       ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
+       ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
                media_content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
                SAFE_FREE(path);
@@ -1521,6 +1568,7 @@ int media_info_delete_item(const char *media_id)
        }
 
        ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
+       SAFE_FREE(storage_id);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
                media_content_error("remove from DB failed : %d", ret);
                SAFE_FREE(path);
@@ -1529,7 +1577,7 @@ int media_info_delete_item(const char *media_id)
 
        ret = media_svc_remove_file(path);
        SAFE_FREE(path);
-       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+       return _content_error_capi(ret);
 }
 
 int media_info_get_contact(media_info_h media, char **contact)
@@ -1756,7 +1804,6 @@ int media_info_get_media_from_db(const char *media_id, media_info_h *media)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
        char select_query[DEFAULT_QUERY_SIZE] = {0, };
-       char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
        sqlite3_stmt *stmt = NULL;
 
        if (!STRING_VALID(media_id) || (media == NULL)) {
@@ -1765,14 +1812,18 @@ int media_info_get_media_from_db(const char *media_id, media_info_h *media)
        }
 
        memset(select_query, 0x00, sizeof(select_query));
-       memset(storage_id, 0x00, sizeof(storage_id));
 
-       ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
-       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+#ifdef _USE_TVPD_MODE
+       char *storage_id = NULL;
 
+       ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
        snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, storage_id, media_id);
-
-       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+       SAFE_FREE(storage_id);
+#else
+       snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id);
+#endif
+       ret = _content_get_result(select_query, &stmt);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        media_info_s *_media = NULL;
@@ -1830,31 +1881,34 @@ int media_info_update_to_db(media_info_h media)
                SQLITE3_SAFE_FREE(test_sql);
 
                /*Update Pinyin If Support Pinyin*/
+               char *file_name_pinyin = NULL;
                char *description_pinyin = NULL;
                bool pinyin_support = FALSE;
 
                /*Update Pinyin If Support Pinyin*/
                media_svc_check_pinyin_support(&pinyin_support);
                if (pinyin_support) {
+                       if (STRING_VALID(_media->display_name))
+                               media_svc_get_pinyin(_media->display_name, &file_name_pinyin);
                        if (STRING_VALID(_media->description))
                                media_svc_get_pinyin(_media->description, &description_pinyin);
                }
 #ifdef _USE_TVPD_MODE
 #ifdef _USE_SENIOR_MODE
                if (_media_content_is_support_senior_mode()) {
-                       set_sql = sqlite3_mprintf("description=%Q, longitude=%f, latitude=%f, description_pinyin=%Q, played_count=%d, last_played_time=%d, last_played_position=%d, favourite=%d, contact=%Q, app_data=%Q",
-                               _media->description, _media->longitude, _media->latitude, description_pinyin, _media->played_count, _media->played_time, _media->played_position, _media->favourite, _media->contact, _media->app_data);
+                       set_sql = sqlite3_mprintf("media_display_name=%Q, media_description=%Q, media_longitude=%f, media_latitude=%f, media_file_name_pinyin=%Q, media_description_pinyin=%Q, played_count=%d, last_played_time=%d, last_played_position=%d, media_rating=%d, media_favourite=%d, contact=%Q, app_data=%Q",
+                               _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->played_count, _media->played_time, _media->played_position, _media->rating, _media->favourite, _media->contact, _media->app_data);
                } else
 #endif
                {
-                       set_sql = sqlite3_mprintf("description=%Q, longitude=%f, latitude=%f, description_pinyin=%Q, played_count=%d, last_played_time=%d, last_played_position=%d, favourite=%d",
-                               _media->description, _media->longitude, _media->latitude, description_pinyin, _media->played_count, _media->played_time, _media->played_position, _media->favourite);
+                       set_sql = sqlite3_mprintf("media_display_name=%Q, media_description=%Q, media_longitude=%f, media_latitude=%f, media_file_name_pinyin=%Q, media_description_pinyin=%Q, played_count=%d, last_played_time=%d, last_played_position=%d, media_rating=%d, media_favourite=%d",
+                               _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->played_count, _media->played_time, _media->played_position, _media->rating, _media->favourite);
                }
 #else
-               set_sql = sqlite3_mprintf("description=%Q, longitude=%f, latitude=%f, description_pinyin=%Q, favourite=%d", _media->description, _media->longitude, _media->latitude, description_pinyin, _media->favourite);
+               set_sql = sqlite3_mprintf("media_display_name=%Q, media_description=%Q, media_longitude=%f, media_latitude=%f, media_file_name_pinyin=%Q, media_description_pinyin=%Q, media_rating=%d, media_favourite=%d", _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->rating, _media->favourite);
 #endif
 
-               sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_uuid=%Q", _media->storage_uuid, set_sql, _media->media_id);
+               sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_id=%Q", _media->storage_uuid, set_sql, _media->media_id);
 
                ret = _content_query_sql(sql);
                SQLITE3_SAFE_FREE(set_sql);
@@ -1866,7 +1920,7 @@ int media_info_update_to_db(media_info_h media)
                        /* Send notification for this update */
                        media_content_debug("Update is successfull. Send notification for this");
                        if (_media->file_path && _media->mime_type)
-                               media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
+                               media_svc_publish_noti(MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
                        else
                                media_content_error("Can't Send Noti : path or mime type is NULL");
                }
@@ -1881,37 +1935,32 @@ int media_info_update_to_db(media_info_h media)
 int media_info_move_to_db(media_info_h media, const char* dst_path)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
-       char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
        char repl_path[MAX_PATH_LEN] = {0, };
-       char org_repl_path[MAX_PATH_LEN] = {0, };
 
        media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
        media_content_retvm_if(!STRING_VALID(dst_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid dst_path");
        memset(repl_path, 0, sizeof(repl_path));
-       memset(org_repl_path, 0, sizeof(org_repl_path));
        ret = _media_content_replace_path(dst_path, repl_path);
        media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
 
        media_info_s *_media = (media_info_s*)media;
 
-       ret = _media_content_replace_path(_media->file_path, org_repl_path);
-       media_content_retvm_if(!STRING_VALID(org_repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+       /* If dst_path is folder, append file_name */
+       if (g_file_test(repl_path, G_FILE_TEST_IS_DIR)) {
+               if (repl_path[strlen(repl_path) - 1] != '/')
+                       SAFE_STRLCAT(repl_path, "/", sizeof(repl_path));
+
+               SAFE_STRLCAT(repl_path, _media->display_name, sizeof(repl_path));
+       }
 
        /* If the two paths are the same, do nothing */
-       media_content_retvm_if(g_strcmp0(repl_path, org_repl_path) == 0, MEDIA_CONTENT_ERROR_NONE, "Same path");
+       media_content_retvm_if(g_strcmp0(repl_path, _media->file_path) == 0, MEDIA_CONTENT_ERROR_NONE, "Same path");
 
        ret = __media_info_check_file_validity(repl_path);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
-       memset(storage_id, 0x00, sizeof(storage_id));
-       ret = media_svc_get_storage_id(_content_get_db_handle(), org_repl_path, storage_id, _content_get_uid());
-       if (ret != MS_MEDIA_ERR_NONE) {
-               media_content_error("media_svc_get_storage_id failed : %d", ret);
-               return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
-       }
-
-       ret = media_svc_move_item(_content_get_db_handle(), org_repl_path, repl_path, _content_get_uid());
-       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+       ret = media_svc_move_item(_content_get_db_handle(), _media->file_path, repl_path, _media->media_id, _media->media_type, _media->mime_type, _content_get_uid());
+       return _content_error_capi(ret);
 }
 
 int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
@@ -1919,14 +1968,9 @@ int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb
        int ret = MEDIA_CONTENT_ERROR_NONE;
        media_content_warn("DEPRECATION WARNING: media_info_create_thumbnail() is deprecated and will be removed from next release. Use media_info_generate_thumbnail() instead.");
        static unsigned int req_id = 0;
-       char repl_path[MAX_PATH_LEN] = {0, };
        media_info_s *_media = (media_info_s*)media;
 
        if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
-               memset(repl_path, 0, sizeof(repl_path));
-               ret = _media_content_replace_path(_media->file_path, repl_path);
-               media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
                media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
                media_content_retvm_if(_thumb_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
                req_id++;
@@ -1936,8 +1980,8 @@ int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb
                _thumb_cb->user_data = user_data;
                _thumb_cb->thumbnail_completed_cb = callback;
 
-               ret = thumbnail_request_from_db_async(_media->request_id, repl_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, _content_get_uid());
-               ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
+               ret = thumbnail_request_from_db_async(_media->request_id, _media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, _content_get_uid());
+               ret = _content_error_capi(ret);
        } else {
                media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
                ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
@@ -1949,7 +1993,6 @@ int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb
 int media_info_generate_thumbnail(media_info_h media)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
-       char repl_path[MAX_PATH_LEN] = {0, };
        char *thumb_path = NULL;
        media_info_s *_media = (media_info_s*)media;
 
@@ -1958,12 +2001,8 @@ int media_info_generate_thumbnail(media_info_h media)
                if (STRING_VALID(_media->thumbnail_path))
                        return MEDIA_CONTENT_ERROR_NONE;
 
-               memset(repl_path, 0, sizeof(repl_path));
-               ret = _media_content_replace_path(_media->file_path, repl_path);
-               media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
-               ret = media_svc_create_thumbnail(_media->storage_uuid, repl_path, _media->media_type, _content_get_uid(), &thumb_path);
-               ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
+               ret = media_svc_create_thumbnail(_media->storage_uuid, _media->file_path, _media->media_type, _content_get_uid(), &thumb_path);
+               ret = _content_error_capi(ret);
                if (ret == MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT) {
                        SAFE_FREE(thumb_path);
                        return ret;
@@ -1990,7 +2029,7 @@ int media_info_cancel_thumbnail(media_info_h media)
 
        if (_media != NULL && STRING_VALID(_media->media_id) && _media->request_id > 0) {
                ret = thumbnail_request_cancel_media(_media->request_id);
-               ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
+               ret = _content_error_capi(ret);
        } else {
                media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
                ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
@@ -2004,7 +2043,6 @@ int media_info_start_face_detection(media_info_h media, media_face_detection_com
        int ret = MEDIA_CONTENT_ERROR_NONE;
        static unsigned int req_id = 0;
        media_info_s *_media = (media_info_s*)media;
-       char repl_path[MAX_PATH_LEN] = {0, };
 
        if (!__media_info_isFaceRecognition_feature_supported()) {
                media_content_error("NOT_SUPPORTED(0x%08x)", MEDIA_CONTENT_ERROR_NOT_SUPPORTED);
@@ -2012,9 +2050,11 @@ int media_info_start_face_detection(media_info_h media, media_face_detection_com
        }
 
        if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
-               memset(repl_path, 0, sizeof(repl_path));
-               ret = _media_content_replace_path(_media->file_path, repl_path);
-               media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+               if (g_strcmp0(_media->mime_type, "image/jpeg") != 0 && g_strcmp0(_media->mime_type, "image/png") != 0 && g_strcmp0(_media->mime_type, "image/bmp") != 0) {
+                       media_content_error("Unsupported mime type");
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+
                media_face_cb_s *_face_cb = (media_face_cb_s*)calloc(1, sizeof(media_face_cb_s));
                media_content_retvm_if(_face_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
                req_id++;
@@ -2023,8 +2063,8 @@ int media_info_start_face_detection(media_info_h media, media_face_detection_com
                _face_cb->user_data = user_data;
                _face_cb->face_completed_cb = callback;
 
-               ret = dcm_request_extract_face_async(_media->face_request_id, repl_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, _content_get_uid());
-               ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
+               ret = dcm_request_extract_face_async(_media->face_request_id, _media->file_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, _content_get_uid());
+               ret = _content_error_capi(ret);
        } else {
                media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
                ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
@@ -2045,7 +2085,7 @@ int media_info_cancel_face_detection(media_info_h media)
 
        if (_media != NULL && STRING_VALID(_media->media_id) && _media->face_request_id > 0) {
                ret = dcm_request_cancel_face(_media->face_request_id);
-               ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
+               ret = _content_error_capi(ret);
        } else {
                media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
                ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
@@ -2125,3 +2165,39 @@ int media_info_set_rating(media_info_h media, int rating)
        return ret;
 }
 
+#ifdef TIZEN_FEATURE_COMPATIBILITY
+int media_info_set_added_time(media_info_h media, time_t added_time)
+{
+       media_content_warn("DEPRECATION WARNING: media_info_set_added_time() is removed from 5.5.");
+
+       return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_delete_batch_from_db(filter_h filter)
+{
+       media_content_warn("DEPRECATION WARNING: media_info_delete_batch_from_db() is removed from 5.5.");
+
+       return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_create(const char *path, media_info_h *media)
+{
+       media_content_warn("DEPRECATION WARNING: media_info_create() is removed from 5.5.");
+
+       return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_refresh_metadata_to_db(const char *media_id)
+{
+       media_content_warn("DEPRECATION WARNING: media_info_refresh_metadata_to_db() is removed from 5.5.");
+
+       return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_set_display_name(media_info_h media, const char *display_name)
+{
+       media_content_warn("DEPRECATION WARNING: media_info_set_display_name() is removed from 5.5.");
+
+       return MEDIA_CONTENT_ERROR_NONE;
+}
+#endif