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_MANAGER_CLIENT_H_ | |
6 #define CHROMEOS_DBUS_BLUETOOTH_MANAGER_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/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 // BluetoothManagerClient is used to communicate with the bluetooth | |
25 // daemon's Manager interface. | |
26 class CHROMEOS_EXPORT BluetoothManagerClient { | |
27 public: | |
28 // Structure of properties associated with the bluetooth manager. | |
29 struct Properties : public BluetoothPropertySet { | |
30 // List of object paths of local Bluetooth adapters. Read-only. | |
31 dbus::Property<std::vector<dbus::ObjectPath> > adapters; | |
32 | |
33 Properties(dbus::ObjectProxy* object_proxy, | |
34 const PropertyChangedCallback& callback); | |
35 virtual ~Properties(); | |
36 }; | |
37 | |
38 // Interface for observing changes from the bluetooth manager. | |
39 class Observer { | |
40 public: | |
41 virtual ~Observer() {} | |
42 | |
43 // Called when the manager has a change in value of the property | |
44 // named |property_name|. | |
45 virtual void ManagerPropertyChanged(const std::string& property_name) {} | |
46 | |
47 // Called when a local bluetooth adapter is added. | |
48 // |object_path| is the dbus object path of the adapter. | |
49 virtual void AdapterAdded(const dbus::ObjectPath& object_path) {} | |
50 | |
51 // Called when a local bluetooth adapter is removed. | |
52 // |object_path| is the dbus object path of the adapter. | |
53 virtual void AdapterRemoved(const dbus::ObjectPath& object_path) {} | |
54 | |
55 // Called when the default local bluetooth adapter changes. | |
56 // |object_path| is the dbus object path of the new default adapter. | |
57 // Not called if all adapters are removed. | |
58 virtual void DefaultAdapterChanged(const dbus::ObjectPath& object_path) {} | |
59 }; | |
60 | |
61 virtual ~BluetoothManagerClient(); | |
62 | |
63 // Adds and removes observers. | |
64 virtual void AddObserver(Observer* observer) = 0; | |
65 virtual void RemoveObserver(Observer* observer) = 0; | |
66 | |
67 // Obtain the properties for the manager, any values should be copied | |
68 // if needed. | |
69 virtual Properties* GetProperties() = 0; | |
70 | |
71 // The AdapterCallback is used for both the DefaultAdapter() and | |
72 // FindAdapter() methods. It receives two arguments, the |object_path| | |
73 // of the adapter and |success| which indicates whether or not the request | |
74 // succeeded. | |
75 typedef base::Callback<void(const dbus::ObjectPath&, bool)> AdapterCallback; | |
76 | |
77 // Retrieves the dbus object path for the default adapter. | |
78 // The default adapter is the preferred local bluetooth interface when a | |
79 // client does not specify a particular interface. | |
80 virtual void DefaultAdapter(const AdapterCallback& callback) = 0; | |
81 | |
82 // Retrieves the dbus object path for the adapter with the address |address|, | |
83 // which may also be an interface name. | |
84 virtual void FindAdapter(const std::string& address, | |
85 const AdapterCallback& callback) = 0; | |
86 | |
87 // Creates the instance. | |
88 static BluetoothManagerClient* Create(DBusClientImplementationType type, | |
89 dbus::Bus* bus); | |
90 | |
91 protected: | |
92 BluetoothManagerClient(); | |
93 | |
94 private: | |
95 DISALLOW_COPY_AND_ASSIGN(BluetoothManagerClient); | |
96 }; | |
97 | |
98 } // namespace chromeos | |
99 | |
100 #endif // CHROMEOS_DBUS_BLUETOOTH_MANAGER_CLIENT_H_ | |
OLD | NEW |