mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 14:20:14 +02:00
Bug 730992 - Patch 1: The DOM boilerplate for BluetoothPairingEvent, r=qdot, sr=mrbkap
--- dom/base/nsDOMClassInfo.cpp | 9 +++ dom/base/nsDOMClassInfoClasses.h | 1 + dom/bluetooth/BluetoothPairingEvent.cpp | 78 +++++++++++++++++++++++++ dom/bluetooth/BluetoothPairingEvent.h | 70 ++++++++++++++++++++++ dom/bluetooth/Makefile.in | 2 + dom/bluetooth/nsIDOMBluetoothPairingEvent.idl | 15 +++++ 6 files changed, 175 insertions(+), 0 deletions(-) create mode 100644 dom/bluetooth/BluetoothPairingEvent.cpp create mode 100644 dom/bluetooth/BluetoothPairingEvent.h create mode 100644 dom/bluetooth/nsIDOMBluetoothPairingEvent.idl
This commit is contained in:
parent
9adf2f74fb
commit
1353638291
6 changed files with 175 additions and 0 deletions
|
|
@ -520,6 +520,7 @@ using mozilla::dom::indexedDB::IDBWrapperCache;
|
||||||
#include "BluetoothDevice.h"
|
#include "BluetoothDevice.h"
|
||||||
#include "BluetoothDeviceEvent.h"
|
#include "BluetoothDeviceEvent.h"
|
||||||
#include "BluetoothPropertyEvent.h"
|
#include "BluetoothPropertyEvent.h"
|
||||||
|
#include "BluetoothPairingEvent.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "nsIDOMNavigatorSystemMessages.h"
|
#include "nsIDOMNavigatorSystemMessages.h"
|
||||||
|
|
@ -1684,6 +1685,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||||
NS_DEFINE_CLASSINFO_DATA(BluetoothPropertyEvent, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(BluetoothPropertyEvent, nsDOMGenericSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||||
|
NS_DEFINE_CLASSINFO_DATA(BluetoothPairingEvent, nsDOMGenericSH,
|
||||||
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NS_DEFINE_CLASSINFO_DATA(CameraManager, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CameraManager, nsDOMGenericSH,
|
||||||
|
|
@ -4488,6 +4491,12 @@ nsDOMClassInfo::Init()
|
||||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothPropertyEvent)
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothPropertyEvent)
|
||||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
|
||||||
DOM_CLASSINFO_MAP_END
|
DOM_CLASSINFO_MAP_END
|
||||||
|
|
||||||
|
DOM_CLASSINFO_MAP_BEGIN(BluetoothPairingEvent, nsIDOMBluetoothPairingEvent)
|
||||||
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothPairingEvent)
|
||||||
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
|
||||||
|
DOM_CLASSINFO_MAP_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DOM_CLASSINFO_MAP_BEGIN(CameraManager, nsIDOMCameraManager)
|
DOM_CLASSINFO_MAP_BEGIN(CameraManager, nsIDOMCameraManager)
|
||||||
|
|
|
||||||
|
|
@ -526,6 +526,7 @@ DOMCI_CLASS(BluetoothAdapter)
|
||||||
DOMCI_CLASS(BluetoothDevice)
|
DOMCI_CLASS(BluetoothDevice)
|
||||||
DOMCI_CLASS(BluetoothDeviceEvent)
|
DOMCI_CLASS(BluetoothDeviceEvent)
|
||||||
DOMCI_CLASS(BluetoothPropertyEvent)
|
DOMCI_CLASS(BluetoothPropertyEvent)
|
||||||
|
DOMCI_CLASS(BluetoothPairingEvent)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DOMCI_CLASS(CameraManager)
|
DOMCI_CLASS(CameraManager)
|
||||||
|
|
|
||||||
78
dom/bluetooth/BluetoothPairingEvent.cpp
Normal file
78
dom/bluetooth/BluetoothPairingEvent.cpp
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||||
|
/* vim: set ts=2 et sw=2 tw=80: */
|
||||||
|
/* 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 "base/basictypes.h"
|
||||||
|
#include "BluetoothPairingEvent.h"
|
||||||
|
|
||||||
|
#include "nsDOMClassInfo.h"
|
||||||
|
|
||||||
|
USING_BLUETOOTH_NAMESPACE
|
||||||
|
|
||||||
|
// static
|
||||||
|
already_AddRefed<BluetoothPairingEvent>
|
||||||
|
BluetoothPairingEvent::Create(const nsAString& aDeviceAddress, const PRUint32& aPasskey)
|
||||||
|
{
|
||||||
|
nsRefPtr<BluetoothPairingEvent> event = new BluetoothPairingEvent();
|
||||||
|
|
||||||
|
event->mPasskey = aPasskey;
|
||||||
|
event->mDeviceAddress = aDeviceAddress;
|
||||||
|
|
||||||
|
return event.forget();
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
already_AddRefed<BluetoothPairingEvent>
|
||||||
|
BluetoothPairingEvent::Create(const nsAString& aDeviceAddress, const nsAString& aUuid)
|
||||||
|
{
|
||||||
|
nsRefPtr<BluetoothPairingEvent> event = new BluetoothPairingEvent();
|
||||||
|
|
||||||
|
event->mUuid = aUuid;
|
||||||
|
event->mDeviceAddress = aDeviceAddress;
|
||||||
|
|
||||||
|
return event.forget();
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_CLASS(BluetoothPairingEvent)
|
||||||
|
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BluetoothPairingEvent,
|
||||||
|
nsDOMEvent)
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||||
|
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BluetoothPairingEvent,
|
||||||
|
nsDOMEvent)
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||||
|
|
||||||
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothPairingEvent)
|
||||||
|
NS_INTERFACE_MAP_ENTRY(nsIDOMBluetoothPairingEvent)
|
||||||
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(BluetoothPairingEvent)
|
||||||
|
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
|
||||||
|
|
||||||
|
NS_IMPL_ADDREF_INHERITED(BluetoothPairingEvent, nsDOMEvent)
|
||||||
|
NS_IMPL_RELEASE_INHERITED(BluetoothPairingEvent, nsDOMEvent)
|
||||||
|
|
||||||
|
DOMCI_DATA(BluetoothPairingEvent, BluetoothPairingEvent)
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
BluetoothPairingEvent::GetPasskey(PRUint32* aPasskey)
|
||||||
|
{
|
||||||
|
*aPasskey = mPasskey;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
BluetoothPairingEvent::GetUuid(nsAString& aUuid)
|
||||||
|
{
|
||||||
|
aUuid = mUuid;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
BluetoothPairingEvent::GetDeviceAddress(nsAString& aDeviceAddress)
|
||||||
|
{
|
||||||
|
aDeviceAddress = mDeviceAddress;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
70
dom/bluetooth/BluetoothPairingEvent.h
Normal file
70
dom/bluetooth/BluetoothPairingEvent.h
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||||
|
/* vim: set ts=2 et sw=2 tw=80: */
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
#ifndef mozilla_dom_bluetooth_requestpairingevent_h__
|
||||||
|
#define mozilla_dom_bluetooth_requestpairingevent_h__
|
||||||
|
|
||||||
|
#include "BluetoothCommon.h"
|
||||||
|
|
||||||
|
#include "nsIDOMBluetoothPairingEvent.h"
|
||||||
|
#include "nsIDOMEventTarget.h"
|
||||||
|
|
||||||
|
#include "nsDOMEvent.h"
|
||||||
|
|
||||||
|
BEGIN_BLUETOOTH_NAMESPACE
|
||||||
|
|
||||||
|
class BluetoothPairingEvent : public nsDOMEvent
|
||||||
|
, public nsIDOMBluetoothPairingEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
NS_FORWARD_TO_NSDOMEVENT
|
||||||
|
NS_DECL_NSIDOMBLUETOOTHPAIRINGEVENT
|
||||||
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BluetoothPairingEvent, nsDOMEvent)
|
||||||
|
|
||||||
|
static already_AddRefed<BluetoothPairingEvent>
|
||||||
|
Create(const nsAString& aDeviceAddress, const PRUint32& aPasskey);
|
||||||
|
|
||||||
|
static already_AddRefed<BluetoothPairingEvent>
|
||||||
|
Create(const nsAString& aDeviceAddress, const nsAString& aUuid);
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
Dispatch(nsIDOMEventTarget* aTarget, const nsAString& aEventType)
|
||||||
|
{
|
||||||
|
NS_ASSERTION(aTarget, "Null pointer!");
|
||||||
|
NS_ASSERTION(!aEventType.IsEmpty(), "Empty event type!");
|
||||||
|
|
||||||
|
nsresult rv = InitEvent(aEventType, false, false);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
rv = SetTrusted(true);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
nsIDOMEvent* thisEvent = static_cast<nsDOMEvent*>(this);
|
||||||
|
|
||||||
|
bool dummy;
|
||||||
|
rv = aTarget->DispatchEvent(thisEvent, &dummy);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
BluetoothPairingEvent()
|
||||||
|
: nsDOMEvent(nullptr, nullptr)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
~BluetoothPairingEvent()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
PRUint32 mPasskey;
|
||||||
|
nsString mUuid;
|
||||||
|
nsString mDeviceAddress;
|
||||||
|
};
|
||||||
|
|
||||||
|
END_BLUETOOTH_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -34,6 +34,7 @@ CPPSRCS += \
|
||||||
BluetoothDevice.cpp \
|
BluetoothDevice.cpp \
|
||||||
BluetoothDeviceEvent.cpp \
|
BluetoothDeviceEvent.cpp \
|
||||||
BluetoothPropertyEvent.cpp \
|
BluetoothPropertyEvent.cpp \
|
||||||
|
BluetoothPairingEvent.cpp \
|
||||||
BluetoothReplyRunnable.cpp \
|
BluetoothReplyRunnable.cpp \
|
||||||
BluetoothPropertyContainer.cpp \
|
BluetoothPropertyContainer.cpp \
|
||||||
BluetoothUtils.cpp \
|
BluetoothUtils.cpp \
|
||||||
|
|
@ -46,6 +47,7 @@ XPIDLSRCS = \
|
||||||
nsIDOMBluetoothDevice.idl \
|
nsIDOMBluetoothDevice.idl \
|
||||||
nsIDOMBluetoothDeviceEvent.idl \
|
nsIDOMBluetoothDeviceEvent.idl \
|
||||||
nsIDOMBluetoothPropertyEvent.idl \
|
nsIDOMBluetoothPropertyEvent.idl \
|
||||||
|
nsIDOMBluetoothPairingEvent.idl \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
||||||
|
|
|
||||||
15
dom/bluetooth/nsIDOMBluetoothPairingEvent.idl
Normal file
15
dom/bluetooth/nsIDOMBluetoothPairingEvent.idl
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||||
|
/* vim: set ts=2 et sw=2 tw=80: */
|
||||||
|
/* 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(b905b05e-2141-444c-a90d-525b6c0daff1)]
|
||||||
|
interface nsIDOMBluetoothPairingEvent : nsIDOMEvent
|
||||||
|
{
|
||||||
|
readonly attribute DOMString deviceAddress;
|
||||||
|
readonly attribute DOMString uuid;
|
||||||
|
readonly attribute unsigned long passkey;
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue