Update path replacement function 51/185751/2 submit/tizen/20180809.003539
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 2 Aug 2018 04:24:34 +0000 (13:24 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Tue, 7 Aug 2018 07:48:18 +0000 (16:48 +0900)
Use hardcording instead of storage API (because of storage API changes)

Change-Id: I92562dbc6c55bfd3ed86d723c0efd4e34db31f33
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
packaging/capi-content-media-content.spec
src/media_util_private.c

index fc9349e..d482003 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-content-media-content
 Summary:    A Media content library in Tizen Native API
-Version:    0.3.33
+Version:    0.3.34
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index d3d2556..ba19ed3 100755 (executable)
@@ -20,6 +20,7 @@
 #include <media_info_private.h>
 #include <storage.h>
 #include <system_info.h>
+
 #ifdef _USE_SENIOR_MODE
 #include <media_util_private.h>
 #endif
@@ -368,9 +369,9 @@ int _media_content_replace_path_in_condition(const char *condition, char *replac
        char *to_replace_str = NULL;
 
        if (replace == TRUE) {  //change User session path to System session path
-               ret = storage_get_root_directory(STORAGE_TYPE_INTERNAL, &find_str);
-               if (ret != STORAGE_ERROR_NONE) {
-                       media_content_error("storage_get_root_directory failed");
+               find_str = g_strdup(MEDIA_ROOT_PATH_INTERNAL_OLD);
+               if (!STRING_VALID(find_str)) {
+                       media_content_error("strdup failed");
                        ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
                        goto ERROR;
                }
@@ -389,9 +390,9 @@ int _media_content_replace_path_in_condition(const char *condition, char *replac
                        goto ERROR;
                }
 
-               ret = storage_get_root_directory(STORAGE_TYPE_INTERNAL, &to_replace_str);
-               if (ret != STORAGE_ERROR_NONE) {
-                       media_content_error("storage_get_root_directory failed");
+               to_replace_str = g_strdup(MEDIA_ROOT_PATH_INTERNAL_OLD);
+               if (!STRING_VALID(to_replace_str)) {
+                       media_content_error("strdup failed");
                        ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
                        goto ERROR;
                }
@@ -457,24 +458,12 @@ int _media_content_replace_path(const char *path, char *replace_path)
 #ifdef _USE_TVPD_MODE
        snprintf(replace_path, MAX_PATH_LEN, "%s", path);
 #else
-
-       int ret = MEDIA_CONTENT_ERROR_NONE;
-       char *old_internal_path =  NULL;
-
-       ret = storage_get_root_directory(STORAGE_TYPE_INTERNAL, &old_internal_path);
-       if (ret != STORAGE_ERROR_NONE) {
-               media_content_error("storage_get_root_directory failed");
-               return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
-       }
-
-       if (strncmp(path, old_internal_path, strlen(old_internal_path)) == 0) {
+       if (strncmp(path, MEDIA_ROOT_PATH_INTERNAL_OLD, strlen(MEDIA_ROOT_PATH_INTERNAL_OLD)) == 0) {
                media_content_sec_debug("Old path[%s]", path);
-               snprintf(replace_path, MAX_PATH_LEN, "%s%s", MEDIA_ROOT_PATH_INTERNAL, path + strlen(old_internal_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);
        }
-
-       SAFE_FREE(old_internal_path);
 #endif
 
        if (!STRING_VALID(replace_path)) {
@@ -490,24 +479,12 @@ int _media_content_rollback_path(const char *path, char *replace_path)
 #ifdef _USE_TVPD_MODE
                snprintf(replace_path, MAX_PATH_LEN, "%s", path);
 #else
-
-       int ret = MEDIA_CONTENT_ERROR_NONE;
-       char *old_internal_path =  NULL;
-
-       ret = storage_get_root_directory(STORAGE_TYPE_INTERNAL, &old_internal_path);
-       if (ret != STORAGE_ERROR_NONE) {
-               media_content_error("storage_get_root_directory failed");
-               return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
-       }
-
        if (strncmp(path, MEDIA_ROOT_PATH_INTERNAL, strlen(MEDIA_ROOT_PATH_INTERNAL)) == 0) {
                media_content_sec_debug("new path[%s]", path);
-               snprintf(replace_path, MAX_PATH_LEN, "%s%s", old_internal_path, path + strlen(MEDIA_ROOT_PATH_INTERNAL));
+               snprintf(replace_path, MAX_PATH_LEN, "%s%s", MEDIA_ROOT_PATH_INTERNAL_OLD, path + strlen(MEDIA_ROOT_PATH_INTERNAL));
        } else {
                snprintf(replace_path, MAX_PATH_LEN, "%s", path);
        }
-
-       SAFE_FREE(old_internal_path);
 #endif
 
        if (!STRING_VALID(replace_path)) {