summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/bluetooth_profile_manager_client.h
blob: 8f53412776e568d47b96359aff5d58037da4b19d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_DBUS_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_
#define CHROMEOS_DBUS_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_

#include <string>
#include <vector>

#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client.h"
#include "dbus/object_path.h"

namespace chromeos {

// BluetoothProfileManagerClient is used to communicate with the profile
// manager object of the Bluetooth daemon.
class CHROMEOS_EXPORT BluetoothProfileManagerClient : public DBusClient {
 public:
  // Species the role of the object within the profile. SYMMETRIC should be
  // usually used unless the profile requires you specify as a CLIENT or as a
  // SERVER.
  enum ProfileRole { SYMMETRIC, CLIENT, SERVER };

  // Options used to register a Profile object.
  struct CHROMEOS_EXPORT Options {
    Options();
    ~Options();

    // Human readable name for the profile.
    scoped_ptr<std::string> name;

    // Primary service class UUID (if different from the actual UUID)
    scoped_ptr<std::string> service;

    // Role.
    enum ProfileRole role;

    // RFCOMM channel number.
    scoped_ptr<uint16> channel;

    // PSM number.
    scoped_ptr<uint16> psm;

    // Pairing is required before connections will be established.
    scoped_ptr<bool> require_authentication;

    // Request authorization before connections will be established.
    scoped_ptr<bool> require_authorization;

    // Force connections when a remote device is connected.
    scoped_ptr<bool> auto_connect;

    // Manual SDP record.
    scoped_ptr<std::string> service_record;

    // Profile version.
    scoped_ptr<uint16> version;

    // Profile features.
    scoped_ptr<uint16> features;
  };

  ~BluetoothProfileManagerClient() override;

  // The ErrorCallback is used by adapter methods to indicate failure.
  // It receives two arguments: the name of the error in |error_name| and
  // an optional message in |error_message|.
  typedef base::Callback<void(const std::string& error_name,
                              const std::string& error_message)> ErrorCallback;

  // Registers a profile implementation within the local process at the
  // D-bus object path |profile_path| with the remote profile manager.
  // |uuid| specifies the identifier of the profile and |options| the way in
  // which the profile is implemented.
  virtual void RegisterProfile(const dbus::ObjectPath& profile_path,
                               const std::string& uuid,
                               const Options& options,
                               const base::Closure& callback,
                               const ErrorCallback& error_callback) = 0;

  // Unregisters the profile with the D-Bus object path |agent_path| from the
  // remote profile manager.
  virtual void UnregisterProfile(const dbus::ObjectPath& profile_path,
                                 const base::Closure& callback,
                                 const ErrorCallback& error_callback) = 0;

  // Creates the instance.
  static BluetoothProfileManagerClient* Create();

  // Constants used to indicate exceptional error conditions.
  static const char kNoResponseError[];

 protected:
  BluetoothProfileManagerClient();

 private:
  DISALLOW_COPY_AND_ASSIGN(BluetoothProfileManagerClient);
};

}  // namespace chromeos

#endif  // CHROMEOS_DBUS_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_