From 9299f6efe9d06d6caaff12fb7f5c7b82c9a49ce6 Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Mon, 23 May 2016 16:43:36 +0900 Subject: [PATCH] Modify the PBAP connection event implementation The previous implemenation only send the connection event when an application calls PBAP connect / disconnect API. This patchset enables to recieve the connection state changed event in the idle time. Change-Id: I498c857dcc8ee8ef29eb5b0aea579dbd8b3e4f82 Signed-off-by: DoHyun Pyun --- bt-api/bt-event-handler.c | 21 +++++++++++++++++---- bt-service/bt-service-pbap.c | 21 ++++++++++++--------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/bt-api/bt-event-handler.c b/bt-api/bt-event-handler.c index ec16d4f..b867a42 100755 --- a/bt-api/bt-event-handler.c +++ b/bt-api/bt-event-handler.c @@ -1886,15 +1886,28 @@ void __bt_pbap_client_event_filter(GDBusConnection *connection, _bt_convert_addr_string_to_type(connected.btaddr.addr, address); - if (result == 0) - connected.connected = 1; - else - connected.connected = 0; + + connected.connected = 1; _bt_common_event_cb(BLUETOOTH_PBAP_CONNECTED, result, &connected, event_info->cb, event_info->user_data); } else if (strcasecmp(signal_name, BT_PBAP_DISCONNECTED) == 0) { + bt_pbap_connected_t connected = { { { 0 }, }, }; + char *address = NULL; + + g_variant_get(parameters, "(is)", &result, &address); + BT_DBG("address: %s", address); + + _bt_convert_addr_string_to_type(connected.btaddr.addr, + address); + + connected.connected = 0; + + _bt_common_event_cb(BLUETOOTH_PBAP_DISCONNECTED, + result, &connected, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_PBAP_DISCONNECTED) == 0) { bt_pbap_connected_t disconnected = { { { 0 }, }, }; char *address = NULL; diff --git a/bt-service/bt-service-pbap.c b/bt-service/bt-service-pbap.c index 9e8e3b8..f5a81b8 100644 --- a/bt-service/bt-service-pbap.c +++ b/bt-service/bt-service-pbap.c @@ -45,7 +45,7 @@ #define PBAP_NUM_OF_FIELDS_ENTRY 29 #define PBAP_FIELD_ALL (0xFFFFFFFFFFFFFFFFULL) -#define PBAP_DEFAULT_DOWNLAOD_PATH "/opt/usr/media/Downloads" +#define PBAP_DEFAULT_DOWNLAOD_PATH "/opt/usr/media/Downloads/" #define PBAP_DEFAULT_FILE_NAME "pb.vcf" char *FIELDS[] = { @@ -364,8 +364,6 @@ void __bt_pbap_disconnect_cb(GDBusProxy *proxy, char *address_string = user_data; GError *error = NULL; GVariant *value; - GVariant *signal = NULL; - int result = BLUETOOTH_ERROR_INTERNAL ; BT_DBG("Address = %s", address_string); @@ -389,15 +387,11 @@ void __bt_pbap_disconnect_cb(GDBusProxy *proxy, g_free(g_pbap_server_address); g_pbap_server_address = NULL; - result = BLUETOOTH_ERROR_NONE; selected_path.folder = -1; selected_path.type = -1; } - signal = g_variant_new("(is)", result, address_string); - _bt_send_event(BT_PBAP_CLIENT_EVENT, - BLUETOOTH_PBAP_DISCONNECTED, - signal); + /* PBAP disconnected event will be sent in event reciever */ g_free(address_string); BT_DBG("-"); @@ -617,8 +611,13 @@ void __bt_pbap_get_vcard_list_cb(GDBusProxy *proxy, g_variant_get(child ,"(&s&s)", &elname, &elval); memset(list_entry, 0, PBAP_VCARDLIST_MAXLENGTH); +#if 0 g_snprintf (list_entry, PBAP_VCARDLIST_MAXLENGTH - 1, "", elname, elval); +#else + g_snprintf (list_entry, PBAP_VCARDLIST_MAXLENGTH - 1, + "%s", elval); +#endif //If possible send as Array of BT_DBG("%s", list_entry); vcard_list[i] = g_strdup(list_entry); @@ -998,7 +997,11 @@ int __bt_pbap_call_get_vcard(GDBusProxy *proxy, bt_pbap_data_t *pbap_data) target_file = g_strdup_printf("%s/%s", PBAP_DEFAULT_DOWNLAOD_PATH, PBAP_DEFAULT_FILE_NAME); } else { - target_file = g_strdup_printf("%s/%s", download_path, + if (vcard_handle) + target_file = g_strdup_printf("%s/%s", download_path, + vcard_handle); + else + target_file = g_strdup_printf("%s/%s", download_path, PBAP_DEFAULT_FILE_NAME); if (download_path) -- 2.7.4