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