#ifdef _USE_DEVICED_DBUS
int ms_sys_get_device_list(ms_stg_type_e stg_type, GArray **dev_list)
{
- int ret;
+ int ret = MS_MEDIA_ERR_NONE;
const char *dev_params[MS_STG_TYPE_MAX] = { BLOCK_DEVICE_USB,
BLOCK_DEVICE_MMC,
BLOCK_DEVICE_ALL,
#else
int ms_sys_get_device_list(ms_stg_type_e stg_type, GArray **dev_list)
{
- int ret = MS_MEDIA_ERR_NONE;
int i = 0;
int count = 0;
int err = 0;
usb_device_h device;
char *mount_path = NULL;
- ret = ms_load_functions();
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_load_functions failed [%d]", ret);
- return ret;
- }
-
err = usb_device_get_device_list(USB_MASS_STORAGE, &list);
if (err == 0) {
count = usb_device_list_get_count(list);
usb_device_free_device_list(list);
} else {
MS_DBG_ERR("usb_device_get_device_list falied [%d]", err);
- ret = MS_MEDIA_ERR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
- ms_unload_functions();
-
- return ret;
+ return MS_MEDIA_ERR_NONE;
}
#endif
#include "media-common-system.h"
int ms_storage_insert_handler(const char *mount_path, const char *mount_uuid);
-int ms_storage_remove_handler(const char *mount_path, const char *mount_uuid);
+void ms_storage_remove_handler(const char *mount_path, const char *mount_uuid);
#ifdef _USE_DEVICED_DBUS
void ms_device_block_changed_cb(ms_block_info_s *block_info, void *user_data);
#else
static int __ms_remake_mediadb(uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
sqlite3 *handle = NULL;
MS_DBG_ERR("THE SIZE OF MEDIA DB REACH THE LIMIT. RESET MEDIA DB.");
/*write read schema*/
- /*load functions from plusin(s)*/
- err = ms_load_functions();
- if (err != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("function load failed [%d]", err);
- return err;
- }
#ifdef _USE_TVPD_MODE
ms_config_set_int(MS_DB_RESET, 1);
#endif
/*disconnect form media db*/
if (handle) ms_disconnect_db(handle);
- /*unload functions*/
- ms_unload_functions();
-
#ifdef _USE_TVPD_MODE
ms_config_set_int(MS_DB_RESET, 0);
#endif
uid_t uid = MEDIA_DEFAULT_UID;
ms_dir_scan_type_t scan_type = MS_SCAN_ALL;
- ret = ms_load_functions();
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_load_functions failed [%d]", ret);
- return ret;
- }
-
ms_sys_get_uid(&uid);
ms_connect_db(&handle, uid);
ms_disconnect_db(handle);
- ms_unload_functions();
-
return ret;
}
-int ms_storage_remove_handler(const char *mount_path, const char *mount_uuid)
+void ms_storage_remove_handler(const char *mount_path, const char *mount_uuid)
{
- int ret = MS_MEDIA_ERR_NONE;
sqlite3 *handle = NULL;
uid_t uid = MEDIA_DEFAULT_UID;
if (mount_path != NULL && mount_uuid != NULL) {
- ret = ms_load_functions();
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_load_functions failed [%d]", ret);
- return ret;
- }
-
ms_sys_get_uid(&uid);
ms_connect_db(&handle, uid);
ms_set_storage_validity(handle, mount_uuid, 0, uid);
ms_send_storage_otg_scan_request(mount_path, mount_uuid, MS_SCAN_INVALID, uid);
ms_disconnect_db(handle);
-
- ms_unload_functions();
} else if (mount_path != NULL && g_strcmp0(mount_path, STORAGE_REMOVED) == 0) {
- ret = ms_load_functions();
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_load_functions failed [%d]", ret);
- return ret;
- }
-
ms_sys_get_uid(&uid);
ms_connect_db(&handle, uid);
ms_set_all_storage_validity(handle, 0, uid);
ms_disconnect_db(handle);
-
- ms_unload_functions();
}
- return ret;
}
#ifdef _USE_DEVICED_DBUS
ms_dir_scan_type_t scan_type = MS_SCAN_ALL;
uid_t uid = MEDIA_DEFAULT_UID;
- ret = ms_load_functions();
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_load_functions failed [%d]", ret);
- return;
- }
-
ms_connect_db(&handle, uid);
if (mount_path != NULL) {
ms_disconnect_db(handle);
- ms_unload_functions();
-
return;
}
uid_t uid = MEDIA_DEFAULT_UID;
if (mount_path != NULL) {
- ret = ms_load_functions();
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_load_functions failed [%d]", ret);
- return;
- }
ms_connect_db(&handle, uid);
}
ms_disconnect_db(handle);
-
- ms_unload_functions();
}
return;
sqlite3 *handle = NULL;
int err;
- /*load functions from plusin(s)*/
- err = ms_load_functions();
- if (err != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("function load failed [%d]", err);
- return ret;
- }
-
ms_connect_db(&handle, uid);
ret = __ms_check_mounted_storage_list(&added_list);
if (strcmp(disc_type, valid_type) == 0) {
ms_config_get_int(MS_DISC_STATE, &disc_state);
- ret = ms_load_functions();
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_load_functions failed [%d]", ret);
- return;
- }
-
/* request scanning */
ms_sys_get_uid(&uid);
}
ms_disconnect_db(handle);
-
- ms_unload_functions();
}
END:
GIOChannel *channel = NULL;
bool is_dcm_supported = __ms_is_dcm_supported();
power_off = false;
+ int ret = 0;
+
+ ret = ms_load_functions();
+ if (ret != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("ms_load_functions failed [%d]", ret);
+ return -1;
+ }
#ifdef _USE_TVPD_MODE
uid_t uid = MEDIA_DEFAULT_UID;
__ms_new_global_variable();
if (ms_cynara_initialize() != MS_MEDIA_ERR_NONE) {
+ ms_unload_functions();
MS_DBG_ERR("Failed to initialize cynara");
return -1;
}
g_thread_join(dcm_thread);
ms_cynara_finish();
+ ms_unload_functions();
__ms_free_global_variable();
memset(mnt_path, 0x0, sizeof(mnt_path));
SAFE_STRLCPY(mnt_path, disc_path, sizeof(mnt_path));
- ret = ms_load_functions();
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_load_functions failed [%d]", ret);
- goto END;
- }
-
/* request scanning */
ms_sys_get_uid(&uid);
ret = ms_insert_storage(handle, DATADISC_STORAGE_ID, mnt_path, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_insert_storage failed");
- ms_unload_functions();
goto END;
}
}
ms_send_storage_scan_request(mnt_path, DATADISC_STORAGE_ID, scan_type, uid);
ms_disconnect_db(handle);
-
- ms_unload_functions();
}
}
sqlite3 *db_handle = NULL;
int ret = MS_MEDIA_ERR_NONE;
- ret = ms_load_functions();
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_load_functions failed [%d]", ret);
- return;
- }
-
ms_sys_get_uid(&uid);
ret = ms_connect_db(&db_handle, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_connect_db failed [%d]", ret);
- ms_unload_functions();
return;
}
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_check_db_upgrade failed [%d]", ret);
ms_disconnect_db(db_handle);
- ms_unload_functions();
return;
}
#endif
ms_disconnect_db(db_handle);
- ms_unload_functions();
#endif
/* update external storage */
return MS_MEDIA_ERR_NONE;
}
-static int __ms_recovery_media_db(uid_t uid)
+static void __ms_recovery_media_db(uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
sqlite3 *handle = NULL;
/* stop the child process */
ms_reset_mediadb(uid);
/*write read schema*/
- /*load functions from plugin(s)*/
- err = ms_load_functions();
- if (err != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("function load failed [%d]", err);
- return err;
- }
-
ms_connect_db(&handle, uid);
MS_DBG_WARN("START WRITE SCHEMA");
/*disconnect form media db*/
if (handle) ms_disconnect_db(handle);
- /*unload functions*/
- ms_unload_functions();
-
#ifdef _USE_TVPD_MODE
ms_check_mounted_storage(uid);
ms_config_set_int(MS_DB_RESET, 0);
#endif
- return MS_MEDIA_ERR_NONE;
+
}
gboolean ms_read_socket(GIOChannel *src, GIOCondition condition, gpointer user_data)
break;
case MS_MSG_MEDIA_DB_MALFORMED:
/*media DB is corrupted, recovery media DB*/
- ret = __ms_recovery_media_db(recv_msg.uid);
+ __ms_recovery_media_db(recv_msg.uid);
goto ERROR;
default:
close(client_sock);