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 6bdb93b..994e253
@@ -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;
@@ -388,6 +385,34 @@ 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)
 {
@@ -452,14 +477,18 @@ int media_info_insert_to_db(const char *path, media_info_h *info)
 
        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;
 }
 
@@ -578,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);
@@ -601,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);
@@ -742,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);
@@ -797,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);
@@ -980,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);
 
@@ -1003,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);
@@ -1039,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);
@@ -1789,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 = NULL;
        sqlite3_stmt *stmt = NULL;
 
        if (!STRING_VALID(media_id) || (media == NULL)) {
@@ -1799,12 +1813,17 @@ int media_info_get_media_from_db(const char *media_id, media_info_h *media)
 
        memset(select_query, 0x00, sizeof(select_query));
 
+#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_get_result(select_query, &stmt);
        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;
@@ -1916,22 +1935,16 @@ 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] != '/')
@@ -1941,19 +1954,12 @@ int media_info_move_to_db(media_info_h media, const char* dst_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(ret);
-       }
-
-       ret = media_svc_move_item(_content_get_db_handle(), org_repl_path, repl_path, _media->media_id, _media->media_type, _media->mime_type, _content_get_uid());
+       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);
 }
 
@@ -1962,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++;
@@ -1979,7 +1980,7 @@ 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 = 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);
@@ -1992,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;
 
@@ -2001,11 +2001,7 @@ 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 = 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);
@@ -2047,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);
@@ -2060,9 +2055,6 @@ int media_info_start_face_detection(media_info_h media, media_face_detection_com
                        return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
                }
 
-               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_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++;
@@ -2071,7 +2063,7 @@ 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 = 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);
@@ -2173,22 +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.");
 
-int media_info_set_display_name(media_info_h media, const char *display_name)
+       return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_delete_batch_from_db(filter_h filter)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
-       media_content_warn("DEPRECATION WARNING: media_info_set_display_name() is deprecated and will be removed from next release.");
-       media_info_s *_media = (media_info_s*)media;
+       media_content_warn("DEPRECATION WARNING: media_info_delete_batch_from_db() is removed from 5.5.");
 
-       if (_media != NULL && STRING_VALID(display_name)) {
-               SAFE_FREE(_media->display_name);
+       return MEDIA_CONTENT_ERROR_NONE;
+}
 
-               _media->display_name = strdup(display_name);
-               media_content_retvm_if(_media->display_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-       } else {
-               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+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 ret;
+       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