Commit 97bb45bb authored by keybuk@chromium.org's avatar keybuk@chromium.org

D-Bus Clients for BlueZ 5 API

Implement the BlueZ 5 D-Bus API in separated clients from the 4.x API
so that we can use them both side-by-side.

BUG=chromium-os:38832
TEST=none


Review URL: https://chromiumcodereview.appspot.com/12605008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190578 0039d316-1c4b-4281-b951-d872f2087c98
parent c76faeaa
...@@ -65,6 +65,18 @@ ...@@ -65,6 +65,18 @@
'dbus/dbus_thread_manager.h', 'dbus/dbus_thread_manager.h',
'dbus/debug_daemon_client.cc', 'dbus/debug_daemon_client.cc',
'dbus/debug_daemon_client.h', 'dbus/debug_daemon_client.h',
'dbus/experimental_bluetooth_adapter_client.cc',
'dbus/experimental_bluetooth_adapter_client.h',
'dbus/experimental_bluetooth_agent_manager_client.cc',
'dbus/experimental_bluetooth_agent_manager_client.h',
'dbus/experimental_bluetooth_agent_service_provider.cc',
'dbus/experimental_bluetooth_agent_service_provider.h',
'dbus/experimental_bluetooth_device_client.cc',
'dbus/experimental_bluetooth_device_client.h',
'dbus/experimental_bluetooth_profile_manager_client.cc',
'dbus/experimental_bluetooth_profile_manager_client.h',
'dbus/experimental_bluetooth_profile_service_provider.cc',
'dbus/experimental_bluetooth_profile_service_provider.h',
'dbus/gsm_sms_client.cc', 'dbus/gsm_sms_client.cc',
'dbus/gsm_sms_client.h', 'dbus/gsm_sms_client.h',
'dbus/shill_client_helper.cc', 'dbus/shill_client_helper.cc',
...@@ -271,6 +283,14 @@ ...@@ -271,6 +283,14 @@
'dbus/mock_dbus_thread_manager.h', 'dbus/mock_dbus_thread_manager.h',
'dbus/mock_debug_daemon_client.cc', 'dbus/mock_debug_daemon_client.cc',
'dbus/mock_debug_daemon_client.h', 'dbus/mock_debug_daemon_client.h',
'dbus/mock_experimental_bluetooth_adapter_client.cc',
'dbus/mock_experimental_bluetooth_adapter_client.h',
'dbus/mock_experimental_bluetooth_agent_manager_client.cc',
'dbus/mock_experimental_bluetooth_agent_manager_client.h',
'dbus/mock_experimental_bluetooth_device_client.cc',
'dbus/mock_experimental_bluetooth_device_client.h',
'dbus/mock_experimental_bluetooth_profile_manager_client.cc',
'dbus/mock_experimental_bluetooth_profile_manager_client.h',
'dbus/mock_shill_device_client.cc', 'dbus/mock_shill_device_client.cc',
'dbus/mock_shill_device_client.h', 'dbus/mock_shill_device_client.h',
'dbus/mock_shill_ipconfig_client.cc', 'dbus/mock_shill_ipconfig_client.cc',
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
#include "chromeos/dbus/dbus_client_implementation_type.h" #include "chromeos/dbus/dbus_client_implementation_type.h"
#include "chromeos/dbus/dbus_thread_manager_observer.h" #include "chromeos/dbus/dbus_thread_manager_observer.h"
#include "chromeos/dbus/debug_daemon_client.h" #include "chromeos/dbus/debug_daemon_client.h"
#include "chromeos/dbus/experimental_bluetooth_adapter_client.h"
#include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h"
#include "chromeos/dbus/experimental_bluetooth_device_client.h"
#include "chromeos/dbus/experimental_bluetooth_profile_manager_client.h"
#include "chromeos/dbus/gsm_sms_client.h" #include "chromeos/dbus/gsm_sms_client.h"
#include "chromeos/dbus/shill_device_client.h" #include "chromeos/dbus/shill_device_client.h"
#include "chromeos/dbus/shill_ipconfig_client.h" #include "chromeos/dbus/shill_ipconfig_client.h"
...@@ -102,6 +106,19 @@ class DBusThreadManagerImpl : public DBusThreadManager { ...@@ -102,6 +106,19 @@ class DBusThreadManagerImpl : public DBusThreadManager {
debug_daemon_client_.reset( debug_daemon_client_.reset(
DebugDaemonClient::Create(client_type_, system_bus_.get())); DebugDaemonClient::Create(client_type_, system_bus_.get()));
experimental_bluetooth_adapter_client_.reset(
ExperimentalBluetoothAdapterClient::Create(
client_type_, system_bus_.get()));
experimental_bluetooth_agent_manager_client_.reset(
ExperimentalBluetoothAgentManagerClient::Create(
client_type_, system_bus_.get()));
experimental_bluetooth_device_client_.reset(
ExperimentalBluetoothDeviceClient::Create(
client_type_, system_bus_.get()));
experimental_bluetooth_profile_manager_client_.reset(
ExperimentalBluetoothProfileManagerClient::Create(
client_type_, system_bus_.get()));
shill_manager_client_.reset( shill_manager_client_.reset(
ShillManagerClient::Create(client_type_override_, system_bus_.get())); ShillManagerClient::Create(client_type_override_, system_bus_.get()));
shill_device_client_.reset( shill_device_client_.reset(
...@@ -257,6 +274,26 @@ class DBusThreadManagerImpl : public DBusThreadManager { ...@@ -257,6 +274,26 @@ class DBusThreadManagerImpl : public DBusThreadManager {
return debug_daemon_client_.get(); return debug_daemon_client_.get();
} }
virtual ExperimentalBluetoothAdapterClient*
GetExperimentalBluetoothAdapterClient() OVERRIDE {
return experimental_bluetooth_adapter_client_.get();
}
virtual ExperimentalBluetoothAgentManagerClient*
GetExperimentalBluetoothAgentManagerClient() OVERRIDE {
return experimental_bluetooth_agent_manager_client_.get();
}
virtual ExperimentalBluetoothDeviceClient*
GetExperimentalBluetoothDeviceClient() OVERRIDE {
return experimental_bluetooth_device_client_.get();
}
virtual ExperimentalBluetoothProfileManagerClient*
GetExperimentalBluetoothProfileManagerClient() OVERRIDE {
return experimental_bluetooth_profile_manager_client_.get();
}
virtual ShillDeviceClient* GetShillDeviceClient() OVERRIDE { virtual ShillDeviceClient* GetShillDeviceClient() OVERRIDE {
return shill_device_client_.get(); return shill_device_client_.get();
} }
...@@ -385,6 +422,14 @@ class DBusThreadManagerImpl : public DBusThreadManager { ...@@ -385,6 +422,14 @@ class DBusThreadManagerImpl : public DBusThreadManager {
scoped_ptr<CrosDisksClient> cros_disks_client_; scoped_ptr<CrosDisksClient> cros_disks_client_;
scoped_ptr<CryptohomeClient> cryptohome_client_; scoped_ptr<CryptohomeClient> cryptohome_client_;
scoped_ptr<DebugDaemonClient> debug_daemon_client_; scoped_ptr<DebugDaemonClient> debug_daemon_client_;
scoped_ptr<ExperimentalBluetoothAdapterClient>
experimental_bluetooth_adapter_client_;
scoped_ptr<ExperimentalBluetoothAgentManagerClient>
experimental_bluetooth_agent_manager_client_;
scoped_ptr<ExperimentalBluetoothDeviceClient>
experimental_bluetooth_device_client_;
scoped_ptr<ExperimentalBluetoothProfileManagerClient>
experimental_bluetooth_profile_manager_client_;
scoped_ptr<ShillDeviceClient> shill_device_client_; scoped_ptr<ShillDeviceClient> shill_device_client_;
scoped_ptr<ShillIPConfigClient> shill_ipconfig_client_; scoped_ptr<ShillIPConfigClient> shill_ipconfig_client_;
scoped_ptr<ShillManagerClient> shill_manager_client_; scoped_ptr<ShillManagerClient> shill_manager_client_;
......
...@@ -35,6 +35,10 @@ class BluetoothOutOfBandClient; ...@@ -35,6 +35,10 @@ class BluetoothOutOfBandClient;
class CrosDisksClient; class CrosDisksClient;
class CryptohomeClient; class CryptohomeClient;
class DebugDaemonClient; class DebugDaemonClient;
class ExperimentalBluetoothAdapterClient;
class ExperimentalBluetoothAgentManagerClient;
class ExperimentalBluetoothDeviceClient;
class ExperimentalBluetoothProfileManagerClient;
class GsmSMSClient; class GsmSMSClient;
class IBusClient; class IBusClient;
class IBusConfigClient; class IBusConfigClient;
...@@ -129,6 +133,14 @@ class CHROMEOS_EXPORT DBusThreadManager { ...@@ -129,6 +133,14 @@ class CHROMEOS_EXPORT DBusThreadManager {
virtual CrosDisksClient* GetCrosDisksClient() = 0; virtual CrosDisksClient* GetCrosDisksClient() = 0;
virtual CryptohomeClient* GetCryptohomeClient() = 0; virtual CryptohomeClient* GetCryptohomeClient() = 0;
virtual DebugDaemonClient* GetDebugDaemonClient() = 0; virtual DebugDaemonClient* GetDebugDaemonClient() = 0;
virtual ExperimentalBluetoothAdapterClient*
GetExperimentalBluetoothAdapterClient() = 0;
virtual ExperimentalBluetoothAgentManagerClient*
GetExperimentalBluetoothAgentManagerClient() = 0;
virtual ExperimentalBluetoothDeviceClient*
GetExperimentalBluetoothDeviceClient() = 0;
virtual ExperimentalBluetoothProfileManagerClient*
GetExperimentalBluetoothProfileManagerClient() = 0;
virtual GsmSMSClient* GetGsmSMSClient() = 0; virtual GsmSMSClient* GetGsmSMSClient() = 0;
virtual IBusClient* GetIBusClient() = 0; virtual IBusClient* GetIBusClient() = 0;
virtual IBusConfigClient* GetIBusConfigClient() = 0; virtual IBusConfigClient* GetIBusConfigClient() = 0;
......
This diff is collapsed.
// Copyright (c) 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_EXPERIMENTAL_BLUETOOTH_ADAPTER_CLIENT_H_
#define CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_ADAPTER_CLIENT_H_
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/observer_list.h"
#include "base/values.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client_implementation_type.h"
#include "dbus/object_path.h"
#include "dbus/property.h"
namespace dbus {
class Bus;
} // namespace dbus
namespace chromeos {
// ExperimentalBluetoothAdapterClient is used to communicate with Bluetooth
// Adapter objects.
class CHROMEOS_EXPORT ExperimentalBluetoothAdapterClient {
public:
// Structure of properties associated with bluetooth adapters.
struct Properties : public dbus::PropertySet {
// The Bluetooth device address of the adapter. Read-only.
dbus::Property<std::string> address;
// The Bluetooth system name, generally derived from the hostname.
dbus::Property<std::string> name;
// The Bluetooth friendly name of the adapter, unlike remote devices,
// this property can be changed to change the presentation for when
// the adapter is discoverable.
dbus::Property<std::string> alias;
// The Bluetooth class of the adapter device. Read-only.
dbus::Property<uint32> bluetooth_class;
// Whether the adapter radio is powered.
dbus::Property<bool> powered;
// Whether the adapter is discoverable by other Bluetooth devices.
// |discovering_timeout| is used to automatically disable after a time
// period.
dbus::Property<bool> discoverable;
// Whether the adapter accepts incoming pairing requests from other
// Bluetooth devices. |pairable_timeout| is used to automatically disable
// after a time period.
dbus::Property<bool> pairable;
// The timeout in seconds to cease accepting incoming pairing requests
// after |pairable| is set to true. Zero means adapter remains pairable
// forever.
dbus::Property<uint32> pairable_timeout;
// The timeout in seconds to cease the adapter being discoverable by
// other Bluetooth devices after |discoverable| is set to true. Zero
// means adapter remains discoverable forever.
dbus::Property<uint32> discoverable_timeout;
// Indicates that the adapter is discovering other Bluetooth Devices.
// Read-only. Use StartDiscovery() to begin discovery.
dbus::Property<bool> discovering;
// List of 128-bit UUIDs that represent the available local services.
// Read-only.
dbus::Property<std::vector<std::string> > uuids;
// Local Device ID information in Linux kernel modalias format. Read-only.
dbus::Property<std::string> modalias;
Properties(dbus::ObjectProxy* object_proxy,
const std::string& interface_name,
const PropertyChangedCallback& callback);
virtual ~Properties();
};
// Interface for observing changes from a local bluetooth adapter.
class Observer {
public:
virtual ~Observer() {}
// Called when the adapter with object path |object_path| is added to the
// system.
virtual void AdapterAdded(const dbus::ObjectPath& object_path) {}
// Called when the adapter with object path |object_path| is removed from
// the system.
virtual void AdapterRemoved(const dbus::ObjectPath& object_path) {}
// Called when the adapter with object path |object_path| has a
// change in value of the property named |property_name|.
virtual void AdapterPropertyChanged(const dbus::ObjectPath& object_path,
const std::string& property_name) {}
};
virtual ~ExperimentalBluetoothAdapterClient();
// Adds and removes observers for events on all local bluetooth
// adapters. Check the |object_path| parameter of observer methods to
// determine which adapter is issuing the event.
virtual void AddObserver(Observer* observer) = 0;
virtual void RemoveObserver(Observer* observer) = 0;
// Returns the list of adapter object paths known to the system.
virtual std::vector<dbus::ObjectPath> GetAdapters() = 0;
// Obtain the properties for the adapter with object path |object_path|,
// any values should be copied if needed.
virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
// 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;
// Starts a device discovery on the adapter with object path |object_path|.
virtual void StartDiscovery(const dbus::ObjectPath& object_path,
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Cancels any previous device discovery on the adapter with object path
// |object_path|.
virtual void StopDiscovery(const dbus::ObjectPath& object_path,
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Removes from the adapter with object path |object_path| the remote
// device with object path |object_path| from the list of known devices
// and discards any pairing information.
virtual void RemoveDevice(const dbus::ObjectPath& object_path,
const dbus::ObjectPath& device_path,
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Creates the instance.
static ExperimentalBluetoothAdapterClient* Create(
DBusClientImplementationType type,
dbus::Bus* bus);
// Constants used to indicate exceptional error conditions.
static const char kNoResponseError[];
static const char kUnknownAdapterError[];
protected:
ExperimentalBluetoothAdapterClient();
private:
DISALLOW_COPY_AND_ASSIGN(ExperimentalBluetoothAdapterClient);
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_ADAPTER_CLIENT_H_
// Copyright (c) 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.
#include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h"
#include "base/bind.h"
#include "base/logging.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace chromeos {
const char ExperimentalBluetoothAgentManagerClient::kNoResponseError[] =
"org.chromium.Error.NoResponse";
// The ExperimentalBluetoothAgentManagerClient implementation used in
// production.
class ExperimentalBluetoothAgentManagerClientImpl
: public ExperimentalBluetoothAgentManagerClient {
public:
explicit ExperimentalBluetoothAgentManagerClientImpl(dbus::Bus* bus)
: bus_(bus),
weak_ptr_factory_(this) {
DCHECK(bus_);
object_proxy_ = bus_->GetObjectProxy(
bluetooth_agent_manager::kBluetoothAgentManagerServiceName,
dbus::ObjectPath(
bluetooth_agent_manager::kExperimentalBluetoothAgentManagerInterface));
}
virtual ~ExperimentalBluetoothAgentManagerClientImpl() {
}
// ExperimentalBluetoothAgentManagerClient override.
virtual void RegisterAgent(const dbus::ObjectPath& agent_path,
const std::string& capability,
const base::Closure& callback,
const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(
bluetooth_agent_manager::kExperimentalBluetoothAgentManagerInterface,
bluetooth_agent_manager::kRegisterAgent);
dbus::MessageWriter writer(&method_call);
writer.AppendObjectPath(agent_path);
writer.AppendString(capability);
object_proxy_->CallMethodWithErrorCallback(
&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&ExperimentalBluetoothAgentManagerClientImpl::OnSuccess,
weak_ptr_factory_.GetWeakPtr(), callback),
base::Bind(&ExperimentalBluetoothAgentManagerClientImpl::OnError,
weak_ptr_factory_.GetWeakPtr(), error_callback));
}
// ExperimentalBluetoothAgentManagerClient override.
virtual void UnregisterAgent(const dbus::ObjectPath& agent_path,
const base::Closure& callback,
const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(
bluetooth_agent_manager::kExperimentalBluetoothAgentManagerInterface,
bluetooth_agent_manager::kUnregisterAgent);
dbus::MessageWriter writer(&method_call);
writer.AppendObjectPath(agent_path);
object_proxy_->CallMethodWithErrorCallback(
&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&ExperimentalBluetoothAgentManagerClientImpl::OnSuccess,
weak_ptr_factory_.GetWeakPtr(), callback),
base::Bind(&ExperimentalBluetoothAgentManagerClientImpl::OnError,
weak_ptr_factory_.GetWeakPtr(), error_callback));
}
// ExperimentalBluetoothAgentManagerClient override.
virtual void RequestDefaultAgent(const dbus::ObjectPath& agent_path,
const base::Closure& callback,
const ErrorCallback& error_callback)
OVERRIDE {
dbus::MethodCall method_call(
bluetooth_agent_manager::kExperimentalBluetoothAgentManagerInterface,
bluetooth_agent_manager::kRequestDefaultAgent);
dbus::MessageWriter writer(&method_call);
writer.AppendObjectPath(agent_path);
object_proxy_->CallMethodWithErrorCallback(
&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&ExperimentalBluetoothAgentManagerClientImpl::OnSuccess,
weak_ptr_factory_.GetWeakPtr(), callback),
base::Bind(&ExperimentalBluetoothAgentManagerClientImpl::OnError,
weak_ptr_factory_.GetWeakPtr(), error_callback));
}
private:
// Called when a response for successful method call is received.
void OnSuccess(const base::Closure& callback,
dbus::Response* response) {
DCHECK(response);
callback.Run();
}
// Called when a response for a failed method call is received.
void OnError(const ErrorCallback& error_callback,
dbus::ErrorResponse* response) {
// Error response has optional error message argument.
std::string error_name;
std::string error_message;
if (response) {
dbus::MessageReader reader(response);
error_name = response->GetErrorName();
reader.PopString(&error_message);
} else {
error_name = kNoResponseError;
error_message = "";
}
error_callback.Run(error_name, error_message);
}
dbus::Bus* bus_;
dbus::ObjectProxy* object_proxy_;
// Weak pointer factory for generating 'this' pointers that might live longer
// than we do.
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
base::WeakPtrFactory<ExperimentalBluetoothAgentManagerClientImpl>
weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ExperimentalBluetoothAgentManagerClientImpl);
};
// The ExperimentalBluetoothAgentManagerClient implementation used on Linux
// desktop, which does nothing.
class ExperimentalBluetoothAgentManagerClientStubImpl
: public ExperimentalBluetoothAgentManagerClient {
public:
ExperimentalBluetoothAgentManagerClientStubImpl() {
}
// ExperimentalBluetoothAgentManagerClient override.
virtual void RegisterAgent(const dbus::ObjectPath& agent_path,
const std::string& capability,
const base::Closure& callback,
const ErrorCallback& error_callback) OVERRIDE {
VLOG(1) << "RegisterAgent: " << agent_path.value();
error_callback.Run(kNoResponseError, "");
}
// ExperimentalBluetoothAgentManagerClient override.
virtual void UnregisterAgent(const dbus::ObjectPath& agent_path,
const base::Closure& callback,
const ErrorCallback& error_callback) OVERRIDE {
VLOG(1) << "UnregisterAgent: " << agent_path.value();
error_callback.Run(kNoResponseError, "");
}
// ExperimentalBluetoothAgentManagerClient override.
virtual void RequestDefaultAgent(const dbus::ObjectPath& agent_path,
const base::Closure& callback,
const ErrorCallback& error_callback)
OVERRIDE {
VLOG(1) << "RequestDefaultAgent: " << agent_path.value();
error_callback.Run(kNoResponseError, "");
}
};
ExperimentalBluetoothAgentManagerClient::
ExperimentalBluetoothAgentManagerClient() {
}
ExperimentalBluetoothAgentManagerClient::
~ExperimentalBluetoothAgentManagerClient() {
}
ExperimentalBluetoothAgentManagerClient*
ExperimentalBluetoothAgentManagerClient::Create(
DBusClientImplementationType type,
dbus::Bus* bus) {
if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
return new ExperimentalBluetoothAgentManagerClientImpl(bus);
DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
return new ExperimentalBluetoothAgentManagerClientStubImpl();
}
} // namespace chromeos
// Copyright (c) 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_EXPERIMENTAL_BLUETOOTH_AGENT_MANAGER_CLIENT_H_
#define CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_AGENT_MANAGER_CLIENT_H_
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/values.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client_implementation_type.h"
#include "dbus/object_path.h"
namespace dbus {
class Bus;
} // namespace dbus
namespace chromeos {
// ExperimentalBluetoothAgentManagerClient is used to communicate with the
// agent manager component of the Bluetooth daemon.
class CHROMEOS_EXPORT ExperimentalBluetoothAgentManagerClient {
public:
virtual ~ExperimentalBluetoothAgentManagerClient();
// The ErrorCallback is used by agent manager 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 an agent within the local process at the D-bus object path
// |agent_path| with the remote agent manager. The agent is used for pairing
// and for authorization of incoming connection requests. |capability|
// specifies the input and display capabilities of the agent and should be
// one of the constants declared in the bluetooth_agent_manager:: namespace.
virtual void RegisterAgent(const dbus::ObjectPath& agent_path,
const std::string& capability,
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Unregisters the agent with the D-Bus object path |agent_path| from the
// remote agent manager.
virtual void UnregisterAgent(const dbus::ObjectPath& agent_path,
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Requests that the agent with the D-Bus object path |agent_path| be made
// the default.
virtual void RequestDefaultAgent(const dbus::ObjectPath& agent_path,
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Creates the instance.
static ExperimentalBluetoothAgentManagerClient* Create(
DBusClientImplementationType type,
dbus::Bus* bus);
// Constants used to indicate exceptional error conditions.
static const char kNoResponseError[];
protected:
ExperimentalBluetoothAgentManagerClient();
private:
DISALLOW_COPY_AND_ASSIGN(ExperimentalBluetoothAgentManagerClient);
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_AGENT_MANAGER_CLIENT_H_
This diff is collapsed.
// Copyright (c) 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_EXPERIMENTAL_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_
#define CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_
#include <string>
#include "base/basictypes.h"
#include "base/callback.h"
#include "chromeos/chromeos_export.h"
#include "dbus/bus.h"
#include "dbus/object_path.h"
namespace chromeos {
// ExperimentalBluetoothAgentServiceProvider is used to provide a D-Bus object
// that BlueZ can communicate with during a remote device pairing request.
//
// Instantiate with a chosen D-Bus object path and delegate object, and pass
// the D-Bus object path as the |agent_path| argument to the
// chromeos::ExperimentalBluetoothAgentManagerClient::RegisterAgent() method.
//
// After initiating the pairing process with a device, using the
// chromeos::ExperimentalBluetoothDeviceClient::Pair() method, the Bluetooth
// daemon will make calls to this agent object and they will be passed on to
// your Delegate object for handling. Responses should be returned using the
// callbacks supplied to those methods.
class CHROMEOS_EXPORT ExperimentalBluetoothAgentServiceProvider {
public:
// Interface for reacting to agent requests.
class Delegate {
public:
virtual ~Delegate() {}
// Possible status values that may be returned to callbacks. Success
// indicates that a pincode or passkey has been obtained, or permission
// granted; rejected indicates the user rejected the request or denied
// permission; cancelled indicates the user cancelled the request
// without confirming either way.
enum Status {
SUCCESS,
REJECTED,
CANCELLED
};
// The PinCodeCallback is used for the RequestPinCode() method, it should
// be called with two arguments, the |status| of the request (success,
// rejected or cancelled) and the |pincode| requested.
typedef base::Callback<void(Status, const std::string&)> PinCodeCallback;
// The PasskeyCallback is used for the RequestPasskey() method, it should
// be called with two arguments, the |status| of the request (success,
// rejected or cancelled) and the |passkey| requested, a numeric in the
// range 0-999999,
typedef base::Callback<void(Status, uint32)> PasskeyCallback;
// The ConfirmationCallback is used for methods which request confirmation
// or authorization, it should be called with one argument, the |status|
// of the request (success, rejected or cancelled).
typedef base::Callback<void(Status)> ConfirmationCallback;
// This method will be called when the agent is unregistered from the
// Bluetooth daemon, generally at the end of a pairing request. It may be
// used to perform cleanup tasks.
virtual void Release() = 0;
// This method will be called when the Bluetooth daemon requires a
// PIN Code for authentication of the device with object path |device_path|,
// the agent should obtain the code from the user and call |callback|
// to provide it, or indicate rejection or cancellation of the request.
//
// PIN Codes are generally required for Bluetooth 2.0 and earlier devices
// for which there is no automatic pairing or special handling.
virtual void RequestPinCode(const dbus::ObjectPath& device_path,
const PinCodeCallback& callback) = 0;
// This method will be called when the Bluetooth daemon requires that the
// user enter the PIN code |pincode| into the device with object path
// |device_path| so that it may be authenticated. The Cancel() method
// will be called to dismiss the display once pairing is complete or
// cancelled.
//
// This is used for Bluetooth 2.0 and earlier keyboard devices, the
// |pincode| will always be a six-digit numeric in the range 000000-999999
// for compatibilty with later specifications.
virtual void DisplayPinCode(const dbus::ObjectPath& device_path,
const std::string& pincode) = 0;
// This method will be called when the Bluetooth daemon requires a
// Passkey for authentication of the device with object path |device_path|,
// the agent should obtain the passkey from the user (a numeric in the
// range 0-999999) and call |callback| to provide it, or indicate
// rejection or cancellation of the request.
//
// Passkeys are generally required for Bluetooth 2.1 and later devices
// which cannot provide input or display on their own, and don't accept
// passkey-less pairing.
virtual void RequestPasskey(const dbus::ObjectPath& device_path,
const PasskeyCallback& callback) = 0;
// This method will be called when the Bluetooth daemon requires that the
// user enter the Passkey |passkey| into the device with object path
// |device_path| so that it may be authenticated. The Cancel() method
// will be called to dismiss the display once pairing is complete or
// cancelled.
//
// This is used for Bluetooth 2.1 and later devices that support input
// but not display, such as keyboards. The Passkey is a numeric in the
// range 0-999999 and should be always presented zero-padded to six
// digits.
//
// As the user enters the passkey onto the device, |entered| will be
// updated to reflect the number of digits entered so far.
virtual void DisplayPasskey(const dbus::ObjectPath& device_path,
uint32 passkey, int16 entered) = 0;
// This method will be called when the Bluetooth daemon requires that the
// user confirm that the Passkey |passkey| is displayed on the screen
// of the device with object path |object_path| so that it may be
// authenticated. The agent should display to the user and ask for
// confirmation, then call |callback| to provide their response (success,
// rejected or cancelled).
//
// This is used for Bluetooth 2.1 and later devices that support display,
// such as other computers or phones. The Passkey is a numeric in the
// range 0-999999 and should be always present zero-padded to six
// digits.
virtual void RequestConfirmation(const dbus::ObjectPath& device_path,
uint32 passkey,
const ConfirmationCallback& callback) = 0;
// This method will be called when the Bluetooth daemon requires
// authorization of an incoming pairing attempt from the device with object
// path |device_path| that would have otherwised triggered the just-works
// pairing model.
//
// The agent should confirm the incoming pairing with the user and call
// |callback| to provide their response (success, rejected or cancelled).
virtual void RequestAuthorization(const dbus::ObjectPath& device_path,
const ConfirmationCallback& callback) = 0;
// This method will be called when the Bluetooth daemon requires that the
// user confirm that the device with object path |object_path| is
// authorized to connect to the service with UUID |uuid|. The agent should
// confirm with the user and call |callback| to provide their response
// (success, rejected or cancelled).
virtual void AuthorizeService(const dbus::ObjectPath& device_path,
const std::string& uuid,
const ConfirmationCallback& callback) = 0;
// This method will be called by the Bluetooth daemon to indicate that
// the request failed before a reply was returned from the device.
virtual void Cancel() = 0;
};
virtual ~ExperimentalBluetoothAgentServiceProvider();
// Creates the instance where |bus| is the D-Bus bus connection to export
// the object onto, |object_path| is the object path that it should have
// and |delegate| is the object to which all method calls will be passed
// and responses generated from.
static ExperimentalBluetoothAgentServiceProvider* Create(
dbus::Bus* bus, const dbus::ObjectPath& object_path, Delegate* delegate);
protected:
ExperimentalBluetoothAgentServiceProvider();
private:
DISALLOW_COPY_AND_ASSIGN(ExperimentalBluetoothAgentServiceProvider);
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_
This diff is collapsed.
// Copyright (c) 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_EXPERIMENTAL_BLUETOOTH_DEVICE_CLIENT_H_
#define CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_DEVICE_CLIENT_H_
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/observer_list.h"
#include "base/values.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client_implementation_type.h"
#include "dbus/object_path.h"
#include "dbus/property.h"
namespace dbus {
class Bus;
} // namespace dbus
namespace chromeos {
// ExperimentalBluetoothDeviceClient is used to communicate with Bluetooth
// Device objects.
class CHROMEOS_EXPORT ExperimentalBluetoothDeviceClient {
public:
// Structure of properties associated with bluetooth devices.
struct Properties : public dbus::PropertySet {
// The Bluetooth device address of the device. Read-only.
dbus::Property<std::string> address;
// The Bluetooth friendly name of the device. Read-only, to give a
// different local name, use the |alias| property.
dbus::Property<std::string> name;
// Proposed icon name for the device according to the freedesktop.org
// icon naming specification. Read-only.
dbus::Property<std::string> icon;
// The Bluetooth class of the device. Read-only.
dbus::Property<uint32> bluetooth_class;
// The GAP external appearance of the device. Read-only.
dbus::Property<uint16> appearance;
// Unique numeric identifier for the vendor of the device. Read-only.
dbus::Property<uint16> vendor;
// List of 128-bit UUIDs that represent the available remote services.
// Read-only.
dbus::Property<std::vector<std::string> > uuids;
// Indicates that the device is currently paired. Read-only.
dbus::Property<bool> paired;
// Indicates that the device is currently connected. Read-only.
dbus::Property<bool> connected;
// Whether the device is trusted, and connections should be always
// accepted and attempted when the device is visible.
dbus::Property<bool> trusted;
// Whether the device is blocked, connections will be always rejected
// and the device will not be visible.
dbus::Property<bool> blocked;
// Local alias for the device, if not set, is equal to |name|.
dbus::Property<std::string> alias;
// Object path of the adapter the device belongs to. Read-only.
dbus::Property<dbus::ObjectPath> adapter;
// Indicates whether the device is likely to only support pre-2.1
// PIN Code pairing rather than 2.1 Secure Simple Pairing, this can
// give false positives. Read-only.
dbus::Property<bool> legacy_pairing;
// Remote Device ID information in Linux kernel modalias format. Read-only.
dbus::Property<std::string> modalias;
// Received signal strength indicator. Read-only.
dbus::Property<int16> rssi;
Properties(dbus::ObjectProxy* object_proxy,
const std::string& interface_name,
const PropertyChangedCallback& callback);
virtual ~Properties();
};
// Interface for observing changes from a remote bluetooth device.
class Observer {
public:
virtual ~Observer() {}
// Called when the remote device with object path |object_path| is added
// to the set of known devices.
virtual void DeviceAdded(const dbus::ObjectPath& object_path) {}
// Called when the remote device with object path |object_path| is removed
// from the set of known devices.
virtual void DeviceRemoved(const dbus::ObjectPath& object_path) {}
// Called when the device with object path |object_path| has a
// change in value of the property named |property_name|.
virtual void DevicePropertyChanged(const dbus::ObjectPath& object_path,
const std::string& property_name) {}
};
virtual ~ExperimentalBluetoothDeviceClient();
// Adds and removes observers for events on all remote bluetooth
// devices. Check the |object_path| parameter of observer methods to
// determine which device is issuing the event.
virtual void AddObserver(Observer* observer) = 0;
virtual void RemoveObserver(Observer* observer) = 0;
// Returns the list of device object paths associated with the given adapter
// identified by the D-Bus object path |adapter_path|.
virtual std::vector<dbus::ObjectPath> GetDevicesForAdapter(
const dbus::ObjectPath& adapter_path) = 0;
// Obtain the properties for the device with object path |object_path|,
// any values should be copied if needed.
virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
// The ErrorCallback is used by device 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;
// Connects to the device with object path |object_path|, connecting any
// profiles that can be connected to and have been flagged as auto-connected;
// may be used to connect additional profiles for an already connected device,
// and succeeds if at least one profile is connected.
virtual void Connect(const dbus::ObjectPath& object_path,
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Disconnects the device with object path |object_path|, terminating
// the low-level ACL connection and any profiles using it.
virtual void Disconnect(const dbus::ObjectPath& object_path,
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Connects to the profile |uuid| on the device with object path
// |object_path|, provided that the profile has been registered with a
// handler on the local device.
virtual void ConnectProfile(const dbus::ObjectPath& object_path,
const std::string& uuid,
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Disconnects from the profile |uuid| on the device with object path
// |object_path|.
virtual void DisconnectProfile(const dbus::ObjectPath& object_path,
const std::string& uuid,
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Initiates pairing with the device with object path |object_path| and
// retrieves all SDP records or GATT primary services. An agent must be
// registered to handle the pairing request.
virtual void Pair(const dbus::ObjectPath& object_path,
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Cancels an in-progress pairing with the device with object path
// |object_path| initiated by Pair().
virtual void CancelPairing(const dbus::ObjectPath& object_path,
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Creates the instance.
static ExperimentalBluetoothDeviceClient* Create(
DBusClientImplementationType type,
dbus::Bus* bus);
// Constants used to indicate exceptional error conditions.
static const char kNoResponseError[];
static const char kUnknownDeviceError[];
protected:
ExperimentalBluetoothDeviceClient();
private:
DISALLOW_COPY_AND_ASSIGN(ExperimentalBluetoothDeviceClient);
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_DEVICE_CLIENT_H_
This diff is collapsed.
// Copyright (c) 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_EXPERIMENTAL_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_
#define CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/values.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client_implementation_type.h"
#include "dbus/object_path.h"
namespace dbus {
class Bus;
} // namespace dbus
namespace chromeos {
// ExperimentalBluetoothProfileManagerClient is used to communicate with
// Bluetooth profile manager objects.
class CHROMEOS_EXPORT ExperimentalBluetoothProfileManagerClient {
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.
std::string name;
// Primary service class UUID (if different from the actual UUID)
std::string service;
// Role.
enum ProfileRole role;
// RFCOMM channel number.
uint16 channel;
// PSM number.
uint16 psm;
// Pairing is required before connections will be established.
bool require_authentication;
// Request authorization before connections will be established.
bool require_authorization;
// Force connections when a remote device is connected.
bool auto_connect;
// Manual SDP record.
std::string service_record;
// Profile version.
uint16 version;
// Profile features.
uint16 features;
};
virtual ~ExperimentalBluetoothProfileManagerClient();
// 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 ExperimentalBluetoothProfileManagerClient* Create(
DBusClientImplementationType type,
dbus::Bus* bus);
// Constants used to indicate exceptional error conditions.
static const char kNoResponseError[];
protected:
ExperimentalBluetoothProfileManagerClient();
private:
DISALLOW_COPY_AND_ASSIGN(ExperimentalBluetoothProfileManagerClient);
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_
// Copyright (c) 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_EXPERIMENTAL_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_
#define CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_
#include <string>
#include "base/basictypes.h"
#include "base/callback.h"
#include "chromeos/chromeos_export.h"
#include "dbus/bus.h"
#include "dbus/file_descriptor.h"
#include "dbus/object_path.h"
namespace chromeos {
// ExperimentalBluetoothProfileServiceProvider is used to provide a D-Bus
// object that BlueZ can communicate with to connect application profiles.
//
// Instantiate with a chosen D-Bus object path and delegate object, and pass
// the D-Bus object path as the |agent_path| argument to the
// chromeos::ExperimentalBluetoothProfileManagerClient::RegisterProfile()
// method.
//
// When an incoming profile connection occurs, or after initiating a connection
// using the chromeos::ExperimentalBluetoothDeviceClient::ConnectProfile()
// method, the Bluetooth daemon will make calls to this profile object and they
// will be passed on to your Delegate object for handling. Responses should be
// returned using the callbacks supplied to those methods.
class CHROMEOS_EXPORT ExperimentalBluetoothProfileServiceProvider {
public:
// Interface for reacting to profile requests.
class Delegate {
public:
virtual ~Delegate() {}
// Possible status values that may be returned to callbacks on a new
// connection or a requested disconnection. Success indicates acceptance,
// reject indicates the user rejected or denied the request; cancelled
// means the user cancelled the request without confirming either way.
enum Status {
SUCCESS,
REJECTED,
CANCELLED
};
// Connection-specific options.
struct CHROMEOS_EXPORT Options {
Options() {}
~Options() {}
// Profile version.
uint16 version;
// Profile features.
uint16 features;
};
// The ConfirmationCallback is used for methods which require confirmation;
// it should be called with one argument, the |status| of the request
// (success, rejected or cancelled).
typedef base::Callback<void(Status)> ConfirmationCallback;
// This method will be called when the profile is unregistered from the
// Bluetooth daemon, generally at shutdown or at the applications' request.
// It may be used to perform cleanup tasks.
virtual void Release() = 0;
// This method will be called when a profile connection to the device
// with object path |device_path| is established. |callback| must be called
// to confirm the connection, or indicate rejection or cancellation.
//
// A file descriptor for the connection socket is provided in |fd|, and
// details about the specific implementation of the profile in |options|.
// The delegate should take the value and ownership
// The file descriptor is owned by the delegate after this call so must be
// cleaned up if the connection is cancelled or rejected, the |options|
// structure is not so information out of it must be copied if required.
virtual void NewConnection(const dbus::ObjectPath& device_path,
dbus::FileDescriptor* fd,
const Options& options,
const ConfirmationCallback& callback) = 0;
// This method will be called when a profile connection to the device
// with object path |device_path| is disconnected. Any file descriptors
// owned by the service should be cleaned up and |callback| called to
// confirm, or indicate rejection or cancellation of the disconnection.
virtual void RequestDisconnection(const dbus::ObjectPath& device_path,
const ConfirmationCallback& callback) = 0;
// This method will be called by the Bluetooth daemon to indicate that
// a profile request failed before a reply was returned from the device.
virtual void Cancel() = 0;
};
virtual ~ExperimentalBluetoothProfileServiceProvider();
// Creates the instance where |bus| is the D-Bus bus connection to export
// the object onto, |object_path| is the object path that it should have
// and |delegate| is the object to which all method calls will be passed
// and responses generated from.
static ExperimentalBluetoothProfileServiceProvider* Create(
dbus::Bus* bus, const dbus::ObjectPath& object_path, Delegate* delegate);
protected:
ExperimentalBluetoothProfileServiceProvider();
private:
DISALLOW_COPY_AND_ASSIGN(ExperimentalBluetoothProfileServiceProvider);
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
#include "chromeos/dbus/mock_cros_disks_client.h" #include "chromeos/dbus/mock_cros_disks_client.h"
#include "chromeos/dbus/mock_cryptohome_client.h" #include "chromeos/dbus/mock_cryptohome_client.h"
#include "chromeos/dbus/mock_debug_daemon_client.h" #include "chromeos/dbus/mock_debug_daemon_client.h"
#include "chromeos/dbus/mock_experimental_bluetooth_adapter_client.h"
#include "chromeos/dbus/mock_experimental_bluetooth_agent_manager_client.h"
#include "chromeos/dbus/mock_experimental_bluetooth_device_client.h"
#include "chromeos/dbus/mock_experimental_bluetooth_profile_manager_client.h"
#include "chromeos/dbus/mock_shill_device_client.h" #include "chromeos/dbus/mock_shill_device_client.h"
#include "chromeos/dbus/mock_shill_ipconfig_client.h" #include "chromeos/dbus/mock_shill_ipconfig_client.h"
#include "chromeos/dbus/mock_shill_manager_client.h" #include "chromeos/dbus/mock_shill_manager_client.h"
...@@ -48,6 +52,14 @@ MockDBusThreadManager::MockDBusThreadManager() ...@@ -48,6 +52,14 @@ MockDBusThreadManager::MockDBusThreadManager()
mock_cros_disks_client_(new MockCrosDisksClient), mock_cros_disks_client_(new MockCrosDisksClient),
mock_cryptohome_client_(new MockCryptohomeClient), mock_cryptohome_client_(new MockCryptohomeClient),
mock_debugdaemon_client_(new MockDebugDaemonClient), mock_debugdaemon_client_(new MockDebugDaemonClient),
mock_experimental_bluetooth_adapter_client_(
new MockExperimentalBluetoothAdapterClient),
mock_experimental_bluetooth_agent_manager_client_(
new MockExperimentalBluetoothAgentManagerClient),
mock_experimental_bluetooth_device_client_(
new MockExperimentalBluetoothDeviceClient),
mock_experimental_bluetooth_profile_manager_client_(
new MockExperimentalBluetoothProfileManagerClient),
mock_shill_device_client_(new MockShillDeviceClient), mock_shill_device_client_(new MockShillDeviceClient),
mock_shill_ipconfig_client_(new MockShillIPConfigClient), mock_shill_ipconfig_client_(new MockShillIPConfigClient),
mock_shill_manager_client_(new MockShillManagerClient), mock_shill_manager_client_(new MockShillManagerClient),
...@@ -81,6 +93,16 @@ MockDBusThreadManager::MockDBusThreadManager() ...@@ -81,6 +93,16 @@ MockDBusThreadManager::MockDBusThreadManager()
.WillRepeatedly(Return(mock_cryptohome_client())); .WillRepeatedly(Return(mock_cryptohome_client()));
EXPECT_CALL(*this, GetDebugDaemonClient()) EXPECT_CALL(*this, GetDebugDaemonClient())
.WillRepeatedly(Return(mock_debugdaemon_client())); .WillRepeatedly(Return(mock_debugdaemon_client()));
EXPECT_CALL(*this, GetExperimentalBluetoothAdapterClient())
.WillRepeatedly(Return(mock_experimental_bluetooth_adapter_client()));
EXPECT_CALL(*this, GetExperimentalBluetoothAgentManagerClient())
.WillRepeatedly(Return(
mock_experimental_bluetooth_agent_manager_client()));
EXPECT_CALL(*this, GetExperimentalBluetoothDeviceClient())
.WillRepeatedly(Return(mock_experimental_bluetooth_device_client()));
EXPECT_CALL(*this, GetExperimentalBluetoothProfileManagerClient())
.WillRepeatedly(Return(
mock_experimental_bluetooth_profile_manager_client()));
EXPECT_CALL(*this, GetShillDeviceClient()) EXPECT_CALL(*this, GetShillDeviceClient())
.WillRepeatedly(Return(mock_shill_device_client())); .WillRepeatedly(Return(mock_shill_device_client()));
EXPECT_CALL(*this, GetShillIPConfigClient()) EXPECT_CALL(*this, GetShillIPConfigClient())
...@@ -173,6 +195,18 @@ MockDBusThreadManager::MockDBusThreadManager() ...@@ -173,6 +195,18 @@ MockDBusThreadManager::MockDBusThreadManager()
.Times(AnyNumber()); .Times(AnyNumber());
EXPECT_CALL(*mock_bluetooth_node_client_.get(), RemoveObserver(_)) EXPECT_CALL(*mock_bluetooth_node_client_.get(), RemoveObserver(_))
.Times(AnyNumber()); .Times(AnyNumber());
EXPECT_CALL(*mock_experimental_bluetooth_adapter_client_.get(),
AddObserver(_))
.Times(AnyNumber());
EXPECT_CALL(*mock_experimental_bluetooth_adapter_client_.get(),
RemoveObserver(_))
.Times(AnyNumber());
EXPECT_CALL(*mock_experimental_bluetooth_device_client_.get(),
AddObserver(_))
.Times(AnyNumber());
EXPECT_CALL(*mock_experimental_bluetooth_device_client_.get(),
RemoveObserver(_))
.Times(AnyNumber());
// Called from PowerMenuButton ctor. // Called from PowerMenuButton ctor.
EXPECT_CALL(*mock_power_manager_client_.get(), RequestStatusUpdate(_)) EXPECT_CALL(*mock_power_manager_client_.get(), RequestStatusUpdate(_))
......
...@@ -29,6 +29,10 @@ class MockBluetoothOutOfBandClient; ...@@ -29,6 +29,10 @@ class MockBluetoothOutOfBandClient;
class MockCrosDisksClient; class MockCrosDisksClient;
class MockCryptohomeClient; class MockCryptohomeClient;
class MockDebugDaemonClient; class MockDebugDaemonClient;
class MockExperimentalBluetoothAdapterClient;
class MockExperimentalBluetoothAgentManagerClient;
class MockExperimentalBluetoothDeviceClient;
class MockExperimentalBluetoothProfileManagerClient;
class MockShillDeviceClient; class MockShillDeviceClient;
class MockShillIPConfigClient; class MockShillIPConfigClient;
class MockShillManagerClient; class MockShillManagerClient;
...@@ -69,6 +73,14 @@ class MockDBusThreadManager : public DBusThreadManager { ...@@ -69,6 +73,14 @@ class MockDBusThreadManager : public DBusThreadManager {
MOCK_METHOD0(GetCrosDisksClient, CrosDisksClient*(void)); MOCK_METHOD0(GetCrosDisksClient, CrosDisksClient*(void));
MOCK_METHOD0(GetCryptohomeClient, CryptohomeClient*(void)); MOCK_METHOD0(GetCryptohomeClient, CryptohomeClient*(void));
MOCK_METHOD0(GetDebugDaemonClient, DebugDaemonClient*(void)); MOCK_METHOD0(GetDebugDaemonClient, DebugDaemonClient*(void));
MOCK_METHOD0(GetExperimentalBluetoothAdapterClient,
ExperimentalBluetoothAdapterClient*(void));
MOCK_METHOD0(GetExperimentalBluetoothAgentManagerClient,
ExperimentalBluetoothAgentManagerClient*(void));
MOCK_METHOD0(GetExperimentalBluetoothDeviceClient,
ExperimentalBluetoothDeviceClient*(void));
MOCK_METHOD0(GetExperimentalBluetoothProfileManagerClient,
ExperimentalBluetoothProfileManagerClient*(void));
MOCK_METHOD0(GetShillDeviceClient, ShillDeviceClient*(void)); MOCK_METHOD0(GetShillDeviceClient, ShillDeviceClient*(void));
MOCK_METHOD0(GetShillIPConfigClient, ShillIPConfigClient*(void)); MOCK_METHOD0(GetShillIPConfigClient, ShillIPConfigClient*(void));
MOCK_METHOD0(GetShillManagerClient, ShillManagerClient*(void)); MOCK_METHOD0(GetShillManagerClient, ShillManagerClient*(void));
...@@ -122,6 +134,22 @@ class MockDBusThreadManager : public DBusThreadManager { ...@@ -122,6 +134,22 @@ class MockDBusThreadManager : public DBusThreadManager {
MockDebugDaemonClient* mock_debugdaemon_client() { MockDebugDaemonClient* mock_debugdaemon_client() {
return mock_debugdaemon_client_.get(); return mock_debugdaemon_client_.get();
} }
MockExperimentalBluetoothAdapterClient*
mock_experimental_bluetooth_adapter_client() {
return mock_experimental_bluetooth_adapter_client_.get();
}
MockExperimentalBluetoothAgentManagerClient*
mock_experimental_bluetooth_agent_manager_client() {
return mock_experimental_bluetooth_agent_manager_client_.get();
}
MockExperimentalBluetoothDeviceClient*
mock_experimental_bluetooth_device_client() {
return mock_experimental_bluetooth_device_client_.get();
}
MockExperimentalBluetoothProfileManagerClient*
mock_experimental_bluetooth_profile_manager_client() {
return mock_experimental_bluetooth_profile_manager_client_.get();
}
MockShillDeviceClient* mock_shill_device_client() { MockShillDeviceClient* mock_shill_device_client() {
return mock_shill_device_client_.get(); return mock_shill_device_client_.get();
} }
...@@ -182,6 +210,14 @@ class MockDBusThreadManager : public DBusThreadManager { ...@@ -182,6 +210,14 @@ class MockDBusThreadManager : public DBusThreadManager {
scoped_ptr<MockCrosDisksClient> mock_cros_disks_client_; scoped_ptr<MockCrosDisksClient> mock_cros_disks_client_;
scoped_ptr<MockCryptohomeClient> mock_cryptohome_client_; scoped_ptr<MockCryptohomeClient> mock_cryptohome_client_;
scoped_ptr<MockDebugDaemonClient> mock_debugdaemon_client_; scoped_ptr<MockDebugDaemonClient> mock_debugdaemon_client_;
scoped_ptr<MockExperimentalBluetoothAdapterClient>
mock_experimental_bluetooth_adapter_client_;
scoped_ptr<MockExperimentalBluetoothAgentManagerClient>
mock_experimental_bluetooth_agent_manager_client_;
scoped_ptr<MockExperimentalBluetoothDeviceClient>
mock_experimental_bluetooth_device_client_;
scoped_ptr<MockExperimentalBluetoothProfileManagerClient>
mock_experimental_bluetooth_profile_manager_client_;
scoped_ptr<MockShillDeviceClient> mock_shill_device_client_; scoped_ptr<MockShillDeviceClient> mock_shill_device_client_;
scoped_ptr<MockShillIPConfigClient> mock_shill_ipconfig_client_; scoped_ptr<MockShillIPConfigClient> mock_shill_ipconfig_client_;
scoped_ptr<MockShillManagerClient> mock_shill_manager_client_; scoped_ptr<MockShillManagerClient> mock_shill_manager_client_;
......
...@@ -97,6 +97,32 @@ DebugDaemonClient* MockDBusThreadManagerWithoutGMock::GetDebugDaemonClient() { ...@@ -97,6 +97,32 @@ DebugDaemonClient* MockDBusThreadManagerWithoutGMock::GetDebugDaemonClient() {
return NULL; return NULL;
} }
ExperimentalBluetoothAdapterClient*
MockDBusThreadManagerWithoutGMock::GetExperimentalBluetoothAdapterClient() {
NOTIMPLEMENTED();
return NULL;
}
ExperimentalBluetoothAgentManagerClient*
MockDBusThreadManagerWithoutGMock::
GetExperimentalBluetoothAgentManagerClient() {
NOTIMPLEMENTED();
return NULL;
}
ExperimentalBluetoothDeviceClient*
MockDBusThreadManagerWithoutGMock::GetExperimentalBluetoothDeviceClient() {
NOTIMPLEMENTED();
return NULL;
}
ExperimentalBluetoothProfileManagerClient*
MockDBusThreadManagerWithoutGMock::
GetExperimentalBluetoothProfileManagerClient() {
NOTIMPLEMENTED();
return NULL;
}
ShillDeviceClient* ShillDeviceClient*
MockDBusThreadManagerWithoutGMock::GetShillDeviceClient() { MockDBusThreadManagerWithoutGMock::GetShillDeviceClient() {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
......
...@@ -49,6 +49,14 @@ class MockDBusThreadManagerWithoutGMock : public DBusThreadManager { ...@@ -49,6 +49,14 @@ class MockDBusThreadManagerWithoutGMock : public DBusThreadManager {
virtual CrosDisksClient* GetCrosDisksClient() OVERRIDE; virtual CrosDisksClient* GetCrosDisksClient() OVERRIDE;
virtual CryptohomeClient* GetCryptohomeClient() OVERRIDE; virtual CryptohomeClient* GetCryptohomeClient() OVERRIDE;
virtual DebugDaemonClient* GetDebugDaemonClient() OVERRIDE; virtual DebugDaemonClient* GetDebugDaemonClient() OVERRIDE;
virtual ExperimentalBluetoothAdapterClient*
GetExperimentalBluetoothAdapterClient() OVERRIDE;
virtual ExperimentalBluetoothAgentManagerClient*
GetExperimentalBluetoothAgentManagerClient() OVERRIDE;
virtual ExperimentalBluetoothDeviceClient*
GetExperimentalBluetoothDeviceClient() OVERRIDE;
virtual ExperimentalBluetoothProfileManagerClient*
GetExperimentalBluetoothProfileManagerClient() OVERRIDE;
virtual ShillDeviceClient* GetShillDeviceClient() OVERRIDE; virtual ShillDeviceClient* GetShillDeviceClient() OVERRIDE;
virtual ShillIPConfigClient* GetShillIPConfigClient() OVERRIDE; virtual ShillIPConfigClient* GetShillIPConfigClient() OVERRIDE;
virtual ShillManagerClient* GetShillManagerClient() OVERRIDE; virtual ShillManagerClient* GetShillManagerClient() OVERRIDE;
......
// Copyright (c) 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.
#include "chromeos/dbus/mock_experimental_bluetooth_adapter_client.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace chromeos {
MockExperimentalBluetoothAdapterClient::Properties::Properties()
: ExperimentalBluetoothAdapterClient::Properties::Properties(
NULL,
bluetooth_adapter::kExperimentalBluetoothAdapterInterface,
PropertyChangedCallback()) {}
MockExperimentalBluetoothAdapterClient::Properties::~Properties() {}
MockExperimentalBluetoothAdapterClient::
MockExperimentalBluetoothAdapterClient() {}
MockExperimentalBluetoothAdapterClient::
~MockExperimentalBluetoothAdapterClient() {}
} // namespace chromeos
// Copyright (c) 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_MOCK_EXPERIMENTAL_BLUETOOTH_ADAPTER_CLIENT_H_
#define CHROMEOS_DBUS_MOCK_EXPERIMENTAL_BLUETOOTH_ADAPTER_CLIENT_H_
#include <string>
#include "chromeos/dbus/experimental_bluetooth_adapter_client.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace chromeos {
class MockExperimentalBluetoothAdapterClient
: public ExperimentalBluetoothAdapterClient {
public:
struct Properties : public ExperimentalBluetoothAdapterClient::Properties {
Properties();
virtual ~Properties();
MOCK_METHOD0(ConnectSignals, void());
MOCK_METHOD2(Get, void(dbus::PropertyBase* property,
dbus::PropertySet::GetCallback callback));
MOCK_METHOD0(GetAll, void());
MOCK_METHOD2(Set, void(dbus::PropertyBase* property,
dbus::PropertySet::SetCallback callback));
MOCK_METHOD1(ChangedReceived, void(dbus::Signal*));
};
MockExperimentalBluetoothAdapterClient();
virtual ~MockExperimentalBluetoothAdapterClient();
MOCK_METHOD1(AddObserver, void(Observer*));
MOCK_METHOD1(RemoveObserver, void(Observer*));
MOCK_METHOD0(GetAdapters, std::vector<dbus::ObjectPath>());
MOCK_METHOD1(GetProperties, Properties*(const dbus::ObjectPath&));
MOCK_METHOD3(StartDiscovery, void(const dbus::ObjectPath&,
const base::Closure&,
const ErrorCallback&));
MOCK_METHOD3(StopDiscovery, void(const dbus::ObjectPath&,
const base::Closure&,
const ErrorCallback&));
MOCK_METHOD4(RemoveDevice, void(const dbus::ObjectPath&,
const dbus::ObjectPath&,
const base::Closure&,
const ErrorCallback&));
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_MOCK_EXPERIMENTAL_BLUETOOTH_ADAPTER_CLIENT_H_
// Copyright (c) 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.
#include "chromeos/dbus/mock_experimental_bluetooth_agent_manager_client.h"
namespace chromeos {
MockExperimentalBluetoothAgentManagerClient::
MockExperimentalBluetoothAgentManagerClient() {}
MockExperimentalBluetoothAgentManagerClient::
~MockExperimentalBluetoothAgentManagerClient() {}
} // namespace chromeos
// Copyright (c) 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_MOCK_EXPERIMENTAL_BLUETOOTH_AGENT_MANAGER_CLIENT_H_
#define CHROMEOS_DBUS_MOCK_EXPERIMENTAL_BLUETOOTH_AGENT_MANAGER_CLIENT_H_
#include <string>
#include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace chromeos {
class MockExperimentalBluetoothAgentManagerClient
: public ExperimentalBluetoothAgentManagerClient {
public:
MockExperimentalBluetoothAgentManagerClient();
virtual ~MockExperimentalBluetoothAgentManagerClient();
MOCK_METHOD4(RegisterAgent, void(const dbus::ObjectPath&,
const std::string&,
const base::Closure&,
const ErrorCallback&));
MOCK_METHOD3(UnregisterAgent, void(const dbus::ObjectPath&,
const base::Closure&,
const ErrorCallback&));
MOCK_METHOD3(RequestDefaultAgent, void(const dbus::ObjectPath&,
const base::Closure&,
const ErrorCallback&));
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_MOCK_EXPERIMENTAL_BLUETOOTH_AGENT_MANAGER_CLIENT_H_
// Copyright (c) 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.
#include "chromeos/dbus/mock_experimental_bluetooth_device_client.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace chromeos {
MockExperimentalBluetoothDeviceClient::Properties::Properties()
: ExperimentalBluetoothDeviceClient::Properties::Properties(
NULL,
bluetooth_device::kExperimentalBluetoothDeviceInterface,
PropertyChangedCallback()) {}
MockExperimentalBluetoothDeviceClient::Properties::~Properties() {}
MockExperimentalBluetoothDeviceClient::
MockExperimentalBluetoothDeviceClient() {}
MockExperimentalBluetoothDeviceClient::
~MockExperimentalBluetoothDeviceClient() {}
} // namespace chromeos
// Copyright (c) 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_MOCK_EXPERIMENTAL_BLUETOOTH_DEVICE_CLIENT_H_
#define CHROMEOS_DBUS_MOCK_EXPERIMENTAL_BLUETOOTH_DEVICE_CLIENT_H_
#include <string>
#include "chromeos/dbus/experimental_bluetooth_device_client.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace chromeos {
class MockExperimentalBluetoothDeviceClient
: public ExperimentalBluetoothDeviceClient {
public:
struct Properties : public ExperimentalBluetoothDeviceClient::Properties {
Properties();
virtual ~Properties();
MOCK_METHOD0(ConnectSignals, void());
MOCK_METHOD2(Get, void(dbus::PropertyBase* property,
dbus::PropertySet::GetCallback callback));
MOCK_METHOD0(GetAll, void());
MOCK_METHOD2(Set, void(dbus::PropertyBase* property,
dbus::PropertySet::SetCallback callback));
MOCK_METHOD1(ChangedReceived, void(dbus::Signal*));
};
MockExperimentalBluetoothDeviceClient();
virtual ~MockExperimentalBluetoothDeviceClient();
MOCK_METHOD1(AddObserver, void(Observer*));
MOCK_METHOD1(RemoveObserver, void(Observer*));
MOCK_METHOD1(GetDevicesForAdapter,
std::vector<dbus::ObjectPath>(const dbus::ObjectPath&));
MOCK_METHOD1(GetProperties, Properties*(const dbus::ObjectPath&));
MOCK_METHOD3(Connect, void(const dbus::ObjectPath&,
const base::Closure&,
const ErrorCallback&));
MOCK_METHOD3(Disconnect, void(const dbus::ObjectPath&,
const base::Closure&,
const ErrorCallback&));
MOCK_METHOD4(ConnectProfile, void(const dbus::ObjectPath&,
const std::string&,
const base::Closure&,
const ErrorCallback&));
MOCK_METHOD4(DisconnectProfile, void(const dbus::ObjectPath&,
const std::string&,
const base::Closure&,
const ErrorCallback&));
MOCK_METHOD3(Pair, void(const dbus::ObjectPath&,
const base::Closure&,
const ErrorCallback&));
MOCK_METHOD3(CancelPairing, void(const dbus::ObjectPath&,
const base::Closure&,
const ErrorCallback&));
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_MOCK_EXPERIMENTAL_BLUETOOTH_DEVICE_CLIENT_H_
// Copyright (c) 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.
#include "chromeos/dbus/mock_experimental_bluetooth_profile_manager_client.h"
namespace chromeos {
MockExperimentalBluetoothProfileManagerClient::
MockExperimentalBluetoothProfileManagerClient() {}
MockExperimentalBluetoothProfileManagerClient::
~MockExperimentalBluetoothProfileManagerClient() {}
} // namespace chromeos
// Copyright (c) 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_MOCK_EXPERIMENTAL_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_
#define CHROMEOS_DBUS_MOCK_EXPERIMENTAL_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_
#include <string>
#include "chromeos/dbus/experimental_bluetooth_profile_manager_client.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace chromeos {
class MockExperimentalBluetoothProfileManagerClient
: public ExperimentalBluetoothProfileManagerClient {
public:
MockExperimentalBluetoothProfileManagerClient();
virtual ~MockExperimentalBluetoothProfileManagerClient();
MOCK_METHOD5(RegisterProfile, void(const dbus::ObjectPath&,
const std::string&,
const Options&,
const base::Closure&,
const ErrorCallback&));
MOCK_METHOD3(UnregisterProfile, void(const dbus::ObjectPath&,
const base::Closure&,
const ErrorCallback&));
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_MOCK_EXPERIMENTAL_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment