bluetooth_profile_manager_client.h revision 424c4d7b64af9d0d8fd9624f381f469654d5e3d2
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_PROFILE_MANAGER_CLIENT_H_
6#define CHROMEOS_DBUS_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_
7
8#include <string>
9#include <vector>
10
11#include "base/callback.h"
12#include "base/values.h"
13#include "chromeos/chromeos_export.h"
14#include "chromeos/dbus/dbus_client.h"
15#include "chromeos/dbus/dbus_client_implementation_type.h"
16#include "dbus/object_path.h"
17
18namespace chromeos {
19
20// BluetoothProfileManagerClient is used to communicate with the profile
21// manager object of the Bluetooth daemon.
22class CHROMEOS_EXPORT BluetoothProfileManagerClient : public DBusClient {
23 public:
24  // Species the role of the object within the profile. SYMMETRIC should be
25  // usually used unless the profile requires you specify as a CLIENT or as a
26  // SERVER.
27  enum ProfileRole {
28    SYMMETRIC,
29    CLIENT,
30    SERVER
31  };
32
33  // Options used to register a Profile object.
34  struct CHROMEOS_EXPORT Options {
35    Options();
36    ~Options();
37
38    // Human readable name for the profile.
39    std::string name;
40
41    // Primary service class UUID (if different from the actual UUID)
42    std::string service;
43
44    // Role.
45    enum ProfileRole role;
46
47    // RFCOMM channel number.
48    uint16 channel;
49
50    // PSM number.
51    uint16 psm;
52
53    // Pairing is required before connections will be established.
54    bool require_authentication;
55
56    // Request authorization before connections will be established.
57    bool require_authorization;
58
59    // Force connections when a remote device is connected.
60    bool auto_connect;
61
62    // Manual SDP record.
63    std::string service_record;
64
65    // Profile version.
66    uint16 version;
67
68    // Profile features.
69    uint16 features;
70  };
71
72  virtual ~BluetoothProfileManagerClient();
73
74  // The ErrorCallback is used by adapter methods to indicate failure.
75  // It receives two arguments: the name of the error in |error_name| and
76  // an optional message in |error_message|.
77  typedef base::Callback<void(const std::string& error_name,
78                              const std::string& error_message)> ErrorCallback;
79
80  // Registers a profile implementation within the local process at the
81  // D-bus object path |profile_path| with the remote profile manager.
82  // |uuid| specifies the identifier of the profile and |options| the way in
83  // which the profile is implemented.
84  virtual void RegisterProfile(const dbus::ObjectPath& profile_path,
85                               const std::string& uuid,
86                               const Options& options,
87                               const base::Closure& callback,
88                               const ErrorCallback& error_callback) = 0;
89
90  // Unregisters the profile with the D-Bus object path |agent_path| from the
91  // remote profile manager.
92  virtual void UnregisterProfile(const dbus::ObjectPath& profile_path,
93                                 const base::Closure& callback,
94                                 const ErrorCallback& error_callback) = 0;
95
96
97  // Creates the instance.
98  static BluetoothProfileManagerClient* Create(
99      DBusClientImplementationType type);
100
101  // Constants used to indicate exceptional error conditions.
102  static const char kNoResponseError[];
103
104 protected:
105  BluetoothProfileManagerClient();
106
107 private:
108  DISALLOW_COPY_AND_ASSIGN(BluetoothProfileManagerClient);
109};
110
111}  // namespace chromeos
112
113#endif  // CHROMEOS_DBUS_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_
114