Bug 921918 - 3.b/4: assign received |aMmsMessage.sender| in mmdb. r=gene

This commit is contained in:
Vicamo Yang 2013-11-25 18:55:01 +08:00
parent 6507b0ffcb
commit b6544cf302
3 changed files with 14 additions and 15 deletions

View File

@ -31,7 +31,6 @@ interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
/** /**
* |aMessage| Object: should contain the following properties for internal use: * |aMessage| Object: should contain the following properties for internal use:
* - |type| DOMString: "sms" or "mms" * - |type| DOMString: "sms" or "mms"
* - |sender| DOMString: the phone number of sender
* - |timestamp| Number: the timestamp of received message * - |timestamp| Number: the timestamp of received message
* - |iccId| DOMString: [optional] the ICC ID of the SIM for receiving * - |iccId| DOMString: [optional] the ICC ID of the SIM for receiving
* message if available. * message if available.
@ -40,6 +39,7 @@ interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
* - |messageClass| DOMString: the message class of received message * - |messageClass| DOMString: the message class of received message
* - |receiver| DOMString: the phone number of receiver * - |receiver| DOMString: the phone number of receiver
* - |pid| Number: the TP-PID field of the SMS TPDU, default 0. * - |pid| Number: the TP-PID field of the SMS TPDU, default 0.
* - |sender| DOMString: the phone number of sender
* *
* - If |type| == "mms", we also need: * - If |type| == "mms", we also need:
* - |delivery| DOMString: the delivery state of received message * - |delivery| DOMString: the delivery state of received message

View File

@ -1456,13 +1456,7 @@ MmsService.prototype = {
} }
intermediate.timestamp = Date.now(); intermediate.timestamp = Date.now();
intermediate.sender = null;
intermediate.transactionId = intermediate.headers["x-mms-transaction-id"]; intermediate.transactionId = intermediate.headers["x-mms-transaction-id"];
if (intermediate.headers.from) {
intermediate.sender = intermediate.headers.from.address;
} else {
intermediate.sender = "anonymous";
}
intermediate.receivers = []; intermediate.receivers = [];
intermediate.phoneNumber = mmsConnection.getPhoneNumber(); intermediate.phoneNumber = mmsConnection.getPhoneNumber();
intermediate.iccId = mmsConnection.getIccId(); intermediate.iccId = mmsConnection.getIccId();
@ -1485,11 +1479,6 @@ MmsService.prototype = {
intermediate, intermediate,
savable) { savable) {
savable.timestamp = Date.now(); savable.timestamp = Date.now();
if (intermediate.headers.from) {
savable.sender = intermediate.headers.from.address;
} else {
savable.sender = "anonymous";
}
savable.receivers = []; savable.receivers = [];
// We don't have Bcc in recevied MMS message. // We don't have Bcc in recevied MMS message.
for each (let type in ["cc", "to"]) { for each (let type in ["cc", "to"]) {

View File

@ -1940,21 +1940,31 @@ MobileMessageDatabaseService.prototype = {
saveReceivedMessage: function saveReceivedMessage(aMessage, aCallback) { saveReceivedMessage: function saveReceivedMessage(aMessage, aCallback) {
if ((aMessage.type != "sms" && aMessage.type != "mms") || if ((aMessage.type != "sms" && aMessage.type != "mms") ||
(aMessage.type == "sms" && aMessage.messageClass == undefined) || (aMessage.type == "sms" && (aMessage.messageClass == undefined ||
aMessage.sender == undefined)) ||
(aMessage.type == "mms" && (aMessage.delivery == undefined || (aMessage.type == "mms" && (aMessage.delivery == undefined ||
aMessage.transactionId == undefined || aMessage.transactionId == undefined ||
!Array.isArray(aMessage.deliveryInfo) || !Array.isArray(aMessage.deliveryInfo) ||
!Array.isArray(aMessage.receivers))) || !Array.isArray(aMessage.receivers))) ||
aMessage.sender == undefined ||
aMessage.timestamp == undefined) { aMessage.timestamp == undefined) {
if (aCallback) { if (aCallback) {
aCallback.notify(Cr.NS_ERROR_FAILURE, null); aCallback.notify(Cr.NS_ERROR_FAILURE, null);
} }
return; return;
} }
let threadParticipants = [aMessage.sender];
let threadParticipants;
if (aMessage.type == "mms") { if (aMessage.type == "mms") {
if (aMessage.headers.from) {
aMessage.sender = aMessage.headers.from.address;
} else {
aMessage.sender = "anonymous";
}
threadParticipants = [aMessage.sender];
this.fillReceivedMmsThreadParticipants(aMessage, threadParticipants); this.fillReceivedMmsThreadParticipants(aMessage, threadParticipants);
} else { // SMS
threadParticipants = [aMessage.sender];
} }
let timestamp = aMessage.timestamp; let timestamp = aMessage.timestamp;