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

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: Reverted BluetoothDevice interface. 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
« no previous file with comments | « device/bluetooth/bluetooth_device_mac.h ('k') | device/bluetooth/test/mock_bluetooth_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <IOBluetooth/Bluetooth.h>
8 #import <IOBluetooth/objc/IOBluetoothDevice.h>
9 #import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h>
10
7 #include <string> 11 #include <string>
8 12
9 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/hash.h"
15 #include "base/stringprintf.h"
16 #include "base/strings/sys_string_conversions.h"
10 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" 17 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h"
11 #include "device/bluetooth/bluetooth_service_record_mac.h" 18 #include "device/bluetooth/bluetooth_service_record_mac.h"
12 19
20 // Replicate specific 10.7 SDK declarations for building with prior SDKs.
21 #if !defined(MAC_OS_X_VERSION_10_7) || \
22 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
23
24 @interface IOBluetoothDevice (LionSDKDeclarations)
25 - (NSString*)addressString;
26 - (NSString*)name;
27 - (unsigned int)classOfDevice;
28 - (NSArray*)services;
29 @end
30
31 #endif // MAC_OS_X_VERSION_10_7
32
13 namespace device { 33 namespace device {
14 34
15 BluetoothDeviceMac::BluetoothDeviceMac() 35 BluetoothDeviceMac::BluetoothDeviceMac(const IOBluetoothDevice* device)
16 : BluetoothDevice() { 36 : BluetoothDevice(),
37 device_fingerprint_(ComputeDeviceFingerprint(device)) {
38 name_ = base::SysNSStringToUTF8([device name]);
39 address_ = base::SysNSStringToUTF8([device addressString]);
40 bluetooth_class_ = [device classOfDevice];
41 connected_ = [device isConnected];
42 bonded_ = [device isPaired];
43 visible_ = true;
17 } 44 }
18 45
19 BluetoothDeviceMac::~BluetoothDeviceMac() { 46 BluetoothDeviceMac::~BluetoothDeviceMac() {
20 } 47 }
21 48
22 bool BluetoothDeviceMac::IsPaired() const { 49 bool BluetoothDeviceMac::IsPaired() const {
23 return false; 50 return bonded_;
24 } 51 }
25 52
26 const BluetoothDevice::ServiceList& BluetoothDeviceMac::GetServices() const { 53 const BluetoothDevice::ServiceList& BluetoothDeviceMac::GetServices() const {
27 return service_uuids_; 54 return service_uuids_;
28 } 55 }
29 56
30 void BluetoothDeviceMac::GetServiceRecords( 57 void BluetoothDeviceMac::GetServiceRecords(
31 const ServiceRecordsCallback& callback, 58 const ServiceRecordsCallback& callback,
32 const ErrorCallback& error_callback) { 59 const ErrorCallback& error_callback) {
33 } 60 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 const ErrorCallback& error_callback) { 127 const ErrorCallback& error_callback) {
101 NOTIMPLEMENTED(); 128 NOTIMPLEMENTED();
102 } 129 }
103 130
104 void BluetoothDeviceMac::ClearOutOfBandPairingData( 131 void BluetoothDeviceMac::ClearOutOfBandPairingData(
105 const base::Closure& callback, 132 const base::Closure& callback,
106 const ErrorCallback& error_callback) { 133 const ErrorCallback& error_callback) {
107 NOTIMPLEMENTED(); 134 NOTIMPLEMENTED();
108 } 135 }
109 136
137 // static
138 uint32 BluetoothDeviceMac::ComputeDeviceFingerprint(
139 const IOBluetoothDevice* device) {
140 std::string device_string = base::StringPrintf("%s|%s|%u|%d|%d",
141 base::SysNSStringToUTF8([device name]).c_str(),
142 base::SysNSStringToUTF8([device addressString]).c_str(),
143 [device classOfDevice],
144 [device isConnected],
145 [device isPaired]);
146
147 for (IOBluetoothSDPServiceRecord* record in [device services]) {
148 base::StringAppendF(
149 &device_string,
150 "|%s|%u",
151 base::SysNSStringToUTF8([record getServiceName]).c_str(),
152 [[record attributes] count]);
Avi (use Gerrit) 2013/03/26 19:15:51 This breaks the 64-bit build. NSUInteger shouldn't
153 }
154
155 return base::Hash(device_string);
156 }
157
110 } // namespace device 158 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_mac.h ('k') | device/bluetooth/test/mock_bluetooth_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698