#endif
int ms_sys_unset_device_block_event_cb(void);
int ms_sys_get_device_list(ms_stg_type_e stg_type, GArray **dev_list);
-int ms_sys_release_device_list(GArray **dev_list);
typedef struct ms_power_info_s {
int option;
dlerror(); /* Clear any existing error */
MS_MALLOC(func_array, sizeof(void*) * eFUNC_MAX);
- if (func_array == NULL) {
+ if (!func_array) {
MS_DBG_ERR("malloc failed");
dlclose(func_handle);
void ms_disconnect_db(sqlite3 *handle)
{
- if (handle)
- media_db_disconnect(handle);
+ media_db_disconnect(handle);
}
int ms_cleanup_db(sqlite3 *handle, uid_t uid)
{
- int ret;
+ int ret = MS_MEDIA_ERR_NONE;
ret = ((CLEANUP_DB)func_array[eCLEANUP_DB])(handle, uid); /*dlopen*/
MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "CLEANUP_DB failed [%d]", ret);
MS_DBG_INFO("Cleanup Media DB");
- return MS_MEDIA_ERR_NONE;
+ return ret;
}
int __ms_check_item_exist(sqlite3 *handle, const char *storage_id, const char *path, bool *modified)
}
#endif
+static void __ms_dev_free(gpointer data)
+{
+ ms_block_info_s **_data = (ms_block_info_s **)data;
+
+ MS_SAFE_FREE((*_data)->mount_path);
+ MS_SAFE_FREE((*_data)->mount_uuid);
+ MS_SAFE_FREE(*_data);
+}
+
#ifdef _USE_DEVICED_DBUS
#define DBUS_REPLY_TIMEOUT (-1)
static int __ms_gdbus_method_sync(const char *dest, const char *path, const char *interface, const char *method, const char *param, GArray **dev_list)
if (*dev_list == NULL) {
MS_DBG_ERR("DEV LIST IS NULL");
*dev_list = g_array_new(FALSE, FALSE, sizeof(ms_block_info_s*));
+ g_array_set_clear_func(*dev_list, __ms_dev_free);
}
g_array_append_val(*dev_list, data);
}
if (*dev_list == NULL) {
MS_DBG_ERR("DEV LIST IS NULL");
*dev_list = g_array_new(FALSE, FALSE, sizeof(ms_block_info_s*));
+ g_array_set_clear_func(*dev_list, __ms_dev_free);
}
for (i = 0; i < count; i++) {
}
#endif
-int ms_sys_release_device_list(GArray **dev_list)
-{
- if (*dev_list) {
- while ((*dev_list)->len != 0) {
- ms_block_info_s *data = NULL;
- data = g_array_index(*dev_list , ms_block_info_s*, 0);
- g_array_remove_index(*dev_list, 0);
-
- if (data != NULL) {
- MS_DBG("MOUNT PATH [%s] RELEASED", data->mount_path);
- MS_SAFE_FREE(data->mount_path);
- MS_SAFE_FREE(data->mount_uuid);
- MS_SAFE_FREE(data);
- }
- }
- g_array_free(*dev_list, FALSE);
- *dev_list = NULL;
- }
-
- return MS_MEDIA_ERR_NONE;
-}
-
//////////////////////////////////////////////////////////////////////////////
/// GET ACTIVATE USER ID
//////////////////////////////////////////////////////////////////////////////
/* This is an array for storing the path of insert datas*/
_path_array = g_ptr_array_new_with_free_func(g_free);
if (!_path_array) {
- MS_DBG_ERR("g_array_new failed");
+ MS_DBG_ERR("g_ptr_array_new_with_free_func failed");
fclose(fp);
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
void ms_device_block_changed_cb(ms_block_info_s *block_info, void *user_data);
#else
void ms_device_block_changed_cb(usb_device_h usb_device, char *action, void *user_data);
-#endif
int ms_check_mounted_storage(uid_t uid);
+#endif
#endif
return ret;
}
-#endif
int ms_check_mounted_storage(uid_t uid)
{
ms_connect_db(&handle, uid);
-#ifdef _USE_DEVICED_DBUS
- ret = ms_sys_get_device_list(MS_STG_TYPE_ALL, &added_list);
-#else
ret = __ms_check_mounted_storage_list(&added_list);
-#endif
if (ret != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("__ms_check_mounted_storage_list failed");
return ret;
}
+#endif
bool smarthub_reset;
static void __ms_check_mediadb(void);
-static int __ms_check_storage_status(void);
+static void __ms_update_storage_status(void);
static void __ms_add_signal_handler(void);
static void __ms_add_event_receiver(GIOChannel *channel);
static void __ms_add_request_receiver(GMainLoop *mainloop, GIOChannel **channel);
}
////////////////////////////////////////////////////////////////////
-static int __ms_check_storage_status(void)
+static void __ms_update_storage_status(void)
{
int ret = MS_MEDIA_ERR_NONE;
- ms_stg_type_e stg_type = MS_STG_TYPE_ALL;
GArray *dev_list = NULL;
+ ms_block_info_s *block_info = NULL;
+ int i = 0;
- ret = ms_sys_get_device_list(stg_type, &dev_list);
- if (ret == MS_MEDIA_ERR_NONE) {
- if (dev_list != NULL) {
- MS_DBG_WARN("External storage found[%d]", dev_list->len);
- int i = 0 ;
- int dev_num = dev_list->len;
- ms_block_info_s *block_info = NULL;
-
- for (i = 0; i < dev_num; i++) {
- block_info = (ms_block_info_s *)g_array_index(dev_list , ms_stg_type_e*, i);
- ms_storage_insert_handler(block_info->mount_path, block_info->mount_uuid);
- }
-
- ms_sys_release_device_list(&dev_list);
- } else {
- MS_DBG_ERR("External storage not found");
- ms_storage_remove_handler(STORAGE_REMOVED, NULL);
- }
- } else {
+ ret = ms_sys_get_device_list(MS_STG_TYPE_ALL, &dev_list);
+ if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_sys_get_device_list failed");
+ return;
}
- return MS_MEDIA_ERR_NONE;
+ if (!dev_list) {
+ MS_DBG_ERR("External storage not found");
+ ms_storage_remove_handler(STORAGE_REMOVED, NULL);
+ return;
+ }
+
+ MS_DBG_WARN("External storage found[%d]", dev_list->len);
+
+ for (i = 0; i < dev_list->len; i++) {
+ block_info = g_array_index(dev_list , ms_block_info_s *, i);
+ ms_storage_insert_handler(block_info->mount_path, block_info->mount_uuid);
+ }
+
+ g_array_free(dev_list, TRUE);
}
#ifdef _USE_SENIOR_MODE
#endif
/* update external storage */
- __ms_check_storage_status();
+ __ms_update_storage_status();
#ifdef _USE_SENIOR_MODE
__ms_check_disc_status();
/*unload functions*/
ms_unload_functions();
- ms_check_mounted_storage(uid);
#ifdef _USE_TVPD_MODE
+ ms_check_mounted_storage(uid);
ms_config_set_int(MS_DB_RESET, 0);
#endif
return MS_MEDIA_ERR_NONE;