Bug 987595 - B2G NFC: onpeerready isn't called. r=dimi

This commit is contained in:
Yoshi Huang 2014-03-25 19:14:41 +08:00
parent d57ebccf9b
commit 1e5774cd89

View File

@ -358,21 +358,10 @@ NfcContentHelper.prototype = {
receiveMessage: function receiveMessage(message) {
debug("Message received: " + JSON.stringify(message));
let result = message.json;
let requester = this._requestMap[result.requestId];
if (!requester) {
debug("Response Invalid requestId=" + result.requestId);
return;
}
delete this._requestMap[result.requestId];
if (result.status !== NFC.GECKO_NFC_ERROR_SUCCESS) {
this.fireRequestError(atob(result.requestId), result.status);
return;
}
switch (message.name) {
case "NFC:ReadNDEFResponse":
this.handleReadNDEFResponse(requester, result);
this.handleReadNDEFResponse(result);
break;
case "NFC:GetDetailsNDEFResponse":
this.handleGetDetailsNDEFResponse(result);
@ -397,7 +386,19 @@ NfcContentHelper.prototype = {
}
},
handleReadNDEFResponse: function handleReadNDEFResponse(requester, result) {
handleReadNDEFResponse: function handleReadNDEFResponse(result) {
let requester = this._requestMap[result.requestId];
if (!requester) {
debug("Response Invalid requestId=" + result.requestId);
return;
}
delete this._requestMap[result.requestId];
if (result.status !== NFC.GECKO_NFC_ERROR_SUCCESS) {
this.fireRequestError(atob(result.requestId), result.status);
return;
}
let requestId = atob(result.requestId);
let ndefMsg = [];
let records = result.records;
@ -412,6 +413,11 @@ NfcContentHelper.prototype = {
},
handleGetDetailsNDEFResponse: function handleGetDetailsNDEFResponse(result) {
if (result.status !== NFC.GECKO_NFC_ERROR_SUCCESS) {
this.fireRequestError(atob(result.requestId), result.status);
return;
}
let requestId = atob(result.requestId);
let result = new GetDetailsNDEFResponse(result);
this.fireRequestSuccess(requestId, result);