| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_INPUT_CLIENT_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_INPUT_CLIENT_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/callback.h" | |
| 12 #include "base/observer_list.h" | |
| 13 #include "base/values.h" | |
| 14 #include "chrome/browser/chromeos/dbus/bluetooth_property.h" | |
| 15 #include "chrome/browser/chromeos/dbus/dbus_client_implementation_type.h" | |
| 16 #include "dbus/object_path.h" | |
| 17 | |
| 18 namespace dbus { | |
| 19 class Bus; | |
| 20 } // namespace dbus | |
| 21 | |
| 22 namespace chromeos { | |
| 23 | |
| 24 class BluetoothAdapterClient; | |
| 25 | |
| 26 // BluetoothInputClient is used to communicate with the Input interface | |
| 27 // of a bluetooth device, rather than the generic device interface. Input | |
| 28 // devices are those conforming to the Bluetooth SIG HID (Human Interface | |
| 29 // Device) Profile such as keyboards, mice, trackpads and joysticks. | |
| 30 class BluetoothInputClient { | |
| 31 public: | |
| 32 // Structure of properties associated with bluetooth input devices. | |
| 33 struct Properties : public BluetoothPropertySet { | |
| 34 // Indicates that the device is currently connected. Read-only. | |
| 35 BluetoothProperty<bool> connected; | |
| 36 | |
| 37 Properties(dbus::ObjectProxy* object_proxy, | |
| 38 PropertyChangedCallback callback); | |
| 39 virtual ~Properties(); | |
| 40 }; | |
| 41 | |
| 42 // Interface for observing changes from a bluetooth input device. | |
| 43 class Observer { | |
| 44 public: | |
| 45 virtual ~Observer() {} | |
| 46 | |
| 47 // Called when the device with object path |object_path| has a | |
| 48 // change in value of the input property named |property_name|. | |
| 49 virtual void InputPropertyChanged(const dbus::ObjectPath& object_path, | |
| 50 const std::string& property_name) {} | |
| 51 }; | |
| 52 | |
| 53 virtual ~BluetoothInputClient(); | |
| 54 | |
| 55 // Adds and removes observers for events on all bluetooth input | |
| 56 // devices. Check the |object_path| parameter of observer methods to | |
| 57 // determine which device is issuing the event. | |
| 58 virtual void AddObserver(Observer* observer) = 0; | |
| 59 virtual void RemoveObserver(Observer* observer) = 0; | |
| 60 | |
| 61 // Obtain the input properties for the device with object path |object_path|, | |
| 62 // any values should be copied if needed. | |
| 63 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0; | |
| 64 | |
| 65 // The InputCallback is used for input device methods that only return to | |
| 66 // indicate success. It receives two arguments, the |object_path| of the | |
| 67 // input devuce the call was made on and |success| which indicates whether | |
| 68 // or not the request succeeded. | |
| 69 typedef base::Callback<void(const dbus::ObjectPath&, bool)> InputCallback; | |
| 70 | |
| 71 // Connects the input subsystem to the device with object path | |
| 72 // |object_path|, which should already be a known device on the adapter. | |
| 73 virtual void Connect(const dbus::ObjectPath& object_path, | |
| 74 const InputCallback& callback) = 0; | |
| 75 | |
| 76 // Disconnects the input subsystem from the device with object path | |
| 77 // |object_path| without terminating the low-level ACL connection, | |
| 78 virtual void Disconnect(const dbus::ObjectPath& object_path, | |
| 79 const InputCallback& callback) = 0; | |
| 80 | |
| 81 // Creates the instance. | |
| 82 static BluetoothInputClient* Create(DBusClientImplementationType type, | |
| 83 dbus::Bus* bus, | |
| 84 BluetoothAdapterClient* adapter_client); | |
| 85 | |
| 86 protected: | |
| 87 BluetoothInputClient(); | |
| 88 | |
| 89 private: | |
| 90 DISALLOW_COPY_AND_ASSIGN(BluetoothInputClient); | |
| 91 }; | |
| 92 | |
| 93 } // namespace chromeos | |
| 94 | |
| 95 #endif // CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_INPUT_CLIENT_H_ | |
| OLD | NEW |