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> | |
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(base::SysNSStringToUTF8([device name]), |
23 base::SysNSStringToUTF8([device addressString]), | |
24 [device classOfDevice], | |
25 [device isConnected], | |
26 [device isPaired]), | |
27 device_fingerprint_(ComputeDeviceFingerprint(device)) { | |
17 } | 28 } |
18 | 29 |
19 BluetoothDeviceMac::~BluetoothDeviceMac() { | 30 BluetoothDeviceMac::~BluetoothDeviceMac() { |
20 } | 31 } |
21 | 32 |
22 bool BluetoothDeviceMac::IsPaired() const { | 33 bool BluetoothDeviceMac::IsPaired() const { |
23 return false; | 34 return false; |
24 } | 35 } |
25 | 36 |
26 const BluetoothDevice::ServiceList& BluetoothDeviceMac::GetServices() const { | 37 const BluetoothDevice::ServiceList& BluetoothDeviceMac::GetServices() const { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 const ErrorCallback& error_callback) { | 111 const ErrorCallback& error_callback) { |
101 NOTIMPLEMENTED(); | 112 NOTIMPLEMENTED(); |
102 } | 113 } |
103 | 114 |
104 void BluetoothDeviceMac::ClearOutOfBandPairingData( | 115 void BluetoothDeviceMac::ClearOutOfBandPairingData( |
105 const base::Closure& callback, | 116 const base::Closure& callback, |
106 const ErrorCallback& error_callback) { | 117 const ErrorCallback& error_callback) { |
107 NOTIMPLEMENTED(); | 118 NOTIMPLEMENTED(); |
108 } | 119 } |
109 | 120 |
121 // static | |
122 uint32 BluetoothDeviceMac::ComputeDeviceFingerprint( | |
123 const IOBluetoothDevice* device) { | |
124 std::string device_string = base::StringPrintf("|%s|%s|%u|%d|%d|", | |
Mark Mentovai
2013/03/19 19:14:20
The first and last | characters aren’t necessary.
youngki
2013/03/20 18:48:27
Done.
| |
125 base::SysNSStringToUTF8([device name]).c_str(), | |
126 base::SysNSStringToUTF8([device addressString]).c_str(), | |
127 [device classOfDevice], | |
128 [device isConnected], | |
129 [device isPaired]); | |
130 | |
131 for (IOBluetoothSDPServiceRecord* record in [device services]) { | |
132 base::StringAppendF( | |
133 &device_string, | |
134 "|%s|%u|", | |
Mark Mentovai
2013/03/19 19:14:20
The last | character isn’t necessary.
youngki
2013/03/20 18:48:27
Done.
| |
135 base::SysNSStringToUTF8([record getServiceName]).c_str(), | |
136 [[record attributes] count]); | |
137 } | |
138 | |
139 return base::Hash(device_string); | |
140 } | |
141 | |
110 } // namespace device | 142 } // namespace device |
OLD | NEW |