increase code quality 45/240145/1
authorYoungjae Shin <yj99.shin@samsung.com>
Tue, 4 Aug 2020 02:20:16 +0000 (11:20 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Tue, 4 Aug 2020 02:30:36 +0000 (11:30 +0900)
add const
separate big function

Change-Id: I26c6287e7b9fd4f87f3e22a84c290b97bb5f0eec

15 files changed:
app/applog.h
app/bt-share-common.c
app/bt-share-common.h
app/bt-share-ipc.c
app/bt-share-ipc.h
app/bt-share-main.c
app/bt-share-main.h
app/bt-share-notification.c
app/bt-share-notification.h
app/obex-event-handler.c
lib/applog.h
lib/bluetooth-share-api.h
tests/CMakeLists.txt
tests/bt-share-test.cpp [moved from tests/bluetooth-share_test.cpp with 75% similarity]
tests/mock/bt-share-mock.c [moved from tests/mock/bluetooth-share-mock.c with 99% similarity]

index 5753b7a..cf62fe6 100644 (file)
 extern "C" {
 #endif
 
-/*
- * SYSLOG_INFO(), SYSLOG_ERR(), SYSLOG_DBG() are syslog() wrappers.
- * PRT_INFO(), PRT_ERR(), PRT_DBG() are fprintf() wrappers.
- *
- * If SLP_DEBUG is not defined, SYSLOG_DBG() and PRT_DBG() is ignored.
- *
- * IF SLP_SYSLOG_OUT or SLP_DAEMON is defined,
- *   INFO(), ERR(), DBG() are SYSLOG_XXX()
- * Otherwise,
- *   They are PRT_XXX()
- *
- *
- * warn_if(exrp, fmt, ...)
- *   If expr is true, The fmt string is printed using ERR().
- *
- * ret_if(), retv_if(), retm_if(), retvm_if()
- *   If expr is true, current function return.
- *   Postfix 'v' means that it has a return value and
- *   'm' means that it has output message.
- *
- */
-
 #include <stdio.h>
 #include <dlog.h>
 
index e68b6ee..844ffd3 100644 (file)
@@ -180,7 +180,7 @@ static char *__bt_share_get_transfer_file_name(int file_type)
        return file;
 }
 
-void _bt_remove_tmp_file(char *file_path)
+void _bt_remove_tmp_file(const char *file_path)
 {
        if (g_str_has_prefix(file_path, BT_TMP_DIR) == TRUE) {
                DBG_SECURE("Remove the file: %s", file_path);
@@ -188,7 +188,7 @@ void _bt_remove_tmp_file(char *file_path)
        }
 }
 
-void _bt_remove_vcf_file(char *file_path)
+void _bt_remove_vcf_file(const char *file_path)
 {
        if (g_str_has_prefix(file_path, BT_CONTACT_SHARE_TMP_DIR) == TRUE) {
                DBG_SECURE("Remove the file: %s", file_path);
@@ -196,7 +196,7 @@ void _bt_remove_vcf_file(char *file_path)
        }
 }
 
-char *_bt_share_create_transfer_file(char *text)
+char *_bt_share_create_transfer_file(const char *text)
 {
        retv_if(text == NULL, NULL);
 
index e3f2aae..dc6406c 100644 (file)
@@ -76,9 +76,9 @@ typedef enum {
 
 int _bt_share_block_sleep(gboolean is_block);
 int _bt_set_transfer_indicator(gboolean state);
-char *_bt_share_create_transfer_file(char *text);
-void _bt_remove_tmp_file(char *file_path);
-void _bt_remove_vcf_file(char *file_path);
+char *_bt_share_create_transfer_file(const char *text);
+void _bt_remove_tmp_file(const char *file_path);
+void _bt_remove_vcf_file(const char *file_path);
 char *_bt_get_time_of_the_day(void);
 void _bt_get_default_storage(char *storage);
 char *_bt_share_get_storage_path(int storage_type);
index c47bda0..9a9c4c9 100644 (file)
@@ -537,8 +537,8 @@ void _bt_deinit_dbus_signal(void)
        FN_END;
 }
 
-void _bt_send_disconnected_signal(char *signal, int result,
-               char *address, int transfer_id)
+void _bt_send_disconnected_signal(const char *signal, int result,
+               const char *address, int transfer_id)
 {
        FN_START;
        retm_if(gdbus_connection == NULL, "gdbus_connection == NULL");
@@ -562,7 +562,7 @@ void _bt_send_disconnected_signal(char *signal, int result,
        FN_END;
 }
 
-void _bt_update_transfer_list_view(char *db)
+void _bt_update_transfer_list_view(const char *db)
 {
        ret_if(gdbus_connection == NULL);
 
@@ -727,7 +727,7 @@ static void __bt_create_send_data(opc_transfer_info_t *node)
 /* LCOV_EXCL_STOP */
 
 gboolean _bt_update_sent_data_status(int uid,
-                               bt_app_tr_status_e status, char *db_sid)
+                               bt_app_tr_status_e status, const char *db_sid)
 {
        INFO("uid = %d", uid);
        sqlite3 *db = NULL;
@@ -750,7 +750,7 @@ gboolean _bt_update_sent_data_status(int uid,
 }
 
 gboolean _bt_update_recv_data_status(int uid,
-               bt_app_tr_status_e status, char *db_sid,
+               bt_app_tr_status_e status, const char *db_sid,
                unsigned int filesize, const char *mime_type)
 {
        INFO("uid = %d", uid);
@@ -776,7 +776,7 @@ gboolean _bt_update_recv_data_status(int uid,
 }
 
 gboolean _bt_update_multiple_sent_data_status(int *uids, int uid_cnt,
-                               bt_app_tr_status_e status, char *db_sid)
+                               bt_app_tr_status_e status, const char *db_sid)
 {
        sqlite3 *db = NULL;
        bt_tr_data_t *tmp = NULL;
@@ -795,9 +795,9 @@ gboolean _bt_update_multiple_sent_data_status(int *uids, int uid_cnt,
        return TRUE;
 }
 
-gboolean _bt_add_recv_transfer_status_data(char *device_name,
-                       char *address, char *filepath, char *type,
-                       unsigned int size, int status, char *db_sid)
+gboolean _bt_add_recv_transfer_status_data(const char *device_name,
+       const char *address, const char *filepath, const char *type,
+       unsigned int size, int status, const char *db_sid)
 {
        retv_if(device_name == NULL || filepath == NULL, FALSE);
 
index 853833a..635e46b 100644 (file)
@@ -91,21 +91,21 @@ void _remove_transfer_info(opc_transfer_info_t *node);
 
 void _bt_create_warning_popup(int error_type, char *msg);
 gboolean _bt_update_sent_data_status(int uid,
-                               bt_app_tr_status_e status, char *db_sid);
+                               bt_app_tr_status_e status, const char *db_sid);
 
 gboolean _bt_update_recv_data_status(int uid,
-               bt_app_tr_status_e status, char *db_sid,
+               bt_app_tr_status_e status, const char *db_sid,
                unsigned int filesize, const char *mime_type);
 
 gboolean _bt_update_multiple_sent_data_status(int *uids, int uid_cnt,
-                               bt_app_tr_status_e status, char *db_sid);
+                               bt_app_tr_status_e status, const char *db_sid);
 
-void _bt_update_transfer_list_view(char *db);
-void _bt_send_disconnected_signal(char *signal, int result, char *address,
+void _bt_update_transfer_list_view(const char *db);
+void _bt_send_disconnected_signal(const char *signal, int result, const char *address,
                int transfer_id);
-gboolean _bt_add_recv_transfer_status_data(char *device_name,
-                       char *address, char *filepath, char *type,
-                       unsigned int size, int status, char *db_sid);
+gboolean _bt_add_recv_transfer_status_data(const char *device_name,
+       const char *address, const char *filepath, const char *type,
+       unsigned int size, int status, const char *db_sid);
 int _bt_share_get_unique_id(int db_table, const char *db_sid);
 int _bt_set_eventsystem_transfer_value(gboolean value);
 
index 65bb335..c9a6228 100644 (file)
@@ -265,7 +265,7 @@ void _bt_remove_temporary_files_by_noti_id(sqlite3 *db, int noti_id)
 }
 
 /* LCOV_EXCL_START */
-gboolean __bt_clean_database(gpointer user_data)
+static gboolean __bt_clean_database(gpointer user_data)
 {
        bt_appdata_t *ad = app_state;
        notification_h noti = NULL;
index d8e6048..6af5f38 100644 (file)
@@ -28,7 +28,7 @@ extern "C" {
 #include <gio/gio.h>
 #include <notification.h>
 #include <tzplatform_config.h>
-#include <db-util.h>
+#include <sqlite3.h>
 
 #ifndef PACKAGE_NAME
 #define PACKAGE_NAME "bluetooth-share"
@@ -70,9 +70,7 @@ typedef struct {
 } bt_appdata_t;
 
 int _bt_init_obex_server(void);
-
 void _bt_terminate_bluetooth_share(void);
-
 void _bt_remove_temporary_files_by_noti_id(sqlite3 *db, int noti_id);
 
 #ifdef __cplusplus
index b59eae3..3421bad 100644 (file)
@@ -122,8 +122,8 @@ void _bt_insert_instant_notification(bt_notification_type_e type)
 }
 
 notification_h _bt_insert_notification(bt_appdata_t *ad,
-                       bt_notification_type_e type, char *dev_name,
-                       char *address, char *db_sid)
+                       bt_notification_type_e type, const char *dev_name,
+                       const char *address, const char *db_sid)
 {
        notification_h noti = NULL;
        notification_error_e ret = NOTIFICATION_ERROR_NONE;
@@ -141,7 +141,8 @@ notification_h _bt_insert_notification(bt_appdata_t *ad,
 
        DBG("Create notification type : %d", type);
 
-       if (type == BT_SENT_NOTI) {
+       switch (type) {
+       case BT_SENT_NOTI:
                success = ad->send_data.tr_success;
                fail = ad->send_data.tr_fail;
 
@@ -152,9 +153,9 @@ notification_h _bt_insert_notification(bt_appdata_t *ad,
                        include_name_param = true;
                }
 
-               if (success == 0 && fail > 0)
+               if (success == 0 && 0 < fail)
                        content = "IDS_BT_SBODY_PD_FAILED_ABB";
-               else if (fail == 0 && success > 0)
+               else if (fail == 0 && 0 < success)
                        content = "IDS_BT_SBODY_PD_SUCCEEDED_ABB";
                else
                        content = "IDS_BT_SBODY_P1SD_SUCCEEDED_P2SD_FAILED_ABB2";
@@ -164,7 +165,8 @@ notification_h _bt_insert_notification(bt_appdata_t *ad,
                flag = NOTIFICATION_PROP_DISABLE_AUTO_DELETE;
                app_id = NOTI_OPC_APP_ID;
                noti_type = NOTIFICATION_TYPE_NOTI;
-       } else if (type == BT_RECEIVED_NOTI) {
+               break;
+       case BT_RECEIVED_NOTI:
                success = ad->recv_data.tr_success;
                fail = ad->recv_data.tr_fail;
 
@@ -185,18 +187,24 @@ notification_h _bt_insert_notification(bt_appdata_t *ad,
                flag = NOTIFICATION_PROP_DISABLE_AUTO_DELETE;
                app_id = NOTI_OPS_APP_ID;
                noti_type = NOTIFICATION_TYPE_NOTI;
-       } else if (type == BT_SENDING_NOTI) {
+               break;
+       case BT_SENDING_NOTI:
                title = "IDS_BT_SBODY_PREPARING_TO_SEND_FILES_ING_ABB";
                icon_path = BT_ICON_NOTIFICATION_SENDING;
                indicator_icon_path = BT_ICON_NOTIFICATION_SENDING_INDICATOR;
                flag = NOTIFICATION_PROP_DISABLE_TICKERNOTI;
                noti_type = NOTIFICATION_TYPE_ONGOING;
-       } else if (type == BT_RECEIVING_NOTI) {
+               break;
+       case BT_RECEIVING_NOTI:
                title = "IDS_BT_SBODY_PREPARING_TO_RECEIVE_FILES_ING_ABB";
                icon_path = BT_ICON_NOTIFICATION_RECEIVING;
                indicator_icon_path = BT_ICON_NOTIFICATION_RECEIVING_INDICATOR;
                flag = NOTIFICATION_PROP_DISABLE_TICKERNOTI;
                noti_type = NOTIFICATION_TYPE_ONGOING;
+               break;
+       default:
+               ERR("Invalid Type(%d)", type);
+               break;
        }
 
        noti = notification_create(noti_type);
@@ -442,9 +450,9 @@ int _bt_delete_notification(notification_h noti)
 }
 
 int _bt_set_notification_app_launch(notification_h noti,
-               char *device_name,
-               char *device_addr,
-               char *db_sid,
+               const char *device_name,
+               const char *device_addr,
+               const char *db_sid,
                bt_notification_launch_type_e launch_type,
                const char *transfer_type,
                const char *filename,
index 3879c2a..1640609 100644 (file)
@@ -53,8 +53,8 @@ typedef enum {
 void _bt_insert_instant_notification(bt_notification_type_e type);
 
 notification_h _bt_insert_notification(bt_appdata_t *ad,
-               bt_notification_type_e type, char *dev_name,
-               char *address, char *db_sid);
+       bt_notification_type_e type, const char *dev_name,
+       const char *address, const char *db_sid);
 
 int _bt_update_notification(bt_appdata_t *ad, notification_h noti,
                char *title, char *content, char *dev_name, char *icon_path, char *opc_count);
@@ -67,8 +67,8 @@ int _bt_get_notification_priv_id(notification_h noti);
 
 int _bt_delete_notification(notification_h noti);
 
-int _bt_set_notification_app_launch(notification_h noti, char *device_name,
-               char *device_addr, char *db_sid,
+int _bt_set_notification_app_launch(notification_h noti, const char *device_name,
+               const char *device_addr, const char *db_sid,
                bt_notification_launch_type_e launch_type,
                const char *transfer_type,
                const char *filename,
index 5669fcc..1bd4fb0 100644 (file)
@@ -71,12 +71,18 @@ typedef struct {
 
 extern bt_appdata_t *app_state;
 extern GSList *bt_transfer_list;
-GSList *bt_receive_noti_list;
-GSList *bt_rcv_noti_info_list = NULL;
-GSList *bt_snd_noti_info_list = NULL;
+static GSList *bt_receive_noti_list;
+static GSList *bt_rcv_noti_info_list = NULL;
+static GSList *bt_snd_noti_info_list = NULL;
 bt_obex_server_authorize_into_t server_auth_info;
 
 static gboolean isTransferConnectedReceived = FALSE;
+static gboolean bt_share_obex_is_started = FALSE;
+static bool bt_share_obex_is_tr_wait = true;
+static int bt_share_obex_send_index = 0;
+static char *bt_share_obex_snd_db_sid = NULL;
+static char *bt_share_obex_rcv_db_sid = NULL;
+
 
 static void *__bt_obex_writeclose(bt_file_info_t *info);
 
@@ -603,806 +609,842 @@ fail:
 #endif
 #endif
 
-/* LCOV_EXCL_START */
-void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
-                              void *user_data)
+static inline void _bt_event_opc_connected(bluetooth_event_param_t *param,
+       opc_transfer_info_t *node)
 {
-       static int send_index = 0;
-       static gboolean is_started = FALSE;
-       static char *snd_db_sid = NULL;
-       static char *rcv_db_sid = NULL;
-       static bool is_tr_wait = true;
-       int percentage = 0;
-       int s_id = 0;
-       char *name = NULL;
-       char *opc_cnt = NULL;
-       notification_h noti = NULL;
-       bt_obex_server_authorize_into_t *auth_info = NULL;
-       bt_obex_server_transfer_info_t *transfer_info = NULL;
-       opc_transfer_info_t *node = NULL;
-       bt_appdata_t *ad = app_state;
        bt_tr_data_t *info = NULL;
-       bt_opc_transfer_info_t *client_info = NULL;
-       bt_noti_data_t *data = NULL;
+       bt_appdata_t *ad = app_state;
        bt_device_snd_noti_info_t *snd_noti_info = NULL;
+       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0};
 
-       pthread_t thread_id = 0;
-       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0, };
+       ret_if(node == NULL);
 
-       if (bt_transfer_list)
-               node = bt_transfer_list->data;
+       bt_share_obex_send_index = 0;
+       bt_share_obex_is_started = FALSE;
+       bt_share_obex_is_tr_wait = true;
 
-       switch (event) {
-       case BLUETOOTH_EVENT_ENABLED: {
-               if (ad->obex_server_init == FALSE) {
-                       if (_bt_init_obex_server() == BT_SHARE_ERROR_NONE)
-                               ad->obex_server_init = TRUE;
-               }
-               break;
-       }
-       case BLUETOOTH_EVENT_DISABLED: {
-               INFO("BT is disabled");
-               _bt_terminate_bluetooth_share();
-               break;
-       }
-       case BLUETOOTH_EVENT_OPC_CONNECTED: {
-               INFO("BLUETOOTH_EVENT_OPC_CONNECTED, result [%d]", param->result);
-               ret_if(node == NULL);
+       _bt_get_pending_list(ad);
 
-               send_index = 0;
-               is_started = FALSE;
-               is_tr_wait = true;
+       retm_if(ad->tr_next_data == NULL, "ad->tr_next_data is NULL");
 
-               _bt_get_pending_list(ad);
+       info = (bt_tr_data_t *)(ad->tr_next_data)->data;
+       retm_if(info == NULL, "info is NULL");
 
-               retm_if(ad->tr_next_data == NULL, "ad->tr_next_data is NULL");
+       bt_share_obex_snd_db_sid = info->db_sid;
+       DBG_SECURE("bt_share_obex_snd_db_sid = [%s]", bt_share_obex_snd_db_sid);
 
-               info = (bt_tr_data_t *)(ad->tr_next_data)->data;
-               retm_if(info == NULL, "info is NULL");
+       _bt_convert_addr_type_to_string(bd_addr, info->addr);
+       DBG_SECURE("bd_addr = [%s]", bd_addr);
 
-               snd_db_sid = info->db_sid;
-               DBG_SECURE("snd_db_sid = [%s]", snd_db_sid);
+       INFO("New device %s", node->name);
 
-               _bt_convert_addr_type_to_string(bd_addr, info->addr);
-               DBG_SECURE("bd_addr = [%s]", bd_addr);
+       snd_noti_info = g_new0(bt_device_snd_noti_info_t, 1);
+       memcpy(snd_noti_info->device_name, node->name,
+               BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
+       memcpy(snd_noti_info->address,
+               info->addr, BT_ADDRESS_STRING_SIZE);
+       snd_noti_info->db_sid = g_strdup(bt_share_obex_snd_db_sid);
+       snd_noti_info->send_noti = NULL;
+       snd_noti_info->send_data.tr_success = 0;
+       snd_noti_info->send_data.tr_fail = 0;
+       bt_snd_noti_info_list = g_slist_append(bt_snd_noti_info_list, snd_noti_info);
 
-               INFO("New device %s", node->name);
-
-               snd_noti_info = g_new0(bt_device_snd_noti_info_t, 1);
-               memcpy(snd_noti_info->device_name, node->name,
-                                       BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
-               memcpy(snd_noti_info->address,
-                               info->addr, BT_ADDRESS_STRING_SIZE);
-               snd_noti_info->db_sid = g_strdup(snd_db_sid);
-               snd_noti_info->send_noti = NULL;
-               snd_noti_info->send_data.tr_success = 0;
-               snd_noti_info->send_data.tr_fail = 0;
-               bt_snd_noti_info_list = g_slist_append(bt_snd_noti_info_list, snd_noti_info);
+       if (param->result != BLUETOOTH_ERROR_NONE) {
+               _bt_create_warning_popup(param->result,
+                       BT_STR_UNABLE_TO_SEND);
+               if (node->file_cnt > bt_share_obex_send_index) {
+                       int s_id;
+                       int *uids;
+                       int uid_cnt = 0;
 
-               if (param->result != BLUETOOTH_ERROR_NONE) {
-                       _bt_create_warning_popup(param->result,
-                               BT_STR_UNABLE_TO_SEND);
-                       if (node->file_cnt > send_index) {
-                               int *uids;
-                               int uid_cnt = 0;
+                       s_id = info->sid;
+                       INFO("info->sid = %d info->id = %d", info->sid, info->id);
+                       uids = g_malloc0(node->file_cnt * sizeof(int));
 
-                               s_id = info->sid;
+                       while (ad->tr_next_data != NULL) {
+                               info = (bt_tr_data_t *)(ad->tr_next_data)->data;
+                               if (info == NULL)
+                                       return;
                                INFO("info->sid = %d info->id = %d", info->sid, info->id);
-                               uids = g_malloc0(node->file_cnt * sizeof(int));
-
-                               while (ad->tr_next_data != NULL) {
-                                       info = (bt_tr_data_t *)(ad->tr_next_data)->data;
-                                       if (info == NULL)
-                                               break;
-                                       INFO("info->sid = %d info->id = %d", info->sid, info->id);
-                                       if (info->sid != s_id) {
-                                               DBG("SID did not match so break done.");
-                                               break;
-                                       }
-
-                                       uids[uid_cnt++] = info->id;
-                                       snd_noti_info->send_data.tr_fail++;
-                                       ad->tr_next_data = g_slist_next(ad->tr_next_data);
-                               }
-                               _bt_update_multiple_sent_data_status(uids, uid_cnt, BT_TR_FAIL,
-                                                               snd_noti_info->db_sid);
-                               _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
-
-                               if (snd_noti_info->send_noti == NULL) {
-                                       ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
-                                       ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
-                                       snd_noti_info->send_noti = _bt_insert_notification(
-                                               ad, BT_SENT_NOTI, snd_noti_info->device_name,
-                                               snd_noti_info->address, snd_noti_info->db_sid);
-                               } else {
-                                       ad->send_noti = snd_noti_info->send_noti;
-                                       ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
-                                       ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
-                                       _bt_update_notification(ad, ad->send_noti, NULL, NULL,
-                                                                       NULL, NULL, NULL);
+                               if (info->sid != s_id) {
+                                       DBG("SID did not match so break done.");
+                                       return;
                                }
-                               /* Update Database with Notification ID*/
-                               __bt_update_db_with_noti_id(BT_DB_OUTBOUND, snd_noti_info->send_noti,
-                                               snd_noti_info->db_sid);
-                               g_free(uids);
-                       }
 
-                       __bt_free_snd_notification(snd_noti_info);
-                       _remove_transfer_info(node);
-
-                       if (!ad->tr_next_data) {
-                               bt_share_release_tr_data_list(ad->tr_send_list);
-                               ad->tr_send_list = NULL;
+                               uids[uid_cnt++] = info->id;
+                               snd_noti_info->send_data.tr_fail++;
+                               ad->tr_next_data = g_slist_next(ad->tr_next_data);
+                       }
+                       _bt_update_multiple_sent_data_status(uids, uid_cnt, BT_TR_FAIL,
+                               snd_noti_info->db_sid);
+                       _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
+
+                       if (snd_noti_info->send_noti == NULL) {
+                               ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
+                               ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
+                               snd_noti_info->send_noti = _bt_insert_notification(
+                                       ad, BT_SENT_NOTI, snd_noti_info->device_name,
+                                       snd_noti_info->address, snd_noti_info->db_sid);
+                       } else {
+                               ad->send_noti = snd_noti_info->send_noti;
+                               ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
+                               ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
+                               _bt_update_notification(ad, ad->send_noti, NULL, NULL,
+                                       NULL, NULL, NULL);
                        }
+                       /* Update Database with Notification ID*/
+                       __bt_update_db_with_noti_id(BT_DB_OUTBOUND, snd_noti_info->send_noti,
+                               snd_noti_info->db_sid);
+                       g_free(uids);
+               }
 
-               } else {
-                       _bt_insert_instant_notification(BT_SENDING_NOTI);
+               __bt_free_snd_notification(snd_noti_info);
+               _remove_transfer_info(node);
 
-                       if (ad->opc_noti) {
-                               _bt_delete_notification(ad->opc_noti);
-                               ad->opc_noti = NULL;
-                               ad->opc_noti_id = 0;
-                       }
+               if (!ad->tr_next_data) {
+                       bt_share_release_tr_data_list(ad->tr_send_list);
+                       ad->tr_send_list = NULL;
+               }
 
-                       noti = _bt_insert_notification(ad,
-                                               BT_SENDING_NOTI, node->name,
-                                               node->addr, info->db_sid);
-                       ad->opc_noti = noti;
-                       ad->opc_noti_id = _bt_get_notification_priv_id(noti);
+       } else {
+               _bt_insert_instant_notification(BT_SENDING_NOTI);
 
-                       _bt_share_block_sleep(TRUE);
-                       _bt_set_transfer_indicator(TRUE);
+               if (ad->opc_noti) {
+                       _bt_delete_notification(ad->opc_noti);
+                       ad->opc_noti = NULL;
+                       ad->opc_noti_id = 0;
                }
-               break;
-       }
 
-       case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED: {
-               INFO("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED");
-               ret_if(node == NULL);
-               retm_if(!ad, "ad is NULL");
-               retm_if(!ad->tr_next_data, "ad>tr_next_data is NULL");
+               notification_h noti = _bt_insert_notification(ad, BT_SENDING_NOTI, node->name,
+                       node->addr, info->db_sid);
+               ad->opc_noti = noti;
+               ad->opc_noti_id = _bt_get_notification_priv_id(noti);
 
-               info = (bt_tr_data_t *)(ad->tr_next_data)->data;
-               ret_if(info == NULL);
+               _bt_share_block_sleep(TRUE);
+               _bt_set_transfer_indicator(TRUE);
+       }
+}
+static inline void _bt_event_opc_transfer_started(bt_appdata_t *ad,
+       opc_transfer_info_t *node)
+{
+       char *opc_cnt = NULL;
+       bt_tr_data_t *info;
+       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0};
 
-               is_started = TRUE;
+       ret_if(node == NULL);
+       retm_if(!ad, "ad is NULL");
+       retm_if(!ad->tr_next_data, "ad>tr_next_data is NULL");
 
-               if (send_index > 0 && is_tr_wait == true)
-                       is_tr_wait = false;
+       info = (bt_tr_data_t *)(ad->tr_next_data)->data;
+       ret_if(info == NULL);
 
-               name = __get_file_name(send_index++, node->file_path);
+       bt_share_obex_is_started = TRUE;
 
-               if (node->file_cnt > 1)
-                       opc_cnt = g_strdup_printf("[%d/%d]", send_index, node->file_cnt);
+       if (bt_share_obex_send_index > 0 && bt_share_obex_is_tr_wait == true)
+               bt_share_obex_is_tr_wait = false;
 
-               INFO("file count %d", node->file_cnt);
-               _bt_convert_addr_type_to_string(bd_addr, node->addr);
-               DBG_SECURE("bd_addr = [%s]", bd_addr);
+       char *name = __get_file_name(bt_share_obex_send_index++, node->file_path);
 
-               if (node->file_cnt > 1)
-                       _bt_set_notification_app_launch(ad->opc_noti, node->name, bd_addr,
-                                       info->db_sid, CREATE_PROGRESS, NOTI_TR_TYPE_OUT,
-                                       name, *(node->size), opc_cnt, 0);
-               else
-                       _bt_set_notification_app_launch(ad->opc_noti, node->name, bd_addr,
-                                       info->db_sid, CREATE_PROGRESS, NOTI_TR_TYPE_OUT,
-                                       name, *(node->size), "[1/1]", 0);
+       if (node->file_cnt > 1)
+               opc_cnt = g_strdup_printf("[%d/%d]", bt_share_obex_send_index, node->file_cnt);
 
-               _bt_update_sent_data_status(info->id, BT_TR_ONGOING, info->db_sid);
-               _bt_update_transfer_list_view("outbound");
+       INFO("file count %d", node->file_cnt);
+       _bt_convert_addr_type_to_string(bd_addr, node->addr);
+       DBG_SECURE("bd_addr = [%s]", bd_addr);
 
-               if (ad->opc_noti && is_tr_wait == false) {
-                       char *sending_files = "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING";
-                       _bt_update_notification(ad, ad->opc_noti, name, sending_files, node->name, NULL, opc_cnt);
-                       _bt_update_notification_progress(NULL, ad->opc_noti_id, 0);
-               }
+       if (node->file_cnt > 1)
+               _bt_set_notification_app_launch(ad->opc_noti, node->name, bd_addr,
+                       info->db_sid, CREATE_PROGRESS, NOTI_TR_TYPE_OUT,
+                       name, *(node->size), opc_cnt, 0);
+       else
+               _bt_set_notification_app_launch(ad->opc_noti, node->name, bd_addr,
+                       info->db_sid, CREATE_PROGRESS, NOTI_TR_TYPE_OUT,
+                       name, *(node->size), "[1/1]", 0);
 
-               g_free(opc_cnt);
-               retm_if(ad->tr_next_data == NULL, "ad->tr_next_data is NULL");
+       _bt_update_sent_data_status(info->id, BT_TR_ONGOING, info->db_sid);
+       _bt_update_transfer_list_view("outbound");
 
-               ad->current_tr_uid = info->id;
-               INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
-               break;
+       if (ad->opc_noti && bt_share_obex_is_tr_wait == false) {
+               char *sending_files = "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING";
+               _bt_update_notification(ad, ad->opc_noti, name, sending_files, node->name, NULL, opc_cnt);
+               _bt_update_notification_progress(NULL, ad->opc_noti_id, 0);
        }
 
-       case BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS: {
-               client_info = (bt_opc_transfer_info_t *)param->param_data;
-               ret_if(client_info == NULL);
-               ret_if(node == NULL);
+       g_free(opc_cnt);
+       retm_if(ad->tr_next_data == NULL, "ad->tr_next_data is NULL");
 
-               percentage = client_info->percentage;
-               name =  strrchr(client_info->filename, '/');
-               if (name)
-                       name++;
-               else
-                       name = client_info->filename;
+       ad->current_tr_uid = info->id;
+       INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
+}
 
-               if (ad->opc_noti) {
-                       if (is_tr_wait == true) {
-                               char *sending_files = "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING";
+static inline void _bt_event_opc_transfer_progress(bt_appdata_t *ad,
+       bluetooth_event_param_t *param, opc_transfer_info_t *node)
+{
+       bt_opc_transfer_info_t *client_info = param->param_data;
+       ret_if(client_info == NULL);
+       ret_if(node == NULL);
+
+       int percentage = client_info->percentage;
+       char *name = strrchr(client_info->filename, '/');
+       if (name)
+               name++;
+       else
+               name = client_info->filename;
+
+       if (ad->opc_noti) {
+               if (bt_share_obex_is_tr_wait == true) {
+                       char *opc_cnt = NULL;
+                       char *sending_files = "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING";
 
-                               if (node->file_cnt > 1)
-                                       opc_cnt = g_strdup_printf("[%d/%d]", send_index, node->file_cnt);
+                       if (node->file_cnt > 1)
+                               opc_cnt = g_strdup_printf("[%d/%d]", bt_share_obex_send_index, node->file_cnt);
 
-                               _bt_update_notification(ad, ad->opc_noti, name, sending_files,
-                                               node->name, NULL, opc_cnt);
+                       _bt_update_notification(ad, ad->opc_noti, name, sending_files,
+                               node->name, NULL, opc_cnt);
 
-                               g_free(opc_cnt);
-                               is_tr_wait = false;
-                       }
-                       _bt_update_notification_progress(NULL, ad->opc_noti_id, percentage);
+                       g_free(opc_cnt);
+                       bt_share_obex_is_tr_wait = false;
                }
-               break;
+               _bt_update_notification_progress(NULL, ad->opc_noti_id, percentage);
        }
+}
+static inline void _bt_event_opc_transfer_complete(bt_appdata_t *ad,
+       bluetooth_event_param_t *param, opc_transfer_info_t *node)
+{
+       ret_if(node == NULL);
 
-       case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE: {
-               INFO("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE");
-               ret_if(node == NULL);
+       if (!bt_share_obex_is_started) {
+               INFO("TRANSFER operation abnormal. It is completed without TRANSFER START");
+               bt_tr_data_t *info = (bt_tr_data_t *)(ad->tr_next_data)->data;
+               ret_if(info == NULL);
 
-               if (!is_started) {
-                       INFO("TRANSFER operation abnormal. It is completed without TRANSFER START");
-                       info = (bt_tr_data_t *)(ad->tr_next_data)->data;
-                       ret_if(info == NULL);
-                       ad->current_tr_uid = info->id;
-                       INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
-                       send_index++;
-               }
+               ad->current_tr_uid = info->id;
+               INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
+               bt_share_obex_send_index++;
+       }
 
-               is_started = FALSE;
+       bt_share_obex_is_started = FALSE;
 
-               client_info = (bt_opc_transfer_info_t *)param->param_data;
-               ret_if(client_info == NULL);
+       bt_opc_transfer_info_t *client_info = param->param_data;
+       ret_if(client_info == NULL);
 
-               DBG_SECURE("client_info->filename = [%s]", client_info->filename);
-               INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
+       DBG_SECURE("client_info->filename = [%s]", client_info->filename);
+       INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
 
-               name =  strrchr(client_info->filename, '/');
-               if (name)
-                       name++;
-               else
-                       name = client_info->filename;
+       char *name = strrchr(client_info->filename, '/');
+       if (name)
+               name++;
+       else
+               name = client_info->filename;
 
-               if (ad->opc_noti && is_tr_wait == true) {
-                       char *sending_files = "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING";
+       if (ad->opc_noti && bt_share_obex_is_tr_wait == true) {
+               char *opc_cnt = NULL;
+               char *sending_files = "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING";
 
-                       if (node->file_cnt > 1)
-                               opc_cnt = g_strdup_printf("[%d/%d]", send_index, node->file_cnt);
+               if (node->file_cnt > 1)
+                       opc_cnt = g_strdup_printf("[%d/%d]", bt_share_obex_send_index, node->file_cnt);
 
-                       _bt_update_notification(ad, ad->opc_noti, name, sending_files, node->name, NULL, opc_cnt);
-                       g_free(opc_cnt);
-                       is_tr_wait = false;
-               }
+               _bt_update_notification(ad, ad->opc_noti, name, sending_files, node->name, NULL, opc_cnt);
+               g_free(opc_cnt);
+               bt_share_obex_is_tr_wait = false;
+       }
 
-               DBG("name address = [%s]", name);
-
-               _bt_convert_addr_type_to_string(bd_addr, node->addr);
-               DBG_SECURE("bd_addr = [%s]", bd_addr);
-
-               snd_noti_info = __bt_get_snd_noti_data_by_device_address(bd_addr);
-               if (snd_noti_info == NULL) {
-                       INFO("New device %s", node->name);
-
-                       snd_noti_info = g_new0(bt_device_snd_noti_info_t, 1);
-                       memcpy(snd_noti_info->device_name, node->name,
-                                               BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
-                       memcpy(snd_noti_info->address, bd_addr,
-                                               BT_ADDRESS_STRING_SIZE);
-                       snd_noti_info->db_sid = g_strdup(snd_db_sid);
-                       snd_noti_info->send_noti = NULL;
-                       snd_noti_info->send_data.tr_success = 0;
-                       snd_noti_info->send_data.tr_fail = 0;
-                       bt_snd_noti_info_list = g_slist_append(bt_snd_noti_info_list, snd_noti_info);
-               }
-               INFO("ad->send_data.tr_fail = %d, ad->send_data.tr_success= %d",
-                       ad->send_data.tr_fail, ad->send_data.tr_success);
+       DBG("name address = [%s]", name);
 
-               if (param->result != BLUETOOTH_ERROR_NONE)
-                       snd_noti_info->send_data.tr_fail++;
-               else {
-                       snd_noti_info->send_data.tr_success++;
-                       _bt_remove_tmp_file(client_info->filename);
-                       _bt_remove_vcf_file(client_info->filename);
-                       _bt_update_notification_progress(NULL, ad->opc_noti_id, 100);
-               }
+       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0};
+       _bt_convert_addr_type_to_string(bd_addr, node->addr);
+       DBG_SECURE("bd_addr = [%s]", bd_addr);
 
-               if (param->result == BLUETOOTH_ERROR_NOT_FOUND) {
-                       ERR("File Doesn't exist. ");
-                       _bt_update_sent_data_status(ad->current_tr_uid,
-                                                       BT_TR_FAIL, snd_noti_info->db_sid);
-               } else if (param->result != BLUETOOTH_ERROR_NONE) {
-                       _bt_update_sent_data_status(ad->current_tr_uid,
-                                                       BT_TR_FAIL, snd_noti_info->db_sid);
-                       ERR("opp_transfer_abort by user %d ", ad->opp_transfer_abort);
+       bt_device_snd_noti_info_t *snd_noti_info;
+       snd_noti_info = __bt_get_snd_noti_data_by_device_address(bd_addr);
+       if (snd_noti_info == NULL) {
+               INFO("New device %s", node->name);
 
-                       if (!ad->opp_transfer_abort)
-                               _bt_create_warning_popup(param->result,
-                                       BT_STR_UNABLE_TO_SEND);
+               snd_noti_info = g_new0(bt_device_snd_noti_info_t, 1);
+               memcpy(snd_noti_info->device_name, node->name,
+                       BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
+               memcpy(snd_noti_info->address, bd_addr,
+                       BT_ADDRESS_STRING_SIZE);
+               snd_noti_info->db_sid = g_strdup(bt_share_obex_snd_db_sid);
+               snd_noti_info->send_noti = NULL;
+               snd_noti_info->send_data.tr_success = 0;
+               snd_noti_info->send_data.tr_fail = 0;
+               bt_snd_noti_info_list = g_slist_append(bt_snd_noti_info_list, snd_noti_info);
+       }
+       INFO("ad->send_data.tr_fail = %d, ad->send_data.tr_success= %d",
+               ad->send_data.tr_fail, ad->send_data.tr_success);
+
+       if (param->result != BLUETOOTH_ERROR_NONE)
+               snd_noti_info->send_data.tr_fail++;
+       else {
+               snd_noti_info->send_data.tr_success++;
+               _bt_remove_tmp_file(client_info->filename);
+               _bt_remove_vcf_file(client_info->filename);
+               _bt_update_notification_progress(NULL, ad->opc_noti_id, 100);
+       }
 
-                       ad->opp_transfer_abort = FALSE;
-               } else {
-                       _bt_update_sent_data_status(ad->current_tr_uid,
-                                                       BT_TR_SUCCESS, snd_noti_info->db_sid);
-               }
+       if (param->result == BLUETOOTH_ERROR_NOT_FOUND) {
+               ERR("File Doesn't exist. ");
+               _bt_update_sent_data_status(ad->current_tr_uid, BT_TR_FAIL, snd_noti_info->db_sid);
+       } else if (param->result != BLUETOOTH_ERROR_NONE) {
+               _bt_update_sent_data_status(ad->current_tr_uid, BT_TR_FAIL, snd_noti_info->db_sid);
+               ERR("opp_transfer_abort by user %d ", ad->opp_transfer_abort);
 
-               _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
+               if (!ad->opp_transfer_abort)
+                       _bt_create_warning_popup(param->result, BT_STR_UNABLE_TO_SEND);
 
-               ad->tr_next_data = g_slist_next(ad->tr_next_data);
-               break;
+               ad->opp_transfer_abort = FALSE;
+       } else {
+               _bt_update_sent_data_status(ad->current_tr_uid, BT_TR_SUCCESS,
+                       snd_noti_info->db_sid);
        }
 
-       case BLUETOOTH_EVENT_OPC_DISCONNECTED: {
-               INFO("BLUETOOTH_EVENT_OPC_DISCONNECTED");
-               ret_if(node == NULL);
+       _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
 
-               if (ad->opc_noti) {
-                       _bt_delete_notification(ad->opc_noti);
-                       ad->opc_noti = NULL;
-                       ad->opc_noti_id = 0;
-               }
+       ad->tr_next_data = g_slist_next(ad->tr_next_data);
+}
 
-               _bt_convert_addr_type_to_string(bd_addr, node->addr);
-               DBG_SECURE("bd_addr = [%s]", bd_addr);
+static void _bt_event_opc_disconnected_release(bt_appdata_t *ad,
+       opc_transfer_info_t *node, bt_device_snd_noti_info_t *snd_noti_info)
+{
+       bt_share_obex_send_index = 0;
+       bt_share_obex_is_started = FALSE;
+       __bt_free_snd_notification(snd_noti_info);
+       _bt_share_block_sleep(FALSE);
+       _bt_set_transfer_indicator(FALSE);
+       _remove_transfer_info(node);
+       if (!ad->tr_next_data) {
+               bt_share_release_tr_data_list(ad->tr_send_list);
+               ad->tr_send_list = NULL;
+       }
+}
+
+static inline void _bt_event_opc_disconnected(bt_appdata_t *ad,
+       opc_transfer_info_t *node)
+{
+       ret_if(node == NULL);
+
+       if (ad->opc_noti) {
+               _bt_delete_notification(ad->opc_noti);
+               ad->opc_noti = NULL;
+               ad->opc_noti_id = 0;
+       }
+
+       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0};
+       _bt_convert_addr_type_to_string(bd_addr, node->addr);
+       DBG_SECURE("bd_addr = [%s]", bd_addr);
+
+       bt_device_snd_noti_info_t *snd_noti_info;
+       snd_noti_info = __bt_get_snd_noti_data_by_device_address(bd_addr);
+       if (snd_noti_info == NULL) {
+               ERR("snd_noti_info == NULL, this shouldn't happen");
+               /* Send Disconnect to Share-UI */
+               _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED,
+                       BLUETOOTH_ERROR_NONE, bd_addr, 0);
+               _bt_event_opc_disconnected_release(ad, node, snd_noti_info);
+               return;
+       }
 
-               snd_noti_info = __bt_get_snd_noti_data_by_device_address(bd_addr);
+       if (node->file_cnt > bt_share_obex_send_index) {
+               int *uids;
+               int uid_cnt = 0;
+               bt_share_obex_send_index = 0;
+               bt_share_obex_is_started = FALSE;
+               retm_if(!ad->tr_next_data, "ad>tr_next_data is NULL");
 
-               if (snd_noti_info == NULL) {
-                       ERR("snd_noti_info == NULL, this shouldn't happen");
-                       goto done;
+               bt_tr_data_t *info = (bt_tr_data_t *)(ad->tr_next_data)->data;
+               if (info == NULL) {
+                       /* Send Disconnect to Share-UI */
+                       _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED,
+                               BLUETOOTH_ERROR_NONE, bd_addr, 0);
+                       return;
                }
 
-               if (node->file_cnt > send_index) {
-                       int *uids;
-                       int uid_cnt = 0;
-                       send_index = 0;
-                       is_started = FALSE;
-                       retm_if(!ad->tr_next_data, "ad>tr_next_data is NULL");
+               int s_id = info->sid;
+               INFO("info->sid = %d info->id = %d", info->sid, info->id);
+               uids = g_malloc0(node->file_cnt * sizeof(int));
 
+               while (NULL != ad->tr_next_data) {
                        info = (bt_tr_data_t *)(ad->tr_next_data)->data;
-                       if (info == NULL) {
-                               /* Send Disconnect to Share-UI */
-                               _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED,
-                                               BLUETOOTH_ERROR_NONE, bd_addr, 0);
+                       if (info == NULL)
+                               break;
+                       INFO("info->sid = %d info->id = %d", info->sid, info->id);
+
+                       if (s_id != info->sid) {
+                               DBG("SID did not match so break done.");
                                break;
                        }
 
-                       s_id = info->sid;
-                       INFO("info->sid = %d info->id = %d", info->sid, info->id);
-                       uids = g_malloc0(node->file_cnt * sizeof(int));
+                       uids[uid_cnt++] = info->id;
+                       snd_noti_info->send_data.tr_fail++;
+                       ad->tr_next_data = g_slist_next(ad->tr_next_data);
+               }
+               _bt_update_multiple_sent_data_status(uids, uid_cnt, BT_TR_FAIL,
+                       snd_noti_info->db_sid);
+               ad->send_noti = snd_noti_info->send_noti;
+               ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
+               ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
+               g_free(uids);
+       }
 
-                       while (NULL != ad->tr_next_data) {
-                               info = (bt_tr_data_t *)(ad->tr_next_data)->data;
-                               if (info == NULL)
-                                       break;
-                               INFO("info->sid = %d info->id = %d", info->sid, info->id);
+       if (snd_noti_info->send_noti == NULL) {
+               ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
+               ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
+               snd_noti_info->send_noti = _bt_insert_notification(ad,
+                       BT_SENT_NOTI, snd_noti_info->device_name,
+                       snd_noti_info->address, snd_noti_info->db_sid);
+       }
 
-                               if (s_id != info->sid) {
-                                       DBG("SID did not match so break done.");
-                                       break;
-                               }
+       if (snd_noti_info->send_data.tr_success)
+               _bt_insert_instant_notification(BT_SENT_NOTI);
+       else
+               _bt_insert_instant_notification(BT_SENT_FAILED_NOTI);
 
-                               uids[uid_cnt++] = info->id;
-                               snd_noti_info->send_data.tr_fail++;
-                               ad->tr_next_data = g_slist_next(ad->tr_next_data);
-                       }
-                       _bt_update_multiple_sent_data_status(uids, uid_cnt, BT_TR_FAIL,
-                                                               snd_noti_info->db_sid);
-                       ad->send_noti = snd_noti_info->send_noti;
-                       ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
-                       ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
-                       g_free(uids);
-               }
+       /* Update Database with Notification ID*/
+       __bt_update_db_with_noti_id(BT_DB_OUTBOUND, snd_noti_info->send_noti,
+               snd_noti_info->db_sid);
 
-               if (snd_noti_info->send_noti == NULL) {
-                       ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
-                       ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
-                       snd_noti_info->send_noti = _bt_insert_notification(ad,
-                               BT_SENT_NOTI, snd_noti_info->device_name,
-                               snd_noti_info->address, snd_noti_info->db_sid);
-               }
+       /* Send Disconnect to Share-UI */
+       _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED,
+               BLUETOOTH_ERROR_NONE, bd_addr, 0);
+       _bt_event_opc_disconnected_release(ad, node, snd_noti_info);
+}
 
-               if (snd_noti_info->send_data.tr_success)
-                       _bt_insert_instant_notification(BT_SENT_NOTI);
-               else
-                       _bt_insert_instant_notification(BT_SENT_FAILED_NOTI);
+static inline void _bt_event_obex_server_transfer_authorize(bluetooth_event_param_t *param)
+{
+       if (param->result == BLUETOOTH_ERROR_NONE) {
+               g_free(server_auth_info.filename);
+               g_free(server_auth_info.name);
+               server_auth_info.filename = NULL;
+               server_auth_info.name = NULL;
+
+               bt_obex_server_authorize_into_t *auth_info = param->param_data;
+               server_auth_info.filename = g_strdup(auth_info->filename);
+               server_auth_info.length = auth_info->length;
+               server_auth_info.name = g_strdup(auth_info->name);
+
+               if (server_auth_info.filename)
+                       __bt_obex_file_push_auth(&server_auth_info);
+       }
+}
 
-               /* Update Database with Notification ID*/
-               __bt_update_db_with_noti_id(BT_DB_OUTBOUND, snd_noti_info->send_noti,
-                               snd_noti_info->db_sid);
-done:
-               /* Send Disconnect to Share-UI */
-               _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED,
-                               BLUETOOTH_ERROR_NONE, bd_addr, 0);
+static inline void _bt_event_obex_server_transfer_connected(bt_appdata_t *ad,
+       bluetooth_event_param_t *param)
+{
+       bt_device_rcv_noti_info_t *rcv_noti_info = NULL;
+       bt_share_obex_rcv_db_sid = _bt_get_time_of_the_day();
 
-               send_index = 0;
-               is_started = FALSE;
-               __bt_free_snd_notification(snd_noti_info);
-               _bt_share_block_sleep(FALSE);
-               _bt_set_transfer_indicator(FALSE);
-               _remove_transfer_info(node);
-               if (!ad->tr_next_data) {
-                       bt_share_release_tr_data_list(ad->tr_send_list);
-                       ad->tr_send_list = NULL;
+       DBG_SECURE("bt_share_obex_rcv_db_sid = [%s]", bt_share_obex_rcv_db_sid);
+       if (param->result == BLUETOOTH_ERROR_NONE) {
+               bt_obex_server_connection_info_t *conn_info = param->param_data;
+               DBG_SECURE("Address[%s] DeviceName[%s] TransferID[%d]",
+                       conn_info->address, conn_info->device_name,
+                       conn_info->transfer_id);
+
+               rcv_noti_info = __bt_get_rcv_noti_data_by_device_address(conn_info->address);
+               if (rcv_noti_info == NULL) {
+                       INFO("New device %s", conn_info->device_name);
+
+                       rcv_noti_info = g_new0(bt_device_rcv_noti_info_t, 1);
+                       rcv_noti_info->id = -1;
+                       rcv_noti_info->address = g_strdup(conn_info->address);
+                       rcv_noti_info->device_name = g_strdup(conn_info->device_name);
+                       rcv_noti_info->db_sid = g_strdup(bt_share_obex_rcv_db_sid);
+                       rcv_noti_info->recv_data.tr_success = -1;
+                       rcv_noti_info->recv_data.tr_fail = -1;
+                       bt_rcv_noti_info_list = g_slist_append(bt_rcv_noti_info_list, rcv_noti_info);
                }
-               break;
+
+               /* Insert Notification */
+               /* TODO: Need to distinguish between GET or PUT request and show Receiving or Sending */
+               notification_h noti;
+               noti = _bt_insert_notification(ad, BT_RECEIVING_NOTI, rcv_noti_info->device_name,
+                       rcv_noti_info->address, rcv_noti_info->db_sid);
+
+       /* Save notification handle & ID and Transfer ID*/
+               bt_noti_data_t *data = g_new0(bt_noti_data_t, 1);
+               data->noti_handle = noti;
+               data->noti_id = _bt_get_notification_priv_id(noti);
+               data->transfer_id = conn_info->transfer_id;
+               bt_receive_noti_list = g_slist_append(bt_receive_noti_list, data);
+
+               isTransferConnectedReceived = TRUE;
        }
+}
+static inline void _bt_event_obex_server_transfer_started(bt_appdata_t *ad,
+       bluetooth_event_param_t *param)
+{
+       int current_file;
+       unsigned int file_size = 0;
+       char *contact_name = NULL;
+       bt_device_rcv_noti_info_t *rcv_noti_info;
+       bt_obex_server_transfer_info_t *transfer_info = param->param_data;
 
-       case BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE: {
-               INFO("BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE");
-               break;
+       rcv_noti_info = __bt_get_rcv_noti_data_by_device_address(transfer_info->address);
+       bt_noti_data_t *data = __bt_get_noti_data_by_transfer_id(transfer_info->transfer_id);
+
+       retm_if(data == NULL || rcv_noti_info == NULL, "Notification data NULL");
+
+       if (rcv_noti_info->recv_data.tr_success == -1 &&
+               rcv_noti_info->recv_data.tr_fail == -1) {
+               current_file = 1;
+       } else {
+               current_file = rcv_noti_info->recv_data.tr_success +
+                       rcv_noti_info->recv_data.tr_fail + 1;
        }
 
-       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE: {
-               INFO("BT_EVENT_OBEX_TRANSFER_AUTHORIZE");
-               if (param->result == BLUETOOTH_ERROR_NONE) {
-                       g_free(server_auth_info.filename);
-                       g_free(server_auth_info.name);
-                       server_auth_info.filename = NULL;
-                       server_auth_info.name = NULL;
-
-                       auth_info = param->param_data;
-                       server_auth_info.filename = g_strdup(auth_info->filename);
-                       server_auth_info.length = auth_info->length;
-                       server_auth_info.name = g_strdup(auth_info->name);
-
-                       if (server_auth_info.filename)
-                               __bt_obex_file_push_auth(&server_auth_info);
-               }
-               break;
+       char *opc_cnt = g_strdup_printf("[%d/All]", current_file);
+
+       if (g_strcmp0(transfer_info->type, TRANSFER_GET) == 0) {
+               /*GET request */
+               _bt_set_notification_app_launch(data->noti_handle,
+                       transfer_info->device_name,
+                       transfer_info->address,
+                       bt_share_obex_rcv_db_sid,
+                       CREATE_PROGRESS,
+                       NOTI_TR_TYPE_OUT,
+                       transfer_info->filename,
+                       transfer_info->file_size, NULL,
+                       transfer_info->transfer_id);
+       } else {
+               /*PUT Request */
+               _bt_add_recv_transfer_status_data(transfer_info->device_name,
+                       transfer_info->address, transfer_info->filename, NULL,
+                       file_size, BT_TR_ONGOING, rcv_noti_info->db_sid);
+               rcv_noti_info->id = _bt_share_get_unique_id(BT_DB_INBOUND,
+                       rcv_noti_info->db_sid);
+               _bt_update_transfer_list_view(BT_INBOUND_TABLE);
+
+               _bt_set_notification_app_launch(data->noti_handle,
+                       transfer_info->device_name, transfer_info->address,
+                       rcv_noti_info->db_sid, CREATE_PROGRESS,
+                       NOTI_TR_TYPE_IN, transfer_info->filename,
+                       transfer_info->file_size, NULL,
+                       transfer_info->transfer_id);
        }
 
-       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED: {
-               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED");
-               bt_device_rcv_noti_info_t *rcv_noti_info = NULL;
-
-               rcv_db_sid = _bt_get_time_of_the_day();
-
-               DBG_SECURE("rcv_db_sid = [%s]", rcv_db_sid);
-               if (param->result == BLUETOOTH_ERROR_NONE) {
-                       bt_obex_server_connection_info_t *conn_info = param->param_data;
-                       DBG_SECURE("Address[%s] DeviceName[%s] TransferID[%d]",
-                                       conn_info->address, conn_info->device_name,
-                                       conn_info->transfer_id);
-
-                       rcv_noti_info =
-                               __bt_get_rcv_noti_data_by_device_address(conn_info->address);
-                       if (rcv_noti_info == NULL) {
-                               INFO("New device %s", conn_info->device_name);
-
-                               rcv_noti_info = g_new0(bt_device_rcv_noti_info_t, 1);
-                               rcv_noti_info->id = -1;
-                               rcv_noti_info->address = g_strdup(conn_info->address);
-                               rcv_noti_info->device_name = g_strdup(conn_info->device_name);
-                               rcv_noti_info->db_sid = g_strdup(rcv_db_sid);
-                               rcv_noti_info->recv_data.tr_success = -1;
-                               rcv_noti_info->recv_data.tr_fail = -1;
-                               bt_rcv_noti_info_list = g_slist_append(bt_rcv_noti_info_list, rcv_noti_info);
-                       }
+#if 0
+//#ifdef ENABLE_CONTACTS_SERVICE2
+       int contact_id = -1;
+
+       if (transfer_info->contact_auth_info) {
+               unsigned char auth_info_null[5];
+               memset(auth_info_null, 0X0, 5);
+               if (memcmp(transfer_info->contact_auth_info, auth_info_null, 5)) {
+                       _bt_util_get_contact_info(transfer_info->contact_auth_info, &contact_id, &contact_name);
+                       DBG_SECURE("contact_id: %d | contact_name: [%s]", contact_id, contact_name);
+               }
+       }
+//#endif
+#endif
+       char *receiving_files = "IDS_WIFI_BODY_RECEIVING_FILES_FROM_PS_ING";
+
+       INFO("Notification data: %p", data);
+       if (data) {
+               _bt_update_notification(ad, data->noti_handle,
+                       transfer_info->filename, receiving_files,
+                       transfer_info->device_name, NULL, opc_cnt);
+               _bt_update_notification_progress(data->noti_handle,
+                       data->noti_id, 0);
+       }
 
-                       /* Insert Notification */
-                       /* TODO: Need to distinguish between GET or PUT request and show Receiving or Sending */
-                       noti = _bt_insert_notification(ad,
-                                       BT_RECEIVING_NOTI,
-                                       rcv_noti_info->device_name,
-                                       rcv_noti_info->address,
-                                       rcv_noti_info->db_sid);
+       _bt_set_transfer_indicator(TRUE);
+       _bt_share_block_sleep(TRUE);
+       g_free(opc_cnt);
+       g_free(contact_name);
+}
 
-                       /* Save notification handle & ID and Transfer ID*/
-                       data = g_new0(bt_noti_data_t, 1);
-                       data->noti_handle = noti;
-                       data->noti_id = _bt_get_notification_priv_id(noti);
-                       data->transfer_id = conn_info->transfer_id;
-                       bt_receive_noti_list = g_slist_append(bt_receive_noti_list, data);
+static inline void _bt_event_obex_server_transfer_progress(bluetooth_event_param_t *param)
+{
+       if (param->result != BLUETOOTH_ERROR_NONE)
+               return;
 
+       bt_obex_server_transfer_info_t *transfer_info = param->param_data;
+       bt_noti_data_t *data = __bt_get_noti_data_by_transfer_id(transfer_info->transfer_id);
+       retm_if(data == NULL, "Data is NULL, returning");
 
-                       isTransferConnectedReceived = TRUE;
-               }
-               break;
+       if (data && data->noti_id) {
+               _bt_update_notification_progress(data->noti_handle, data->noti_id,
+                       transfer_info->percentage);
+       } else {
+               DBG("noti_id is not exist!");
        }
+}
 
-       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED: {
-               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED");
-               transfer_info = param->param_data;
-               unsigned int file_size = 0;
-               char *contact_name = NULL;
-               bt_device_rcv_noti_info_t *rcv_noti_info =
-                       __bt_get_rcv_noti_data_by_device_address(transfer_info->address);
-               data = __bt_get_noti_data_by_transfer_id(transfer_info->transfer_id);
-               int current_file;
-
-               retm_if(data == NULL || rcv_noti_info == NULL, "Notification data NULL");
-
-               if (rcv_noti_info->recv_data.tr_success == -1 &&
-                               rcv_noti_info->recv_data.tr_fail == -1) {
-                       current_file = 1;
-               } else {
-                       current_file = rcv_noti_info->recv_data.tr_success +
-                                       rcv_noti_info->recv_data.tr_fail + 1;
+static inline void _bt_event_obex_server_transfer_completed(bt_appdata_t *ad,
+       bluetooth_event_param_t *param)
+{
+       struct stat file_attr;
+       char *file_path = NULL;
+       unsigned int file_size = 0;
+       char mime_type[BT_MIME_TYPE_MAX_LEN] = {0};
+       bt_obex_server_transfer_info_t *transfer_info = param->param_data;
+
+       _bt_set_transfer_indicator(FALSE);
+       _bt_share_block_sleep(FALSE);
+       bt_noti_data_t *data = __bt_get_noti_data_by_transfer_id(transfer_info->transfer_id);
+
+       if (g_strcmp0(transfer_info->type, TRANSFER_PUT) == 0) {
+               INFO("TRANSFER_PUT");
+
+               bt_device_rcv_noti_info_t *rcv_noti_info;
+               rcv_noti_info = __bt_get_rcv_noti_data_by_device_address(transfer_info->address);
+               if (rcv_noti_info == NULL)
+                       return;
+
+               file_path = __get_dest_file_path(transfer_info->file_path);
+               DBG_SECURE("Filename[%s] FilePath[%s] Address[%s]",
+                       transfer_info->filename, file_path, transfer_info->address);
+
+               if (aul_get_mime_from_file(file_path, mime_type, BT_MIME_TYPE_MAX_LEN) == AUL_R_OK)
+                       DBG_SECURE("mime type : %s", mime_type);
+
+               if (g_utf8_validate(file_path, -1, NULL)) {
+                       if (stat(file_path, &file_attr) == 0)
+                               file_size = file_attr.st_size;
+                       else
+                               file_size = 0;
                }
 
-               opc_cnt = g_strdup_printf("[%d/All]", current_file);
-
-               if (g_strcmp0(transfer_info->type, TRANSFER_GET) == 0) {
-                       /*GET request */
-                       _bt_set_notification_app_launch(noti,
-                                       transfer_info->device_name,
-                                       transfer_info->address,
-                                       rcv_db_sid,
-                                       CREATE_PROGRESS,
-                                       NOTI_TR_TYPE_OUT,
-                                       transfer_info->filename,
-                                       transfer_info->file_size, NULL,
-                                       transfer_info->transfer_id);
-               } else {
-                       /*PUT Request */
-                       _bt_add_recv_transfer_status_data(transfer_info->device_name,
-                                       transfer_info->address, transfer_info->filename, NULL,
-                                       file_size, BT_TR_ONGOING, rcv_noti_info->db_sid);
-                       rcv_noti_info->id = _bt_share_get_unique_id(BT_DB_INBOUND,
-                                       rcv_noti_info->db_sid);
-                       _bt_update_transfer_list_view(BT_INBOUND_TABLE);
-
-                       _bt_set_notification_app_launch(data->noti_handle,
-                                       transfer_info->device_name, transfer_info->address,
-                                       rcv_noti_info->db_sid, CREATE_PROGRESS,
-                                       NOTI_TR_TYPE_IN, transfer_info->filename,
-                                       transfer_info->file_size, NULL,
-                                       transfer_info->transfer_id);
-               }
+               g_free(file_path);
 
-#ifdef ENABLE_CONTACTS_SERVICE2
-#if 0
-               int contact_id = -1;
-
-               if (transfer_info->contact_auth_info) {
-                       unsigned char auth_info_null[5];
-                       memset(auth_info_null, 0X0, 5);
-                       if (memcmp(transfer_info->contact_auth_info, auth_info_null, 5)) {
-                               _bt_util_get_contact_info(transfer_info->contact_auth_info, &contact_id, &contact_name);
-                               DBG_SECURE("contact_id: %d | contact_name: [%s]", contact_id, contact_name);
-                       }
+               if (rcv_noti_info->recv_data.tr_success == -1
+                               && rcv_noti_info->recv_data.tr_fail == -1) {
+                       rcv_noti_info->recv_data.tr_success = 0;
+                       rcv_noti_info->recv_data.tr_fail = 0;
                }
-#endif
-#endif
-               char *receiving_files = "IDS_WIFI_BODY_RECEIVING_FILES_FROM_PS_ING";
-
-               INFO("Notification data: %p", data);
-               if (data) {
-                       _bt_update_notification(ad, data->noti_handle,
-                               transfer_info->filename, receiving_files,
-                               transfer_info->device_name, NULL, opc_cnt);
-                       _bt_update_notification_progress(data->noti_handle,
-                                       data->noti_id, 0);
+
+               if (param->result != BLUETOOTH_ERROR_NONE) {
+                       rcv_noti_info->recv_data.tr_fail++;
+                       _bt_update_recv_data_status(rcv_noti_info->id, BT_TR_FAIL,
+                               rcv_noti_info->db_sid, file_size, mime_type);
+               } else {
+                       rcv_noti_info->recv_data.tr_success++;
+                       _bt_update_recv_data_status(rcv_noti_info->id, BT_TR_SUCCESS,
+                               rcv_noti_info->db_sid, file_size, mime_type);
+                       if (data)
+                               _bt_update_notification_progress(data->noti_handle, data->noti_id, 100);
                }
 
-               _bt_set_transfer_indicator(TRUE);
-               _bt_share_block_sleep(TRUE);
-               g_free(opc_cnt);
-               g_free(contact_name);
-               break;
+               _bt_update_transfer_list_view(BT_INBOUND_TABLE);
+       } else if (g_strcmp0(transfer_info->type, TRANSFER_GET) == 0) {
+               INFO("TRANSFER_GET");
        }
 
-       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS: {
-               if (param->result == BLUETOOTH_ERROR_NONE) {
-                       transfer_info = param->param_data;
-                       data = __bt_get_noti_data_by_transfer_id(
-                                               transfer_info->transfer_id);
-                       retm_if(data == NULL, "Data is NULL, returning");
+       if (param->result == BLUETOOTH_ERROR_NONE) {
+               bt_file_type_e file_type;
+               char *extn = NULL;
+               bt_file_info_t *info = NULL;
 
-                       if (data && data->noti_id)
-                               _bt_update_notification_progress(
-                                               data->noti_handle,
-                                               data->noti_id,
-                                               transfer_info->percentage);
-                       else
-                               DBG("noti_id is not exist!");
-               }
-               break;
-       }
-
-       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED: {
-               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED");
-               char mime_type[BT_MIME_TYPE_MAX_LEN] = {0, };
-               unsigned int file_size = 0;
-               struct stat file_attr;
-               char *file_path = NULL;
                transfer_info = param->param_data;
-               _bt_set_transfer_indicator(FALSE);
-               _bt_share_block_sleep(FALSE);
+               if (transfer_info->file_path == NULL) {
+                       ERR("File path is NULL");
+                       return;
+               }
 
-               data = __bt_get_noti_data_by_transfer_id(transfer_info->transfer_id);
+               if (!g_strcmp0(transfer_info->type, TRANSFER_GET)) {
+                       DBG("Transfer is GET, so no need to handle");
+                       return;
+               }
 
-               if (g_strcmp0(transfer_info->type, TRANSFER_PUT) == 0) {
-                       INFO("TRANSFER_PUT");
+               char *name = __get_dest_file_path(transfer_info->file_path);
 
-                       bt_device_rcv_noti_info_t *rcv_noti_info =
-                               __bt_get_rcv_noti_data_by_device_address(transfer_info->address);
+               extn = strrchr(name, '.');
+               if (extn != NULL)
+                       extn++;
+               file_type = __get_file_type(extn);
 
-                       if (rcv_noti_info == NULL)
-                               break;
+               INFO("file type %d", file_type);
 
-                       file_path = __get_dest_file_path(transfer_info->file_path);
-                       DBG_SECURE("Filename[%s] FilePath[%s] Address[%s]",
-                                       transfer_info->filename, file_path,
-                                       transfer_info->address);
+               if (transfer_info->server_type == FTP_SERVER || file_type != BT_FILE_VCARD) {
+                       if (file_type != BT_FILE_VCAL)
+                               __bt_scan_media_file(name);
 
-                       if (aul_get_mime_from_file(file_path, mime_type,
-                                       BT_MIME_TYPE_MAX_LEN) == AUL_R_OK)
-                               DBG_SECURE("mime type : %s", mime_type);
+                       if (file_type != BT_FILE_VCARD)
+                               __bt_move_media_file(name);
+                       else
+                               ecore_file_remove(name);
 
-                       if (g_utf8_validate(file_path, -1, NULL)) {
-                               if (stat(file_path, &file_attr) == 0)
-                                       file_size = file_attr.st_size;
-                               else
-                                       file_size = 0;
-                       }
+                       g_free(name);
+                       return;
+               }
 
-                       g_free(file_path);
+               info = g_new0(bt_file_info_t, 1);
+               info->file_path = name;
+               info->file_type = file_type;
 
-                       if (rcv_noti_info->recv_data.tr_success == -1 &&
-                                       rcv_noti_info->recv_data.tr_fail == -1) {
-                               rcv_noti_info->recv_data.tr_success = 0;
-                               rcv_noti_info->recv_data.tr_fail = 0;
-                       }
+               pthread_t thread_id = 0;
+               if (pthread_create(&thread_id, NULL, (void *)&__bt_obex_writeclose, info) < 0) {
+                       ERR("pthread_create() is failed");
+                       __free_file_info(info);
+                       return;
+               }
+               warn_if(pthread_detach(thread_id) < 0, "pthread_detach() is failed");
+       } else {
+               DBG("param->result = %d", param->result);
+               DBG("opp_transfer_abort by user %d ", ad->opp_transfer_abort);
 
-                       if (param->result != BLUETOOTH_ERROR_NONE) {
-                               rcv_noti_info->recv_data.tr_fail++;
-                               _bt_update_recv_data_status(rcv_noti_info->id,
-                                                       BT_TR_FAIL, rcv_noti_info->db_sid,
-                                                       file_size, mime_type);
-                       } else {
-                               rcv_noti_info->recv_data.tr_success++;
-                               _bt_update_recv_data_status(rcv_noti_info->id,
-                                                       BT_TR_SUCCESS, rcv_noti_info->db_sid,
-                                                       file_size, mime_type);
-                               if (data)
-                                       _bt_update_notification_progress(data->noti_handle,
-                                                       data->noti_id, 100);
-                       }
+               if (!ad->opp_transfer_abort)
+                       _bt_create_warning_popup(param->result, BT_STR_UNABLE_TO_RECEIVE);
 
-                       _bt_update_transfer_list_view(BT_INBOUND_TABLE);
+               ad->opp_transfer_abort = FALSE;
+       }
+}
 
-               } else if (g_strcmp0(transfer_info->type, TRANSFER_GET) == 0) {
-                       INFO("TRANSFER_GET");
-               }
+static inline void _bt_event_obex_server_transfer_disconnected(bt_appdata_t *ad,
+       bluetooth_event_param_t *param, opc_transfer_info_t *node)
+{
+       bt_obex_server_transfer_info_t *transfer_info = param->param_data;
 
-               if (param->result == BLUETOOTH_ERROR_NONE) {
-                       bt_file_type_e file_type;
-                       char *extn = NULL;
-                       bt_file_info_t *info = NULL;
+       char *address = transfer_info->address;
+       int transfer_id = transfer_info->transfer_id;
+       int ret;
 
-                       transfer_info = param->param_data;
-                       if (transfer_info->file_path == NULL) {
-                               ERR("File path is NULL");
-                               break;
-                       }
+       DBG_SECURE("OBEX Disconnected from: %s, transfer_id: %d", address, transfer_id);
 
-                       if (!g_strcmp0(transfer_info->type, TRANSFER_GET)) {
-                               DBG("Transfer is GET, so no need to handle");
-                               break;
-                       }
+       if (param->result == BLUETOOTH_ERROR_NONE)
+               isTransferConnectedReceived = FALSE;
 
-                       name = __get_dest_file_path(transfer_info->file_path);
+       /* P150828-03206 : OPP connection is disconnected without completed event
+       in this case, noti should be removed in the disconnected event */
+       bt_noti_data_t *data = __bt_get_noti_data_by_transfer_id(transfer_id);
+       if (data) {
+               DBG("delete noti in the disconnected event!");
+               _bt_delete_notification(data->noti_handle);
+               bt_receive_noti_list = g_slist_remove(bt_receive_noti_list, data);
+               g_free(data);
+       }
 
-                       extn = strrchr(name, '.');
-                       if (extn != NULL)
-                               extn++;
-                       file_type = __get_file_type(extn);
+       DBG("Sending signal to bt-share-ui");
 
-                       INFO("file type %d", file_type);
+       /* Send Disconnect to Share-UI */
+       _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_SERVER_DISCONNECTED,
+               BLUETOOTH_ERROR_NONE, address, transfer_id);
 
-                       if (transfer_info->server_type == FTP_SERVER ||
-                                       file_type != BT_FILE_VCARD) {
-                               if (file_type != BT_FILE_VCAL)
-                                       __bt_scan_media_file(name);
+       bt_device_rcv_noti_info_t *rcv_noti_info =
+               __bt_get_rcv_noti_data_by_device_address(address);
+       if (rcv_noti_info == NULL) {
+               INFO("rcv_noti_info does not exist!");
+               return;
+       }
 
-                               if (file_type != BT_FILE_VCARD)
-                                       __bt_move_media_file(name);
-                               else
-                                       ecore_file_remove(name);
+       ad->recv_data.tr_success = rcv_noti_info->recv_data.tr_success;
+       ad->recv_data.tr_fail = rcv_noti_info->recv_data.tr_fail;
+       DBG("SUCCESS[%d] Failed[%d]", rcv_noti_info->recv_data.tr_success, rcv_noti_info->recv_data.tr_fail);
 
-                               g_free(name);
-                               break;
-                       }
+       if (rcv_noti_info->recv_data.tr_success == -1 &&
+               rcv_noti_info->recv_data.tr_fail == -1) {
+               __bt_free_rcv_notification(rcv_noti_info);
+               return;
+       }
+       notification_h rcv_noti_info_receive_noti = _bt_insert_notification(ad,
+               BT_RECEIVED_NOTI, rcv_noti_info->device_name,
+               rcv_noti_info->address, rcv_noti_info->db_sid);
+       ad->receive_noti = rcv_noti_info_receive_noti;
+       DBG("LAUNCH DATA: Filename [%s] TransferID[%d]",
+               transfer_info->filename, transfer_info->transfer_id);
+
+       _bt_set_notification_app_launch(rcv_noti_info_receive_noti,
+               rcv_noti_info->device_name, rcv_noti_info->address,
+               rcv_noti_info->db_sid, CREATE_TR_LIST,
+               NOTI_TR_TYPE_IN, transfer_info->filename,
+               0, NULL, transfer_info->transfer_id);
+       ret = notification_update(rcv_noti_info_receive_noti);
+       warn_if(ret != NOTIFICATION_ERROR_NONE,
+               "Fail to notification_update [%d]", ret);
+
+       if (rcv_noti_info->recv_data.tr_success != -1) {
+               if (rcv_noti_info->recv_data.tr_success)
+                       _bt_insert_instant_notification(BT_RECEIVED_NOTI);
+               else
+                       _bt_insert_instant_notification(BT_RECEIVED_FAILED_NOTI);
 
-                       info = g_new0(bt_file_info_t, 1);
-                       info->file_path = name;
-                       info->file_type = file_type;
+               /* Update Database with Notification ID*/
+               __bt_update_db_with_noti_id(BT_DB_INBOUND, rcv_noti_info_receive_noti,
+                       rcv_noti_info->db_sid);
+       }
 
-                       if (pthread_create(&thread_id, NULL, (void *)&__bt_obex_writeclose,
-                                                       info) < 0) {
-                               ERR("pthread_create() is failed");
-                               __free_file_info(info);
-                               break;
-                       }
-                       warn_if(pthread_detach(thread_id) < 0, "pthread_detach() is failed");
+       __bt_free_rcv_notification(rcv_noti_info);
+}
 
-               } else {
-                       DBG("param->result = %d", param->result);
-                       DBG("opp_transfer_abort by user %d ", ad->opp_transfer_abort);
+/* LCOV_EXCL_START */
+void _bt_share_event_handler(int event, bluetooth_event_param_t *param, void *user_data)
+{
+       bt_appdata_t *ad = app_state;
+       opc_transfer_info_t *node = NULL;
 
-                       if (!ad->opp_transfer_abort)
-                               _bt_create_warning_popup(param->result,
-                                       BT_STR_UNABLE_TO_RECEIVE);
+       if (bt_transfer_list)
+               node = bt_transfer_list->data;
 
-                       ad->opp_transfer_abort = FALSE;
+       switch (event) {
+       case BLUETOOTH_EVENT_ENABLED:
+               if (ad->obex_server_init == FALSE) {
+                       if (_bt_init_obex_server() == BT_SHARE_ERROR_NONE)
+                               ad->obex_server_init = TRUE;
                }
                break;
-       }
 
-       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED: {
-               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED");
-               transfer_info = param->param_data;
+       case BLUETOOTH_EVENT_DISABLED:
+               INFO("BT is disabled");
+               _bt_terminate_bluetooth_share();
+               break;
 
-               char *address = transfer_info->address;
-               int transfer_id = transfer_info->transfer_id;
-               int ret;
+       case BLUETOOTH_EVENT_OPC_CONNECTED:
+               INFO("BLUETOOTH_EVENT_OPC_CONNECTED, result [%d]", param->result);
+               _bt_event_opc_connected(param, node);
+               break;
 
-               DBG_SECURE("OBEX Disconnected from: %s, transfer_id: %d", address, transfer_id);
+       case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED:
+               INFO("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED");
+               _bt_event_opc_transfer_started(ad, node);
+               break;
 
-               if (param->result == BLUETOOTH_ERROR_NONE)
-                       isTransferConnectedReceived = FALSE;
+       case BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS:
+               _bt_event_opc_transfer_progress(ad, param, node);
+               break;
 
-               /* P150828-03206 : OPP connection is disconnected without completed event
-               in this case, noti should be removed in the disconnected event */
-               data = __bt_get_noti_data_by_transfer_id(transfer_id);
+       case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE:
+               INFO("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE");
+               _bt_event_opc_transfer_complete(ad, param, node);
+               break;
 
-               if (data) {
-                       DBG("delete noti in the disconnected event!");
-                       _bt_delete_notification(data->noti_handle);
-                       bt_receive_noti_list = g_slist_remove(bt_receive_noti_list, data);
-                       g_free(data);
-               }
+       case BLUETOOTH_EVENT_OPC_DISCONNECTED:
+               INFO("BLUETOOTH_EVENT_OPC_DISCONNECTED");
+               _bt_event_opc_disconnected(ad, node);
+               break;
 
-               DBG("Sending signal to bt-share-ui");
+       case BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE:
+               INFO("BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE");
+               break;
 
-               /* Send Disconnect to Share-UI */
-               _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_SERVER_DISCONNECTED,
-                               BLUETOOTH_ERROR_NONE, address, transfer_id);
+       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE:
+               INFO("BT_EVENT_OBEX_TRANSFER_AUTHORIZE");
+               _bt_event_obex_server_transfer_authorize(param);
+               break;
 
-               bt_device_rcv_noti_info_t *rcv_noti_info =
-                               __bt_get_rcv_noti_data_by_device_address(address);
-               if (rcv_noti_info == NULL) {
-                       INFO("rcv_noti_info does not exist!");
-                       break;
-               }
+       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED:
+               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED");
+               _bt_event_obex_server_transfer_connected(ad, param);
+               break;
 
-               ad->recv_data.tr_success = rcv_noti_info->recv_data.tr_success;
-               ad->recv_data.tr_fail = rcv_noti_info->recv_data.tr_fail;
-               DBG("SUCCESS[%d] Failed[%d]", rcv_noti_info->recv_data.tr_success, rcv_noti_info->recv_data.tr_fail);
+       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED:
+               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED");
+               _bt_event_obex_server_transfer_started(ad, param);
+               break;
 
-               if (rcv_noti_info->recv_data.tr_success == -1 &&
-                               rcv_noti_info->recv_data.tr_fail == -1) {
-                       __bt_free_rcv_notification(rcv_noti_info);
-                       break;
-               }
-               notification_h rcv_noti_info_receive_noti = _bt_insert_notification(ad,
-                               BT_RECEIVED_NOTI, rcv_noti_info->device_name,
-                               rcv_noti_info->address, rcv_noti_info->db_sid);
-               ad->receive_noti = rcv_noti_info_receive_noti;
-               DBG("LAUNCH DATA: Filename [%s] TransferID[%d]",
-                               transfer_info->filename, transfer_info->transfer_id);
-
-               _bt_set_notification_app_launch(rcv_noti_info_receive_noti,
-                               rcv_noti_info->device_name, rcv_noti_info->address,
-                               rcv_noti_info->db_sid, CREATE_TR_LIST,
-                               NOTI_TR_TYPE_IN, transfer_info->filename,
-                               0, NULL, transfer_info->transfer_id);
-               ret = notification_update(rcv_noti_info_receive_noti);
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                               "Fail to notification_update [%d]", ret);
-
-               if (rcv_noti_info->recv_data.tr_success != -1) {
-                       if (rcv_noti_info->recv_data.tr_success)
-                               _bt_insert_instant_notification(BT_RECEIVED_NOTI);
-                       else
-                               _bt_insert_instant_notification(BT_RECEIVED_FAILED_NOTI);
+       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS:
+               _bt_event_obex_server_transfer_progress(param);
+               break;
 
-                       /* Update Database with Notification ID*/
-                       __bt_update_db_with_noti_id(BT_DB_INBOUND, rcv_noti_info_receive_noti,
-                                       rcv_noti_info->db_sid);
-               }
+       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED: {
+               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED");
+               _bt_event_obex_server_transfer_completed(ad, param);
+               break;
+       }
 
-               __bt_free_rcv_notification(rcv_noti_info);
+       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED: {
+               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED");
+               _bt_event_obex_server_transfer_disconnected(ad, param, node);
                break;
        }
 
index 731bc23..59ca221 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * bluetooth-share-api
- *
  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
 extern "C" {
 #endif
 
-/*
- * SYSLOG_INFO(), SYSLOG_ERR(), SYSLOG_DBG() are syslog() wrappers.
- * PRT_INFO(), PRT_ERR(), PRT_DBG() are fprintf() wrappers.
- *
- * If SLP_DEBUG is not defined, SYSLOG_DBG() and PRT_DBG() is ignored.
- *
- * IF SLP_SYSLOG_OUT or SLP_DAEMON is defined,
- *   INFO(), ERR(), DBG() are SYSLOG_XXX()
- * Otherwise,
- *   They are PRT_XXX()
- *
- *
- * warn_if(exrp, fmt, ...)
- *   If expr is true, The fmt string is printed using ERR().
- *
- * ret_if(), retv_if(), retm_if(), retvm_if()
- *   If expr is true, current function return.
- *   Postfix 'v' means that it has a return value and
- *   'm' means that it has output message.
- *
- */
-
 #include <stdio.h>
 #include <dlog.h>
 
index f811aa4..ba1aef0 100644 (file)
@@ -24,6 +24,7 @@
 extern "C" {
 #endif
 
+#include <glib.h>
 #include <db-util.h>
 
 #ifndef EXPORT_API
index 33b4b3e..931a24d 100644 (file)
@@ -40,12 +40,12 @@ INCLUDE(FindPkgConfig)
 pkg_check_modules(testpkgs REQUIRED glib-2.0)
 
 SET(GTEST_TESTS_SOURCES
-bluetooth-share_test.cpp
+bt-share-test.cpp
 )
 
 SET(BLUETOOTH_SHARE_MOCK "bluetooth-share-mock")
 SET(BLUETOOTH_SHARE_MOCK_SRCS
-       mock/bluetooth-share-mock.c)
+       mock/bt-share-mock.c)
 SET(BLUETOOTH_SHARE_MOCK_CFLAGS "${CMAKE_C_FLAGS}" )
 ADD_LIBRARY(${BLUETOOTH_SHARE_MOCK} SHARED ${BLUETOOTH_SHARE_MOCK_SRCS})
 TARGET_LINK_LIBRARIES(${BLUETOOTH_SHARE_MOCK} -ldl)
similarity index 75%
rename from tests/bluetooth-share_test.cpp
rename to tests/bt-share-test.cpp
index 7191ac4..5b86fee 100644 (file)
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
-/**
- * @file        bluetooth-share_test.cpp
- * @author      abc
- * @version     1.0
- * @brief       Unit-tests setup
- */
-
 #include <gtest/gtest.h>
 #include <unistd.h>
 #include <glib.h>
@@ -34,7 +27,8 @@
 #include "bt-share-syspopup.h"
 #include "obex-event-handler.h"
 
-TEST(BluetoothShare_test, _bt_share_block_sleep_p) {
+TEST(BluetoothShare_test, _bt_share_block_sleep_p)
+{
        int ret = BT_SHARE_ERROR_NONE;
 
        ret = _bt_share_block_sleep(TRUE);
@@ -50,14 +44,16 @@ TEST(BluetoothShare_test, _bt_share_block_sleep_p) {
        ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
 }
 
-TEST(BluetoothShare_test, _bt_share_block_sleep_n) {
+TEST(BluetoothShare_test, _bt_share_block_sleep_n)
+{
        int ret = BT_SHARE_ERROR_NONE;
 
        ret = _bt_share_block_sleep(FALSE);
        ASSERT_TRUE(ret == BT_SHARE_FAIL);
 }
 
-TEST(BluetoothShare_test, _bt_set_transfer_indicator_p) {
+TEST(BluetoothShare_test, _bt_set_transfer_indicator_p)
+{
        int ret = BT_SHARE_ERROR_NONE;
 
        ret = _bt_set_transfer_indicator(TRUE);
@@ -73,15 +69,18 @@ TEST(BluetoothShare_test, _bt_set_transfer_indicator_p) {
        ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
 }
 
-TEST(BluetoothShare_test, _bt_remove_tmp_file_p) {
+TEST(BluetoothShare_test, _bt_remove_tmp_file_p)
+{
        _bt_remove_tmp_file(BT_TMP_FILE);
 }
 
-TEST(BluetoothShare_test, _bt_remove_vcf_file_p) {
+TEST(BluetoothShare_test, _bt_remove_vcf_file_p)
+{
        _bt_remove_vcf_file(BT_CONTACT_SHARE_TMP_DIR"test");
 }
 
-TEST(BluetoothShare_test, _bt_share_create_transfer_file_p) {
+TEST(BluetoothShare_test, _bt_share_create_transfer_file_p)
+{
        char *file = NULL;
 
        file = _bt_share_create_transfer_file("http://www.tizen.org");
@@ -97,14 +96,16 @@ TEST(BluetoothShare_test, _bt_share_create_transfer_file_p) {
        g_free(file);
 }
 
-TEST(BluetoothShare_test, _bt_share_create_transfer_file_n) {
+TEST(BluetoothShare_test, _bt_share_create_transfer_file_n)
+{
        char *file = NULL;
 
        file = _bt_share_create_transfer_file(NULL);
        ASSERT_TRUE(file == NULL);
 }
 
-TEST(BluetoothShare_test, _bt_get_time_of_the_day_p) {
+TEST(BluetoothShare_test, _bt_get_time_of_the_day_p)
+{
        char *time = NULL;
 
        time = _bt_get_time_of_the_day();
@@ -113,7 +114,8 @@ TEST(BluetoothShare_test, _bt_get_time_of_the_day_p) {
        g_free(time);
 }
 
-TEST(BluetoothShare_test, _bt_share_get_storage_path_p) {
+TEST(BluetoothShare_test, _bt_share_get_storage_path_p)
+{
        char *path = NULL;
 
        path = _bt_share_get_storage_path(BT_DEFAULT_MEM_PHONE);
@@ -128,7 +130,8 @@ TEST(BluetoothShare_test, _bt_share_get_storage_path_p) {
 }
 
 
-TEST(BluetoothShare_test, _bt_share_get_active_uid_p) {
+TEST(BluetoothShare_test, _bt_share_get_active_uid_p)
+{
        int ret = BT_SHARE_ERROR_NONE;
        uid_t uid = 0;
 
@@ -137,7 +140,8 @@ TEST(BluetoothShare_test, _bt_share_get_active_uid_p) {
        ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
 }
 
-TEST(BluetoothShare_test, _remove_transfer_info_p) {
+TEST(BluetoothShare_test, _remove_transfer_info_p)
+{
        opc_transfer_info_t *data = NULL;
 
        data = g_new0(opc_transfer_info_t, 1);
@@ -150,7 +154,8 @@ TEST(BluetoothShare_test, _remove_transfer_info_p) {
        _remove_transfer_info(data);
 }
 
-TEST(BluetoothShare_test, _bt_init_dbus_signal_p) {
+TEST(BluetoothShare_test, _bt_init_dbus_signal_p)
+{
        gboolean ret = FALSE;
 
        ret = _bt_init_dbus_signal();
@@ -161,7 +166,8 @@ TEST(BluetoothShare_test, _bt_init_dbus_signal_p) {
 }
 
 
-TEST(BluetoothShare_test, _bt_send_disconnected_signal_p) {
+TEST(BluetoothShare_test, _bt_send_disconnected_signal_p)
+{
        gboolean ret = FALSE;
 
        ret = _bt_init_dbus_signal();
@@ -169,12 +175,13 @@ TEST(BluetoothShare_test, _bt_send_disconnected_signal_p) {
        ASSERT_TRUE(ret == TRUE);
 
        _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED,
-                                                       BLUETOOTH_ERROR_NONE, "BT address", 0);
+               BLUETOOTH_ERROR_NONE, "BT address", 0);
 
        _bt_deinit_dbus_signal();
 }
 
-TEST(BluetoothShare_test, _bt_update_transfer_list_view_p) {
+TEST(BluetoothShare_test, _bt_update_transfer_list_view_p)
+{
        gboolean ret = FALSE;
 
        ret = _bt_init_dbus_signal();
@@ -187,7 +194,8 @@ TEST(BluetoothShare_test, _bt_update_transfer_list_view_p) {
 }
 
 
-TEST(BluetoothShare_test, _bt_create_warning_popup_p) {
+TEST(BluetoothShare_test, _bt_create_warning_popup_p)
+{
        gboolean ret = FALSE;
 
        ret = _bt_init_dbus_signal();
@@ -199,7 +207,8 @@ TEST(BluetoothShare_test, _bt_create_warning_popup_p) {
        _bt_deinit_dbus_signal();
 }
 
-TEST(BluetoothShare_test, _bt_update_sent_data_status_p) {
+TEST(BluetoothShare_test, _bt_update_sent_data_status_p)
+{
        gboolean ret = FALSE;
 
        ret = _bt_update_sent_data_status(1, BT_TR_ONGOING, "1");
@@ -207,7 +216,8 @@ TEST(BluetoothShare_test, _bt_update_sent_data_status_p) {
        ASSERT_TRUE(ret == TRUE);
 }
 
-TEST(BluetoothShare_test, _bt_update_recv_data_status_p) {
+TEST(BluetoothShare_test, _bt_update_recv_data_status_p)
+{
        gboolean ret = FALSE;
 
        ret = _bt_update_recv_data_status(1, BT_TR_FAIL, "1", 100, "text/vcard");
@@ -215,35 +225,39 @@ TEST(BluetoothShare_test, _bt_update_recv_data_status_p) {
        ASSERT_TRUE(ret == TRUE);
 }
 
-TEST(BluetoothShare_test, _bt_update_multiple_sent_data_status_p) {
+TEST(BluetoothShare_test, _bt_update_multiple_sent_data_status_p)
+{
        gboolean ret = FALSE;
 
-       int uids[2] = { 1, 2};
+       int uids[2] = {1, 2};
 
        ret = _bt_update_multiple_sent_data_status(uids, 1, BT_TR_FAIL, "1");
 
        ASSERT_TRUE(ret == TRUE);
 }
 
-TEST(BluetoothShare_test, _bt_add_recv_transfer_status_data_p) {
+TEST(BluetoothShare_test, _bt_add_recv_transfer_status_data_p)
+{
        gboolean ret = FALSE;
 
        ret = _bt_add_recv_transfer_status_data("NAME",
-                                       "ADDRESS", "FILE NAME", "TYPE",
-                                       100, BT_TR_ONGOING, "1");
+               "ADDRESS", "FILE NAME", "TYPE",
+               100, BT_TR_ONGOING, "1");
 
        ASSERT_TRUE(ret == TRUE);
 }
 
-TEST(BluetoothShare_test, _bt_share_get_unique_id_p) {
+TEST(BluetoothShare_test, _bt_share_get_unique_id_p)
+{
        int id;
 
-       id = _bt_share_get_unique_id(BT_DB_INBOUND,     "1");
+       id = _bt_share_get_unique_id(BT_DB_INBOUND, "1");
 
        ASSERT_FALSE(id < 0);
 }
 
-TEST(BluetoothShare_test, _bt_set_eventsystem_transfer_value_p) {
+TEST(BluetoothShare_test, _bt_set_eventsystem_transfer_value_p)
+{
        int ret = BT_SHARE_ERROR_NONE;
 
        ret = _bt_set_eventsystem_transfer_value(TRUE);
@@ -251,12 +265,13 @@ TEST(BluetoothShare_test, _bt_set_eventsystem_transfer_value_p) {
        ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
 }
 
-TEST(BluetoothShare_test, _bt_terminate_bluetooth_share_p) {
+TEST(BluetoothShare_test, _bt_terminate_bluetooth_share_p)
+{
        _bt_terminate_bluetooth_share();
 }
 
-
-TEST(BluetoothShare_test, _bt_remove_temporary_files_by_noti_id_p) {
+TEST(BluetoothShare_test, _bt_remove_temporary_files_by_noti_id_p)
+{
        sqlite3 *db = NULL;
 
        db = bt_share_open_db();
@@ -266,22 +281,23 @@ TEST(BluetoothShare_test, _bt_remove_temporary_files_by_noti_id_p) {
        bt_share_close_db(db);
 }
 
-TEST(BluetoothShare_test, _bt_init_obex_server_p) {
-       int ret = BT_SHARE_ERROR_NONE;
-
-       ret = _bt_init_obex_server();
+TEST(BluetoothShare_test, _bt_init_obex_server_p)
+{
+       _bt_init_obex_server();
 
        /* bluetooth-share process already allocate the obex serivce, so will return the error */
        /* ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE); */
 }
 
-TEST(BluetoothShare_test, _bt_init_vconf_notification_p) {
+TEST(BluetoothShare_test, _bt_init_vconf_notification_p)
+{
        _bt_init_vconf_notification(NULL);
 
        _bt_deinit_vconf_notification();
 }
 
-TEST(BluetoothShare_test, _bt_insert_instant_notification_p) {
+TEST(BluetoothShare_test, _bt_insert_instant_notification_p)
+{
        _bt_insert_instant_notification(BT_SENT_NOTI);
 
        _bt_insert_instant_notification(BT_SENT_FAILED_NOTI);
@@ -295,7 +311,8 @@ TEST(BluetoothShare_test, _bt_insert_instant_notification_p) {
        _bt_insert_instant_notification(BT_RECEIVING_NOTI);
 }
 
-TEST(BluetoothShare_test, _bt_notification_test_p) {
+TEST(BluetoothShare_test, _bt_notification_test_p)
+{
        bt_appdata_t *ad = NULL;
 
        notification_h noti = NULL;
@@ -304,8 +321,8 @@ TEST(BluetoothShare_test, _bt_notification_test_p) {
 
 
        noti = _bt_insert_notification(ad,
-                                                       BT_SENDING_NOTI, "TEST",
-                                                       "test address", "1");
+               BT_SENDING_NOTI, "TEST",
+               "test address", "1");
 
        if (noti == NULL)
                g_free(ad);
@@ -316,17 +333,17 @@ TEST(BluetoothShare_test, _bt_notification_test_p) {
        ad->opc_noti_id = _bt_get_notification_priv_id(noti);
 
        _bt_set_notification_app_launch(noti, "TEST", "test address", "1",
-                                       CREATE_TR_LIST, NOTI_TR_TYPE_OUT, NULL, 0, NULL, 0);
+               CREATE_TR_LIST, NOTI_TR_TYPE_OUT, NULL, 0, NULL, 0);
 
        _bt_update_notification(ad, ad->send_noti,
-                                                       NULL, NULL, NULL, NULL, NULL);
+               NULL, NULL, NULL, NULL, NULL);
 
        _bt_delete_notification(noti);
        ad->send_noti = NULL;
 
        noti = _bt_insert_notification(ad,
-                                                       BT_RECEIVED_NOTI, "TEST",
-                                                       "test address", "1");
+               BT_RECEIVED_NOTI, "TEST",
+               "test address", "1");
 
        if (noti == NULL)
                g_free(ad);
@@ -336,14 +353,14 @@ TEST(BluetoothShare_test, _bt_notification_test_p) {
        ad->receive_noti = noti;
 
        _bt_update_notification(ad, ad->receive_noti,
-                                                       NULL, NULL, NULL, NULL, NULL);
+               NULL, NULL, NULL, NULL, NULL);
 
        _bt_delete_notification(noti);
        ad->receive_noti = NULL;
 
        noti = _bt_insert_notification(ad,
-                                                       BT_SENDING_NOTI, "TEST",
-                                                       "test address", "1");
+               BT_SENDING_NOTI, "TEST",
+               "test address", "1");
 
        if (noti == NULL)
                g_free(ad);
@@ -353,16 +370,16 @@ TEST(BluetoothShare_test, _bt_notification_test_p) {
        ad->opc_noti_id = _bt_get_notification_priv_id(noti);
 
        _bt_set_notification_app_launch(noti, "TEST", "test address",
-                                               "1", CREATE_PROGRESS, NOTI_TR_TYPE_OUT,
-                                               "TEST", 0, NULL, 1);
+               "1", CREATE_PROGRESS, NOTI_TR_TYPE_OUT,
+               "TEST", 0, NULL, 1);
 
        _bt_update_notification_progress(noti, ad->opc_noti_id, 100);
 
        _bt_delete_notification(noti);
 
        noti = _bt_insert_notification(ad,
-                                                       BT_RECEIVING_NOTI, "TEST",
-                                                       "test address", "1");
+               BT_RECEIVING_NOTI, "TEST",
+               "test address", "1");
 
        if (noti == NULL)
                g_free(ad);
@@ -373,24 +390,26 @@ TEST(BluetoothShare_test, _bt_notification_test_p) {
 }
 
 
-TEST(BluetoothShare_test, _bt_register_notification_cb_p) {
+TEST(BluetoothShare_test, _bt_register_notification_cb_p)
+{
        _bt_register_notification_cb(NULL);
 
        _bt_unregister_notification_cb(NULL);
 }
 
-TEST(BluetoothShare_test, _bt_launch_system_popup_p) {
-       bt_app_sys_popup_params_t popup_params = { NULL };
+TEST(BluetoothShare_test, _bt_launch_system_popup_p)
+{
+       bt_app_sys_popup_params_t popup_params = {NULL};
        int ret = BT_SHARE_ERROR_NONE;
        bt_appdata_t *ad = NULL;
 
-       ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
+       ad = (bt_appdata_t*)calloc(1, sizeof(bt_appdata_t));
 
        popup_params.title = BT_STR_MEMORY_FULL;
-       popup_params.type = "none";
+       popup_params.type = (char*)"none";
 
        ret = _bt_launch_system_popup(BT_APP_EVENT_CONFIRM_MODE_REQUEST,
-                               &popup_params, NULL, ad);
+               &popup_params, NULL, ad);
 
        if (ret != BT_SHARE_ERROR_NONE)
                g_free(ad);
@@ -401,7 +420,7 @@ TEST(BluetoothShare_test, _bt_launch_system_popup_p) {
        usleep(1000 * 200);
 
        ret = _bt_launch_system_popup(BT_APP_EVENT_FILE_RECEIVED,
-                               &popup_params, NULL, ad);
+               &popup_params, NULL, ad);
 
        syspopup_destroy_all();
        usleep(1000 * 200);
@@ -412,7 +431,7 @@ TEST(BluetoothShare_test, _bt_launch_system_popup_p) {
        ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
 
        ret = _bt_launch_system_popup(BT_APP_EVENT_INFORMATION,
-                       &popup_params, NULL, ad);
+               &popup_params, NULL, ad);
 
        if (ret != BT_SHARE_ERROR_NONE)
                g_free(ad);
@@ -423,7 +442,7 @@ TEST(BluetoothShare_test, _bt_launch_system_popup_p) {
        usleep(1000 * 200);
 
        ret = _bt_launch_system_popup(BT_APP_EVENT_OVERWRITE_REQUEST,
-                               &popup_params, NULL, ad);
+               &popup_params, NULL, ad);
 
        if (ret != BT_SHARE_ERROR_NONE)
                g_free(ad);
@@ -434,13 +453,15 @@ TEST(BluetoothShare_test, _bt_launch_system_popup_p) {
        usleep(1000 * 200);
 }
 
-TEST(BluetoothShare_test, _bt_app_popup_memoryfull_p) {
+TEST(BluetoothShare_test, _bt_app_popup_memoryfull_p)
+{
        _bt_app_popup_memoryfull(NULL);
 }
 
-TEST(BluetoothShare_test, _bt_convert_addr_type_to_string_p) {
-       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0, };
-       char addr[BT_ADDRESS_LENGTH] = {0, };
+TEST(BluetoothShare_test, _bt_convert_addr_type_to_string_p)
+{
+       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0,};
+       char addr[BT_ADDRESS_LENGTH] = {0,};
 
        addr[0] = '1';
        addr[1] = '1';
@@ -452,7 +473,8 @@ TEST(BluetoothShare_test, _bt_convert_addr_type_to_string_p) {
        _bt_convert_addr_type_to_string(bd_addr, addr);
 }
 
-TEST(BluetoothShare_test, _bt_obex_cancel_transfer_p) {
+TEST(BluetoothShare_test, _bt_obex_cancel_transfer_p)
+{
        bt_appdata_t *ad = NULL;
 
        ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
@@ -462,17 +484,20 @@ TEST(BluetoothShare_test, _bt_obex_cancel_transfer_p) {
        g_free(ad);
 }
 
-TEST(BluetoothShare_test, _bt_clear_receive_noti_list_p) {
+TEST(BluetoothShare_test, _bt_clear_receive_noti_list_p)
+{
        _bt_clear_receive_noti_list();
 }
 
-TEST(BluetoothShare_test, _bt_get_default_storage_p) {
-       char storage[STORAGE_PATH_LEN_MAX] = {0, };
+TEST(BluetoothShare_test, _bt_get_default_storage_p)
+{
+       char storage[STORAGE_PATH_LEN_MAX] = {0,};
 
        _bt_get_default_storage(storage);
 }
 
-TEST(BluetoothShare_test, _bt_get_available_int_memory_p) {
+TEST(BluetoothShare_test, _bt_get_available_int_memory_p)
+{
        int ret = 0;
        double available_int_mem_size = 0;
 
@@ -481,7 +506,8 @@ TEST(BluetoothShare_test, _bt_get_available_int_memory_p) {
        ASSERT_TRUE(ret >= 0);
 }
 
-TEST(BluetoothShare_test, _bt_get_available_ext_memory_p) {
+TEST(BluetoothShare_test, _bt_get_available_ext_memory_p)
+{
        int ret = 0;
        unsigned long long available_ext_mem_size = 0;
 
@@ -490,7 +516,8 @@ TEST(BluetoothShare_test, _bt_get_available_ext_memory_p) {
        ASSERT_TRUE(ret >= 0);
 }
 
-TEST(BluetoothShareApi_test, bt_share_db_api_test_p) {
+TEST(BluetoothShareApi_test, bt_share_db_api_test_p)
+{
        int ret = BT_SHARE_ERR_NONE;
        int session_id = -1;
        int cnt = -1;
@@ -507,14 +534,14 @@ TEST(BluetoothShareApi_test, bt_share_db_api_test_p) {
 
        tmp->tr_status = BT_TRANSFER_FAIL;
        tmp->sid = 1;
-       tmp->file_path = "TEST";
-       tmp->content = "TEST";
-       tmp->dev_name = "TEST";
-       tmp->type = "TEST";
+       tmp->file_path = (char*)"TEST";
+       tmp->content = (char*)"TEST";
+       tmp->dev_name = (char*)"TEST";
+       tmp->type = (char*)"TEST";
        tmp->timestamp = 2;
-       tmp->addr = "TEST";
+       tmp->addr = (char*)"TEST";
        tmp->size = 0;
-       tmp->db_sid = "1";
+       tmp->db_sid = (char*)"1";
 
        ret = bt_share_add_tr_data(db, BT_DB_OUTBOUND, tmp);
 
@@ -550,7 +577,7 @@ TEST(BluetoothShareApi_test, bt_share_db_api_test_p) {
        tr_data_list = NULL;
 
        tr_data_list = bt_share_get_all_tr_data_by_sid(db,
-                                       BT_DB_OUTBOUND, "TEST", "1");
+               BT_DB_OUTBOUND, "TEST", "1");
 
        if (tr_data_list == NULL) {
                bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
@@ -564,7 +591,7 @@ TEST(BluetoothShareApi_test, bt_share_db_api_test_p) {
        tr_data_list = NULL;
 
        tr_data_list = bt_share_get_failed_tr_data_by_sid(db,
-                                       BT_DB_OUTBOUND, "TEST", "1");
+               BT_DB_OUTBOUND, "TEST", "1");
 
        if (tr_data_list == NULL) {
                bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
@@ -622,9 +649,9 @@ TEST(BluetoothShareApi_test, bt_share_db_api_test_p) {
        g_free(tmp);
 }
 
+int main(int argc, char **argv)
+{
+       testing::InitGoogleTest(&argc, argv);
 
-int main(int argc, char **argv) {
-  testing::InitGoogleTest(&argc, argv);
-
-  return RUN_ALL_TESTS();
+       return RUN_ALL_TESTS();
 }
similarity index 99%
rename from tests/mock/bluetooth-share-mock.c
rename to tests/mock/bt-share-mock.c
index fb3ec1c..a4dc242 100644 (file)
@@ -267,6 +267,7 @@ API int sqlite3_bind_int(sqlite3_stmt *param1, int param2, int param3)
 
 API int sqlite3_reset(sqlite3_stmt *pStmt)
 {
+       return 0;
 }
 
 API const char *sqlite3_errmsg(sqlite3 *param1)
@@ -281,7 +282,7 @@ API int sqlite3_column_int(sqlite3_stmt *param1, int iCol)
 
 API const unsigned char *sqlite3_column_text(sqlite3_stmt *param1, int iCol)
 {
-       return "1234";
+       return (const unsigned char*)"1234";
 }
 
 API notification_h notification_create(notification_type_e type)