*/
#include <tizen.h>
+#include <tzplatform_config.h>
#include "storage.h"
#define STORAGE_ERROR_NO_DEVICE TIZEN_ERROR_NO_SUCH_DEVICE
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);
/**
* @}
#define CHECK_STR(a) (a ? a : "")
-#define STORAGE_EXT_GET_LIST "GetDeviceList"
-#define STORAGE_EXT_GET_STATVFS "GetStatvfs"
+#define STORAGE_EXT_GET_LIST "GetDeviceList"
+#define STORAGE_EXT_GET_STATVFS "GetStatvfs"
+#define STORAGE_EXT_GET_STORAGE_LEVEL "GetStorageLevel"
-#define STORAGE_EXT_DEVICE_CHANGED "DeviceChanged"
-#define STORAGE_EXT_DEVICE_ADDED "DeviceAdded"
-#define STORAGE_EXT_DEVICE_REMOVED "DeviceRemoved"
-#define STORAGE_EXT_DEVICE_BLOCKED "DeviceBlocked"
+#define STORAGE_EXT_DEVICE_CHANGED "DeviceChanged"
+#define STORAGE_EXT_DEVICE_ADDED "DeviceAdded"
+#define STORAGE_EXT_DEVICE_REMOVED "DeviceRemoved"
+#define STORAGE_EXT_DEVICE_BLOCKED "DeviceBlocked"
#define DBUS_REPLY_TIMEOUT (-1)
return 0;
}
+int storage_ext_get_storage_level(enum tzplatform_variable id, char **level)
+{
+ GVariant *result;
+ char *tmp;
+
+ result = dbus_method_call_sync(STORAGE_EXT_BUS_NAME,
+ STORAGE_EXT_PATH_STORAGE,
+ STORAGE_EXT_IFACE_STORAGE,
+ STORAGE_EXT_GET_STORAGE_LEVEL,
+ g_variant_new("(i)", id));
+ if (!result) {
+ _E("Failed to get %d level", id);
+ return -EIO;
+ }
+
+ g_variant_get(result, "(s)", &tmp);
+ *level = strdup(tmp);
+ if (*level == NULL)
+ return -ENOMEM;
+
+ return 0;
+}
+
//LCOV_EXCL_START Not called Callback
static void storage_ext_device_changed(GVariant *params, enum storage_ext_state state, gpointer user_data)
{
#include <stdbool.h>
#include <glib.h>
#include <gio/gio.h>
+#include <tzplatform_config.h>
#include "list.h"
#define STORAGE_EXT_BUS_NAME "org.tizen.system.storage"
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);
/* storage-internal.c */
GVariant *dbus_method_call_sync(const gchar *dest, const gchar *path,
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <tzplatform_config.h>
#include "common.h"
#include "list.h"
return STORAGE_ERROR_NONE;
}
+API int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e *dev)
+{
+ storage_ext_device *ext_dev;
+ int ret;
+
+ if (storage_id < 0) {
+ _E("Invalid parameger");
+ return STORAGE_ERROR_NO_DEVICE;
+ }
+
+ if (!type) {
+ _E("Invalid parameger");
+ return STORAGE_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!dev) {
+ _E("Invalid parameger");
+ return STORAGE_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = storage_get_type(storage_id, type);
+ if (ret != STORAGE_ERROR_NONE) {
+ _E("Failed to get storage type: %d", ret);
+ return ret;
+ }
+ if (*type == STORAGE_TYPE_INTERNAL)
+ return STORAGE_ERROR_NONE;
+
+ ext_dev = calloc(1, sizeof(storage_ext_device));
+ if (!ext_dev) {
+ //LCOV_EXCL_START System Error
+ _E("calloc failed");
+ return STORAGE_ERROR_OUT_OF_MEMORY;
+ //LCOV_EXCL_STOP
+ }
+
+ ret = storage_ext_get_device_info(storage_id, ext_dev);
+ if (ret < 0) {
+ _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
+ ret = STORAGE_ERROR_NO_DEVICE;
+ goto out;
+ }
+
+ if (ext_dev->type == STORAGE_EXT_SCSI)
+ *dev = STORAGE_DEV_EXT_USB_MASS_STORAGE;
+ else if (ext_dev->type == STORAGE_EXT_MMC)
+ *dev = STORAGE_DEV_EXT_SDCARD;
+ ret = STORAGE_ERROR_NONE;
+ _I("type: %d(internal:0, external:1) dev: %d(sdcard: 1001, usb: 1002)", *type, *dev);
+
+out:
+ storage_ext_release_device(&ext_dev);
+ return ret;
+}
+
+API int storage_get_storage_level(enum tzplatform_variable id, char **level)
+{
+ int ret;
+
+ if (!level)
+ 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);
+ if (ret == -ENOMEM)
+ return STORAGE_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error
+ else if (ret < 0)
+ return STORAGE_ERROR_OPERATION_FAILED;
+
+ return STORAGE_ERROR_NONE;
+}