Merge lp:~cyphermox/ubuntu-system-settings/discoverability-annd-fixes into lp:ubuntu-system-settings
- discoverability-annd-fixes
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Charles Kerr |
Approved revision: | 750 |
Merged at revision: | 744 |
Proposed branch: | lp:~cyphermox/ubuntu-system-settings/discoverability-annd-fixes |
Merge into: | lp:ubuntu-system-settings |
Diff against target: |
452 lines (+201/-6) 7 files modified
plugins/bluetooth/PageComponent.qml (+45/-1) plugins/bluetooth/bluetooth.cpp (+20/-2) plugins/bluetooth/bluetooth.h (+10/-0) plugins/bluetooth/device.cpp (+25/-0) plugins/bluetooth/device.h (+9/-0) plugins/bluetooth/devicemodel.cpp (+74/-0) plugins/bluetooth/devicemodel.h (+18/-3) |
To merge this branch: | bzr merge lp:~cyphermox/ubuntu-system-settings/discoverability-annd-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Charles Kerr (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+223955@code.launchpad.net |
Commit message
Implement discoverability and some bluetooth fixes:
- Discoverability: make the system visible to other bluetooth devices
- Trusted: when successfully paired and connected, mark device as Trusted so it can automatically connect again.
- Connect the Audio interface for all audio devices, including Headsets. Some bluetooth audio devices that don't contain a microphone still show up as Headsets, and won't connect successfully otherwise. This will still work for standard headsets, since Audio connects all audio interfaces.
- Stop discovery when a device is selected for connection, and it sometimes causes connection attempts to fail.
Description of the change
Implement discoverability and some bluetooth fixes:
- Discoverability: make the system visible to other bluetooth devices
- Trusted: when successfully paired and connected, mark device as Trusted so it can automatically connect again.
- Connect the Audio interface for all audio devices, including Headsets. Some bluetooth audio devices that don't contain a microphone still show up as Headsets, and won't connect successfully otherwise. This will still work for standard headsets, since Audio connects all audio interfaces.
- Stop discovery when a device is selected for connection, and it sometimes causes connection attempts to fail.
PS Jenkins bot (ps-jenkins) wrote : | # |
Charles Kerr (charlesk) wrote : | # |
There are a couple of things I'd like to see fixed here, but they're small.
Overall, looks very good! Nice work.
Charles Kerr (charlesk) wrote : | # |
There are a couple of things I'd like to see fixed here, but they're small.
Overall, looks very good! Nice work.
- 748. By Mathieu Trudel-Lapierre
-
Remove qWarning's used as debug.
- 749. By Mathieu Trudel-Lapierre
-
Keep the discoverability timer as a private member, so it can be explicitly stopped.
- 750. By Mathieu Trudel-Lapierre
-
Follow proper convention for returning adapterName; make it const too.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:750
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Charles Kerr (charlesk) : | # |
Preview Diff
1 | === modified file 'plugins/bluetooth/PageComponent.qml' | |||
2 | --- plugins/bluetooth/PageComponent.qml 2014-06-09 15:12:34 +0000 | |||
3 | +++ plugins/bluetooth/PageComponent.qml 2014-06-20 22:19:44 +0000 | |||
4 | @@ -142,8 +142,51 @@ | |||
5 | 142 | value: bluetoothActionGroup.enabled.state | 142 | value: bluetoothActionGroup.enabled.state |
6 | 143 | } | 143 | } |
7 | 144 | 144 | ||
8 | 145 | // Discoverability | ||
9 | 146 | ListItem.Subtitled { | ||
10 | 147 | enabled: bluetoothActionGroup.enabled | ||
11 | 148 | |||
12 | 149 | Rectangle { | ||
13 | 150 | color: "transparent" | ||
14 | 151 | anchors.fill: parent | ||
15 | 152 | anchors.topMargin: units.gu(1) | ||
16 | 153 | |||
17 | 154 | Label { | ||
18 | 155 | anchors { | ||
19 | 156 | top: parent.top | ||
20 | 157 | left: parent.left | ||
21 | 158 | topMargin: units.gu(1) | ||
22 | 159 | } | ||
23 | 160 | height: units.gu(3) | ||
24 | 161 | text: backend.discoverable ? i18n.tr("Discoverable") : i18n.tr("Not discoverable") | ||
25 | 162 | } | ||
26 | 163 | |||
27 | 164 | Label { | ||
28 | 165 | anchors { | ||
29 | 166 | top: parent.top | ||
30 | 167 | right: parent.right | ||
31 | 168 | topMargin: units.gu(1) | ||
32 | 169 | } | ||
33 | 170 | height: units.gu(3) | ||
34 | 171 | text: backend.discoverable ? backend.adapterName() : "" | ||
35 | 172 | color: "darkgrey" | ||
36 | 173 | visible: backend.discoverable | ||
37 | 174 | enabled: false | ||
38 | 175 | } | ||
39 | 176 | |||
40 | 177 | ActivityIndicator { | ||
41 | 178 | anchors { | ||
42 | 179 | top: parent.top | ||
43 | 180 | right: parent.right | ||
44 | 181 | topMargin: units.gu(1) | ||
45 | 182 | } | ||
46 | 183 | visible: !backend.discoverable | ||
47 | 184 | running: !backend.discoverable | ||
48 | 185 | } | ||
49 | 186 | } | ||
50 | 187 | } | ||
51 | 188 | |||
52 | 145 | // Connnected Headset(s) | 189 | // Connnected Headset(s) |
53 | 146 | |||
54 | 147 | ListItem.Standard { | 190 | ListItem.Standard { |
55 | 148 | id: connectedHeader | 191 | id: connectedHeader |
56 | 149 | text: i18n.tr("Connected devices:") | 192 | text: i18n.tr("Connected devices:") |
57 | @@ -194,6 +237,7 @@ | |||
58 | 194 | iconName: iconName | 237 | iconName: iconName |
59 | 195 | text: getDisplayName(connection, displayName) | 238 | text: getDisplayName(connection, displayName) |
60 | 196 | onClicked: { | 239 | onClicked: { |
61 | 240 | backend.stopDiscovery(); | ||
62 | 197 | backend.connectDevice(addressName); | 241 | backend.connectDevice(addressName); |
63 | 198 | } | 242 | } |
64 | 199 | } | 243 | } |
65 | 200 | 244 | ||
66 | === modified file 'plugins/bluetooth/bluetooth.cpp' | |||
67 | --- plugins/bluetooth/bluetooth.cpp 2014-06-09 15:12:34 +0000 | |||
68 | +++ plugins/bluetooth/bluetooth.cpp 2014-06-20 22:19:44 +0000 | |||
69 | @@ -53,6 +53,9 @@ | |||
70 | 53 | QObject::connect(&m_devices, SIGNAL(discoveringChanged(bool)), | 53 | QObject::connect(&m_devices, SIGNAL(discoveringChanged(bool)), |
71 | 54 | this, SIGNAL(discoveringChanged(bool))); | 54 | this, SIGNAL(discoveringChanged(bool))); |
72 | 55 | 55 | ||
73 | 56 | QObject::connect(&m_devices, SIGNAL(discoverableChanged(bool)), | ||
74 | 57 | this, SIGNAL(discoverableChanged(bool))); | ||
75 | 58 | |||
76 | 56 | QObject::connect(&m_agent, SIGNAL(onPairingDone()), | 59 | QObject::connect(&m_agent, SIGNAL(onPairingDone()), |
77 | 57 | this, SLOT(onPairingDone())); | 60 | this, SLOT(onPairingDone())); |
78 | 58 | } | 61 | } |
79 | @@ -65,6 +68,21 @@ | |||
80 | 65 | } | 68 | } |
81 | 66 | } | 69 | } |
82 | 67 | 70 | ||
83 | 71 | void Bluetooth::toggleDiscovery() | ||
84 | 72 | { | ||
85 | 73 | m_devices.toggleDiscovery(); | ||
86 | 74 | } | ||
87 | 75 | |||
88 | 76 | void Bluetooth::startDiscovery() | ||
89 | 77 | { | ||
90 | 78 | m_devices.startDiscovery(); | ||
91 | 79 | } | ||
92 | 80 | |||
93 | 81 | void Bluetooth::stopDiscovery() | ||
94 | 82 | { | ||
95 | 83 | m_devices.stopDiscovery(); | ||
96 | 84 | } | ||
97 | 85 | |||
98 | 68 | /*** | 86 | /*** |
99 | 69 | **** | 87 | **** |
100 | 70 | ***/ | 88 | ***/ |
101 | @@ -113,7 +131,7 @@ | |||
102 | 113 | if (m_selectedDevice) | 131 | if (m_selectedDevice) |
103 | 114 | type = m_selectedDevice->getType(); | 132 | type = m_selectedDevice->getType(); |
104 | 115 | if (type == Device::Type::Headset) | 133 | if (type == Device::Type::Headset) |
106 | 116 | m_selectedDevice->disconnect(Device::ConnectionMode::HeadsetMode); | 134 | m_selectedDevice->disconnect(Device::ConnectionMode::Audio); |
107 | 117 | else if (type == Device::Type::Headphones) | 135 | else if (type == Device::Type::Headphones) |
108 | 118 | m_selectedDevice->disconnect(Device::ConnectionMode::Audio); | 136 | m_selectedDevice->disconnect(Device::ConnectionMode::Audio); |
109 | 119 | else if (type == Device::Type::OtherAudio) | 137 | else if (type == Device::Type::OtherAudio) |
110 | @@ -131,7 +149,7 @@ | |||
111 | 131 | 149 | ||
112 | 132 | type = device->getType(); | 150 | type = device->getType(); |
113 | 133 | if (type == Device::Type::Headset) | 151 | if (type == Device::Type::Headset) |
115 | 134 | connMode = Device::ConnectionMode::HeadsetMode; | 152 | connMode = Device::ConnectionMode::Audio; |
116 | 135 | else if (type == Device::Type::Headphones) | 153 | else if (type == Device::Type::Headphones) |
117 | 136 | connMode = Device::ConnectionMode::Audio; | 154 | connMode = Device::ConnectionMode::Audio; |
118 | 137 | else if (type == Device::Type::OtherAudio) | 155 | else if (type == Device::Type::OtherAudio) |
119 | 138 | 156 | ||
120 | === modified file 'plugins/bluetooth/bluetooth.h' | |||
121 | --- plugins/bluetooth/bluetooth.h 2014-05-30 06:53:11 +0000 | |||
122 | +++ plugins/bluetooth/bluetooth.h 2014-06-20 22:19:44 +0000 | |||
123 | @@ -50,9 +50,14 @@ | |||
124 | 50 | READ isDiscovering | 50 | READ isDiscovering |
125 | 51 | NOTIFY discoveringChanged); | 51 | NOTIFY discoveringChanged); |
126 | 52 | 52 | ||
127 | 53 | Q_PROPERTY (bool discoverable | ||
128 | 54 | READ isDiscoverable | ||
129 | 55 | NOTIFY discoverableChanged); | ||
130 | 56 | |||
131 | 53 | Q_SIGNALS: | 57 | Q_SIGNALS: |
132 | 54 | void selectedDeviceChanged(); | 58 | void selectedDeviceChanged(); |
133 | 55 | void discoveringChanged(bool isActive); | 59 | void discoveringChanged(bool isActive); |
134 | 60 | void discoverableChanged(bool isActive); | ||
135 | 56 | 61 | ||
136 | 57 | private Q_SLOTS: | 62 | private Q_SLOTS: |
137 | 58 | void onPairingDone(); | 63 | void onPairingDone(); |
138 | @@ -61,9 +66,13 @@ | |||
139 | 61 | Bluetooth(QObject *parent = 0); | 66 | Bluetooth(QObject *parent = 0); |
140 | 62 | ~Bluetooth() {} | 67 | ~Bluetooth() {} |
141 | 63 | 68 | ||
142 | 69 | Q_INVOKABLE QString adapterName() const { return m_devices.adapterName(); } | ||
143 | 64 | Q_INVOKABLE void setSelectedDevice(const QString &address); | 70 | Q_INVOKABLE void setSelectedDevice(const QString &address); |
144 | 65 | Q_INVOKABLE void connectDevice(const QString &address); | 71 | Q_INVOKABLE void connectDevice(const QString &address); |
145 | 66 | Q_INVOKABLE void disconnectDevice(); | 72 | Q_INVOKABLE void disconnectDevice(); |
146 | 73 | Q_INVOKABLE void toggleDiscovery(); | ||
147 | 74 | Q_INVOKABLE void startDiscovery(); | ||
148 | 75 | Q_INVOKABLE void stopDiscovery(); | ||
149 | 67 | 76 | ||
150 | 68 | public: | 77 | public: |
151 | 69 | Agent * getAgent(); | 78 | Agent * getAgent(); |
152 | @@ -72,6 +81,7 @@ | |||
153 | 72 | QAbstractItemModel * getDisconnectedDevices(); | 81 | QAbstractItemModel * getDisconnectedDevices(); |
154 | 73 | 82 | ||
155 | 74 | bool isDiscovering() const { return m_devices.isDiscovering(); } | 83 | bool isDiscovering() const { return m_devices.isDiscovering(); } |
156 | 84 | bool isDiscoverable() const { return m_devices.isDiscoverable(); } | ||
157 | 75 | 85 | ||
158 | 76 | private: | 86 | private: |
159 | 77 | QDBusConnection m_dbus; | 87 | QDBusConnection m_dbus; |
160 | 78 | 88 | ||
161 | === modified file 'plugins/bluetooth/device.cpp' | |||
162 | --- plugins/bluetooth/device.cpp 2014-06-09 15:12:34 +0000 | |||
163 | +++ plugins/bluetooth/device.cpp 2014-06-20 22:19:44 +0000 | |||
164 | @@ -35,6 +35,7 @@ | |||
165 | 35 | QObject::connect(this, SIGNAL(iconNameChanged()), this, SIGNAL(deviceChanged())); | 35 | QObject::connect(this, SIGNAL(iconNameChanged()), this, SIGNAL(deviceChanged())); |
166 | 36 | QObject::connect(this, SIGNAL(addressChanged()), this, SIGNAL(deviceChanged())); | 36 | QObject::connect(this, SIGNAL(addressChanged()), this, SIGNAL(deviceChanged())); |
167 | 37 | QObject::connect(this, SIGNAL(pairedChanged()), this, SIGNAL(deviceChanged())); | 37 | QObject::connect(this, SIGNAL(pairedChanged()), this, SIGNAL(deviceChanged())); |
168 | 38 | QObject::connect(this, SIGNAL(trustedChanged()), this, SIGNAL(deviceChanged())); | ||
169 | 38 | QObject::connect(this, SIGNAL(typeChanged()), this, SIGNAL(deviceChanged())); | 39 | QObject::connect(this, SIGNAL(typeChanged()), this, SIGNAL(deviceChanged())); |
170 | 39 | QObject::connect(this, SIGNAL(connectionChanged()), this, SIGNAL(deviceChanged())); | 40 | QObject::connect(this, SIGNAL(connectionChanged()), this, SIGNAL(deviceChanged())); |
171 | 40 | QObject::connect(this, SIGNAL(strengthChanged()), this, SIGNAL(deviceChanged())); | 41 | QObject::connect(this, SIGNAL(strengthChanged()), this, SIGNAL(deviceChanged())); |
172 | @@ -117,6 +118,16 @@ | |||
173 | 117 | qWarning() << "Unhandled connection mode" << mode; | 118 | qWarning() << "Unhandled connection mode" << mode; |
174 | 118 | } | 119 | } |
175 | 119 | 120 | ||
176 | 121 | void Device::makeTrusted() | ||
177 | 122 | { | ||
178 | 123 | QVariant value; | ||
179 | 124 | QDBusVariant trusted(true); | ||
180 | 125 | |||
181 | 126 | value.setValue(trusted); | ||
182 | 127 | |||
183 | 128 | m_deviceInterface->asyncCall("SetProperty", "Trusted", value); | ||
184 | 129 | } | ||
185 | 130 | |||
186 | 120 | /*** | 131 | /*** |
187 | 121 | **** | 132 | **** |
188 | 122 | ***/ | 133 | ***/ |
189 | @@ -162,6 +173,14 @@ | |||
190 | 162 | } | 173 | } |
191 | 163 | } | 174 | } |
192 | 164 | 175 | ||
193 | 176 | void Device::setTrusted(bool trusted) | ||
194 | 177 | { | ||
195 | 178 | if (m_trusted != trusted) { | ||
196 | 179 | m_trusted = trusted; | ||
197 | 180 | Q_EMIT(trustedChanged()); | ||
198 | 181 | } | ||
199 | 182 | } | ||
200 | 183 | |||
201 | 165 | void Device::setConnection(Connection connection) | 184 | void Device::setConnection(Connection connection) |
202 | 166 | { | 185 | { |
203 | 167 | if (m_connection != connection) { | 186 | if (m_connection != connection) { |
204 | @@ -204,6 +223,9 @@ | |||
205 | 204 | else | 223 | else |
206 | 205 | c = m_isConnected ? Connection::Connected : Connection::Disconnected; | 224 | c = m_isConnected ? Connection::Connected : Connection::Disconnected; |
207 | 206 | 225 | ||
208 | 226 | if (m_isConnected && m_paired && !m_trusted) | ||
209 | 227 | makeTrusted(); | ||
210 | 228 | |||
211 | 207 | setConnection(c); | 229 | setConnection(c); |
212 | 208 | } | 230 | } |
213 | 209 | 231 | ||
214 | @@ -223,6 +245,9 @@ | |||
215 | 223 | setType(getTypeFromClass(value.toUInt())); | 245 | setType(getTypeFromClass(value.toUInt())); |
216 | 224 | } else if (key == "Paired") { // org.bluez.Device | 246 | } else if (key == "Paired") { // org.bluez.Device |
217 | 225 | setPaired(value.toBool()); | 247 | setPaired(value.toBool()); |
218 | 248 | updateConnection(); | ||
219 | 249 | } else if (key == "Trusted") { // org.bluez.Device | ||
220 | 250 | setTrusted(value.toBool()); | ||
221 | 226 | } else if (key == "Icon") { // org.bluez.Device | 251 | } else if (key == "Icon") { // org.bluez.Device |
222 | 227 | m_fallbackIconName = value.toString(); | 252 | m_fallbackIconName = value.toString(); |
223 | 228 | updateIcon (); | 253 | updateIcon (); |
224 | 229 | 254 | ||
225 | === modified file 'plugins/bluetooth/device.h' | |||
226 | --- plugins/bluetooth/device.h 2014-05-30 06:53:11 +0000 | |||
227 | +++ plugins/bluetooth/device.h 2014-06-20 22:19:44 +0000 | |||
228 | @@ -49,6 +49,10 @@ | |||
229 | 49 | READ isPaired | 49 | READ isPaired |
230 | 50 | NOTIFY pairedChanged) | 50 | NOTIFY pairedChanged) |
231 | 51 | 51 | ||
232 | 52 | Q_PROPERTY(bool trusted | ||
233 | 53 | READ isTrusted | ||
234 | 54 | NOTIFY trustedChanged) | ||
235 | 55 | |||
236 | 52 | Q_PROPERTY(Connection connection | 56 | Q_PROPERTY(Connection connection |
237 | 53 | READ getConnection | 57 | READ getConnection |
238 | 54 | NOTIFY connectionChanged) | 58 | NOTIFY connectionChanged) |
239 | @@ -81,6 +85,7 @@ | |||
240 | 81 | void addressChanged(); | 85 | void addressChanged(); |
241 | 82 | void typeChanged(); | 86 | void typeChanged(); |
242 | 83 | void pairedChanged(); | 87 | void pairedChanged(); |
243 | 88 | void trustedChanged(); | ||
244 | 84 | void connectionChanged(); | 89 | void connectionChanged(); |
245 | 85 | void strengthChanged(); | 90 | void strengthChanged(); |
246 | 86 | void deviceChanged(); // catchall for any change | 91 | void deviceChanged(); // catchall for any change |
247 | @@ -91,6 +96,7 @@ | |||
248 | 91 | const QString& getIconName() const { return m_iconName; } | 96 | const QString& getIconName() const { return m_iconName; } |
249 | 92 | Type getType() const { return m_type; } | 97 | Type getType() const { return m_type; } |
250 | 93 | bool isPaired() const { return m_paired; } | 98 | bool isPaired() const { return m_paired; } |
251 | 99 | bool isTrusted() const { return m_trusted; } | ||
252 | 94 | Connection getConnection() const { return m_connection; } | 100 | Connection getConnection() const { return m_connection; } |
253 | 95 | Strength getStrength() const { return m_strength; } | 101 | Strength getStrength() const { return m_strength; } |
254 | 96 | QString getPath() const { return m_deviceInterface->path(); } | 102 | QString getPath() const { return m_deviceInterface->path(); } |
255 | @@ -103,6 +109,7 @@ | |||
256 | 103 | QString m_fallbackIconName; | 109 | QString m_fallbackIconName; |
257 | 104 | Type m_type = Type::Other; | 110 | Type m_type = Type::Other; |
258 | 105 | bool m_paired = false; | 111 | bool m_paired = false; |
259 | 112 | bool m_trusted = false; | ||
260 | 106 | Connection m_connection = Connection::Disconnected; | 113 | Connection m_connection = Connection::Disconnected; |
261 | 107 | Strength m_strength = Strength::Fair; | 114 | Strength m_strength = Strength::Fair; |
262 | 108 | bool m_isConnected = false; | 115 | bool m_isConnected = false; |
263 | @@ -118,6 +125,7 @@ | |||
264 | 118 | void setAddress(const QString &address); | 125 | void setAddress(const QString &address); |
265 | 119 | void setType(Type type); | 126 | void setType(Type type); |
266 | 120 | void setPaired(bool paired); | 127 | void setPaired(bool paired); |
267 | 128 | void setTrusted(bool trusted); | ||
268 | 121 | void setConnection(Connection connection); | 129 | void setConnection(Connection connection); |
269 | 122 | void setStrength(Strength strength); | 130 | void setStrength(Strength strength); |
270 | 123 | void updateIcon(); | 131 | void updateIcon(); |
271 | @@ -129,6 +137,7 @@ | |||
272 | 129 | Device(const QString &path, QDBusConnection &bus); | 137 | Device(const QString &path, QDBusConnection &bus); |
273 | 130 | bool isValid() const { return getType() != Type::Other; } | 138 | bool isValid() const { return getType() != Type::Other; } |
274 | 131 | void connect(ConnectionMode); | 139 | void connect(ConnectionMode); |
275 | 140 | void makeTrusted(); | ||
276 | 132 | void disconnect(ConnectionMode); | 141 | void disconnect(ConnectionMode); |
277 | 133 | void setProperties(const QMap<QString,QVariant> &properties); | 142 | void setProperties(const QMap<QString,QVariant> &properties); |
278 | 134 | 143 | ||
279 | 135 | 144 | ||
280 | === modified file 'plugins/bluetooth/devicemodel.cpp' | |||
281 | --- plugins/bluetooth/devicemodel.cpp 2014-05-30 06:53:11 +0000 | |||
282 | +++ plugins/bluetooth/devicemodel.cpp 2014-06-20 22:19:44 +0000 | |||
283 | @@ -19,6 +19,7 @@ | |||
284 | 19 | */ | 19 | */ |
285 | 20 | 20 | ||
286 | 21 | #include <QDBusReply> | 21 | #include <QDBusReply> |
287 | 22 | #include <QDebug> | ||
288 | 22 | 23 | ||
289 | 23 | #include "devicemodel.h" | 24 | #include "devicemodel.h" |
290 | 24 | #include "dbus-shared.h" | 25 | #include "dbus-shared.h" |
291 | @@ -135,6 +136,8 @@ | |||
292 | 135 | const QString interface = m_bluezAdapter->interface(); | 136 | const QString interface = m_bluezAdapter->interface(); |
293 | 136 | 137 | ||
294 | 137 | stopDiscovery(); | 138 | stopDiscovery(); |
295 | 139 | m_discoverableTimer.stop(); | ||
296 | 140 | trySetDiscoverable(false); | ||
297 | 138 | 141 | ||
298 | 139 | bus.disconnect(service, path, interface, "DeviceCreated", | 142 | bus.disconnect(service, path, interface, "DeviceCreated", |
299 | 140 | this, SLOT(slotDeviceCreated(const QDBusObjectPath&))); | 143 | this, SLOT(slotDeviceCreated(const QDBusObjectPath&))); |
300 | @@ -144,8 +147,11 @@ | |||
301 | 144 | this, SLOT(slotDeviceFound(const QString&, const QMap<QString,QVariant>&))); | 147 | this, SLOT(slotDeviceFound(const QString&, const QMap<QString,QVariant>&))); |
302 | 145 | bus.disconnect(service, path, interface, "DeviceDisappeared", | 148 | bus.disconnect(service, path, interface, "DeviceDisappeared", |
303 | 146 | this, SLOT(slotDeviceDisappeared(const QString&))); | 149 | this, SLOT(slotDeviceDisappeared(const QString&))); |
304 | 150 | bus.disconnect(service, path, interface, "PropertyChanged", | ||
305 | 151 | this, SLOT(slotPropertyChanged(const QString&, const QDBusVariant&))); | ||
306 | 147 | 152 | ||
307 | 148 | m_bluezAdapter.reset(0); | 153 | m_bluezAdapter.reset(0); |
308 | 154 | m_adapterName.clear(); | ||
309 | 149 | 155 | ||
310 | 150 | beginResetModel(); | 156 | beginResetModel(); |
311 | 151 | m_devices.clear(); | 157 | m_devices.clear(); |
312 | @@ -171,10 +177,22 @@ | |||
313 | 171 | this, SLOT(slotDeviceFound(const QString&, const QMap<QString,QVariant>&))); | 177 | this, SLOT(slotDeviceFound(const QString&, const QMap<QString,QVariant>&))); |
314 | 172 | m_dbus.connect(service, path, interface, "DeviceDisappeared", | 178 | m_dbus.connect(service, path, interface, "DeviceDisappeared", |
315 | 173 | this, SLOT(slotDeviceDisappeared(const QString&))); | 179 | this, SLOT(slotDeviceDisappeared(const QString&))); |
316 | 180 | m_dbus.connect(service, path, interface, "PropertyChanged", | ||
317 | 181 | this, SLOT(slotPropertyChanged(const QString&, const QDBusVariant&))); | ||
318 | 174 | 182 | ||
319 | 175 | m_bluezAdapter.reset(i); | 183 | m_bluezAdapter.reset(i); |
320 | 176 | startDiscovery(); | 184 | startDiscovery(); |
321 | 177 | updateDevices(); | 185 | updateDevices(); |
322 | 186 | |||
323 | 187 | QDBusReply<QMap<QString,QVariant> > properties = m_bluezAdapter->call("GetProperties"); | ||
324 | 188 | if (properties.isValid()) | ||
325 | 189 | setProperties(properties.value()); | ||
326 | 190 | |||
327 | 191 | // Delay enabling discoverability by 1 second. | ||
328 | 192 | m_discoverableTimer.setSingleShot(true); | ||
329 | 193 | connect(&m_discoverableTimer, SIGNAL(timeout()), this, SLOT(slotEnableDiscoverable())); | ||
330 | 194 | m_discoverableTimer.start(1000); | ||
331 | 195 | |||
332 | 178 | } | 196 | } |
333 | 179 | } | 197 | } |
334 | 180 | 198 | ||
335 | @@ -199,6 +217,62 @@ | |||
336 | 199 | } | 217 | } |
337 | 200 | } | 218 | } |
338 | 201 | 219 | ||
339 | 220 | void DeviceModel::setProperties(const QMap<QString,QVariant> &properties) | ||
340 | 221 | { | ||
341 | 222 | QMapIterator<QString,QVariant> it(properties); | ||
342 | 223 | while (it.hasNext()) { | ||
343 | 224 | it.next(); | ||
344 | 225 | updateProperty(it.key(), it.value()); | ||
345 | 226 | } | ||
346 | 227 | } | ||
347 | 228 | |||
348 | 229 | void DeviceModel::updateProperty(const QString &key, const QVariant &value) | ||
349 | 230 | { | ||
350 | 231 | if (key == "Name") { | ||
351 | 232 | m_adapterName = value.toString(); | ||
352 | 233 | } else if (key == "Address") { | ||
353 | 234 | m_adapterAddress = value.toString(); | ||
354 | 235 | } else if (key == "Pairable") { | ||
355 | 236 | m_isPairable = value.toBool(); | ||
356 | 237 | } else if (key == "Discoverable") { | ||
357 | 238 | setDiscoverable(value.toBool()); | ||
358 | 239 | } | ||
359 | 240 | } | ||
360 | 241 | |||
361 | 242 | void DeviceModel::setDiscoverable(bool discoverable) | ||
362 | 243 | { | ||
363 | 244 | if (m_isDiscoverable != discoverable) { | ||
364 | 245 | m_isDiscoverable = discoverable; | ||
365 | 246 | Q_EMIT(discoverableChanged(m_isDiscoverable)); | ||
366 | 247 | } | ||
367 | 248 | } | ||
368 | 249 | |||
369 | 250 | void DeviceModel::slotEnableDiscoverable() | ||
370 | 251 | { | ||
371 | 252 | trySetDiscoverable(true); | ||
372 | 253 | } | ||
373 | 254 | |||
374 | 255 | void DeviceModel::trySetDiscoverable(bool discoverable) | ||
375 | 256 | { | ||
376 | 257 | QVariant value; | ||
377 | 258 | QDBusVariant disc(discoverable); | ||
378 | 259 | QDBusReply<void > reply; | ||
379 | 260 | |||
380 | 261 | value.setValue(disc); | ||
381 | 262 | |||
382 | 263 | if (m_bluezAdapter && m_bluezAdapter->isValid()) { | ||
383 | 264 | reply = m_bluezAdapter->call("SetProperty", "Discoverable", value); | ||
384 | 265 | if (!reply.isValid()) | ||
385 | 266 | qWarning() << "Error setting device discoverable:" << reply.error(); | ||
386 | 267 | } | ||
387 | 268 | } | ||
388 | 269 | |||
389 | 270 | void DeviceModel::slotPropertyChanged(const QString &key, | ||
390 | 271 | const QDBusVariant &value) | ||
391 | 272 | { | ||
392 | 273 | updateProperty (key, value.variant()); | ||
393 | 274 | } | ||
394 | 275 | |||
395 | 202 | /*** | 276 | /*** |
396 | 203 | **** | 277 | **** |
397 | 204 | ***/ | 278 | ***/ |
398 | 205 | 279 | ||
399 | === modified file 'plugins/bluetooth/devicemodel.h' | |||
400 | --- plugins/bluetooth/devicemodel.h 2014-05-30 06:53:11 +0000 | |||
401 | +++ plugins/bluetooth/devicemodel.h 2014-06-20 22:19:44 +0000 | |||
402 | @@ -61,24 +61,37 @@ | |||
403 | 61 | 61 | ||
404 | 62 | QSharedPointer<Device> getDeviceFromAddress(const QString &address); | 62 | QSharedPointer<Device> getDeviceFromAddress(const QString &address); |
405 | 63 | QSharedPointer<Device> getDeviceFromPath(const QString &path); | 63 | QSharedPointer<Device> getDeviceFromPath(const QString &path); |
406 | 64 | QString adapterName() const { return m_adapterName; } | ||
407 | 64 | 65 | ||
408 | 65 | public: | 66 | public: |
409 | 66 | bool isDiscovering() const { return m_isDiscovering; } | 67 | bool isDiscovering() const { return m_isDiscovering; } |
410 | 68 | bool isDiscoverable() const { return m_isDiscoverable; } | ||
411 | 67 | void pairDevice(const QString &address); | 69 | void pairDevice(const QString &address); |
412 | 70 | void stopDiscovery(); | ||
413 | 71 | void startDiscovery(); | ||
414 | 72 | void toggleDiscovery(); | ||
415 | 68 | 73 | ||
416 | 69 | Q_SIGNALS: | 74 | Q_SIGNALS: |
417 | 70 | void discoveringChanged(bool isDiscovering); | 75 | void discoveringChanged(bool isDiscovering); |
418 | 76 | void discoverableChanged(bool isDiscoverable); | ||
419 | 71 | 77 | ||
420 | 72 | private: | 78 | private: |
421 | 73 | QDBusConnection m_dbus; | 79 | QDBusConnection m_dbus; |
422 | 74 | QDBusInterface m_bluezManager; | 80 | QDBusInterface m_bluezManager; |
423 | 75 | 81 | ||
424 | 82 | void setProperties(const QMap<QString,QVariant> &properties); | ||
425 | 83 | void updateProperty(const QString &key, const QVariant &value); | ||
426 | 84 | |||
427 | 85 | QString m_adapterName; | ||
428 | 86 | QString m_adapterAddress; | ||
429 | 87 | bool m_isPairable = false; | ||
430 | 76 | bool m_isDiscovering = false; | 88 | bool m_isDiscovering = false; |
431 | 89 | bool m_isDiscoverable = false; | ||
432 | 77 | QTimer m_timer; | 90 | QTimer m_timer; |
436 | 78 | void stopDiscovery(); | 91 | QTimer m_discoverableTimer; |
434 | 79 | void startDiscovery(); | ||
435 | 80 | void toggleDiscovery(); | ||
437 | 81 | void restartTimer(); | 92 | void restartTimer(); |
438 | 93 | void trySetDiscoverable(bool discoverable); | ||
439 | 94 | void setDiscoverable(bool discoverable); | ||
440 | 82 | 95 | ||
441 | 83 | QScopedPointer<QDBusInterface> m_bluezAdapter; | 96 | QScopedPointer<QDBusInterface> m_bluezAdapter; |
442 | 84 | void clearAdapter(); | 97 | void clearAdapter(); |
443 | @@ -93,7 +106,9 @@ | |||
444 | 93 | void emitRowChanged(int row); | 106 | void emitRowChanged(int row); |
445 | 94 | 107 | ||
446 | 95 | private Q_SLOTS: | 108 | private Q_SLOTS: |
447 | 109 | void slotPropertyChanged(const QString &key, const QDBusVariant &value); | ||
448 | 96 | void slotTimeout(); | 110 | void slotTimeout(); |
449 | 111 | void slotEnableDiscoverable(); | ||
450 | 97 | void slotDeviceChanged(); | 112 | void slotDeviceChanged(); |
451 | 98 | void slotDeviceCreated(const QDBusObjectPath &); | 113 | void slotDeviceCreated(const QDBusObjectPath &); |
452 | 99 | void slotDeviceRemoved(const QDBusObjectPath &); | 114 | void slotDeviceRemoved(const QDBusObjectPath &); |
FAILED: Continuous integration, rev:747 /code.launchpad .net/~mathieu- tl/ubuntu- system- settings/ discoverability -annd-fixes/ +merge/ 223955/ +edit-commit- message
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http:// jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- ci/883/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- utopic- touch/1073 jenkins. qa.ubuntu. com/job/ generic- mediumtests- utopic/ 963 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- utopic- amd64-ci/ 75 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- utopic- armhf-ci/ 75 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- utopic- armhf-ci/ 75/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- utopic- i386-ci/ 75 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- mako/1443 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/1877 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/1877/ artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 8682 jenkins. qa.ubuntu. com/job/ autopilot- testrunner- otto-utopic/ 831 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- amd64/1106 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- amd64/1106/ artifact/ work/output/ *zip*/output. zip
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- system- settings- ci/883/ rebuild
http://