Add user path to system session path 31/99731/1 accepted/tizen/common/20161124.170134 accepted/tizen/ivi/20161125.004406 accepted/tizen/mobile/20161125.004355 accepted/tizen/tv/20161125.004359 accepted/tizen/unified/20170309.032137 accepted/tizen/wearable/20161125.004402 submit/tizen/20161124.033505 submit/tizen_unified/20170308.100405
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 24 Nov 2016 03:23:35 +0000 (12:23 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Thu, 24 Nov 2016 03:23:35 +0000 (12:23 +0900)
Change-Id: I27b33c2f272a71945cb718fc33eed8fb73786ed2
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
CMakeLists.txt
packaging/capi-media-thumbnail-util.spec
src/thumbnail_util.c

index 5dd6f4a..20e0513 100755 (executable)
@@ -24,7 +24,7 @@ SET(service "media")
 SET(submodule "thumbnail-util")
 
 # for package file
-SET(dependents "dlog glib-2.0 capi-base-common media-thumbnail libmedia-utils")
+SET(dependents "dlog glib-2.0 capi-base-common media-thumbnail libmedia-utils storage")
 SET(fw_name "${project_prefix}-${service}-${submodule}")
 
 PROJECT(${fw_name})
index 097070e..3329fbf 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-thumbnail-util
 Summary:    A media thumbnail util library in Tizen Native API
-Version: 0.1.4
+Version: 0.1.5
 Release:    1
 Group:      Multimedia/API
 License:    Apache-2.0
@@ -11,6 +11,7 @@ BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(libmedia-utils)
 BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(media-thumbnail)
+BuildRequires:  pkgconfig(storage)
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 
index 8707fbc..e2fe74d 100755 (executable)
 #include <media-util.h>
 #include <thumbnail_util.h>
 #include <thumbnail_util_private.h>
+#include <storage.h>
 
 #define MAX_SIZE 16
+#define MAX_PATH_SIZE 4096
+
+int __thumbnail_util_replace_path(const char *path, char *replace_path)
+{
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+       char *old_path = NULL;
+
+       ret = storage_get_root_directory(STORAGE_TYPE_INTERNAL, &old_path);
+       if (ret != STORAGE_ERROR_NONE) {
+               thumbnail_util_error("storage_get_directory failed");
+               return THUMBNAIL_UTIL_ERROR_INVALID_OPERATION;
+       }
+
+       if (strncmp(path, old_path, strlen(old_path)) == 0) {
+               thumbnail_util_sec_debug("Old path[%s]", path);
+               snprintf(replace_path, MAX_PATH_SIZE, "%s%s", tzplatform_getenv(TZ_USER_CONTENT), path + strlen(old_path));
+       } else {
+               snprintf(replace_path, MAX_PATH_SIZE, "%s", path);
+       }
+
+       SAFE_FREE(old_path);
+
+       if (!STRING_VALID(replace_path)) {
+               thumbnail_util_error("replace failed");
+               return THUMBNAIL_UTIL_ERROR_INVALID_OPERATION;
+       }
+
+       return THUMBNAIL_UTIL_ERROR_NONE;
+}
 
 int __thumbnail_util_error_capi(int content_error)
 {
@@ -133,11 +163,19 @@ int thumbnail_util_extract(thumbnail_h thumb, thumbnail_extracted_cb callback, v
 int thumbnail_util_set_path(thumbnail_h thumb, const char *path)
 {
        int ret = THUMBNAIL_UTIL_ERROR_NONE;
+       char repl_path[MAX_PATH_SIZE + 1] = {0, };
        thumbnail_s *_thumb = (thumbnail_s *)thumb;
 
        if (_thumb != NULL && path != NULL) {
                SAFE_FREE(_thumb->file_path);
-               _thumb->file_path = strndup(path, strlen(path));
+               memset(repl_path, 0, sizeof(repl_path));
+               ret = __thumbnail_util_replace_path(path, repl_path);
+               if (ret != THUMBNAIL_UTIL_ERROR_NONE) {
+                       thumbnail_util_error("Convert path failed");
+                       _thumb->file_path = NULL;
+               } else {
+                       _thumb->file_path = strndup(repl_path, strlen(repl_path));
+               }
        } else {
                thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
                ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;