Fix the sending failed count (TSAM-9574) 74/96674/1 accepted/tizen/common/20161110.190142 accepted/tizen/ivi/20161111.001148 accepted/tizen/mobile/20161111.001053 accepted/tizen/tv/20161111.001107 accepted/tizen/wearable/20161111.001130 submit/tizen/20161110.000647
authorHyuk Lee <hyuk0512.lee@samsung.com>
Wed, 9 Nov 2016 08:35:10 +0000 (17:35 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 10 Nov 2016 00:06:11 +0000 (09:06 +0900)
Change-Id: I30b8a83766067a96997fe037050ae73c642f495e
Signed-off-by: Hyuk Lee <hyuk0512.lee@samsung.com>
bt-share/src/obex-event-handler.c

index eedec78..90e1972 100644 (file)
@@ -226,6 +226,7 @@ void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
 {
        int ret;
        static int send_index = 0;
+       static gboolean is_started = FALSE;
        int percentage = 0;
        int s_id = 0;
        char *name = NULL;
@@ -254,6 +255,7 @@ void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
        case BLUETOOTH_EVENT_OPC_CONNECTED:
                INFO("BLUETOOTH_EVENT_OPC_CONNECTED, result [%d] \n", param->result);
                send_index = 0;
+               is_started = FALSE;
                if (param->result != BLUETOOTH_ERROR_NONE) {
                        _bt_create_warning_popup(param->result,
                                BT_STR_UNABLE_TO_SEND);
@@ -314,6 +316,8 @@ void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
                INFO("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED");
                ret_if(node == NULL);
 
+               is_started = TRUE;
+
                if (ad->opc_noti) {
                        _bt_delete_notification(ad->opc_noti);
                        ad->opc_noti = NULL;
@@ -366,6 +370,17 @@ void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
        case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE:
                INFO("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE");
 
+               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++;
+               }
+
+               is_started = FALSE;
+
                client_info = (bt_opc_transfer_info_t *)param->param_data;
                ret_if(client_info == NULL);
 
@@ -413,6 +428,7 @@ void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
                                        BT_STR_UNABLE_TO_SEND);
                        ad->opp_transfer_abort = FALSE;
                        _bt_update_transfer_list_view("outbound");
+                       ad->tr_next_data = g_slist_next(ad->tr_next_data);
                        break;
                } else {
                        _bt_update_sent_data_status(ad->current_tr_uid,
@@ -425,18 +441,21 @@ void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
                break;
 
 
-       case BLUETOOTH_EVENT_OPC_DISCONNECTED: 
+       case BLUETOOTH_EVENT_OPC_DISCONNECTED:
                INFO("BLUETOOTH_EVENT_OPC_DISCONNECTED");
                ret_if(node == NULL);
 
                if (node->file_cnt > send_index) {
                        send_index = 0;
+                       is_started = FALSE;
+
                        if (!ad) {
                                ERR("ad is NULL");
                                break;
                        }
                        if (!ad->tr_next_data) {
                                send_index = 0;
+                               is_started = FALSE;
                                _bt_share_block_sleep(FALSE);
                                _bt_set_transfer_indicator(FALSE);
                                _remove_transfer_info(node);
@@ -481,6 +500,7 @@ void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
 
 
                send_index = 0;
+               is_started = FALSE;
                _bt_share_block_sleep(FALSE);
                _bt_set_transfer_indicator(FALSE);
                _remove_transfer_info(node);