Bug 1181466 - Fix observe function in SmsService/MmsService. r=btseng

Ensure deletedInfo object is converted by subject.QueryInterface()
when "sms-deleted" topic observed.

--HG--
extra : rebase_source : 95351459bb2739d7e5786155934741a7641c0b2f
This commit is contained in:
Samael Wang 2015-07-09 11:59:45 +08:00
Родитель 842e3cc577
Коммит e528cceb83
2 изменённых файлов: 12 добавлений и 11 удалений

Просмотреть файл

@ -1072,8 +1072,9 @@ CancellableTransaction.prototype = {
break;
}
case kSmsDeletedObserverTopic: {
if (subject && subject.deletedMessageIds &&
subject.deletedMessageIds.indexOf(this.cancellableId) >= 0) {
let deletedInfo = subject.QueryInterface(Ci.nsIDeletedMessageInfo);
if (deletedInfo && deletedInfo.deletedMessageIds &&
deletedInfo.deletedMessageIds.indexOf(this.cancellableId) >= 0) {
this.cancelRunning(_MMS_ERROR_MESSAGE_DELETED);
}
break;

Просмотреть файл

@ -1307,19 +1307,19 @@ SmsSendingScheduler.prototype = {
observe: function(aSubject, aTopic, aData) {
switch (aTopic) {
case kSmsDeletedObserverTopic:
let deletedInfo = aSubject.QueryInterface(Ci.nsIDeletedMessageInfo);
if (DEBUG) {
debug("Observe " + kSmsDeletedObserverTopic + ": " +
JSON.stringify(aSubject));
JSON.stringify(deletedInfo));
}
if (aSubject && aSubject.deletedMessageIds) {
for (let id of aSubject.deletedMessageIds) {
for (let i = 0; i < this._queue.length; i++) {
if (this._queue[i].messageId === id) {
if (DEBUG) debug("Deleting message with id=" + id);
this._queue.splice(i, 1)[0].onCancel(
Ci.nsIMobileMessageCallback.NOT_FOUND_ERROR);
}
if (deletedInfo && deletedInfo.deletedMessageIds) {
for (let i = 0; i < this._queue.length; i++) {
let id = this._queue[i].messageId;
if (deletedInfo.deletedMessageIds.includes(id)) {
if (DEBUG) debug("Deleting message with id=" + id);
this._queue.splice(i, 1)[0].onCancel(
Ci.nsIMobileMessageCallback.NOT_FOUND_ERROR);
}
}
}