Merge lp:~seb128/ubuntu-system-settings/rtm-bluetooth-simple-secure into lp:ubuntu-system-settings/rtm-14.09

Proposed by Sebastien Bacher
Status: Rejected
Rejected by: Sebastien Bacher
Proposed branch: lp:~seb128/ubuntu-system-settings/rtm-bluetooth-simple-secure
Merge into: lp:ubuntu-system-settings/rtm-14.09
Diff against target: 464 lines (+160/-50)
13 files modified
plugins/bluetooth/CMakeLists.txt (+1/-0)
plugins/bluetooth/DisplayPasskeyDialog.qml (+56/-0)
plugins/bluetooth/PageComponent.qml (+25/-1)
plugins/bluetooth/agent.cpp (+50/-12)
plugins/bluetooth/agent.h (+4/-2)
plugins/bluetooth/agent.xml (+1/-1)
plugins/bluetooth/agentadaptor.cpp (+3/-3)
plugins/bluetooth/agentadaptor.h (+6/-6)
plugins/bluetooth/bluetooth.cpp (+8/-16)
plugins/bluetooth/bluetooth.h (+0/-1)
plugins/bluetooth/device.cpp (+5/-0)
plugins/bluetooth/device.h (+1/-0)
tests/plugins/bluetooth/tst_bluetooth.cpp (+0/-8)
To merge this branch: bzr merge lp:~seb128/ubuntu-system-settings/rtm-bluetooth-simple-secure
Reviewer Review Type Date Requested Status
Ken VanDine Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+248712@code.launchpad.net

Commit message

bluetooth: implement simple secure pairing dialog

Description of the change

bluetooth: implement simple secure pairing dialog

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
981. By Michael Zanetti

Enable support for Bluetooth Input devices

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
982. By Mathieu Trudel-Lapierre

Re-enable all device types.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks fine, approving based on testing from the trunk branch.

review: Approve
Revision history for this message
Sebastien Bacher (seb128) wrote :

seems like we are not doing more rtm landing, so cleaning the list a bit, that one is rather going to be including with the vivid rebase

Unmerged revisions

982. By Mathieu Trudel-Lapierre

Re-enable all device types.

981. By Michael Zanetti

Enable support for Bluetooth Input devices

980. By Sebastien Bacher

bluetooth: implement simple secure pairing dialog

979. By CI Train Bot Account

Releasing 0.3+15.04.20150203.1~rtm-0ubuntu1

978. By Ken VanDine

Use device-state from indicator-power to determine charging status. QtSystemsInfo doesn't support UPower 0.99. Fixes: #1416096
Approved by: Jonas G. Drange

977. By Ken VanDine

initialize m_lastFullCharge as NULL

Approved by: Sebastien Bacher, PS Jenkins bot

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/bluetooth/CMakeLists.txt'
2--- plugins/bluetooth/CMakeLists.txt 2013-10-22 14:44:44 +0000
3+++ plugins/bluetooth/CMakeLists.txt 2015-02-05 17:32:38 +0000
4@@ -3,6 +3,7 @@
5 set(QML_SOURCES
6 ProvidePinCodeDialog.qml
7 ConfirmPasskeyDialog.qml
8+DisplayPasskeyDialog.qml
9 ProvidePasskeyDialog.qml
10 PageComponent.qml
11 )
12
13=== added file 'plugins/bluetooth/DisplayPasskeyDialog.qml'
14--- plugins/bluetooth/DisplayPasskeyDialog.qml 1970-01-01 00:00:00 +0000
15+++ plugins/bluetooth/DisplayPasskeyDialog.qml 2015-02-05 17:32:38 +0000
16@@ -0,0 +1,56 @@
17+/*
18+ * This file is part of ubuntu-system-settings
19+ *
20+ * Copyright (C) 2013 Canonical Ltd.
21+ *
22+ * This program is free software: you can redistribute it and/or modify it
23+ * under the terms of the GNU General Public License version 3, as published
24+ * by the Free Software Foundation.
25+ *
26+ * This program is distributed in the hope that it will be useful, but
27+ * WITHOUT ANY WARRANTY; without even the implied warranties of
28+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
29+ * PURPOSE. See the GNU General Public License for more details.
30+ *
31+ * You should have received a copy of the GNU General Public License along
32+ * with this program. If not, see <http://www.gnu.org/licenses/>.
33+ */
34+
35+
36+import QtQuick 2.0
37+import Ubuntu.Components 0.1
38+import Ubuntu.Components.Popups 0.1
39+
40+Dialog {
41+ id: root
42+ title: i18n.tr("Bluetooth Pairing Request")
43+
44+ property string name: "Unknown"
45+ property string passkey: "000000"
46+ property string entered: "0"
47+
48+ signal canceled
49+
50+ // TRANSLATORS: %1 is the name of the bluetooth device being paired
51+ text: i18n.tr("Please enter the following PIN on %1 and press “Enter” on the keyboard:").arg(root.name)
52+
53+ Label {
54+ /* display the number of chars that remain to be typed */
55+ text: root.passkey.slice(entered)+"⏎"
56+ fontSize: "x-large"
57+ verticalAlignment: Text.AlignVCenter
58+ horizontalAlignment: Text.AlignHCenter
59+ }
60+
61+ Row {
62+ spacing: units.gu(1)
63+ Button {
64+ text: i18n.tr("Cancel")
65+ onClicked: {
66+ root.canceled()
67+ PopupUtils.close(root)
68+ }
69+ width: (parent.width - parent.spacing)
70+ }
71+ }
72+}
73
74=== modified file 'plugins/bluetooth/PageComponent.qml'
75--- plugins/bluetooth/PageComponent.qml 2014-11-18 19:37:24 +0000
76+++ plugins/bluetooth/PageComponent.qml 2015-02-05 17:32:38 +0000
77@@ -31,6 +31,8 @@
78 id: root
79 title: i18n.tr("Bluetooth")
80
81+ property var dialogPopupId
82+
83 UbuntuBluetoothPanel { id: backend }
84
85 Component {
86@@ -48,6 +50,11 @@
87 ProvidePinCodeDialog { }
88 }
89
90+ Component {
91+ id: displayPasskeyDialog
92+ DisplayPasskeyDialog { }
93+ }
94+
95 Connections {
96 target: backend.agent
97 onPasskeyConfirmationNeeded: {
98@@ -68,6 +75,24 @@
99 popup.canceled.connect(function() {target.providePinCode(request_tag, false, "")})
100 popup.provided.connect(function(pinCode) {target.providePinCode(request_tag, true, pinCode)})
101 }
102+ onDisplayPasskeyNeeded: {
103+ if (!root.dialogPopupId)
104+ {
105+ var request_tag = tag
106+ root.dialogPopupId = PopupUtils.open(displayPasskeyDialog, root, {passkey: passkey, name: device.name,
107+ entered: entered})
108+ root.dialogPopupId.canceled.connect(function() {root.dialogPopupId = null;
109+ target.displayPasskeyCallback(request_tag)})
110+ }
111+ else
112+ {
113+ root.dialogPopupId.entered = entered
114+ }
115+ }
116+ onPairingDone: {
117+ if (root.dialogPopupId)
118+ PopupUtils.close(root.dialogPopupId)
119+ }
120 }
121
122 function getDisplayName(type, displayName) {
123@@ -265,7 +290,6 @@
124 iconSource: iconPath
125 iconFrame: false
126 text: getDisplayName(type, displayName)
127- enabled: backend.isSupportedType(type)
128 onClicked: {
129 backend.setSelectedDevice(addressName);
130 pageStack.push(connectedDevicePage);
131
132=== modified file 'plugins/bluetooth/agent.cpp'
133--- plugins/bluetooth/agent.cpp 2014-07-23 13:37:06 +0000
134+++ plugins/bluetooth/agent.cpp 2015-02-05 17:32:38 +0000
135@@ -22,7 +22,6 @@
136
137 #include <cassert>
138
139-
140 /***
141 ****
142 ***/
143@@ -54,7 +53,7 @@
144 */
145 void Agent::Release()
146 {
147- Q_EMIT(onPairingDone());
148+ Q_EMIT(pairingDone());
149 }
150
151 /***
152@@ -219,20 +218,59 @@
153 }
154 }
155
156-/***
157-****
158-***/
159+/** This method gets called when the service daemon
160+ * needs to display a passkey for an authentication.
161+ * The entered parameter indicates the number of already
162+ * typed keys on the remote side.
163+ * An empty reply should be returned. When the passkey
164+ * needs no longer to be displayed, the Cancel method
165+ * of the agent will be called.
166+ * During the pairing process this method might be
167+ * called multiple times to update the entered value.
168+ * Note that the passkey will always be a 6-digit number,
169+ * so the display should be zero-padded at the start if
170+ * the value contains less than 6 digits.
171+ */
172
173-void Agent::DisplayPasskey(const QDBusObjectPath &objectPath, uint passkey, uchar entered)
174+void Agent::DisplayPasskey(const QDBusObjectPath &objectPath, uint passkey, ushort entered)
175 {
176- Q_UNUSED(objectPath);
177- Q_UNUSED(passkey);
178- Q_UNUSED(entered);
179-
180- // unimplemented -- unneeded for headsets
181+ auto device = m_devices.getDeviceFromPath(objectPath.path());
182+ if (device) {
183+ const uint tag = m_tag++;
184+
185+ setDelayedReply(true);
186+ assert(!m_delayedReplies.contains(tag));
187+ m_delayedReplies[tag] = message();
188+
189+ QString passkeyStr = QString("%1").arg(passkey, 6, 10, QChar('0'));
190+ Q_EMIT(displayPasskeyNeeded(tag, device.data(), passkeyStr, entered));
191+ } else { // confirmation requested for an unknown device..?!
192+ reject(message(), __func__);
193+ }
194 }
195
196+/**
197+ * This method gets called to indicate that the agent
198+ * request failed before a reply was returned.
199+ */
200 void Agent::Cancel()
201 {
202- // unimplemented -- companion function for DisplayPasskey
203+ qWarning() << "Cancel callback called";
204+}
205+
206+/**
207+ * Invoked by the user-facing code after it prompts the user to cancel
208+ * the passkey passed from an Agent::displayPasskeyNeeded signal.
209+ *
210+ * @param tag: the tag from the Agent::displayPasskeyNeeded signal
211+ */
212+void Agent::displayPasskeyCallback(uint tag)
213+{
214+ if (m_delayedReplies.contains(tag)) {
215+ QDBusMessage message = m_delayedReplies[tag];
216+
217+ cancel(message, __func__);
218+
219+ m_delayedReplies.remove(tag);
220+ }
221 }
222
223=== modified file 'plugins/bluetooth/agent.h'
224--- plugins/bluetooth/agent.h 2014-08-20 12:50:09 +0000
225+++ plugins/bluetooth/agent.h 2015-02-05 17:32:38 +0000
226@@ -41,10 +41,11 @@
227 Q_INVOKABLE void confirmPasskey(uint tag, bool confirmed);
228 Q_INVOKABLE void providePasskey(uint tag, bool provided, uint passkey);
229 Q_INVOKABLE void providePinCode(uint tag, bool provided, QString pinCode);
230+ Q_INVOKABLE void displayPasskeyCallback(uint tag);
231
232 public Q_SLOTS: // received from the system's bluez service
233 void Cancel();
234- void DisplayPasskey(const QDBusObjectPath &path, uint passkey, uchar entered);
235+ void DisplayPasskey(const QDBusObjectPath &path, uint passkey, ushort entered);
236 void Release();
237 void RequestConfirmation(const QDBusObjectPath &path, uint passkey);
238 uint RequestPasskey(const QDBusObjectPath &path);
239@@ -54,7 +55,8 @@
240 void pinCodeNeeded(int tag, Device* device);
241 void passkeyNeeded(int tag, Device* device);
242 void passkeyConfirmationNeeded(int tag, Device* device, QString passkey);
243- void onPairingDone();
244+ void displayPasskeyNeeded(int tag, Device* device, QString passkey, ushort entered);
245+ void pairingDone();
246
247 private:
248 Q_DISABLE_COPY(Agent)
249
250=== modified file 'plugins/bluetooth/agent.xml'
251--- plugins/bluetooth/agent.xml 2013-09-23 02:50:33 +0000
252+++ plugins/bluetooth/agent.xml 2015-02-05 17:32:38 +0000
253@@ -18,7 +18,7 @@
254 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
255 <arg type="o" name="device"/>
256 <arg type="u" name="passkey"/>
257- <arg type="y" name="entered"/>
258+ <arg type="q" name="entered"/>
259 </method>
260
261 <method name="RequestConfirmation">
262
263=== modified file 'plugins/bluetooth/agentadaptor.cpp'
264--- plugins/bluetooth/agentadaptor.cpp 2013-09-23 02:50:33 +0000
265+++ plugins/bluetooth/agentadaptor.cpp 2015-02-05 17:32:38 +0000
266@@ -2,7 +2,7 @@
267 * This file was generated by qdbusxml2cpp version 0.8
268 * Command line was: qdbusxml2cpp agent.xml -a agentadaptor
269 *
270- * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
271+ * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
272 *
273 * This is an auto-generated file.
274 * Do not edit! All changes made to it will be lost.
275@@ -39,10 +39,10 @@
276 QMetaObject::invokeMethod(parent(), "Cancel");
277 }
278
279-void AgentAdaptor::DisplayPasskey(const QDBusObjectPath &device, uint passkey, uchar entered)
280+void AgentAdaptor::DisplayPasskey(const QDBusObjectPath &device, uint passkey, ushort entered)
281 {
282 // handle method call org.bluez.Agent.DisplayPasskey
283- QMetaObject::invokeMethod(parent(), "DisplayPasskey", Q_ARG(QDBusObjectPath, device), Q_ARG(uint, passkey), Q_ARG(uchar, entered));
284+ QMetaObject::invokeMethod(parent(), "DisplayPasskey", Q_ARG(QDBusObjectPath, device), Q_ARG(uint, passkey), Q_ARG(ushort, entered));
285 }
286
287 void AgentAdaptor::Release()
288
289=== modified file 'plugins/bluetooth/agentadaptor.h'
290--- plugins/bluetooth/agentadaptor.h 2014-07-23 13:37:06 +0000
291+++ plugins/bluetooth/agentadaptor.h 2015-02-05 17:32:38 +0000
292@@ -2,15 +2,15 @@
293 * This file was generated by qdbusxml2cpp version 0.8
294 * Command line was: qdbusxml2cpp agent.xml -a agentadaptor
295 *
296- * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
297+ * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
298 *
299 * This is an auto-generated file.
300 * This file may have been hand-edited. Look for HAND-EDIT comments
301 * before re-generating it.
302 */
303
304-#ifndef AGENTADAPTOR_H_1379893589
305-#define AGENTADAPTOR_H_1379893589
306+#ifndef AGENTADAPTOR_H_1423046874
307+#define AGENTADAPTOR_H_1423046874
308
309 #include <QtCore/QObject>
310 #include <QtDBus/QtDBus>
311@@ -46,7 +46,7 @@
312 " <annotation value=\"\" name=\"org.freedesktop.DBus.GLib.Async\"/>\n"
313 " <arg type=\"o\" name=\"device\"/>\n"
314 " <arg type=\"u\" name=\"passkey\"/>\n"
315-" <arg type=\"y\" name=\"entered\"/>\n"
316+" <arg type=\"q\" name=\"entered\"/>\n"
317 " </method>\n"
318 " <method name=\"RequestConfirmation\">\n"
319 " <annotation value=\"\" name=\"org.freedesktop.DBus.GLib.Async\"/>\n"
320@@ -62,13 +62,13 @@
321 " </interface>\n"
322 "")
323 public:
324- explicit AgentAdaptor(QObject *parent);
325+ AgentAdaptor(QObject *parent);
326 virtual ~AgentAdaptor();
327
328 public: // PROPERTIES
329 public Q_SLOTS: // METHODS
330 void Cancel();
331- void DisplayPasskey(const QDBusObjectPath &device, uint passkey, uchar entered);
332+ void DisplayPasskey(const QDBusObjectPath &device, uint passkey, ushort entered);
333 void Release();
334 void RequestConfirmation(const QDBusObjectPath &device, uint passkey);
335 uint RequestPasskey(const QDBusObjectPath &device);
336
337=== modified file 'plugins/bluetooth/bluetooth.cpp'
338--- plugins/bluetooth/bluetooth.cpp 2014-09-24 17:09:48 +0000
339+++ plugins/bluetooth/bluetooth.cpp 2015-02-05 17:32:38 +0000
340@@ -88,22 +88,6 @@
341 m_devices.stopDiscovery();
342 }
343
344-bool Bluetooth::isSupportedType(const int type)
345-{
346- switch((Device::Type)type) {
347-
348- case Device::Type::Headset:
349- case Device::Type::Headphones:
350- case Device::Type::Speakers:
351- case Device::Type::Carkit:
352- case Device::Type::OtherAudio:
353- return true;
354-
355- default:
356- return false;
357- }
358-}
359-
360 /***
361 ****
362 ***/
363@@ -164,6 +148,10 @@
364 case Device::Type::Carkit:
365 m_selectedDevice->disconnect(Device::ConnectionMode::Audio);
366 break;
367+ case Device::Type::Keyboard:
368+ case Device::Type::Mouse:
369+ m_selectedDevice->disconnect(Device::ConnectionMode::Input);
370+ break;
371 default:
372 qWarning() << "Nothing to disconnect: Unsupported device type.";
373 break;
374@@ -193,6 +181,10 @@
375 case Device::Type::Carkit:
376 connMode = Device::ConnectionMode::Audio;
377 break;
378+ case Device::Type::Keyboard:
379+ case Device::Type::Mouse:
380+ connMode = Device::ConnectionMode::Input;
381+ break;
382 default:
383 qWarning() << "Nothing to connect: Unsupported device type.";
384 return;
385
386=== modified file 'plugins/bluetooth/bluetooth.h'
387--- plugins/bluetooth/bluetooth.h 2014-08-28 07:22:28 +0000
388+++ plugins/bluetooth/bluetooth.h 2015-02-05 17:32:38 +0000
389@@ -81,7 +81,6 @@
390 Q_INVOKABLE void toggleDiscovery();
391 Q_INVOKABLE void startDiscovery();
392 Q_INVOKABLE void stopDiscovery();
393- Q_INVOKABLE static bool isSupportedType(const int type);
394
395 public:
396 Agent * getAgent();
397
398=== modified file 'plugins/bluetooth/device.cpp'
399--- plugins/bluetooth/device.cpp 2014-08-28 07:22:28 +0000
400+++ plugins/bluetooth/device.cpp 2015-02-05 17:32:38 +0000
401@@ -59,6 +59,7 @@
402 initInterface(m_audioSourceInterface, path, "org.bluez.AudioSource", bus);
403 initInterface(m_audioSinkInterface, path, "org.bluez.AudioSink", bus);
404 initInterface(m_headsetInterface, path, "org.bluez.Headset", bus);
405+ initInterface(m_inputInterface, path, "org.bluez.Input", bus);
406
407 Q_EMIT(pathChanged());
408 }
409@@ -190,6 +191,8 @@
410 interface = m_headsetInterface;
411 else if (m_audioInterface && (mode == Audio))
412 interface = m_audioInterface;
413+ else if (m_inputInterface && (mode == Input))
414+ interface = m_inputInterface;
415 else {
416 qWarning() << "Unhandled connection mode" << mode;
417 return;
418@@ -206,6 +209,8 @@
419 interface = m_headsetInterface;
420 else if (m_audioInterface && (mode == Audio))
421 interface = m_audioInterface;
422+ else if (m_inputInterface && (mode == Input))
423+ interface = m_inputInterface;
424 else {
425 qWarning() << "Unhandled connection mode" << mode;
426 return;
427
428=== modified file 'plugins/bluetooth/device.h'
429--- plugins/bluetooth/device.h 2014-08-11 09:32:31 +0000
430+++ plugins/bluetooth/device.h 2015-02-05 17:32:38 +0000
431@@ -125,6 +125,7 @@
432 QSharedPointer<QDBusInterface> m_audioSourceInterface;
433 QSharedPointer<QDBusInterface> m_audioSinkInterface;
434 QSharedPointer<QDBusInterface> m_headsetInterface;
435+ QSharedPointer<QDBusInterface> m_inputInterface;
436 QList<ConnectionMode> m_connectAfterPairing;
437
438 protected:
439
440=== modified file 'tests/plugins/bluetooth/tst_bluetooth.cpp'
441--- tests/plugins/bluetooth/tst_bluetooth.cpp 2014-08-20 12:50:09 +0000
442+++ tests/plugins/bluetooth/tst_bluetooth.cpp 2015-02-05 17:32:38 +0000
443@@ -42,7 +42,6 @@
444 void testStartDiscovery();
445 void testStopDiscovery();
446 void testToggleDiscovery();
447- void testIsSupportedType();
448 void testIsDiscovering();
449 void cleanup();
450
451@@ -142,13 +141,6 @@
452 QCOMPARE(result.toBool(), false);
453 }
454
455-void BluetoothTest::testIsSupportedType()
456-{
457- QCOMPARE(Bluetooth::isSupportedType(Device::Type::Headset), true);
458- QCOMPARE(Bluetooth::isSupportedType(Device::Type::Mouse), false);
459- QCOMPARE(Bluetooth::isSupportedType(Device::Type::Tablet), false);
460-}
461-
462 void BluetoothTest::testIsDiscovering()
463 {
464 m_bluetooth->stopDiscovery();

Subscribers

People subscribed via source and target branches