Bug 397888 - get rid of anonymous functions in calStorageCalendar.js [r=philipp]

This commit is contained in:
Stefan Sitter 2009-07-01 19:32:57 +02:00
Родитель b363ba3aea
Коммит 8af179f28b
1 изменённых файлов: 49 добавлений и 48 удалений

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

@ -298,11 +298,11 @@ calStorageCalendar.prototype = {
return calGetString("calendar", "storageName"); return calGetString("calendar", "storageName");
}, },
createCalendar: function stor_createCal() { createCalendar: function cSC_createCalendar() {
throw NS_ERROR_NOT_IMPLEMENTED; throw NS_ERROR_NOT_IMPLEMENTED;
}, },
deleteCalendar: function stor_deleteCal(cal, listener) { deleteCalendar: function cSC_deleteCalendar(cal, listener) {
cal = cal.wrappedJSObject; cal = cal.wrappedJSObject;
for (var i in this.mDeleteEventExtras) { for (var i in this.mDeleteEventExtras) {
@ -341,7 +341,7 @@ calStorageCalendar.prototype = {
// calICalendar interface // calICalendar interface
// //
getProperty: function stor_getProperty(aName) { getProperty: function cSC_getProperty(aName) {
switch (aName) { switch (aName) {
case "cache.supported": case "cache.supported":
return false; return false;
@ -437,18 +437,18 @@ calStorageCalendar.prototype = {
this.initDB(); this.initDB();
}, },
refresh: function() { refresh: function cSC_refresh() {
// no-op // no-op
}, },
// void addItem( in calIItemBase aItem, in calIOperationListener aListener ); // void addItem( in calIItemBase aItem, in calIOperationListener aListener );
addItem: function (aItem, aListener) { addItem: function cSC_addItem(aItem, aListener) {
var newItem = aItem.clone(); var newItem = aItem.clone();
return this.adoptItem(newItem, aListener); return this.adoptItem(newItem, aListener);
}, },
// void adoptItem( in calIItemBase aItem, in calIOperationListener aListener ); // void adoptItem( in calIItemBase aItem, in calIOperationListener aListener );
adoptItem: function (aItem, aListener) { adoptItem: function cSC_adoptItem(aItem, aListener) {
if (this.readOnly) { if (this.readOnly) {
this.notifyOperationComplete(aListener, this.notifyOperationComplete(aListener,
Components.interfaces.calIErrors.CAL_IS_READONLY, Components.interfaces.calIErrors.CAL_IS_READONLY,
@ -500,7 +500,7 @@ calStorageCalendar.prototype = {
}, },
// void modifyItem( in calIItemBase aNewItem, in calIItemBase aOldItem, in calIOperationListener aListener ); // void modifyItem( in calIItemBase aNewItem, in calIItemBase aOldItem, in calIOperationListener aListener );
modifyItem: function (aNewItem, aOldItem, aListener) { modifyItem: function cSC_modifyItem(aNewItem, aOldItem, aListener) {
if (this.readOnly) { if (this.readOnly) {
this.notifyOperationComplete(aListener, this.notifyOperationComplete(aListener,
Components.interfaces.calIErrors.CAL_IS_READONLY, Components.interfaces.calIErrors.CAL_IS_READONLY,
@ -577,7 +577,7 @@ calStorageCalendar.prototype = {
}, },
// void deleteItem( in string id, in calIOperationListener aListener ); // void deleteItem( in string id, in calIOperationListener aListener );
deleteItem: function (aItem, aListener) { deleteItem: function cSC_deleteItem(aItem, aListener) {
if (this.readOnly) { if (this.readOnly) {
this.notifyOperationComplete(aListener, this.notifyOperationComplete(aListener,
Components.interfaces.calIErrors.CAL_IS_READONLY, Components.interfaces.calIErrors.CAL_IS_READONLY,
@ -615,7 +615,7 @@ calStorageCalendar.prototype = {
}, },
// void getItem( in string id, in calIOperationListener aListener ); // void getItem( in string id, in calIOperationListener aListener );
getItem: function (aId, aListener) { getItem: function cSC_getItem(aId, aListener) {
if (!aListener) if (!aListener)
return; return;
@ -659,15 +659,15 @@ calStorageCalendar.prototype = {
// void getItems( in unsigned long aItemFilter, in unsigned long aCount, // void getItems( in unsigned long aItemFilter, in unsigned long aCount,
// in calIDateTime aRangeStart, in calIDateTime aRangeEnd, // in calIDateTime aRangeStart, in calIDateTime aRangeEnd,
// in calIOperationListener aListener ); // in calIOperationListener aListener );
getItems: function (aItemFilter, aCount, getItems: function cSC_getItems(aItemFilter, aCount,
aRangeStart, aRangeEnd, aListener) { aRangeStart, aRangeEnd, aListener) {
let this_ = this; let this_ = this;
cal.postPone(function() { cal.postPone(function() {
this_.getItems_(aItemFilter, aCount, aRangeStart, aRangeEnd, aListener); this_.getItems_(aItemFilter, aCount, aRangeStart, aRangeEnd, aListener);
}); });
}, },
getItems_: function (aItemFilter, aCount, getItems_: function cSC_getItems_(aItemFilter, aCount,
aRangeStart, aRangeEnd, aListener) aRangeStart, aRangeEnd, aListener)
{ {
//var profStartTime = Date.now(); //var profStartTime = Date.now();
if (!aListener) if (!aListener)
@ -911,7 +911,7 @@ calStorageCalendar.prototype = {
// initialize the database schema. // initialize the database schema.
// needs to do some version checking // needs to do some version checking
initDBSchema: function () { initDBSchema: function cSC_initDBSchema() {
for (table in sqlTables) { for (table in sqlTables) {
try { try {
this.mDB.executeSimpleSQL("DROP TABLE " + table); this.mDB.executeSimpleSQL("DROP TABLE " + table);
@ -961,7 +961,7 @@ calStorageCalendar.prototype = {
throw "cal_calendar_schema_version SELECT returned no results"; throw "cal_calendar_schema_version SELECT returned no results";
}, },
upgradeDB: function (oldVersion) { upgradeDB: function cSC_upgradeDB(oldVersion) {
// some common helpers // some common helpers
function addColumn(db, tableName, colName, colType) { function addColumn(db, tableName, colName, colType) {
db.executeSimpleSQL("ALTER TABLE " + tableName + " ADD COLUMN " + colName + " " + colType); db.executeSimpleSQL("ALTER TABLE " + tableName + " ADD COLUMN " + colName + " " + colType);
@ -1427,7 +1427,7 @@ calStorageCalendar.prototype = {
} }
}, },
ensureUpdatedTimezones: function stor_ensureUpdatedTimezones() { ensureUpdatedTimezones: function cSC_ensureUpdatedTimezones() {
// check if timezone version has changed: // check if timezone version has changed:
var selectTzVersion = createStatement(this.mDB, "SELECT version FROM cal_tz_version LIMIT 1"); var selectTzVersion = createStatement(this.mDB, "SELECT version FROM cal_tz_version LIMIT 1");
var version; var version;
@ -1506,7 +1506,7 @@ calStorageCalendar.prototype = {
// database initialization // database initialization
// assumes mDB is valid // assumes mDB is valid
initDB: function () { initDB: function cSC_initDB() {
ASSERT(this.mDB, "Database has not been opened!", true); ASSERT(this.mDB, "Database has not been opened!", true);
if (!this.mDB.tableExists("cal_calendar_schema_version")) { if (!this.mDB.tableExists("cal_calendar_schema_version")) {
this.initDBSchema(); this.initDBSchema();
@ -1872,7 +1872,7 @@ calStorageCalendar.prototype = {
// read in the common ItemBase attributes from aDBRow, and stick // read in the common ItemBase attributes from aDBRow, and stick
// them on item // them on item
getItemBaseFromRow: function (row, flags, item) { getItemBaseFromRow: function cSC_getItemBaseFromRow(row, flags, item) {
item.calendar = this.superCalendar; item.calendar = this.superCalendar;
item.id = row.id; item.id = row.id;
if (row.title) if (row.title)
@ -1910,7 +1910,7 @@ calStorageCalendar.prototype = {
} }
}, },
cacheItem: function stor_cacheItem(item) { cacheItem: function cSC_cacheItem(item) {
this.mItemCache[item.id] = item; this.mItemCache[item.id] = item;
if (item.recurrenceInfo) { if (item.recurrenceInfo) {
if (isEvent(item)) { if (isEvent(item)) {
@ -1921,7 +1921,7 @@ calStorageCalendar.prototype = {
} }
}, },
assureRecurringItemCaches: function stor_assureRecurringItemCaches() { assureRecurringItemCaches: function cSC_assureRecurringItemCaches() {
if (this.mRecItemCacheInited) { if (this.mRecItemCacheInited) {
return; return;
} }
@ -1960,7 +1960,7 @@ calStorageCalendar.prototype = {
}, },
// xxx todo: consider removing flags parameter // xxx todo: consider removing flags parameter
getEventFromRow: function stor_getEventFromRow(row, flags, isException) { getEventFromRow: function cSC_getEventFromRow(row, flags, isException) {
var item; var item;
if (!isException) { // only parent items are cached if (!isException) { // only parent items are cached
item = this.mItemCache[row.id]; item = this.mItemCache[row.id];
@ -1993,7 +1993,7 @@ calStorageCalendar.prototype = {
return item; return item;
}, },
getTodoFromRow: function stor_getTodoFromRow(row, flags, isException) { getTodoFromRow: function cSC_getTodoFromRow(row, flags, isException) {
var item; var item;
if (!isException) { // only parent items are cached if (!isException) { // only parent items are cached
item = this.mItemCache[row.id]; item = this.mItemCache[row.id];
@ -2032,7 +2032,7 @@ calStorageCalendar.prototype = {
// We used to use mDBTwo for this, so this can be run while a // We used to use mDBTwo for this, so this can be run while a
// select is executing but this no longer seems to be required. // select is executing but this no longer seems to be required.
getAdditionalDataForItem: function (item, flags) { getAdditionalDataForItem: function cSC_getAdditionalDataForItem(item, flags) {
// This is needed to keep the modification time intact. // This is needed to keep the modification time intact.
var savedLastModifiedTime = item.lastModifiedTime; var savedLastModifiedTime = item.lastModifiedTime;
@ -2304,7 +2304,7 @@ calStorageCalendar.prototype = {
item.setProperty("LAST-MODIFIED", savedLastModifiedTime); item.setProperty("LAST-MODIFIED", savedLastModifiedTime);
}, },
getAttendeeFromRow: function (row) { getAttendeeFromRow: function cSC_getAttendeeFromRow(row) {
var a = CalAttendee(); var a = CalAttendee();
a.id = row.attendee_id; a.id = row.attendee_id;
@ -2333,7 +2333,7 @@ calStorageCalendar.prototype = {
return a; return a;
}, },
getAttachmentFromRow: function (row) { getAttachmentFromRow: function cSC_getAttachmentFromRow(row) {
var a = createAttachment(); var a = createAttachment();
// TODO we don't support binary data here, libical doesn't either. // TODO we don't support binary data here, libical doesn't either.
@ -2344,7 +2344,7 @@ calStorageCalendar.prototype = {
return a; return a;
}, },
getRelationFromRow: function (row) { getRelationFromRow: function cSC_getRelationFromRow(row) {
var r = createRelation(); var r = createRelation();
r.relType = row.rel_type; r.relType = row.rel_type;
r.relId = row.rel_id; r.relId = row.rel_id;
@ -2354,7 +2354,7 @@ calStorageCalendar.prototype = {
// //
// get item from db or from cache with given iid // get item from db or from cache with given iid
// //
getItemById: function (aID) { getItemById: function cSC_getItemById(aID) {
this.assureRecurringItemCaches(); this.assureRecurringItemCaches();
// cached? // cached?
@ -2401,7 +2401,7 @@ calStorageCalendar.prototype = {
// database writing functions // database writing functions
// //
setDateParamHelper: function (params, entryname, cdt) { setDateParamHelper: function cSC_setDateParamHelper(params, entryname, cdt) {
if (cdt) { if (cdt) {
params[entryname] = cdt.nativeTime; params[entryname] = cdt.nativeTime;
var tz = cdt.timezone; var tz = cdt.timezone;
@ -2417,7 +2417,7 @@ calStorageCalendar.prototype = {
} }
}, },
flushItem: function (item, olditem) { flushItem: function cSC_flushItem(item, olditem) {
ASSERT(!item.recurrenceId, "no parent item passed!", true); ASSERT(!item.recurrenceId, "no parent item passed!", true);
this.acquireTransaction(); this.acquireTransaction();
@ -2440,7 +2440,7 @@ calStorageCalendar.prototype = {
// to writeEvent/writeTodo to actually do the writing. // to writeEvent/writeTodo to actually do the writing.
// //
writeItem: function (item, olditem) { writeItem: function cSC_writeItem(item, olditem) {
var flags = 0; var flags = 0;
flags |= this.writeAttendees(item, olditem); flags |= this.writeAttendees(item, olditem);
@ -2458,7 +2458,7 @@ calStorageCalendar.prototype = {
throw Components.results.NS_ERROR_UNEXPECTED; throw Components.results.NS_ERROR_UNEXPECTED;
}, },
writeEvent: function (item, olditem, flags) { writeEvent: function cSC_writeEvent(item, olditem, flags) {
var ip = this.mInsertEvent.params; var ip = this.mInsertEvent.params;
this.setupItemBaseParams(item, olditem,ip); this.setupItemBaseParams(item, olditem,ip);
@ -2478,7 +2478,7 @@ calStorageCalendar.prototype = {
this.mInsertEvent.reset(); this.mInsertEvent.reset();
}, },
writeTodo: function (item, olditem, flags) { writeTodo: function cSC_writeTodo(item, olditem, flags) {
var ip = this.mInsertTodo.params; var ip = this.mInsertTodo.params;
this.setupItemBaseParams(item, olditem,ip); this.setupItemBaseParams(item, olditem,ip);
@ -2504,7 +2504,7 @@ calStorageCalendar.prototype = {
this.mInsertTodo.reset(); this.mInsertTodo.reset();
}, },
setupItemBaseParams: function (item, olditem, ip) { setupItemBaseParams: function cSC_setupItemBaseParams(item, olditem, ip) {
ip.id = item.id; ip.id = item.id;
if (item.recurrenceId) if (item.recurrenceId)
@ -2527,7 +2527,7 @@ calStorageCalendar.prototype = {
} }
}, },
writeAttendees: function (item, olditem) { writeAttendees: function cSC_writeAttendees(item, olditem) {
var attendees = item.getAttendees({}); var attendees = item.getAttendees({});
if (item.organizer) { if (item.organizer) {
attendees = attendees.concat([]); attendees = attendees.concat([]);
@ -2581,7 +2581,7 @@ calStorageCalendar.prototype = {
return 0; return 0;
}, },
writeProperty: function stor_writeProperty(item, propName, propValue) { writeProperty: function cSC_writeProperty(item, propName, propValue) {
var pp = this.mInsertProperty.params; var pp = this.mInsertProperty.params;
pp.key = propName; pp.key = propName;
if (calInstanceOf(propValue, Components.interfaces.calIDateTime)) { if (calInstanceOf(propValue, Components.interfaces.calIDateTime)) {
@ -2603,7 +2603,8 @@ calStorageCalendar.prototype = {
this.mInsertProperty.execute(); this.mInsertProperty.execute();
this.mInsertProperty.reset(); this.mInsertProperty.reset();
}, },
writeProperties: function (item, olditem) {
writeProperties: function cSC_writeProperties(item, olditem) {
var ret = 0; var ret = 0;
var propEnumerator = item.propertyEnumerator; var propEnumerator = item.propertyEnumerator;
while (propEnumerator.hasMoreElements()) { while (propEnumerator.hasMoreElements()) {
@ -2623,7 +2624,7 @@ calStorageCalendar.prototype = {
return ret; return ret;
}, },
writeRecurrence: function (item, olditem) { writeRecurrence: function cSC_writeRecurrence(item, olditem) {
var flags = 0; var flags = 0;
var rec = item.recurrenceInfo; var rec = item.recurrenceInfo;
@ -2708,7 +2709,7 @@ calStorageCalendar.prototype = {
return flags; return flags;
}, },
writeAttachments: function (item, olditem) { writeAttachments: function cSC_writeAttachments(item, olditem) {
var attachments = item.getAttachments({}); var attachments = item.getAttachments({});
if (attachments && attachments.length > 0) { if (attachments && attachments.length > 0) {
for each (att in attachments) { for each (att in attachments) {
@ -2726,7 +2727,7 @@ calStorageCalendar.prototype = {
return 0; return 0;
}, },
writeRelations: function (item, olditem) { writeRelations: function cSC_writeRelations(item, olditem) {
var relations = item.getRelations({}); var relations = item.getRelations({});
if (relations && relations.length > 0) { if (relations && relations.length > 0) {
for each (var rel in relations) { for each (var rel in relations) {
@ -2770,7 +2771,7 @@ calStorageCalendar.prototype = {
// //
// delete the item with the given uid // delete the item with the given uid
// //
deleteItemById: function stor_deleteItemById(aID) { deleteItemById: function cSC_deleteItemById(aID) {
this.acquireTransaction(); this.acquireTransaction();
try { try {
this.mDeleteAttendees(aID); this.mDeleteAttendees(aID);
@ -2792,7 +2793,7 @@ calStorageCalendar.prototype = {
delete this.mRecTodoCache[aID]; delete this.mRecTodoCache[aID];
}, },
acquireTransaction: function stor_acquireTransaction() { acquireTransaction: function cSC_acquireTransaction() {
var uriKey = this.uri.spec; var uriKey = this.uri.spec;
if (!(uriKey in gTransCount)) { if (!(uriKey in gTransCount)) {
gTransCount[uriKey] = 0; gTransCount[uriKey] = 0;
@ -2801,7 +2802,7 @@ calStorageCalendar.prototype = {
this.mDB.beginTransaction(); this.mDB.beginTransaction();
} }
}, },
releaseTransaction: function stor_releaseTransaction(err) { releaseTransaction: function cSC_releaseTransaction(err) {
var uriKey = this.uri.spec; var uriKey = this.uri.spec;
if (err) { if (err) {
cal.ERROR("DB error: " + this.mDB.lastErrorString + "\nexc: " + err); cal.ERROR("DB error: " + this.mDB.lastErrorString + "\nexc: " + err);
@ -2822,11 +2823,11 @@ calStorageCalendar.prototype = {
} }
}, },
startBatch: function stor_startBatch() { startBatch: function cSC_startBatch() {
this.acquireTransaction(); this.acquireTransaction();
this.__proto__.__proto__.startBatch.apply(this, arguments); this.__proto__.__proto__.startBatch.apply(this, arguments);
}, },
endBatch: function stor_endBatch() { endBatch: function cSC_endBatch() {
this.releaseTransaction(); this.releaseTransaction();
this.__proto__.__proto__.endBatch.apply(this, arguments); this.__proto__.__proto__.endBatch.apply(this, arguments);
}, },
@ -2835,7 +2836,7 @@ calStorageCalendar.prototype = {
// calISyncWriteCalendar interface // calISyncWriteCalendar interface
// //
setMetaData: function stor_setMetaData(id, value) { setMetaData: function cSC_setMetaData(id, value) {
this.mDeleteMetaData(id); this.mDeleteMetaData(id);
var sp = this.mInsertMetaData.params; var sp = this.mInsertMetaData.params;
sp.item_id = id; sp.item_id = id;
@ -2853,11 +2854,11 @@ calStorageCalendar.prototype = {
this.mInsertMetaData.reset(); this.mInsertMetaData.reset();
}, },
deleteMetaData: function stor_deleteMetaData(id) { deleteMetaData: function cSC_deleteMetaData(id) {
this.mDeleteMetaData(id); this.mDeleteMetaData(id);
}, },
getMetaData: function stor_getMetaData(id) { getMetaData: function cSC_getMetaData(id) {
let query = this.mSelectMetaData; let query = this.mSelectMetaData;
query.params.item_id = id; query.params.item_id = id;
let value = null; let value = null;
@ -2874,7 +2875,7 @@ calStorageCalendar.prototype = {
return value; return value;
}, },
getAllMetaData: function stor_getAllMetaData(out_count, getAllMetaData: function cSC_getAllMetaData(out_count,
out_ids, out_ids,
out_values) { out_values) {
var query = this.mSelectAllMetaData; var query = this.mSelectAllMetaData;