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
1=== modified file 'plugins/bluetooth/bluetooth.cpp'
2--- plugins/bluetooth/bluetooth.cpp 2014-09-08 18:43:00 +0000
3+++ plugins/bluetooth/bluetooth.cpp 2014-09-24 17:17:21 +0000
4@@ -156,12 +156,18 @@
5 {
6 if (m_selectedDevice) {
7 auto type = m_selectedDevice->getType();
8- if (type == Device::Type::Headset)
9- m_selectedDevice->disconnect(Device::ConnectionMode::Audio);
10- else if (type == Device::Type::Headphones)
11- m_selectedDevice->disconnect(Device::ConnectionMode::Audio);
12- else if (type == Device::Type::OtherAudio)
13- m_selectedDevice->disconnect(Device::ConnectionMode::Audio);
14+ switch ((Device::Type)type) {
15+ case Device::Type::Headset:
16+ case Device::Type::Headphones:
17+ case Device::Type::OtherAudio:
18+ case Device::Type::Speakers:
19+ case Device::Type::Carkit:
20+ m_selectedDevice->disconnect(Device::ConnectionMode::Audio);
21+ break;
22+ default:
23+ qWarning() << "Nothing to disconnect: Unsupported device type.";
24+ break;
25+ }
26 } else {
27 qWarning() << "No selected device to disconnect";
28 }
29@@ -179,12 +185,18 @@
30 }
31
32 type = device->getType();
33- if (type == Device::Type::Headset)
34- connMode = Device::ConnectionMode::Audio;
35- else if (type == Device::Type::Headphones)
36- connMode = Device::ConnectionMode::Audio;
37- else if (type == Device::Type::OtherAudio)
38- connMode = Device::ConnectionMode::Audio;
39+ switch (type) {
40+ case Device::Type::Headset:
41+ case Device::Type::Headphones:
42+ case Device::Type::OtherAudio:
43+ case Device::Type::Speakers:
44+ case Device::Type::Carkit:
45+ connMode = Device::ConnectionMode::Audio;
46+ break;
47+ default:
48+ qWarning() << "Nothing to connect: Unsupported device type.";
49+ return;
50+ }
51
52 if (device->isTrusted()) {
53 device->connect(connMode);

Subscribers

People subscribed via source and target branches