OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_MANAGER_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_MANAGER_CLIENT_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_MANAGER_CLIENT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_MANAGER_CLIENT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "dbus/object_path.h" |
13 | 14 |
14 namespace dbus { | 15 namespace dbus { |
15 class Bus; | 16 class Bus; |
16 } // namespace dbus | 17 } // namespace dbus |
17 | 18 |
18 namespace chromeos { | 19 namespace chromeos { |
19 | 20 |
20 // BluetoothManagerClient is used to communicate with the bluetooth | 21 // BluetoothManagerClient is used to communicate with the bluetooth |
21 // daemon's Manager interface. | 22 // daemon's Manager interface. |
22 class BluetoothManagerClient { | 23 class BluetoothManagerClient { |
23 public: | 24 public: |
24 // Interface for observing changes from the bluetooth manager. | 25 // Interface for observing changes from the bluetooth manager. |
25 class Observer { | 26 class Observer { |
26 public: | 27 public: |
27 virtual ~Observer() {} | 28 virtual ~Observer() {} |
28 | 29 |
29 // Called when a local bluetooth adapter is added. | 30 // Called when a local bluetooth adapter is added. |
30 // |object_path| is the dbus object path of the adapter. | 31 // |object_path| is the dbus object path of the adapter. |
31 virtual void AdapterAdded(const std::string& object_path) {} | 32 virtual void AdapterAdded(const dbus::ObjectPath& object_path) {} |
32 | 33 |
33 // Called when a local bluetooth adapter is removed. | 34 // Called when a local bluetooth adapter is removed. |
34 // |object_path| is the dbus object path of the adapter. | 35 // |object_path| is the dbus object path of the adapter. |
35 virtual void AdapterRemoved(const std::string& object_path) {} | 36 virtual void AdapterRemoved(const dbus::ObjectPath& object_path) {} |
36 | 37 |
37 // Called when the default local bluetooth adapter changes. | 38 // Called when the default local bluetooth adapter changes. |
38 // |adapter| is the dbus object path of the new default adapter. | 39 // |object_path| is the dbus object path of the new default adapter. |
39 // Not called if all adapters are removed. | 40 // Not called if all adapters are removed. |
40 virtual void DefaultAdapterChanged(const std::string& adapter) {} | 41 virtual void DefaultAdapterChanged(const dbus::ObjectPath& object_path) {} |
41 }; | 42 }; |
42 | 43 |
43 virtual ~BluetoothManagerClient(); | 44 virtual ~BluetoothManagerClient(); |
44 | 45 |
45 // Adds and removes the observer. | 46 // Adds and removes the observer. |
46 virtual void AddObserver(Observer* observer) = 0; | 47 virtual void AddObserver(Observer* observer) = 0; |
47 virtual void RemoveObserver(Observer* observer) = 0; | 48 virtual void RemoveObserver(Observer* observer) = 0; |
48 | 49 |
49 // The DefaultAdapterCallback receives two arguments: | 50 // The DefaultAdapterCallback receives two arguments: |
50 // std::string adapter - the unique identifier of the default adapter | 51 // dbus::ObjectPath object_path - the path of the new default adapter |
51 // bool success - whether or not the request succeeded | 52 // bool success - whether or not the request succeeded |
52 typedef base::Callback<void(const std::string&, bool)> | 53 typedef base::Callback<void(const dbus::ObjectPath&, bool)> |
53 DefaultAdapterCallback; | 54 DefaultAdapterCallback; |
54 | 55 |
55 // Retrieves the dbus object path for the default adapter. | 56 // Retrieves the dbus object path for the default adapter. |
56 // The default adapter is the preferred local bluetooth interface when a | 57 // The default adapter is the preferred local bluetooth interface when a |
57 // client does not specify a particular interface. | 58 // client does not specify a particular interface. |
58 virtual void DefaultAdapter(const DefaultAdapterCallback& callback) = 0; | 59 virtual void DefaultAdapter(const DefaultAdapterCallback& callback) = 0; |
59 | 60 |
60 // Creates the instance. | 61 // Creates the instance. |
61 static BluetoothManagerClient* Create(dbus::Bus* bus); | 62 static BluetoothManagerClient* Create(dbus::Bus* bus); |
62 | 63 |
63 protected: | 64 protected: |
64 BluetoothManagerClient(); | 65 BluetoothManagerClient(); |
65 | 66 |
66 private: | 67 private: |
67 DISALLOW_COPY_AND_ASSIGN(BluetoothManagerClient); | 68 DISALLOW_COPY_AND_ASSIGN(BluetoothManagerClient); |
68 }; | 69 }; |
69 | 70 |
70 } // namespace chromeos | 71 } // namespace chromeos |
71 | 72 |
72 #endif // CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_MANAGER_CLIENT_H_ | 73 #endif // CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_MANAGER_CLIENT_H_ |
OLD | NEW |