From ebe8d117ef1e8c593ecd1db932a2931d8aba7b50 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Thu, 28 Jun 2018 16:27:54 +0900 Subject: [PATCH] Modify storage_get_storage_level - Change fist parameter of storage_get_storage_level enum tzplatform_variable -> char * - Remove tzplatform_config.h in storage-internal.h Change-Id: I3f5ac4d6ff47aad5cccce101c7775cb1ce3e0379 Signed-off-by: pr.jung --- include/storage-internal.h | 3 +-- src/storage-external-dbus.c | 15 ++++++++++++++- src/storage-external-dbus.h | 3 +-- src/storage-inhouse.c | 12 ++++++------ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/include/storage-internal.h b/include/storage-internal.h index 1b14798..53795d2 100644 --- a/include/storage-internal.h +++ b/include/storage-internal.h @@ -30,7 +30,6 @@ extern "C" { */ #include -#include #include "storage.h" #define STORAGE_ERROR_NO_DEVICE TIZEN_ERROR_NO_SUCH_DEVICE @@ -56,7 +55,7 @@ int storage_get_primary_sdcard(int *storage_id, char **path); int storage_get_compat_internal_path(const char* origin, int len, char* compat); int storage_get_origin_internal_path(const char* compat, int len, char* origin); -int storage_get_storage_level(enum tzplatform_variable id, char **level); +int storage_get_storage_level(const char *path, char **level); /** * @} diff --git a/src/storage-external-dbus.c b/src/storage-external-dbus.c index d335ca7..f070e8f 100755 --- a/src/storage-external-dbus.c +++ b/src/storage-external-dbus.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "log.h" #include "storage-external-dbus.h" @@ -287,10 +288,22 @@ int storage_ext_get_statvfs_size64(char *path, struct statvfs *buf) return 0; } -int storage_ext_get_storage_level(enum tzplatform_variable id, char **level) +int storage_ext_get_storage_level(const char *path, char **level) { GVariant *result; char *tmp; + enum tzplatform_variable id; + + if (!strcmp(path, tzplatform_getenv(TZ_SYS_USER))) + id = TZ_SYS_USER; + else if (!strcmp(path, tzplatform_getenv(TZ_SYS_TMP))) + id = TZ_SYS_TMP; + else if (!strcmp(path, tzplatform_getenv(TZ_SYS_OPT))) + id = TZ_SYS_OPT; + else { + _E("Invalid path"); + return -EINVAL; + } result = dbus_method_call_sync(STORAGE_EXT_BUS_NAME, STORAGE_EXT_PATH_STORAGE, diff --git a/src/storage-external-dbus.h b/src/storage-external-dbus.h index 24800f8..b71d2e4 100644 --- a/src/storage-external-dbus.h +++ b/src/storage-external-dbus.h @@ -23,7 +23,6 @@ #include #include #include -#include #include "list.h" #define STORAGE_EXT_BUS_NAME "org.tizen.system.storage" @@ -107,7 +106,7 @@ int storage_ext_register_device_change(storage_ext_changed_cb func, void *data); void storage_ext_unregister_device_change(storage_ext_changed_cb func); int storage_ext_get_device_info(int storage_id, storage_ext_device *info); -int storage_ext_get_storage_level(enum tzplatform_variable id, char **level); +int storage_ext_get_storage_level(const char *path, char **level); /* storage-internal.c */ GVariant *dbus_method_call_sync(const gchar *dest, const gchar *path, diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index d3e30d3..051b6b9 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "common.h" #include "list.h" @@ -180,19 +181,18 @@ API int storage_get_primary_sdcard(int *storage_id, char **path) return STORAGE_ERROR_NONE; } -API int storage_get_storage_level(enum tzplatform_variable id, char **level) +API int storage_get_storage_level(const char *path, char **level) { int ret; - if (!level) + if (!level || !path) return STORAGE_ERROR_INVALID_PARAMETER; - if (id != TZ_SYS_USER || id != TZ_SYS_TMP || id != TZ_SYS_OPT) - return STORAGE_ERROR_INVALID_PARAMETER; - - ret = storage_ext_get_storage_level(id, level); + ret = storage_ext_get_storage_level(path, level); if (ret == -ENOMEM) return STORAGE_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error + else if (ret == -EINVAL) + return STORAGE_ERROR_INVALID_PARAMETER; else if (ret < 0) return STORAGE_ERROR_OPERATION_FAILED; -- 2.7.4