зеркало из https://github.com/mozilla/gecko-dev.git
Bug 867440 - B2G MMS: Add more delivery status in delivery "not-downloaded" and send the dom message with right delivery status. r=vyang, a=leo+
This commit is contained in:
Родитель
55806cc6a3
Коммит
e991389d32
|
@ -58,9 +58,11 @@ const DELIVERY_SENDING = "sending";
|
|||
const DELIVERY_SENT = "sent";
|
||||
const DELIVERY_ERROR = "error";
|
||||
|
||||
const DELIVERY_STATUS_SUCCESS = "success";
|
||||
const DELIVERY_STATUS_PENDING = "pending";
|
||||
const DELIVERY_STATUS_ERROR = "error";
|
||||
const DELIVERY_STATUS_SUCCESS = "success";
|
||||
const DELIVERY_STATUS_PENDING = "pending";
|
||||
const DELIVERY_STATUS_ERROR = "error";
|
||||
const DELIVERY_STATUS_REJECTED = "rejected";
|
||||
const DELIVERY_STATUS_MANUAL = "manual";
|
||||
|
||||
const PREF_SEND_RETRY_COUNT =
|
||||
Services.prefs.getIntPref("dom.mms.sendRetryCount");
|
||||
|
@ -966,13 +968,35 @@ MmsService.prototype = {
|
|||
/**
|
||||
* Convert intermediate message to indexedDB savable object.
|
||||
*
|
||||
* @param retrievalMode
|
||||
* Retrieval mode for MMS receiving setting.
|
||||
* @param intermediate
|
||||
* Intermediate MMS message parsed from PDU.
|
||||
*/
|
||||
convertIntermediateToSavable: function convertIntermediateToSavable(intermediate) {
|
||||
convertIntermediateToSavable: function convertIntermediateToSavable(intermediate,
|
||||
retrievalMode) {
|
||||
intermediate.type = "mms";
|
||||
intermediate.delivery = DELIVERY_NOT_DOWNLOADED;
|
||||
intermediate.deliveryStatus = [DELIVERY_STATUS_PENDING];
|
||||
|
||||
switch(retrievalMode) {
|
||||
case RETRIEVAL_MODE_MANUAL:
|
||||
intermediate.deliveryStatus = [DELIVERY_STATUS_MANUAL];
|
||||
break;
|
||||
case RETRIEVAL_MODE_NEVER:
|
||||
intermediate.deliveryStatus = [DELIVERY_STATUS_REJECTED];
|
||||
break;
|
||||
case RETRIEVAL_MODE_AUTOMATIC:
|
||||
intermediate.deliveryStatus = [DELIVERY_STATUS_PENDING];
|
||||
break;
|
||||
case RETRIEVAL_MODE_AUTOMATIC_HOME:
|
||||
if (gMmsConnection.isVoiceRoaming()) {
|
||||
intermediate.deliveryStatus = [DELIVERY_STATUS_MANUAL];
|
||||
} else {
|
||||
intermediate.deliveryStatus = [DELIVERY_STATUS_PENDING];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
intermediate.timestamp = Date.now();
|
||||
intermediate.sender = null;
|
||||
intermediate.transactionId = intermediate.headers["x-mms-transaction-id"];
|
||||
|
@ -1136,6 +1160,15 @@ MmsService.prototype = {
|
|||
mmsStatus,
|
||||
reportAllowed);
|
||||
transaction.run();
|
||||
// Retrieved fail after retry, so we update the delivery status in DB and
|
||||
// notify this domMessage that error happen.
|
||||
gMobileMessageDatabaseService.setMessageDelivery(id,
|
||||
null,
|
||||
null,
|
||||
DELIVERY_STATUS_ERROR,
|
||||
(function (rv, domMessage) {
|
||||
this.broadcastReceivedMessageEvent(domMessage);
|
||||
}).bind(this));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1163,7 +1196,7 @@ MmsService.prototype = {
|
|||
// that storing an incoming MMS failed, most likely due to a full disk.
|
||||
// The end user has to retrieve the MMS again.
|
||||
if (DEBUG) debug("Could not store MMS " + domMessage.id +
|
||||
", error code " + rv);
|
||||
", error code " + rv);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1174,7 +1207,8 @@ MmsService.prototype = {
|
|||
/**
|
||||
* Callback for saveReceivedMessage.
|
||||
*/
|
||||
saveReceivedMessageCallback: function saveReceivedMessageCallback(savableMessage,
|
||||
saveReceivedMessageCallback: function saveReceivedMessageCallback(retrievalMode,
|
||||
savableMessage,
|
||||
rv,
|
||||
domMessage) {
|
||||
let success = Components.isSuccessCode(rv);
|
||||
|
@ -1196,11 +1230,6 @@ MmsService.prototype = {
|
|||
|
||||
this.broadcastReceivedMessageEvent(domMessage);
|
||||
|
||||
let retrievalMode = RETRIEVAL_MODE_MANUAL;
|
||||
try {
|
||||
retrievalMode = Services.prefs.getCharPref(PREF_RETRIEVAL_MODE);
|
||||
} catch (e) {}
|
||||
|
||||
// In roaming environment, we send notify response only in
|
||||
// automatic retrieval mode.
|
||||
if ((retrievalMode !== RETRIEVAL_MODE_AUTOMATIC) &&
|
||||
|
@ -1251,11 +1280,18 @@ MmsService.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
let savableMessage = this.convertIntermediateToSavable(notification);
|
||||
let retrievalMode = RETRIEVAL_MODE_MANUAL;
|
||||
try {
|
||||
retrievalMode = Services.prefs.getCharPref(PREF_RETRIEVAL_MODE);
|
||||
} catch (e) {}
|
||||
|
||||
let savableMessage = this.convertIntermediateToSavable(notification, retrievalMode);
|
||||
|
||||
gMobileMessageDatabaseService
|
||||
.saveReceivedMessage(savableMessage,
|
||||
this.saveReceivedMessageCallback.bind(this, savableMessage));
|
||||
this.saveReceivedMessageCallback.bind(this,
|
||||
retrievalMode,
|
||||
savableMessage));
|
||||
}).bind(this));
|
||||
},
|
||||
|
||||
|
@ -1457,6 +1493,16 @@ MmsService.prototype = {
|
|||
aRequest.notifyGetMessageFailed(Ci.nsIMobileMessageCallback.INTERNAL_ERROR);
|
||||
return;
|
||||
}
|
||||
if (DELIVERY_NOT_DOWNLOADED != aMessageRecord.delivery) {
|
||||
if (DEBUG) debug("Delivery of message record is not 'not-downloaded'.");
|
||||
aRequest.notifyGetMessageFailed(Ci.nsIMobileMessageCallback.INTERNAL_ERROR);
|
||||
return;
|
||||
}
|
||||
if (DELIVERY_STATUS_PENDING == aMessageRecord.deliveryStatus) {
|
||||
if (DEBUG) debug("Delivery status of message record is 'pending'.");
|
||||
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
|
||||
|
@ -1474,7 +1520,7 @@ MmsService.prototype = {
|
|||
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) {
|
||||
let responseNotify = 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) {
|
||||
|
@ -1528,7 +1574,14 @@ MmsService.prototype = {
|
|||
let transaction = new AcknowledgeTransaction(transactionId, reportAllowed);
|
||||
transaction.run();
|
||||
}).bind(this));
|
||||
}).bind(this));
|
||||
};
|
||||
// Update the delivery status to pending in DB.
|
||||
gMobileMessageDatabaseService
|
||||
.setMessageDelivery(aMessageId,
|
||||
null,
|
||||
null,
|
||||
DELIVERY_STATUS_PENDING,
|
||||
this.retrieveMessage(url, responseNotify.bind(this)));
|
||||
}).bind(this));
|
||||
},
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ extern const char* kMmsReceivedObserverTopic;
|
|||
#define DELIVERY_STATUS_SUCCESS NS_LITERAL_STRING("success")
|
||||
#define DELIVERY_STATUS_PENDING NS_LITERAL_STRING("pending")
|
||||
#define DELIVERY_STATUS_ERROR NS_LITERAL_STRING("error")
|
||||
#define DELIVERY_STATUS_REJECTED NS_LITERAL_STRING("rejected")
|
||||
#define DELIVERY_STATUS_MANUAL NS_LITERAL_STRING("manual")
|
||||
|
||||
#define MESSAGE_CLASS_NORMAL NS_LITERAL_STRING("normal")
|
||||
#define MESSAGE_CLASS_CLASS_0 NS_LITERAL_STRING("class-0")
|
||||
|
|
|
@ -187,6 +187,10 @@ MmsMessage::Create(int32_t aId,
|
|||
status = eDeliveryStatus_Pending;
|
||||
} else if (statusStr.Equals(DELIVERY_STATUS_ERROR)) {
|
||||
status = eDeliveryStatus_Error;
|
||||
} else if (statusStr.Equals(DELIVERY_STATUS_REJECTED)) {
|
||||
status = eDeliveryStatus_Reject;
|
||||
} else if (statusStr.Equals(DELIVERY_STATUS_MANUAL)) {
|
||||
status = eDeliveryStatus_Manual;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
@ -390,6 +394,12 @@ MmsMessage::GetDeliveryStatus(JSContext* aCx, JS::Value* aDeliveryStatus)
|
|||
case eDeliveryStatus_Error:
|
||||
statusStr = DELIVERY_STATUS_ERROR;
|
||||
break;
|
||||
case eDeliveryStatus_Reject:
|
||||
statusStr = DELIVERY_STATUS_REJECTED;
|
||||
break;
|
||||
case eDeliveryStatus_Manual:
|
||||
statusStr = DELIVERY_STATUS_MANUAL;
|
||||
break;
|
||||
case eDeliveryStatus_EndGuard:
|
||||
default:
|
||||
MOZ_NOT_REACHED("We shouldn't get any other delivery status!");
|
||||
|
|
|
@ -219,7 +219,7 @@ MobileMessageThread::GetLastMessageType(nsAString& aLastMessageType)
|
|||
break;
|
||||
case eMessageType_EndGuard:
|
||||
default:
|
||||
MOZ_NOT_REACHED("We shouldn't get any other delivery state!");
|
||||
MOZ_NOT_REACHED("We shouldn't get any other message type!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ enum DeliveryStatus {
|
|||
eDeliveryStatus_Success,
|
||||
eDeliveryStatus_Pending,
|
||||
eDeliveryStatus_Error,
|
||||
eDeliveryStatus_Reject,
|
||||
eDeliveryStatus_Manual,
|
||||
// This state should stay at the end.
|
||||
eDeliveryStatus_EndGuard
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче