diff --git a/dom/mobilemessage/interfaces/nsIRilMobileMessageDatabaseService.idl b/dom/mobilemessage/interfaces/nsIRilMobileMessageDatabaseService.idl index 71fe9bd36741..6acd90567640 100644 --- a/dom/mobilemessage/interfaces/nsIRilMobileMessageDatabaseService.idl +++ b/dom/mobilemessage/interfaces/nsIRilMobileMessageDatabaseService.idl @@ -46,6 +46,7 @@ interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService * - |deliveryStatus| DOMString Array: the delivery status of received message * - |receivers| DOMString Array: the phone numbers of receivers * - |phoneNumber| DOMString: [optional] my own phone number. + * - |transactionId| DOMString: the transaction ID from MMS PDU header. * * Note: |deliveryStatus| should only contain single string to specify * the delivery status of MMS message for the phone owner self. diff --git a/dom/mobilemessage/src/gonk/MmsService.js b/dom/mobilemessage/src/gonk/MmsService.js index eaf1fd9fddc3..ae2b6e06d164 100644 --- a/dom/mobilemessage/src/gonk/MmsService.js +++ b/dom/mobilemessage/src/gonk/MmsService.js @@ -1456,6 +1456,7 @@ MmsService.prototype = { } intermediate.timestamp = Date.now(); + intermediate.transactionId = intermediate.headers["x-mms-transaction-id"]; intermediate.receivers = []; intermediate.phoneNumber = mmsConnection.getPhoneNumber(); intermediate.iccId = mmsConnection.getIccId(); @@ -1603,8 +1604,6 @@ MmsService.prototype = { retrievedMessage) { if (DEBUG) debug("retrievedMessage = " + JSON.stringify(retrievedMessage)); - let transactionId = savableMessage.headers["x-mms-transaction-id"]; - // The absence of the field does not indicate any default // value. So we go check the same field in the retrieved // message instead. @@ -1644,6 +1643,8 @@ MmsService.prototype = { savableMessage = this.mergeRetrievalConfirmation(mmsConnection, retrievedMessage, savableMessage); + let transactionId = savableMessage.headers["x-mms-transaction-id"]; + gMobileMessageDatabaseService.saveReceivedMessage(savableMessage, (function (rv, domMessage) { let success = Components.isSuccessCode(rv); diff --git a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js index 1795dfe581e1..8e78361a184c 100644 --- a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js +++ b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js @@ -28,7 +28,7 @@ const DISABLE_MMS_GROUPING_FOR_RECEIVING = true; const DB_NAME = "sms"; -const DB_VERSION = 20; +const DB_VERSION = 19; const MESSAGE_STORE_NAME = "sms"; const THREAD_STORE_NAME = "thread"; const PARTICIPANT_STORE_NAME = "participant"; @@ -260,10 +260,6 @@ MobileMessageDatabaseService.prototype = { self.upgradeSchema18(event.target.transaction, next); break; case 19: - if (DEBUG) debug("Upgrade to version 20. Add readStatus and readTimestamp."); - self.upgradeSchema19(event.target.transaction, next); - break; - case 20: // This will need to be moved for each new version if (DEBUG) debug("Upgrade finished."); break; @@ -1185,35 +1181,6 @@ MobileMessageDatabaseService.prototype = { }; }, - /** - * Add readStatus and readTimestamp. - */ - upgradeSchema19: function upgradeSchema19(transaction, next) { - let messageStore = transaction.objectStore(MESSAGE_STORE_NAME); - messageStore.openCursor().onsuccess = function(event) { - let cursor = event.target.result; - if (!cursor) { - next(); - return; - } - - let messageRecord = cursor.value; - if (messageRecord.type == "sms") { - cursor.continue(); - return; - } - - // We can always retrieve transaction id from - // |messageRecord.headers["x-mms-transaction-id"]|. - if (messageRecord.hasOwnProperty("transactionId")) { - delete messageRecord.transactionId; - } - - cursor.update(messageRecord); - cursor.continue(); - }; - }, - matchParsedPhoneNumbers: function matchParsedPhoneNumbers(addr1, parsedAddr1, addr2, parsedAddr2) { if ((parsedAddr1.internationalNumber && @@ -1976,6 +1943,7 @@ MobileMessageDatabaseService.prototype = { (aMessage.type == "sms" && (aMessage.messageClass == undefined || aMessage.sender == undefined)) || (aMessage.type == "mms" && (aMessage.delivery == undefined || + aMessage.transactionId == undefined || !Array.isArray(aMessage.deliveryInfo) || !Array.isArray(aMessage.receivers))) || aMessage.timestamp == undefined) { @@ -2007,7 +1975,7 @@ MobileMessageDatabaseService.prototype = { aMessage.read = FILTER_READ_UNREAD; if (aMessage.type == "mms") { - aMessage.transactionIdIndex = aMessage.headers["x-mms-transaction-id"]; + aMessage.transactionIdIndex = aMessage.transactionId; aMessage.isReadReportSent = false; // If |deliveryTimestamp| is not specified, use 0 as default.