Bug 855607 - B2G MMS: Notify user while retrieving expiried notification indication. r=vyang, a=leo+
authorVicamo Yang <vyang@mozilla.com>
Thu, 18 Apr 2013 09:09:48 +0800
changeset 119104 6aa156cf431c1aa68784e034f0b7cfb2c1dcff34
parent 119103 eb102e6d41c0593e96c35f81e54232826f4bcb07
child 119105 90f543e4a4e030eb22227a80b481398870b2b5f3
push id680
push uservyang@mozilla.com
push dateThu, 18 Apr 2013 01:11:41 +0000
reviewersvyang, leo
bugs855607
milestone18.0
Bug 855607 - B2G MMS: Notify user while retrieving expiried notification indication. r=vyang, a=leo+
dom/mms/src/ril/MmsService.js
--- a/dom/mms/src/ril/MmsService.js
+++ b/dom/mms/src/ril/MmsService.js
@@ -1352,16 +1352,27 @@ MmsService.prototype = {
       }
       if (!aMessageRecord.headers ||
           !aMessageRecord.headers["x-mms-content-location"]) {
         debug("Can't find mms content url in database.");
         aRequest.notifyGetMessageFailed(Ci.nsIMobileMessageCallback.INTERNAL_ERROR);
         return;
       }
 
+      // Cite 6.2 "Multimedia Message Notification" in OMA-TS-MMS_ENC-V1_3-20110913-A:
+      //   The field has only one format, relative. The recipient client calculates this
+      //   length of time relative to the time it receives the notification.
+      let expiriedDate = aMessageRecord.timestamp +
+        aMessageRecord.headers["x-mms-expiry"] * 1000;
+      if (expiriedDate < Date.now()) {
+        aRequest.notifyGetMessageFailed(Ci.nsIMobileMessageCallback.NOT_FOUND_ERROR);
+        debug("This notification indication is expired.");
+        return;
+      }
+
       let url =  aMessageRecord.headers["x-mms-content-location"].uri;
       // For X-Mms-Report-Allowed
       let wish = aMessageRecord.headers["x-mms-delivery-report"];
       this.retrieveMessage(url, (function responseNotify(mmsStatus, retrievedMsg) {
         // If the mmsStatus is still MMS_PDU_STATUS_DEFERRED after retry,
         // we should not store it into database.
         if (MMS.MMS_PDU_STATUS_RETRIEVED !== mmsStatus) {
           debug("RetrieveMessage fail after retry.");