Closed Bug 1015090 Opened 6 years ago Closed 6 years ago

Add BluetoothAdapterEvent.webidl and BluetoothAttributeEvent.webidl

Categories

(Firefox OS Graveyard :: Bluetooth, defect)

ARM
Gonk (Firefox OS)
defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ben.tian, Assigned: ben.tian)

References

Details

(Whiteboard: [webbt-api])

Attachments

(1 file, 4 obsolete files)

Assignee: nobody → btian
Whiteboard: [webbt-api]
Wrap the line in BluetoothAttributeEvent.webidl
Attachment #8427620 - Attachment is obsolete: true
Sync dom/bluetooth/moz.build change in bug 942104 comment 73.
Attachment #8427626 - Attachment is obsolete: true
Move dom/webidl/moz.build change for Bluetooth*Events to dev patch in bug 1005848 comment 3.
Attachment #8427638 - Attachment is obsolete: true
Comment on attachment 8427638 [details] [diff] [review]
Patch 1 (v3): add BluetoothAdapterEvent.webidl and BluetoothAttributeEvent.webidl

># HG changeset patch
># User Ben Tian <btian@mozilla.com>
># Date 1400838878 -28800
># Node ID cfca0acce1bb2dd3a46def98a52424aea32769a9
># Parent  6345c67e9dbe66f77302e76682265e8b89e150e0
>Bug 1015090 - Add BluetoothAdapterEvent.webidl and BluetoothAttributeEvent.webidl
>
>diff --git a/dom/bluetooth2/moz.build b/dom/bluetooth2/moz.build
>--- a/dom/bluetooth2/moz.build
>+++ b/dom/bluetooth2/moz.build
>@@ -86,17 +86,20 @@ if CONFIG['MOZ_B2G_BT']:
>         'ipc',
>     ]
> 
> EXPORTS.mozilla.dom.bluetooth.ipc += [
>     'ipc/BluetoothMessageUtils.h',
> ]
> 
> EXPORTS.mozilla.dom.bluetooth += [
>+    'BluetoothAdapter.h',
>     'BluetoothCommon.h',
>+    'BluetoothDevice.h',
>+    'BluetoothManager.h',
> ]
> 
> IPDL_SOURCES += [
>     'ipc/BluetoothTypes.ipdlh',
>     'ipc/PBluetooth.ipdl',
>     'ipc/PBluetoothRequest.ipdl',
> ]
> 
>diff --git a/dom/events/test/test_all_synthetic_events.html b/dom/events/test/test_all_synthetic_events.html
>--- a/dom/events/test/test_all_synthetic_events.html
>+++ b/dom/events/test/test_all_synthetic_events.html
>@@ -39,16 +39,24 @@ const kEventConstructors = {
>                                                          e.initEvent(aName, aProps.bubbles, aProps.cancelable);
>                                                          return e;
>                                                        },
>                                              },
>   BlobEvent:                                 { create: function (aName, aProps) {
>                                                          return new BlobEvent(aName, aProps);
>                                                        },
>                                              },
>+  BluetoothAdapterEvent:                     { create: function (aName, aProps) {
>+                                                          return new BluetoothAdapterEvent(aName, aProps);
>+                                                       },
>+                                             },
>+  BluetoothAttributeEvent:                   { create: function (aName, aProps) {
>+                                                          return new BluetoothAttributeEvent(aName, aProps);
>+                                                       },
>+                                             },
>   BluetoothDeviceEvent:                      { create: function (aName, aProps) {
>                                                           return new BluetoothDeviceEvent(aName, aProps);
>                                                        },
>                                              },
>   BluetoothStatusChangedEvent:               { create: function (aName, aProps) {
>                                                           return new BluetoothStatusChangedEvent(aName, aProps);
>                                                        },
>                                              },
>diff --git a/dom/webidl/BluetoothAdapterEvent.webidl b/dom/webidl/BluetoothAdapterEvent.webidl
>new file mode 100644
>--- /dev/null
>+++ b/dom/webidl/BluetoothAdapterEvent.webidl
>@@ -0,0 +1,19 @@
>+/* -*- 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/.
>+ */
>+
>+[Func="Navigator::HasBluetoothSupport",
>+ Constructor(DOMString type, optional BluetoothAdapterEventInit eventInitDict)]
>+interface BluetoothAdapterEvent : Event
>+{
>+  readonly attribute BluetoothAdapter? adapter;
>+  readonly attribute DOMString?        address;
>+};
>+
>+dictionary BluetoothAdapterEventInit : EventInit
>+{
>+  BluetoothAdapter? adapter = null;
>+  DOMString?        address = "";
>+};
>diff --git a/dom/webidl/BluetoothAttributeEvent.webidl b/dom/webidl/BluetoothAttributeEvent.webidl
>new file mode 100644
>--- /dev/null
>+++ b/dom/webidl/BluetoothAttributeEvent.webidl
>@@ -0,0 +1,25 @@
>+/* -*- 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/.
>+ */
>+
>+[Func="Navigator::HasBluetoothSupport",
>+ Constructor(DOMString type,
>+             optional BluetoothAttributeEventInit eventInitDict)]
>+interface BluetoothAttributeEvent : Event
>+{
>+  readonly attribute unsigned short   attr;
>+  readonly attribute any              value;
>+  // We don't support sequences in unions yet (Bug 767924)
>+  /* readonly attribute (BluetoothAdapter or BluetoothAdapterState or
>+   *                     BluetoothClassOfDevice or boolean or
>+   *                     DOMString or sequence<DOMString>) value;
>+   */
>+};
>+
>+dictionary BluetoothAttributeEventInit : EventInit
>+{
>+  unsigned short attr  = 0;
>+  any            value = null;
>+};
>diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build
>--- a/dom/webidl/moz.build
>+++ b/dom/webidl/moz.build
>@@ -649,20 +649,28 @@ GENERATED_EVENTS_WEBIDL_FILES = [
> if CONFIG['MOZ_GAMEPAD']:
>     GENERATED_EVENTS_WEBIDL_FILES += [
>         'GamepadAxisMoveEvent.webidl',
>         'GamepadButtonEvent.webidl',
>         'GamepadEvent.webidl',
>     ]
> 
> if CONFIG['MOZ_B2G_BT']:
>-    GENERATED_EVENTS_WEBIDL_FILES += [
>-        'BluetoothDeviceEvent.webidl',
>-        'BluetoothStatusChangedEvent.webidl',
>-    ]
>+    if CONFIG['MOZ_B2G_BT_API_V2']:
>+        GENERATED_EVENTS_WEBIDL_FILES += [
>+            'BluetoothAdapterEvent.webidl',
>+            'BluetoothAttributeEvent.webidl',
>+            'BluetoothDeviceEvent.webidl',
>+            'BluetoothStatusChangedEvent.webidl',
>+        ]
>+    else:
>+        GENERATED_EVENTS_WEBIDL_FILES += [
>+            'BluetoothDeviceEvent.webidl',
>+            'BluetoothStatusChangedEvent.webidl',
>+        ]
> 
> if CONFIG['MOZ_BUILD_APP'] in ['browser', 'xulrunner']:
>     WEBIDL_FILES += [
>         'BrowserFeedWriter.webidl',
>     ]
> 
> if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/android', 'xulrunner']:
>     WEBIDL_FILES += [
Attachment #8427638 - Attachment is obsolete: false
Attachment #8427653 - Attachment is obsolete: true
Comment on attachment 8427638 [details] [diff] [review]
Patch 1 (v3): add BluetoothAdapterEvent.webidl and BluetoothAttributeEvent.webidl

The patch adds BluetoothAdapterEvent.webidl [1] and BluetoothAttributeEvent.webidl [2], and applies dom/bluetooth/moz.build change in bug 942104 comment 73 to dom/bluetooth2/.

Boris, can you help review this patch?

[1] https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothAdapterEvent
[2] https://wiki.mozilla.org/B2G/Bluetooth/WebBluetooth-v2/BluetoothAttributeEvent
Attachment #8427638 - Flags: review?(bzbarsky)
Comment on attachment 8427638 [details] [diff] [review]
Patch 1 (v3): add BluetoothAdapterEvent.webidl and BluetoothAttributeEvent.webidl

>+  // We don't support sequences in unions yet (Bug 767924)

Maybe file a bug depending on 767924 to fix this bit of IDL to use a union?

>+++ b/dom/webidl/moz.build

Why not leave the two files that are needed either way outside the MOZ_B2G_BT_API_V2 conditional?

r=me either way on that second issue, if there's a good reason to duplicate that bit
Attachment #8427638 - Flags: review?(bzbarsky) → review+
Blocks: 1015796
(In reply to Boris Zbarsky [:bz] from comment #7)
> Maybe file a bug depending on 767924 to fix this bit of IDL to use a union?
Opened bug 1015796 to track.

> >+++ b/dom/webidl/moz.build
> 
> Why not leave the two files that are needed either way outside the
> MOZ_B2G_BT_API_V2 conditional?
> 
> r=me either way on that second issue, if there's a good reason to duplicate
> that bit
Agree. I'll keep the two files outside the conditional.

My thought was to keep a distinct API_V2 event webidl set for clarity since the two files will be removed in API_V2. But keeping them outside the conditional until they are really touched seems a better choice.
Changes:
- Move duplicate two files outside API_V2 conditional in dom/webidl/moz.build
- Rebase on bug 945631's fix
Attachment #8427638 - Attachment is obsolete: true
https://hg.mozilla.org/mozilla-central/rev/b1f349b0ee5f
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.