Bug 1082452 - B2G NFC: Add a parameter 'isP2P' in WriteNDEF request. r=smaug, dimi
authorYoshi Huang <allstars.chh@mozilla.com>
Wed, 15 Oct 2014 11:54:09 +0800
changeset 210708 528b832ab47813351a1d689561235588c3cd45ed
parent 210707 f461eb1653f1ef28b29029e7e0d00363cd2f2152
child 210709 c6e8d12832f7814d702ae3af5dba78e03e86ee0f
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerssmaug, dimi
bugs1082452
milestone36.0a1
Bug 1082452 - B2G NFC: Add a parameter 'isP2P' in WriteNDEF request. r=smaug, dimi
dom/nfc/gonk/Nfc.js
dom/nfc/gonk/NfcGonkMessage.h
dom/nfc/gonk/NfcMessageHandler.cpp
dom/nfc/gonk/NfcOptions.h
dom/webidl/NfcOptions.webidl
--- a/dom/nfc/gonk/Nfc.js
+++ b/dom/nfc/gonk/Nfc.js
@@ -625,16 +625,17 @@ Nfc.prototype = {
       case "NFC:PowerOff":
         this.setConfig({powerLevel: NFC.NFC_POWER_LEVEL_DISABLED,
                         requestId: message.data.requestId});
         break;
       case "NFC:ReadNDEF":
         this.sendToNfcService("readNDEF", message.data);
         break;
       case "NFC:WriteNDEF":
+        message.data.isP2P = SessionHelper.isP2PSession(message.data.sessionId);
         this.sendToNfcService("writeNDEF", message.data);
         break;
       case "NFC:MakeReadOnlyNDEF":
         this.sendToNfcService("makeReadOnlyNDEF", message.data);
         break;
       case "NFC:Connect":
         this.sendToNfcService("connect", message.data);
         break;
--- a/dom/nfc/gonk/NfcGonkMessage.h
+++ b/dom/nfc/gonk/NfcGonkMessage.h
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef NfcGonkMessage_h
 #define NfcGonkMessage_h
 
 namespace mozilla {
 
 #define NFCD_MAJOR_VERSION 1
-#define NFCD_MINOR_VERSION 10
+#define NFCD_MINOR_VERSION 11
 
 enum NfcRequest {
   ConfigReq = 0,
   ConnectReq,
   CloseReq,
   ReadNDEFReq,
   WriteNDEFReq,
   MakeReadOnlyNDEFReq,
--- a/dom/nfc/gonk/NfcMessageHandler.cpp
+++ b/dom/nfc/gonk/NfcMessageHandler.cpp
@@ -191,16 +191,17 @@ NfcMessageHandler::ReadNDEFResponse(cons
   return true;
 }
 
 bool
 NfcMessageHandler::WriteNDEFRequest(Parcel& aParcel, const CommandOptions& aOptions)
 {
   aParcel.writeInt32(NfcRequest::WriteNDEFReq);
   aParcel.writeInt32(aOptions.mSessionId);
+  aParcel.writeInt32(aOptions.mIsP2P);
   WriteNDEFMessage(aParcel, aOptions);
   mRequestIdQueue.AppendElement(aOptions.mRequestId);
   return true;
 }
 
 bool
 NfcMessageHandler::MakeReadOnlyNDEFRequest(Parcel& aParcel, const CommandOptions& aOptions)
 {
--- a/dom/nfc/gonk/NfcOptions.h
+++ b/dom/nfc/gonk/NfcOptions.h
@@ -31,16 +31,17 @@ struct CommandOptions
     prop = defaultValue;                              \
   }
 
     COPY_FIELD(mType)
     COPY_FIELD(mRequestId)
     COPY_OPT_FIELD(mSessionId, 0)
     COPY_OPT_FIELD(mPowerLevel, 0)
     COPY_OPT_FIELD(mTechType, 0)
+    COPY_OPT_FIELD(mIsP2P, false)
 
     if (!aOther.mRecords.WasPassed()) {
       return;
     }
 
     mozilla::dom::Sequence<mozilla::dom::MozNDEFRecordOptions> const & currentValue = aOther.mRecords.InternalValue();
     int count = currentValue.Length();
     for (int32_t i = 0; i < count; i++) {
@@ -72,16 +73,17 @@ struct CommandOptions
 #undef COPY_OPT_FIELD
   }
 
   nsString mType;
   int32_t mSessionId;
   nsString mRequestId;
   int32_t mPowerLevel;
   int32_t mTechType;
+  bool mIsP2P;
   nsTArray<NDEFRecordStruct> mRecords;
 };
 
 struct EventOptions
 {
   EventOptions()
     : mType(EmptyString()), mStatus(-1), mSessionId(-1), mRequestId(EmptyString()), mMajorVersion(-1), mMinorVersion(-1),
       mIsReadOnly(-1), mCanBeMadeReadOnly(-1), mMaxSupportedLength(-1), mPowerLevel(-1),
--- a/dom/webidl/NfcOptions.webidl
+++ b/dom/webidl/NfcOptions.webidl
@@ -8,16 +8,17 @@ dictionary NfcCommandOptions
 
   long sessionId;
   DOMString requestId = "";
 
   long powerLevel;
 
   long techType;
 
+  boolean isP2P;
   sequence<MozNDEFRecordOptions> records;
 };
 
 dictionary NfcEventOptions
 {
   DOMString type = "";
 
   long status;