Restore media_info_delete_from_db to product API 77/288877/2 accepted/tizen/unified/20230306.081555
authorminje.ahn <minje.ahn@samsung.com>
Fri, 24 Feb 2023 04:11:33 +0000 (13:11 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Sun, 26 Feb 2023 07:23:29 +0000 (07:23 +0000)
A long-deprecated public API was recently removed, but since the product module prv-service is still required, it has been restored and moved into the product header.

Change-Id: If26b36dca847063612fd66dfc2f2ac639f652909
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
include_product/media_content_product.h
src/media_info.c

index 47a30fe..c3f0b2b 100755 (executable)
@@ -32,6 +32,8 @@ int media_content_scan_folder_v2(const char *path, bool is_recursive, media_scan
 
 /********** media_info **********/
 
+int media_info_delete_from_db(const char *media_id);
+
 /**
  * @brief Gets the extract_flag of media info.
  * @since_tizen 2.3
index 06634d0..f9084ab 100644 (file)
@@ -454,6 +454,62 @@ int media_info_get_media_info_by_path_from_db(const char* path, media_info_h* me
 
        return ret;
 }
+
+static int __media_info_get_media_path_by_id_from_db(const char *media_id, char **path)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       char *select_query = NULL;
+
+       content_retip_if_fail(STRING_VALID(media_id));
+
+       select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
+
+       ret = _content_get_result(select_query, &stmt);
+       SQLITE3_SAFE_FREE(select_query);
+       content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       if (sqlite3_step(stmt) == SQLITE_ROW) {
+               *path = g_strdup((const char *)sqlite3_column_text(stmt, 0));
+       } else {
+               content_error("There's no media with this ID : %s", media_id);
+               *path = NULL;
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int media_info_delete_from_db(const char *media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *path = NULL;
+       char *storage_id = NULL;
+
+       content_retip_if_fail(STRING_VALID(media_id));
+
+       ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
+       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+               content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
+               g_free(path);
+               return ret;
+       }
+
+       ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
+       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+               content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
+               g_free(path);
+               return ret;
+       }
+
+       ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, _content_get_uid());
+       g_free(path);
+       g_free(storage_id);
+
+       return _content_error_capi(ret);
+}
 #endif
 
 int media_info_destroy(media_info_h media)