Merge lp:~cyphermox/ubuntu-system-settings/agent-rework into lp:ubuntu-system-settings

Proposed by Sebastien Bacher
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 1337
Merged at revision: 1336
Proposed branch: lp:~cyphermox/ubuntu-system-settings/agent-rework
Merge into: lp:ubuntu-system-settings
Diff against target: 103 lines (+28/-6)
5 files modified
debian/changelog (+7/-0)
plugins/bluetooth/bluetooth.cpp (+3/-3)
plugins/bluetooth/dbus-shared.h (+1/-0)
plugins/bluetooth/devicemodel.cpp (+16/-2)
plugins/bluetooth/devicemodel.h (+1/-1)
To merge this branch: bzr merge lp:~cyphermox/ubuntu-system-settings/agent-rework
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Manuel de la Peña Pending
Ken VanDine Pending
Review via email: mp+250889@code.launchpad.net

Commit message

register an agent on the adapter as well, that's needed for pairing initiated by the other side (in which case no device is selected in the settings which means not device agent is created)

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

urg, sorry Mathieu, I tried to rebase on trunk and by mistake wiped out the previous version with the earlier review comments... going to test the CI build on that one when it shows up and comment back today though

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

Works great, tested on a bluetooth audio receiver (that requires no input), a displaypasskey keyboard and a car with pin confirmation, they all work without issue!

review: Approve
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Works great.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-02-23 19:58:56 +0000
3+++ debian/changelog 2015-02-25 08:41:15 +0000
4@@ -1,3 +1,10 @@
5+ubuntu-system-settings (0.3+15.04.20150223-0ubuntu2) UNRELEASED; urgency=medium
6+
7+ * Make an adapter-wide agent available for pairing requests initiated from
8+ a remote device. (LP: #1366061)
9+
10+ -- Mathieu Trudel-Lapierre <mathieu-tl@ubuntu.com> Tue, 24 Feb 2015 13:39:09 -0500
11+
12 ubuntu-system-settings (0.3+15.04.20150223-0ubuntu1) vivid; urgency=medium
13
14 [ Leo Arias ]
15
16=== modified file 'plugins/bluetooth/bluetooth.cpp'
17--- plugins/bluetooth/bluetooth.cpp 2015-02-10 11:19:53 +0000
18+++ plugins/bluetooth/bluetooth.cpp 2015-02-25 08:41:15 +0000
19@@ -39,8 +39,8 @@
20 {
21 // export our Agent to handle pairing requests
22 new AgentAdaptor(&m_agent);
23- if(!m_dbus.registerObject(DBUS_AGENT_PATH, &m_agent))
24- qCritical() << "Couldn't register agent at" << DBUS_AGENT_PATH;
25+ if(!m_dbus.registerObject(DBUS_ADAPTER_AGENT_PATH, &m_agent))
26+ qCritical() << "Couldn't register agent at" << DBUS_ADAPTER_AGENT_PATH;
27
28 m_connectedDevices.filterOnConnections(Device::Connection::Connected |
29 Device::Connection::Connecting |
30@@ -212,7 +212,7 @@
31 device->connect(connMode);
32 } else {
33 m_devices.addConnectAfterPairing(address, connMode);
34- m_devices.createDevice(address);
35+ m_devices.createDevice(address, &m_agent);
36 }
37 }
38
39
40=== modified file 'plugins/bluetooth/dbus-shared.h'
41--- plugins/bluetooth/dbus-shared.h 2013-09-23 02:55:58 +0000
42+++ plugins/bluetooth/dbus-shared.h 2015-02-25 08:41:15 +0000
43@@ -21,6 +21,7 @@
44 #define USS_DBUS_SHARED_H
45
46 #define DBUS_AGENT_PATH "/com/canonical/SettingsBluetoothAgent"
47+#define DBUS_ADAPTER_AGENT_PATH "/com/canonical/SettingsBluetoothAgent/adapteragent"
48 #define DBUS_AGENT_CAPABILITY "DisplayYesNo"
49
50 #endif // USS_DBUS_SHARED_H
51
52=== modified file 'plugins/bluetooth/devicemodel.cpp'
53--- plugins/bluetooth/devicemodel.cpp 2015-02-18 15:13:40 +0000
54+++ plugins/bluetooth/devicemodel.cpp 2015-02-25 08:41:15 +0000
55@@ -194,6 +194,12 @@
56 connect(&m_discoverableTimer, SIGNAL(timeout()), this, SLOT(slotEnableDiscoverable()));
57 m_discoverableTimer.start(1000);
58
59+ // With the agent registered on the bus, make it known by the adapter
60+ QDBusReply<void > reply = m_bluezAdapter->call("RegisterAgent",
61+ qVariantFromValue(QDBusObjectPath(DBUS_ADAPTER_AGENT_PATH)),
62+ QString(DBUS_AGENT_CAPABILITY));
63+ if (!reply.isValid())
64+ qWarning() << "Error registering agent for the default adapter:" << reply.error();
65 }
66 }
67
68@@ -462,12 +468,20 @@
69 call->deleteLater();
70 }
71
72-void DeviceModel::createDevice (const QString &address)
73+void DeviceModel::createDevice (const QString &address, QObject *agent)
74 {
75 if (m_bluezAdapter) {
76+ QString agent_path(DBUS_AGENT_PATH);
77+ agent_path.append("/");
78+ agent_path.append(address);
79+ agent_path.replace(":", "_");
80+
81+ if(!m_dbus.registerObject(agent_path, agent))
82+ qCritical() << "Couldn't register agent at" << agent_path;
83+
84 QDBusPendingCall pcall = m_bluezAdapter->asyncCall("CreatePairedDevice",
85 address,
86- qVariantFromValue(QDBusObjectPath(DBUS_AGENT_PATH)),
87+ qVariantFromValue(QDBusObjectPath(agent_path)),
88 QString(DBUS_AGENT_CAPABILITY));
89
90 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this);
91
92=== modified file 'plugins/bluetooth/devicemodel.h'
93--- plugins/bluetooth/devicemodel.h 2014-08-11 09:18:12 +0000
94+++ plugins/bluetooth/devicemodel.h 2015-02-25 08:41:15 +0000
95@@ -69,7 +69,7 @@
96 bool isDiscovering() const { return m_isDiscovering; }
97 bool isDiscoverable() const { return m_isDiscoverable; }
98 void addConnectAfterPairing(const QString &address, Device::ConnectionMode mode);
99- void createDevice(const QString &address);
100+ void createDevice(const QString &address, QObject *agent);
101 void removeDevice(const QString &path);
102 void stopDiscovery();
103 void startDiscovery();

Subscribers

People subscribed via source and target branches