Use tzplatform-config for storage_get_directory 16/128816/1 accepted/tizen/unified/20170511.173603 submit/tizen/20170511.114720 tizen_4.0.m1_release
authorpr.jung <pr.jung@samsung.com>
Thu, 11 May 2017 11:43:06 +0000 (20:43 +0900)
committerpr.jung <pr.jung@samsung.com>
Thu, 11 May 2017 11:44:08 +0000 (20:44 +0900)
Change-Id: Ic079a84945fa0c6f55367c9d4c90321b7b2133cc
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/storage.c

index fa719ec60a82f4b9cf06c3e7e479c0062685254f..598a289abaff331a1985e99051d810513133f921 100644 (file)
 #include <string.h>
 #include <errno.h>
 #include <vconf.h>
+#include <tzplatform_config.h>
 
 #include "common.h"
 #include "list.h"
 #include "log.h"
 #include "storage-external.h"
 
-const char *dir_path[STORAGE_DIRECTORY_MAX] = {
-       [STORAGE_DIRECTORY_IMAGES] = "Images",
-       [STORAGE_DIRECTORY_SOUNDS] = "Sounds",
-       [STORAGE_DIRECTORY_VIDEOS] = "Videos",
-       [STORAGE_DIRECTORY_CAMERA] = "DCIM",
-       [STORAGE_DIRECTORY_DOWNLOADS] = "Downloads",
-       [STORAGE_DIRECTORY_MUSIC] = "Music",
-       [STORAGE_DIRECTORY_DOCUMENTS] = "Documents",
-       [STORAGE_DIRECTORY_OTHERS] = "Others",
-       [STORAGE_DIRECTORY_SYSTEM_RINGTONES] = "",
+const char *dir_path[STORAGE_DIRECTORY_MAX];
+
+const int tz_id[STORAGE_DIRECTORY_MAX] = {
+       [STORAGE_DIRECTORY_IMAGES] = TZ_USER_IMAGES,
+       [STORAGE_DIRECTORY_SOUNDS] = TZ_USER_SOUNDS,
+       [STORAGE_DIRECTORY_VIDEOS] = TZ_USER_VIDEOS,
+       [STORAGE_DIRECTORY_CAMERA] = TZ_USER_CAMERA,
+       [STORAGE_DIRECTORY_DOWNLOADS] = TZ_USER_DOWNLOADS,
+       [STORAGE_DIRECTORY_MUSIC] = TZ_USER_MUSIC,
+       [STORAGE_DIRECTORY_DOCUMENTS] = TZ_USER_DOCUMENTS,
+       [STORAGE_DIRECTORY_OTHERS] = TZ_USER_OTHERS,
 };
 
 static dd_list *st_int_head; /* Internal storage list */
@@ -525,3 +527,21 @@ API int storage_unset_changed_cb(storage_type_e type, storage_changed_cb callbac
 
        return STORAGE_ERROR_NONE;
 }
+
+static void __CONSTRUCTOR__ init(void)
+{
+       const char *tmp;
+       char *token;
+       int i;
+
+       for (i = 0 ; i <= STORAGE_DIRECTORY_OTHERS ; i++) {
+               tmp = tzplatform_getenv(tz_id[i]);
+               if (tmp != NULL) {
+                       token = rindex(tmp, '/');
+                       if (token != NULL) {
+                               token++;
+                               dir_path[i] = strdup(token);
+                       }
+               }
+       }
+}