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>
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);
}
}
-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);
}
}
-char *_bt_share_create_transfer_file(char *text)
+char *_bt_share_create_transfer_file(const char *text)
{
retv_if(text == NULL, NULL);
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);
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");
FN_END;
}
-void _bt_update_transfer_list_view(char *db)
+void _bt_update_transfer_list_view(const char *db)
{
ret_if(gdbus_connection == NULL);
/* 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;
}
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);
}
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;
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);
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);
}
/* 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;
#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"
} 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
}
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;
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;
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";
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;
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);
}
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,
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);
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,
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;
}
/*
- * 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>
extern "C" {
#endif
+#include <glib.h>
#include <db-util.h>
#ifndef EXPORT_API
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)
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * 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 <syspopup_caller.h>
-#include "bluetooth-share-api.h"
-#include "bt-share-common.h"
-#include "bt-share-ipc.h"
-#include "bt-share-resource.h"
-#include "bt-share-main.h"
-#include "bt-share-noti-handler.h"
-#include "bt-share-notification.h"
-#include "bt-share-syspopup.h"
-#include "obex-event-handler.h"
-
-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);
-
- ret = _bt_share_block_sleep(TRUE);
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
- ret = _bt_share_block_sleep(FALSE);
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
- ret = _bt_share_block_sleep(FALSE);
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-}
-
-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) {
- int ret = BT_SHARE_ERROR_NONE;
-
- ret = _bt_set_transfer_indicator(TRUE);
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
- ret = _bt_set_transfer_indicator(TRUE);
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
- ret = _bt_set_transfer_indicator(FALSE);
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
- ret = _bt_set_transfer_indicator(FALSE);
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-}
-
-TEST(BluetoothShare_test, _bt_remove_tmp_file_p) {
- _bt_remove_tmp_file(BT_TMP_FILE);
-}
-
-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) {
- char *file = NULL;
-
- file = _bt_share_create_transfer_file("http://www.tizen.org");
- ASSERT_FALSE(file == NULL);
-
- _bt_remove_tmp_file(HTML_FILE_NAME);
- g_free(file);
-
- file = _bt_share_create_transfer_file("Text test");
- ASSERT_FALSE(file == NULL);
-
- _bt_remove_tmp_file(TXT_FILE_FORMAT);
- g_free(file);
-}
-
-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) {
- char *time = NULL;
-
- time = _bt_get_time_of_the_day();
- ASSERT_FALSE(time == NULL);
-
- g_free(time);
-}
-
-TEST(BluetoothShare_test, _bt_share_get_storage_path_p) {
- char *path = NULL;
-
- path = _bt_share_get_storage_path(BT_DEFAULT_MEM_PHONE);
- ASSERT_FALSE(path == NULL);
-
- g_free(path);
-
- path = _bt_share_get_storage_path(BT_DEFAULT_MEM_MMC);
- ASSERT_FALSE(path == NULL);
-
- g_free(path);
-}
-
-
-TEST(BluetoothShare_test, _bt_share_get_active_uid_p) {
- int ret = BT_SHARE_ERROR_NONE;
- uid_t uid = 0;
-
- ret = _bt_share_get_active_uid(&uid);
-
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-}
-
-TEST(BluetoothShare_test, _remove_transfer_info_p) {
- opc_transfer_info_t *data = NULL;
-
- data = g_new0(opc_transfer_info_t, 1);
- data->content = g_new0(char *, 1);
- data->file_path = g_new0(char *, 1);
- data->file_cnt = 1;
- data->type = g_new0(char *, 1);
- data->size = (unsigned int *)g_new0(unsigned int *, 1);
-
- _remove_transfer_info(data);
-}
-
-TEST(BluetoothShare_test, _bt_init_dbus_signal_p) {
- gboolean ret = FALSE;
-
- ret = _bt_init_dbus_signal();
-
- ASSERT_TRUE(ret == TRUE);
-
- _bt_deinit_dbus_signal();
-}
-
-
-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);
-
- _bt_deinit_dbus_signal();
-}
-
-TEST(BluetoothShare_test, _bt_update_transfer_list_view_p) {
- gboolean ret = FALSE;
-
- ret = _bt_init_dbus_signal();
-
- ASSERT_TRUE(ret == TRUE);
-
- _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
-
- _bt_deinit_dbus_signal();
-}
-
-
-TEST(BluetoothShare_test, _bt_create_warning_popup_p) {
- gboolean ret = FALSE;
-
- ret = _bt_init_dbus_signal();
-
- ASSERT_TRUE(ret == TRUE);
-
- _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL, BT_STR_UNABLE_TO_SEND);
-
- _bt_deinit_dbus_signal();
-}
-
-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) {
- 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) {
- gboolean ret = FALSE;
-
- 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) {
- gboolean ret = FALSE;
-
- ret = _bt_add_recv_transfer_status_data("NAME",
- "ADDRESS", "FILE NAME", "TYPE",
- 100, BT_TR_ONGOING, "1");
-
- ASSERT_TRUE(ret == TRUE);
-}
-
-TEST(BluetoothShare_test, _bt_share_get_unique_id_p) {
- int id;
-
- id = _bt_share_get_unique_id(BT_DB_INBOUND, "1");
-
- ASSERT_FALSE(id < 0);
-}
-
-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) {
- _bt_terminate_bluetooth_share();
-}
-
-
-TEST(BluetoothShare_test, _bt_remove_temporary_files_by_noti_id_p) {
- sqlite3 *db = NULL;
-
- db = bt_share_open_db();
-
- _bt_remove_temporary_files_by_noti_id(db, 1);
-
- bt_share_close_db(db);
-}
-
-TEST(BluetoothShare_test, _bt_init_obex_server_p) {
- int ret = BT_SHARE_ERROR_NONE;
-
- ret = _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) {
- _bt_init_vconf_notification(NULL);
-
- _bt_deinit_vconf_notification();
-}
-
-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_SENDING_NOTI);
-
- _bt_insert_instant_notification(BT_RECEIVED_NOTI);
-
- _bt_insert_instant_notification(BT_RECEIVED_FAILED_NOTI);
-
- _bt_insert_instant_notification(BT_RECEIVING_NOTI);
-}
-
-TEST(BluetoothShare_test, _bt_notification_test_p) {
- bt_appdata_t *ad = NULL;
-
- notification_h noti = NULL;
-
- ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
-
-
- noti = _bt_insert_notification(ad,
- BT_SENDING_NOTI, "TEST",
- "test address", "1");
-
- if (noti == NULL)
- g_free(ad);
-
- ASSERT_FALSE(noti == NULL);
-
- ad->send_noti = noti;
- 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);
-
- _bt_update_notification(ad, ad->send_noti,
- 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");
-
- if (noti == NULL)
- g_free(ad);
-
- ASSERT_FALSE(noti == NULL);
-
- ad->receive_noti = noti;
-
- _bt_update_notification(ad, ad->receive_noti,
- 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");
-
- if (noti == NULL)
- g_free(ad);
-
- ASSERT_FALSE(noti == NULL);
-
- 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);
-
- _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");
-
- if (noti == NULL)
- g_free(ad);
-
- ASSERT_FALSE(noti == NULL);
-
- _bt_delete_notification(noti);
-}
-
-
-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 };
- int ret = BT_SHARE_ERROR_NONE;
- bt_appdata_t *ad = NULL;
-
- ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
-
- popup_params.title = BT_STR_MEMORY_FULL;
- popup_params.type = "none";
-
- ret = _bt_launch_system_popup(BT_APP_EVENT_CONFIRM_MODE_REQUEST,
- &popup_params, NULL, ad);
-
- if (ret != BT_SHARE_ERROR_NONE)
- g_free(ad);
-
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
- syspopup_destroy_all();
- usleep(1000 * 200);
-
- ret = _bt_launch_system_popup(BT_APP_EVENT_FILE_RECEIVED,
- &popup_params, NULL, ad);
-
- syspopup_destroy_all();
- usleep(1000 * 200);
-
- if (ret != BT_SHARE_ERROR_NONE)
- g_free(ad);
-
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
- ret = _bt_launch_system_popup(BT_APP_EVENT_INFORMATION,
- &popup_params, NULL, ad);
-
- if (ret != BT_SHARE_ERROR_NONE)
- g_free(ad);
-
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
- syspopup_destroy_all();
- usleep(1000 * 200);
-
- ret = _bt_launch_system_popup(BT_APP_EVENT_OVERWRITE_REQUEST,
- &popup_params, NULL, ad);
-
- if (ret != BT_SHARE_ERROR_NONE)
- g_free(ad);
-
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
- syspopup_destroy_all();
- usleep(1000 * 200);
-}
-
-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, };
-
- addr[0] = '1';
- addr[1] = '1';
- addr[2] = '1';
- addr[3] = '1';
- addr[4] = '1';
- addr[5] = '1';
-
- _bt_convert_addr_type_to_string(bd_addr, addr);
-}
-
-TEST(BluetoothShare_test, _bt_obex_cancel_transfer_p) {
- bt_appdata_t *ad = NULL;
-
- ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
-
- _bt_obex_cancel_transfer((void *)ad);
-
- g_free(ad);
-}
-
-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, };
-
- _bt_get_default_storage(storage);
-}
-
-TEST(BluetoothShare_test, _bt_get_available_int_memory_p) {
- int ret = 0;
- double available_int_mem_size = 0;
-
- ret = _bt_get_available_int_memory(&available_int_mem_size);
-
- ASSERT_TRUE(ret >= 0);
-}
-
-TEST(BluetoothShare_test, _bt_get_available_ext_memory_p) {
- int ret = 0;
- unsigned long long available_ext_mem_size = 0;
-
- ret = _bt_get_available_ext_memory(&available_ext_mem_size);
-
- ASSERT_TRUE(ret >= 0);
-}
-
-TEST(BluetoothShareApi_test, bt_share_db_api_test_p) {
- int ret = BT_SHARE_ERR_NONE;
- int session_id = -1;
- int cnt = -1;
- sqlite3 *db = NULL;
- bt_tr_data_t *tmp = NULL;
- bt_tr_data_t *info = NULL;
- GSList *tr_data_list = NULL;
-
- db = bt_share_open_db();
-
- ASSERT_FALSE(db == NULL);
-
- tmp = (bt_tr_data_t *)g_malloc0(sizeof(bt_tr_data_t));
-
- tmp->tr_status = BT_TRANSFER_FAIL;
- tmp->sid = 1;
- tmp->file_path = "TEST";
- tmp->content = "TEST";
- tmp->dev_name = "TEST";
- tmp->type = "TEST";
- tmp->timestamp = 2;
- tmp->addr = "TEST";
- tmp->size = 0;
- tmp->db_sid = "1";
-
- ret = bt_share_add_tr_data(db, BT_DB_OUTBOUND, tmp);
-
- if (ret != BT_SHARE_ERR_NONE) {
- bt_share_close_db(db);
- g_free(tmp);
- }
-
- ASSERT_TRUE(ret == BT_SHARE_ERR_NONE);
-
- info = bt_share_get_tr_data(db, BT_DB_OUTBOUND, tmp->sid);
-
- if (info != NULL) {
- g_free(info->file_path);
- g_free(info->dev_name);
- g_free(info->addr);
- g_free(info->type);
- g_free(info->content);
- g_free(info);
- }
-
- tr_data_list = bt_share_get_all_tr_data_list(db, BT_DB_OUTBOUND);
-
- if (tr_data_list == NULL) {
- bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
- bt_share_close_db(db);
- g_free(tmp);
- }
-
- ASSERT_FALSE(tr_data_list == NULL);
-
- bt_share_release_tr_data_list(tr_data_list);
- tr_data_list = NULL;
-
- tr_data_list = bt_share_get_all_tr_data_by_sid(db,
- BT_DB_OUTBOUND, "TEST", "1");
-
- if (tr_data_list == NULL) {
- bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
- bt_share_close_db(db);
- g_free(tmp);
- }
-
- ASSERT_FALSE(tr_data_list == NULL);
-
- bt_share_release_tr_data_list(tr_data_list);
- tr_data_list = NULL;
-
- tr_data_list = bt_share_get_failed_tr_data_by_sid(db,
- BT_DB_OUTBOUND, "TEST", "1");
-
- if (tr_data_list == NULL) {
- bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
- bt_share_close_db(db);
- g_free(tmp);
- }
-
- ASSERT_FALSE(tr_data_list == NULL);
-
- bt_share_release_tr_data_list(tr_data_list);
- tr_data_list = NULL;
-
- session_id = bt_share_get_last_session_id(db, BT_DB_OUTBOUND);
-
- if (session_id == -1) {
- bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
- bt_share_close_db(db);
- g_free(tmp);
- }
-
- ASSERT_FALSE(session_id == -1);
-
- cnt = bt_share_get_tr_data_count(db, BT_DB_OUTBOUND);
-
- if (cnt == -1) {
- bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
- bt_share_close_db(db);
- g_free(tmp);
- }
-
- ASSERT_FALSE(cnt == -1);
-
- ret = bt_share_remove_tr_data_by_id(db, BT_DB_OUTBOUND, 1);
-
- if (ret != BT_SHARE_ERROR_NONE) {
- bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
- bt_share_close_db(db);
- g_free(tmp);
- }
-
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
- ret = bt_share_remove_tr_data_non_pending(db, BT_DB_OUTBOUND);
-
- if (ret != BT_SHARE_ERROR_NONE) {
- bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
- bt_share_close_db(db);
- g_free(tmp);
- }
-
- ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
- bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
- bt_share_close_db(db);
- g_free(tmp);
-}
-
-
-int main(int argc, char **argv) {
- testing::InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <gtest/gtest.h>
+#include <unistd.h>
+#include <glib.h>
+#include <syspopup_caller.h>
+#include "bluetooth-share-api.h"
+#include "bt-share-common.h"
+#include "bt-share-ipc.h"
+#include "bt-share-resource.h"
+#include "bt-share-main.h"
+#include "bt-share-noti-handler.h"
+#include "bt-share-notification.h"
+#include "bt-share-syspopup.h"
+#include "obex-event-handler.h"
+
+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);
+
+ ret = _bt_share_block_sleep(TRUE);
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+ ret = _bt_share_block_sleep(FALSE);
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+ ret = _bt_share_block_sleep(FALSE);
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+}
+
+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)
+{
+ int ret = BT_SHARE_ERROR_NONE;
+
+ ret = _bt_set_transfer_indicator(TRUE);
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+ ret = _bt_set_transfer_indicator(TRUE);
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+ ret = _bt_set_transfer_indicator(FALSE);
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+ ret = _bt_set_transfer_indicator(FALSE);
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+}
+
+TEST(BluetoothShare_test, _bt_remove_tmp_file_p)
+{
+ _bt_remove_tmp_file(BT_TMP_FILE);
+}
+
+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)
+{
+ char *file = NULL;
+
+ file = _bt_share_create_transfer_file("http://www.tizen.org");
+ ASSERT_FALSE(file == NULL);
+
+ _bt_remove_tmp_file(HTML_FILE_NAME);
+ g_free(file);
+
+ file = _bt_share_create_transfer_file("Text test");
+ ASSERT_FALSE(file == NULL);
+
+ _bt_remove_tmp_file(TXT_FILE_FORMAT);
+ g_free(file);
+}
+
+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)
+{
+ char *time = NULL;
+
+ time = _bt_get_time_of_the_day();
+ ASSERT_FALSE(time == NULL);
+
+ g_free(time);
+}
+
+TEST(BluetoothShare_test, _bt_share_get_storage_path_p)
+{
+ char *path = NULL;
+
+ path = _bt_share_get_storage_path(BT_DEFAULT_MEM_PHONE);
+ ASSERT_FALSE(path == NULL);
+
+ g_free(path);
+
+ path = _bt_share_get_storage_path(BT_DEFAULT_MEM_MMC);
+ ASSERT_FALSE(path == NULL);
+
+ g_free(path);
+}
+
+
+TEST(BluetoothShare_test, _bt_share_get_active_uid_p)
+{
+ int ret = BT_SHARE_ERROR_NONE;
+ uid_t uid = 0;
+
+ ret = _bt_share_get_active_uid(&uid);
+
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+}
+
+TEST(BluetoothShare_test, _remove_transfer_info_p)
+{
+ opc_transfer_info_t *data = NULL;
+
+ data = g_new0(opc_transfer_info_t, 1);
+ data->content = g_new0(char *, 1);
+ data->file_path = g_new0(char *, 1);
+ data->file_cnt = 1;
+ data->type = g_new0(char *, 1);
+ data->size = (unsigned int *)g_new0(unsigned int *, 1);
+
+ _remove_transfer_info(data);
+}
+
+TEST(BluetoothShare_test, _bt_init_dbus_signal_p)
+{
+ gboolean ret = FALSE;
+
+ ret = _bt_init_dbus_signal();
+
+ ASSERT_TRUE(ret == TRUE);
+
+ _bt_deinit_dbus_signal();
+}
+
+
+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);
+
+ _bt_deinit_dbus_signal();
+}
+
+TEST(BluetoothShare_test, _bt_update_transfer_list_view_p)
+{
+ gboolean ret = FALSE;
+
+ ret = _bt_init_dbus_signal();
+
+ ASSERT_TRUE(ret == TRUE);
+
+ _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
+
+ _bt_deinit_dbus_signal();
+}
+
+
+TEST(BluetoothShare_test, _bt_create_warning_popup_p)
+{
+ gboolean ret = FALSE;
+
+ ret = _bt_init_dbus_signal();
+
+ ASSERT_TRUE(ret == TRUE);
+
+ _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL, BT_STR_UNABLE_TO_SEND);
+
+ _bt_deinit_dbus_signal();
+}
+
+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)
+{
+ 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)
+{
+ gboolean ret = FALSE;
+
+ 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)
+{
+ gboolean ret = FALSE;
+
+ ret = _bt_add_recv_transfer_status_data("NAME",
+ "ADDRESS", "FILE NAME", "TYPE",
+ 100, BT_TR_ONGOING, "1");
+
+ ASSERT_TRUE(ret == TRUE);
+}
+
+TEST(BluetoothShare_test, _bt_share_get_unique_id_p)
+{
+ int id;
+
+ id = _bt_share_get_unique_id(BT_DB_INBOUND, "1");
+
+ ASSERT_FALSE(id < 0);
+}
+
+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)
+{
+ _bt_terminate_bluetooth_share();
+}
+
+TEST(BluetoothShare_test, _bt_remove_temporary_files_by_noti_id_p)
+{
+ sqlite3 *db = NULL;
+
+ db = bt_share_open_db();
+
+ _bt_remove_temporary_files_by_noti_id(db, 1);
+
+ bt_share_close_db(db);
+}
+
+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)
+{
+ _bt_init_vconf_notification(NULL);
+
+ _bt_deinit_vconf_notification();
+}
+
+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_SENDING_NOTI);
+
+ _bt_insert_instant_notification(BT_RECEIVED_NOTI);
+
+ _bt_insert_instant_notification(BT_RECEIVED_FAILED_NOTI);
+
+ _bt_insert_instant_notification(BT_RECEIVING_NOTI);
+}
+
+TEST(BluetoothShare_test, _bt_notification_test_p)
+{
+ bt_appdata_t *ad = NULL;
+
+ notification_h noti = NULL;
+
+ ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
+
+
+ noti = _bt_insert_notification(ad,
+ BT_SENDING_NOTI, "TEST",
+ "test address", "1");
+
+ if (noti == NULL)
+ g_free(ad);
+
+ ASSERT_FALSE(noti == NULL);
+
+ ad->send_noti = noti;
+ 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);
+
+ _bt_update_notification(ad, ad->send_noti,
+ 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");
+
+ if (noti == NULL)
+ g_free(ad);
+
+ ASSERT_FALSE(noti == NULL);
+
+ ad->receive_noti = noti;
+
+ _bt_update_notification(ad, ad->receive_noti,
+ 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");
+
+ if (noti == NULL)
+ g_free(ad);
+
+ ASSERT_FALSE(noti == NULL);
+
+ 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);
+
+ _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");
+
+ if (noti == NULL)
+ g_free(ad);
+
+ ASSERT_FALSE(noti == NULL);
+
+ _bt_delete_notification(noti);
+}
+
+
+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};
+ int ret = BT_SHARE_ERROR_NONE;
+ bt_appdata_t *ad = NULL;
+
+ ad = (bt_appdata_t*)calloc(1, sizeof(bt_appdata_t));
+
+ popup_params.title = BT_STR_MEMORY_FULL;
+ popup_params.type = (char*)"none";
+
+ ret = _bt_launch_system_popup(BT_APP_EVENT_CONFIRM_MODE_REQUEST,
+ &popup_params, NULL, ad);
+
+ if (ret != BT_SHARE_ERROR_NONE)
+ g_free(ad);
+
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+ syspopup_destroy_all();
+ usleep(1000 * 200);
+
+ ret = _bt_launch_system_popup(BT_APP_EVENT_FILE_RECEIVED,
+ &popup_params, NULL, ad);
+
+ syspopup_destroy_all();
+ usleep(1000 * 200);
+
+ if (ret != BT_SHARE_ERROR_NONE)
+ g_free(ad);
+
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+ ret = _bt_launch_system_popup(BT_APP_EVENT_INFORMATION,
+ &popup_params, NULL, ad);
+
+ if (ret != BT_SHARE_ERROR_NONE)
+ g_free(ad);
+
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+ syspopup_destroy_all();
+ usleep(1000 * 200);
+
+ ret = _bt_launch_system_popup(BT_APP_EVENT_OVERWRITE_REQUEST,
+ &popup_params, NULL, ad);
+
+ if (ret != BT_SHARE_ERROR_NONE)
+ g_free(ad);
+
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+ syspopup_destroy_all();
+ usleep(1000 * 200);
+}
+
+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,};
+
+ addr[0] = '1';
+ addr[1] = '1';
+ addr[2] = '1';
+ addr[3] = '1';
+ addr[4] = '1';
+ addr[5] = '1';
+
+ _bt_convert_addr_type_to_string(bd_addr, addr);
+}
+
+TEST(BluetoothShare_test, _bt_obex_cancel_transfer_p)
+{
+ bt_appdata_t *ad = NULL;
+
+ ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
+
+ _bt_obex_cancel_transfer((void *)ad);
+
+ g_free(ad);
+}
+
+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,};
+
+ _bt_get_default_storage(storage);
+}
+
+TEST(BluetoothShare_test, _bt_get_available_int_memory_p)
+{
+ int ret = 0;
+ double available_int_mem_size = 0;
+
+ ret = _bt_get_available_int_memory(&available_int_mem_size);
+
+ ASSERT_TRUE(ret >= 0);
+}
+
+TEST(BluetoothShare_test, _bt_get_available_ext_memory_p)
+{
+ int ret = 0;
+ unsigned long long available_ext_mem_size = 0;
+
+ ret = _bt_get_available_ext_memory(&available_ext_mem_size);
+
+ ASSERT_TRUE(ret >= 0);
+}
+
+TEST(BluetoothShareApi_test, bt_share_db_api_test_p)
+{
+ int ret = BT_SHARE_ERR_NONE;
+ int session_id = -1;
+ int cnt = -1;
+ sqlite3 *db = NULL;
+ bt_tr_data_t *tmp = NULL;
+ bt_tr_data_t *info = NULL;
+ GSList *tr_data_list = NULL;
+
+ db = bt_share_open_db();
+
+ ASSERT_FALSE(db == NULL);
+
+ tmp = (bt_tr_data_t *)g_malloc0(sizeof(bt_tr_data_t));
+
+ tmp->tr_status = BT_TRANSFER_FAIL;
+ tmp->sid = 1;
+ tmp->file_path = (char*)"TEST";
+ tmp->content = (char*)"TEST";
+ tmp->dev_name = (char*)"TEST";
+ tmp->type = (char*)"TEST";
+ tmp->timestamp = 2;
+ tmp->addr = (char*)"TEST";
+ tmp->size = 0;
+ tmp->db_sid = (char*)"1";
+
+ ret = bt_share_add_tr_data(db, BT_DB_OUTBOUND, tmp);
+
+ if (ret != BT_SHARE_ERR_NONE) {
+ bt_share_close_db(db);
+ g_free(tmp);
+ }
+
+ ASSERT_TRUE(ret == BT_SHARE_ERR_NONE);
+
+ info = bt_share_get_tr_data(db, BT_DB_OUTBOUND, tmp->sid);
+
+ if (info != NULL) {
+ g_free(info->file_path);
+ g_free(info->dev_name);
+ g_free(info->addr);
+ g_free(info->type);
+ g_free(info->content);
+ g_free(info);
+ }
+
+ tr_data_list = bt_share_get_all_tr_data_list(db, BT_DB_OUTBOUND);
+
+ if (tr_data_list == NULL) {
+ bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+ bt_share_close_db(db);
+ g_free(tmp);
+ }
+
+ ASSERT_FALSE(tr_data_list == NULL);
+
+ bt_share_release_tr_data_list(tr_data_list);
+ tr_data_list = NULL;
+
+ tr_data_list = bt_share_get_all_tr_data_by_sid(db,
+ BT_DB_OUTBOUND, "TEST", "1");
+
+ if (tr_data_list == NULL) {
+ bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+ bt_share_close_db(db);
+ g_free(tmp);
+ }
+
+ ASSERT_FALSE(tr_data_list == NULL);
+
+ bt_share_release_tr_data_list(tr_data_list);
+ tr_data_list = NULL;
+
+ tr_data_list = bt_share_get_failed_tr_data_by_sid(db,
+ BT_DB_OUTBOUND, "TEST", "1");
+
+ if (tr_data_list == NULL) {
+ bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+ bt_share_close_db(db);
+ g_free(tmp);
+ }
+
+ ASSERT_FALSE(tr_data_list == NULL);
+
+ bt_share_release_tr_data_list(tr_data_list);
+ tr_data_list = NULL;
+
+ session_id = bt_share_get_last_session_id(db, BT_DB_OUTBOUND);
+
+ if (session_id == -1) {
+ bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+ bt_share_close_db(db);
+ g_free(tmp);
+ }
+
+ ASSERT_FALSE(session_id == -1);
+
+ cnt = bt_share_get_tr_data_count(db, BT_DB_OUTBOUND);
+
+ if (cnt == -1) {
+ bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+ bt_share_close_db(db);
+ g_free(tmp);
+ }
+
+ ASSERT_FALSE(cnt == -1);
+
+ ret = bt_share_remove_tr_data_by_id(db, BT_DB_OUTBOUND, 1);
+
+ if (ret != BT_SHARE_ERROR_NONE) {
+ bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+ bt_share_close_db(db);
+ g_free(tmp);
+ }
+
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+ ret = bt_share_remove_tr_data_non_pending(db, BT_DB_OUTBOUND);
+
+ if (ret != BT_SHARE_ERROR_NONE) {
+ bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+ bt_share_close_db(db);
+ g_free(tmp);
+ }
+
+ ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+ bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+ bt_share_close_db(db);
+ g_free(tmp);
+}
+
+int main(int argc, char **argv)
+{
+ testing::InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}
+++ /dev/null
-/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <sqlite3.h>
-#include <db-util.h>
-#include <notification.h>
-#include <dlfcn.h>
-#include <fcntl.h>
-#include <storage.h>
-#include <bluetooth-api.h>
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-static int access_count = 0;
-static bool row_return_required = false;
-
-API int display_lock_state(unsigned int state, unsigned int flag, unsigned int timeout)
-{
- return 0;
-}
-
-API int display_unlock_state(unsigned int state, unsigned int flag)
-{
- return 0;
-}
-
-API int vconf_get_int(const char *in_key, int *intval)
-{
- if (strcmp(in_key, "db/bluetooth/status") == 0) // VCONFKEY_BT_STATUS
- *intval = TRUE;
- return 0;
-}
-
-API int vconf_set_int(const char *in_key, const int intval)
-{
- return 0;
-}
-
-API GDBusConnection *g_bus_get_sync(GBusType bus_type,
- GCancellable *cancellable,
- GError **error)
-{
- return (void *)1234;
-}
-
-API GVariant *g_dbus_proxy_call_sync(GDBusProxy *proxy,
- const gchar *method_name,
- GVariant *parameters,
- GDBusCallFlags flags,
- gint timeout_msec,
- GCancellable *cancellable,
- GError **error)
-{
- return (void *)1234;
-}
-
-API GDBusProxy *g_dbus_proxy_new_sync(GDBusConnection *connection,
- GDBusProxyFlags flags,
- GDBusInterfaceInfo *info,
- const gchar *name,
- const gchar *object_path,
- const gchar *interface_name,
- GCancellable *cancellable,
- GError **error)
-{
- return (void *)1234;
-}
-
-API char *g_uri_parse_scheme(const char *uri)
-{
- if (strcmp(uri, "http://www.tizen.org") == 0)
- return strdup("http");
- else if (strcmp(uri, "Text test") == 0)
- return NULL;
- else
- return NULL;
-}
-
-API int access(const char *pathname, int mode)
-{
- if (access_count == 0) {
- access_count = 1;
- return 0;
- } else {
- access_count = 0;
- return -1;
- }
-}
-
-API int open(const char *__path, int __oflag, ...)
-{
- if (strcmp(__path, "/opt/usr/home/owner/media/Downloads/bluetooth_content_share.html") == 0) {
- return 0;
- } else if (strcmp(__path, "/opt/usr/home/owner/media/Downloads/bluetooth_content_share_0.txt") == 0) {
- return 0;
- } else if (strcmp(__path, "/opt/system/model-config/system_info_db") == 0) {
- return 0;
- } else if (strcmp(__path, "/etc/dlog.conf.d") == 0) {
- return 0;
- }
-
- int (*org_fn)(const char *, int, ...) = NULL;
- org_fn = dlsym(RTLD_NEXT, "open");
-
- int ret;
- va_list ap;
- va_start(ap, __oflag);
- int mode = va_arg(ap, int);
- if (mode <= 0x777)
- ret = org_fn(__path, __oflag, mode);
- else
- ret = org_fn(__path, __oflag);
- va_end(ap);
- return ret;
-}
-
-API ssize_t write(int fd, const void *buf, size_t count)
-{
- return 0;
-}
-
-API int close(int fd)
-{
- return 0;
-}
-
-API void g_dbus_connection_signal_unsubscribe(GDBusConnection *connection,
- guint subscription_id)
-{
-}
-
-API guint g_dbus_connection_signal_subscribe(GDBusConnection *connection,
- const gchar *sender,
- const gchar *interface_name,
- const gchar *member,
- const gchar *object_path,
- const gchar *arg0,
- GDBusSignalFlags flags,
- GDBusSignalCallback callback,
- gpointer user_data,
- GDestroyNotify user_data_free_func)
-{
- return 0;
-}
-
-API GDBusMessage *g_dbus_message_new_signal(const gchar *path,
- const gchar *interface_,
- const gchar *signal)
-{
- return (void *)1234;
-}
-
-API void g_dbus_message_set_body(GDBusMessage *message,
- GVariant *body)
-{
-}
-
-API void g_dbus_message_set_destination(GDBusMessage *message,
- const gchar *value)
-{
-}
-
-API gboolean g_dbus_connection_send_message(GDBusConnection *connection,
- GDBusMessage *message,
- GDBusSendMessageFlags flags,
- volatile guint32 *out_serial,
- GError **error)
-{
- return TRUE;
-}
-
-API void g_object_unref(gpointer object)
-{
-}
-
-API void g_variant_unref(GVariant *value)
-{
-}
-
-API int db_util_open(const char *pszFilePath, sqlite3 **ppDB,
- int nOption)
-{
- *ppDB = (void *)1234;
- return 0;
-}
-
-API int sqlite3_prepare(
- sqlite3 *db,
- const char *zSql,
- int nByte,
- sqlite3_stmt **ppStmt,
- const char **pzTail)
-{
- *ppStmt = (sqlite3_stmt *)1234;
- if (strncasecmp(zSql, "select", strlen("select")) == 0) {
- row_return_required = true;
- }
- return 0;
-}
-
-API int sqlite3_prepare_v2(
- sqlite3 *db,
- const char *zSql,
- int nByte,
- sqlite3_stmt **ppStmt,
- const char **pzTail)
-{
- return sqlite3_prepare(db, zSql, nByte, ppStmt, pzTail);
-}
-
-API int sqlite3_step(sqlite3_stmt *pStmt)
-{
- if (row_return_required) {
- row_return_required = false;
- return SQLITE_ROW;
- }
- return SQLITE_DONE;
-}
-
-API int sqlite3_finalize(sqlite3_stmt *pStmt)
-{
- return 0;
-}
-
-API int db_util_close(sqlite3 *ppDB)
-{
- return 0;
-}
-
-API char *sqlite3_mprintf(const char *param1, ...)
-{
- return "success";
-}
-
-API void sqlite3_free(void *param1)
-{
-}
-
-API int sqlite3_bind_int(sqlite3_stmt *param1, int param2, int param3)
-{
- return 0;
-}
-
-API int sqlite3_reset(sqlite3_stmt *pStmt)
-{
-}
-
-API const char *sqlite3_errmsg(sqlite3 *param1)
-{
- return "success";
-}
-
-API int sqlite3_column_int(sqlite3_stmt *param1, int iCol)
-{
- return 0;
-}
-
-API const unsigned char *sqlite3_column_text(sqlite3_stmt *param1, int iCol)
-{
- return "1234";
-}
-
-API notification_h notification_create(notification_type_e type)
-{
- return (void *)1234;
-}
-
-API int notification_set_text(notification_h noti, notification_text_type_e type,
- const char *text, const char *key, int args_type, ...)
-{
- return 0;
-}
-
-API int notification_set_image(notification_h noti, notification_image_type_e type, const char *image_path)
-{
- return 0;
-}
-
-API int notification_set_display_applist(notification_h noti, int applist)
-{
- return 0;
-}
-
-API int notification_post(notification_h noti)
-{
- return 0;
-}
-
-API int notification_free(notification_h noti)
-{
- return 0;
-}
-
-API int notification_set_text_domain(notification_h noti,
- const char *domain,
- const char *dir)
-{
- return 0;
-}
-
-API int notification_set_property(notification_h noti, int flags)
-{
- return 0;
-}
-
-API int notification_get_property(notification_h noti, int *flags)
-{
- return 0;
-}
-
-API int notification_set_pkgname(notification_h noti, const char *pkgname)
-{
- return 0;
-}
-
-API int notification_set_execute_option(notification_h noti,
- notification_execute_type_e type,
- const char *text,
- const char *key,
- bundle *service_handle)
-{
- return 0;
-}
-
-API int notification_insert(notification_h noti, int *priv_id)
-{
- return 0;
-}
-
-API int notification_get_id(notification_h noti, int *group_id, int *priv_id)
-{
- return 0;
-}
-
-API int notification_delete(notification_h noti)
-{
- return 0;
-}
-
-API int notification_update(notification_h noti)
-{
- return 0;
-}
-
-API int notification_update_progress(notification_h noti, int priv_id, double progress)
-{
- return 0;
-}
-
-API int notification_register_detailed_changed_cb(
- void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
- void *user_data)
-{
- return 0;
-}
-
-API int notification_unregister_detailed_changed_cb(
- void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
- void *user_data)
-{
- return 0;
-}
-
-API int appsvc_set_pkgname(bundle *b, const char *pkg_name)
-{
- return 0;
-}
-
-API int appsvc_add_data(bundle *b, const char *key, const char *val)
-{
- return 0;
-}
-
-API bundle *bundle_create(void)
-{
- return (void *)1234;
-}
-
-API int bundle_add(bundle *b, const char *key, const char *val)
-{
- return 0;
-}
-
-API int bundle_free(bundle *b)
-{
- return 0;
-}
-
-API int aul_app_is_running(const char *appid)
-{
- return 0;
-}
-
-API int aul_launch_app(const char *appid, bundle *kb)
-{
- return 0;
-}
-
-API int syspopup_launch(char *popup_name, bundle *b)
-{
- return 0;
-}
-
-API int syspopup_destroy_all(void)
-{
- return 0;
-}
-
-API int storage_get_internal_memory_size(struct statvfs *buf)
-{
- return 0;
-}
-
-API int bluetooth_obex_server_init(const char *dst_path)
-{
- return 0;
-}
-
-API int bluetooth_obex_server_set_root(const char *root)
-{
- return 0;
-}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <sqlite3.h>
+#include <db-util.h>
+#include <notification.h>
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <storage.h>
+#include <bluetooth-api.h>
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+static int access_count = 0;
+static bool row_return_required = false;
+
+API int display_lock_state(unsigned int state, unsigned int flag, unsigned int timeout)
+{
+ return 0;
+}
+
+API int display_unlock_state(unsigned int state, unsigned int flag)
+{
+ return 0;
+}
+
+API int vconf_get_int(const char *in_key, int *intval)
+{
+ if (strcmp(in_key, "db/bluetooth/status") == 0) // VCONFKEY_BT_STATUS
+ *intval = TRUE;
+ return 0;
+}
+
+API int vconf_set_int(const char *in_key, const int intval)
+{
+ return 0;
+}
+
+API GDBusConnection *g_bus_get_sync(GBusType bus_type,
+ GCancellable *cancellable,
+ GError **error)
+{
+ return (void *)1234;
+}
+
+API GVariant *g_dbus_proxy_call_sync(GDBusProxy *proxy,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusCallFlags flags,
+ gint timeout_msec,
+ GCancellable *cancellable,
+ GError **error)
+{
+ return (void *)1234;
+}
+
+API GDBusProxy *g_dbus_proxy_new_sync(GDBusConnection *connection,
+ GDBusProxyFlags flags,
+ GDBusInterfaceInfo *info,
+ const gchar *name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ GCancellable *cancellable,
+ GError **error)
+{
+ return (void *)1234;
+}
+
+API char *g_uri_parse_scheme(const char *uri)
+{
+ if (strcmp(uri, "http://www.tizen.org") == 0)
+ return strdup("http");
+ else if (strcmp(uri, "Text test") == 0)
+ return NULL;
+ else
+ return NULL;
+}
+
+API int access(const char *pathname, int mode)
+{
+ if (access_count == 0) {
+ access_count = 1;
+ return 0;
+ } else {
+ access_count = 0;
+ return -1;
+ }
+}
+
+API int open(const char *__path, int __oflag, ...)
+{
+ if (strcmp(__path, "/opt/usr/home/owner/media/Downloads/bluetooth_content_share.html") == 0) {
+ return 0;
+ } else if (strcmp(__path, "/opt/usr/home/owner/media/Downloads/bluetooth_content_share_0.txt") == 0) {
+ return 0;
+ } else if (strcmp(__path, "/opt/system/model-config/system_info_db") == 0) {
+ return 0;
+ } else if (strcmp(__path, "/etc/dlog.conf.d") == 0) {
+ return 0;
+ }
+
+ int (*org_fn)(const char *, int, ...) = NULL;
+ org_fn = dlsym(RTLD_NEXT, "open");
+
+ int ret;
+ va_list ap;
+ va_start(ap, __oflag);
+ int mode = va_arg(ap, int);
+ if (mode <= 0x777)
+ ret = org_fn(__path, __oflag, mode);
+ else
+ ret = org_fn(__path, __oflag);
+ va_end(ap);
+ return ret;
+}
+
+API ssize_t write(int fd, const void *buf, size_t count)
+{
+ return 0;
+}
+
+API int close(int fd)
+{
+ return 0;
+}
+
+API void g_dbus_connection_signal_unsubscribe(GDBusConnection *connection,
+ guint subscription_id)
+{
+}
+
+API guint g_dbus_connection_signal_subscribe(GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *interface_name,
+ const gchar *member,
+ const gchar *object_path,
+ const gchar *arg0,
+ GDBusSignalFlags flags,
+ GDBusSignalCallback callback,
+ gpointer user_data,
+ GDestroyNotify user_data_free_func)
+{
+ return 0;
+}
+
+API GDBusMessage *g_dbus_message_new_signal(const gchar *path,
+ const gchar *interface_,
+ const gchar *signal)
+{
+ return (void *)1234;
+}
+
+API void g_dbus_message_set_body(GDBusMessage *message,
+ GVariant *body)
+{
+}
+
+API void g_dbus_message_set_destination(GDBusMessage *message,
+ const gchar *value)
+{
+}
+
+API gboolean g_dbus_connection_send_message(GDBusConnection *connection,
+ GDBusMessage *message,
+ GDBusSendMessageFlags flags,
+ volatile guint32 *out_serial,
+ GError **error)
+{
+ return TRUE;
+}
+
+API void g_object_unref(gpointer object)
+{
+}
+
+API void g_variant_unref(GVariant *value)
+{
+}
+
+API int db_util_open(const char *pszFilePath, sqlite3 **ppDB,
+ int nOption)
+{
+ *ppDB = (void *)1234;
+ return 0;
+}
+
+API int sqlite3_prepare(
+ sqlite3 *db,
+ const char *zSql,
+ int nByte,
+ sqlite3_stmt **ppStmt,
+ const char **pzTail)
+{
+ *ppStmt = (sqlite3_stmt *)1234;
+ if (strncasecmp(zSql, "select", strlen("select")) == 0) {
+ row_return_required = true;
+ }
+ return 0;
+}
+
+API int sqlite3_prepare_v2(
+ sqlite3 *db,
+ const char *zSql,
+ int nByte,
+ sqlite3_stmt **ppStmt,
+ const char **pzTail)
+{
+ return sqlite3_prepare(db, zSql, nByte, ppStmt, pzTail);
+}
+
+API int sqlite3_step(sqlite3_stmt *pStmt)
+{
+ if (row_return_required) {
+ row_return_required = false;
+ return SQLITE_ROW;
+ }
+ return SQLITE_DONE;
+}
+
+API int sqlite3_finalize(sqlite3_stmt *pStmt)
+{
+ return 0;
+}
+
+API int db_util_close(sqlite3 *ppDB)
+{
+ return 0;
+}
+
+API char *sqlite3_mprintf(const char *param1, ...)
+{
+ return "success";
+}
+
+API void sqlite3_free(void *param1)
+{
+}
+
+API int sqlite3_bind_int(sqlite3_stmt *param1, int param2, int param3)
+{
+ return 0;
+}
+
+API int sqlite3_reset(sqlite3_stmt *pStmt)
+{
+ return 0;
+}
+
+API const char *sqlite3_errmsg(sqlite3 *param1)
+{
+ return "success";
+}
+
+API int sqlite3_column_int(sqlite3_stmt *param1, int iCol)
+{
+ return 0;
+}
+
+API const unsigned char *sqlite3_column_text(sqlite3_stmt *param1, int iCol)
+{
+ return (const unsigned char*)"1234";
+}
+
+API notification_h notification_create(notification_type_e type)
+{
+ return (void *)1234;
+}
+
+API int notification_set_text(notification_h noti, notification_text_type_e type,
+ const char *text, const char *key, int args_type, ...)
+{
+ return 0;
+}
+
+API int notification_set_image(notification_h noti, notification_image_type_e type, const char *image_path)
+{
+ return 0;
+}
+
+API int notification_set_display_applist(notification_h noti, int applist)
+{
+ return 0;
+}
+
+API int notification_post(notification_h noti)
+{
+ return 0;
+}
+
+API int notification_free(notification_h noti)
+{
+ return 0;
+}
+
+API int notification_set_text_domain(notification_h noti,
+ const char *domain,
+ const char *dir)
+{
+ return 0;
+}
+
+API int notification_set_property(notification_h noti, int flags)
+{
+ return 0;
+}
+
+API int notification_get_property(notification_h noti, int *flags)
+{
+ return 0;
+}
+
+API int notification_set_pkgname(notification_h noti, const char *pkgname)
+{
+ return 0;
+}
+
+API int notification_set_execute_option(notification_h noti,
+ notification_execute_type_e type,
+ const char *text,
+ const char *key,
+ bundle *service_handle)
+{
+ return 0;
+}
+
+API int notification_insert(notification_h noti, int *priv_id)
+{
+ return 0;
+}
+
+API int notification_get_id(notification_h noti, int *group_id, int *priv_id)
+{
+ return 0;
+}
+
+API int notification_delete(notification_h noti)
+{
+ return 0;
+}
+
+API int notification_update(notification_h noti)
+{
+ return 0;
+}
+
+API int notification_update_progress(notification_h noti, int priv_id, double progress)
+{
+ return 0;
+}
+
+API int notification_register_detailed_changed_cb(
+ void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
+ void *user_data)
+{
+ return 0;
+}
+
+API int notification_unregister_detailed_changed_cb(
+ void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
+ void *user_data)
+{
+ return 0;
+}
+
+API int appsvc_set_pkgname(bundle *b, const char *pkg_name)
+{
+ return 0;
+}
+
+API int appsvc_add_data(bundle *b, const char *key, const char *val)
+{
+ return 0;
+}
+
+API bundle *bundle_create(void)
+{
+ return (void *)1234;
+}
+
+API int bundle_add(bundle *b, const char *key, const char *val)
+{
+ return 0;
+}
+
+API int bundle_free(bundle *b)
+{
+ return 0;
+}
+
+API int aul_app_is_running(const char *appid)
+{
+ return 0;
+}
+
+API int aul_launch_app(const char *appid, bundle *kb)
+{
+ return 0;
+}
+
+API int syspopup_launch(char *popup_name, bundle *b)
+{
+ return 0;
+}
+
+API int syspopup_destroy_all(void)
+{
+ return 0;
+}
+
+API int storage_get_internal_memory_size(struct statvfs *buf)
+{
+ return 0;
+}
+
+API int bluetooth_obex_server_init(const char *dst_path)
+{
+ return 0;
+}
+
+API int bluetooth_obex_server_set_root(const char *root)
+{
+ return 0;
+}