From b43b8d98f6636e4e854f6a1de41f5337ad0f9910 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 14 Apr 2015 10:40:23 +0900 Subject: [PATCH] Remove storage api TC-2495 storage api is supported in libstorage Change-Id: I692f9229d4763c6dc47de56bd123877fa981f256 Signed-off-by: Sangyoon Jang --- include/app.h | 1 - include/app_storage.h | 226 ----------------------- include/app_storage_private.h | 60 ------ src/storage.c | 416 ------------------------------------------ src/storage_internal.c | 81 -------- src/storage_sdcard.c | 125 ------------- src/storage_usbhost.c | 125 ------------- 7 files changed, 1034 deletions(-) delete mode 100644 include/app_storage.h delete mode 100755 include/app_storage_private.h delete mode 100755 src/storage.c delete mode 100755 src/storage_internal.c delete mode 100755 src/storage_sdcard.c delete mode 100755 src/storage_usbhost.c diff --git a/include/app.h b/include/app.h index bd8d68e..b3b259e 100755 --- a/include/app.h +++ b/include/app.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/include/app_storage.h b/include/app_storage.h deleted file mode 100644 index 0afe823..0000000 --- a/include/app_storage.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __TIZEN_APPFW_STORAGE_H__ -#define __TIZEN_APPFW_STORAGE_H__ - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - - /** - * @addtogroup CAPI_STORAGE_MODULE - * @{ - */ - - -/** - * @brief Enumerations of error code for Storage. - */ -typedef enum -{ - STORAGE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - STORAGE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - STORAGE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - STORAGE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NO_SUCH_DEVICE /**< Not supported storage */ -} storage_error_e; - - -/** - * @brief Enumerations of the storage type. - */ -typedef enum -{ - STORAGE_TYPE_INTERNAL, /**< Internal device storage (built-in storage in a device, non-removable) */ - STORAGE_TYPE_EXTERNAL, /**< External storage */ -} storage_type_e; - - -/** - * @brief Enumerations of the state of storage device. - */ -typedef enum -{ - STORAGE_STATE_UNMOUNTABLE = -2, /**< Storage is present but cannot be mounted. Typically it happens if the file system of the storage is corrupted. */ - STORAGE_STATE_REMOVED = -1, /**< Storage is not present. */ - STORAGE_STATE_MOUNTED = 0, /**< Storage is present and mounted with read/write access. */ - STORAGE_STATE_MOUNTED_READ_ONLY = 1, /**< Storage is present and mounted with read only access. */ -} storage_state_e; - - -/** -* @brief Called to get information once for each supported storage. -* -* @param [in] storage The unique storage ID -* @param [in] type The type of the storage -* @param [in] state The current state of the storage -* @param [in] path The absolute path to the root directory of the @a storage -* @param [in] user_data The user data passed from the foreach function -* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop. -* @pre storage_foreach_device_supported() will invoke this callback function. -* @see storage_foreach_device_supported() -*/ -typedef bool (*storage_device_supported_cb)(int storage, storage_type_e type, storage_state_e state, const char *path, void *user_data); - - -/** -* @brief Called when the state of storage changes -* -* @param [in] storage The unique storage ID -* @param [in] state The current state of the storage -* @param [in] user_data The user data passed from the foreach function -* @pre storage_set_state_changed_cb() will invoke this callback function. -* @see storage_set_state_changed_cb() -* @see storage_unset_state_changed_cb() -*/ -typedef void (*storage_state_changed_cb)(int storage, storage_state_e state, void *user_data); - - -/** - * @brief Retrieves all storage in device. - * @details This function invokes the callback function once for each @a storage in device. \n - * If storage_device_supported_cb() returns @c false, then iteration will be finished. - * - * @param [in] callback The iteration callback function - * @param [in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #STORAGE_ERROR_NONE Successful - * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter - * @post This function invokes storage_device_supported_cb() repeatedly for each supported device. - * @see storage_device_supported_cb() - */ -int storage_foreach_device_supported(storage_device_supported_cb callback, void *user_data); - - -/** - * @brief Gets the absolute path to the root directory of the given @a storage. - * @details - * Files saved on the internal/external storage are readable or writeable by all applications. - * When an application is uninstalled, the files written by that application are not removed from the internal/external storage. - * - * @remarks @a path must be released with free() by you. - * - * @param[in] storage The storage device - * @param[out] path The absolute path to the storage directory - * @return 0 on success, otherwise a negative error value. - * @retval #STORAGE_ERROR_NONE Successful - * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory - * @retval #STORAGE_ERROR_NOT_SUPPORTED Not supported storage - * @see storage_get_state() - */ -int storage_get_root_directory(int storage, char **path); - - -/** - * @brief Gets the type of the given @a storage. - * - * @param[in] storage The storage device - * @param[out] type The type of the storage - * @return 0 on success, otherwise a negative error value. - * @retval #STORAGE_ERROR_NONE Successful - * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STORAGE_ERROR_NOT_SUPPORTED Not supported storage - */ -int storage_get_type(int storage, storage_type_e *type); - - -/** - * @brief Gets the current state of the given @a storage. - * - * @param[in] storage The storage device - * @param[out] state The current state of the storage, - * @return 0 on success, otherwise a negative error value. - * @retval #STORAGE_ERROR_NONE Successful - * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STORAGE_ERROR_NOT_SUPPORTED Not supported storage - * @see storage_get_root_directory() - * @see storage_get_total_space() - * @see storage_get_available_space() - */ -int storage_get_state(int storage, storage_state_e *state); - - -/** - * @brief Registers a callback function to be invoked when the state of the storage changes. - * - * @param[in] storage The storage device - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #STORAGE_ERROR_NONE Successful - * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STORAGE_ERROR_NOT_SUPPORTED Not supported storage - * @post storage_state_changed_cb() will be invoked if the state of registered storage changes. - * @see storage_state_changed_cb() - * @see storage_unset_state_changed_cb() - */ -int storage_set_state_changed_cb(int storage, storage_state_changed_cb callback, void *user_data); - - -/** - * @brief Unregisters the callback function. - * - * @param [in] storage The storage device to monitor - * @return 0 on success, otherwise a negative error value. - * @retval #STORAGE_ERROR_NONE Successful - * @retval #STORAGE_ERROR_NOT_SUPPORTED Not supported storage - * @see storage_state_changed_cb() - * @see storage_set_state_changed_cb() - */ -int storage_unset_state_changed_cb(int storage); - -/** - * @brief Gets the total space of the given @a storage in bytes. - * - * @param[in] storage The storage device - * @param[out] bytes The total space size of the storage (bytes) - * @return 0 on success, otherwise a negative error value - * @retval #STORAGE_ERROR_NONE Successful - * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STORAGE_ERROR_NOT_SUPPORTED Not supported storage - * @see storage_get_state() - * @see storage_get_available_space() - */ -int storage_get_total_space(int storage, unsigned long long *bytes); - -/** - * @brief Gets the available space size of the given @a storage in bytes. - * - * @param[in] storage The storage device - * @param[out] bytes The available space size of the storage (bytes) - * @return 0 on success, otherwise a negative error value. - * @retval #STORAGE_ERROR_NONE Successful - * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STORAGE_ERROR_NOT_SUPPORTED Not supported storage - - * @see storage_get_state() - * @see storage_get_total_space() - */ -int storage_get_available_space(int storage, unsigned long long *bytes); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_APPFW_STORAGE_H__ */ diff --git a/include/app_storage_private.h b/include/app_storage_private.h deleted file mode 100755 index e5bf36c..0000000 --- a/include/app_storage_private.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef __TIZEN_APPFW_STORAGE_PRIVATE_H__ -#define __TIZEN_APPFW_STORAGE_PRIVATE_H__ - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef int (*storage_dev_get_state)(void); -typedef int (*storage_dev_set_state_cb)(void *data); -typedef void (*storage_dev_unset_state_cb)(void); -typedef int (*storage_dev_get_space)(unsigned long long *total, unsigned long long *available); - -typedef struct storage_device_s -{ - storage_type_e type; - char *path; - storage_dev_get_state get_state; - storage_dev_set_state_cb set_state_cb; - storage_dev_unset_state_cb unset_state_cb; - storage_dev_get_space get_space; -} *storage_device_h; - -typedef struct storage_info_s -{ - int id; - storage_device_h device; - storage_state_e state; - storage_state_changed_cb state_cb; - void *state_cb_data; -} *storage_info_h; - -void storage_dispatch_state_event(storage_state_e state, void* data); - -int storage_statfs(const char *directory, unsigned long long *total, unsigned long long *available); - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_APPFW_STORAGE_PRIVATE_H__ */ diff --git a/src/storage.c b/src/storage.c deleted file mode 100755 index 81894cb..0000000 --- a/src/storage.c +++ /dev/null @@ -1,416 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif - -#define LOG_TAG "CAPI_APPFW_APPLICATION_STORAGE" - -static int storage_initialize(); -static int storage_register_device(storage_device_h device); -static int storage_get_storage(int id, storage_info_h* storage_info); - -extern storage_device_h storage_internal_device(); -extern storage_device_h storage_sdcard_device(); -extern storage_device_h storage_usbhost_device(); - -extern int storage_internal_get_state(); -extern int storage_sdcard_get_state(); -extern int storage_usbhost_get_state(); - -#define STORAGE_MAX 3 -static struct storage_info_s storage_info_table[STORAGE_MAX]; -static int storage_num = 0; - -static int storage_register_device(storage_device_h device) -{ - if (device == NULL) - { - return -1; - } - - if (storage_num >= STORAGE_MAX) - { - LOGE("failed to register device : not enough device table"); - return -1; - } - - storage_info_table[storage_num].id = storage_num; - storage_info_table[storage_num].device = device; - storage_info_table[storage_num].state = device->get_state(); - storage_info_table[storage_num].state_cb = NULL; - storage_info_table[storage_num].state_cb_data = NULL; - - storage_num++; - - return 0; -} - -static int storage_initialize() -{ - storage_device_h dev_internal; - storage_device_h dev_sdcard; - storage_device_h dev_usbhost; - - dev_internal = storage_internal_device(); - storage_register_device(dev_internal); - - dev_sdcard = storage_sdcard_device(); - storage_register_device(dev_sdcard); - - dev_usbhost = storage_usbhost_device(); - storage_register_device(dev_usbhost); - - return 0; -} - -static int storage_get_storage(int id, storage_info_h* storage_info) -{ - int device_state = -1; - - if (storage_num < 1) - { - if (storage_initialize() != 0) - { - return STORAGE_ERROR_NOT_SUPPORTED; - } - } - - if (id < 0 || id >= storage_num) - { - return STORAGE_ERROR_NOT_SUPPORTED; - } - - switch (id) - { - case 0: - device_state = storage_internal_get_state(); - break; - case 1: - device_state = storage_sdcard_get_state(); - break; - case 2: - device_state = storage_usbhost_get_state(); - break; - default: - LOGE("Device statei is invalid"); - break; - } - storage_info_table[id].state = device_state; - *storage_info = &(storage_info_table[id]); - - return STORAGE_ERROR_NONE; -} - -int storage_foreach_device_supported(storage_device_supported_cb callback, void *user_data) -{ - int storage_id = 0; - storage_info_h storage_info = NULL; - bool foreach_next = false; - - if (callback == NULL) - { - LOGE("INVALID_PARAMETER(0x%08x) : invalid callback", STORAGE_ERROR_INVALID_PARAMETER); - return STORAGE_ERROR_INVALID_PARAMETER; - } - - while (true) - { - if (storage_get_storage(storage_id, &storage_info) != 0) - { - break; - } - - storage_id++; - - foreach_next = callback(storage_info->id, storage_info->device->type, storage_info->state, storage_info->device->path, user_data); - - if (foreach_next == false) - { - break; - } - } - - return STORAGE_ERROR_NONE; -} - - -int storage_get_root_directory(int storage, char **path) -{ - storage_info_h storage_info; - - if (path == NULL) - { - LOGE("INVALID_PARAMETER(0x%08x) : invalid output param", STORAGE_ERROR_INVALID_PARAMETER); - return STORAGE_ERROR_INVALID_PARAMETER; - } - - if (storage_get_storage(storage, &storage_info) != 0) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - *path = strdup(storage_info->device->path); - - return STORAGE_ERROR_NONE; -} - - -int storage_get_type(int storage, storage_type_e *type) -{ - storage_info_h storage_info; - - if (type == NULL) - { - LOGE("INVALID_PARAMETER(0x%08x) : invalid output param", STORAGE_ERROR_INVALID_PARAMETER); - return STORAGE_ERROR_INVALID_PARAMETER; - } - - if (storage_get_storage(storage, &storage_info) != 0) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - *type = storage_info->device->type; - - return STORAGE_ERROR_NONE; -} - - -int storage_get_state(int storage, storage_state_e *state) -{ - storage_info_h storage_info; - storage_dev_get_state get_state; - - if (state == NULL) - { - LOGE("INVALID_PARAMETER(0x%08x) : invalid output param", STORAGE_ERROR_INVALID_PARAMETER); - return STORAGE_ERROR_INVALID_PARAMETER; - } - - if (storage_get_storage(storage, &storage_info) != 0) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - get_state = storage_info->device->get_state; - - if (get_state == NULL) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - storage_info->state = get_state(); - - *state = storage_info->state; - - return STORAGE_ERROR_NONE; -} - - -void storage_dispatch_state_event(storage_state_e state, void* data) -{ - storage_info_h storage_info; - storage_state_changed_cb state_cb; - - storage_info = data; - - if (storage_info == NULL) - { - LOGE("INVALID_PARAMETER(0x%08x) : invalid storage information", STORAGE_ERROR_INVALID_PARAMETER); - return; - } - - storage_info->state = state; - state_cb = storage_info->state_cb; - - if (state_cb != NULL) - { - state_cb(storage_info->id, state, storage_info->state_cb_data); - } -} - - -int storage_set_state_changed_cb(int storage, storage_state_changed_cb callback, void *user_data) -{ - storage_info_h storage_info; - storage_dev_set_state_cb set_state_cb; - - if (callback == NULL) - { - LOGE("INVALID_PARAMETER(0x%08x) : invalid callback", STORAGE_ERROR_INVALID_PARAMETER); - return STORAGE_ERROR_INVALID_PARAMETER; - } - - if (storage_get_storage(storage, &storage_info) != 0) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - storage_info->state_cb = callback; - storage_info->state_cb_data = user_data; - - set_state_cb = storage_info->device->set_state_cb; - - if (set_state_cb == NULL) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - if (set_state_cb(storage_info) != 0) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - return STORAGE_ERROR_NONE; -} - - -int storage_unset_state_changed_cb(int storage) -{ - storage_info_h storage_info; - storage_dev_unset_state_cb unset_state_cb; - - if (storage_get_storage(storage, &storage_info) != 0) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - storage_info->state_cb = NULL; - unset_state_cb = storage_info->device->unset_state_cb; - - if (unset_state_cb != NULL) - { - unset_state_cb(); - } - - return STORAGE_ERROR_NONE; -} - - -int storage_get_total_space(int storage, unsigned long long *bytes) -{ - storage_info_h storage_info; - storage_dev_get_space get_space; - - if (bytes == NULL) - { - LOGE("INVALID_PARAMETER(0x%08x) : invalid output param", STORAGE_ERROR_INVALID_PARAMETER); - return STORAGE_ERROR_INVALID_PARAMETER; - } - - if (storage_get_storage(storage, &storage_info) != 0) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - get_space = storage_info->device->get_space; - - if (get_space == NULL) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - if (get_space(bytes, NULL) != 0) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - return STORAGE_ERROR_NONE; -} - -int storage_get_available_space(int storage, unsigned long long *bytes) -{ - storage_info_h storage_info; - storage_dev_get_space get_space; - - if (bytes == NULL) - { - LOGE("INVALID_PARAMETER(0x%08x) : invalid output param", STORAGE_ERROR_INVALID_PARAMETER); - return STORAGE_ERROR_INVALID_PARAMETER; - } - - if (storage_get_storage(storage, &storage_info) != 0) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - get_space = storage_info->device->get_space; - - if (get_space == NULL) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - if (get_space(NULL, bytes) != 0) - { - LOGE("NOT_SUPPORTED(0x%08x) : storage(%d)", STORAGE_ERROR_NOT_SUPPORTED, storage); - return STORAGE_ERROR_NOT_SUPPORTED; - } - - return STORAGE_ERROR_NONE; -} - -int storage_statfs(const char *directory, unsigned long long *total, unsigned long long *available) -{ - struct statfs fs; - - if (statfs(directory, &fs) < 0) - { - LOGE("statfs returns error(%d) directory(%s)\n", errno, directory); - return -1; - } - - if (total != NULL) - { - *total = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_blocks; - } - - if (available != NULL) - { - *available = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_bavail; - } - - return 0; -} - diff --git a/src/storage_internal.c b/src/storage_internal.c deleted file mode 100755 index ef59f29..0000000 --- a/src/storage_internal.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif - -#define LOG_TAG "CAPI_APPFW_APPLICATION_STORAGE" - -#define INTERNAL_MEMORY_PATH tzplatform_getenv(TZ_USER_CONTENT) - -int storage_internal_get_state() -{ - return STORAGE_STATE_MOUNTED; -} - -static int storage_internal_set_state_cb(void *data) -{ - return 0; -} - -static void storage_internal_unset_state_cb() -{ - // empty function -} - -int storage_internal_get_space(unsigned long long *total, unsigned long long *available) -{ - return storage_statfs(INTERNAL_MEMORY_PATH, total, available); -} - -storage_device_h storage_internal_device() -{ - storage_device_h device; - - device = calloc(1, sizeof(struct storage_device_s)); - - if (device == NULL) - { - LOGE("OUT_OF_MEMORY(0x%08x)", STORAGE_ERROR_OUT_OF_MEMORY); - return NULL; - } - - device->type = STORAGE_TYPE_INTERNAL; - device->path = INTERNAL_MEMORY_PATH; - device->get_state = storage_internal_get_state; - device->set_state_cb = storage_internal_set_state_cb; - device->unset_state_cb = storage_internal_unset_state_cb; - device->get_space = storage_internal_get_space; - - return device; -} - diff --git a/src/storage_sdcard.c b/src/storage_sdcard.c deleted file mode 100755 index 3fa1f43..0000000 --- a/src/storage_sdcard.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif - -#define LOG_TAG "CAPI_APPFW_APPLICATION_STORAGE" - -#define SDCARD_PATH "/opt/storage/sdcard" - -int storage_sdcard_get_state() -{ - int sdcard_state = 0; - - vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdcard_state); - - switch (sdcard_state) - { - case VCONFKEY_SYSMAN_MMC_REMOVED: - return STORAGE_STATE_REMOVED; - - case VCONFKEY_SYSMAN_MMC_MOUNTED: - return STORAGE_STATE_MOUNTED; - - case VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED: - return STORAGE_STATE_UNMOUNTABLE; - - default: - return STORAGE_STATE_REMOVED; - } -} - -static void storage_sdcard_state_cb_broker(keynode_t* key, void* data) -{ - storage_state_e state; - state = storage_sdcard_get_state(); - - storage_dispatch_state_event(state, data); -} - -static int storage_sdcard_set_state_cb(void *data) -{ - vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, storage_sdcard_state_cb_broker, data); - return 0; -} - -static void storage_sdcard_unset_state_cb() -{ - vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, storage_sdcard_state_cb_broker); -} - -static int storage_sdcard_get_space(unsigned long long *total, unsigned long long *available) -{ - storage_state_e state; - state = storage_sdcard_get_state(); - - if (state < STORAGE_STATE_MOUNTED) - { - if (total != NULL) - { - *total = 0; - } - - if (available != NULL) - { - *available = 0; - } - - return 0; - } - else - { - return storage_statfs(SDCARD_PATH, total, available); - } -} - -storage_device_h storage_sdcard_device() -{ - storage_device_h device; - - device = calloc(1, sizeof(struct storage_device_s)); - - if (device == NULL) - { - LOGE("OUT_OF_MEMORY(0x%08x)", STORAGE_ERROR_OUT_OF_MEMORY); - return NULL; - } - - device->type = STORAGE_TYPE_EXTERNAL; - device->path = SDCARD_PATH; - device->get_state = storage_sdcard_get_state; - device->set_state_cb = storage_sdcard_set_state_cb; - device->unset_state_cb = storage_sdcard_unset_state_cb; - device->get_space = storage_sdcard_get_space; - - return device; -} - diff --git a/src/storage_usbhost.c b/src/storage_usbhost.c deleted file mode 100755 index 88394e4..0000000 --- a/src/storage_usbhost.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif - -#define LOG_TAG "CAPI_APPFW_APPLICATION_STORAGE" - -#define USBHOST_PATH "/opt/storage/usb" - -int storage_usbhost_get_state() -{ - int usbhost_state = 0; - - vconf_get_int(VCONFKEY_SYSMAN_USB_HOST_STATUS, &usbhost_state); - - switch (usbhost_state) - { - case VCONFKEY_SYSMAN_USB_HOST_DISCONNECTED: - return STORAGE_STATE_REMOVED; - - case VCONFKEY_SYSMAN_USB_HOST_CONNECTED: - return STORAGE_STATE_MOUNTED; - - default: - return STORAGE_STATE_REMOVED; - } -} - -static void storage_usbhost_state_cb_broker(keynode_t* key, void* data) -{ - storage_state_e state; - - state = storage_usbhost_get_state(); - - storage_dispatch_state_event(state, data); -} - -static int storage_usbhost_set_state_cb(void *data) -{ - vconf_notify_key_changed(VCONFKEY_SYSMAN_USB_HOST_STATUS, storage_usbhost_state_cb_broker, data); - return 0; -} - -static void storage_usbhost_unset_state_cb() -{ - vconf_ignore_key_changed(VCONFKEY_SYSMAN_USB_HOST_STATUS, storage_usbhost_state_cb_broker); -} - - -static int storage_usbhost_get_space(unsigned long long *total, unsigned long long *available) -{ - storage_state_e state; - state = storage_usbhost_get_state(); - - if (state < STORAGE_STATE_MOUNTED) - { - if (total != NULL) - { - *total = 0; - } - - if (available != NULL) - { - *available = 0; - } - - return 0; - } - else - { - return storage_statfs(USBHOST_PATH, total, available); - } -} - - -storage_device_h storage_usbhost_device() -{ - storage_device_h device; - - device = calloc(1, sizeof(struct storage_device_s)); - - if (device == NULL) - { - LOGE("OUT_OF_MEMORY(0x%08x)", STORAGE_ERROR_OUT_OF_MEMORY); - return NULL; - } - - device->type = STORAGE_TYPE_EXTERNAL; - device->path = USBHOST_PATH; - device->get_state = storage_usbhost_get_state; - device->set_state_cb = storage_usbhost_set_state_cb; - device->unset_state_cb = storage_usbhost_unset_state_cb; - device->get_space = storage_usbhost_get_space; - - return device; -} - -- 2.7.4