diff --git a/dom/mms/src/ril/MmsPduHelper.jsm b/dom/mms/src/ril/MmsPduHelper.jsm index ccd80fd9272d..cd845ac6c9e9 100644 --- a/dom/mms/src/ril/MmsPduHelper.jsm +++ b/dom/mms/src/ril/MmsPduHelper.jsm @@ -14,16 +14,16 @@ Cu.import("resource://gre/modules/mms_consts.js"); let DEBUG; // set to true to see debug messages function translatePduErrorToStatus(error) { - switch (error) { - case MMS_PDU_ERROR_OK: - return MMS_PDU_STATUS_RETRIEVED; - case MMS_PDU_ERROR_TRANSIENT_FAILURE: - case MMS_PDU_ERROR_TRANSIENT_MESSAGE_NOT_FOUND: - case MMS_PDU_ERROR_TRANSIENT_NETWORK_PROBLEM: - return MMS_PDU_STATUS_DEFERRED; - default: - return MMS_PDU_STATUS_UNRECOGNISED; + if (error == MMS_PDU_ERROR_OK) { + return MMS_PDU_STATUS_RETRIEVED; } + + if ((error >= MMS_PDU_ERROR_TRANSIENT_FAILURE) + && (error < MMS_PDU_ERROR_PERMANENT_FAILURE)) { + return MMS_PDU_STATUS_DEFERRED; + } + + return MMS_PDU_STATUS_UNRECOGNISED; } /** @@ -881,25 +881,14 @@ let RetrieveStatusValue = { */ decode: function decode(data) { let value = WSP.Octet.decode(data); - if ((value == 128) - || ((value >= 192) && (value <= 194)) - || ((value >= 224) && (value <= 227))) { + if (value == MMS_PDU_ERROR_OK) { return value; } - if ((value >= 195) && (value <= 223)) { - // The values 195 through 223 are reserved for future use to indicate - // other transient failures. An MMS Client MUST react the same to a value - // in range 195 to 223 as it does to the value 192 - // (Error-transient-failure). - return MMS_PDU_ERROR_TRANSIENT_FAILURE; + if ((value >= MMS_PDU_ERROR_TRANSIENT_FAILURE) && (value < 256)) { + return value; } - // The values 228 through 255 are reserved for future use to indicate - // other permanent failures. An MMS Client MUST react the same to a value - // in range 228 to 255 as it does to the value 224 - // (Error-permanent-failure). - // Any other values SHALL NOT be used. They are reserved for future use. // An MMS Client that receives such a reserved value MUST react the same // as it does to the value 224 (Error-permanent-failure). diff --git a/dom/mms/src/ril/mms_consts.js b/dom/mms/src/ril/mms_consts.js index 8dff6d8a53a3..313d4000ceaa 100644 --- a/dom/mms/src/ril/mms_consts.js +++ b/dom/mms/src/ril/mms_consts.js @@ -33,16 +33,18 @@ const MMS_PDU_TYPE_CANCEL_CONF = 151; // @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.34 const MMS_VERSION = (0x01 << 4) | 0x03; +// Common Status Values +const MMS_PDU_ERROR_OK = 128; +const MMS_PDU_ERROR_TRANSIENT_FAILURE = 192; +const MMS_PDU_ERROR_PERMANENT_FAILURE = 224; + // X-Mms-Retrieve-Status values // @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.50 -const MMS_PDU_ERROR_OK = 128; -const MMS_PDU_ERROR_TRANSIENT_FAILURE = 192; -const MMS_PDU_ERROR_TRANSIENT_MESSAGE_NOT_FOUND = 193; -const MMS_PDU_ERROR_TRANSIENT_NETWORK_PROBLEM = 194; -const MMS_PDU_ERROR_PERMANENT_FAILURE = 224; -const MMS_PDU_ERROR_PERMANENT_SERVICE_DENIED = 225; -const MMS_PDU_ERROR_PERMANENT_MESSAGE_NOT_FOUND = 226; -const MMS_PDU_ERROR_PERMANENT_CONTENT_UNSUPPORTED = 227; +const MMS_PDU_RETRIEVE_ERROR_TRANSIENT_MESSAGE_NOT_FOUND = 193; +const MMS_PDU_RETRIEVE_ERROR_TRANSIENT_NETWORK_PROBLEM = 194; +const MMS_PDU_RETRIEVE_ERROR_PERMANENT_SERVICE_DENIED = 225; +const MMS_PDU_RETRIEVE_ERROR_PERMANENT_MESSAGE_NOT_FOUND = 226; +const MMS_PDU_RETRIEVE_ERROR_PERMANENT_CONTENT_UNSUPPORTED = 227; // X-Mms-Status values // @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.54 diff --git a/dom/mms/tests/test_mms_pdu_helper.js b/dom/mms/tests/test_mms_pdu_helper.js index 1be7c88b5214..4bc066cbd60c 100644 --- a/dom/mms/tests/test_mms_pdu_helper.js +++ b/dom/mms/tests/test_mms_pdu_helper.js @@ -516,14 +516,12 @@ add_test(function test_ReplyChargingValue_decode() { add_test(function test_RetrieveStatusValue_decode() { for (let i = 0; i < 256; i++) { - if ((i == 128) - || ((i >= 192) && (i <= 194)) - || ((i >= 224) && (i <= 227))) { + if ((i == MMS_PDU_ERROR_OK) + || (i >= MMS_PDU_ERROR_TRANSIENT_FAILURE)) { wsp_decode_test(MMS.RetrieveStatusValue, [i], i); - } else if ((i >= 195) && (i <= 223)) { - wsp_decode_test(MMS.RetrieveStatusValue, [i], 192); } else { - wsp_decode_test(MMS.RetrieveStatusValue, [i], 224); + wsp_decode_test(MMS.RetrieveStatusValue, [i], + MMS_PDU_ERROR_PERMANENT_FAILURE); } }