зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1036228 - Patch1: Add BluetoothPairingRequestListeningHandle.webidl and implement it. r=btian, r=bz
This commit is contained in:
Родитель
732c3fb48f
Коммит
68c5209cb0
|
@ -712,6 +712,7 @@ GK_ATOM(ondischargingtimechange, "ondischargingtimechange")
|
|||
GK_ATOM(ondisconnected, "ondisconnected")
|
||||
GK_ATOM(ondisconnecting, "ondisconnecting")
|
||||
GK_ATOM(ondiscoverystatechanged, "ondiscoverystatechanged")
|
||||
GK_ATOM(ondisplaypasskeyreq, "ondisplaypasskeyreq")
|
||||
GK_ATOM(ondownloading, "ondownloading")
|
||||
GK_ATOM(onDOMActivate, "onDOMActivate")
|
||||
GK_ATOM(onDOMAttrModified, "onDOMAttrModified")
|
||||
|
@ -735,6 +736,7 @@ GK_ATOM(ondragover, "ondragover")
|
|||
GK_ATOM(ondragstart, "ondragstart")
|
||||
GK_ATOM(ondrop, "ondrop")
|
||||
GK_ATOM(onenabled, "onenabled")
|
||||
GK_ATOM(onenterpincodereq, "onenterpincodereq")
|
||||
GK_ATOM(onemergencycbmodechange, "onemergencycbmodechange")
|
||||
GK_ATOM(onerror, "onerror")
|
||||
GK_ATOM(onevicted, "onevicted")
|
||||
|
@ -798,6 +800,8 @@ GK_ATOM(onpagehide, "onpagehide")
|
|||
GK_ATOM(onpageshow, "onpageshow")
|
||||
GK_ATOM(onpaint, "onpaint")
|
||||
GK_ATOM(onpairedstatuschanged, "onpairedstatuschanged")
|
||||
GK_ATOM(onpairingconfirmationreq, "onpairingconfirmationreq")
|
||||
GK_ATOM(onpairingconsentreq, "onpairingconsentreq")
|
||||
GK_ATOM(onpaste, "onpaste")
|
||||
GK_ATOM(onpendingchange, "onpendingchange")
|
||||
GK_ATOM(onpopuphidden, "onpopuphidden")
|
||||
|
|
|
@ -186,6 +186,11 @@ DOMInterfaces = {
|
|||
'nativeType': 'mozilla::dom::bluetooth::BluetoothPairingHandle',
|
||||
},
|
||||
|
||||
'BluetoothPairingListener': {
|
||||
'nativeType':
|
||||
'mozilla::dom::bluetooth::BluetoothPairingListener',
|
||||
},
|
||||
|
||||
'CameraCapabilities': {
|
||||
'nativeType': 'mozilla::dom::CameraCapabilities',
|
||||
'headerFile': 'DOMCameraCapabilities.h'
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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 "mozilla/dom/bluetooth/BluetoothPairingListener.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothPairingHandle.h"
|
||||
#include "mozilla/dom/BluetoothPairingEvent.h"
|
||||
#include "mozilla/dom/BluetoothPairingListenerBinding.h"
|
||||
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BluetoothPairingListener)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(BluetoothPairingListener, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(BluetoothPairingListener, DOMEventTargetHelper)
|
||||
|
||||
BluetoothPairingListener::BluetoothPairingListener(nsPIDOMWindow* aWindow)
|
||||
: DOMEventTargetHelper(aWindow)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(IsDOMBinding());
|
||||
}
|
||||
|
||||
already_AddRefed<BluetoothPairingListener>
|
||||
BluetoothPairingListener::Create(nsPIDOMWindow* aWindow)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aWindow);
|
||||
|
||||
nsRefPtr<BluetoothPairingListener> handle =
|
||||
new BluetoothPairingListener(aWindow);
|
||||
|
||||
return handle.forget();
|
||||
}
|
||||
|
||||
BluetoothPairingListener::~BluetoothPairingListener()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothPairingListener::DispatchPairingEvent(BluetoothDevice* aDevice,
|
||||
const nsAString& aPasskey,
|
||||
const nsAString& aType)
|
||||
{
|
||||
MOZ_ASSERT(aDevice && !aType.IsEmpty());
|
||||
|
||||
nsString address;
|
||||
aDevice->GetAddress(address);
|
||||
|
||||
nsRefPtr<BluetoothPairingHandle> handle =
|
||||
BluetoothPairingHandle::Create(GetOwner(),
|
||||
address,
|
||||
aType,
|
||||
aPasskey);
|
||||
|
||||
BluetoothPairingEventInit init;
|
||||
init.mDevice = aDevice;
|
||||
init.mHandle = handle;
|
||||
|
||||
nsRefPtr<BluetoothPairingEvent> event =
|
||||
BluetoothPairingEvent::Constructor(this,
|
||||
aType,
|
||||
init);
|
||||
|
||||
DispatchTrustedEvent(event);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
BluetoothPairingListener::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return BluetoothPairingListenerBinding::Wrap(aCx, this);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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_bluetoothpairinglistener_h
|
||||
#define mozilla_dom_bluetooth_bluetoothpairinglistener_h
|
||||
|
||||
#include "BluetoothCommon.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
class BluetoothDevice;
|
||||
|
||||
class BluetoothPairingListener MOZ_FINAL : public DOMEventTargetHelper
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
static already_AddRefed<BluetoothPairingListener>
|
||||
Create(nsPIDOMWindow* aWindow);
|
||||
|
||||
void DispatchPairingEvent(BluetoothDevice* aDevice,
|
||||
const nsAString& aPasskey,
|
||||
const nsAString& aType);
|
||||
|
||||
nsPIDOMWindow* GetParentObject() const
|
||||
{
|
||||
return GetOwner();
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
IMPL_EVENT_HANDLER(displaypasskeyreq);
|
||||
IMPL_EVENT_HANDLER(enterpincodereq);
|
||||
IMPL_EVENT_HANDLER(pairingconfirmationreq);
|
||||
IMPL_EVENT_HANDLER(pairingconsentreq);
|
||||
|
||||
private:
|
||||
BluetoothPairingListener(nsPIDOMWindow* aWindow);
|
||||
~BluetoothPairingListener();
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
||||
#endif // mozilla_dom_bluetooth_bluetoothpairinglistener_h
|
|
@ -13,6 +13,7 @@ if CONFIG['MOZ_B2G_BT']:
|
|||
'BluetoothHidManager.cpp',
|
||||
'BluetoothManager.cpp',
|
||||
'BluetoothPairingHandle.cpp',
|
||||
'BluetoothPairingListener.cpp',
|
||||
'BluetoothProfileController.cpp',
|
||||
'BluetoothReplyRunnable.cpp',
|
||||
'BluetoothService.cpp',
|
||||
|
@ -106,6 +107,7 @@ EXPORTS.mozilla.dom.bluetooth += [
|
|||
'BluetoothDiscoveryHandle.h',
|
||||
'BluetoothManager.h',
|
||||
'BluetoothPairingHandle.h',
|
||||
'BluetoothPairingListener.h',
|
||||
]
|
||||
|
||||
IPDL_SOURCES += [
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
[AvailableIn=CertifiedApps, CheckPermissions="bluetooth"]
|
||||
interface BluetoothPairingListener: EventTarget
|
||||
{
|
||||
attribute EventHandler ondisplaypasskeyreq;
|
||||
attribute EventHandler onenterpincodereq;
|
||||
attribute EventHandler onpairingconfirmationreq;
|
||||
attribute EventHandler onpairingconsentreq;
|
||||
};
|
|
@ -573,6 +573,7 @@ if CONFIG['MOZ_B2G_BT']:
|
|||
'BluetoothDiscoveryHandle.webidl',
|
||||
'BluetoothManager2.webidl',
|
||||
'BluetoothPairingHandle.webidl',
|
||||
'BluetoothPairingListener.webidl',
|
||||
]
|
||||
else:
|
||||
WEBIDL_FILES += [
|
||||
|
|
Загрузка…
Ссылка в новой задаче