| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_experimental_chromeos.h" | 5 #include "device/bluetooth/bluetooth_device_experimental_chromeos.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chromeos/dbus/dbus_thread_manager.h" | 8 #include "chromeos/dbus/dbus_thread_manager.h" |
| 9 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h" | 9 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h" |
| 10 #include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h" | 10 #include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h" |
| 11 #include "chromeos/dbus/experimental_bluetooth_agent_service_provider.h" | 11 #include "chromeos/dbus/experimental_bluetooth_agent_service_provider.h" |
| 12 #include "chromeos/dbus/experimental_bluetooth_device_client.h" | 12 #include "chromeos/dbus/experimental_bluetooth_device_client.h" |
| 13 #include "chromeos/dbus/experimental_bluetooth_input_client.h" |
| 13 #include "dbus/bus.h" | 14 #include "dbus/bus.h" |
| 14 #include "device/bluetooth/bluetooth_adapter_experimental_chromeos.h" | 15 #include "device/bluetooth/bluetooth_adapter_experimental_chromeos.h" |
| 15 #include "device/bluetooth/bluetooth_socket.h" | 16 #include "device/bluetooth/bluetooth_socket.h" |
| 16 #include "third_party/cros_system_api/dbus/service_constants.h" | 17 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 17 | 18 |
| 18 using device::BluetoothDevice; | 19 using device::BluetoothDevice; |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // The agent path is relatively meaningless since BlueZ only supports one | 23 // The agent path is relatively meaningless since BlueZ only supports one |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 bool BluetoothDeviceExperimentalChromeOS::IsConnected() const { | 81 bool BluetoothDeviceExperimentalChromeOS::IsConnected() const { |
| 81 ExperimentalBluetoothDeviceClient::Properties* properties = | 82 ExperimentalBluetoothDeviceClient::Properties* properties = |
| 82 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> | 83 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> |
| 83 GetProperties(object_path_); | 84 GetProperties(object_path_); |
| 84 DCHECK(properties); | 85 DCHECK(properties); |
| 85 | 86 |
| 86 return properties->connected.value(); | 87 return properties->connected.value(); |
| 87 } | 88 } |
| 88 | 89 |
| 89 bool BluetoothDeviceExperimentalChromeOS::IsConnectable() const { | 90 bool BluetoothDeviceExperimentalChromeOS::IsConnectable() const { |
| 90 // TODO(deymo): implement | 91 ExperimentalBluetoothInputClient::Properties* input_properties = |
| 91 return false; | 92 DBusThreadManager::Get()->GetExperimentalBluetoothInputClient()-> |
| 93 GetProperties(object_path_); |
| 94 // GetProperties returns NULL when the device does not implement the given |
| 95 // interface. Non HID devices are normally connectable. |
| 96 if (!input_properties) |
| 97 return true; |
| 98 |
| 99 return input_properties->reconnect_mode.value() != "device"; |
| 92 } | 100 } |
| 93 | 101 |
| 94 bool BluetoothDeviceExperimentalChromeOS::IsConnecting() const { | 102 bool BluetoothDeviceExperimentalChromeOS::IsConnecting() const { |
| 95 return num_connecting_calls_ > 0; | 103 return num_connecting_calls_ > 0; |
| 96 } | 104 } |
| 97 | 105 |
| 98 BluetoothDeviceExperimentalChromeOS::ServiceList | 106 BluetoothDeviceExperimentalChromeOS::ServiceList |
| 99 BluetoothDeviceExperimentalChromeOS::GetServices() const { | 107 BluetoothDeviceExperimentalChromeOS::GetServices() const { |
| 100 ExperimentalBluetoothDeviceClient::Properties* properties = | 108 ExperimentalBluetoothDeviceClient::Properties* properties = |
| 101 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> | 109 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 if (!confirmation_callback_.is_null()) { | 608 if (!confirmation_callback_.is_null()) { |
| 601 confirmation_callback_.Run(status); | 609 confirmation_callback_.Run(status); |
| 602 confirmation_callback_.Reset(); | 610 confirmation_callback_.Reset(); |
| 603 callback_run = true; | 611 callback_run = true; |
| 604 } | 612 } |
| 605 | 613 |
| 606 return callback_run; | 614 return callback_run; |
| 607 } | 615 } |
| 608 | 616 |
| 609 } // namespace chromeos | 617 } // namespace chromeos |
| OLD | NEW |