Skip to content
Permalink
Browse files

Bug 1127670 - Replace device property of BluetoothPairingEvent with d…

…evice name. r=btian, r=bz
  • Loading branch information...
rmottola committed Jul 24, 2019
1 parent 8843467 commit 2765ed7386a244c040a7dcf02f4f6fb4b3999614
@@ -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 @@ class BluetoothPairingListener final : public DOMEventTargetHelper
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;
};

0 comments on commit 2765ed7

Please sign in to comment.
You can’t perform that action at this time.