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