Merge lp:~cyphermox/ubuntu-system-settings/fix-1369964 into lp:ubuntu-system-settings

Proposed by Mathieu Trudel-Lapierre
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 1067
Merged at revision: 1085
Proposed branch: lp:~cyphermox/ubuntu-system-settings/fix-1369964
Merge into: lp:ubuntu-system-settings
Diff against target: 53 lines (+24/-12)
1 file modified
plugins/bluetooth/bluetooth.cpp (+24/-12)
To merge this branch: bzr merge lp:~cyphermox/ubuntu-system-settings/fix-1369964
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+235837@code.launchpad.net

Commit message

[bluetooth] Properly handle device types for connection and disconnection.

Description of the change

[bluetooth] Properly handle device types for connection and disconnection.

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
Sebastien Bacher (seb128) wrote :

Thanks, that issue is already in the current code but in the default case you end up calling "device->connect(connMode)" or "m_devices.addConnectAfterPairing(address, connMode)" on an un-initialized "connMode", isn't that an issue?

review: Needs Information
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Hum, doesn't the default case for connect return, so these calls wouldn't get made?

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

oh right, looks fine then ;-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/bluetooth/bluetooth.cpp'
--- plugins/bluetooth/bluetooth.cpp 2014-09-08 18:43:00 +0000
+++ plugins/bluetooth/bluetooth.cpp 2014-09-24 17:17:21 +0000
@@ -156,12 +156,18 @@
156{156{
157 if (m_selectedDevice) {157 if (m_selectedDevice) {
158 auto type = m_selectedDevice->getType();158 auto type = m_selectedDevice->getType();
159 if (type == Device::Type::Headset)159 switch ((Device::Type)type) {
160 m_selectedDevice->disconnect(Device::ConnectionMode::Audio);160 case Device::Type::Headset:
161 else if (type == Device::Type::Headphones)161 case Device::Type::Headphones:
162 m_selectedDevice->disconnect(Device::ConnectionMode::Audio);162 case Device::Type::OtherAudio:
163 else if (type == Device::Type::OtherAudio)163 case Device::Type::Speakers:
164 m_selectedDevice->disconnect(Device::ConnectionMode::Audio);164 case Device::Type::Carkit:
165 m_selectedDevice->disconnect(Device::ConnectionMode::Audio);
166 break;
167 default:
168 qWarning() << "Nothing to disconnect: Unsupported device type.";
169 break;
170 }
165 } else {171 } else {
166 qWarning() << "No selected device to disconnect";172 qWarning() << "No selected device to disconnect";
167 }173 }
@@ -179,12 +185,18 @@
179 }185 }
180186
181 type = device->getType();187 type = device->getType();
182 if (type == Device::Type::Headset)188 switch (type) {
183 connMode = Device::ConnectionMode::Audio;189 case Device::Type::Headset:
184 else if (type == Device::Type::Headphones)190 case Device::Type::Headphones:
185 connMode = Device::ConnectionMode::Audio;191 case Device::Type::OtherAudio:
186 else if (type == Device::Type::OtherAudio)192 case Device::Type::Speakers:
187 connMode = Device::ConnectionMode::Audio;193 case Device::Type::Carkit:
194 connMode = Device::ConnectionMode::Audio;
195 break;
196 default:
197 qWarning() << "Nothing to connect: Unsupported device type.";
198 return;
199 }
188200
189 if (device->isTrusted()) {201 if (device->isTrusted()) {
190 device->connect(connMode);202 device->connect(connMode);

Subscribers

People subscribed via source and target branches