Closed Bug 1000935 Opened 10 years ago Closed 10 years ago

[NFC] Support sending NDEF messages on Emulator

Categories

(Firefox OS Graveyard :: NFC, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: tzimmermann, Assigned: tzimmermann)

References

Details

Attachments

(3 files, 4 obsolete files)

This is the send part of bug 980851.
Attached file Github pull request
This implements the whole protocol stack for sending NDEF messages over LLCP, and most of the primitives for receiving.
Attachment #8411877 - Flags: review?(vyang)
Attached patch [01] Bug 1000935: Added NfcUtils (obsolete) — Splinter Review
Copied from Gaia.
Attachment #8411880 - Flags: review?(vyang)
This test case uses most of the protocol stack in the pull request.
Attachment #8411883 - Flags: review?(vyang)
Depends on: 1000191
Blocks: 993836
Comment on attachment 8411880 [details] [diff] [review]
[01] Bug 1000935: Added NfcUtils

Review of attachment 8411880 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/nfc/tests/marionette/head.js
@@ +87,5 @@
> +
> +/* -*- Mode: js; js-indent-level: 2; indent-tabs-mode: nil -*- */
> +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
> +
> +/* Copyright © 2013, Deutsche Telekom, Inc. */

Hi, I don't think we can merge a patch that explicitly says its copyright is not owned by Mozilla or not being MPL/CC compatible.  Actually, this file has already copyright declaration right on the first line. http://mxr.mozilla.org/mozilla-central/source/dom/nfc/tests/marionette/head.js#1
Attachment #8411880 - Flags: review?(vyang) → review-
Attachment #8411883 - Flags: review?(vyang) → review?(dlee)
(In reply to Vicamo Yang [:vicamo][:vyang] from comment #4)
> Comment on attachment 8411880 [details] [diff] [review]
> [01] Bug 1000935: Added NfcUtils
> 
> Review of attachment 8411880 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: dom/nfc/tests/marionette/head.js
> @@ +87,5 @@
> > +
> > +/* -*- Mode: js; js-indent-level: 2; indent-tabs-mode: nil -*- */
> > +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
> > +
> > +/* Copyright © 2013, Deutsche Telekom, Inc. */
> 
> Hi, I don't think we can merge a patch that explicitly says its copyright is
> not owned by Mozilla or not being MPL/CC compatible.

That is not strictly a problem, I think. I copied the license statement and code below from directly Gaia. [1] But I'm not really happy with the situation either. Maybe we can add the code under Public Domain here if the DT guys don't mind.

Garner, are you OK with me adding the code of [1] as Public Domain here?

[1] https://github.com/mozilla-b2g/gaia/blob/master/shared/js/nfc_utils.js
Flags: needinfo?(dgarnerlee)
I believe Mozilla Public License can be added explicitly (and probably made consistent elsewhere as well), if MPL is not already inherited from the associated parent repository license. I'll go check through the proper channels if it can be even more explicitly open for Utility files and test cases (full Public Domain).
Flags: needinfo?(dgarnerlee)
(In reply to Thomas Zimmermann [:tzimmermann] [:tdz] from comment #5)
> (In reply to Vicamo Yang [:vicamo][:vyang] from comment #4)
> > Hi, I don't think we can merge a patch that explicitly says its copyright is
> > not owned by Mozilla or not being MPL/CC compatible.
> 
> That is not strictly a problem, I think. I copied the license statement and
> code below from directly Gaia. [1] But I'm not really happy with the
> situation either.

That only means the committer/reviewer of the pull request doesn't pay enough attention to software license agreements.

This file has been released under CC Public Domain and I don't feel it necessary to change.  Adding a line to claim DT owns the copyright is really ambiguous here.  How can you dedicate the rights you're holding to public domain while owning them?
(In reply to Vicamo Yang [:vicamo][:vyang] from comment #7)
> (In reply to Thomas Zimmermann [:tzimmermann] [:tdz] from comment #5)
> > (In reply to Vicamo Yang [:vicamo][:vyang] from comment #4)
> > > Hi, I don't think we can merge a patch that explicitly says its copyright is
> > > not owned by Mozilla or not being MPL/CC compatible.
> > 
> > That is not strictly a problem, I think. I copied the license statement and
> > code below from directly Gaia. [1] But I'm not really happy with the
> > situation either.
> 
> That only means the committer/reviewer of the pull request doesn't pay
> enough attention to software license agreements.

No. The license discussion came up when the NFC code landed in the first place in bug 674741. Apparently it was decided that Mozilla doesn't need to hold copyright.

> 
> This file has been released under CC Public Domain and I don't feel it
> necessary to change.  Adding a line to claim DT owns the copyright is really
> ambiguous here.  How can you dedicate the rights you're holding to public
> domain while owning them?

If you're the owner of the code, you can license it in any way you what. Dual-licensing is nothing uncommon.
BTW, is there a way to specify more than one file in MARIONETTE_HEAD_JS? Having multiple files with individual licenses could ease such license mess in the future.
Comment on attachment 8411883 [details] [diff] [review]
[02] Bug 1000935: Added Marionette test for NfcPeer.sendNDEF

Review of attachment 8411883 [details] [diff] [review]:
-----------------------------------------------------------------

Pass local test ! r+ with nits fixed

::: dom/nfc/tests/marionette/test_nfc_peer_sendndef.js
@@ +3,5 @@
> +
> +MARIONETTE_TIMEOUT = 30000;
> +MARIONETTE_HEAD_JS = 'head.js';
> +
> +let url = 'https://www.example.com';

From MDN coding style and checked other test cases, double-quoted strings are preferred.
To sync our coding style, could you help modify here and below to use double-quoted literals, thanks

@@ +46,5 @@
> +  return ndef;
> +}
> +
> +function sendNDEF(techType, sessionToken) {
> +  let tnf = 1;

Could use TNF_WELL_KNOWN defined in head.js

@@ +52,5 @@
> +  let id = new Uint8Array(NfcUtils.fromUTF8(''));
> +  let payload = new Uint8Array(NfcUtils.fromUTF8(url));
> +  let ndef = [new MozNDEFRecord(tnf, type, id, payload)];
> +
> +  let peer = window.navigator.mozNfc.getNFCPeer(sessionToken);

After bug 987596 is land, we could use nfc directly instead of window.navigator.mozNfc

@@ +103,5 @@
> +SpecialPowers.pushPermissions(
> +  [{'type': 'nfc', 'allow': true,
> +                   'read': true, 'write': true, context: document},
> +   {'type': 'nfc-manager', 'allow': true, context: document},
> +   {'type': 'settings', 'allow': true, context: document}], runTests);

settings permission is not required now.
Attachment #8411883 - Flags: review?(dlee) → review+
(In reply to Thomas Zimmermann [:tzimmermann] [:tdz] from comment #9)
> BTW, is there a way to specify more than one file in MARIONETTE_HEAD_JS?
> Having multiple files with individual licenses could ease such license mess
> in the future.

That was landed in bug 805838.  One can always send a patch to allow multiple, even nested MARIONETTE_HEAD_JS labels if necessary.
(In reply to Thomas Zimmermann [:tzimmermann] [:tdz] from comment #8)
> (In reply to Vicamo Yang [:vicamo][:vyang] from comment #7)
> > This file has been released under CC Public Domain and I don't feel it
> > necessary to change.  Adding a line to claim DT owns the copyright is really
> > ambiguous here.  How can you dedicate the rights you're holding to public
> > domain while owning them?
> 
> If you're the owner of the code, you can license it in any way you what.
> Dual-licensing is nothing uncommon.

I mean the word "dedicate" used in CC Public Domain literally disallow owning copyright by the author at the same time.  Wikipedia has a more clearer definition: "Works in the public domain are those whose intellectual property rights have expired, have been forfeited, or are inapplicable."  The original license term also has "A certifier, moreover, dedicates any copyright interest he may have in the associated work, and for these purposes."  One may claim the authorship of a piece of Public Domain work, but he no longer owns copyright because, by Public Domain terms, he has given up the copyright related to the work.

http://creativecommons.org/licenses/publicdomain/
Comment on attachment 8411877 [details]
Github pull request

Hi, a few questions, typo on Github.  That's really an awesome job!  Thank you.
Attachment #8411877 - Flags: review?(vyang)
Depends on: 996426
This bug blocks NFC 2.0 release.
Blocks: b2g-NFC-2.0
Comment on attachment 8411877 [details]
Github pull request

Updated github pull request

  - rebased on top of bug 996426
  - added white spaces around operators
  - fixed typo 'nsep'
Changes since v1:

  - replaced single quotes by double quotes
  - use NDEF.TNF_WELL_KNOWN
  - don't acquire settings permission
  - replace remaining 'var' by 'let'

I didn't change |window.navigator.mozNfc| to |nfc|. IMHO that variable mostly adds confusion and needs a cleanup first to be more discoverable.
Attachment #8411883 - Attachment is obsolete: true
Attachment #8417354 - Flags: review+
I reimplemented the required utility functions from scratch to solve the licensing problems for now. It's not much extra code.
Attachment #8411880 - Attachment is obsolete: true
Attachment #8419320 - Flags: review?(vyang)
Changes since v2:

  - rebased onto bug 996426
Attachment #8417354 - Attachment is obsolete: true
Attachment #8419321 - Flags: review+
Comment on attachment 8411877 [details]
Github pull request

Hi Vicamo,

I updated the pull request as reported in comment 15 and rebased once more, now that bug 996426 has landed. If there's nothing else, I'd like to get the patches merged.
Attachment #8411877 - Flags: review?(vyang)
Attachment #8419320 - Flags: review?(vyang) → review+
Comment on attachment 8411877 [details]
Github pull request

I'll merge it after https://tbpl.mozilla.org/?tree=B2g-Inbound&rev=14132a1a89dd
Attachment #8411877 - Flags: review?(vyang) → review+
Thanks a lot, Vicamo!
Blocks: 1008854
Blocks: 1008875
https://hg.mozilla.org/mozilla-central/rev/bf6874a80bbf
https://hg.mozilla.org/mozilla-central/rev/1548cd4a5895
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: