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);
#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;
}
* 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>
#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);
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);
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");
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();
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);
}
-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;
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);
_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();
}
-TEST(BluetoothShare_test, _bt_send_disconnected_signal_p) {
+TEST(BluetoothShare_test, _bt_send_disconnected_signal_p)
+{
gboolean ret = FALSE;
ret = _bt_init_dbus_signal();
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();
}
-TEST(BluetoothShare_test, _bt_create_warning_popup_p) {
+TEST(BluetoothShare_test, _bt_create_warning_popup_p)
+{
gboolean ret = FALSE;
ret = _bt_init_dbus_signal();
_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");
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");
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);
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();
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);
_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;
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);
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);
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);
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);
}
-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);
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);
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);
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);
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';
_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));
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;
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;
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;
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);
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);
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);
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();
}