mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 783520 - [b2g-bluetooth] follow-up to bug 730992, r=qdot
This commit is contained in:
parent
a316b8c4b1
commit
d86c1206ca
@ -518,7 +518,6 @@ using mozilla::dom::indexedDB::IDBWrapperCache;
|
||||
#include "BluetoothAdapter.h"
|
||||
#include "BluetoothDevice.h"
|
||||
#include "BluetoothPropertyEvent.h"
|
||||
#include "BluetoothPairingEvent.h"
|
||||
#endif
|
||||
|
||||
#include "nsIDOMNavigatorSystemMessages.h"
|
||||
@ -1679,8 +1678,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(BluetoothPropertyEvent, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(BluetoothPairingEvent, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
#endif
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(CameraManager, nsDOMGenericSH,
|
||||
@ -4475,12 +4472,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothPropertyEvent)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
|
||||
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
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CameraManager, nsIDOMCameraManager)
|
||||
|
@ -524,7 +524,6 @@ DOMCI_CLASS(BluetoothManager)
|
||||
DOMCI_CLASS(BluetoothAdapter)
|
||||
DOMCI_CLASS(BluetoothDevice)
|
||||
DOMCI_CLASS(BluetoothPropertyEvent)
|
||||
DOMCI_CLASS(BluetoothPairingEvent)
|
||||
#endif
|
||||
|
||||
DOMCI_CLASS(CameraManager)
|
||||
|
@ -8,21 +8,22 @@
|
||||
#include "BluetoothAdapter.h"
|
||||
#include "BluetoothDevice.h"
|
||||
#include "BluetoothPropertyEvent.h"
|
||||
#include "BluetoothPairingEvent.h"
|
||||
#include "BluetoothService.h"
|
||||
#include "BluetoothTypes.h"
|
||||
#include "BluetoothReplyRunnable.h"
|
||||
#include "BluetoothUtils.h"
|
||||
#include "GeneratedEvents.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsXPCOMCIDInternal.h"
|
||||
#include "nsIDOMDOMRequest.h"
|
||||
#include "nsIDOMBluetoothAuthorizeEvent.h"
|
||||
#include "nsIDOMBluetoothDeviceEvent.h"
|
||||
#include "nsIDOMBluetoothDeviceAddressEvent.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDOMBluetoothPairingEvent.h"
|
||||
#include "nsIDOMDOMRequest.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsXPCOMCIDInternal.h"
|
||||
|
||||
#include "mozilla/LazyIdleThread.h"
|
||||
#include "mozilla/Util.h"
|
||||
@ -322,66 +323,100 @@ BluetoothAdapter::Notify(const BluetoothSignal& aData)
|
||||
} else if (aData.name().EqualsLiteral("PropertyChanged")) {
|
||||
// Get BluetoothNamedValue, make sure array length is 1
|
||||
arr = aData.value().get_ArrayOfBluetoothNamedValue();
|
||||
if(arr.Length() != 1) {
|
||||
// This really should not happen
|
||||
NS_ERROR("Got more than one property in a change message!");
|
||||
return;
|
||||
}
|
||||
|
||||
NS_ASSERTION(arr.Length() == 1, "Got more than one property in a change message!");
|
||||
NS_ASSERTION(arr[0].value().type() == BluetoothValue::TArrayOfBluetoothNamedValue,
|
||||
"PropertyChanged: Invalid value type");
|
||||
|
||||
BluetoothNamedValue v = arr[0];
|
||||
SetPropertyByValue(v);
|
||||
nsRefPtr<BluetoothPropertyEvent> e = BluetoothPropertyEvent::Create(v.name());
|
||||
e->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("propertychanged"));
|
||||
} else if (aData.name().EqualsLiteral("RequestConfirmation")) {
|
||||
arr = aData.value().get_ArrayOfBluetoothNamedValue();
|
||||
if(arr.Length() != 2) {
|
||||
NS_ERROR("RequestConfirmation: Length of parameters is wrong");
|
||||
return;
|
||||
}
|
||||
|
||||
nsString deviceAddress = arr[0].value().get_nsString();
|
||||
uint32_t passkey = arr[1].value().get_uint32_t();
|
||||
NS_ASSERTION(arr.Length() == 2, "RequestConfirmation: Wrong length of parameters");
|
||||
NS_ASSERTION(arr[0].value().type() == BluetoothValue::TnsString,
|
||||
"RequestConfirmation: Invalid value type");
|
||||
NS_ASSERTION(arr[1].value().type() == BluetoothValue::Tuint32_t,
|
||||
"RequestConfirmation: Invalid value type");
|
||||
|
||||
nsRefPtr<BluetoothPairingEvent> e = BluetoothPairingEvent::Create(deviceAddress, passkey);
|
||||
e->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("requestconfirmation"));
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
NS_NewDOMBluetoothPairingEvent(getter_AddRefs(event), nullptr, nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMBluetoothPairingEvent> e = do_QueryInterface(event);
|
||||
e->InitBluetoothPairingEvent(NS_LITERAL_STRING("requestconfirmation"),
|
||||
false,
|
||||
false,
|
||||
arr[0].value().get_nsString(),
|
||||
arr[1].value().get_uint32_t());
|
||||
e->SetTrusted(true);
|
||||
bool dummy;
|
||||
DispatchEvent(event, &dummy);
|
||||
} else if (aData.name().EqualsLiteral("RequestPinCode")) {
|
||||
arr = aData.value().get_ArrayOfBluetoothNamedValue();
|
||||
if(arr.Length() != 1) {
|
||||
NS_ERROR("RequestPinCode: Length of parameters is wrong");
|
||||
return;
|
||||
}
|
||||
|
||||
nsString deviceAddress = arr[0].value().get_nsString();
|
||||
NS_ASSERTION(arr.Length() == 1, "RequestPinCode: Wrong length of parameters");
|
||||
NS_ASSERTION(arr[0].value().type() == BluetoothValue::TnsString,
|
||||
"RequestPinCode: Invalid value type");
|
||||
|
||||
nsRefPtr<BluetoothPairingEvent> e = BluetoothPairingEvent::Create(deviceAddress, 0);
|
||||
e->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("requestpincode"));
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
NS_NewDOMBluetoothDeviceAddressEvent(getter_AddRefs(event), nullptr, nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMBluetoothDeviceAddressEvent> e = do_QueryInterface(event);
|
||||
e->InitBluetoothDeviceAddressEvent(NS_LITERAL_STRING("requestpincode"),
|
||||
false, false, arr[0].value().get_nsString());
|
||||
e->SetTrusted(true);
|
||||
bool dummy;
|
||||
DispatchEvent(event, &dummy);
|
||||
} else if (aData.name().EqualsLiteral("RequestPasskey")) {
|
||||
arr = aData.value().get_ArrayOfBluetoothNamedValue();
|
||||
if(arr.Length() != 1) {
|
||||
NS_ERROR("RequestPasskey: Length of parameters is wrong");
|
||||
return;
|
||||
}
|
||||
|
||||
nsString deviceAddress = arr[0].value().get_nsString();
|
||||
NS_ASSERTION(arr.Length() == 1, "RequestPasskey: Wrong length of parameters");
|
||||
NS_ASSERTION(arr[0].value().type() == BluetoothValue::TnsString,
|
||||
"RequestPasskey: Invalid value type");
|
||||
|
||||
nsRefPtr<BluetoothPairingEvent> e = BluetoothPairingEvent::Create(deviceAddress, 0);
|
||||
e->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("requestpasskey"));
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
NS_NewDOMBluetoothDeviceAddressEvent(getter_AddRefs(event), nullptr, nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMBluetoothDeviceAddressEvent> e = do_QueryInterface(event);
|
||||
e->InitBluetoothDeviceAddressEvent(NS_LITERAL_STRING("requestpasskey"),
|
||||
false, false, arr[0].value().get_nsString());
|
||||
e->SetTrusted(true);
|
||||
bool dummy;
|
||||
DispatchEvent(event, &dummy);
|
||||
} else if (aData.name().EqualsLiteral("Authorize")) {
|
||||
arr = aData.value().get_ArrayOfBluetoothNamedValue();
|
||||
if(arr.Length() != 2) {
|
||||
NS_ERROR("Authorize: Length of parameters is wrong");
|
||||
return;
|
||||
}
|
||||
|
||||
nsString deviceAddress = arr[0].value().get_nsString();
|
||||
nsString serviceUuid = arr[1].value().get_nsString();
|
||||
NS_ASSERTION(arr.Length() == 2, "Authorize: Wrong length of parameters");
|
||||
NS_ASSERTION(arr[0].value().type() == BluetoothValue::TnsString,
|
||||
"Authorize: Invalid value type");
|
||||
NS_ASSERTION(arr[1].value().type() == BluetoothValue::TnsString,
|
||||
"Authorize: Invalid value type");
|
||||
|
||||
nsRefPtr<BluetoothPairingEvent> e = BluetoothPairingEvent::Create(deviceAddress, serviceUuid);
|
||||
e->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("authorize"));
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
NS_NewDOMBluetoothAuthorizeEvent(getter_AddRefs(event), nullptr, nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMBluetoothAuthorizeEvent> e = do_QueryInterface(event);
|
||||
e->InitBluetoothAuthorizeEvent(NS_LITERAL_STRING("authorize"),
|
||||
false,
|
||||
false,
|
||||
arr[0].value().get_nsString(),
|
||||
arr[1].value().get_nsString());
|
||||
e->SetTrusted(true);
|
||||
bool dummy;
|
||||
DispatchEvent(event, &dummy);
|
||||
} else if (aData.name().EqualsLiteral("Cancel")) {
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
NS_NewDOMBluetoothDeviceAddressEvent(getter_AddRefs(event), nullptr, nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMBluetoothDeviceAddressEvent> e = do_QueryInterface(event);
|
||||
// Just send a null nsString, won't be used
|
||||
nsString deviceObjectPath = EmptyString();
|
||||
nsRefPtr<BluetoothPairingEvent> e = BluetoothPairingEvent::Create(deviceObjectPath, 0);
|
||||
e->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("cancel"));
|
||||
e->InitBluetoothDeviceAddressEvent(NS_LITERAL_STRING("cancel"),
|
||||
false, false, EmptyString());
|
||||
e->SetTrusted(true);
|
||||
bool dummy;
|
||||
DispatchEvent(event, &dummy);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
nsCString warningMsg;
|
||||
|
@ -33,7 +33,6 @@ CPPSRCS += \
|
||||
BluetoothAdapter.cpp \
|
||||
BluetoothDevice.cpp \
|
||||
BluetoothPropertyEvent.cpp \
|
||||
BluetoothPairingEvent.cpp \
|
||||
BluetoothReplyRunnable.cpp \
|
||||
BluetoothPropertyContainer.cpp \
|
||||
BluetoothUtils.cpp \
|
||||
@ -48,6 +47,7 @@ XPIDLSRCS = \
|
||||
nsIDOMBluetoothDeviceAddressEvent.idl \
|
||||
nsIDOMBluetoothPropertyEvent.idl \
|
||||
nsIDOMBluetoothPairingEvent.idl \
|
||||
nsIDOMBluetoothAuthorizeEvent.idl \
|
||||
$(NULL)
|
||||
|
||||
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
||||
|
26
dom/bluetooth/nsIDOMBluetoothAuthorizeEvent.idl
Normal file
26
dom/bluetooth/nsIDOMBluetoothAuthorizeEvent.idl
Normal file
@ -0,0 +1,26 @@
|
||||
/* -*- 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(1cfe7854-31a6-4a41-add6-b4ed35869a6d)]
|
||||
interface nsIDOMBluetoothAuthorizeEvent : nsIDOMEvent
|
||||
{
|
||||
readonly attribute DOMString deviceAddress;
|
||||
readonly attribute DOMString uuid;
|
||||
|
||||
[noscript] void initBluetoothAuthorizeEvent(in DOMString aType,
|
||||
in boolean aCanBubble,
|
||||
in boolean aCancelable,
|
||||
in DOMString aDeviceAddress,
|
||||
in DOMString aUuid);
|
||||
};
|
||||
|
||||
dictionary BluetoothAuthorizeEventInit : EventInit
|
||||
{
|
||||
DOMString deviceAddress;
|
||||
DOMString uuid;
|
||||
};
|
@ -6,10 +6,21 @@
|
||||
|
||||
#include "nsIDOMEvent.idl"
|
||||
|
||||
[scriptable, builtinclass, uuid(b905b05e-2141-444c-a90d-525b6c0daff1)]
|
||||
[scriptable, builtinclass, uuid(333022b8-a7e5-4fff-8588-36f2eedff17e)]
|
||||
interface nsIDOMBluetoothPairingEvent : nsIDOMEvent
|
||||
{
|
||||
readonly attribute DOMString deviceAddress;
|
||||
readonly attribute DOMString uuid;
|
||||
readonly attribute unsigned long passkey;
|
||||
|
||||
[noscript] void initBluetoothPairingEvent(in DOMString aType,
|
||||
in boolean aCanBubble,
|
||||
in boolean aCancelable,
|
||||
in DOMString aDeviceAddress,
|
||||
in unsigned long aPasskey);
|
||||
};
|
||||
|
||||
dictionary BluetoothPairingEventInit : EventInit
|
||||
{
|
||||
DOMString deviceAddress;
|
||||
unsigned long passkey;
|
||||
};
|
||||
|
@ -22,8 +22,10 @@ simple_events = [
|
||||
'DeviceLightEvent',
|
||||
'MozApplicationEvent',
|
||||
#ifdef MOZ_B2G_BT
|
||||
'BluetoothDeviceAddressEvent',
|
||||
'BluetoothAuthorizeEvent',
|
||||
'BluetoothDeviceEvent',
|
||||
'BluetoothDeviceAddressEvent',
|
||||
'BluetoothPairingEvent',
|
||||
#endif
|
||||
'DeviceStorageChangeEvent',
|
||||
'PopupBlockedEvent'
|
||||
|
Loading…
Reference in New Issue
Block a user