OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "device/bluetooth/bluetooth_device_mac.h" | 5 #include "device/bluetooth/bluetooth_device_mac.h" |
6 | 6 |
7 #import <IObluetooth/objc/IOBluetoothDevice.h> | |
Mark Mentovai
2013/03/19 16:04:35
Fix capitalization.
youngki
2013/03/19 19:04:55
Done.
| |
8 #import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h> | |
9 | |
7 #include <string> | 10 #include <string> |
8 | 11 |
9 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/hash.h" | |
14 #include "base/stringprintf.h" | |
15 #include "base/strings/sys_string_conversions.h" | |
10 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" | 16 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" |
11 #include "device/bluetooth/bluetooth_service_record_mac.h" | 17 #include "device/bluetooth/bluetooth_service_record_mac.h" |
12 | 18 |
13 namespace device { | 19 namespace device { |
14 | 20 |
15 BluetoothDeviceMac::BluetoothDeviceMac() | 21 BluetoothDeviceMac::BluetoothDeviceMac(const IOBluetoothDevice* device) |
16 : BluetoothDevice() { | 22 : BluetoothDevice(), |
23 device_fingerprint_(ComputeDeviceFingerprint(device)) { | |
24 name_ = base::SysNSStringToUTF8([device name]); | |
Mark Mentovai
2013/03/19 16:04:35
You can list all of these in the initializer list.
youngki
2013/03/19 19:04:55
Done.
| |
25 address_ = base::SysNSStringToUTF8([device addressString]); | |
26 bluetooth_class_ = [device classOfDevice]; | |
27 connected_ = [device isConnected]; | |
28 bonded_ = [device isPaired]; | |
17 } | 29 } |
18 | 30 |
19 BluetoothDeviceMac::~BluetoothDeviceMac() { | 31 BluetoothDeviceMac::~BluetoothDeviceMac() { |
20 } | 32 } |
21 | 33 |
34 void BluetoothDeviceMac::SetVisible(bool visible) { | |
35 visible_ = visible; | |
36 } | |
37 | |
22 bool BluetoothDeviceMac::IsPaired() const { | 38 bool BluetoothDeviceMac::IsPaired() const { |
23 return false; | 39 return false; |
24 } | 40 } |
25 | 41 |
26 const BluetoothDevice::ServiceList& BluetoothDeviceMac::GetServices() const { | 42 const BluetoothDevice::ServiceList& BluetoothDeviceMac::GetServices() const { |
27 return service_uuids_; | 43 return service_uuids_; |
28 } | 44 } |
29 | 45 |
30 void BluetoothDeviceMac::GetServiceRecords( | 46 void BluetoothDeviceMac::GetServiceRecords( |
31 const ServiceRecordsCallback& callback, | 47 const ServiceRecordsCallback& callback, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 const ErrorCallback& error_callback) { | 116 const ErrorCallback& error_callback) { |
101 NOTIMPLEMENTED(); | 117 NOTIMPLEMENTED(); |
102 } | 118 } |
103 | 119 |
104 void BluetoothDeviceMac::ClearOutOfBandPairingData( | 120 void BluetoothDeviceMac::ClearOutOfBandPairingData( |
105 const base::Closure& callback, | 121 const base::Closure& callback, |
106 const ErrorCallback& error_callback) { | 122 const ErrorCallback& error_callback) { |
107 NOTIMPLEMENTED(); | 123 NOTIMPLEMENTED(); |
108 } | 124 } |
109 | 125 |
126 // static | |
127 uint32 BluetoothDeviceMac::ComputeDeviceFingerprint( | |
128 const IOBluetoothDevice* device) { | |
129 std::string device_string = base::StringPrintf("%s%s%u%s%s", | |
Mark Mentovai
2013/03/19 16:04:35
For fields without fixed width, can you have the d
youngki
2013/03/19 19:04:55
Done.
| |
130 base::SysNSStringToUTF8([device name]).c_str(), | |
131 base::SysNSStringToUTF8([device addressString]).c_str(), | |
132 [device classOfDevice], | |
133 [device isConnected] ? "true" : "false", | |
Mark Mentovai
2013/03/19 16:04:35
You don’t need to turn these into strings, you can
youngki
2013/03/19 19:04:55
Done.
| |
134 [device isPaired] ? "true" : "false"); | |
135 | |
136 for (IOBluetoothSDPServiceRecord* record in [device services]) { | |
137 base::StringAppendF( | |
138 &device_string, | |
139 "%s%u", | |
140 base::SysNSStringToUTF8([record getServiceName]).c_str(), | |
141 [[record sortedAttributes] count]); | |
Mark Mentovai
2013/03/19 16:04:35
If you’re just getting a count, you don’t care if
youngki
2013/03/19 19:04:55
Done.
| |
142 } | |
143 | |
144 return base::Hash(device_string); | |
145 } | |
146 | |
110 } // namespace device | 147 } // namespace device |
OLD | NEW |