#include "media-common-types.h"
#define INTERNAL_STORAGE_ID "media"
-#define USB_STORAGE_REMOVED "usb_removed"
+#define STORAGE_REMOVED "storage_removed"
#define DATADISC_STORAGE_ID "data_disc"
typedef struct ms_dir_info_s {
#define BLOCK_DEVICE_MMC "mmc"
#define BLOCK_DEVICE_ALL "all"
-static GDBusConnection *g_usb_bus;
+static GDBusConnection *g_storage_bus;
-static int g_usb_handler;
+static int g_storage_handler;
typedef struct block_cb_data {
block_changed_cb usr_cb;
void *usr_data;
} block_cb_data;
-block_cb_data *g_usb_cb_data = NULL;
+block_cb_data *g_stg_cb_data = NULL;
static void __ms_block_changed(GDBusConnection* connection,
const gchar* sender_name,
GVariant* parameters,
gpointer user_data)
{
- const char *devnode = NULL;
const char *mount_path = NULL;
const char *mount_uuid = NULL;
GVariant *tmp;
block_info->block_type = g_variant_get_int32(tmp);
MS_DBG_INFO("block_type : %d", block_info->block_type);
- tmp = g_variant_get_child_value(parameters, 1);
- devnode = g_variant_get_string(tmp, &size);
- MS_DBG_INFO("devnode : %s", devnode);
-
tmp = g_variant_get_child_value(parameters, 6);
mount_uuid = g_variant_get_string(tmp, &size);
if (mount_uuid != NULL) {
MS_DBG_FENTER();
- g_usb_cb_data = malloc(sizeof(block_cb_data));
- if (g_usb_cb_data == NULL) {
+ g_stg_cb_data = malloc(sizeof(block_cb_data));
+ if (g_stg_cb_data == NULL) {
MS_DBG_ERR("malloc failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
- g_usb_cb_data->usr_cb = usr_callback;
- g_usb_cb_data->usr_data = usr_data;
+ g_stg_cb_data->usr_cb = usr_callback;
+ g_stg_cb_data->usr_data = usr_data;
- if (g_usb_bus == NULL) {
- g_usb_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (!g_usb_bus) {
+ if (g_storage_bus == NULL) {
+ g_storage_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (!g_storage_bus) {
MS_DBG_ERR("Failed to connect to the g D-BUS daemon: %s", error->message);
g_error_free(error);
ret = MS_MEDIA_ERR_INTERNAL;
}
/* listening to messages from all objects as no path is specified */
- g_usb_handler = g_dbus_connection_signal_subscribe(
- g_usb_bus,
+ g_storage_handler = g_dbus_connection_signal_subscribe(
+ g_storage_bus,
NULL,
DEVICED_INTERFACE_BLOCK_MANAGER,
BLOCK_DEVICE_CHANGED,
NULL,
G_DBUS_SIGNAL_FLAGS_NONE,
__ms_block_changed,
- g_usb_cb_data,
+ g_stg_cb_data,
NULL);
MS_DBG_FLEAVE();
ERROR:
- if (g_usb_bus != NULL) {
- g_object_unref(g_usb_bus);
- g_usb_bus = NULL;
+ if (g_storage_bus != NULL) {
+ g_object_unref(g_storage_bus);
+ g_storage_bus = NULL;
}
- MS_SAFE_FREE(g_usb_cb_data);
+ MS_SAFE_FREE(g_stg_cb_data);
MS_DBG_FLEAVE();
#ifdef _USE_DEVICED_DBUS
int ms_sys_unset_device_block_event_cb(void)
{
- if (g_usb_bus == NULL)
+ if (g_storage_bus == NULL)
return MS_MEDIA_ERR_NONE;
- g_dbus_connection_signal_unsubscribe(g_usb_bus, g_usb_handler);
- g_object_unref(g_usb_bus);
- g_usb_bus = NULL;
+ g_dbus_connection_signal_unsubscribe(g_storage_bus, g_storage_handler);
+ g_object_unref(g_storage_bus);
+ g_storage_bus = NULL;
/*Release Callback*/
- MS_SAFE_FREE(g_usb_cb_data);
+ MS_SAFE_FREE(g_stg_cb_data);
return MS_MEDIA_ERR_NONE;
}
#include "media-common-system.h"
-int ms_usb_insert_handler(const char *mount_path, const char *mount_uuid);
-int ms_usb_remove_handler(const char *mount_path, const char *mount_uuid);
+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);
#ifdef _USE_DEVICED_DBUS
void ms_device_block_changed_cb(ms_block_info_s *block_info, void *user_data);
#else
}
#endif
-int ms_usb_insert_handler(const char *mount_path, const char *mount_uuid)
+int ms_storage_insert_handler(const char *mount_path, const char *mount_uuid)
{
int ret = MS_MEDIA_ERR_NONE;
char *storage_path = NULL;
return ret;
}
-int ms_usb_remove_handler(const char *mount_path, const char *mount_uuid)
+int ms_storage_remove_handler(const char *mount_path, const char *mount_uuid)
{
int ret = MS_MEDIA_ERR_NONE;
void **handle = NULL;
ms_disconnect_db(&handle);
ms_unload_functions();
- } else if (mount_path != NULL && strncmp(mount_path, USB_STORAGE_REMOVED, strlen(USB_STORAGE_REMOVED)) == 0) {
+ } 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;
}
-void _ms_usb_changed_event(const char *mount_path, const char *mount_uuid, ms_stg_status_e mount_status)
-{
- if (mount_status == MS_STG_INSERTED) {
- if (mount_path != NULL && mount_uuid != NULL) {
- MS_DBG("usb_mount_path[%s], usb_mount_uuid[%s]", mount_path, mount_uuid);
- ms_usb_insert_handler(mount_path, mount_uuid);
- } else {
- MS_DBG_ERR("usb_mount_path[%s] or usb_mount_uuid[%s] is NULL", mount_path, mount_uuid);
- return;
- }
- } else if (mount_status == MS_STG_REMOVED) {
- if (mount_path != NULL && mount_uuid != NULL) {
- MS_DBG("usb_mount_path[%s], usb_mount_uuid[%s]", mount_path, mount_uuid);
- ms_usb_remove_handler(mount_path, mount_uuid);
- } else {
- MS_DBG_ERR("usb_mount_path[%s] or usb_mount_uuid[%s] is NULL", mount_path, mount_uuid);
- return;
- }
- }
-
- return;
-}
-
#ifdef _USE_DEVICED_DBUS
void ms_device_block_changed_cb(ms_block_info_s *block_info, void *user_data)
{
MS_DBG_WARN("GET EXTERNAL EVENT");
- _ms_usb_changed_event(block_info->mount_path, block_info->mount_uuid, block_info->state);
+ if (block_info->mount_path != NULL && block_info->mount_uuid != NULL) {
+ MS_DBG("uuid[%s] path[%s]", block_info->mount_uuid, block_info->mount_path);
+ if (block_info->state == MS_STG_INSERTED)
+ ms_storage_insert_handler(block_info->mount_path, block_info->mount_uuid);
+ else if (block_info->state == MS_STG_REMOVED)
+ ms_storage_remove_handler(block_info->mount_path, block_info->mount_uuid);
+ } else {
+ MS_DBG_ERR("mount_path or mount_uuid is NULL");
+ }
}
#else
static void __ms_usb_add_event(const char *mount_path)
bool smarthub_reset;
static void __ms_check_mediadb(void);
-static int __ms_check_usb_status(void);
+static int __ms_check_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_usb_status(void)
+static int __ms_check_storage_status(void)
{
int ret = MS_MEDIA_ERR_NONE;
ms_stg_type_e stg_type = MS_STG_TYPE_ALL;
for (i = 0; i < dev_num; i++) {
block_info = (ms_block_info_s *)g_array_index(dev_list , ms_stg_type_e*, i);
- ms_usb_insert_handler(block_info->mount_path, block_info->mount_uuid);
+ 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_usb_remove_handler(USB_STORAGE_REMOVED, NULL);
+ ms_storage_remove_handler(STORAGE_REMOVED, NULL);
}
} else {
MS_DBG_ERR("ms_sys_get_device_list failed");
#endif
/* update external storage */
- __ms_check_usb_status();
+ __ms_check_storage_status();
#ifdef _USE_SENIOR_MODE
__ms_check_disc_status();