mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 1127670 - Replace device property of BluetoothPairingEvent with device name. r=btian, r=bz
--HG-- extra : rebase_source : 26f252f46b1d738b1f89ddab54354479b9c36508
This commit is contained in:
parent
b53b686a1b
commit
84f14f7306
@ -50,23 +50,21 @@ BluetoothPairingListener::~BluetoothPairingListener()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothPairingListener::DispatchPairingEvent(BluetoothDevice* aDevice,
|
||||
BluetoothPairingListener::DispatchPairingEvent(const nsAString& aName,
|
||||
const nsAString& aAddress,
|
||||
const nsAString& aPasskey,
|
||||
const nsAString& aType)
|
||||
{
|
||||
MOZ_ASSERT(aDevice && !aType.IsEmpty());
|
||||
|
||||
nsString address;
|
||||
aDevice->GetAddress(address);
|
||||
MOZ_ASSERT(!aName.IsEmpty() && !aAddress.IsEmpty() && !aType.IsEmpty());
|
||||
|
||||
nsRefPtr<BluetoothPairingHandle> handle =
|
||||
BluetoothPairingHandle::Create(GetOwner(),
|
||||
address,
|
||||
aAddress,
|
||||
aType,
|
||||
aPasskey);
|
||||
|
||||
BluetoothPairingEventInit init;
|
||||
init.mDevice = aDevice;
|
||||
init.mDeviceName = aName;
|
||||
init.mHandle = handle;
|
||||
|
||||
nsRefPtr<BluetoothPairingEvent> event =
|
||||
@ -96,20 +94,13 @@ BluetoothPairingListener::Notify(const BluetoothSignal& aData)
|
||||
arr[2].value().type() == BluetoothValue::TnsString && // passkey
|
||||
arr[3].value().type() == BluetoothValue::TnsString); // type
|
||||
|
||||
nsString deviceAddress = arr[0].value().get_nsString();
|
||||
nsString deviceName = arr[1].value().get_nsString();
|
||||
nsString address = arr[0].value().get_nsString();
|
||||
nsString name = arr[1].value().get_nsString();
|
||||
nsString passkey = arr[2].value().get_nsString();
|
||||
nsString type = arr[3].value().get_nsString();
|
||||
|
||||
// Create a temporary device with deviceAddress and deviceName
|
||||
InfallibleTArray<BluetoothNamedValue> props;
|
||||
BT_APPEND_NAMED_VALUE(props, "Address", deviceAddress);
|
||||
BT_APPEND_NAMED_VALUE(props, "Name", deviceName);
|
||||
nsRefPtr<BluetoothDevice> device =
|
||||
BluetoothDevice::Create(GetOwner(), props);
|
||||
|
||||
// Notify pairing listener of pairing requests
|
||||
DispatchPairingEvent(device, passkey, type);
|
||||
DispatchPairingEvent(name, address, passkey, type);
|
||||
} else {
|
||||
BT_WARNING("Not handling pairing listener signal: %s",
|
||||
NS_ConvertUTF16toUTF8(aData.name()).get());
|
||||
|
@ -25,7 +25,8 @@ public:
|
||||
static already_AddRefed<BluetoothPairingListener>
|
||||
Create(nsPIDOMWindow* aWindow);
|
||||
|
||||
void DispatchPairingEvent(BluetoothDevice* aDevice,
|
||||
void DispatchPairingEvent(const nsAString& aName,
|
||||
const nsAString& aAddress,
|
||||
const nsAString& aPasskey,
|
||||
const nsAString& aType);
|
||||
|
||||
|
@ -9,12 +9,12 @@
|
||||
optional BluetoothPairingEventInit eventInitDict)]
|
||||
interface BluetoothPairingEvent : Event
|
||||
{
|
||||
readonly attribute BluetoothDevice device;
|
||||
readonly attribute DOMString deviceName;
|
||||
readonly attribute BluetoothPairingHandle handle;
|
||||
};
|
||||
|
||||
dictionary BluetoothPairingEventInit : EventInit
|
||||
{
|
||||
required BluetoothDevice device;
|
||||
required DOMString deviceName;
|
||||
required BluetoothPairingHandle handle;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user