From 95e9859ccccc4a131d1d68767fa6cd6d9a18658a Mon Sep 17 00:00:00 2001 From: "keybuk@google.com" Date: Mon, 4 Jun 2012 18:39:44 +0000 Subject: bluetooth: obtain D-Bus error for select methods For the CreateDevice, CreatePairedDevice and Connect methods use CallMethodWithErrorCallback rather than CallMethod so that we obtain richer error information from the BlueZ service. BUG=chromium-os:27902 TEST=make chrome Change-Id: If801d834604e4c2142c20169603bc527bde09403 Review URL: https://chromiumcodereview.appspot.com/10409062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140334 0039d316-1c4b-4281-b951-d872f2087c98 --- chromeos/dbus/bluetooth_adapter_client.h | 38 +++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'chromeos/dbus/bluetooth_adapter_client.h') diff --git a/chromeos/dbus/bluetooth_adapter_client.h b/chromeos/dbus/bluetooth_adapter_client.h index 6e59429..52c8692 100644 --- a/chromeos/dbus/bluetooth_adapter_client.h +++ b/chromeos/dbus/bluetooth_adapter_client.h @@ -171,14 +171,30 @@ class CHROMEOS_EXPORT BluetoothAdapterClient { const std::string& address, const DeviceCallback& callback) = 0; + // The CreateDeviceCallback is used for the CreateDevice and + // CreatePairedDevice adapter methods that return a dbus object path for + // a remote device on success. It receives a single argument, the + // |object_path| of the device returned by the method. + typedef base::Callback CreateDeviceCallback; + + // The CreateDeviceErrorCallback is used for the CreateDevice and + // CreatePairedDevices 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 + CreateDeviceErrorCallback; + // Creates a new dbus object from the adapter with object path |object_path| // to the remote device with address |address|, connecting to it and // retrieving all SDP records. After a successful call, the device is known // and appear's in the adapter's |devices| interface. This is a low-security // connection which may not be accepted by the device. - virtual void CreateDevice(const dbus::ObjectPath& object_path, - const std::string& address, - const DeviceCallback& callback) = 0; + virtual void CreateDevice( + const dbus::ObjectPath& object_path, + const std::string& address, + const CreateDeviceCallback& callback, + const CreateDeviceErrorCallback& error_callback) = 0; // Creates a new dbus object from the adapter with object path |object_path| // to the remote device with address |address|, connecting to it, retrieving @@ -189,11 +205,13 @@ class CHROMEOS_EXPORT BluetoothAdapterClient { // must be specified to negotiate the pairing, |capability| specifies the // input and display capabilities of that agent and should be one of the // constants declared in the bluetooth_agent:: namespace. - virtual void CreatePairedDevice(const dbus::ObjectPath& object_path, - const std::string& address, - const dbus::ObjectPath& agent_path, - const std::string& capability, - const DeviceCallback& callback) = 0; + virtual void CreatePairedDevice( + const dbus::ObjectPath& object_path, + const std::string& address, + const dbus::ObjectPath& agent_path, + const std::string& capability, + const CreateDeviceCallback& callback, + const CreateDeviceErrorCallback& error_callback) = 0; // Cancels the currently in progress call to CreateDevice() or // CreatePairedDevice() on the adapter with object path |object_path| @@ -232,6 +250,10 @@ class CHROMEOS_EXPORT BluetoothAdapterClient { dbus::Bus* bus, BluetoothManagerClient* manager_client); + // Constants used to indicate exceptional error conditions. + static const char kNoResponseError[]; + static const char kBadResponseError[]; + protected: BluetoothAdapterClient(); -- cgit v1.1