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
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#include <vector>
10
11#include "base/callback.h"
12#include "base/observer_list.h"
13#include "chromeos/chromeos_export.h"
14#include "chromeos/dbus/dbus_client_implementation_type.h"
15#include "dbus/object_path.h"
16#include "dbus/property.h"
17
18namespace dbus {
19class Bus;
20}  // namespace dbus
21
22namespace chromeos {
23
24// BluetoothInputClient is used to communicate with objects representing
25// Bluetooth Input (HID) devices.
26class CHROMEOS_EXPORT BluetoothInputClient {
27 public:
28  // Structure of properties associated with bluetooth input devices.
29  struct Properties : public dbus::PropertySet {
30    // The Bluetooth input device reconnect mode. Read-only.
31    dbus::Property<std::string> reconnect_mode;
32
33    Properties(dbus::ObjectProxy* object_proxy,
34               const std::string& interface_name,
35               const PropertyChangedCallback& callback);
36    virtual ~Properties();
37  };
38
39  // Interface for observing changes from a remote bluetooth input device.
40  class Observer {
41   public:
42    virtual ~Observer() {}
43
44    // Called when the remote device with object path |object_path| implementing
45    // the Input interface is added to the set of known devices or an already
46    // known device implements the Input interface.
47    virtual void InputAdded(const dbus::ObjectPath& object_path) {}
48
49    // Called when the remote device with object path |object_path| is removed
50    // from the set of known devices or does not implement the Input interface
51    // anymore.
52    virtual void InputRemoved(const dbus::ObjectPath& object_path) {}
53
54    // Called when the device with object path |object_path| has a
55    // change in value of the property named |property_name| of its Input
56    // interface.
57    virtual void InputPropertyChanged(const dbus::ObjectPath& object_path,
58                                      const std::string& property_name) {}
59  };
60
61  virtual ~BluetoothInputClient();
62
63  // Adds and removes observers for events on all remote bluetooth input
64  // devices. Check the |object_path| parameter of observer methods to
65  // determine which device is issuing the event.
66  virtual void AddObserver(Observer* observer) = 0;
67  virtual void RemoveObserver(Observer* observer) = 0;
68
69  // Obtain the properties for the device with object path |object_path|,
70  // any values should be copied if needed.
71  virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
72
73  // Creates the instance.
74  static BluetoothInputClient* Create(DBusClientImplementationType type,
75                                      dbus::Bus* bus);
76
77 protected:
78  BluetoothInputClient();
79
80 private:
81  DISALLOW_COPY_AND_ASSIGN(BluetoothInputClient);
82};
83
84}  // namespace chromeos
85
86#endif  // CHROMEOS_DBUS_BLUETOOTH_INPUT_CLIENT_H_
87