Fix trust setting in Sixaxis devices
This commit is contained in:
parent
ce8270ace4
commit
c38c767f28
@ -1,4 +1,4 @@
|
|||||||
From 64f9449656dbbb718d53a54ed8e7904e289280ec Mon Sep 17 00:00:00 2001
|
From 03827726cebf7d8b5bc5a4e7859ea92a7e62044f Mon Sep 17 00:00:00 2001
|
||||||
From: Bastien Nocera <hadess@hadess.net>
|
From: Bastien Nocera <hadess@hadess.net>
|
||||||
Date: Fri, 30 Dec 2011 12:34:29 +0100
|
Date: Fri, 30 Dec 2011 12:34:29 +0100
|
||||||
Subject: [PATCH] Add sixaxis cable-pairing plugin
|
Subject: [PATCH] Add sixaxis cable-pairing plugin
|
||||||
@ -9,17 +9,19 @@ When a Sixaxis device is plugged in, events are filtered, and
|
|||||||
the device is selected, poked around to set the default Bluetooth
|
the device is selected, poked around to set the default Bluetooth
|
||||||
address, and added to the database of the current default adapter.
|
address, and added to the database of the current default adapter.
|
||||||
---
|
---
|
||||||
Makefile.am | 9 +-
|
Makefile.am | 9 +-
|
||||||
acinclude.m4 | 16 +++
|
acinclude.m4 | 16 +++
|
||||||
configure.ac | 1 +
|
configure.ac | 1 +
|
||||||
plugins/cable.c | 382 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
plugins/cable.c | 382 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
src/adapter.c | 19 +++
|
src/adapter.c | 19 +++
|
||||||
src/adapter.h | 3 +
|
src/adapter.h | 3 +
|
||||||
6 files changed, 428 insertions(+), 2 deletions(-)
|
src/device.c | 37 ++++--
|
||||||
|
src/device.h | 2 +
|
||||||
|
8 files changed, 456 insertions(+), 13 deletions(-)
|
||||||
create mode 100644 plugins/cable.c
|
create mode 100644 plugins/cable.c
|
||||||
|
|
||||||
diff --git a/Makefile.am b/Makefile.am
|
diff --git a/Makefile.am b/Makefile.am
|
||||||
index 53fcbe9..f831a72 100644
|
index 1c214c6..c70ff24 100644
|
||||||
--- a/Makefile.am
|
--- a/Makefile.am
|
||||||
+++ b/Makefile.am
|
+++ b/Makefile.am
|
||||||
@@ -238,6 +238,11 @@ builtin_sources += thermometer/main.c \
|
@@ -238,6 +238,11 @@ builtin_sources += thermometer/main.c \
|
||||||
@ -53,7 +55,7 @@ index 53fcbe9..f831a72 100644
|
|||||||
INCLUDES = -I$(builddir)/lib -I$(builddir)/src -I$(srcdir)/src \
|
INCLUDES = -I$(builddir)/lib -I$(builddir)/src -I$(srcdir)/src \
|
||||||
-I$(srcdir)/audio -I$(srcdir)/sbc -I$(srcdir)/gdbus \
|
-I$(srcdir)/audio -I$(srcdir)/sbc -I$(srcdir)/gdbus \
|
||||||
diff --git a/acinclude.m4 b/acinclude.m4
|
diff --git a/acinclude.m4 b/acinclude.m4
|
||||||
index 6505ad3..3f59989 100644
|
index 1d6d736..ae58bbd 100644
|
||||||
--- a/acinclude.m4
|
--- a/acinclude.m4
|
||||||
+++ b/acinclude.m4
|
+++ b/acinclude.m4
|
||||||
@@ -139,6 +139,12 @@ AC_DEFUN([AC_PATH_UDEV], [
|
@@ -139,6 +139,12 @@ AC_DEFUN([AC_PATH_UDEV], [
|
||||||
@ -106,7 +108,7 @@ index 6505ad3..3f59989 100644
|
|||||||
+ AM_CONDITIONAL(CABLE, test "${cable_enable}" = "yes" && test "${cable_found}" = "yes")
|
+ AM_CONDITIONAL(CABLE, test "${cable_enable}" = "yes" && test "${cable_found}" = "yes")
|
||||||
])
|
])
|
||||||
diff --git a/configure.ac b/configure.ac
|
diff --git a/configure.ac b/configure.ac
|
||||||
index 48b181e..45a4b15 100644
|
index f2db920..8e7ad79 100644
|
||||||
--- a/configure.ac
|
--- a/configure.ac
|
||||||
+++ b/configure.ac
|
+++ b/configure.ac
|
||||||
@@ -46,6 +46,7 @@ AC_PATH_GSTREAMER
|
@@ -46,6 +46,7 @@ AC_PATH_GSTREAMER
|
||||||
@ -119,7 +121,7 @@ index 48b181e..45a4b15 100644
|
|||||||
AC_PATH_CHECK
|
AC_PATH_CHECK
|
||||||
diff --git a/plugins/cable.c b/plugins/cable.c
|
diff --git a/plugins/cable.c b/plugins/cable.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..fe758db
|
index 0000000..89333c4
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/plugins/cable.c
|
+++ b/plugins/cable.c
|
||||||
@@ -0,0 +1,382 @@
|
@@ -0,0 +1,382 @@
|
||||||
@ -212,7 +214,7 @@ index 0000000..fe758db
|
|||||||
+ store_device_id(srcaddr, address, 0xffff, vendor_id, product_id, 0);
|
+ store_device_id(srcaddr, address, 0xffff, vendor_id, product_id, 0);
|
||||||
+ /* Don't write a profile, it will be updated when the device connects */
|
+ /* Don't write a profile, it will be updated when the device connects */
|
||||||
+
|
+
|
||||||
+ write_trust(srcaddr, address, "[all]", TRUE);
|
+ device_set_trust (conn, device, TRUE);
|
||||||
+
|
+
|
||||||
+ return device;
|
+ return device;
|
||||||
+}
|
+}
|
||||||
@ -506,7 +508,7 @@ index 0000000..fe758db
|
|||||||
+BLUETOOTH_PLUGIN_DEFINE(cable, VERSION,
|
+BLUETOOTH_PLUGIN_DEFINE(cable, VERSION,
|
||||||
+ BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, cable_init, cable_exit)
|
+ BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, cable_init, cable_exit)
|
||||||
diff --git a/src/adapter.c b/src/adapter.c
|
diff --git a/src/adapter.c b/src/adapter.c
|
||||||
index 6e04faf..0488891 100644
|
index f922876..b688642 100644
|
||||||
--- a/src/adapter.c
|
--- a/src/adapter.c
|
||||||
+++ b/src/adapter.c
|
+++ b/src/adapter.c
|
||||||
@@ -952,6 +952,25 @@ static struct btd_device *adapter_create_device(DBusConnection *conn,
|
@@ -952,6 +952,25 @@ static struct btd_device *adapter_create_device(DBusConnection *conn,
|
||||||
@ -549,6 +551,81 @@ index b7ea62b..ac0aa2e 100644
|
|||||||
void adapter_mode_changed(struct btd_adapter *adapter, uint8_t scan_mode);
|
void adapter_mode_changed(struct btd_adapter *adapter, uint8_t scan_mode);
|
||||||
int adapter_set_name(struct btd_adapter *adapter, const char *name);
|
int adapter_set_name(struct btd_adapter *adapter, const char *name);
|
||||||
void adapter_name_changed(struct btd_adapter *adapter, const char *name);
|
void adapter_name_changed(struct btd_adapter *adapter, const char *name);
|
||||||
|
diff --git a/src/device.c b/src/device.c
|
||||||
|
index c210bcb..056b450 100644
|
||||||
|
--- a/src/device.c
|
||||||
|
+++ b/src/device.c
|
||||||
|
@@ -471,31 +471,46 @@ static DBusMessage *set_alias(DBusConnection *conn, DBusMessage *msg,
|
||||||
|
return dbus_message_new_method_return(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static DBusMessage *set_trust(DBusConnection *conn, DBusMessage *msg,
|
||||||
|
- gboolean value, void *data)
|
||||||
|
+int device_set_trust (DBusConnection *conn, struct btd_device *device,
|
||||||
|
+ gboolean trusted)
|
||||||
|
{
|
||||||
|
- struct btd_device *device = data;
|
||||||
|
struct btd_adapter *adapter = device->adapter;
|
||||||
|
char srcaddr[18], dstaddr[18];
|
||||||
|
bdaddr_t src;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
- if (device->trusted == value)
|
||||||
|
- return dbus_message_new_method_return(msg);
|
||||||
|
-
|
||||||
|
adapter_get_address(adapter, &src);
|
||||||
|
ba2str(&src, srcaddr);
|
||||||
|
ba2str(&device->bdaddr, dstaddr);
|
||||||
|
|
||||||
|
- err = write_trust(srcaddr, dstaddr, GLOBAL_TRUST, value);
|
||||||
|
+ err = write_trust(srcaddr, dstaddr, GLOBAL_TRUST, trusted);
|
||||||
|
if (err < 0)
|
||||||
|
- return btd_error_failed(msg, strerror(-err));
|
||||||
|
+ return err;
|
||||||
|
|
||||||
|
- device->trusted = value;
|
||||||
|
+ device->trusted = trusted;
|
||||||
|
|
||||||
|
- emit_property_changed(conn, dbus_message_get_path(msg),
|
||||||
|
+ emit_property_changed(conn, device->path,
|
||||||
|
DEVICE_INTERFACE, "Trusted",
|
||||||
|
- DBUS_TYPE_BOOLEAN, &value);
|
||||||
|
+ DBUS_TYPE_BOOLEAN, &trusted);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static DBusMessage *set_trust(DBusConnection *conn, DBusMessage *msg,
|
||||||
|
+ gboolean value, void *data)
|
||||||
|
+{
|
||||||
|
+ struct btd_device *device = data;
|
||||||
|
+ struct btd_adapter *adapter = device->adapter;
|
||||||
|
+ char srcaddr[18], dstaddr[18];
|
||||||
|
+ bdaddr_t src;
|
||||||
|
+ int err;
|
||||||
|
+
|
||||||
|
+ if (device->trusted == value)
|
||||||
|
+ return dbus_message_new_method_return(msg);
|
||||||
|
+
|
||||||
|
+ err = device_set_trust (conn, device, value);
|
||||||
|
+ if (err < 0)
|
||||||
|
+ return btd_error_failed(msg, strerror(-err));
|
||||||
|
|
||||||
|
return dbus_message_new_method_return(msg);
|
||||||
|
}
|
||||||
|
diff --git a/src/device.h b/src/device.h
|
||||||
|
index 26e17f7..0d5e5ce 100644
|
||||||
|
--- a/src/device.h
|
||||||
|
+++ b/src/device.h
|
||||||
|
@@ -119,6 +119,8 @@ void btd_unregister_device_driver(struct btd_device_driver *driver);
|
||||||
|
struct btd_device *btd_device_ref(struct btd_device *device);
|
||||||
|
void btd_device_unref(struct btd_device *device);
|
||||||
|
|
||||||
|
+int device_set_trust(DBusConnection *conn, struct btd_device *device,
|
||||||
|
+ gboolean trusted);
|
||||||
|
int device_block(DBusConnection *conn, struct btd_device *device,
|
||||||
|
gboolean update_only);
|
||||||
|
int device_unblock(DBusConnection *conn, struct btd_device *device,
|
||||||
--
|
--
|
||||||
1.7.10.2
|
1.8.3.1
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Summary: Bluetooth utilities
|
Summary: Bluetooth utilities
|
||||||
Name: bluez
|
Name: bluez
|
||||||
Version: 4.101
|
Version: 4.101
|
||||||
Release: 8%{?dist}
|
Release: 9%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
URL: http://www.bluez.org/
|
URL: http://www.bluez.org/
|
||||||
@ -337,6 +337,9 @@ fi
|
|||||||
%exclude /usr/lib/udev/rules.d/97-bluetooth-hid2hci.rules
|
%exclude /usr/lib/udev/rules.d/97-bluetooth-hid2hci.rules
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jul 23 2013 Bastien Nocera <bnocera@redhat.com> 4.101-9
|
||||||
|
- Fix trust setting in Sixaxis devices
|
||||||
|
|
||||||
* Wed Jun 26 2013 Bastien Nocera <bnocera@redhat.com> 4.101-8
|
* Wed Jun 26 2013 Bastien Nocera <bnocera@redhat.com> 4.101-8
|
||||||
- Another pass at fixing A2DP support (#964031)
|
- Another pass at fixing A2DP support (#964031)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user