Fix the svace issue - DEREF_AFTER_NULL
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / oal-device-mgr.c
index 1ddacc9..790ff2c 100755 (executable)
@@ -119,7 +119,7 @@ oal_status_t device_set_alias(bt_address_t * addr, char * alias)
        return OAL_STATUS_SUCCESS;
 }
 
-oal_status_t device_create_bond(bt_address_t *addr, connection_type_e transport)
+oal_status_t device_create_bond(bt_address_t *addr, oal_conn_type_e transport)
 {
        int res;
        bdstr_t bdstr;
@@ -179,6 +179,25 @@ oal_status_t device_stop_bond(bt_address_t * addr)
        return OAL_STATUS_SUCCESS;
 }
 
+oal_status_t device_get_ida(bt_address_t *device_address, bt_address_t *id_address)
+{
+       int res;
+
+       CHECK_OAL_INITIALIZED();
+
+       OAL_CHECK_PARAMETER(device_address, return);
+
+       API_TRACE();
+
+       res = blued_api->get_device_ida((bt_bdaddr_t*) device_address, (bt_bdaddr_t*) id_address);
+
+       if (res != BT_STATUS_SUCCESS)
+               BT_ERR("get_device_IDA failed: [%s]",status2string(res));
+
+       res = convert_to_oal_status(res);
+       return res;
+}
+
 oal_status_t device_accept_pin_request(bt_address_t * addr, const char * pin)
 {
        int res;
@@ -385,7 +404,7 @@ gboolean device_get_svc_conn_state(bt_address_t * addr, oal_service_t svc_id)
        return res;
 }
 
-oal_status_t device_set_osp_server(oal_osp_server_type_e type, int enable)
+oal_status_t device_register_osp_server(oal_osp_server_type_e type, char *uuid, char *path, int fd)
 {
        int res;
        uint32_t server_type;
@@ -399,14 +418,53 @@ oal_status_t device_set_osp_server(oal_osp_server_type_e type, int enable)
        case OAL_OSP_SERVER_OBEX:
                server_type = BT_OSP_SERVER_OBEX;
                break;
+       case OAL_OSP_SERVER_RFCOMM:
+               server_type = BT_OSP_SERVER_RFCOMM;
+               break;
        default:
                BT_ERR("unknown type: %d", type);
                return OAL_STATUS_INVALID_PARAM;
        }
 
-       res = blued_api->set_agent_osp_server(server_type, enable);
+       res = blued_api->register_agent_osp_server(server_type, uuid, path, fd);
        if (res != BT_STATUS_SUCCESS) {
-               BT_ERR("set_agent_osp_server error: [%s]", status2string(res));
+               BT_ERR("register_agent_osp_server error: [%s]", status2string(res));
+               return convert_to_oal_status(res);
+       }
+
+       return OAL_STATUS_SUCCESS;
+#else
+       BT_ERR("Not supported");
+       res = OAL_STATUS_NOT_SUPPORT;
+       return res;
+#endif
+}
+
+oal_status_t device_unregister_osp_server(oal_osp_server_type_e type, char *uuid)
+{
+       int res;
+       uint32_t server_type;
+
+       CHECK_OAL_INITIALIZED();
+
+       API_TRACE("type: %d", type);
+
+#ifdef TIZEN_BT_HAL
+       switch (type) {
+       case OAL_OSP_SERVER_OBEX:
+               server_type = BT_OSP_SERVER_OBEX;
+               break;
+       case OAL_OSP_SERVER_RFCOMM:
+               server_type = BT_OSP_SERVER_RFCOMM;
+               break;
+       default:
+               BT_ERR("unknown type: %d", type);
+               return OAL_STATUS_INVALID_PARAM;
+       }
+
+       res = blued_api->unregister_agent_osp_server(server_type, uuid);
+       if (res != BT_STATUS_SUCCESS) {
+               BT_ERR("unregister_agent_osp_server error: [%s]", status2string(res));
                return convert_to_oal_status(res);
        }
 
@@ -547,6 +605,26 @@ oal_status_t device_enable_gap_auth_notifications(oal_gap_auth_type_e type, gboo
 #endif
 }
 
+oal_status_t device_disconnect(bt_address_t * addr)
+{
+       int res;
+       bdstr_t bdstr;
+
+       CHECK_OAL_INITIALIZED();
+
+       OAL_CHECK_PARAMETER(addr, return);
+
+       API_TRACE("[%s]", bdt_bd2str(addr, &bdstr));
+
+       res = blued_api->device_disconnect((bt_bdaddr_t *)addr);
+       if (res != BT_STATUS_SUCCESS) {
+               BT_ERR("device_disconnect error: [%s]", status2string(res));
+               return convert_to_oal_status(res);
+       }
+
+       return OAL_STATUS_SUCCESS;
+}
+
 void cb_device_properties(bt_status_t status, bt_bdaddr_t *bd_addr,
                int num_properties, bt_property_t *properties)
 {
@@ -684,16 +762,13 @@ void cb_device_acl_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr,
                bt_acl_state_t state)
 {
        event_dev_conn_status_t * conn_status = g_new0(event_dev_conn_status_t, 1);
-       //bt_address_t * address = g_new0(bt_address_t, 1);
        oal_event_t event;
        gsize size = 0;
 
-       BT_DBG("ACL State:%d, state: %d", status, state);
-
        memcpy(conn_status->address.addr, bd_addr->address, 6);
 
 #ifdef TIZEN_BT_HAL
-       conn_status->status = convert_to_oal_status(status);
+       conn_status->status = status;
 #else
        if (BT_STATUS_SUCCESS != status) {
                /* At present only timeout will cause non-success status, later we can add more */
@@ -705,7 +780,7 @@ void cb_device_acl_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr,
        memcpy(conn_status->address.addr, bd_addr->address, 6);
 #endif
 
-       BT_INFO("ACL STATE :%d, conn_status->status :%d, BT_ACL_STATE: %d", status, conn_status->status, state);
+       BT_INFO("[ACL] Status: %d, State: %d", conn_status->status, state);
 
        switch (state) {
        case BT_ACL_STATE_CONNECTED:
@@ -730,13 +805,12 @@ void cb_device_le_conn_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr,
                bt_le_conn_state_t state)
 {
        event_dev_conn_status_t * conn_status = g_new0(event_dev_conn_status_t, 1);
-       //bt_address_t * address = g_new0(bt_address_t, 1);
        oal_event_t event;
        gsize size = 0;
 
-       BT_DBG("LE conn status:%d, state: %d", status, state);
        memcpy(conn_status->address.addr, bd_addr->address, 6);
-       conn_status->status = convert_to_oal_status(status);
+       conn_status->status = status;
+       BT_INFO("[LE ACL] Status: %d, State: %d", conn_status->status, state);
 
        switch (state) {
        case BT_LE_CONN_STATE_CONNECTED:
@@ -866,12 +940,15 @@ void cb_device_trust_state_changed(bt_bdaddr_t *bd_addr, bt_device_trust_state_t
 }
 
 #ifdef TIZEN_BT_HAL
-void cb_socket_conn_authorize_request(bt_bdaddr_t *bd_addr, bt_uuid_t *uuid)
+void cb_socket_conn_authorize_request(bt_bdaddr_t *bd_addr, bt_uuid_t *uuid, uint8_t *name, uint8_t *path, uint32_t fd)
 {
        event_socket_authorize_req_t *auth_req = g_new0(event_socket_authorize_req_t, 1);
 
        memcpy(auth_req->address.addr, bd_addr->address, 6);
        memcpy(auth_req->uuid.uuid, uuid->uu, 16);
+       memcpy(auth_req->name, name, sizeof(auth_req->name) - 1);
+       memcpy(auth_req->path, path, sizeof(auth_req->path) - 1);
+       auth_req->fd = fd;
 
        send_event_bda_trace(OAL_EVENT_SOCKET_AUTHORIZE_REQUEST, auth_req, sizeof(event_socket_authorize_req_t), (bt_address_t*)bd_addr);
 }
@@ -936,4 +1013,21 @@ void cb_raw_rssi_received(bt_bdaddr_t *bd_addr, int32_t link_type, int32_t rssi)
                        ev, sizeof(event_dev_rssi_info_t), (bt_address_t*)bd_addr);
        BT_DBG("-");
 }
+
+void cb_dbfw_plus_info_received(unsigned char *data, uint32_t length, uint8_t event_code)
+{
+       event_dev_dbfw_plus_info_t *dbfw_info;
+       int len = (length > 512)?512:length;
+
+       ret_if(data == NULL || length == 0);
+
+       dbfw_info = g_new0(event_dev_dbfw_plus_info_t, 1);
+       dbfw_info->event_code = event_code;
+       memcpy(dbfw_info->data, data, len);
+       dbfw_info->length = len;
+
+       send_event(OAL_EVENT_DEVICE_DBFW_PLUS_INFO,
+               dbfw_info, sizeof(event_dev_dbfw_plus_info_t));
+}
+
 #endif