Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug 850680 - B2G MMS: broadcast "sms-received" and "sms-sent" system …

…messages (part 1, code clean-up). r=vicamo
  • Loading branch information...
commit 2805913e2b9fafe237b0ae88c35059e3c0e15d74 1 parent 123ce43
@airpingu airpingu authored
View
36 dom/mms/src/ril/MmsService.js
@@ -348,8 +348,7 @@ XPCOMUtils.defineLazyGetter(this, "gMmsTransactionHelper", function () {
* status, the other for wrapped PDU data for further parsing.
*/
sendRequest: function sendRequest(method, url, istream, callback) {
- // TODO: bug 810226 - Support of GPRS bearer for MMS transmission and
- // reception
+ // TODO: bug 810226 - Support GPRS bearer for MMS transmission and reception.
gMmsConnection.acquire((function (method, url, istream, callback,
connected) {
@@ -934,7 +933,7 @@ MmsService.prototype = {
if (intermediate.headers.from) {
intermediate.sender = intermediate.headers.from.address;
} else {
- record.sender = "anonymous";
+ intermediate.sender = "anonymous";
}
intermediate.receivers = [];
return intermediate;
@@ -995,10 +994,8 @@ MmsService.prototype = {
* the other parsed MMS message.
*/
retrieveMessage: function retrieveMessage(contentLocation, callback) {
- // TODO: bug 839436 - make DB be able to save MMS messages
// TODO: bug 810099 - support onretrieving event
- // TODO: bug 809832 - support customizable max incoming/outgoing message
- // size.
+ // TODO: bug 809832 - support customizable max incoming/outgoing message size.
let transaction = new RetrieveTransaction(contentLocation);
transaction.run(callback);
@@ -1011,11 +1008,9 @@ MmsService.prototype = {
* The parsed MMS message object.
*/
handleNotificationIndication: function handleNotificationIndication(notification) {
- // TODO: bug 839436 - make DB be able to save MMS messages
-
let url = notification.headers["x-mms-content-location"].uri;
- // TODO: bug 810091 - don't download message twice on receiving duplicated
- // notification
+ // TODO: bug 810091 - don't download message twice when receiving duplicated
+ // notification.
let transactionId = notification.headers["x-mms-transaction-id"];
// For X-Mms-Report-Allowed
@@ -1028,17 +1023,17 @@ MmsService.prototype = {
let success = Components.isSuccessCode(rv);
if (!success) {
// At this point we could send a message to content to notify the
- // user that storing an incoming MMS notify indication failed,
+ // user that storing an incoming MMS notification indication failed,
// ost likely due to a full disk.
debug("Could not store MMS " + JSON.stringify(savableMessage) +
", error code " + rv);
// Because MMSC will resend the notification indication once we don't
// response the notification. Hope the end user will clean some space
- // for the resended notification indication.
+ // for the resent notification indication.
return;
}
- // Notifing new comming notification indication through notifyObservers.
+ // Notifying observers a new notification indication is coming.
Services.obs.notifyObservers(domMessage, kMmsReceivedObserverTopic, null);
let retrievalMode = RETRIEVAL_MODE_MANUAL;
@@ -1062,10 +1057,11 @@ MmsService.prototype = {
return;
}
+ // For RETRIEVAL_MODE_AUTOMATIC, proceed to retrieve MMS.
this.retrieveMessage(url, (function responseNotify(mmsStatus,
retrievedMessage) {
- // `The absence of the field does not indicate any default
- // value.` So we go checking the same field in retrieved
+ // The absence of the field does not indicate any default
+ // value. So we go check the same field in the retrieved
// message instead.
if ((wish == null) && retrievedMessage) {
wish = retrievedMessage.headers["x-mms-delivery-report"];
@@ -1073,11 +1069,11 @@ MmsService.prototype = {
let reportAllowed = this.getReportAllowed(this.confSendDeliveryReport,
wish);
- // Should update the retrievedStatus in databse.
+ // Should update the retrievedStatus in database.
debug("retrievedMessage = " + JSON.stringify(retrievedMessage));
- // If the mmsStatus is still MMS_PDU_STATUS_DEFERRED after retry, we
- // should not store into database.
+ // 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) {
let transaction =
new NotifyResponseTransaction(transactionId,
@@ -1108,7 +1104,7 @@ MmsService.prototype = {
return;
}
- // Notifing new retrieved MMS message through notifyObservers.
+ // Notifying observers an MMS message is received.
Services.obs.notifyObservers(domMessage, kMmsReceivedObserverTopic, null);
}).bind(this)
);
@@ -1248,6 +1244,7 @@ MmsService.prototype = {
aIsSentSuccess ? null : DELIVERY_STATUS_ERROR,
function notifySetDeliveryResult(aRv, aDomMessage) {
debug("Marking the delivery state/staus is done. Notify sent or failed.");
+ // TODO bug 832140 handle !Components.isSuccessCode(aRv)
if (!aIsSentSuccess) {
aRequest.notifySendMessageFailed(Ci.nsIMobileMessageCallback.INTERNAL_ERROR);
Services.obs.notifyObservers(aDomMessage, kMmsFailedObserverTopic, null);
@@ -1263,6 +1260,7 @@ MmsService.prototype = {
.saveSendingMessage(savableMessage,
function notifySendingResult(aRv, aDomMessage) {
debug("Saving sending message is done. Start to send.");
+ // TODO bug 832140 handle !Components.isSuccessCode(aRv)
Services.obs.notifyObservers(aDomMessage, kMmsSendingObserverTopic, null);
let sendTransaction;
try {
View
20 dom/mobilemessage/interfaces/nsIRilMobileMessageDatabaseService.idl
@@ -23,7 +23,17 @@ interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
* - |type| DOMString: "sms" or "mms"
* - |sender| DOMString: the phone number of sender
* - |timestamp| Number: the timestamp of received message
- * - |messageClass| DOMString: the message class of received message
+ *
+ * - If |type| == "sms", we also need:
+ * - |messageClass| DOMString: the message class of received message
+ *
+ * - If |type| == "mms", we also need:
+ * - |delivery| DOMString: the delivery state of received message
+ * - |deliveryStatus| DOMString Array: the delivery status of received message
+ * - |receivers| DOMString Array: the phone numbers of receivers
+ *
+ * Note: |deliveryStatus| should only contain single string to specify
+ * the delivery status of MMS message for the phone owner self.
*/
long saveReceivedMessage(in jsval aMessage,
[optional] in nsIRilMobileMessageDatabaseCallback aCallback);
@@ -31,10 +41,14 @@ interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
/**
* |aMessage| Object: should contain the following properties for internal use:
* - |type| DOMString: "sms" or "mms"
- * - |receiver| DOMString: the phone number of receiver (needed if type = "sms")
- * - |receivers| DOMString: the phone numbers of receivers (needed if type = "mms")
* - |timestamp| Number: the timestamp of sending message
* - |deliveryStatusRequested| Bool: true when the delivery report is requested.
+ *
+ * - If |type| == "sms", we also need:
+ * - |receiver| DOMString: the phone number of receiver
+ *
+ * - If |type| == "mms", we also need:
+ * - |receivers| DOMString Array: the phone numbers of receivers
*/
long saveSendingMessage(in jsval aMessage,
[optional] in nsIRilMobileMessageDatabaseCallback aCallback);
View
23 dom/mobilemessage/src/ril/MobileMessageDatabaseService.js
@@ -1088,7 +1088,7 @@ MobileMessageDatabaseService.prototype = {
threadStore.put(threadRecord);
}
- insertMessageRecord(threadRecord.id);
+ insertMessageRecord(threadRecord.id);
return;
}
@@ -1125,11 +1125,12 @@ MobileMessageDatabaseService.prototype = {
*/
saveReceivedMessage: function saveReceivedMessage(aMessage, aCallback) {
- if (aMessage.type == undefined ||
- aMessage.sender == undefined ||
+ if ((aMessage.type != "sms" && aMessage.type != "mms") ||
(aMessage.type == "sms" && aMessage.messageClass == undefined) ||
- (aMessage.type == "mms" && aMessage.delivery == undefined) ||
- (aMessage.type == "mms" && aMessage.deliveryStatus == undefined) ||
+ (aMessage.type == "mms" && (aMessage.delivery == undefined ||
+ !Array.isArray(aMessage.deliveryStatus) ||
+ !Array.isArray(aMessage.receivers))) ||
+ aMessage.sender == undefined ||
aMessage.timestamp == undefined) {
if (aCallback) {
aCallback.notify(Cr.NS_ERROR_FAILURE, null);
@@ -1139,14 +1140,18 @@ MobileMessageDatabaseService.prototype = {
let self = this.getRilIccInfoMsisdn();
let threadParticipants = [aMessage.sender];
if (aMessage.type == "sms") {
+ // TODO Bug 853384 - for some SIMs we cannot retrieve the vaild
+ // phone number, thus setting the SMS' receiver to be null.
aMessage.receiver = self;
} else if (aMessage.type == "mms") {
let receivers = aMessage.receivers;
if (!receivers.length) {
- // We cannot expose empty receivers for an MMS message.
- // Returns 'myself' when .msisdn is not available.
+ // TODO Bug 853384 - we cannot expose empty receivers for
+ // an MMS message. Returns 'myself' when .msisdn isn't valid.
receivers.push(self ? self : "myself");
} else {
+ // TODO Bug 853384 - we cannot correcly exclude the phone number
+ // from the receivers, thus wrongly building the index.
let slicedReceivers = receivers.slice();
if (self) {
let found = slicedReceivers.indexOf(self);
@@ -1178,7 +1183,7 @@ MobileMessageDatabaseService.prototype = {
saveSendingMessage: function saveSendingMessage(aMessage, aCallback) {
if ((aMessage.type != "sms" && aMessage.type != "mms") ||
(aMessage.type == "sms" && !aMessage.receiver) ||
- (aMessage.type == "mms" && !aMessage.receivers) ||
+ (aMessage.type == "mms" && !Array.isArray(aMessage.receivers)) ||
aMessage.deliveryStatusRequested == undefined ||
aMessage.timestamp == undefined) {
if (aCallback) {
@@ -1211,6 +1216,8 @@ MobileMessageDatabaseService.prototype = {
}
}
+ // TODO Bug 853384 - for some SIMs we cannot retrieve the vaild
+ // phone number, thus setting the message's sender to be null.
aMessage.sender = this.getRilIccInfoMsisdn();
let timestamp = aMessage.timestamp;
View
45 dom/system/gonk/RadioInterfaceLayer.js
@@ -1548,15 +1548,15 @@ RadioInterfaceLayer.prototype = {
}
gSystemMessenger.broadcastMessage("sms-received", {
- id: message.id,
- delivery: DOM_MOBILE_MESSAGE_DELIVERY_RECEIVED,
+ id: message.id,
+ delivery: DOM_MOBILE_MESSAGE_DELIVERY_RECEIVED,
deliveryStatus: RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS,
- sender: message.sender,
- receiver: message.receiver,
- body: message.fullBody,
- messageClass: message.messageClass,
- timestamp: message.timestamp,
- read: false
+ sender: message.sender,
+ receiver: message.receiver,
+ body: message.fullBody,
+ messageClass: message.messageClass,
+ timestamp: message.timestamp,
+ read: false
});
Services.obs.notifyObservers(domMessage, kSmsReceivedObserverTopic, null);
@@ -1617,17 +1617,18 @@ RadioInterfaceLayer.prototype = {
DOM_MOBILE_MESSAGE_DELIVERY_SENT,
options.sms.deliveryStatus,
function notifyResult(rv, domMessage) {
- //TODO bug 832140 handle !Components.isSuccessCode(rv)
- gSystemMessenger.broadcastMessage("sms-sent",
- {id: options.sms.id,
- delivery: DOM_MOBILE_MESSAGE_DELIVERY_SENT,
- deliveryStatus: options.sms.deliveryStatus,
- sender: message.sender || null,
- receiver: options.sms.receiver,
- body: options.sms.body,
- messageClass: options.sms.messageClass,
- timestamp: options.sms.timestamp,
- read: true});
+ // TODO bug 832140 handle !Components.isSuccessCode(rv)
+ gSystemMessenger.broadcastMessage("sms-sent", {
+ id: options.sms.id,
+ delivery: DOM_MOBILE_MESSAGE_DELIVERY_SENT,
+ deliveryStatus: options.sms.deliveryStatus,
+ sender: message.sender || null,
+ receiver: options.sms.receiver,
+ body: options.sms.body,
+ messageClass: options.sms.messageClass,
+ timestamp: options.sms.timestamp,
+ read: true
+ });
if (!options.requestStatusReport) {
// No more used if STATUS-REPORT not requested.
@@ -1655,7 +1656,7 @@ RadioInterfaceLayer.prototype = {
options.sms.delivery,
message.deliveryStatus,
function notifyResult(rv, domMessage) {
- //TODO bug 832140 handle !Components.isSuccessCode(rv)
+ // TODO bug 832140 handle !Components.isSuccessCode(rv)
let topic = (message.deliveryStatus == RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS)
? kSmsDeliverySuccessObserverTopic
: kSmsDeliveryErrorObserverTopic;
@@ -1684,7 +1685,7 @@ RadioInterfaceLayer.prototype = {
DOM_MOBILE_MESSAGE_DELIVERY_ERROR,
RIL.GECKO_SMS_DELIVERY_STATUS_ERROR,
function notifyResult(rv, domMessage) {
- //TODO bug 832140 handle !Components.isSuccessCode(rv)
+ // TODO bug 832140 handle !Components.isSuccessCode(rv)
options.request.notifySendMessageFailed(error);
Services.obs.notifyObservers(domMessage, kSmsFailedObserverTopic, null);
}.bind(this));
@@ -2686,7 +2687,7 @@ RadioInterfaceLayer.prototype = {
let id = gMobileMessageDatabaseService.saveSendingMessage(sendingMessage,
function notifyResult(rv, domMessage) {
- //TODO bug 832140 handle !Components.isSuccessCode(rv)
+ // TODO bug 832140 handle !Components.isSuccessCode(rv)
Services.obs.notifyObservers(domMessage, kSmsSendingObserverTopic, null);
// Keep current SMS message info for sent/delivered notifications
Please sign in to comment.
Something went wrong with that request. Please try again.