CAPI/Socket: Implement function bt_socket_accept 11/22711/1
authorWu Jiangbo <jiangbox.wu@intel.com>
Tue, 10 Jun 2014 03:44:34 +0000 (11:44 +0800)
committerWu Jiangbo <jiangbox.wu@intel.com>
Tue, 10 Jun 2014 11:34:50 +0000 (19:34 +0800)
Change-Id: I40ee627e7501cb4d497f156ddddfd696e004a4e7
Signed-off-by: Wu Jiangbo <jiangbox.wu@intel.com>
capi/bluetooth.c

index 68e67f0..05b6a8f 100644 (file)
@@ -4106,6 +4106,27 @@ int bt_socket_listen_and_accept_rfcomm(int socket_fd,
        return BT_SUCCESS;
 }
 
+int bt_socket_accept(int requested_socket_fd, int *connected_socket_fd)
+{
+       struct spp_context *spp_ctx;
+
+       if (connected_socket_fd == NULL)
+               return BT_ERROR_INVALID_PARAMETER;
+
+       spp_ctx = find_spp_context_from_socketfd(requested_socket_fd);
+       if (spp_ctx == NULL)
+               return BT_ERROR_OPERATION_FAILED;
+
+       bt_spp_accept(spp_ctx->requestion);
+
+       if (spp_ctx->max_pending > 0)
+               spp_ctx->max_pending--;
+
+       *connected_socket_fd = g_io_channel_unix_get_fd(spp_ctx->channel);
+
+       return BT_SUCCESS;
+}
+
 int bt_socket_set_connection_state_changed_cb(
                        bt_socket_connection_state_changed_cb callback,
                        void *user_data)