Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…messages (part 2, broadcast system messages). r=vicamo
  • Loading branch information...
commit a107157806843a01f3bad43c42d8ef2d1642520a 1 parent 2805913
@airpingu airpingu authored
Showing with 73 additions and 23 deletions.
  1. +42 −0 dom/mms/src/ril/MmsService.js
  2. +31 −23 dom/system/gonk/RadioInterfaceLayer.js
View
42 dom/mms/src/ril/MmsService.js
@@ -80,6 +80,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "gMobileMessageService",
"@mozilla.org/mobilemessage/mobilemessageservice;1",
"nsIMobileMessageService");
+XPCOMUtils.defineLazyServiceGetter(this, "gSystemMessenger",
+ "@mozilla.org/system-message-internal;1",
+ "nsISystemMessagesInternal");
+
XPCOMUtils.defineLazyGetter(this, "MMS", function () {
let MMS = {};
Cu.import("resource://gre/modules/MmsPduHelper.jsm", MMS);
@@ -1002,6 +1006,36 @@ MmsService.prototype = {
},
/**
+ * A helper to broadcast the system message to launch registered apps
+ * like Costcontrol, Notification and Message app... etc.
+ *
+ * @param aName
+ * The system message name.
+ * @param aDomMessage
+ * The nsIDOMMozMmsMessage object.
+ */
+ broadcastMmsSystemMessage: function broadcastMmsSystemMessage(aName, aDomMessage) {
+ debug("Broadcasting the MMS system message: " + aName);
+
+ // Sadly we cannot directly broadcast the aDomMessage object
+ // because the system message mechamism will rewrap the object
+ // based on the content window, which needs to know the properties.
+ gSystemMessenger.broadcastMessage(aName, {
+ type: aDomMessage.type,
+ id: aDomMessage.id,
+ delivery: aDomMessage.delivery,
+ deliveryStatus: aDomMessage.deliveryStatus,
+ sender: aDomMessage.sender,
+ receivers: aDomMessage.receivers,
+ timestamp: aDomMessage.timestamp.getTime(),
+ read: aDomMessage.read,
+ subject: aDomMessage.subject,
+ smil: aDomMessage.smil,
+ attachments: aDomMessage.attachments
+ });
+ },
+
+ /**
* Handle incoming M-Notification.ind PDU.
*
* @param notification
@@ -1033,6 +1067,9 @@ MmsService.prototype = {
return;
}
+ // Broadcasting an 'sms-received' system message to open apps.
+ this.broadcastMmsSystemMessage("sms-received", domMessage);
+
// Notifying observers a new notification indication is coming.
Services.obs.notifyObservers(domMessage, kMmsReceivedObserverTopic, null);
@@ -1104,6 +1141,9 @@ MmsService.prototype = {
return;
}
+ // Broadcasting an 'sms-received' system message to open apps.
+ this.broadcastMmsSystemMessage("sms-received", domMessage);
+
// Notifying observers an MMS message is received.
Services.obs.notifyObservers(domMessage, kMmsReceivedObserverTopic, null);
}).bind(this)
@@ -1250,6 +1290,8 @@ MmsService.prototype = {
Services.obs.notifyObservers(aDomMessage, kMmsFailedObserverTopic, null);
return;
}
+
+ self.broadcastMmsSystemMessage("sms-sent", aDomMessage);
aRequest.notifyMessageSent(aDomMessage);
Services.obs.notifyObservers(aDomMessage, kMmsSentObserverTopic, null);
});
View
54 dom/system/gonk/RadioInterfaceLayer.js
@@ -1487,6 +1487,35 @@ RadioInterfaceLayer.prototype = {
0, options);
},
+ /**
+ * A helper to broadcast the system message to launch registered apps
+ * like Costcontrol, Notification and Message app... etc.
+ *
+ * @param aName
+ * The system message name.
+ * @param aDomMessage
+ * The nsIDOMMozSmsMessage object.
+ */
+ broadcastSmsSystemMessage: function broadcastSmsSystemMessage(aName, aDomMessage) {
+ debug("Broadcasting the SMS system message: " + aName);
+
+ // Sadly we cannot directly broadcast the aDomMessage object
+ // because the system message mechamism will rewrap the object
+ // based on the content window, which needs to know the properties.
+ gSystemMessenger.broadcastMessage(aName, {
+ type: aDomMessage.type,
+ id: aDomMessage.id,
+ delivery: aDomMessage.delivery,
+ deliveryStatus: aDomMessage.deliveryStatus,
+ sender: aDomMessage.sender,
+ receiver: aDomMessage.receiver,
+ body: aDomMessage.body,
+ messageClass: aDomMessage.messageClass,
+ timestamp: aDomMessage.timestamp.getTime(),
+ read: aDomMessage.read
+ });
+ },
+
portAddressedSmsApps: null,
handleSmsReceived: function handleSmsReceived(message) {
debug("handleSmsReceived: " + JSON.stringify(message));
@@ -1547,18 +1576,7 @@ RadioInterfaceLayer.prototype = {
return;
}
- gSystemMessenger.broadcastMessage("sms-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
- });
-
+ this.broadcastSmsSystemMessage("sms-received", domMessage);
Services.obs.notifyObservers(domMessage, kSmsReceivedObserverTopic, null);
}.bind(this);
@@ -1618,17 +1636,7 @@ RadioInterfaceLayer.prototype = {
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
- });
+ this.broadcastSmsSystemMessage("sms-sent", domMessage);
if (!options.requestStatusReport) {
// No more used if STATUS-REPORT not requested.
Please sign in to comment.
Something went wrong with that request. Please try again.