From: Minje Ahn Date: Fri, 13 Apr 2018 00:38:25 +0000 (+0900) Subject: Remove USB keyword from function X-Git-Tag: submit/tizen/20180511.003859~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dc6f63e85645f2b9481f41a50e0ea1f5bb18a63e;p=platform%2Fcore%2Fmultimedia%2Fmedia-server.git Remove USB keyword from function Remove or change name(except scanner-v2 and v2 related function) Change-Id: Ic898799c8a0db5f7b29621f0df9fbd4af3635a29 Signed-off-by: Minje Ahn --- diff --git a/src/common/include/media-common-db-svc.h b/src/common/include/media-common-db-svc.h index bd2f927..1e7f0ef 100755 --- a/src/common/include/media-common-db-svc.h +++ b/src/common/include/media-common-db-svc.h @@ -27,7 +27,7 @@ #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 { diff --git a/src/common/media-common-system.c b/src/common/media-common-system.c index 96d6e94..176b0da 100755 --- a/src/common/media-common-system.c +++ b/src/common/media-common-system.c @@ -49,16 +49,16 @@ #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, @@ -68,7 +68,6 @@ static void __ms_block_changed(GDBusConnection* connection, GVariant* parameters, gpointer user_data) { - const char *devnode = NULL; const char *mount_path = NULL; const char *mount_uuid = NULL; GVariant *tmp; @@ -88,10 +87,6 @@ static void __ms_block_changed(GDBusConnection* connection, 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) { @@ -125,18 +120,18 @@ static int __ms_sys_subscribe_device_block_event(block_changed_cb usr_callback, 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; @@ -145,8 +140,8 @@ static int __ms_sys_subscribe_device_block_event(block_changed_cb usr_callback, } /* 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, @@ -154,7 +149,7 @@ static int __ms_sys_subscribe_device_block_event(block_changed_cb usr_callback, NULL, G_DBUS_SIGNAL_FLAGS_NONE, __ms_block_changed, - g_usb_cb_data, + g_stg_cb_data, NULL); MS_DBG_FLEAVE(); @@ -163,12 +158,12 @@ static int __ms_sys_subscribe_device_block_event(block_changed_cb usr_callback, 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(); @@ -215,15 +210,15 @@ int ms_sys_set_device_block_event_cb(usb_connected_cb usr_callback, void *usr_da #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; } diff --git a/src/server/include/media-server-device-block.h b/src/server/include/media-server-device-block.h index fbba264..316710b 100755 --- a/src/server/include/media-server-device-block.h +++ b/src/server/include/media-server-device-block.h @@ -23,8 +23,8 @@ #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 diff --git a/src/server/media-server-device-block.c b/src/server/media-server-device-block.c index 44a0f90..4302002 100755 --- a/src/server/media-server-device-block.c +++ b/src/server/media-server-device-block.c @@ -57,7 +57,7 @@ static int __ms_get_added_storage_path(void **handle, const char *add_path, char } #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; @@ -135,7 +135,7 @@ ERROR: 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; @@ -156,7 +156,7 @@ int ms_usb_remove_handler(const char *mount_path, const char *mount_uuid) 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); @@ -175,35 +175,20 @@ int ms_usb_remove_handler(const char *mount_path, const char *mount_uuid) 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) diff --git a/src/server/media-server-main.c b/src/server/media-server-main.c index e93e23b..600bad0 100755 --- a/src/server/media-server-main.c +++ b/src/server/media-server-main.c @@ -53,7 +53,7 @@ bool smarthub_reset_start; 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); @@ -601,7 +601,7 @@ static void __ms_add_signal_handler(void) } //////////////////////////////////////////////////////////////////// -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; @@ -617,13 +617,13 @@ static int __ms_check_usb_status(void) 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"); @@ -780,7 +780,7 @@ static void __ms_check_mediadb(void) #endif /* update external storage */ - __ms_check_usb_status(); + __ms_check_storage_status(); #ifdef _USE_SENIOR_MODE __ms_check_disc_status();