Removed the function that replaces path '/opt/usr/media' with path '/opt/usr/home/owner/media'.
Only some old mobile apps used this hard-coded value.
Change-Id: I4cf1cb318c4a6e82153ae434bf0a59ab5af2e0ce
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
bool _media_util_is_ignorable_file(const char *path);
bool _media_util_is_ignorable_dir(const char *dir_path);
int _media_content_check_dir(const char *path);
-char * _media_content_replace_path_in_condition(const char *condition);
-int _media_content_replace_path(const char *path, char *replace_path);
-
-
#ifdef __cplusplus
}
bool _media_util_is_ignorable_file(const char *path);
bool _media_util_is_ignorable_dir(const char *dir_path);
int _media_content_check_dir(const char *path);
-char * _media_content_replace_path_in_condition(const char *condition);
-int _media_content_replace_path(const char *path, char *replace_path);
#ifdef __cplusplus
}
Name: capi-content-media-content
Summary: A Media content library in Tizen Native API
-Version: 0.4.15
+Version: 0.4.16
Release: 0
Group: Multimedia/API
License: Apache-2.0
char *folder_path = NULL;
int check_file = MEDIA_CONTENT_ERROR_NONE;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
- char repl_path[MAX_PATH_LEN] = {0,};
content_retip_if_fail(STRING_VALID(path));
content_sec_debug("Path : %s", path);
- ret = _media_content_replace_path(path, repl_path);
- content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+ content_retvm_if(_media_util_is_ignorable_file(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
- content_retvm_if(_media_util_is_ignorable_file(repl_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
-
- ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
+ ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
content_error("media_svc_get_storage_id failed : %d", ret);
return _content_error_capi(ret);
}
- check_file = _media_util_check_file_exist(repl_path);
+ check_file = _media_util_check_file_exist(path);
if (check_file == MEDIA_CONTENT_ERROR_NONE) {
/* This means this path has to be inserted or refreshed */
- folder_path = g_path_get_dirname(repl_path);
+ folder_path = g_path_get_dirname(path);
if (_media_util_is_ignorable_dir(folder_path)) {
g_free(folder_path);
g_free(folder_path);
/* check feature */
- content_retvm_if(!_media_util_check_support_media_type(repl_path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
+ content_retvm_if(!_media_util_check_support_media_type(path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
ms_user_storage_type_e storage_type;
- ret = ms_user_get_storage_type(_content_get_uid(), repl_path, &storage_type);
+ ret = ms_user_get_storage_type(_content_get_uid(), path, &storage_type);
if (ret != MS_MEDIA_ERR_NONE) {
- content_sec_error("ms_user_get_storage_type failed : %d (%s)", ret, repl_path);
+ content_sec_error("ms_user_get_storage_type failed : %d (%s)", ret, path);
return _content_error_capi(ret);
}
- ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, repl_path);
+ ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, path);
if (ret == MS_MEDIA_ERR_NONE) {
/* Refresh */
- ret = media_svc_refresh_item(_content_get_db_handle(), false, storage_id, storage_type, repl_path, _content_get_uid());
+ ret = media_svc_refresh_item(_content_get_db_handle(), false, storage_id, storage_type, path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
content_error("media_svc_refresh_item failed : %d", ret);
return _content_error_capi(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, repl_path, _content_get_uid());
+ ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
- content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path);
+ content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", path);
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, repl_path);
+ content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
}
return _content_error_capi(ret);
} else {
/* This means this path has to be deleted */
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, repl_path, _content_get_uid());
+ ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
content_error("Does not exist in media DB also... So, this is an invalid parameter");
{
int ret = MEDIA_CONTENT_ERROR_NONE;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
- char repl_path[MAX_PATH_LEN] = {0, };
ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
content_retip_if_fail(STRING_VALID(path));
content_retip_if_fail(callback);
- ret = _media_content_replace_path(path, repl_path);
- content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
- ret = _media_content_check_dir(repl_path);
+ ret = _media_content_check_dir(path);
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*/
- content_retvm_if(_media_util_is_ignorable_dir(repl_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+ content_retvm_if(_media_util_is_ignorable_dir(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
} else {
/* This means this folder has to be deleted */
/* Or, it is real invalid path.. check storage type */
- ret = ms_user_get_storage_type(_content_get_uid(), repl_path, &storage_type);
+ ret = ms_user_get_storage_type(_content_get_uid(), path, &storage_type);
if (ret != MS_MEDIA_ERR_NONE) {
- content_sec_error("ms_user_get_storage_type failed : %d (%s)", ret, repl_path);
+ content_sec_error("ms_user_get_storage_type failed : %d (%s)", ret, path);
return _content_error_capi(ret);
}
content_debug("This path doesn't exists in file system... So will be deleted it from DB");
}
- ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
+ ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
content_error("media_svc_get_storage_id failed : %d", ret);
return _content_error_capi(ret);
cb_data->callback = callback;
cb_data->user_data = user_data;
- ret = media_directory_scanning_async(repl_path, storage_id, is_recursive, _media_content_scan_cb, cb_data, _content_get_uid());
+ ret = media_directory_scanning_async(path, storage_id, is_recursive, _media_content_scan_cb, cb_data, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
content_error("media_directory_scanning_async failed : %d", ret);
g_free(cb_data);
int media_content_cancel_scan_folder(const char *path)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- char repl_path[MAX_PATH_LEN] = {0, };
content_retip_if_fail(STRING_VALID(path));
- ret = _media_content_replace_path(path, repl_path);
- content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
- ret = media_directory_scanning_cancel(repl_path, _content_get_uid());
+ ret = media_directory_scanning_cancel(path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE)
content_error("media_directory_scanning_async failed : %d", ret);
_filter->is_full_condition = false;
g_free(_filter->condition);
- _filter->condition = _media_content_replace_path_in_condition(condition);
-
- /* FIXME
- If an error is occured in _media_content_replace_path_in_condition(),
- A suitable return value is 'MEDIA_CONTENT_ERROR_INVALID_OPERATION'.
- However, it is not stated in the description of media_filter_set_condition().
- Therefore, use 'MEDIA_CONTENT_ERROR_OUT_OF_MEMORY' temporarily.
- It will be modified after removing _media_content_replace_path_in_condition() function.
- */
- content_retvm_if(_filter->condition == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "Fail to set condition");
+ _filter->condition = g_strdup(condition);
content_sec_debug("Condition string : %s", _filter->condition);
g_free(_filter->condition);
- /* FIXME
- If an error is occured in _media_content_replace_path_in_condition(),
- A suitable return value is 'MEDIA_CONTENT_ERROR_INVALID_OPERATION'.
- However, it is not stated in the description of media_filter_set_condition().
- Therefore, use 'MEDIA_CONTENT_ERROR_OUT_OF_MEMORY' temporarily.
- It will be modified after removing _media_content_replace_path_in_condition() function.
- */
- _filter->condition = _media_content_replace_path_in_condition(condition);
- content_retvm_if(_filter->condition == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "Fail to set condition");
+ _filter->condition = g_strdup(condition);
content_sec_debug("Condition string : %s", _filter->condition);
int ret = MEDIA_CONTENT_ERROR_NONE;
content_warn("DEPRECATION WARNING: media_folder_update_to_db() is deprecated and will be removed from next release.");
media_folder_s *_folder = (media_folder_s*)folder;
- char repl_path[MAX_PATH_LEN] = {0, };
content_retip_if_fail(folder);
content_retip_if_fail(STRING_VALID(_folder->folder_id));
if (!g_src_path)
return ret;
-
- ret = _media_content_replace_path(_folder->path, repl_path);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- SAFE_FREE(g_src_path);
- return ret;
- }
- ret = media_svc_rename_folder(_content_get_db_handle(), _folder->storage_uuid, g_src_path, repl_path, _content_get_uid());
+ ret = media_svc_rename_folder(_content_get_db_handle(), _folder->storage_uuid, g_src_path, _folder->path, _content_get_uid());
SAFE_FREE(g_src_path);
return _content_error_capi(ret);
int ret = MEDIA_CONTENT_ERROR_NONE;
content_warn("DEPRECATION WARNING: media_folder_set_name() is deprecated and will be removed from next release.");
media_folder_s *_folder = (media_folder_s*)folder;
-
- char *folder_path = NULL;
- char new_folder_path[MAX_PATH_LEN] = {0,};
- char repl_path[MAX_PATH_LEN] = {0, };
+ char *parent_folder_path = NULL;
content_retip_if_fail(folder);
content_retip_if_fail(STRING_VALID(name));
content_retip_if_fail(STRING_VALID(_folder->path));
content_retip_if_fail(STRING_VALID(_folder->name));
- ret = _media_content_replace_path(_folder->path, repl_path);
- content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
- folder_path = g_path_get_dirname(repl_path);
- content_sec_debug("Existed Folder Path : %s", repl_path);
- snprintf(new_folder_path, sizeof(new_folder_path), "%s/%s", folder_path, name);
- content_sec_debug("New Path : %s", new_folder_path);
+ // Change name..
+ g_free(_folder->name);
+ _folder->name = g_strdup(name);
+ // Change path..
g_free(g_src_path);
- g_src_path = g_strdup(repl_path);
-
+ g_src_path = g_strdup(_folder->path);
g_free(_folder->path);
- g_free(_folder->name);
- g_free(folder_path);
- _folder->path = g_strdup(new_folder_path);
- _folder->name = g_strdup(name);
+ parent_folder_path = g_path_get_dirname(g_src_path);
+ _folder->path = g_strdup_printf("%s/%s", parent_folder_path, name);
+ g_free(parent_folder_path);
+
+ content_sec_debug("Old[%s] New[%s]", g_src_path, _folder->path);
return ret;
}
int media_folder_insert_to_db(const char *path)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- char repl_path[MAX_PATH_LEN] = {0, };
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
content_retip_if_fail(STRING_VALID(path));
- ret = _media_content_replace_path(path, repl_path);
- content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
- content_retvm_if(_media_util_is_ignorable_dir(repl_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+ content_retvm_if(_media_util_is_ignorable_dir(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
- ret = _media_content_check_dir(repl_path);
+ ret = _media_content_check_dir(path);
content_retvm_if(ret == MEDIA_CONTENT_ERROR_PERMISSION_DENIED, ret, "Permission Denied");
content_retvm_if(ret == MEDIA_CONTENT_ERROR_INVALID_PARAMETER, ret, "invalid path[%s]", path);
- ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
+ ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
content_error("media_svc_get_storage_id failed : %d", ret);
return _content_error_capi(ret);
}
- ret = media_svc_check_folder_exist_by_path(_content_get_db_handle(), storage_id, repl_path);
+ ret = media_svc_check_folder_exist_by_path(_content_get_db_handle(), storage_id, path);
if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
- content_sec_debug("media_svc_check_folder_exist_by_path : no record : %s", repl_path);
+ content_sec_debug("media_svc_check_folder_exist_by_path : no record : %s", path);
ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
- ret = ms_user_get_storage_type(_content_get_uid(), repl_path, &storage_type);
+ ret = ms_user_get_storage_type(_content_get_uid(), path, &storage_type);
if (ret != MS_MEDIA_ERR_NONE) {
content_sec_error("ms_user_get_storage_type failed : %d", ret);
return _content_error_capi(ret);
}
- ret = media_svc_insert_folder(_content_get_db_handle(), storage_id, storage_type, repl_path, false, _content_get_uid());
+ ret = media_svc_insert_folder(_content_get_db_handle(), storage_id, storage_type, path, false, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
- content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path);
+ content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", path);
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- content_sec_error("media_svc_insert_folder failed : %d (%s)", ret, repl_path);
+ content_sec_error("media_svc_insert_folder failed : %d (%s)", ret, path);
}
return _content_error_capi(ret);
}
- ret = media_svc_set_folder_scan_status(storage_id, repl_path, MEDIA_DIR_SCAN_DONE, false, _content_get_uid());
+ ret = media_svc_set_folder_scan_status(storage_id, path, MEDIA_DIR_SCAN_DONE, false, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
content_sec_error("media_svc_set_folder_scan_status failed : %d", ret);
return _content_error_capi(ret);
}
} else if (ret != MS_MEDIA_ERR_NONE) {
- content_sec_error("media_svc_check_folder_exist_by_path failed : %d (%s)", ret, repl_path);
+ content_sec_error("media_svc_check_folder_exist_by_path failed : %d (%s)", ret, path);
return _content_error_capi(ret);
}
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;
content_retip_if_fail(STRING_VALID(path));
content_retip_if_fail(info);
- ret = _media_content_replace_path(path, repl_path);
- content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
- ret = __media_info_check_file_validity(repl_path);
+ ret = __media_info_check_file_validity(path);
content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
+ ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
content_error("media_svc_get_storage_id failed : %d", ret);
return _content_error_capi(ret);
}
- ret = ms_user_get_storage_type(_content_get_uid(), repl_path, &storage_type);
+ ret = ms_user_get_storage_type(_content_get_uid(), path, &storage_type);
if (ret != MS_MEDIA_ERR_NONE) {
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);
+ ret = media_svc_get_modified_time(_content_get_db_handle(), storage_id, 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 (modified_time != _media_util_get_file_time(path)) {
+ ret = media_svc_refresh_item(_content_get_db_handle(), false, storage_id, storage_type, path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
content_error("media_svc_refresh_item failed : %d", ret);
return _content_error_capi(ret);
}
}
} else if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
- content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", repl_path);
- content_retvm_if(!_media_util_check_support_media_type(repl_path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
+ content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", path);
+ content_retvm_if(!_media_util_check_support_media_type(path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
- ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, _content_get_uid());
+ ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
- content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path);
+ content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", path);
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, repl_path);
+ content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
}
return _content_error_capi(ret);
}
} else {
- content_sec_error("media_svc_get_modified_time failed : %d (%s)", ret, repl_path);
+ content_sec_error("media_svc_get_modified_time failed : %d (%s)", ret, path);
return _content_error_capi(ret);
}
#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);
+ ret = _media_info_get_media_info_from_db(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);
+ ret = _media_info_get_media_info_from_db(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);
+ ret = _media_info_get_media_info_from_db(path, (media_info_h)_media);
*info = (media_info_h)_media;
#endif
int media_info_insert_batch_to_db(const char **path_array, unsigned int array_length, 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_PATH_LEN] = {0, };
-
content_retip_if_fail(path_array);
content_retip_if_fail(array_length > 0);
content_retip_if_fail(completed_cb);
- repl_path_array = g_malloc0(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] = g_strndup(repl_path, strlen(repl_path));
- } else {
- content_error("path[%d] is invalid string", idx);
- }
- }
-
- ret = __media_info_insert_batch((const char **)repl_path_array, array_length, completed_cb, user_data);
- for (idx = 0; idx < array_length; idx++)
- g_free(repl_path_array[idx]);
-
- g_free(repl_path_array);
-
- return ret;
+ return __media_info_insert_batch(path_array, array_length, completed_cb, user_data);
}
+
#ifdef _USE_TVPD_MODE
int media_info_get_media_info_by_path_from_db(const char* path, media_info_h* media)
{
if (ret == MEDIA_CONTENT_ERROR_NONE) {
/* Send notification for this update */
- content_debug("Update is successfull. Send notification for this");
+ content_debug("Update is successful. Send notification for this");
if (_media->file_path && _media->mime_type)
media_svc_publish_noti(MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
else
content_retip_if_fail(media);
content_retip_if_fail(STRING_VALID(dst_path));
- ret = _media_content_replace_path(dst_path, repl_path);
- content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
media_info_s *_media = (media_info_s*)media;
/* If dst_path is folder, append file_name */
+ SAFE_STRLCPY(repl_path, dst_path, sizeof(repl_path));
+
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));
{
int tmp_str_len = 0;
char tmp_str[MAX_PATH_LEN] = {0, };
- char repl_item[MAX_PATH_LEN] = {0, };
FILE *fp = NULL;
fp = fopen(playlist_path, "rb");
}
while (fgets(tmp_str, MAX_PATH_LEN, fp) != NULL) {
- memset(repl_item, 0, sizeof(repl_item));
- _media_content_replace_path(tmp_str, repl_item);
-
- tmp_str_len = strlen(repl_item);
+ tmp_str_len = strlen(tmp_str);
/* Check for empty file */
if (tmp_str_len <= 1)
continue;
- if (repl_item[0] == '#')
+ if (tmp_str[0] == '#')
continue;
- if (repl_item[tmp_str_len - 1] == '\n')
- repl_item[tmp_str_len - 1] = '\0';
+ if (tmp_str[tmp_str_len - 1] == '\n')
+ tmp_str[tmp_str_len - 1] = '\0';
- *item_list = g_slist_append(*item_list, g_strdup(repl_item));
+ *item_list = g_slist_append(*item_list, g_strdup(tmp_str));
}
fclose(fp);
{
int ret = MEDIA_CONTENT_ERROR_NONE;
GSList *item_list = NULL;
- char repl_path[MAX_PATH_LEN] = {0, };
content_retip_if_fail(STRING_VALID(path));
content_retip_if_fail(STRING_VALID(playlist_name));
- ret = _media_content_replace_path(path, repl_path);
- content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
ret = media_playlist_insert_to_db(playlist_name, playlist);
content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_playlist_insert_to_db fail");
- ret = __media_playlist_import_item_from_file(repl_path, &item_list);
+ ret = __media_playlist_import_item_from_file(path, &item_list);
content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "Fail to get playlist from file");
g_slist_foreach(item_list, __media_playlist_foreach_item, playlist);
int ret = MEDIA_CONTENT_ERROR_NONE;
media_playlist_s *_playlist = (media_playlist_s *)playlist;
GList *item_list = NULL;
- unsigned int idx = 0;
- char repl_path[MAX_PATH_LEN] = {0, };
+ GList *iter = NULL;
+ char *item = NULL;
content_retip_if_fail(STRING_VALID(path));
content_retip_if_fail(playlist);
content_retipm_if_fail(_playlist->playlist_id > 0, "%d", _playlist->playlist_id);
- ret = _media_content_replace_path(path, repl_path);
- 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);
content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "_media_db_get_playlist_item fail");
- ret = __media_playlist_reset_file(repl_path);
+ ret = __media_playlist_reset_file(path);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
- g_list_free_full(item_list, g_free);
content_error("Fail to init playlist file");
- return ret;
+ goto FINALIZE;
}
- for (idx = 0; idx < g_list_length(item_list); idx++) {
- char *item = g_list_nth_data(item_list, idx);
- if (STRING_VALID(item)) {
- ret = __media_playlist_append_to_file(repl_path, item);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- g_list_free_full(item_list, g_free);
- content_error("Fail to export paths into file");
- return ret;
- }
+ for (iter = item_list; iter; iter = g_list_next(iter)) {
+ item = (char *)iter->data;
+ if (!STRING_VALID(item))
+ continue;
+
+ ret = __media_playlist_append_to_file(path, item);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ content_error("Fail to export paths into file");
+ goto FINALIZE;
}
}
+FINALIZE:
g_list_free_full(item_list, g_free);
return ret;
}
#else
if (g_str_has_prefix(tmp_path, MEDIA_SHARE_PATH)) {
- /* If shared dirctory, it should be change path to TZ_USER_SHARE from realpath */
+ /* If shared directory, it should be change path to TZ_USER_SHARE from realpath */
snprintf(replace, MAX_PATH_LEN, "%s%s", tzplatform_getenv(TZ_USER_MEDIASHARED), tmp_path + strlen(MEDIA_SHARE_PATH));
if (g_strcmp0(replace, org_path) != 0) {
content_error("symbolic link(directory)");
}
#else
if (g_str_has_prefix(real, MEDIA_SHARE_PATH)) {
- /* If shared dirctory, it should be change path to TZ_USER_SHARE from realpath */
+ /* If shared directory, it should be change path to TZ_USER_SHARE from realpath */
snprintf(result_path, MAX_PATH_LEN, "%s%s", tzplatform_getenv(TZ_USER_MEDIASHARED), real + strlen(MEDIA_SHARE_PATH));
if (g_strcmp0(result_path, origin) != 0) {
content_error("symbolic link(directory)");
return MEDIA_CONTENT_ERROR_NONE;
}
-
-
-/* FIXME : If there are no issue reports related to this, it will be deleted in tizen 6.5 or after. */
-char * _media_content_replace_path_in_condition(const char *condition)
-{
- return g_strdup(condition);
-#if 0
- char **split_list = NULL;
- char *result = NULL;
-
- if (!STRING_VALID(MEDIA_ROOT_PATH_INTERNAL_OLD) || !STRING_VALID(MEDIA_ROOT_PATH_INTERNAL))
- return NULL;
-
- content_sec_debug("Old condition[%s]", condition);
-
- split_list = g_strsplit(condition, MEDIA_ROOT_PATH_INTERNAL_OLD, -1);
- if (!split_list)
- return NULL;
-
- result = g_strjoinv(MEDIA_ROOT_PATH_INTERNAL, split_list);
- g_strfreev(split_list);
-
- return result;
-#endif
-}
-
-/* FIXME : If there are no issue reports related to this, it will be deleted in Tizen 6.5 or after. */
-int _media_content_replace_path(const char *path, char *replace_path)
-{
- content_retip_if_fail(STRING_VALID(path));
-
- snprintf(replace_path, MAX_PATH_LEN, "%s", path);
-#if 0
- if (strncmp(path, MEDIA_ROOT_PATH_INTERNAL_OLD, strlen(MEDIA_ROOT_PATH_INTERNAL_OLD)) == 0) {
- content_sec_debug("Old path[%s]", path);
- snprintf(replace_path, MAX_PATH_LEN, "%s%s", MEDIA_ROOT_PATH_INTERNAL, path + strlen(MEDIA_ROOT_PATH_INTERNAL_OLD));
- } else {
- snprintf(replace_path, MAX_PATH_LEN, "%s", path);
- }
-#endif
-
- return MEDIA_CONTENT_ERROR_NONE;
-}
-