bluez/0001-Add-sixaxis-cable-pairing-plugin.patch

555 lines
16 KiB
Diff
Raw Normal View History

2012-03-07 10:02:34 +00:00
From 2977a39aad96cb3f2be90c6291169a25c9965fc9 Mon Sep 17 00:00:00 2001
2009-06-05 13:14:16 +00:00
From: Bastien Nocera <hadess@hadess.net>
2011-12-30 11:37:18 +00:00
Date: Fri, 30 Dec 2011 12:34:29 +0100
Subject: [PATCH] Add sixaxis cable-pairing plugin
2009-06-05 13:14:16 +00:00
Implement the old "sixpair" using libudev and libusb-1.0.
2009-06-05 13:14:16 +00:00
When a Sixaxis device is plugged in, events are filtered, and
the device is selected, poked around to set the default Bluetooth
address, and added to the database of the current default adapter.
---
Makefile.am | 9 +-
2010-09-09 22:13:17 +00:00
acinclude.m4 | 16 +++
configure.ac | 1 +
2010-12-19 14:41:05 +00:00
plugins/cable.c | 382 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/adapter.c | 19 +++
src/adapter.h | 3 +
6 files changed, 428 insertions(+), 2 deletions(-)
2009-06-05 13:14:16 +00:00
create mode 100644 plugins/cable.c
diff --git a/Makefile.am b/Makefile.am
2012-03-07 10:02:34 +00:00
index cafb4cc..4ccf4f0 100644
--- a/Makefile.am
+++ b/Makefile.am
2012-01-13 12:41:55 +00:00
@@ -244,6 +244,11 @@ builtin_sources += thermometer/main.c \
2011-08-01 22:38:07 +00:00
thermometer/thermometer.h thermometer/thermometer.c
endif
+if CABLE
+builtin_modules += cable
+builtin_sources += plugins/cable.c
+endif
+
2010-11-08 16:46:58 +00:00
builtin_modules += hciops mgmtops
builtin_sources += plugins/hciops.c plugins/mgmtops.c
2012-01-13 12:41:55 +00:00
@@ -311,7 +316,7 @@ src_bluetoothd_SOURCES = $(gdbus_sources) $(builtin_sources) \
2011-05-31 23:17:21 +00:00
src/event.h src/event.c \
src/oob.h src/oob.c src/eir.h src/eir.c
2011-12-30 11:37:18 +00:00
src_bluetoothd_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@ @DBUS_LIBS@ \
2010-10-27 18:16:55 +00:00
- @CAPNG_LIBS@ -ldl -lrt
+ @CAPNG_LIBS@ @CABLE_LIBS@ -ldl -lrt
src_bluetoothd_LDFLAGS = -Wl,--export-dynamic \
2010-10-27 18:04:10 +00:00
-Wl,--version-script=$(srcdir)/src/bluetooth.ver
2012-03-07 10:02:34 +00:00
@@ -447,7 +452,7 @@ EXTRA_DIST += doc/manager-api.txt \
AM_YFLAGS = -d
2011-12-30 11:37:18 +00:00
-AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ @CAPNG_CFLAGS@
+AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ @CAPNG_CFLAGS@ @CABLE_CFLAGS@
INCLUDES = -I$(builddir)/lib -I$(builddir)/src -I$(srcdir)/src \
2011-12-30 11:37:18 +00:00
-I$(srcdir)/audio -I$(srcdir)/sbc -I$(srcdir)/gdbus \
diff --git a/acinclude.m4 b/acinclude.m4
2012-03-07 10:02:34 +00:00
index b0f790c..20a930c 100644
--- a/acinclude.m4
+++ b/acinclude.m4
2012-03-07 10:02:34 +00:00
@@ -152,6 +152,12 @@ AC_DEFUN([AC_PATH_UDEV], [
2011-05-31 23:17:21 +00:00
AC_SUBST(UDEV_LIBS)
])
+AC_DEFUN([AC_PATH_CABLE], [
+ PKG_CHECK_MODULES(CABLE, libudev libusb-1.0, cable_found=yes, cable_found=no)
+ AC_SUBST(CABLE_CFLAGS)
+ AC_SUBST(CABLE_LIBS)
+])
2010-02-15 10:23:26 +00:00
+
AC_DEFUN([AC_PATH_SNDFILE], [
PKG_CHECK_MODULES(SNDFILE, sndfile, sndfile_found=yes, sndfile_found=no)
AC_SUBST(SNDFILE_CFLAGS)
2012-03-07 10:02:34 +00:00
@@ -189,6 +195,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [
2010-02-15 10:23:26 +00:00
sndfile_enable=${sndfile_found}
2010-09-09 22:13:17 +00:00
hal_enable=no
usb_enable=${usb_found}
+ cable_enable=${cable_found}
alsa_enable=${alsa_found}
gstreamer_enable=${gstreamer_found}
audio_enable=yes
2012-03-07 10:02:34 +00:00
@@ -298,6 +305,10 @@ AC_DEFUN([AC_ARG_BLUEZ], [
usb_enable=${enableval}
])
+ AC_ARG_ENABLE(cable, AC_HELP_STRING([--enable-cable], [enable DeviceKit support]), [
+ cable_enable=${enableval}
+ ])
2010-02-15 10:23:26 +00:00
+
2012-03-07 10:02:34 +00:00
AC_ARG_ENABLE(tools, AC_HELP_STRING([--enable-tools], [install Bluetooth utilities]), [
tools_enable=${enableval}
])
2012-03-07 10:02:34 +00:00
@@ -393,6 +404,10 @@ AC_DEFUN([AC_ARG_BLUEZ], [
2010-02-15 10:23:26 +00:00
AC_DEFINE(HAVE_LIBUSB, 1, [Define to 1 if you have USB library.])
fi
+ if (test "${cable_enable}" = "yes" && test "${cable_found}" = "yes"); then
+ AC_DEFINE(HAVE_CABLE, 1, [Define to 1 if you have libcable.])
+ fi
+
AM_CONDITIONAL(SNDFILE, test "${sndfile_enable}" = "yes" && test "${sndfile_found}" = "yes")
AM_CONDITIONAL(USB, test "${usb_enable}" = "yes" && test "${usb_found}" = "yes")
2010-03-26 10:47:21 +00:00
AM_CONDITIONAL(SBC, test "${alsa_enable}" = "yes" || test "${gstreamer_enable}" = "yes" ||
2012-03-07 10:02:34 +00:00
@@ -429,4 +444,5 @@ AC_DEFUN([AC_ARG_BLUEZ], [
2011-05-31 23:17:21 +00:00
AM_CONDITIONAL(DBUSOOBPLUGIN, test "${dbusoob_enable}" = "yes")
2011-08-01 22:38:07 +00:00
AM_CONDITIONAL(WIIMOTEPLUGIN, test "${wiimote_enable}" = "yes")
AM_CONDITIONAL(THERMOMETERPLUGIN, test "${thermometer_enable}" = "yes")
+ AM_CONDITIONAL(CABLE, test "${cable_enable}" = "yes" && test "${cable_found}" = "yes")
])
2009-06-05 13:14:16 +00:00
diff --git a/configure.ac b/configure.ac
2012-03-07 10:02:34 +00:00
index cd0f1cf..c61f230 100644
2009-06-05 13:14:16 +00:00
--- a/configure.ac
+++ b/configure.ac
2012-01-13 12:41:55 +00:00
@@ -46,6 +46,7 @@ AC_PATH_GSTREAMER
2009-06-05 13:14:16 +00:00
AC_PATH_USB
2011-05-31 23:17:21 +00:00
AC_PATH_UDEV
2009-06-05 13:14:16 +00:00
AC_PATH_SNDFILE
2011-05-31 23:17:21 +00:00
+AC_PATH_CABLE
2010-09-09 22:50:06 +00:00
AC_PATH_OUI
2011-05-31 23:17:21 +00:00
AC_PATH_READLINE
2012-01-13 12:41:55 +00:00
AC_PATH_CHECK
2009-06-05 13:14:16 +00:00
diff --git a/plugins/cable.c b/plugins/cable.c
new file mode 100644
2012-03-07 10:02:34 +00:00
index 0000000..b974b4c
2009-06-05 13:14:16 +00:00
--- /dev/null
+++ b/plugins/cable.c
2010-12-19 14:41:05 +00:00
@@ -0,0 +1,382 @@
2009-06-05 13:14:16 +00:00
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2009 Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE 1
+#include <libudev.h>
2009-06-05 13:14:16 +00:00
+#include <dbus/dbus.h>
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/sdp.h>
+#include <libusb.h>
+
+#include "plugin.h"
2010-05-24 11:22:48 +00:00
+#include "log.h"
2009-06-05 13:14:16 +00:00
+
+#include "adapter.h"
2010-12-19 14:41:05 +00:00
+#include "manager.h"
2009-06-05 13:14:16 +00:00
+#include "device.h"
+
+#include "storage.h"
+#include "sdp_lib.h"
+
+/* Vendor and product ID for the Sixaxis PS3 controller */
+#define VENDOR 0x054c
+#define PRODUCT 0x0268
+#define SIXAXIS_PNP_RECORD "3601920900000A000100000900013503191124090004350D35061901000900113503190011090006350909656E09006A0901000900093508350619112409010009000D350F350D350619010009001335031900110901002513576972656C65737320436F6E74726F6C6C65720901012513576972656C65737320436F6E74726F6C6C6572090102251B536F6E7920436F6D707574657220456E7465727461696E6D656E740902000901000902010901000902020800090203082109020428010902052801090206359A35980822259405010904A101A102850175089501150026FF00810375019513150025013500450105091901291381027501950D0600FF8103150026FF0005010901A10075089504350046FF0009300931093209358102C0050175089527090181027508953009019102750895300901B102C0A1028502750895300901B102C0A10285EE750895300901B102C0A10285EF750895300901B102C0C0090207350835060904090901000902082800090209280109020A280109020B09010009020C093E8009020D280009020E2800"
+#define HID_UUID "00001124-0000-1000-8000-00805f9b34fb"
+
+static struct btd_device *create_cable_association(DBusConnection *conn,
+ struct btd_adapter *adapter,
+ const char *name,
+ const char *address,
+ guint32 vendor_id,
+ guint32 product_id,
+ const char *pnp_record)
2009-06-05 13:14:16 +00:00
+{
+ sdp_record_t *rec;
+ struct btd_device *device;
+ bdaddr_t src, dst;
+ char srcaddr[18];
+
+ device = adapter_find_device(adapter, address);
2010-12-19 14:41:05 +00:00
+ if (device == NULL) {
2012-01-13 13:10:13 +00:00
+ device = device_create(conn, adapter, address, ADDR_TYPE_BREDR);
2010-12-19 14:41:05 +00:00
+ if (device != NULL)
+ adapter_create_device_for_device(conn, adapter, device);
+ }
2009-06-05 13:14:16 +00:00
+ if (device != NULL) {
+ device_set_temporary(device, FALSE);
+ device_set_name(device, name);
+ }
+
+ str2ba(address, &dst);
+ adapter_get_address(adapter, &src);
+ ba2str(&src, srcaddr);
+
+ write_device_name(&dst, &src, (char *) name);
+
+ /* Store the device's SDP record */
+ rec = record_from_string(pnp_record);
+ store_record(srcaddr, address, rec);
+ sdp_record_free(rec);
+ /* Set the device id */
+ store_device_id(srcaddr, address, 0xffff, vendor_id, product_id, 0);
+ /* Don't write a profile, it will be updated when the device connects */
+
+ write_trust(srcaddr, address, "[all]", TRUE);
+
+ return device;
+}
+
+static char *get_bdaddr(libusb_device_handle *devh, int itfnum)
+{
+ unsigned char msg[17];
+ char *address;
+ int res;
+
+ res = libusb_control_transfer(devh,
+ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
+ 0x01, 0x03f2, itfnum,
+ (void*) msg, sizeof(msg),
+ 5000);
+
+ if (res < 0) {
2010-06-14 10:45:59 +00:00
+ DBG("Getting the device Bluetooth address failed");
2009-06-05 13:14:16 +00:00
+ return NULL;
+ }
+
+ address = g_strdup_printf("%02X:%02X:%02X:%02X:%02X:%02X",
+ msg[4], msg[5], msg[6], msg[7], msg[8], msg[9]);
+
2010-06-14 10:45:59 +00:00
+ DBG("Device Bluetooth address: %s\n", address);
2009-06-05 13:14:16 +00:00
+
+ return address;
+}
+
+static gboolean set_master_bdaddr(libusb_device_handle *devh, int itfnum, char *host)
+{
+ unsigned char msg[8];
+ int mac[6];
+ int res;
+
+ if (sscanf(host, "%X:%X:%X:%X:%X:%X",
+ &mac[0],&mac[1],&mac[2],&mac[3],&mac[4],&mac[5]) != 6) {
+ return FALSE;
+ }
+
+ msg[0] = 0x01;
+ msg[1] = 0x00;
+ msg[2] = mac[0];
+ msg[3] = mac[1];
+ msg[4] = mac[2];
+ msg[5] = mac[3];
+ msg[6] = mac[4];
+ msg[7] = mac[5];
+
+ res = libusb_control_transfer(devh,
+ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
+ 0x09, 0x03f5, itfnum,
+ (void*) msg, sizeof(msg),
+ 5000);
+
+ if (res < 0) {
2010-06-14 10:45:59 +00:00
+ DBG("Setting the master Bluetooth address failed");
2009-06-05 13:14:16 +00:00
+ return FALSE;
+ }
+
+ return TRUE;
+}
+static void handle_usb_device(struct btd_adapter *adapter,
+ libusb_device *dev,
+ struct libusb_config_descriptor *cfg,
+ int itfnum,
+ const struct libusb_interface_descriptor *alt)
+{
+ DBusConnection *conn;
+ libusb_device_handle *devh;
+ char *device_bdaddr;
+ char adapter_bdaddr[18];
+ struct btd_device *device;
+ bdaddr_t dst;
+
2010-02-15 10:23:26 +00:00
+ device_bdaddr = NULL;
2009-06-05 13:14:16 +00:00
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (conn == NULL) {
2010-06-14 10:45:59 +00:00
+ DBG("Failed to get on the bus");
2009-06-05 13:14:16 +00:00
+ return;
+ }
+
+ if (libusb_open(dev, &devh) < 0) {
2010-06-14 10:45:59 +00:00
+ DBG("Can't open device");
2009-06-05 13:14:16 +00:00
+ goto bail;
+ }
+ libusb_detach_kernel_driver(devh, itfnum);
+
+ if (libusb_claim_interface(devh, itfnum) < 0) {
2010-06-14 10:45:59 +00:00
+ DBG("Can't claim interface %d", itfnum);
2009-06-05 13:14:16 +00:00
+ goto bail;
+ }
+
+ device_bdaddr = get_bdaddr(devh, itfnum);
+ if (device_bdaddr == NULL) {
2010-06-14 10:45:59 +00:00
+ DBG("Failed to get the Bluetooth address from the device");
2009-06-05 13:14:16 +00:00
+ goto bail;
+ }
+
+ device = create_cable_association(conn,
+ adapter,
+ "PLAYSTATION(R)3 Controller",
+ device_bdaddr,
+ VENDOR, PRODUCT, SIXAXIS_PNP_RECORD);
+ btd_device_add_uuid(device, HID_UUID);
+
+ adapter_get_address(adapter, &dst);
+ ba2str(&dst, adapter_bdaddr);
2010-06-14 10:45:59 +00:00
+ DBG("Adapter bdaddr %s", adapter_bdaddr);
2009-06-05 13:14:16 +00:00
+
+ if (set_master_bdaddr(devh, itfnum, adapter_bdaddr) == FALSE) {
2010-06-14 10:45:59 +00:00
+ DBG("Failed to set the master Bluetooth address");
2009-06-05 13:14:16 +00:00
+ goto bail;
+ }
+
+bail:
+ dbus_connection_unref(conn);
+ g_free(device_bdaddr);
+ libusb_release_interface(devh, itfnum);
+ /* We ignore errors from the reattach, as there's nothing we
+ * can do about it */
+ libusb_attach_kernel_driver(devh, itfnum);
+ if (devh != NULL)
+ libusb_close(devh);
+}
+
+static void handle_device_plug(struct udev_device *udevice)
2009-06-05 13:14:16 +00:00
+{
+ struct btd_adapter *adapter;
+ guint i;
+
+ libusb_device **list, *usbdev;
+ ssize_t num_devices;
+ struct libusb_device_descriptor desc;
+ guint8 j;
+
+ if (g_strcmp0(udev_device_get_property_value(udevice, "ID_SERIAL"),
+ "Sony_PLAYSTATION_R_3_Controller") != 0)
2009-06-05 13:14:16 +00:00
+ return;
+ /* Don't look at events with an associated driver */
+ if (udev_device_get_property_value(udevice, "ID_USB_DRIVER") != NULL)
2009-06-05 13:14:16 +00:00
+ return;
+
2010-06-14 10:45:59 +00:00
+ DBG("Found Sixaxis device");
2009-06-05 13:14:16 +00:00
+
+ /* Look for the default adapter */
2010-12-19 14:41:05 +00:00
+ adapter = manager_get_default_adapter();
2009-06-05 13:14:16 +00:00
+ if (adapter == NULL)
+ return;
+
+ /* Look for the USB device */
+ libusb_init(NULL);
+
+ num_devices = libusb_get_device_list(NULL, &list);
+ if (num_devices < 0) {
2010-06-14 10:45:59 +00:00
+ DBG("libusb_get_device_list failed");
2009-06-05 13:14:16 +00:00
+ return;
+ }
+
+ usbdev = NULL;
+ for (i = 0; i < num_devices; i++) {
+ char *path;
+
+ path = g_strdup_printf("%s/%03d/%03d", "/dev/bus/usb",
+ libusb_get_bus_number(list[i]),
+ libusb_get_device_address(list[i]));
+ if (g_strcmp0(path, udev_device_get_devnode(udevice)) == 0) {
2009-06-05 13:14:16 +00:00
+ g_free(path);
+ usbdev = libusb_ref_device(list[i]);
+ break;
+ }
+ g_free(path);
+ }
+
+ libusb_free_device_list(list, TRUE);
+ if (usbdev == NULL) {
2010-06-14 10:45:59 +00:00
+ DBG("Found a Sixaxis, but couldn't find it via libusb");
2009-06-05 13:14:16 +00:00
+ goto out;
+ }
+
+ if (libusb_get_device_descriptor(usbdev, &desc) < 0) {
2010-06-14 10:45:59 +00:00
+ DBG("libusb_get_device_descriptor() failed");
2009-06-05 13:14:16 +00:00
+ goto out;
+ }
+
+ /* Look for the interface number that interests us */
+ for (j = 0; j < desc.bNumConfigurations; j++) {
+ struct libusb_config_descriptor *config;
+ guint8 k;
+
+ if (libusb_get_config_descriptor(usbdev, j, &config) < 0) {
2010-06-14 10:45:59 +00:00
+ DBG("Failed to get config descriptor %d", j);
2009-06-05 13:14:16 +00:00
+ continue;
+ }
+
+ for (k = 0; k < config->bNumInterfaces; k++) {
+ const struct libusb_interface *itf = &config->interface[k];
+ int l;
+
+ for (l = 0; l < itf->num_altsetting ; l++) {
+ struct libusb_interface_descriptor alt;
+
+ alt = itf->altsetting[l];
+ if (alt.bInterfaceClass == 3) {
+ handle_usb_device(adapter, usbdev, config, l, &alt);
+ }
+ }
+ }
+ }
+
+out:
+ if (usbdev != NULL)
+ libusb_unref_device(usbdev);
+ libusb_exit(NULL);
+}
+
+static gboolean device_event_idle(struct udev_device *udevice)
2009-06-05 13:14:16 +00:00
+{
+ handle_device_plug(udevice);
+ udev_device_unref(udevice);
2009-06-05 13:14:16 +00:00
+ return FALSE;
+}
+
+static struct udev *ctx = NULL;
+static struct udev_monitor *monitor = NULL;
+static guint watch_id = 0;
+
+static gboolean
+monitor_event(GIOChannel *source,
+ GIOCondition condition,
+ gpointer data)
2009-06-05 13:14:16 +00:00
+{
+ struct udev_device *udevice;
+
+ udevice = udev_monitor_receive_device(monitor);
+ if (udevice == NULL)
+ goto out;
+ if (g_strcmp0(udev_device_get_action(udevice), "add") != 0)
+ goto out;
+
+ g_timeout_add_seconds(1, (GSourceFunc) device_event_idle, udevice);
+
+out:
+ return TRUE;
2009-06-05 13:14:16 +00:00
+}
+
+
+static int cable_init(void)
+{
+ GIOChannel *channel;
2009-06-05 13:14:16 +00:00
+
2010-06-14 10:45:59 +00:00
+ DBG("Setup cable plugin");
2009-06-05 13:14:16 +00:00
+
+ ctx = udev_new();
+ monitor = udev_monitor_new_from_netlink(ctx, "udev");
+ if (monitor == NULL) {
+ error ("Could not get udev monitor");
+ return -1;
+ }
2009-06-05 13:14:16 +00:00
+
+ /* Listen for newly connected usb device */
+ udev_monitor_filter_add_match_subsystem_devtype(monitor,
+ "usb", NULL);
+ udev_monitor_enable_receiving(monitor);
2009-06-05 13:14:16 +00:00
+
+ channel = g_io_channel_unix_new(udev_monitor_get_fd(monitor));
+ watch_id = g_io_add_watch(channel, G_IO_IN, monitor_event, NULL);
+ g_io_channel_unref(channel);
2009-06-05 13:14:16 +00:00
+
+ return 0;
+}
+
+static void cable_exit(void)
+{
2010-06-14 10:45:59 +00:00
+ DBG("Cleanup cable plugin");
2009-06-05 13:14:16 +00:00
+
+ if (watch_id != 0) {
+ g_source_remove(watch_id);
+ watch_id = 0;
+ }
+ if (monitor != NULL) {
+ udev_monitor_unref(monitor);
+ monitor = NULL;
+ }
+ if (ctx != NULL) {
+ udev_unref(ctx);
+ ctx = NULL;
2009-06-05 13:14:16 +00:00
+ }
+}
+
+BLUETOOTH_PLUGIN_DEFINE(cable, VERSION,
+ BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, cable_init, cable_exit)
2010-12-19 14:41:05 +00:00
diff --git a/src/adapter.c b/src/adapter.c
2012-03-07 10:02:34 +00:00
index acb845e..478a8fb 100644
2010-12-19 14:41:05 +00:00
--- a/src/adapter.c
+++ b/src/adapter.c
2012-03-07 10:02:34 +00:00
@@ -952,6 +952,25 @@ static struct btd_device *adapter_create_device(DBusConnection *conn,
2010-12-19 14:41:05 +00:00
return device;
}
+void adapter_create_device_for_device(DBusConnection *conn,
+ struct btd_adapter *adapter,
+ struct btd_device *device)
+{
+ const char *path;
+
+ device_set_temporary(device, TRUE);
+
+ adapter->devices = g_slist_append(adapter->devices, device);
+
+ path = device_get_path(device);
+ g_dbus_emit_signal(conn, adapter->path,
+ ADAPTER_INTERFACE, "DeviceCreated",
+ DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
+
+ adapter_update_devices(adapter);
+}
+
void adapter_remove_device(DBusConnection *conn, struct btd_adapter *adapter,
struct btd_device *device,
gboolean remove_storage)
diff --git a/src/adapter.h b/src/adapter.h
2012-03-07 10:02:34 +00:00
index ceebb97..b0a0461 100644
2010-12-19 14:41:05 +00:00
--- a/src/adapter.h
+++ b/src/adapter.h
2012-03-07 10:02:34 +00:00
@@ -123,6 +123,9 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
2012-01-13 12:41:55 +00:00
uint8_t *data, uint8_t data_len);
2010-12-19 14:41:05 +00:00
void adapter_emit_device_found(struct btd_adapter *adapter,
2011-01-13 14:52:36 +00:00
struct remote_dev_info *dev);
2010-12-19 14:41:05 +00:00
+void adapter_create_device_for_device(DBusConnection *conn,
+ struct btd_adapter *adapter,
+ struct btd_device *device);
void adapter_mode_changed(struct btd_adapter *adapter, uint8_t scan_mode);
2011-12-30 11:37:18 +00:00
int adapter_set_name(struct btd_adapter *adapter, const char *name);
void adapter_name_changed(struct btd_adapter *adapter, const char *name);
2009-06-05 13:14:16 +00:00
--
2012-03-07 10:02:34 +00:00
1.7.7.6
2009-06-05 13:14:16 +00:00