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