Merge lp:~rsalveti/ubuntu-system-settings/agent-rework-rtm into lp:ubuntu-system-settings/rtm-14.09

Proposed by Ricardo Salveti
Status: Merged
Approved by: Bill Filler
Approved revision: 998
Merged at revision: 998
Proposed branch: lp:~rsalveti/ubuntu-system-settings/agent-rework-rtm
Merge into: lp:ubuntu-system-settings/rtm-14.09
Diff against target: 88 lines (+21/-6)
4 files modified
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:~rsalveti/ubuntu-system-settings/agent-rework-rtm
Reviewer Review Type Date Requested Status
Michał Sawicz (community) functional Approve
PS Jenkins bot continuous-integration Approve
Ubuntu Touch System Settings Pending
Review via email: mp+251209@code.launchpad.net

Commit message

Make an adapter-wide agent available for pairing requests initiated from a remote device. (LP: #1366061)

Description of the change

Make an adapter-wide agent available for pairing requests initiated from a remote device. (LP: #1366061)

Backport of: https://code.launchpad.net/~mathieu-tl/ubuntu-system-settings/agent-rework/+merge/250889

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

I can confirm the built packages in silo 14 finally let me use my car's HFP \o/

It did not connect straight away after pairing, but subsequent connections worked fine.

review: Approve (functional)

Preview Diff

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

Subscribers

People subscribed via source and target branches