Bug 1146923: Pass SSP variant as enum instead of string, r=btian

This commit is contained in:
Thomas Zimmermann 2015-03-26 10:29:58 +01:00
parent f3fd643c51
commit 2ec891bdbc
6 changed files with 18 additions and 19 deletions

View File

@ -514,7 +514,7 @@ public:
virtual void SspRequestNotification(const nsAString& aRemoteBdAddr,
const nsAString& aBdName,
uint32_t aCod,
const nsAString& aPairingVariant,
BluetoothSspVariant aPairingVariant,
uint32_t aPassKey) { }
virtual void BondStateChangedNotification(BluetoothStatus aStatus,

View File

@ -913,9 +913,8 @@ private:
typedef BluetoothNotificationRunnable5<NotificationHandlerWrapper, void,
nsString, nsString, uint32_t,
nsString, uint32_t,
const nsAString&, const nsAString&,
uint32_t, const nsAString&>
BluetoothSspVariant, uint32_t,
const nsAString&, const nsAString&>
SspRequestNotification;
typedef BluetoothNotificationRunnable3<NotificationHandlerWrapper, void,
@ -1150,7 +1149,7 @@ private:
nsresult
operator () (nsString& aArg1, nsString& aArg2, uint32_t& aArg3,
nsString& aArg4, uint32_t& aArg5) const
BluetoothSspVariant aArg4, uint32_t& aArg5) const
{
BluetoothDaemonPDU& pdu = GetPDU();
@ -1175,8 +1174,7 @@ private:
}
/* Read pairing variant */
rv = UnpackPDU(
pdu, UnpackConversion<BluetoothSspVariant, nsAString>(aArg4));
rv = UnpackPDU(pdu, aArg4);
if (NS_FAILED(rv)) {
return rv;
}

View File

@ -111,18 +111,20 @@ nsresult
Convert(const nsAString& aIn, bt_ssp_variant_t& aOut);
inline nsresult
Convert(const bt_ssp_variant_t& aIn, nsAString& aOut)
Convert(const bt_ssp_variant_t& aIn, BluetoothSspVariant& aOut)
{
static const char * const sSspVariant[] = {
CONVERT(BT_SSP_VARIANT_PASSKEY_CONFIRMATION, "PasskeyConfirmation"),
CONVERT(BT_SSP_VARIANT_PASSKEY_ENTRY, "PasskeyEntry"),
CONVERT(BT_SSP_VARIANT_CONSENT, "Consent"),
CONVERT(BT_SSP_VARIANT_PASSKEY_NOTIFICATION, "PasskeyNotification")
static const BluetoothSspVariant sSspVariant[] = {
CONVERT(BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
SSP_VARIANT_PASSKEY_CONFIRMATION),
CONVERT(BT_SSP_VARIANT_PASSKEY_ENTRY, SSP_VARIANT_PASSKEY_ENTRY),
CONVERT(BT_SSP_VARIANT_CONSENT, SSP_VARIANT_CONSENT),
CONVERT(BT_SSP_VARIANT_PASSKEY_NOTIFICATION,
SSP_VARIANT_PASSKEY_NOTIFICATION)
};
if (aIn >= MOZ_ARRAY_LENGTH(sSspVariant)) {
return NS_ERROR_ILLEGAL_VALUE;
}
aOut = NS_ConvertUTF8toUTF16(sSspVariant[aIn]);
aOut = sSspVariant[aIn];
return NS_OK;
}

View File

@ -151,9 +151,8 @@ struct BluetoothCallback
typedef BluetoothNotificationHALRunnable5<NotificationHandlerWrapper, void,
nsString, nsString, uint32_t,
nsString, uint32_t,
const nsAString&, const nsAString&,
uint32_t, const nsAString&>
BluetoothSspVariant, uint32_t,
const nsAString&, const nsAString&>
SspRequestNotification;
typedef BluetoothNotificationHALRunnable3<NotificationHandlerWrapper, void,

View File

@ -1493,7 +1493,7 @@ BluetoothServiceBluedroid::PinRequestNotification(const nsAString& aRemoteBdAddr
void
BluetoothServiceBluedroid::SspRequestNotification(
const nsAString& aRemoteBdAddr, const nsAString& aBdName, uint32_t aCod,
const nsAString& aPairingaVariant, uint32_t aPassKey)
BluetoothSspVariant aPairingVariant, uint32_t aPassKey)
{
MOZ_ASSERT(NS_IsMainThread());

View File

@ -196,7 +196,7 @@ public:
virtual void SspRequestNotification(const nsAString& aRemoteBdAddr,
const nsAString& aBdName,
uint32_t aCod,
const nsAString& aPairingaVariant,
BluetoothSspVariant aPairingVariant,
uint32_t aPassKey) override;
virtual void BondStateChangedNotification(