Home | History | Annotate | Download | only in dbus
      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/memory/scoped_ptr.h"
     13 #include "base/values.h"
     14 #include "chromeos/chromeos_export.h"
     15 #include "chromeos/dbus/dbus_client.h"
     16 #include "dbus/object_path.h"
     17 
     18 namespace chromeos {
     19 
     20 // BluetoothProfileManagerClient is used to communicate with the profile
     21 // manager object of the Bluetooth daemon.
     22 class 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     scoped_ptr<std::string> name;
     40 
     41     // Primary service class UUID (if different from the actual UUID)
     42     scoped_ptr<std::string> service;
     43 
     44     // Role.
     45     enum ProfileRole role;
     46 
     47     // RFCOMM channel number.
     48     scoped_ptr<uint16> channel;
     49 
     50     // PSM number.
     51     scoped_ptr<uint16> psm;
     52 
     53     // Pairing is required before connections will be established.
     54     scoped_ptr<bool> require_authentication;
     55 
     56     // Request authorization before connections will be established.
     57     scoped_ptr<bool> require_authorization;
     58 
     59     // Force connections when a remote device is connected.
     60     scoped_ptr<bool> auto_connect;
     61 
     62     // Manual SDP record.
     63     scoped_ptr<std::string> service_record;
     64 
     65     // Profile version.
     66     scoped_ptr<uint16> version;
     67 
     68     // Profile features.
     69     scoped_ptr<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 
    100   // Constants used to indicate exceptional error conditions.
    101   static const char kNoResponseError[];
    102 
    103  protected:
    104   BluetoothProfileManagerClient();
    105 
    106  private:
    107   DISALLOW_COPY_AND_ASSIGN(BluetoothProfileManagerClient);
    108 };
    109 
    110 }  // namespace chromeos
    111 
    112 #endif  // CHROMEOS_DBUS_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_
    113