Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Side by Side Diff: device/bluetooth/bluetooth_device_mac.mm

Issue 12929003: Implemented BluetoothAdapterMac::AddDevices(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: used pairedDevices instead of recentDevices Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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)) {
28 visible_ = true;
17 } 29 }
18 30
19 BluetoothDeviceMac::~BluetoothDeviceMac() { 31 BluetoothDeviceMac::~BluetoothDeviceMac() {
20 } 32 }
21 33
22 bool BluetoothDeviceMac::IsPaired() const { 34 bool BluetoothDeviceMac::IsPaired() const {
23 return false; 35 return bonded_;
24 } 36 }
25 37
26 const BluetoothDevice::ServiceList& BluetoothDeviceMac::GetServices() const { 38 const BluetoothDevice::ServiceList& BluetoothDeviceMac::GetServices() const {
27 return service_uuids_; 39 return service_uuids_;
28 } 40 }
29 41
30 void BluetoothDeviceMac::GetServiceRecords( 42 void BluetoothDeviceMac::GetServiceRecords(
31 const ServiceRecordsCallback& callback, 43 const ServiceRecordsCallback& callback,
32 const ErrorCallback& error_callback) { 44 const ErrorCallback& error_callback) {
33 } 45 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 const ErrorCallback& error_callback) { 112 const ErrorCallback& error_callback) {
101 NOTIMPLEMENTED(); 113 NOTIMPLEMENTED();
102 } 114 }
103 115
104 void BluetoothDeviceMac::ClearOutOfBandPairingData( 116 void BluetoothDeviceMac::ClearOutOfBandPairingData(
105 const base::Closure& callback, 117 const base::Closure& callback,
106 const ErrorCallback& error_callback) { 118 const ErrorCallback& error_callback) {
107 NOTIMPLEMENTED(); 119 NOTIMPLEMENTED();
108 } 120 }
109 121
122 // static
123 uint32 BluetoothDeviceMac::ComputeDeviceFingerprint(
124 const IOBluetoothDevice* device) {
125 std::string device_string = base::StringPrintf("%s|%s|%u|%d|%d",
126 base::SysNSStringToUTF8([device name]).c_str(),
127 base::SysNSStringToUTF8([device addressString]).c_str(),
128 [device classOfDevice],
129 [device isConnected],
130 [device isPaired]);
131
132 for (IOBluetoothSDPServiceRecord* record in [device services]) {
133 base::StringAppendF(
134 &device_string,
135 "|%s|%u",
136 base::SysNSStringToUTF8([record getServiceName]).c_str(),
137 [[record attributes] count]);
138 }
139
140 return base::Hash(device_string);
141 }
142
110 } // namespace device 143 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698