" <method name='AuthorizeService'>"
" <arg type='o' name='device' direction='in'/>"
" <arg type='s' name='uuid' direction='in'/>"
+ " <arg type='h' name='fd' direction='in'/>"
" </method>"
" <method name='Cancel'>"
" </method>"
GDBusMethodInvocation *invocation)
{
char *device_name, *device_address;
+ GDBusMessage *msg;
+ GUnixFDList *fd_list;
+ gint fd;
if (spp_ctx->max_pending == 0) {
bt_spp_reject(invocation);
return;
}
+ msg = g_dbus_method_invocation_get_message(invocation);
+
+ fd_list = g_dbus_message_get_unix_fd_list(msg);
+
+ fd = g_unix_fd_list_get(fd_list, (gint)0, NULL);
+
+ spp_ctx->channel = g_io_channel_unix_new(fd);
+
device_name = bluez_device_get_property_alias(device);
device_address = bluez_device_get_property_address(device);
if (g_strcmp0(method_name, "AuthorizeService") == 0) {
gchar *device_path, *uuid;
- g_variant_get(parameters, "(os)", &device_path, &uuid);
+ gint32 fd_index;
+
+ g_variant_get(parameters, "(osh)", &device_path,
+ &uuid, &fd_index);
request_authorize_service_handler(device_path,
uuid, invocation);
return;
}
- channel = g_io_channel_unix_new(fd);
- if (channel == NULL) {
- ERROR("Create connection channel error");
- g_dbus_method_invocation_return_value(invocation, NULL);
- goto done;
- }
+ if (!(spp_ctx->channel)) {
+ channel = g_io_channel_unix_new(fd);
+ if (channel == NULL) {
+ ERROR("Create connection channel error");
+ g_dbus_method_invocation_return_value(invocation, NULL);
+ goto done;
+ }
- spp_ctx->channel = channel;
+ spp_ctx->channel = channel;
+ } else
+ channel = spp_ctx->channel;
g_io_channel_set_close_on_unref(channel, TRUE);
g_io_channel_set_encoding(channel, NULL, NULL);
*
*/
+#include <gio/gunixfdlist.h>
#include "common.h"
#include "gdbus.h"
#include "comms_error.h"
" <method name='AuthorizeService'>"
" <arg type='o' name='device' direction='in'/>"
" <arg type='s' name='uuid' direction='in'/>"
+ " <arg type='h' name='fd' direction='in'/>"
" </method>"
" <method name='Cancel'>"
" </method>"
gpointer user_data)
{
struct agent_reply_data *reply_data;
+ GDBusMessage *msg;
+ GUnixFDList *in_fd_list, *out_fd_list;
+ GError *error = NULL;
+ gchar *device_path, *uuid;
+ gint32 fd_index;
+ gint fd;
DBG("");
+ g_variant_get(parameters, "(osh)", &device_path,
+ &uuid, &fd_index);
+
+ msg = g_dbus_method_invocation_get_message(invocation);
+
+ in_fd_list = g_dbus_message_get_unix_fd_list(msg);
+
+ fd = g_unix_fd_list_get(in_fd_list, fd_index, NULL);
+
+ out_fd_list = g_unix_fd_list_new();
+
+ g_unix_fd_list_append(out_fd_list, fd, &error);
+
+ g_assert_no_error(error);
+
reply_data = g_new0(struct agent_reply_data, 1);
reply_data->connection = connection;
reply_data->invocation = invocation;
- g_dbus_connection_call(connection,
- relay_agent->owner,
- relay_agent->object_path,
- AGENT_INTERFACE,
- "AuthorizeService",
- parameters,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- -1, NULL,
- relay_agent_reply,
- reply_data);
+ g_dbus_connection_call_with_unix_fd_list(connection,
+ relay_agent->owner,
+ relay_agent->object_path,
+ AGENT_INTERFACE,
+ "AuthorizeService",
+ parameters,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ out_fd_list,
+ NULL,
+ relay_agent_reply,
+ reply_data);
}
static void handle_cancel(GDBusConnection *connection,
const char *remote_address,
void *user_data)
{
-
+ int connected_socket_fd;
DBG("socket_fd = %d", socket_fd);
DBG("remote_address = %s", remote_address);
+ bt_socket_accept(fd, &connected_socket_fd);
+
+ DBG("Connected socket_fd = %d", connected_socket_fd);
socket_fd = fd;
}
int socket_set_connection_requested_cb(const char *p1, const char *p2)
{
int ret;
-
DBG("");
ret = bt_socket_set_connection_requested_cb(
if (g_strcmp0(method_name, "AuthorizeService") == 0) {
gchar *device_path, *uuid;
- g_variant_get(parameters, "(os)", &device_path, &uuid);
+ gint32 fd_index;
+ g_variant_get(parameters, "(osh)", &device_path,
+ &uuid, &fd_index);
printf("\n\tdevice %s uuid %s", device_path, uuid);
printf("\n\tAuthorize connection (yes/no):\n");