Bug 1029389: Add result-handler class for Bluetooth Handsfree profile, r=shuang

This commit is contained in:
Thomas Zimmermann 2014-07-15 10:56:53 +02:00
parent e8b46a74c6
commit 145befb0cb
2 changed files with 66 additions and 0 deletions

View File

@ -576,6 +576,37 @@ struct interface_traits<BluetoothHandsfreeInterface>
}
};
typedef
BluetoothInterfaceRunnable0<BluetoothHandsfreeResultHandler, void>
BluetoothHandsfreeResultRunnable;
typedef
BluetoothInterfaceRunnable1<BluetoothHandsfreeResultHandler, void, bt_status_t>
BluetoothHandsfreeErrorRunnable;
static nsresult
DispatchBluetoothHandsfreeResult(
BluetoothHandsfreeResultHandler* aRes,
void (BluetoothHandsfreeResultHandler::*aMethod)(),
bt_status_t aStatus)
{
MOZ_ASSERT(aRes);
nsRunnable* runnable;
if (aStatus == BT_STATUS_SUCCESS) {
runnable = new BluetoothHandsfreeResultRunnable(aRes, aMethod);
} else {
runnable = new BluetoothHandsfreeErrorRunnable(aRes,
&BluetoothHandsfreeResultHandler::OnError, aStatus);
}
nsresult rv = NS_DispatchToMainThread(runnable);
if (NS_FAILED(rv)) {
BT_WARNING("NS_DispatchToMainThread failed: %X", rv);
}
return rv;
}
BluetoothHandsfreeInterface::BluetoothHandsfreeInterface(
const bthf_interface_t* aInterface)
: mInterface(aInterface)

View File

@ -72,6 +72,41 @@ private:
// Handsfree Interface
//
class BluetoothHandsfreeResultHandler
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothHandsfreeResultHandler)
virtual ~BluetoothHandsfreeResultHandler() { }
virtual void OnError(bt_status_t aStatus)
{
BT_WARNING("Received error code %d", (int)aStatus);
}
virtual void Init() { }
virtual void Cleanup() { }
virtual void Connect() { }
virtual void Disconnect() { }
virtual void ConnectAudio() { }
virtual void DisconnectAudio() { }
virtual void StartVoiceRecognition() { }
virtual void StopVoiceRecognition() { }
virtual void VolumeControl() { }
virtual void DeviceStatusNotification() { }
virtual void CopsResponse() { }
virtual void CindResponse() { }
virtual void FormattedAtResponse() { }
virtual void AtResponse() { }
virtual void ClccResponse() { }
virtual void PhoneStateChange() { }
};
class BluetoothHandsfreeInterface
{
public: