Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bluez-4.98 update

  • Loading branch information...
commit 0e735d04a67ce793d560d21e1310bb859e886657 1 parent 14cc863
Sergey Kondakov authored
7 net-wireless/bluez/Manifest
View
@@ -1,15 +1,22 @@
AUX bluetooth-conf.d 181 RMD160 287e1806e25a4f74b4a9f6fc401b78dac31d44ee SHA1 595f897553a6e99000b4a4757f8973b9f39ce11d SHA256 63a96c907996158f637abc3202235b81e7c8a998df487b3e83554062433dd2f8
AUX bluetooth-init.d 767 RMD160 7afb50646e359ed1ede5abdc4e5e01319dc9e3c4 SHA1 3685d4dbbf56802cb03a483dad23825968dc57f8 SHA256 38efb9dffaab70477f7525dd6657dffc725c61e29c05b0649e95c31f589b31ce
+AUX bluetooth-init.d-r1 454 RMD160 c4521bba34ef4fc8fa2a624f55c900531d110b83 SHA1 3a0eccc0b2cf4801e594760660143fe1e2d8a53a SHA256 04de6c5bd2d2c702b0e27d7b379a284643cf2f5a03f3c5e3eaf1ac728d47b886
AUX bluez-4.18-udev.rules 228 RMD160 ab9b4ce8907c62eb9d1f14406cc2ff3f5ec69a19 SHA1 14e652de6cfed28f215727800460e600129007c2 SHA256 7577c2ed295b67f960f17ac65a44889c6536c125b34e33860d6d9f128a59fa82
AUX bluez-4.18-udev.script 752 RMD160 d8f60749dbe497bef7362a4c3f56b2b83ca079cb SHA1 0c39b4b4f4c57fb334daa793f89c0ffac046b956 SHA256 cb41a4eeea5137fb27d82d74f34e5e7dd725ddf8442c39ea623afe0d3c041fcf
AUX bluez-4.96-bAdd-sixaxis-plugin-USB-pairing-and-LEDs-settings.patch 18383 RMD160 58c20ce5e573e72086d362f7e5664cc974bcaf83 SHA1 7910b8ac8466a4f1d5b6b7e860225c197eff24a8 SHA256 952d6bc5653b22663851aa36ef62796e55dce27eae536a8169beac55674294ea
AUX bluez-4.96-cLink-to-udev-only-when-needed.patch 576 RMD160 776b69deb553baf2f33f64003633ce707c81c83e SHA1 6fa5edf5c9802e6a763aa6fd14672e5addff01dc SHA256 aa61a3436157350f3dd3713dec2c751f13da4adac938e5e4ae29ef1ecb02301a
AUX bluez-4.96-dplugins-sixaxis-Wait-for-the-PS-button-before-setting-the-LEDs.patch 452 RMD160 a22f2c48f3a300c8488f1f4b8c3aeb538345feb9 SHA1 2750a2fef0ae7d30ac6311a0710e71009133811e SHA256 668eea2f0589ca4a05b69a888949aa042c6a043e4ea78a006a47c44f28700230
+AUX bluez-4.98-Add-sixaxis-cable-pairing-plugin.patch 16272 RMD160 d2f31ced41bdd43e2c79c0f4471a0eba94634f7e SHA1 ea0283f3c2199649c6319520e068a89326ff64ea SHA256 5ba857752d45dc4cb311749a7889b6abd36b60e32a933be30adc12b2b7397abd
AUX bluez-plugdev.patch 469 RMD160 a70cd0310240491cf14a5a6d7b60e760804e9816 SHA1 b273aac740e7c19aebc441c6c77e0ba8d32f3480 SHA256 ec3f06f24f530574edf5eef308afcf16bb7e0a88336a454a0b24698d2491f5f2
AUX conf.d-dund 96 RMD160 cf0a59a45f6f1bab134e4aab3545a94dfe094ae0 SHA1 c8d3196d8a917ee5240900af8478bb5adc6c7dea SHA256 fcbf3993c373a71e14557ed35854e839fd7ebf3526f753c83cee07194afca64b
AUX conf.d-hidd 89 RMD160 31407e00bcb00eb0b9c1adeb7434a922bfb967e9 SHA1 dc6831fa817c8bd2378830e13bc96d3ff3fdffa2 SHA256 8fc50b8c644e0bc69eacef2a9555118b2f4758aafcb42e8ea3ca1293e8f3a211
AUX init.d-dund 551 RMD160 273a9fb1989b80f12dc9813e9fe9ca42bd010e33 SHA1 51a24ecdf6d973c09553ed525e97e1cad2d6261f SHA256 e4985a2295d1cd2361b4a6a01b2d474820bf66cb1ff9251742d7aacd0fa574aa
AUX init.d-hidd 780 RMD160 46a761ad2e151c2e1d997a9455edf4e3e4d61df0 SHA1 7d2d80a91517d5fa2965c1ac6078d8cc4f382198 SHA256 b1878d70112fd8fa1b851aaa4caa5e2b4efb55bf8e2dda02c014b55ce93adedb
+AUX rfcomm-conf.d 150 RMD160 5b4e24e56ea284f2bc80436a641fec0c6d0a8e84 SHA1 1716708772bf67f7f83ed562c35cc3b12da8073c SHA256 672498957049fd301f9c9c1dc9fa49430e5e6d3c3f1f3cdce80df3af7d425d08
+AUX rfcomm-init.d 668 RMD160 6c4f90ffbb00651fa957b91150c0c0ebb8ad11fb SHA1 93fc518eb512d71625d5d62da65c3b5c3e926401 SHA256 4430703a9bec9a9482416b2d24aa47492264768a0b61356b361bbc8b1229a83e
DIST bluez-4.96.tar.gz 1164913 RMD160 7775a70c5cd86fc418547fae83621dab39196147 SHA1 c9327784cbcf1efc03cc547ceb18de90c8fb4c7c SHA256 c06fd50fd77909cad55e3181a42c6bce7cfcf7abb8cd87871c13d0d70f87fa99
+DIST bluez-4.98.tar.xz 838868 RMD160 eeb933670dc610d46f574da274edc58c3e07942a SHA1 4fe7cbee9db8bd82c30046d4ccca132702b511ad SHA256 6eb21e712e8835eb1aec84bdfb38891cc4dc5353af921b8235d481da13c565d9
DIST oui-20110801.txt.xz 520980 RMD160 2f7c863825fa8ae35d9beebe6bbd49fddd32f32e SHA1 a210a711e4e8046627676e5adf56132c977b663c SHA256 47be96b0e7b4a3235260f94ad77445fbf5226832ede588d9ea67d61759ff32e3
+DIST oui-20120113.txt.xz 541268 RMD160 445c782408d427bce66eadd3e179c425e3eb4c76 SHA1 6bc294d6992242648189b234e04afc96fce4a7cf SHA256 f65d2096566d88f9c55ce4da9104696cecb262a7d07c2f2ff58332f1ab40ae84
EBUILD bluez-4.96-r1.ebuild 5097 RMD160 abbf0bd873bac7aeede99ff29226f72cfef87a77 SHA1 b5d48c11eb9d257f54979d03a0c96f6a20e03347 SHA256 4c204b59156d44106f95d797d5e64aec206ca0997e258bf43621fc849cb296b2
+EBUILD bluez-4.98-r1.ebuild 4763 RMD160 56825a99bb12891a5f693d90c1a72e365c350027 SHA1 c9a6bb5ab1983ac922b808c5f51643f06a523f69 SHA256 db7649de4e2b2eacc11ad0263e2293b4833c19fb48d487c5a17084510f65b618
182 net-wireless/bluez/bluez-4.98-r1.ebuild
View
@@ -0,0 +1,182 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-wireless/bluez/bluez-4.98-r1.ebuild,v 1.4 2012/01/26 11:39:09 chainsaw Exp $
+
+EAPI="4"
+PYTHON_DEPEND="test-programs? 2"
+
+inherit multilib eutils systemd python autotools
+
+DESCRIPTION="Bluetooth Tools and System Daemons for Linux"
+HOMEPAGE="http://www.bluez.org/"
+
+# Because of oui.txt changing from time to time without noticement, we need to supply it
+# ourselves instead of using http://standards.ieee.org/regauth/oui/oui.txt directly.
+# See bugs #345263 and #349473 for reference.
+OUIDATE="20120113"
+SRC_URI="mirror://kernel/linux/bluetooth/${P}.tar.xz
+ http://dev.gentoo.org/~pacho/bluez/oui-${OUIDATE}.txt.xz"
+
+LICENSE="GPL-2 LGPL-2.1"
+SLOT="0"
+KEYWORDS="amd64 ~arm ~hppa ~ppc ~ppc64 ~x86"
+IUSE="alsa caps +consolekit cups debug gstreamer pcmcia test-programs +usb"
+
+CDEPEND="
+ >=dev-libs/glib-2.14:2
+ sys-apps/dbus
+ >=sys-fs/udev-169
+ alsa? (
+ media-libs/alsa-lib[alsa_pcm_plugins_extplug(+),alsa_pcm_plugins_ioplug(+)]
+ media-libs/libsndfile
+ )
+ caps? ( >=sys-libs/libcap-ng-0.6.2 )
+ cups? ( net-print/cups )
+ gstreamer? (
+ >=media-libs/gstreamer-0.10:0.10
+ >=media-libs/gst-plugins-base-0.10:0.10
+ )
+ usb? ( dev-libs/libusb:1 )
+"
+DEPEND="${CDEPEND}
+ >=dev-util/pkgconfig-0.20
+ sys-devel/flex
+ test-programs? ( >=dev-libs/check-0.9.6 )
+"
+RDEPEND="${CDEPEND}
+ !net-wireless/bluez-libs
+ !net-wireless/bluez-utils
+ consolekit? (
+ || ( sys-auth/consolekit
+ >=sys-apps/systemd-37 )
+ )
+ test-programs? (
+ dev-python/dbus-python
+ dev-python/pygobject:2
+ )
+"
+
+DOCS=( AUTHORS ChangeLog README )
+
+pkg_setup() {
+ if ! use consolekit; then
+ enewgroup plugdev
+ fi
+
+ if use test-programs; then
+ python_pkg_setup
+ fi
+}
+
+src_prepare() {
+ if ! use consolekit; then
+ # No consolekit for at_console etc, so we grant plugdev the rights
+ epatch "${FILESDIR}/bluez-plugdev.patch"
+ fi
+
+ if use cups; then
+ sed -i \
+ -e "s:cupsdir = \$(libdir)/cups:cupsdir = `cups-config --serverbin`:" \
+ Makefile.tools Makefile.in || die
+ fi
+
+ # sixaxis/dualshock3 support
+ epatch "${FILESDIR}"/bluez-4.98-Add-sixaxis-cable-pairing-plugin.patch
+ eautoreconf
+}
+
+src_configure() {
+ econf \
+ --enable-hid2hci \
+ --enable-audio \
+ --enable-bccmd \
+ --enable-datafiles \
+ --enable-dfutool \
+ --enable-input \
+ --enable-network \
+ --enable-serial \
+ --enable-service \
+ --enable-tools \
+ --disable-hal \
+ --localstatedir=/var \
+ --with-systemdunitdir="$(systemd_get_unitdir)" \
+ $(use_enable alsa) \
+ $(use_enable caps capng) \
+ $(use_enable cups) \
+ $(use_enable debug) \
+ $(use_enable gstreamer) \
+ $(use_enable pcmcia) \
+ $(use_enable test-programs test) \
+ $(use_enable usb) \
+ --enable-alert \
+ --enable-dbusoob \
+ --enable-health \
+ --enable-maemo6 \
+ --enable-pnat \
+ --enable-proximity \
+ --enable-sap \
+ --enable-time \
+ --enable-thermometer \
+ --enable-wii
+}
+
+src_install() {
+ default
+
+ if use test-programs ; then
+ cd "${S}/test"
+ dobin simple-agent simple-service monitor-bluetooth
+ newbin list-devices list-bluetooth-devices
+ rm test-textfile.{c,o} || die # bug #356529
+ for b in apitest hsmicro hsplay test-* ; do
+ newbin "${b}" "bluez-${b}"
+ done
+ insinto /usr/share/doc/${PF}/test-services
+ doins service-*
+
+ python_convert_shebangs -r 2 "${ED}"
+ cd "${S}"
+ fi
+
+ insinto /etc/bluetooth
+ doins \
+ input/input.conf \
+ audio/audio.conf \
+ network/network.conf \
+ serial/serial.conf
+
+ newinitd "${FILESDIR}/bluetooth-init.d-r1" bluetooth
+ newinitd "${FILESDIR}/rfcomm-init.d" rfcomm
+ newconfd "${FILESDIR}/rfcomm-conf.d" rfcomm
+
+ # Install oui.txt as requested in bug #283791 and approved by upstream
+ insinto /var/lib/misc
+ newins "${WORKDIR}/oui-${OUIDATE}.txt" oui.txt
+
+ find "${D}" -name "*.la" -delete
+}
+
+pkg_postinst() {
+ udevadm control --reload-rules && udevadm trigger --subsystem-match=bluetooth
+
+ if ! has_version "net-dialup/ppp"; then
+ elog "To use dial up networking you must install net-dialup/ppp."
+ fi
+
+ if use consolekit; then
+ elog "If you want to use rfcomm as a normal user, you need to add the user"
+ elog "to the uucp group."
+ else
+ elog "Since you have the consolekit use flag disabled, you will only be able to run"
+ elog "bluetooth clients as root. If you want to be able to run bluetooth clientes as "
+ elog "a regular user, you need to enable the consolekit use flag for this package or"
+ elog "to add the user to the plugdev group."
+ fi
+
+ if [ "$(rc-config list default | grep bluetooth)" = "" ] ; then
+ elog "You will need to add bluetooth service to default runlevel"
+ elog "for getting your devices detected from startup without needing"
+ elog "to reconnect them. For that please run:"
+ elog "'rc-update add bluetooth default'"
+ fi
+}
19 net-wireless/bluez/files/bluetooth-init.d-r1
View
@@ -0,0 +1,19 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-wireless/bluez/files/bluetooth-init.d-r1,v 1.1 2012/01/09 23:01:55 pacho Exp $
+
+depend() {
+ after coldplug
+ need dbus localmount hostname
+}
+
+start() {
+ ebegin "Udev coldplug of bluetooth devices"
+ udevadm trigger --subsystem-match=bluetooth --action=add
+ eend $?
+}
+
+stop() {
+ return 0
+}
554 net-wireless/bluez/files/bluez-4.98-Add-sixaxis-cable-pairing-plugin.patch
View
@@ -0,0 +1,554 @@
+From 3e999539978919395af19ac1b554ca997ab1b3d1 Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess@hadess.net>
+Date: Fri, 30 Dec 2011 12:34:29 +0100
+Subject: [PATCH] Add sixaxis cable-pairing plugin
+
+Implement the old "sixpair" using libudev and libusb-1.0.
+
+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 +-
+ acinclude.m4 | 16 +++
+ configure.ac | 1 +
+ plugins/cable.c | 382 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ src/adapter.c | 19 +++
+ src/adapter.h | 3 +
+ 6 files changed, 428 insertions(+), 2 deletions(-)
+ create mode 100644 plugins/cable.c
+
+diff --git a/Makefile.am b/Makefile.am
+index 102ee62..63d7198 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -244,6 +244,11 @@ builtin_sources += thermometer/main.c \
+ thermometer/thermometer.h thermometer/thermometer.c
+ endif
+
++if CABLE
++builtin_modules += cable
++builtin_sources += plugins/cable.c
++endif
++
+ builtin_modules += hciops mgmtops
+ builtin_sources += plugins/hciops.c plugins/mgmtops.c
+
+@@ -311,7 +316,7 @@ src_bluetoothd_SOURCES = $(gdbus_sources) $(builtin_sources) \
+ src/event.h src/event.c \
+ src/oob.h src/oob.c src/eir.h src/eir.c
+ src_bluetoothd_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@ @DBUS_LIBS@ \
+- @CAPNG_LIBS@ -ldl -lrt
++ @CAPNG_LIBS@ @CABLE_LIBS@ -ldl -lrt
+ src_bluetoothd_LDFLAGS = -Wl,--export-dynamic \
+ -Wl,--version-script=$(srcdir)/src/bluetooth.ver
+
+@@ -432,7 +437,7 @@ EXTRA_DIST += doc/manager-api.txt \
+
+ AM_YFLAGS = -d
+
+-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 \
+ -I$(srcdir)/audio -I$(srcdir)/sbc -I$(srcdir)/gdbus \
+diff --git a/acinclude.m4 b/acinclude.m4
+index 57fc5e0..90582ba 100644
+--- a/acinclude.m4
++++ b/acinclude.m4
+@@ -149,6 +149,12 @@ AC_DEFUN([AC_PATH_UDEV], [
+ 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)
++])
++
+ AC_DEFUN([AC_PATH_SNDFILE], [
+ PKG_CHECK_MODULES(SNDFILE, sndfile, sndfile_found=yes, sndfile_found=no)
+ AC_SUBST(SNDFILE_CFLAGS)
+@@ -186,6 +192,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [
+ sndfile_enable=${sndfile_found}
+ hal_enable=no
+ usb_enable=${usb_found}
++ cable_enable=${cable_found}
+ alsa_enable=${alsa_found}
+ gstreamer_enable=${gstreamer_found}
+ audio_enable=yes
+@@ -296,6 +303,10 @@ AC_DEFUN([AC_ARG_BLUEZ], [
+ usb_enable=${enableval}
+ ])
+
++ AC_ARG_ENABLE(cable, AC_HELP_STRING([--enable-cable], [enable DeviceKit support]), [
++ cable_enable=${enableval}
++ ])
++
+ AC_ARG_ENABLE(tracer, AC_HELP_STRING([--enable-tracer], [install Tracing daemon]), [
+ tracer_enable=${enableval}
+ ])
+@@ -395,6 +406,10 @@ AC_DEFUN([AC_ARG_BLUEZ], [
+ 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")
+ AM_CONDITIONAL(SBC, test "${alsa_enable}" = "yes" || test "${gstreamer_enable}" = "yes" ||
+@@ -432,4 +447,5 @@ AC_DEFUN([AC_ARG_BLUEZ], [
+ AM_CONDITIONAL(DBUSOOBPLUGIN, test "${dbusoob_enable}" = "yes")
+ 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")
+ ])
+diff --git a/configure.ac b/configure.ac
+index 5b81f28..0e0dd9d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -46,6 +46,7 @@ AC_PATH_GSTREAMER
+ AC_PATH_USB
+ AC_PATH_UDEV
+ AC_PATH_SNDFILE
++AC_PATH_CABLE
+ AC_PATH_OUI
+ AC_PATH_READLINE
+ AC_PATH_CHECK
+diff --git a/plugins/cable.c b/plugins/cable.c
+new file mode 100644
+index 0000000..e8cff76
+--- /dev/null
++++ b/plugins/cable.c
+@@ -0,0 +1,382 @@
++/*
++ *
++ * 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>
++#include <dbus/dbus.h>
++#include <bluetooth/bluetooth.h>
++#include <bluetooth/sdp.h>
++#include <libusb.h>
++
++#include "plugin.h"
++#include "log.h"
++
++#include "adapter.h"
++#include "manager.h"
++#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)
++{
++ sdp_record_t *rec;
++ struct btd_device *device;
++ bdaddr_t src, dst;
++ char srcaddr[18];
++
++ device = adapter_find_device(adapter, address);
++ if (device == NULL) {
++ device = device_create(conn, adapter, address, ADDR_TYPE_BREDR);
++ if (device != NULL)
++ adapter_create_device_for_device(conn, adapter, device);
++ }
++ 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) {
++ DBG("Getting the device Bluetooth address failed");
++ return NULL;
++ }
++
++ address = g_strdup_printf("%02X:%02X:%02X:%02X:%02X:%02X",
++ msg[4], msg[5], msg[6], msg[7], msg[8], msg[9]);
++
++ DBG("Device Bluetooth address: %s\n", address);
++
++ 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) {
++ DBG("Setting the master Bluetooth address failed");
++ 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;
++
++ device_bdaddr = NULL;
++ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
++ if (conn == NULL) {
++ DBG("Failed to get on the bus");
++ return;
++ }
++
++ if (libusb_open(dev, &devh) < 0) {
++ DBG("Can't open device");
++ goto bail;
++ }
++ libusb_detach_kernel_driver(devh, itfnum);
++
++ if (libusb_claim_interface(devh, itfnum) < 0) {
++ DBG("Can't claim interface %d", itfnum);
++ goto bail;
++ }
++
++ device_bdaddr = get_bdaddr(devh, itfnum);
++ if (device_bdaddr == NULL) {
++ DBG("Failed to get the Bluetooth address from the device");
++ 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);
++ DBG("Adapter bdaddr %s", adapter_bdaddr);
++
++ if (set_master_bdaddr(devh, itfnum, adapter_bdaddr) == FALSE) {
++ DBG("Failed to set the master Bluetooth address");
++ 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)
++{
++ 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)
++ return;
++ /* Don't look at events with an associated driver */
++ if (udev_device_get_property_value(udevice, "ID_USB_DRIVER") != NULL)
++ return;
++
++ DBG("Found Sixaxis device");
++
++ /* Look for the default adapter */
++ adapter = manager_get_default_adapter();
++ if (adapter == NULL)
++ return;
++
++ /* Look for the USB device */
++ libusb_init(NULL);
++
++ num_devices = libusb_get_device_list(NULL, &list);
++ if (num_devices < 0) {
++ DBG("libusb_get_device_list failed");
++ 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) {
++ g_free(path);
++ usbdev = libusb_ref_device(list[i]);
++ break;
++ }
++ g_free(path);
++ }
++
++ libusb_free_device_list(list, TRUE);
++ if (usbdev == NULL) {
++ DBG("Found a Sixaxis, but couldn't find it via libusb");
++ goto out;
++ }
++
++ if (libusb_get_device_descriptor(usbdev, &desc) < 0) {
++ DBG("libusb_get_device_descriptor() failed");
++ 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) {
++ DBG("Failed to get config descriptor %d", j);
++ 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)
++{
++ handle_device_plug(udevice);
++ udev_device_unref(udevice);
++ 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)
++{
++ 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;
++}
++
++
++static int cable_init(void)
++{
++ GIOChannel *channel;
++
++ DBG("Setup cable plugin");
++
++ ctx = udev_new();
++ monitor = udev_monitor_new_from_netlink(ctx, "udev");
++ if (monitor == NULL) {
++ error ("Could not get udev monitor");
++ return -1;
++ }
++
++ /* Listen for newly connected usb device */
++ udev_monitor_filter_add_match_subsystem_devtype(monitor,
++ "usb", NULL);
++ udev_monitor_enable_receiving(monitor);
++
++ 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);
++
++ return 0;
++}
++
++static void cable_exit(void)
++{
++ DBG("Cleanup cable plugin");
++
++ 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;
++ }
++}
++
++BLUETOOTH_PLUGIN_DEFINE(cable, VERSION,
++ BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, cable_init, cable_exit)
+diff --git a/src/adapter.c b/src/adapter.c
+index 7e4bbb6..012f632 100644
+--- a/src/adapter.c
++++ b/src/adapter.c
+@@ -1014,6 +1014,25 @@ static struct btd_device *adapter_create_device(DBusConnection *conn,
+ 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
+index fb1dcdf..4c3d148 100644
+--- a/src/adapter.h
++++ b/src/adapter.h
+@@ -108,6 +108,9 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
+ uint8_t *data, uint8_t data_len);
+ void adapter_emit_device_found(struct btd_adapter *adapter,
+ struct remote_dev_info *dev);
++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);
+ int adapter_set_name(struct btd_adapter *adapter, const char *name);
+ void adapter_name_changed(struct btd_adapter *adapter, const char *name);
+--
+1.7.6.4
+
5 net-wireless/bluez/files/rfcomm-conf.d
View
@@ -0,0 +1,5 @@
+# Bind rfcomm devices (allowed values are "true" and "false")
+RFCOMM_ENABLE=true
+
+# Config file for rfcomm
+RFCOMM_CONFIG="/etc/bluetooth/rfcomm.conf"
27 net-wireless/bluez/files/rfcomm-init.d
View
@@ -0,0 +1,27 @@
+#!/sbin/runscript
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-wireless/bluez/files/rfcomm-init.d,v 1.1 2011/12/31 21:09:18 pacho Exp $
+
+depend() {
+ after coldplug
+ need dbus localmount hostname
+}
+
+start() {
+ if [ "${RFCOMM_ENABLE}" = "true" -a -x /usr/bin/rfcomm ]; then
+ if [ -f "${RFCOMM_CONFIG}" ]; then
+ ebegin "Starting rfcomm"
+ /usr/bin/rfcomm -f "${RFCOMM_CONFIG}" bind all
+ eend $?
+ else
+ ewarn "Not enabling rfcomm because RFCOMM_CONFIG does not exists"
+ fi
+ fi
+}
+
+stop() {
+ ebegin "Shutting down rfcomm"
+ /usr/bin/rfcomm release all
+ eend $?
+}
Please sign in to comment.
Something went wrong with that request. Please try again.