ENDIF(TIZEN_PRODUCT_TV)
INCLUDE_DIRECTORIES(${INC_DIR})
-SET(dependents "dlog libmedia-service media-thumbnail libmedia-utils capi-base-common capi-system-info vconf cynara-client cynara-creds-socket cynara-session")
+SET(dependents "dlog libmedia-service media-thumbnail libmedia-utils capi-base-common capi-system-info vconf cynara-client cynara-creds-socket cynara-session storage")
SET(pc_dependents "dlog capi-base-common")
INCLUDE(FindPkgConfig)
int _media_util_check_ignore_file(const char *path, bool *ignore);
int _media_util_check_ignore_dir(const char *dir_path, bool *ignore);
int _media_content_replace_path(const char *path, char *replace_path);
+int _media_content_rollback_path(const char *path, char *replace_path);
int _media_util_check_ignore_file(const char *path, bool *ignore);
int _media_util_check_ignore_dir(const char *dir_path, bool *ignore);
int _media_content_replace_path(const char *path, char *replace_path);
+int _media_content_rollback_path(const char *path, char *replace_path);
#ifdef _USE_SENIOR_MODE
bool _media_content_is_support_senior_mode();
Name: capi-content-media-content
Summary: A Media content library in Tizen Native API
-Version: 0.2.82
+Version: 0.2.83
Release: 0
Group: Multimedia/API
License: Apache-2.0
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(cynara-client)
BuildRequires: pkgconfig(cynara-session)
+BuildRequires: pkgconfig(storage)
%description
A Media content library in Tizen Native API.
#include <media_info_private.h>
+#include <media_util_private.h>
int media_bookmark_insert_to_db(const char *media_id, time_t time, const char *thumbnail_path)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
char *sql = NULL;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
if (STRING_VALID(media_id)) {
- sql = sqlite3_mprintf(INSERT_BOOKMARK_TO_BOOKMARK, media_id, time, thumbnail_path);
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(thumbnail_path, repl_path);
+ sql = sqlite3_mprintf(INSERT_BOOKMARK_TO_BOOKMARK, media_id, time, repl_path);
ret = _content_query_sql(sql);
SQLITE3_SAFE_FREE(sql);
} else {
char *folder_path = NULL;
int check_file = MEDIA_CONTENT_ERROR_NONE;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
+ char repl_path[MAX_QUERY_SIZE] = {0,};
media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
media_content_sec_debug("Path : %s", path);
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(path, repl_path);
+ media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- ret = _media_util_check_ignore_file(path, &ignore_file);
+ ret = _media_util_check_ignore_file(repl_path, &ignore_file);
media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
memset(storage_id, 0x00, sizeof(storage_id));
- ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id);
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id);
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);
}
- check_file = _media_util_check_file_exist(path);
+ check_file = _media_util_check_file_exist(repl_path);
if (check_file == MEDIA_CONTENT_ERROR_NONE) {
/* This means this path has to be inserted or refreshed */
- folder_path = g_path_get_dirname(path);
+ folder_path = g_path_get_dirname(repl_path);
ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
SAFE_FREE(folder_path);
media_svc_storage_type_e storage_type;
- ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_type(repl_path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
if (ret != MS_MEDIA_ERR_NONE) {
- media_content_sec_error("media_svc_get_storage_type failed : %d (%s)", ret, path);
+ media_content_sec_error("media_svc_get_storage_type failed : %d (%s)", ret, repl_path);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
- ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, path);
+ ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, repl_path);
if (ret == MS_MEDIA_ERR_NONE) {
/* Refresh */
- ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_refresh_item failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
} else if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
/* Insert */
- ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
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)", path);
+ media_content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path);
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
+ media_content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, repl_path);
}
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
} else {
/* This means this path has to be deleted */
media_content_debug("This path doesn't exists in file system... So now start to delete it from DB");
- ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, repl_path, tzplatform_getuid(TZ_USER_NAME));
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_delete_item_by_path failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
int ret = MEDIA_CONTENT_ERROR_NONE;
bool ignore_dir = FALSE;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
+ char repl_path[MAX_QUERY_SIZE] = {0, };
media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(path, repl_path);
+ media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
/* Temporary Code [remove after inserted gid patch by security part] */
- if (strncmp(path, "/opt/media", strlen("/opt/media")) == 0) {
+ if (strncmp(repl_path, "/opt/media", strlen("/opt/media")) == 0) {
ret = __media_content_cynara_check("http://tizen.org/privilege/externalstorage");
media_content_retvm_if(ret == MEDIA_CONTENT_ERROR_PERMISSION_DENIED, ret, "Permission Denied");
} else {
memset(storage_id, 0x00, sizeof(storage_id));
- ret = __media_content_check_dir(path);
+ ret = __media_content_check_dir(repl_path);
media_content_retvm_if(ret == MEDIA_CONTENT_ERROR_PERMISSION_DENIED, ret, "Permission Denied");
if (ret == MEDIA_CONTENT_ERROR_NONE) {
/* If directory exist check that's ignore directory or not*/
- ret = _media_util_check_ignore_dir(path, &ignore_dir);
+ ret = _media_util_check_ignore_dir(repl_path, &ignore_dir);
media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
} else {
/* This means this folder has to be deleted */
cb_data->callback = callback;
cb_data->user_data = user_data;
- ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id);
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id);
/*FIX ME. need to check ret value?*/
- ret = media_directory_scanning_async(path, storage_id, is_recursive, _media_content_scan_cb, cb_data, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_directory_scanning_async(repl_path, storage_id, is_recursive, _media_content_scan_cb, cb_data, tzplatform_getuid(TZ_USER_NAME));
if (ret != MS_MEDIA_ERR_NONE)
media_content_error("media_directory_scanning_async failed : %d", ret);
int media_content_cancel_scan_folder(const char *path)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+
+ media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
+
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(path, repl_path);
+ media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- ret = media_directory_scanning_cancel(path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_directory_scanning_cancel(repl_path, tzplatform_getuid(TZ_USER_NAME));
if (ret != MS_MEDIA_ERR_NONE)
media_content_error("media_directory_scanning_async failed : %d", ret);
#include <media_content.h>
#include <media_info_private.h>
+#include <media_util_private.h>
static char * __media_db_get_group_name(media_group_e group);
static int __media_db_make_query(filter_h filter, attribute_h attr, char *select_query, int select_query_size, char **condition_query, char **option_query);
sqlite3_stmt *stmt = NULL;
attribute_h attr = NULL;
filter_s *_filter = (filter_s*)filter;
+ char *tmp_path = NULL;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
attr = _content_get_alias_attirbute_handle();
memset(select_query, 0x00, sizeof(select_query));
}
_folder->folder_id = g_strdup((const char *)sqlite3_column_text(stmt, 0));
+#ifdef _USE_TV_PROFILE
_folder->path = g_strdup((const char *)sqlite3_column_text(stmt, 1));
+#else
+ tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, 1));
+ _media_content_rollback_path(tmp_path, repl_path);
+ _folder->path = g_strdup(repl_path);
+ SAFE_FREE(tmp_path);
+#endif
_folder->name = g_strdup((const char *)sqlite3_column_text(stmt, 2));
_folder->storage_type = (int)sqlite3_column_int(stmt, 3);
_folder->modified_time = (int)sqlite3_column_int(stmt, 4);
char *option_query = NULL;
sqlite3_stmt *stmt = NULL;
attribute_h attr = NULL;
+ char *tmp_path = NULL;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
attr = _content_get_attirbute_handle();
memset(select_query, 0x00, sizeof(select_query));
_playlist->playlist_id = (int)sqlite3_column_int(stmt, 0);
_playlist->name = g_strdup((const char *)sqlite3_column_text(stmt, 1));
+#ifdef _USE_TV_PROFILE
_playlist->thumbnail_path = g_strdup((const char *)sqlite3_column_text(stmt, 2));
+#else
+ tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, 2));
+ if (STRING_VALID(tmp_path)) {
+ _media_content_rollback_path(tmp_path, repl_path);
+ _playlist->thumbnail_path = g_strdup(repl_path);
+ SAFE_FREE(tmp_path);
+ } else {
+ _playlist->thumbnail_path = NULL;
+ }
+#endif
if (callback((media_playlist_h)_playlist, user_data) == false) {
media_playlist_destroy((media_playlist_h)_playlist);
int ret = MEDIA_CONTENT_ERROR_NONE;
sqlite3_stmt *stmt = NULL;
char select_query[DEFAULT_QUERY_SIZE];
+ char *tmp_path = NULL;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
if (!STRING_VALID(folder_id)) {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
media_content_error("folder handle %x", _folder);
_folder->folder_id = g_strdup((const char *)sqlite3_column_text(stmt, 0));
+#ifdef _USE_TV_PROFILE
_folder->path = g_strdup((const char *)sqlite3_column_text(stmt, 1));
+#else
+ tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, 1));
+ _media_content_rollback_path(tmp_path, repl_path);
+ _folder->path = g_strdup(repl_path);
+ SAFE_FREE(tmp_path);
+#endif
+
_folder->name = g_strdup((const char *)sqlite3_column_text(stmt, 2));
_folder->modified_time = (int)sqlite3_column_int(stmt, 3);
_folder->storage_type = (int)sqlite3_column_int(stmt, 5);
int ret = MEDIA_CONTENT_ERROR_NONE;
media_folder_s *_folder = (media_folder_s*)folder;
char *sql = NULL;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
if ((_folder == NULL) || (_folder->folder_id == NULL)) {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
char *name_pinyin = NULL;
bool pinyin_support = FALSE;
+ ret = _media_content_replace_path(_folder->path, repl_path);
+
/* Set modified time */
time_t date;
time(&date);
media_svc_get_pinyin(_folder->name, &name_pinyin);
sql = sqlite3_mprintf("UPDATE %Q SET path='%q', name='%q', modified_time=%d, name_pinyin='%q' WHERE folder_uuid=%Q",
- DB_TABLE_FOLDER, _folder->path, _folder->name, _folder->modified_time, name_pinyin, _folder->folder_id);
+ DB_TABLE_FOLDER, repl_path, _folder->name, _folder->modified_time, name_pinyin, _folder->folder_id);
ret = _content_query_sql(sql);
SQLITE3_SAFE_FREE(sql);
char dst_path_slash[MAX_QUERY_SIZE + 1] = {0, };
snprintf(src_path_slash, sizeof(src_path_slash), "%s/", g_src_path);
- snprintf(dst_path_slash, sizeof(dst_path_slash), "%s/", _folder->path);
+ snprintf(dst_path_slash, sizeof(dst_path_slash), "%s/", repl_path);
update_folder_path_sql = sqlite3_mprintf("UPDATE folder SET path = REPLACE( path, '%q', '%q');", src_path_slash, dst_path_slash);
return ret;
}
- ret = media_svc_rename_folder(_content_get_db_handle(), _folder->storage_uuid, g_src_path, _folder->path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_rename_folder(_content_get_db_handle(), _folder->storage_uuid, g_src_path, repl_path, tzplatform_getuid(TZ_USER_NAME));
SAFE_FREE(g_src_path);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
char *folder_path = NULL;
char new_folder_path[MAX_QUERY_SIZE] = {0,};
bool ignore_dir = FALSE;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(_folder->path, repl_path);
+ media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- folder_path = g_path_get_dirname(_folder->path);
- media_content_sec_debug("Existed Folder Path : %s", _folder->path);
+ folder_path = g_path_get_dirname(repl_path);
+ media_content_sec_debug("Existed Folder Path : %s", repl_path);
snprintf(new_folder_path, sizeof(new_folder_path), "%s/%s", folder_path, name);
media_content_sec_debug("New Path : %s", new_folder_path);
}
SAFE_FREE(g_src_path);
- g_src_path = strdup(_folder->path);
+ g_src_path = strdup(repl_path);
SAFE_FREE(_folder->path);
SAFE_FREE(_folder->name);
SAFE_FREE(folder_path);
- _folder->path = strdup(new_folder_path);
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_rollback_path(new_folder_path, repl_path);
+ media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+
+ _folder->path = strdup(repl_path);
media_content_retvm_if(_folder->path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
}
void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
{
media_info_s *_media = (media_info_s*)media;
+ char *tmp_path = NULL;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
_media->media_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID));
+#ifdef _USE_TV_PROFILE
_media->file_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH));
+#else
+ tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH));
+ _media_content_rollback_path(tmp_path, repl_path);
+ _media->file_path = g_strdup(repl_path);
+ SAFE_FREE(tmp_path);
+#endif
_media->display_name = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME));
_media->media_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_TYPE);
_media->mime_type = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MIME_TYPE));
bool ignore_dir = FALSE;
char *folder_path = NULL;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
+ char repl_path[MAX_QUERY_SIZE] = {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(info == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(path, repl_path);
+ media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- ret = _media_util_check_ignore_file(path, &ignore_file);
+ ret = _media_util_check_ignore_file(repl_path, &ignore_file);
media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
- ret = _media_util_check_file_exist(path);
+ ret = _media_util_check_file_exist(repl_path);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- folder_path = g_path_get_dirname(path);
+ folder_path = g_path_get_dirname(repl_path);
ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
SAFE_FREE(folder_path);
media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
memset(storage_id, 0x00, sizeof(storage_id));
- ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id);
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id);
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_check_item_exist_by_path(_content_get_db_handle(), storage_id, path);
+ ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, repl_path);
if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
- media_content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", path);
+ media_content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", repl_path);
media_svc_storage_type_e storage_type = 0;
- ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_type(repl_path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
if (ret != MS_MEDIA_ERR_NONE) {
media_content_sec_error("media_svc_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, path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
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)", path);
+ media_content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path);
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
+ media_content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, repl_path);
}
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
} else if (ret != MS_MEDIA_ERR_NONE) {
- media_content_sec_error("media_svc_check_item_exist_by_path failed : %d (%s)", ret, path);
+ 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);
}
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, DEFAULT_MEDIA_STORAGE_ID, (media_info_h)_media);
+ ret = _media_info_get_media_info_from_db(repl_path, DEFAULT_MEDIA_STORAGE_ID, (media_info_h)_media);
*info = (media_info_h)_media;
return ret;
media_insert_completed_cb completed_cb,
void *user_data)
{
+ char **repl_path_array = NULL;
+ int idx = 0;
+ int ret = MS_MEDIA_ERR_NONE;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+
media_content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
media_content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
- return __media_info_insert_batch(MEDIA_BATCH_INSERT_NORMAL, path_array, array_length, completed_cb, user_data);
+ repl_path_array = calloc(1, sizeof(char *) * array_length);
+
+ for (idx = 0; idx < array_length; idx++) {
+ if (STRING_VALID(path_array[idx])) {
+ memset(repl_path, 0, sizeof(repl_path));
+ _media_content_replace_path(path_array[idx], repl_path);
+ repl_path_array[idx] = strndup(repl_path, strlen(repl_path));
+ } else {
+ media_content_error("path[%d] is invalid string", idx);
+ }
+ }
+
+ ret = __media_info_insert_batch(MEDIA_BATCH_INSERT_NORMAL, (const char **)repl_path_array, array_length, completed_cb, user_data);
+ for (idx = 0; idx < array_length; idx++)
+ SAFE_FREE(repl_path_array[idx]);
+
+ SAFE_FREE(repl_path_array);
+
+ return ret;
}
int media_info_insert_burst_shot_to_db(const char **path_array, unsigned int array_length, media_insert_burst_shot_completed_cb callback, void *user_data)
{
+ char **repl_path_array = NULL;
+ int idx = 0;
+ int ret = MS_MEDIA_ERR_NONE;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+
media_content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
media_content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
- return __media_info_insert_batch(MEDIA_BATCH_INSERT_BURSTSHOT, path_array, array_length, callback, user_data);
+ repl_path_array = calloc(1, sizeof(char *) * array_length);
+
+ for (idx = 0; idx < array_length; idx++) {
+ if (STRING_VALID(path_array[idx])) {
+ memset(repl_path, 0, sizeof(repl_path));
+ _media_content_replace_path(path_array[idx], repl_path);
+ repl_path_array[idx] = strndup(repl_path, strlen(repl_path));
+ } else {
+ media_content_error("path[%d] is invalid string", idx);
+ }
+ }
+
+ ret = __media_info_insert_batch(MEDIA_BATCH_INSERT_BURSTSHOT, (const char **)repl_path_array, array_length, callback, user_data);
+ for (idx = 0; idx < array_length; idx++)
+ SAFE_FREE(repl_path_array[idx]);
+
+ SAFE_FREE(repl_path_array);
+
+ return ret;
}
#ifdef _USE_SENIOR_MODE
char *file_path = NULL;
media_content_storage_e storage_type = 0;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
+ char repl_path[MAX_QUERY_SIZE] = {0, };
if (!STRING_VALID(media_id)) {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
media_info_destroy(media);
return ret;
}
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(file_path, repl_path);
- ret = _media_util_check_file_exist(file_path);
+ ret = _media_util_check_file_exist(repl_path);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
SAFE_FREE(file_path);
media_info_destroy(media);
}
memset(storage_id, 0x00, sizeof(storage_id));
- ret = media_svc_get_storage_id(_content_get_db_handle(), file_path, storage_id);
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id);
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_get_storage_id failed : %d", ret);
SAFE_FREE(file_path);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
- ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, file_path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
if (ret != MS_MEDIA_ERR_NONE)
ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
media_svc_storage_type_e src_storage_type = 0;
media_svc_storage_type_e dst_storage_type = 0;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+ char org_repl_path[MAX_QUERY_SIZE] = {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_util_check_ignore_file(dst_path, &ignore_file);
+ ret = _media_util_check_ignore_file(repl_path, &ignore_file);
media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
+ 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");
- ret = _media_util_check_file_exist(dst_path);
+ ret = _media_util_check_file_exist(repl_path);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- folder_path = g_path_get_dirname(dst_path);
+ folder_path = g_path_get_dirname(repl_path);
ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
SAFE_FREE(folder_path);
media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
- ret = media_svc_get_storage_type(_media->file_path, &src_storage_type, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_type(org_repl_path, &src_storage_type, tzplatform_getuid(TZ_USER_NAME));
if (ret != MS_MEDIA_ERR_NONE) {
media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
- ret = media_svc_get_storage_type(dst_path, &dst_storage_type, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_type(repl_path, &dst_storage_type, tzplatform_getuid(TZ_USER_NAME));
if (ret != MS_MEDIA_ERR_NONE) {
media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
memset(storage_id, 0x00, sizeof(storage_id));
- ret = media_svc_get_storage_id(_content_get_db_handle(), _media->file_path, storage_id);
+ ret = media_svc_get_storage_id(_content_get_db_handle(), org_repl_path, storage_id);
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(), storage_id, src_storage_type, _media->file_path, dst_storage_type, dst_path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_move_item(_content_get_db_handle(), storage_id, src_storage_type, org_repl_path, dst_storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
static unsigned int req_id = 0;
+ char repl_path[MAX_QUERY_SIZE] = {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++;
_thumb_cb->user_data = user_data;
_thumb_cb->thumbnail_completed_cb = callback;
- ret = thumbnail_request_from_db_async(_media->request_id, _media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, tzplatform_getuid(TZ_USER_NAME));
+ ret = thumbnail_request_from_db_async(_media->request_id, repl_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, tzplatform_getuid(TZ_USER_NAME));
ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
} else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path) && _media->request_id > 0) {
- ret = thumbnail_request_cancel_media(_media->request_id, _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");
+
+ ret = thumbnail_request_cancel_media(_media->request_id, repl_path);
ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
} else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
int ret = MEDIA_CONTENT_ERROR_NONE;
static unsigned int req_id = 0;
media_info_s *_media = (media_info_s*)media;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
if (!__media_info_isFaceRecognition_feature_supported()) {
media_content_error("NOT_SUPPORTED(0x%08x)", MEDIA_CONTENT_ERROR_NOT_SUPPORTED);
}
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_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++;
_face_cb->user_data = user_data;
_face_cb->face_completed_cb = callback;
- ret = dcm_request_extract_face_async(_media->face_request_id, _media->file_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, tzplatform_getuid(TZ_USER_NAME));
+ ret = dcm_request_extract_face_async(_media->face_request_id, repl_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, tzplatform_getuid(TZ_USER_NAME));
ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
} else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
if (!__media_info_isFaceRecognition_feature_supported()) {
media_content_error("NOT_SUPPORTED(0x%08x)", MEDIA_CONTENT_ERROR_NOT_SUPPORTED);
}
if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path) && _media->face_request_id > 0) {
- ret = dcm_request_cancel_face(_media->face_request_id, _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");
+ ret = dcm_request_cancel_face(_media->face_request_id, repl_path);
ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
} else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
static int __media_info_map_data_usr_to_svc(media_info_s *media, media_svc_content_info_s **service_content, media_content_storage_e storage_type)
{
media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+ char *tmp_path = NULL;
media_svc_content_info_s *svc_content_info = calloc(1, sizeof(media_svc_content_info_s));
media_content_retvm_if(svc_content_info == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ memset(repl_path, 0, sizeof(repl_path));
+#ifdef _USE_TV_PROFILE
svc_content_info->path = g_strdup(media->file_path);
+#else
+ tmp_path = g_strdup(media->file_path);
+ _media_content_replace_path(tmp_path, repl_path);
+ svc_content_info->path = g_strdup(repl_path);
+ SAFE_FREE(tmp_path);
+#endif
svc_content_info->file_name = g_strdup(media->display_name);
svc_content_info->media_type = media->media_type;
svc_content_info->mime_type = g_strdup(media->mime_type);
int media_info_insert_to_db_with_data(media_info_h media)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
media_info_s *_media = (media_info_s*)media;
SAFE_FREE(svc_content_info);
/*Fill out the handle*/
- char *media_file_path = g_strdup(_media->file_path);
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(_media->file_path, repl_path);
+ char *media_file_path = g_strdup(repl_path);
+
char *media_string_uuid = g_strdup(_media->storage_uuid);
__media_info_destroy(media);
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
media_svc_storage_type_e storage_type = 0;
bool ignore_file = FALSE;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
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 media");
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(path, repl_path);
+ media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- ret = _media_util_check_ignore_file(path, &ignore_file);
+ ret = _media_util_check_ignore_file(repl_path, &ignore_file);
media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
memset(storage_id, 0x00, sizeof(storage_id));
- if (STRING_VALID(MEDIA_ROOT_PATH_CLOUD) && (strstr(path, MEDIA_ROOT_PATH_CLOUD) == NULL)) {
+ if (STRING_VALID(MEDIA_ROOT_PATH_CLOUD) && (strstr(repl_path, MEDIA_ROOT_PATH_CLOUD) == NULL)) {
bool ignore_dir = FALSE;
char *folder_path = NULL;
- ret = _media_util_check_file_exist(path);
+ ret = _media_util_check_file_exist(repl_path);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- folder_path = g_path_get_dirname(path);
+ folder_path = g_path_get_dirname(repl_path);
ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
SAFE_FREE(folder_path);
media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
- ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id);
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id);
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_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_type(repl_path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
if (ret != MS_MEDIA_ERR_NONE) {
media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
#include <media_info.h>
#include <media_info_private.h>
#include <media_playlist.h>
+#include <media_util_private.h>
+
#define PLAYLIST_ARRAY_SIZE 20
#define PLAYLIST_ARRAY_EXPAND 10
char *buf = NULL;
char *tmp_buf = NULL;
char *tmp_str = NULL;
+ char repl_item[MAX_QUERY_SIZE] = {0, };
FILE *fp = NULL;
long int file_size = 0;
break;
}
- tmp_str_len = strlen(tmp_str);
+ memset(repl_item, 0, sizeof(repl_item));
+ _media_content_replace_path(tmp_str, repl_item);
+ tmp_str_len = strlen(repl_item);
+ SAFE_FREE(tmp_str);
+ tmp_str = strndup(repl_item, tmp_str_len);
if (tmp_str[0] != '#') {
if (!(current_index < (current_max_size - 1))) {
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_playlist_s *_playlist = (media_playlist_s*)playlist;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
if (_playlist != NULL && STRING_VALID(path)) {
SAFE_FREE(_playlist->thumbnail_path);
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(path, repl_path);
+ media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+
media_playlist_item_s *item = (media_playlist_item_s*)calloc(1, sizeof(media_playlist_item_s));
media_content_retvm_if(item == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- item->thumbnail_path = strdup(path);
+ item->thumbnail_path = strdup(repl_path);
item->function = MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH;
if (item->thumbnail_path == NULL) {
SAFE_FREE(item);
char** import_item_list = NULL;
int import_item_count = 0;
int idx;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
media_content_retvm_if(!STRING_VALID(playlist_name), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid playlist_name");
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(path, repl_path);
+ media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
ret = media_playlist_insert_to_db(playlist_name, playlist);
media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_playlist_insert_to_db fail");
- ret = __media_playlist_import_item_from_file(path, &import_item_list, &import_item_count);
+ ret = __media_playlist_import_item_from_file(repl_path, &import_item_list, &import_item_count);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
__media_playlist_destroy_import_item(import_item_list, import_item_count);
media_content_error("Fail to get playlist from file");
media_playlist_s *_playlist = (media_playlist_s*)playlist;
GList *item_list = NULL;
unsigned int idx = 0;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+ char repl_item[MAX_QUERY_SIZE] = {0, };
media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
media_content_retvm_if(_playlist == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid playlist");
media_content_retvm_if(_playlist->playlist_id <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid playlist_id");
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(path, repl_path);
+ media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
ret = _media_db_get_playlist_item(_playlist->playlist_id, NULL, __media_playlist_member_cb, &item_list);
media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "_media_db_get_playlist_item fail");
- ret = __media_playlist_reset_file(path);
+ ret = __media_playlist_reset_file(repl_path);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
g_list_free_full(item_list, __media_playlist_destroy_export_item);
media_content_error("Fail to init playlist file");
for (idx = 0; idx < g_list_length(item_list); idx++) {
char *item = g_list_nth_data(item_list, idx);
- ret = __media_playlist_append_to_file(path, item);
+ memset(repl_item, 0, sizeof(repl_item));
+ ret = _media_content_rollback_path(item, repl_item);
+
+ ret = __media_playlist_append_to_file(repl_path, repl_item);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
g_list_free_full(item_list, __media_playlist_destroy_export_item);
media_content_error("Fail to export paths into file");
#include <media_util_private.h>
#include <media_info_private.h>
#include <media_content_type.h>
+#include <storage.h>
#ifdef _USE_TV_PROFILE
#include <system_info.h>
#endif
int _media_content_replace_path(const char *path, char *replace_path)
{
- const char *old_path = "/opt/usr/media";
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char *old_path = NULL;
+
+ ret = storage_get_root_directory(STORAGE_TYPE_INTERNAL, &old_path);
+ if (ret != STORAGE_ERROR_NONE) {
+ media_content_error("storage_get_directory failed");
+ return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+ }
if (strncmp(path, old_path, strlen(old_path)) == 0) {
media_content_sec_debug("Old path[%s]", path);
snprintf(replace_path, MAX_QUERY_SIZE, "%s", path);
}
+ SAFE_FREE(old_path);
+
+ if (!STRING_VALID(replace_path)) {
+ media_content_error("replace failed");
+ return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+ }
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int _media_content_rollback_path(const char *path, char *replace_path)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char *old_path = NULL;
+
+ ret = storage_get_root_directory(STORAGE_TYPE_INTERNAL, &old_path);
+ if (ret != STORAGE_ERROR_NONE) {
+ media_content_error("storage_get_directory failed");
+ return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+ }
+
+ if (strncmp(path, tzplatform_getenv(TZ_USER_CONTENT), strlen(tzplatform_getenv(TZ_USER_CONTENT))) == 0) {
+ media_content_sec_debug("new path[%s]", path);
+ snprintf(replace_path, MAX_QUERY_SIZE, "%s%s", old_path, path + strlen(tzplatform_getenv(TZ_USER_CONTENT)));
+ } else {
+ snprintf(replace_path, MAX_QUERY_SIZE, "%s", path);
+ }
+
+ SAFE_FREE(old_path);
+
if (!STRING_VALID(replace_path)) {
media_content_error("replace failed");
return MEDIA_CONTENT_ERROR_INVALID_OPERATION;