Bug 778640 - Final version: Firing devicedisappeared event, create nsIDOMBluetoothDeviceAddressEvent by event generator, r=qdot, r=smaug

---
 dom/bluetooth/BluetoothAdapter.cpp                 |   17 +++++++++++++++-
 dom/bluetooth/Makefile.in                          |    1 +
 .../nsIDOMBluetoothDeviceAddressEvent.idl          |   21 ++++++++++++++++++++
 js/xpconnect/src/event_impl_gen.conf.in            |    3 ++-
 4 files changed, 40 insertions(+), 2 deletions(-)
 create mode 100644 dom/bluetooth/nsIDOMBluetoothDeviceAddressEvent.idl
This commit is contained in:
Gina Yeh 2012-08-17 12:02:52 +08:00
Родитель 10083eff12
Коммит faa4304b5c
4 изменённых файлов: 39 добавлений и 1 удалений

Просмотреть файл

@ -14,11 +14,13 @@
#include "BluetoothReplyRunnable.h" #include "BluetoothReplyRunnable.h"
#include "BluetoothUtils.h" #include "BluetoothUtils.h"
#include "GeneratedEvents.h"
#include "nsDOMClassInfo.h" #include "nsDOMClassInfo.h"
#include "nsDOMEvent.h" #include "nsDOMEvent.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "nsXPCOMCIDInternal.h" #include "nsXPCOMCIDInternal.h"
#include "nsIDOMDOMRequest.h" #include "nsIDOMDOMRequest.h"
#include "nsIDOMBluetoothDeviceAddressEvent.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "mozilla/LazyIdleThread.h" #include "mozilla/LazyIdleThread.h"
@ -272,6 +274,19 @@ BluetoothAdapter::Notify(const BluetoothSignal& aData)
nsRefPtr<BluetoothDevice> d = BluetoothDevice::Create(GetOwner(), mPath, aData.value()); nsRefPtr<BluetoothDevice> d = BluetoothDevice::Create(GetOwner(), mPath, aData.value());
nsRefPtr<BluetoothDeviceEvent> e = BluetoothDeviceEvent::Create(d); nsRefPtr<BluetoothDeviceEvent> e = BluetoothDeviceEvent::Create(d);
e->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("devicefound")); e->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("devicefound"));
} else if (aData.name().EqualsLiteral("DeviceDisappeared")) {
const nsAString& deviceAddress = aData.value().get_nsString();
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMBluetoothDeviceAddressEvent(getter_AddRefs(event), nullptr, nullptr);
nsCOMPtr<nsIDOMBluetoothDeviceAddressEvent> e = do_QueryInterface(event);
e->InitBluetoothDeviceAddressEvent(NS_LITERAL_STRING("devicedisappeared"),
false, false, deviceAddress);
e->SetTrusted(true);
bool dummy;
DispatchEvent(event, &dummy);
} else if (aData.name().EqualsLiteral("PropertyChanged")) { } else if (aData.name().EqualsLiteral("PropertyChanged")) {
// Get BluetoothNamedValue, make sure array length is 1 // Get BluetoothNamedValue, make sure array length is 1
InfallibleTArray<BluetoothNamedValue> arr = aData.value().get_ArrayOfBluetoothNamedValue(); InfallibleTArray<BluetoothNamedValue> arr = aData.value().get_ArrayOfBluetoothNamedValue();

Просмотреть файл

@ -45,6 +45,7 @@ XPIDLSRCS = \
nsIDOMBluetoothAdapter.idl \ nsIDOMBluetoothAdapter.idl \
nsIDOMBluetoothDevice.idl \ nsIDOMBluetoothDevice.idl \
nsIDOMBluetoothDeviceEvent.idl \ nsIDOMBluetoothDeviceEvent.idl \
nsIDOMBluetoothDeviceAddressEvent.idl \
nsIDOMBluetoothPropertyEvent.idl \ nsIDOMBluetoothPropertyEvent.idl \
$(NULL) $(NULL)

Просмотреть файл

@ -0,0 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIDOMEvent.idl"
[scriptable, builtinclass, uuid(afcb832f-bbb5-45fa-b703-f8185bd2d26d)]
interface nsIDOMBluetoothDeviceAddressEvent : nsIDOMEvent
{
readonly attribute DOMString deviceAddress;
[noscript] void initBluetoothDeviceAddressEvent(in DOMString aType,
in boolean aCanBubble,
in boolean aCancelable,
in DOMString aDeviceAddress);
};
dictionary BluetoothDeviceAddressEventInit : EventInit
{
DOMString deviceAddress;
};

Просмотреть файл

@ -21,7 +21,8 @@ simple_events = [
'DeviceOrientationEvent', 'DeviceOrientationEvent',
'DeviceLightEvent', 'DeviceLightEvent',
'MozApplicationEvent', 'MozApplicationEvent',
'DeviceStorageChangeEvent' 'DeviceStorageChangeEvent',
'BluetoothDeviceAddressEvent'
] ]
""" include file names """ """ include file names """