Backout 8baf93244cfa for Marionette bustage, bug 813978

This commit is contained in:
Jonathan Griffin 2012-12-10 17:06:58 -08:00
parent 6e6bee80b5
commit a3ef44ebe7

View File

@ -15,7 +15,7 @@ const RIL_SMSDATABASESERVICE_CID = Components.ID("{a1fa610c-eb6c-4ac2-878f-b005d
const DEBUG = false; const DEBUG = false;
const DB_NAME = "sms"; const DB_NAME = "sms";
const DB_VERSION = 7; const DB_VERSION = 6;
const STORE_NAME = "sms"; const STORE_NAME = "sms";
const MOST_RECENT_STORE_NAME = "most-recent"; const MOST_RECENT_STORE_NAME = "most-recent";
@ -97,13 +97,6 @@ function SmsDatabaseService() {
}); });
this.messageLists = {}; this.messageLists = {};
// cursorReqs are where we keep "live" cursor based queries.
// Each item is an object with the following properties:
// ids[] : the message IDs already retrieved.
// done : a boolean indicating wether we retrieved all the ids.
// cursor : the indexedDB cursor itself.
this.cursorReqs = {};
} }
SmsDatabaseService.prototype = { SmsDatabaseService.prototype = {
@ -121,10 +114,8 @@ SmsDatabaseService.prototype = {
* message list is stored as an array of primary keys. * message list is stored as an array of primary keys.
*/ */
messageLists: null, messageLists: null,
cursorReqs: null,
lastMessageListId: 0, lastMessageListId: 0,
lastCursorReqId: 0,
/** /**
* Last key value stored in the database. * Last key value stored in the database.
@ -187,27 +178,22 @@ SmsDatabaseService.prototype = {
self.upgradeSchema(objectStore); self.upgradeSchema(objectStore);
break; break;
case 2: case 2:
if (DEBUG) debug("Upgrade to version 3. Fix existing entries."); if (DEBUG) debug("Upgrade to version 3. Fix existing entries.")
objectStore = event.target.transaction.objectStore(STORE_NAME); objectStore = event.target.transaction.objectStore(STORE_NAME);
self.upgradeSchema2(objectStore); self.upgradeSchema2(objectStore);
break; break;
case 3: case 3:
if (DEBUG) debug("Upgrade to version 4. Add quick threads view."); if (DEBUG) debug("Upgrade to version 4. Add quick threads view.")
self.upgradeSchema3(db, event.target.transaction); self.upgradeSchema3(db, event.target.transaction);
break; break;
case 4: case 4:
if (DEBUG) debug("Upgrade to version 5. Populate quick threads view."); if (DEBUG) debug("Upgrade to version 5. Populate quick threads view.")
self.upgradeSchema4(event.target.transaction); self.upgradeSchema4(event.target.transaction);
break; break;
case 5: case 5:
if (DEBUG) debug("Upgrade to version 6. Use PhonenumberJS.") if (DEBUG) debug("Upgrade to version 6. Use PhonenumberJS.")
self.upgradeSchema5(event.target.transaction); self.upgradeSchema5(event.target.transaction);
break; break;
case 6:
if (DEBUG) debug("Upgrade to version 7. Add a `senderOrReceiver` field.");
objectStore = event.target.transaction.objectStore(STORE_NAME);
self.upgradeSchema6(objectStore);
break;
default: default:
event.target.transaction.abort(); event.target.transaction.abort();
callback("Old database version: " + event.oldVersion, null); callback("Old database version: " + event.oldVersion, null);
@ -380,27 +366,6 @@ SmsDatabaseService.prototype = {
// Don't perform any upgrade. See Bug 819560. // Don't perform any upgrade. See Bug 819560.
}, },
upgradeSchema6: function upgradeSchema6(objectStore) {
objectStore.createIndex("senderOrReceiver", "senderOrReceiver",
{ unique: false });
objectStore.openCursor().onsuccess = function(event) {
let cursor = event.target.result;
if (!cursor) {
if (DEBUG) debug("updgradeSchema6 done");
return;
}
let message = cursor.value;
message.senderOrReceiver =
message.delivery == DELIVERY_SENT ? message.receiver
: message.sender;
cursor.update(message);
cursor.continue();
}
},
/** /**
* Helper function to make the intersection of the partial result arrays * Helper function to make the intersection of the partial result arrays
* obtained within createMessageList. * obtained within createMessageList.
@ -414,12 +379,10 @@ SmsDatabaseService.prototype = {
* return Array of keys containing the final result of createMessageList. * return Array of keys containing the final result of createMessageList.
*/ */
keyIntersection: function keyIntersection(keys, filter) { keyIntersection: function keyIntersection(keys, filter) {
// Use the FILTER_TIMESTAMP as a base filter if available, or the // Always use keys[FILTER_TIMESTAMP] as base result set to be filtered.
// FILTER_NUMBERS filter otherwise. // This ensures the result set is always sorted by timestamp.
let result = keys[FILTER_TIMESTAMP]; let result = keys[FILTER_TIMESTAMP];
if (!result) { if (keys[FILTER_NUMBERS].length || filter.numbers) {
result = keys[FILTER_NUMBERS];
} else if (keys[FILTER_NUMBERS].length || filter.numbers) {
result = result.filter(function(i) { result = result.filter(function(i) {
return keys[FILTER_NUMBERS].indexOf(i) != -1; return keys[FILTER_NUMBERS].indexOf(i) != -1;
}); });
@ -491,8 +454,6 @@ SmsDatabaseService.prototype = {
saveMessage: function saveMessage(message) { saveMessage: function saveMessage(message) {
this.lastKey += 1; this.lastKey += 1;
message.id = this.lastKey; message.id = this.lastKey;
message.senderOrReceiver = message.sender || message.receiver;
if (DEBUG) debug("Going to store " + JSON.stringify(message)); if (DEBUG) debug("Going to store " + JSON.stringify(message));
this.newTxn(READ_WRITE, function(error, txn, stores) { this.newTxn(READ_WRITE, function(error, txn, stores) {
if (error) { if (error) {
@ -542,6 +503,21 @@ SmsDatabaseService.prototype = {
*/ */
saveReceivedMessage: function saveReceivedMessage(aSender, aBody, aMessageClass, aDate) { saveReceivedMessage: function saveReceivedMessage(aSender, aBody, aMessageClass, aDate) {
let receiver = this.mRIL.rilContext.icc ? this.mRIL.rilContext.icc.msisdn : null;
// Workaround an xpconnect issue with undefined string objects.
// See bug 808220
if (receiver === undefined || receiver === "undefined") {
receiver = null;
}
if (receiver) {
let parsedNumber = PhoneNumberUtils.parse(receiver);
receiver = (parsedNumber && parsedNumber.internationalNumber)
? parsedNumber.internationalNumber
: receiver;
}
let sender = aSender; let sender = aSender;
if (sender) { if (sender) {
let parsedNumber = PhoneNumberUtils.parse(sender); let parsedNumber = PhoneNumberUtils.parse(sender);
@ -553,7 +529,7 @@ SmsDatabaseService.prototype = {
let message = {delivery: DELIVERY_RECEIVED, let message = {delivery: DELIVERY_RECEIVED,
deliveryStatus: DELIVERY_STATUS_SUCCESS, deliveryStatus: DELIVERY_STATUS_SUCCESS,
sender: sender, sender: sender,
receiver: null, receiver: receiver,
body: aBody, body: aBody,
messageClass: aMessageClass, messageClass: aMessageClass,
timestamp: aDate, timestamp: aDate,
@ -562,6 +538,14 @@ SmsDatabaseService.prototype = {
}, },
saveSentMessage: function saveSentMessage(aReceiver, aBody, aDate) { saveSentMessage: function saveSentMessage(aReceiver, aBody, aDate) {
let sender = this.mRIL.rilContext.icc ? this.mRIL.rilContext.icc.msisdn : null;
// Workaround an xpconnect issue with undefined string objects.
// See bug 808220
if (sender === undefined || sender === "undefined") {
sender = null;
}
let receiver = aReceiver let receiver = aReceiver
if (receiver) { if (receiver) {
let parsedNumber = PhoneNumberUtils.parse(receiver.toString()); let parsedNumber = PhoneNumberUtils.parse(receiver.toString());
@ -570,9 +554,16 @@ SmsDatabaseService.prototype = {
: receiver; : receiver;
} }
if (sender) {
let parsedNumber = PhoneNumberUtils.parse(sender.toString());
sender = (parsedNumber && parsedNumber.internationalNumber)
? parsedNumber.internationalNumber
: sender;
}
let message = {delivery: DELIVERY_SENT, let message = {delivery: DELIVERY_SENT,
deliveryStatus: DELIVERY_STATUS_PENDING, deliveryStatus: DELIVERY_STATUS_PENDING,
sender: null, sender: sender,
receiver: receiver, receiver: receiver,
body: aBody, body: aBody,
messageClass: MESSAGE_CLASS_NORMAL, messageClass: MESSAGE_CLASS_NORMAL,
@ -629,14 +620,12 @@ SmsDatabaseService.prototype = {
}); });
}, },
// Internal helper to get a message. getMessage: function getMessage(messageId, aRequest) {
// Returns the sms object in aSuccess, if (DEBUG) debug("Retrieving message with ID " + messageId);
// or an nsISmsRequest error code in aError
_getMessageInternal: function getMessageInternal(messageId, aSuccess, aError) {
this.newTxn(READ_ONLY, function (error, txn, store) { this.newTxn(READ_ONLY, function (error, txn, store) {
if (error) { if (error) {
if (DEBUG) debug(error); if (DEBUG) debug(error);
aError(Ci.nsISmsRequest.INTERNAL_ERROR); aRequest.notifyGetMessageFailed(Ci.nsISmsRequest.INTERNAL_ERROR);
return; return;
} }
let request = store.mozGetAll(messageId); let request = store.mozGetAll(messageId);
@ -645,13 +634,13 @@ SmsDatabaseService.prototype = {
if (DEBUG) debug("Transaction " + txn + " completed."); if (DEBUG) debug("Transaction " + txn + " completed.");
if (request.result.length > 1) { if (request.result.length > 1) {
if (DEBUG) debug("Got too many results for id " + messageId); if (DEBUG) debug("Got too many results for id " + messageId);
aError(Ci.nsISmsRequest.UNKNOWN_ERROR); aRequest.notifyGetMessageFailed(Ci.nsISmsRequest.UNKNOWN_ERROR);
return; return;
} }
let data = request.result[0]; let data = request.result[0];
if (!data) { if (!data) {
if (DEBUG) debug("Message ID " + messageId + " not found"); if (DEBUG) debug("Message ID " + messageId + " not found");
aError(Ci.nsISmsRequest.NOT_FOUND_ERROR); aRequest.notifyGetMessageFailed(Ci.nsISmsRequest.NOT_FOUND_ERROR);
return; return;
} }
if (data.id != messageId) { if (data.id != messageId) {
@ -659,7 +648,7 @@ SmsDatabaseService.prototype = {
debug("Requested message ID (" + messageId + ") is " + debug("Requested message ID (" + messageId + ") is " +
"different from the one we got"); "different from the one we got");
} }
aError(Ci.nsISmsRequest.UNKNOWN_ERROR); aRequest.notifyGetMessageFailed(Ci.nsISmsRequest.UNKNOWN_ERROR);
return; return;
} }
let message = gSmsService.createSmsMessage(data.id, let message = gSmsService.createSmsMessage(data.id,
@ -671,7 +660,7 @@ SmsDatabaseService.prototype = {
data.messageClass, data.messageClass,
data.timestamp, data.timestamp,
data.read); data.read);
aSuccess(message); aRequest.notifyMessageGot(message);
}; };
txn.onerror = function onerror(event) { txn.onerror = function onerror(event) {
@ -680,21 +669,11 @@ SmsDatabaseService.prototype = {
debug("Caught error on transaction", event.target.errorCode); debug("Caught error on transaction", event.target.errorCode);
} }
//TODO look at event.target.errorCode, pick appropriate error constant //TODO look at event.target.errorCode, pick appropriate error constant
aError(Ci.nsISmsRequest.INTERNAL_ERROR); aRequest.notifyGetMessageFailed(Ci.nsISmsRequest.INTERNAL_ERROR);
} };
}); });
}, },
getMessage: function getMessage(messageId, aRequest) {
this._getMessageInternal(messageId,
function(aMessage) {
aRequest.notifyMessageGot(aMessage);
},
function(aError) {
aRequest.notifyGetMessageFailed(aError);
});
},
deleteMessage: function deleteMessage(messageId, aRequest) { deleteMessage: function deleteMessage(messageId, aRequest) {
let deleted = false; let deleted = false;
let self = this; let self = this;
@ -797,65 +776,6 @@ SmsDatabaseService.prototype = {
}, [STORE_NAME, MOST_RECENT_STORE_NAME]); }, [STORE_NAME, MOST_RECENT_STORE_NAME]);
}, },
startCursorRequest: function startCurReq(aIndex, aKey, aDirection, aRequest) {
if (DEBUG) debug("Starting cursor request on " + aIndex + " " + aDirection);
let self = this;
let id = self.lastCursorReqId += 1;
let firstMessage = true;
this.newTxn(READ_ONLY, function (error, txn, store) {
if (error) {
if (DEBUG) debug("Error creating transaction: " + error);
aRequest.notifyReadMessageListFailed(Ci.nsISmsRequest.INTERNAL_ERROR);
return;
}
let cursor = store.index(aIndex).openKeyCursor(aKey, aDirection);
self.cursorReqs[id] = { done: false,
cursor: cursor,
ids: [] }
cursor.onsuccess = function(aEvent) {
let result = aEvent.target.result;
let cursor = self.cursorReqs[id];
if (!result) {
cursor.done = true;
return;
}
let messageId = result.primaryKey;
if (firstMessage) {
self._getMessageInternal(messageId,
function(aMessage) {
aRequest.notifyMessageListCreated(id, aMessage);
},
function(aError) {
aRequest.notifyReadMessageListFailed(aError);
}
);
firstMessage = false;
} else {
cursor.ids.push(messageId);
}
result.continue();
}
cursor.onerror = function() {
aRequest.notifyReadMessageListFailed(Ci.nsISmsRequest.INTERNAL_ERROR);
}
txn.oncomplete = function oncomplete(event) {
// Nothing to do.
}
txn.onerror = function onerror(event) {
aRequest.notifyReadMessageListFailed(Ci.nsISmsRequest.INTERNAL_ERROR);
}
});
},
createMessageList: function createMessageList(filter, reverse, aRequest) { createMessageList: function createMessageList(filter, reverse, aRequest) {
if (DEBUG) { if (DEBUG) {
debug("Creating a message list. Filters:" + debug("Creating a message list. Filters:" +
@ -866,65 +786,12 @@ SmsDatabaseService.prototype = {
" read: " + filter.read + " read: " + filter.read +
" reverse: " + reverse); " reverse: " + reverse);
} }
// Fast paths for some common situations:
// 1. If only one constraint is set, filter based on this one, and
// avoid the full scan due to unrestricted date range.
// 2. If no filters are applied, use a cursor on all messages with
// the right direction.
// In any other case, fallback to the slow path.
let constraintCount = (filter.delivery ? 1 : 0) +
(filter.numbers ? filter.numbers.length : 0) +
(filter.read ? 1 : 0) +
(filter.startDate ? 1 : 0) +
(filter.endDate ? 1 : 0);
if (DEBUG) debug("Constraints found: " + constraintCount);
let direction = reverse ? PREV : NEXT;
if (constraintCount == 1) {
// 1.
let indexName;
let keyRange;
if (filter.delivery) {
indexName = "delivery";
keyRange = IDBKeyRange.only(filter.delivery);
} else if (filter.numbers) {
indexName = "senderOrReceiver";
keyRange = IDBKeyRange.only(filter.numbers[0]);
} else if (filter.read) {
indexName = "read";
let keyRange = IDBKeyRange.only(filter.read ? FILTER_READ_READ
: FILTER_READ_UNREAD);
} else {
indexName = "timestamp";
if (filter.startDate != null && filter.endDate != null) {
keyRange = IDBKeyRange.bound(filter.startDate.getTime(),
filter.endDate.getTime());
} else if (filter.startDate != null) {
keyRange = IDBKeyRange.lowerBound(filter.startDate.getTime());
} else if (filter.endDate != null) {
keyRange = IDBKeyRange.upperBound(filter.endDate.getTime());
}
}
if (indexName && keyRange) {
this.startCursorRequest(indexName, keyRange, direction, aRequest);
return;
}
} else if (constraintCount == 0) {
// 2.
this.startCursorRequest("timestamp", null, direction, aRequest);
return;
}
// This object keeps the lists of keys retrieved by the search specific to // This object keeps the lists of keys retrieved by the search specific to
// each nsIMozSmsFilter. Once all the keys have been retrieved from the // each nsIMozSmsFilter. Once all the keys have been retrieved from the
// store, the final intersection of this arrays will contain all the // store, the final intersection of this arrays will contain all the
// keys for the message list that we are creating. // keys for the message list that we are creating.
let filteredKeys = {}; let filteredKeys = {};
filteredKeys[FILTER_TIMESTAMP] = null; filteredKeys[FILTER_TIMESTAMP] = [];
filteredKeys[FILTER_NUMBERS] = []; filteredKeys[FILTER_NUMBERS] = [];
filteredKeys[FILTER_DELIVERY] = []; filteredKeys[FILTER_DELIVERY] = [];
filteredKeys[FILTER_READ] = []; filteredKeys[FILTER_READ] = [];
@ -961,55 +828,8 @@ SmsDatabaseService.prototype = {
return; return;
} }
let filtered = false; // In first place, we retrieve the keys that match the filter.startDate
// Retrieve the keys from the 'delivery' index that matches the
// value of filter.delivery.
if (filter.delivery) {
filtered = true;
let deliveryKeyRange = IDBKeyRange.only(filter.delivery);
let deliveryRequest = store.index("delivery")
.openKeyCursor(deliveryKeyRange);
deliveryRequest.onsuccess = function onsuccess(event) {
successCb(event.target.result, FILTER_DELIVERY);
};
deliveryRequest.onerror = errorCb;
}
// Retrieve the keys from the 'senderOrReceiver' indexes that
// match the values of filter.numbers
if (filter.numbers) {
for (let i = 0; i < filter.numbers.length; i++) {
filtered = true;
let numberKeyRange = IDBKeyRange.only(filter.numbers[i]);
let numberRequest = store.index("senderOrReceiver")
.openKeyCursor(numberKeyRange, direction);
numberRequest.onsuccess =
function onsuccess(event){
successCb(event.target.result, FILTER_NUMBERS);
};
numberRequest.onerror = errorCb;
}
}
// Retrieve the keys from the 'read' index that matches the value of
// filter.read
if (filter.read != undefined) {
filtered = true;
let read = filter.read ? FILTER_READ_READ : FILTER_READ_UNREAD;
if (DEBUG) debug("filter.read " + read);
let readKeyRange = IDBKeyRange.only(read);
let readRequest = store.index("read")
.openKeyCursor(readKeyRange);
readRequest.onsuccess = function onsuccess(event) {
successCb(event.target.result, FILTER_READ);
};
readRequest.onerror = errorCb;
}
// In last place, we retrieve the keys that match the filter.startDate
// and filter.endDate search criteria. // and filter.endDate search criteria.
// If we already filtered and have no date filtering, bail out.
let timeKeyRange = null; let timeKeyRange = null;
if (filter.startDate != null && filter.endDate != null) { if (filter.startDate != null && filter.endDate != null) {
timeKeyRange = IDBKeyRange.bound(filter.startDate.getTime(), timeKeyRange = IDBKeyRange.bound(filter.startDate.getTime(),
@ -1019,20 +839,56 @@ SmsDatabaseService.prototype = {
} else if (filter.endDate != null) { } else if (filter.endDate != null) {
timeKeyRange = IDBKeyRange.upperBound(filter.endDate.getTime()); timeKeyRange = IDBKeyRange.upperBound(filter.endDate.getTime());
} }
let direction = reverse ? PREV : NEXT;
let timeRequest = store.index("timestamp").openKeyCursor(timeKeyRange,
direction);
if (DEBUG) timeRequest.onsuccess = function onsuccess(event) {
debug("timeKeyRange: " + timeKeyRange + " filtered: " + filtered); successCb(event.target.result, FILTER_TIMESTAMP);
if (timeKeyRange || !filtered) { };
filteredKeys[FILTER_TIMESTAMP] = []; timeRequest.onerror = errorCb;
let timeRequest = store.index("timestamp").openKeyCursor(timeKeyRange,
direction);
timeRequest.onsuccess = function onsuccess(event) { // Retrieve the keys from the 'delivery' index that matches the
successCb(event.target.result, FILTER_TIMESTAMP); // value of filter.delivery.
if (filter.delivery) {
let deliveryKeyRange = IDBKeyRange.only(filter.delivery);
let deliveryRequest = store.index("delivery")
.openKeyCursor(deliveryKeyRange);
deliveryRequest.onsuccess = function onsuccess(event) {
successCb(event.target.result, FILTER_DELIVERY);
}; };
timeRequest.onerror = errorCb; deliveryRequest.onerror = errorCb;
} else { }
if (DEBUG) debug("Ignoring useless date filtering");
// Retrieve the keys from the 'sender' and 'receiver' indexes that
// match the values of filter.numbers
if (filter.numbers) {
for (let i = 0; i < filter.numbers.length; i++) {
let numberKeyRange = IDBKeyRange.only(filter.numbers[i]);
let senderRequest = store.index("sender")
.openKeyCursor(numberKeyRange);
let receiverRequest = store.index("receiver")
.openKeyCursor(numberKeyRange);
senderRequest.onsuccess = receiverRequest.onsuccess =
function onsuccess(event){
successCb(event.target.result, FILTER_NUMBERS);
};
senderRequest.onerror = receiverRequest.onerror = errorCb;
}
}
// Retrieve the keys from the 'read' index that matches the value of
// filter.read
if (filter.read != undefined) {
let read = filter.read ? FILTER_READ_READ : FILTER_READ_UNREAD;
if (DEBUG) debug("filter.read " + read);
let readKeyRange = IDBKeyRange.only(read);
let readRequest = store.index("read")
.openKeyCursor(readKeyRange);
readRequest.onsuccess = function onsuccess(event) {
successCb(event.target.result, FILTER_READ);
};
readRequest.onerror = errorCb;
} }
txn.oncomplete = function oncomplete(event) { txn.oncomplete = function oncomplete(event) {
@ -1060,55 +916,10 @@ SmsDatabaseService.prototype = {
}, },
getNextMessageInList: function getNextMessageInList(listId, aRequest) { getNextMessageInList: function getNextMessageInList(listId, aRequest) {
let getMessage = (function getMessage(messageId) {
this._getMessageInternal(messageId,
function(aMessage) {
aRequest.notifyNextMessageInListGot(aMessage);
},
function(aError) {
aRequest.notifyReadMessageListFailed(aError);
}
);
}).bind(this);
if (DEBUG) debug("Getting next message in list " + listId); if (DEBUG) debug("Getting next message in list " + listId);
let messageId; let messageId;
let list = this.messageLists[listId]; let list = this.messageLists[listId];
if (!list) { if (!list) {
if (this.cursorReqs[listId]) {
let cursor = this.cursorReqs[listId];
if (cursor.done && cursor.ids.length == 0) {
aRequest.notifyNoMessageInList();
return;
}
messageId = cursor.ids.shift();
// There is a message in the queue, retrieve it and provide it to
// the caller.
if (messageId) {
getMessage(messageId);
return;
}
// We're not done, but have no message yet. Wait for the cursor
// to provide something.
cursor.cursor.addEventListener("success",
function waitForResult(aEvent) {
cursor.cursor.removeEventListener("success", waitForResult);
// No more messages.
if (cursor.done) {
aRequest.notifyNoMessageInList();
return;
}
// We have a new message, grab it from the queue.
messageId = cursor.ids.shift();
getMessage(messageId);
});
return;
}
if (DEBUG) debug("Wrong list id"); if (DEBUG) debug("Wrong list id");
aRequest.notifyReadMessageListFailed(Ci.nsISmsRequest.NOT_FOUND_ERROR); aRequest.notifyReadMessageListFailed(Ci.nsISmsRequest.NOT_FOUND_ERROR);
return; return;
@ -1119,17 +930,46 @@ SmsDatabaseService.prototype = {
aRequest.notifyNoMessageInList(); aRequest.notifyNoMessageInList();
return; return;
} }
this.newTxn(READ_ONLY, function (error, txn, store) {
if (DEBUG) debug("Fetching message " + messageId);
let request = store.get(messageId);
let message;
request.onsuccess = function onsuccess(event) {
message = request.result;
};
getMessage(messageId); txn.oncomplete = function oncomplete(event) {
if (DEBUG) debug("Transaction " + txn + " completed.");
if (!message) {
if (DEBUG) debug("Could not get message id " + messageId);
aRequest.notifyReadMessageListFailed(Ci.nsISmsRequest.NOT_FOUND_ERROR);
}
let sms = gSmsService.createSmsMessage(message.id,
message.delivery,
message.deliveryStatus,
message.sender,
message.receiver,
message.body,
message.messageClass,
message.timestamp,
message.read);
aRequest.notifyNextMessageInListGot(sms);
};
txn.onerror = function onerror(event) {
//TODO check event.target.errorCode
if (DEBUG) {
debug("Error retrieving message id: " + messageId +
". Error code: " + event.target.errorCode);
}
aRequest.notifyReadMessageListFailed(Ci.nsISmsRequest.INTERNAL_ERROR);
};
});
}, },
clearMessageList: function clearMessageList(listId) { clearMessageList: function clearMessageList(listId) {
if (DEBUG) debug("Clearing message list: " + listId); if (DEBUG) debug("Clearing message list: " + listId);
if (this.messageLists[listId]) { delete this.messageLists[listId];
delete this.messageLists[listId];
} else if (this.cursorReqs[listId]) {
delete this.cursorReqs[listId];
}
}, },
markMessageRead: function markMessageRead(messageId, value, aRequest) { markMessageRead: function markMessageRead(messageId, value, aRequest) {
@ -1195,7 +1035,6 @@ SmsDatabaseService.prototype = {
}; };
}, [STORE_NAME, MOST_RECENT_STORE_NAME]); }, [STORE_NAME, MOST_RECENT_STORE_NAME]);
}, },
getThreadList: function getThreadList(aRequest) { getThreadList: function getThreadList(aRequest) {
if (DEBUG) debug("Getting thread list"); if (DEBUG) debug("Getting thread list");
this.newTxn(READ_ONLY, function (error, txn, store) { this.newTxn(READ_ONLY, function (error, txn, store) {