[Adapt] Send Device Trust state changed event to Application 58/86058/1
authorAnupam Roy <anupam.r@samsung.com>
Mon, 1 Aug 2016 11:27:53 +0000 (16:57 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Mon, 1 Aug 2016 11:27:53 +0000 (16:57 +0530)
Change-Id: I39cf44693ef44512d083d8a624948ea68799cdcb
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
bt-service-adaptation/services/bt-service-event-receiver.c
bt-service-adaptation/services/device/bt-service-core-device.c

index 23c7f71..f11c9d3 100644 (file)
@@ -124,6 +124,8 @@ void _bt_service_oal_event_receiver(int event_type, gpointer event_data, gsize l
        case OAL_EVENT_DEVICE_SSP_CONSENT_REQUEST:
        case OAL_EVENT_DEVICE_SERVICES:
        case OAL_EVENT_DEVICE_AUTHORIZE_REQUEST:
+       case OAL_EVENT_DEVICE_TRUSTED:
+       case OAL_EVENT_DEVICE_UNTRUSTED:
                if (device_cb)
                        device_cb(event_type, event_data);
                break;
index a2cbe86..1158985 100644 (file)
@@ -130,6 +130,8 @@ static void __bt_device_authorization_request_callback(event_dev_authorize_req_t
 static void __bt_device_services_callback(event_dev_services_t* uuid_list);
 static void __bt_handle_ongoing_device_service_search(bt_remote_dev_info_t *remote_dev_info);
 
+static void __bt_device_trusted_callback(gboolean trusted, event_dev_trust_t* info);
+
 void _bt_device_state_handle_callback_set_request(void)
 {
        _bt_service_register_event_handler_callback(
@@ -770,6 +772,16 @@ static void __bt_device_event_handler(int event_type, gpointer event_data)
                __bt_device_authorization_request_callback((event_dev_authorize_req_t*)event_data);
                break;
        }
+       case OAL_EVENT_DEVICE_TRUSTED: {
+               BT_INFO("Remote Device Trusted");
+               __bt_device_trusted_callback(TRUE, (event_dev_trust_t*)event_data);
+               break;
+       }
+       case OAL_EVENT_DEVICE_UNTRUSTED: {
+               BT_INFO("Remote Device UnTrusted");
+               __bt_device_trusted_callback(FALSE, (event_dev_trust_t*)event_data);
+               break;
+       }
        default:
                BT_INFO("Unhandled event..");
        }
@@ -1095,6 +1107,27 @@ static void __bt_device_remote_device_found_callback(gpointer event_data, gboole
        BT_DBG("-");
 }
 
+static void __bt_device_trusted_callback(gboolean trusted, event_dev_trust_t* info)
+{
+       gchar address[BT_ADDRESS_STR_LEN];
+       int result = BLUETOOTH_ERROR_NONE;
+       GVariant *param = NULL;
+       int event;
+       BT_DBG("+");
+
+       _bt_convert_addr_type_to_string(address, info->address.addr);
+
+       param = g_variant_new("(is)", result, address);
+
+       event = trusted ? BLUETOOTH_EVENT_DEVICE_AUTHORIZED :
+                                        BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED;
+       /* Send event to application */
+       _bt_send_event(BT_DEVICE_EVENT,
+                       event,
+                       param);
+       BT_DBG("-");
+}
+
 static void __bt_free_pairing_info(bt_pairing_data_t **p_info)
 {
        bt_pairing_data_t * info = *p_info;