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 CHROMEOS_DBUS_BLUETOOTH_INPUT_CLIENT_H_ | |
6 #define CHROMEOS_DBUS_BLUETOOTH_INPUT_CLIENT_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/observer_list.h" | |
12 #include "base/values.h" | |
13 #include "chromeos/chromeos_export.h" | |
14 #include "chromeos/dbus/bluetooth_property.h" | |
15 #include "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 CHROMEOS_EXPORT 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 dbus::Property<bool> connected; | |
36 | |
37 Properties(dbus::ObjectProxy* object_proxy, | |
38 const 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 device 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 // The ConnectCallback is used for the Connect input device method to | |
72 // indicate success. It receives a single argument, the |object_path| of | |
73 // the input device the call was made on. | |
74 typedef base::Callback<void(const dbus::ObjectPath&)> ConnectCallback; | |
75 | |
76 // The ConnectErrorCallback is used for the Connect input device method | |
77 // to indicate failure. It receives three arguments, the |object_path| of | |
78 // the input device the call was made on, the name of the error in | |
79 // |error_name| and an optional message in |error_message|. | |
80 typedef base::Callback<void(const dbus::ObjectPath& object_path, | |
81 const std::string& error_name, | |
82 const std::string& error_message)> | |
83 ConnectErrorCallback; | |
84 | |
85 // Connects the input subsystem to the device with object path | |
86 // |object_path|, which should already be a known device on the adapter. | |
87 virtual void Connect(const dbus::ObjectPath& object_path, | |
88 const ConnectCallback& callback, | |
89 const ConnectErrorCallback& error_callback) = 0; | |
90 | |
91 // Disconnects the input subsystem from the device with object path | |
92 // |object_path| without terminating the low-level ACL connection, | |
93 virtual void Disconnect(const dbus::ObjectPath& object_path, | |
94 const InputCallback& callback) = 0; | |
95 | |
96 // Creates the instance. | |
97 static BluetoothInputClient* Create(DBusClientImplementationType type, | |
98 dbus::Bus* bus, | |
99 BluetoothAdapterClient* adapter_client); | |
100 | |
101 // Constants used to indicate exceptional error conditions. | |
102 static const char kNoResponseError[]; | |
103 | |
104 protected: | |
105 BluetoothInputClient(); | |
106 | |
107 private: | |
108 DISALLOW_COPY_AND_ASSIGN(BluetoothInputClient); | |
109 }; | |
110 | |
111 } // namespace chromeos | |
112 | |
113 #endif // CHROMEOS_DBUS_BLUETOOTH_INPUT_CLIENT_H_ | |
OLD | NEW |