Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Side by Side Diff: chromeos/dbus/experimental_bluetooth_profile_service_provider.h

Issue 12605008: D-Bus Clients for BlueZ 5 API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mock dbus thread manager without gmock? I didn't even know that was a thing! Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 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_EXPERIMENTAL_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_
6 #define CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "chromeos/chromeos_export.h"
13 #include "dbus/bus.h"
14 #include "dbus/file_descriptor.h"
15 #include "dbus/object_path.h"
16
17 namespace chromeos {
18
19 // ExperimentalBluetoothProfileServiceProvider is used to provide a D-Bus
20 // object that BlueZ can communicate with to connect application profiles.
21 //
22 // Instantiate with a chosen D-Bus object path and delegate object, and pass
23 // the D-Bus object path as the |agent_path| argument to the
24 // chromeos::ExperimentalBluetoothProfileManagerClient::RegisterProfile()
25 // method.
26 //
27 // When an incoming profile connection occurs, or after initiating a connection
28 // using the chromeos::ExperimentalBluetoothDeviceClient::ConnectProfile()
29 // method, the Bluetooth daemon will make calls to this profile object and they
30 // will be passed on to your Delegate object for handling. Responses should be
31 // returned using the callbacks supplied to those methods.
32 class CHROMEOS_EXPORT ExperimentalBluetoothProfileServiceProvider {
33 public:
34 // Interface for reacting to profile requests.
35 class Delegate {
36 public:
37 virtual ~Delegate() {}
38
39 // Possible status values that may be returned to callbacks on a new
40 // connection or a requested disconnection. Success indicates acceptance,
41 // reject indicates the user rejected or denied the request; cancelled
42 // means the user cancelled the request without confirming either way.
43 enum Status {
44 SUCCESS,
45 REJECTED,
46 CANCELLED
47 };
48
49 // Connection-specific options.
50 struct CHROMEOS_EXPORT Options {
51 Options() {}
52 ~Options() {}
53
54 // Profile version.
55 uint16 version;
56
57 // Profile features.
58 uint16 features;
59 };
60
61 // The ConfirmationCallback is used for methods which require confirmation;
62 // it should be called with one argument, the |status| of the request
63 // (success, rejected or cancelled).
64 typedef base::Callback<void(Status)> ConfirmationCallback;
65
66 // This method will be called when the profile is unregistered from the
67 // Bluetooth daemon, generally at shutdown or at the applications' request.
68 // It may be used to perform cleanup tasks.
69 virtual void Release() = 0;
70
71 // This method will be called when a profile connection to the device
72 // with object path |device_path| is established. |callback| must be called
73 // to confirm the connection, or indicate rejection or cancellation.
74 //
75 // A file descriptor for the connection socket is provided in |fd|, and
76 // details about the specific implementation of the profile in |options|.
77 // The delegate should take the value and ownership
78
79 // The file descriptor is owned by the delegate after this call so must be
80 // cleaned up if the connection is cancelled or rejected, the |options|
81 // structure is not so information out of it must be copied if required.
82 virtual void NewConnection(const dbus::ObjectPath& device_path,
83 dbus::FileDescriptor* fd,
84 const Options& options,
85 const ConfirmationCallback& callback) = 0;
86
87 // This method will be called when a profile connection to the device
88 // with object path |device_path| is disconnected. Any file descriptors
89 // owned by the service should be cleaned up and |callback| called to
90 // confirm, or indicate rejection or cancellation of the disconnection.
91 virtual void RequestDisconnection(const dbus::ObjectPath& device_path,
92 const ConfirmationCallback& callback) = 0;
93
94 // This method will be called by the Bluetooth daemon to indicate that
95 // a profile request failed before a reply was returned from the device.
96 virtual void Cancel() = 0;
97 };
98
99 virtual ~ExperimentalBluetoothProfileServiceProvider();
100
101 // Creates the instance where |bus| is the D-Bus bus connection to export
102 // the object onto, |object_path| is the object path that it should have
103 // and |delegate| is the object to which all method calls will be passed
104 // and responses generated from.
105 static ExperimentalBluetoothProfileServiceProvider* Create(
106 dbus::Bus* bus, const dbus::ObjectPath& object_path, Delegate* delegate);
107
108 protected:
109 ExperimentalBluetoothProfileServiceProvider();
110
111 private:
112 DISALLOW_COPY_AND_ASSIGN(ExperimentalBluetoothProfileServiceProvider);
113 };
114
115 } // namespace chromeos
116
117 #endif // CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698