Bug 736708 - 1/3: WebSMS - support Replace-Short-Message-Type. Don't return next message id. r=gene

This commit is contained in:
Vicamo Yang 2013-11-20 03:46:12 +08:00
parent 8d3da12c95
commit 8c86750769
3 changed files with 27 additions and 27 deletions

View File

@ -25,7 +25,7 @@ interface nsIRilMobileMessageDatabaseRecordCallback : nsISupports
void notify(in nsresult aRv, in jsval aMessageRecord, in nsISupports aDomMessage);
};
[scriptable, uuid(f6cd671e-f9af-11e2-b64b-1fb87e9c217c)]
[scriptable, uuid(d5374151-7451-4590-a70e-40c49c1369ce)]
interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
{
/**
@ -49,7 +49,7 @@ interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
* 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,
void saveReceivedMessage(in jsval aMessage,
[optional] in nsIRilMobileMessageDatabaseCallback aCallback);
/**
@ -66,7 +66,7 @@ interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
* - If |type| == "mms", we also need:
* - |receivers| DOMString Array: the phone numbers of receivers
*/
long saveSendingMessage(in jsval aMessage,
void saveSendingMessage(in jsval aMessage,
[optional] in nsIRilMobileMessageDatabaseCallback aCallback);
/**

View File

@ -1455,30 +1455,26 @@ MobileMessageDatabaseService.prototype = {
},
saveRecord: function saveRecord(aMessageRecord, aAddresses, aCallback) {
let isOverriding = (aMessageRecord.id !== undefined);
if (!isOverriding) {
// Assign a new id.
this.lastMessageId += 1;
aMessageRecord.id = this.lastMessageId;
}
if (DEBUG) debug("Going to store " + JSON.stringify(aMessageRecord));
let self = this;
function notifyResult(rv) {
if (!aCallback) {
return;
}
let domMessage = self.createDomMessageFromRecord(aMessageRecord);
aCallback.notify(rv, domMessage);
}
this.newTxn(READ_WRITE, function(error, txn, stores) {
let notifyResult = function(rv) {
if (aCallback) {
aCallback.notify(rv, self.createDomMessageFromRecord(aMessageRecord));
}
};
if (error) {
// TODO bug 832140 check event.target.errorCode
notifyResult(Cr.NS_ERROR_FAILURE);
return;
}
txn.oncomplete = function oncomplete(event) {
if (aMessageRecord.id > self.lastMessageId) {
self.lastMessageId = aMessageRecord.id;
}
notifyResult(Cr.NS_OK);
};
txn.onabort = function onabort(event) {
@ -1495,10 +1491,16 @@ MobileMessageDatabaseService.prototype = {
function (threadRecord,
participantIds) {
if (!participantIds) {
notifyResult(Cr.NS_ERROR_FAILURE);
txn.abort();
return;
}
let isOverriding = (aMessageRecord.id !== undefined);
if (!isOverriding) {
// |self.lastMessageId| is only updated in |txn.oncomplete|.
aMessageRecord.id = self.lastMessageId + 1;
}
let insertMessageRecord = function (threadId) {
// Setup threadId & threadIdIndex.
aMessageRecord.threadId = threadId;
@ -1580,8 +1582,6 @@ MobileMessageDatabaseService.prototype = {
};
});
}, [MESSAGE_STORE_NAME, PARTICIPANT_STORE_NAME, THREAD_STORE_NAME]);
// We return the key that we expect to store in the db
return aMessageRecord.id;
},
forEachMatchedMmsDeliveryInfo:
@ -1889,7 +1889,7 @@ MobileMessageDatabaseService.prototype = {
}
aMessage.deliveryIndex = [aMessage.delivery, timestamp];
return this.saveRecord(aMessage, threadParticipants, aCallback);
this.saveRecord(aMessage, threadParticipants, aCallback);
},
saveSendingMessage: function saveSendingMessage(aMessage, aCallback) {
@ -1951,7 +1951,7 @@ MobileMessageDatabaseService.prototype = {
} else if (aMessage.type == "mms") {
addresses = aMessage.receivers;
}
return this.saveRecord(aMessage, addresses, aCallback);
this.saveRecord(aMessage, addresses, aCallback);
},
setMessageDeliveryByMessageId: function setMessageDeliveryByMessageId(

View File

@ -1935,7 +1935,7 @@ RadioInterface.prototype = {
// At this point we could send a message to content to notify the user
// that storing an incoming SMS failed, most likely due to a full disk.
if (DEBUG) {
this.debug("Could not store SMS " + message.id + ", error code " + rv);
this.debug("Could not store SMS, error code " + rv);
}
return;
}
@ -1945,8 +1945,8 @@ RadioInterface.prototype = {
}.bind(this);
if (message.messageClass != RIL.GECKO_SMS_MESSAGE_CLASSES[RIL.PDU_DCS_MSG_CLASS_0]) {
message.id = gMobileMessageDatabaseService.saveReceivedMessage(message,
notifyReceived);
gMobileMessageDatabaseService.saveReceivedMessage(message,
notifyReceived);
} else {
message.id = -1;
message.threadId = 0;
@ -3146,8 +3146,8 @@ RadioInterface.prototype = {
return;
}
let id = gMobileMessageDatabaseService.saveSendingMessage(
sendingMessage, notifyResult);
gMobileMessageDatabaseService.saveSendingMessage(sendingMessage,
notifyResult);
},
registerDataCallCallback: function registerDataCallCallback(callback) {