Bug 1280898 - Set up eslint for calendar files - enable consistent-this and no-useless-call rule. r=MakeMyDay
MozReview-Commit-ID: CJ5anO9j2VX --HG-- extra : rebase_source : 43e734ad7471132048406515c5c94d8ee8612b0a
This commit is contained in:
Родитель
89700567e8
Коммит
07739923ce
|
@ -379,6 +379,12 @@
|
|||
// Disallow spaces inside of computed properties
|
||||
"computed-property-spacing": [2, "never"],
|
||||
|
||||
// Require consistent this (using |self|)
|
||||
"consistent-this": [2, "self"],
|
||||
|
||||
// Disallow unnecessary .call() and .apply()
|
||||
"no-useless-call": 2,
|
||||
|
||||
// The following rules will not be enabled currently, but are kept here for
|
||||
// easier updates in the future.
|
||||
"no-else-return": 0,
|
||||
|
|
|
@ -401,11 +401,11 @@ calIcalComponent.prototype = {
|
|||
},
|
||||
|
||||
_getNextParentVCalendar: function() {
|
||||
let that = this;
|
||||
while (that && that.componentType != "VCALENDAR") {
|
||||
that = that.parent;
|
||||
let vcalendar = this; // eslint-disable-line consistent-this
|
||||
while (vcalendar && vcalendar.componentType != "VCALENDAR") {
|
||||
vcalendar = vcalendar.parent;
|
||||
}
|
||||
return that || this;
|
||||
return vcalendar || this;
|
||||
},
|
||||
|
||||
addProperty: function(prop) {
|
||||
|
|
|
@ -1096,9 +1096,8 @@
|
|||
|
||||
if (!aStop) {
|
||||
// Set up a timer to stop the flashing after the total time.
|
||||
let this_ = this;
|
||||
this.mFlashingEvents[aAlarmItem.hashId] = aAlarmItem;
|
||||
setTimeout(function() { this_.flashAlarm(aAlarmItem, true); }, totaltime);
|
||||
setTimeout(() => this.flashAlarm(aAlarmItem, true), totaltime);
|
||||
} else {
|
||||
// We are done flashing, prevent newly created event boxes from flashing.
|
||||
delete this.mFlashingEvents[aAlarmItem.hashId];
|
||||
|
|
|
@ -596,13 +596,12 @@
|
|||
if (this.mEventMapTimeout) {
|
||||
clearTimeout(this.mEventMapTimeout);
|
||||
}
|
||||
let column = this;
|
||||
|
||||
if (this.mCreatedNewEvent) {
|
||||
this.mEventToEdit = aOccurrence;
|
||||
}
|
||||
// Fun with scoping...
|
||||
this.mEventMapTimeout = setTimeout(function() { column.relayout.call(column); }, 5);
|
||||
|
||||
this.mEventMapTimeout = setTimeout(() => this.relayout(), 5);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
@ -1259,8 +1258,8 @@
|
|||
<parameter name="aOffset"/>
|
||||
<parameter name="aShadows"/>
|
||||
<body><![CDATA[
|
||||
let firstCol = this;
|
||||
let lastCol = this;
|
||||
let firstCol = this; // eslint-disable-line consistent-this
|
||||
let lastCol = this; // eslint-disable-line consistent-this
|
||||
let firstIndex = (aOffset != null ? aOffset : this.mDragState.offset);
|
||||
let lastIndex = firstIndex;
|
||||
while (firstCol.previousSibling && firstIndex > 0) {
|
||||
|
@ -2679,12 +2678,8 @@
|
|||
<method name="onResize">
|
||||
<parameter name="aRealSelf"/>
|
||||
<body><![CDATA[
|
||||
let self = this;
|
||||
let isARelayout = true;
|
||||
if (aRealSelf) {
|
||||
self = aRealSelf;
|
||||
isARelayout = false;
|
||||
}
|
||||
let self = aRealSelf || this; // eslint-disable-line consistent-this
|
||||
let isARelayout = !aRealSelf;
|
||||
let scrollbox = document.getAnonymousElementByAttribute(self, "anonid", "scrollbox");
|
||||
let size;
|
||||
if (self.orient == "horizontal") {
|
||||
|
@ -2770,9 +2765,8 @@
|
|||
|
||||
if (!aStop) {
|
||||
// Set up a timer to stop the flashing after the total time.
|
||||
let this_ = this;
|
||||
this.mFlashingEvents[aAlarmItem.hashId] = aAlarmItem;
|
||||
setTimeout(function() { this_.flashAlarm(aAlarmItem, true); }, totaltime);
|
||||
setTimeout(() => this.flashAlarm(aAlarmItem, true), totaltime);
|
||||
} else {
|
||||
// We are done flashing, prevent newly created event boxes from flashing.
|
||||
delete this.mFlashingEvents[aAlarmItem.hashId];
|
||||
|
@ -3288,29 +3282,28 @@
|
|||
let daybox = document.getAnonymousElementByAttribute(this, "anonid", "daybox");
|
||||
let headerdaybox = document.getAnonymousElementByAttribute(this, "anonid", "headerdaybox");
|
||||
|
||||
let calView = this;
|
||||
let dayStartMin = this.mDayStartMin;
|
||||
let dayEndMin = this.mDayEndMin;
|
||||
function setUpDayEventsBox(aDayBox, date) {
|
||||
let setUpDayEventsBox = (aDayBox, date) => {
|
||||
aDayBox.setAttribute("class", "calendar-event-column-" + (counter % 2 == 0 ? "even" : "odd"));
|
||||
aDayBox.setAttribute("context", calView.getAttribute("context"));
|
||||
aDayBox.setAttribute("item-context", calView.getAttribute("item-context") || calView.getAttribute("context"));
|
||||
aDayBox.setAttribute("context", this.getAttribute("context"));
|
||||
aDayBox.setAttribute("item-context", this.getAttribute("item-context") || this.getAttribute("context"));
|
||||
aDayBox.startLayoutBatchChange();
|
||||
aDayBox.date = date;
|
||||
aDayBox.setAttribute("orient", orient);
|
||||
aDayBox.calendarView = calView;
|
||||
aDayBox.calendarView = this;
|
||||
aDayBox.setDayStartEndMinutes(dayStartMin, dayEndMin);
|
||||
}
|
||||
};
|
||||
|
||||
function setUpDayHeaderBox(aDayBox, date) {
|
||||
let setUpDayHeaderBox = (aDayBox, date) => {
|
||||
aDayBox.date = date;
|
||||
aDayBox.calendarView = calView;
|
||||
aDayBox.calendarView = this;
|
||||
aDayBox.setAttribute("orient", "vertical");
|
||||
// Since the calendar-header-container boxes have the same vertical
|
||||
// orientation for normal and rotated views, it needs an attribute
|
||||
// "rotated" in order to have different css rules.
|
||||
setBooleanAttribute(aDayBox, "rotated", orient == "horizontal");
|
||||
}
|
||||
};
|
||||
|
||||
this.mDateColumns = [];
|
||||
|
||||
|
|
|
@ -1474,12 +1474,11 @@ ItipItemFinder.prototype = {
|
|||
switch (method) {
|
||||
case "REQUEST":
|
||||
case "PUBLISH": {
|
||||
let this_ = this;
|
||||
let action = function(opListener, partStat) {
|
||||
let action = (opListener, partStat) => {
|
||||
let newItem = itipItemItem.clone();
|
||||
setReceivedInfo(newItem, itipItemItem);
|
||||
newItem.parentItem.calendar = this_.mItipItem.targetCalendar;
|
||||
addScheduleAgentClient(newItem, this_.mItipItem.targetCalendar);
|
||||
newItem.parentItem.calendar = this.mItipItem.targetCalendar;
|
||||
addScheduleAgentClient(newItem, this.mItipItem.targetCalendar);
|
||||
if (partStat) {
|
||||
if (partStat != "DECLINED") {
|
||||
cal.alarms.setDefaultValues(newItem);
|
||||
|
|
|
@ -535,18 +535,18 @@ cal.ProviderBase.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
let this_ = this;
|
||||
function takeOverIfNotPresent(oldPref, newPref, dontDeleteOldPref) {
|
||||
let val = calMgr.getCalendarPref_(this_, oldPref);
|
||||
let takeOverIfNotPresent = (oldPref, newPref, dontDeleteOldPref) => {
|
||||
let val = calMgr.getCalendarPref_(this, oldPref);
|
||||
if (val !== null) {
|
||||
if (!dontDeleteOldPref) {
|
||||
calMgr.deleteCalendarPref_(this_, oldPref);
|
||||
calMgr.deleteCalendarPref_(this, oldPref);
|
||||
}
|
||||
if (calMgr.getCalendarPref_(this_, newPref) === null) {
|
||||
calMgr.setCalendarPref_(this_, newPref, val);
|
||||
if (calMgr.getCalendarPref_(this, newPref) === null) {
|
||||
calMgr.setCalendarPref_(this, newPref, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// takeover lightning calendar visibility from 0.5:
|
||||
takeOverIfNotPresent("lightning-main-in-composite", "calendar-main-in-composite");
|
||||
takeOverIfNotPresent("lightning-main-default", "calendar-main-default");
|
||||
|
|
|
@ -223,19 +223,19 @@ calCachedCalendar.prototype = {
|
|||
},
|
||||
|
||||
getOfflineAddedItems: function cCC_getOfflineAddedItems(callbackFunc) {
|
||||
let this_ = this;
|
||||
this_.offlineCachedItems = {};
|
||||
let self = this;
|
||||
self.offlineCachedItems = {};
|
||||
let getListener = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
|
||||
onGetResult: function cCC_oOC_cL_onGetResult(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
|
||||
for (let item of aItems) {
|
||||
this_.offlineCachedItems[item.hashId] = item;
|
||||
this_.offlineCachedItemFlags[item.hashId] = cICL.OFFLINE_FLAG_CREATED_RECORD;
|
||||
self.offlineCachedItems[item.hashId] = item;
|
||||
self.offlineCachedItemFlags[item.hashId] = cICL.OFFLINE_FLAG_CREATED_RECORD;
|
||||
}
|
||||
},
|
||||
|
||||
onOperationComplete: function cCC_oOC_cL_onOperationComplete(aCalendar, aStatus, aOpType, aId, aDetail) {
|
||||
this_.getOfflineModifiedItems(callbackFunc);
|
||||
self.getOfflineModifiedItems(callbackFunc);
|
||||
}
|
||||
};
|
||||
this.mCachedCalendar.getItems(calICalendar.ITEM_FILTER_ALL_ITEMS | calICalendar.ITEM_FILTER_OFFLINE_CREATED,
|
||||
|
@ -243,18 +243,18 @@ calCachedCalendar.prototype = {
|
|||
},
|
||||
|
||||
getOfflineModifiedItems: function cCC_getOfflineModifiedItems(callbackFunc) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let getListener = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
|
||||
onGetResult: function cCC_oOC_cL_onGetResult(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
|
||||
for (let item of aItems) {
|
||||
this_.offlineCachedItems[item.hashId] = item;
|
||||
this_.offlineCachedItemFlags[item.hashId] = cICL.OFFLINE_FLAG_MODIFIED_RECORD;
|
||||
self.offlineCachedItems[item.hashId] = item;
|
||||
self.offlineCachedItemFlags[item.hashId] = cICL.OFFLINE_FLAG_MODIFIED_RECORD;
|
||||
}
|
||||
},
|
||||
|
||||
onOperationComplete: function cCC_oOC_cL_onOperationComplete(aCalendar, aStatus, aOpType, aId, aDetail) {
|
||||
this_.getOfflineDeletedItems(callbackFunc);
|
||||
self.getOfflineDeletedItems(callbackFunc);
|
||||
}
|
||||
};
|
||||
this.mCachedCalendar.getItems(calICalendar.ITEM_FILTER_OFFLINE_MODIFIED | calICalendar.ITEM_FILTER_ALL_ITEMS,
|
||||
|
@ -262,13 +262,13 @@ calCachedCalendar.prototype = {
|
|||
},
|
||||
|
||||
getOfflineDeletedItems: function cCC_getOfflineDeletedItems(callbackFunc) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let getListener = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
|
||||
onGetResult: function cCC_oOC_cL_onGetResult(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
|
||||
for (let item of aItems) {
|
||||
this_.offlineCachedItems[item.hashId] = item;
|
||||
this_.offlineCachedItemFlags[item.hashId] = cICL.OFFLINE_FLAG_DELETED_RECORD;
|
||||
self.offlineCachedItems[item.hashId] = item;
|
||||
self.offlineCachedItemFlags[item.hashId] = cICL.OFFLINE_FLAG_DELETED_RECORD;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -285,7 +285,7 @@ calCachedCalendar.prototype = {
|
|||
mPendingSync: null,
|
||||
mSyncQueue: null,
|
||||
synchronize: function cCC_synchronize(respFunc) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
if (this.getProperty("disabled")) {
|
||||
return emptyQueue(Components.results.NS_OK);
|
||||
}
|
||||
|
@ -297,8 +297,8 @@ calCachedCalendar.prototype = {
|
|||
}
|
||||
|
||||
function emptyQueue(status) {
|
||||
let queue = this_.mSyncQueue;
|
||||
this_.mSyncQueue = [];
|
||||
let queue = self.mSyncQueue;
|
||||
self.mSyncQueue = [];
|
||||
function execResponseFunc(func) {
|
||||
try {
|
||||
func(status);
|
||||
|
@ -308,8 +308,8 @@ calCachedCalendar.prototype = {
|
|||
}
|
||||
queue.forEach(execResponseFunc);
|
||||
cal.LOG("[calCachedCalendar] sync queue empty.");
|
||||
let op = this_.mPendingSync;
|
||||
this_.mPendingSync = null;
|
||||
let op = self.mPendingSync;
|
||||
self.mPendingSync = null;
|
||||
return op;
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ calCachedCalendar.prototype = {
|
|||
if (!Components.isSuccessCode(status)) {
|
||||
cal.ERROR("[calCachedCalendar] replay action failed: " +
|
||||
(op ? op.id : "<unknown>") + ", uri=" +
|
||||
this_.uri.spec + ", result=" +
|
||||
self.uri.spec + ", result=" +
|
||||
result + ", op=" + op);
|
||||
}
|
||||
cal.LOG("[calCachedCalendar] replayChangesOn finished.");
|
||||
|
@ -358,7 +358,7 @@ calCachedCalendar.prototype = {
|
|||
// TODO instead of deleting the calendar and creating a new
|
||||
// one, maybe we want to do a "real" sync between the
|
||||
// existing local calendar and the remote calendar.
|
||||
this_.setupCachedCalendar();
|
||||
self.setupCachedCalendar();
|
||||
this.hasRenewedCalendar = true;
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ calCachedCalendar.prototype = {
|
|||
// Adding items recd from the Memory Calendar
|
||||
// These may be different than what the cache has
|
||||
completeListener.modifiedTimes[item.id] = item.lastModifiedTime;
|
||||
this_.mCachedCalendar.addItem(item, null);
|
||||
self.mCachedCalendar.addItem(item, null);
|
||||
}, function completed() {
|
||||
completeListener.getsCompleted++;
|
||||
if (completeListener.opCompleted) {
|
||||
|
@ -392,11 +392,11 @@ calCachedCalendar.prototype = {
|
|||
}
|
||||
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
cal.forEach(this_.offlineCachedItems, function(item) {
|
||||
switch (this_.offlineCachedItemFlags[item.hashId]) {
|
||||
cal.forEach(self.offlineCachedItems, function(item) {
|
||||
switch (self.offlineCachedItemFlags[item.hashId]) {
|
||||
case cICL.OFFLINE_FLAG_CREATED_RECORD:
|
||||
// Created items are not present on the server, so its safe to adopt them
|
||||
this_.adoptOfflineItem(item.clone(), null);
|
||||
self.adoptOfflineItem(item.clone(), null);
|
||||
break;
|
||||
case cICL.OFFLINE_FLAG_MODIFIED_RECORD:
|
||||
// Two Cases Here:
|
||||
|
@ -405,16 +405,16 @@ calCachedCalendar.prototype = {
|
|||
if (item.lastModifiedTime.compare(completeListener.modifiedTimes[item.id]) < 0) {
|
||||
// The item on the server has been modified, ask to overwrite
|
||||
cal.WARN("[calCachedCalendar] Item '" + item.title + "' at the server seems to be modified recently.");
|
||||
this_.promptOverwrite("modify", item, null, null);
|
||||
self.promptOverwrite("modify", item, null, null);
|
||||
} else {
|
||||
// Our item is newer, just modify the item
|
||||
this_.modifyOfflineItem(item, null, null);
|
||||
self.modifyOfflineItem(item, null, null);
|
||||
}
|
||||
} else {
|
||||
// The item has been deleted from the server, ask if it should be added again
|
||||
cal.WARN("[calCachedCalendar] Item '" + item.title + "' has been deleted from the server");
|
||||
if (cal.promptOverwrite("modify", item, null, null)) {
|
||||
this_.adoptOfflineItem(item.clone(), null);
|
||||
self.adoptOfflineItem(item.clone(), null);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -424,10 +424,10 @@ calCachedCalendar.prototype = {
|
|||
if (item.lastModifiedTime.compare(completeListener.modifiedTimes[item.id]) < 0) {
|
||||
// ...and has been modified on the server. Ask to overwrite
|
||||
cal.WARN("[calCachedCalendar] Item '" + item.title + "' at the server seems to be modified recently.");
|
||||
this_.promptOverwrite("delete", item, null, null);
|
||||
self.promptOverwrite("delete", item, null, null);
|
||||
} else {
|
||||
// ...and has not been modified. Delete it now.
|
||||
this_.deleteOfflineItem(item, null);
|
||||
self.deleteOfflineItem(item, null);
|
||||
}
|
||||
} else {
|
||||
// Item has already been deleted from the server, no need to change anything.
|
||||
|
@ -436,12 +436,12 @@ calCachedCalendar.prototype = {
|
|||
}
|
||||
},
|
||||
function completed() {
|
||||
this_.offlineCachedItems = {};
|
||||
this_.offlineCachedItemFlags = {};
|
||||
this_.playbackOfflineItems(() => emptyQueue(aStatus));
|
||||
self.offlineCachedItems = {};
|
||||
self.offlineCachedItemFlags = {};
|
||||
self.playbackOfflineItems(() => emptyQueue(aStatus));
|
||||
});
|
||||
} else {
|
||||
this_.playbackOfflineItems(function() { this_.mCachedObserver.onLoad(this_.mCachedCalendar); });
|
||||
self.playbackOfflineItems(function() { self.mCachedObserver.onLoad(self.mCachedCalendar); });
|
||||
emptyQueue(aStatus);
|
||||
}
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ calCachedCalendar.prototype = {
|
|||
* OFFLINE_FLAG_XXX constants in the calIChangeLog interface.
|
||||
*/
|
||||
playbackOfflineItems: function cCC_playbackOfflineItems(aCallback, aPlaybackType) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let storage = this.mCachedCalendar.QueryInterface(Components.interfaces.calIOfflineStorage);
|
||||
|
||||
let resetListener = gNoOpListener;
|
||||
|
@ -509,7 +509,7 @@ calCachedCalendar.prototype = {
|
|||
case cICL.OFFLINE_FLAG_MODIFIED_RECORD:
|
||||
debugOp = "modify";
|
||||
nextCallback = this.playbackOfflineItems.bind(this, aCallback, cICL.OFFLINE_FLAG_DELETED_RECORD);
|
||||
uncachedOp = function(item, listener) { this_.mUncachedCalendar.modifyItem(item, item, listener); };
|
||||
uncachedOp = function(item, listener) { self.mUncachedCalendar.modifyItem(item, item, listener); };
|
||||
listenerOp = cIOL.MODIFY;
|
||||
filter = calICalendar.ITEM_FILTER_OFFLINE_MODIFIED;
|
||||
break;
|
||||
|
@ -530,7 +530,7 @@ calCachedCalendar.prototype = {
|
|||
onOperationComplete: function(calendar, status, opType, id, detail) {
|
||||
if (Components.isSuccessCode(status)) {
|
||||
if (aPlaybackType == cICL.OFFLINE_FLAG_DELETED_RECORD) {
|
||||
this_.mCachedCalendar.deleteItem(detail, resetListener);
|
||||
self.mCachedCalendar.deleteItem(detail, resetListener);
|
||||
} else {
|
||||
storage.resetItemOfflineFlag(detail, resetListener);
|
||||
}
|
||||
|
@ -561,7 +561,7 @@ calCachedCalendar.prototype = {
|
|||
} catch (e) {
|
||||
cal.ERROR("[calCachedCalendar] Could not perform playback operation " + debugOp +
|
||||
" for item " + (item.title || " (none) ") + ": " + e);
|
||||
opListener.onOperationComplete(this_, e.result, listenerOp, item.id, e.message);
|
||||
opListener.onOperationComplete(self, e.result, listenerOp, item.id, e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -571,14 +571,14 @@ calCachedCalendar.prototype = {
|
|||
itemQueue = itemQueue.concat(items);
|
||||
},
|
||||
onOperationComplete: function(calendar, status, opType, id, detail) {
|
||||
if (this_.offline) {
|
||||
if (self.offline) {
|
||||
cal.LOG("[calCachedCalendar] back to offline mode, reconciliation aborted");
|
||||
if (aCallback) {
|
||||
aCallback();
|
||||
}
|
||||
} else {
|
||||
cal.LOG("[calCachedCalendar] Performing playback operation " + debugOp +
|
||||
" on " + itemQueue.length + " items to " + this_.name);
|
||||
" on " + itemQueue.length + " items to " + self.name);
|
||||
|
||||
// start the first operation
|
||||
popItemQueue();
|
||||
|
@ -633,10 +633,10 @@ calCachedCalendar.prototype = {
|
|||
if (this.mUncachedCalendar.canRefresh && !this.offline) {
|
||||
return this.mUncachedCalendar.refresh(); // will trigger synchronize once the calendar is loaded
|
||||
} else {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
return this.synchronize(
|
||||
function(status) { // fire completing onLoad for this refresh call
|
||||
this_.mCachedObserver.onLoad(this_.mCachedCalendar);
|
||||
self.mCachedObserver.onLoad(self.mCachedCalendar);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -694,17 +694,17 @@ calCachedCalendar.prototype = {
|
|||
}
|
||||
},
|
||||
adoptOfflineItem: function(item, listener) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let opListener = {
|
||||
onGetResult: function(calendar, status, itemType, detail, count, items) {
|
||||
cal.ASSERT(false, "unexpected!");
|
||||
},
|
||||
onOperationComplete: function(calendar, status, opType, id, detail) {
|
||||
if (Components.isSuccessCode(status)) {
|
||||
let storage = this_.mCachedCalendar.QueryInterface(Components.interfaces.calIOfflineStorage);
|
||||
let storage = self.mCachedCalendar.QueryInterface(Components.interfaces.calIOfflineStorage);
|
||||
storage.addOfflineItem(detail, listener);
|
||||
} else if (listener) {
|
||||
listener.onOperationComplete(this_, status, opType, id, detail);
|
||||
listener.onOperationComplete(self, status, opType, id, detail);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -770,7 +770,7 @@ calCachedCalendar.prototype = {
|
|||
},
|
||||
|
||||
modifyOfflineItem: function(newItem, oldItem, listener) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let opListener = {
|
||||
onGetResult: function(calendar, status, itemType, detail, count, items) {
|
||||
cal.ASSERT(false, "unexpected!");
|
||||
|
@ -779,12 +779,12 @@ calCachedCalendar.prototype = {
|
|||
if (Components.isSuccessCode(status)) {
|
||||
// Modify the offline item in the storage, passing the
|
||||
// listener will make sure its notified
|
||||
let storage = this_.mCachedCalendar.QueryInterface(Components.interfaces.calIOfflineStorage);
|
||||
let storage = self.mCachedCalendar.QueryInterface(Components.interfaces.calIOfflineStorage);
|
||||
storage.modifyOfflineItem(detail, listener);
|
||||
} else if (listener) {
|
||||
// If there was not a success, then we need to notify the
|
||||
// listener ourselves
|
||||
listener.onOperationComplete(this_, status, opType, id, detail);
|
||||
listener.onOperationComplete(self, status, opType, id, detail);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7,11 +7,9 @@ function calCalendarSearchListener(numOperations, finalListener) {
|
|||
this.mNumOperations = numOperations;
|
||||
this.mResults = [];
|
||||
|
||||
let this_ = this;
|
||||
function cancelFunc() { // operation group has been cancelled
|
||||
this_.notifyResult(null);
|
||||
}
|
||||
this.opGroup = new calOperationGroup(cancelFunc);
|
||||
this.opGroup = new calOperationGroup(() => {
|
||||
this.notifyResult(null);
|
||||
});
|
||||
}
|
||||
calCalendarSearchListener.prototype = {
|
||||
mFinalListener: null,
|
||||
|
|
|
@ -8,11 +8,9 @@ function calFreeBusyListener(numOperations, finalListener) {
|
|||
this.mFinalListener = finalListener;
|
||||
this.mNumOperations = numOperations;
|
||||
|
||||
let this_ = this;
|
||||
function cancelFunc() { // operation group has been cancelled
|
||||
this_.notifyResult(null);
|
||||
}
|
||||
this.opGroup = new calOperationGroup(cancelFunc);
|
||||
this.opGroup = new calOperationGroup(() => {
|
||||
this.notifyResult(null);
|
||||
});
|
||||
}
|
||||
calFreeBusyListener.prototype = {
|
||||
mFinalListener: null,
|
||||
|
|
|
@ -254,7 +254,7 @@ parserState.prototype = {
|
|||
* @param subComp The component to process
|
||||
*/
|
||||
submit: function submit(subComp) {
|
||||
let state = this;
|
||||
let self = this;
|
||||
let runner = {
|
||||
run: function run() {
|
||||
let item = null;
|
||||
|
@ -262,14 +262,14 @@ parserState.prototype = {
|
|||
case "VEVENT":
|
||||
item = cal.createEvent();
|
||||
item.icalComponent = subComp;
|
||||
state.checkTimezone(item, item.startDate);
|
||||
state.checkTimezone(item, item.endDate);
|
||||
self.checkTimezone(item, item.startDate);
|
||||
self.checkTimezone(item, item.endDate);
|
||||
break;
|
||||
case "VTODO":
|
||||
item = cal.createTodo();
|
||||
item.icalComponent = subComp;
|
||||
state.checkTimezone(item, item.entryDate);
|
||||
state.checkTimezone(item, item.dueDate);
|
||||
self.checkTimezone(item, item.entryDate);
|
||||
self.checkTimezone(item, item.dueDate);
|
||||
// completed is defined to be in UTC
|
||||
break;
|
||||
case "VTIMEZONE":
|
||||
|
@ -278,23 +278,23 @@ parserState.prototype = {
|
|||
// do anything with it here.
|
||||
break;
|
||||
default:
|
||||
state.extraComponents.push(subComp);
|
||||
self.extraComponents.push(subComp);
|
||||
break;
|
||||
}
|
||||
|
||||
if (item) {
|
||||
let rid = item.recurrenceId;
|
||||
if (!rid) {
|
||||
state.items.push(item);
|
||||
self.items.push(item);
|
||||
if (item.recurrenceInfo) {
|
||||
state.uid2parent[item.id] = item;
|
||||
self.uid2parent[item.id] = item;
|
||||
}
|
||||
} else {
|
||||
state.excItems.push(item);
|
||||
self.excItems.push(item);
|
||||
}
|
||||
}
|
||||
state.threadCount--;
|
||||
state.checkCompletion();
|
||||
self.threadCount--;
|
||||
self.checkCompletion();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -647,7 +647,7 @@ calDavCalendar.prototype = {
|
|||
let itemUri = this.makeUri(locationPath);
|
||||
cal.LOG("CalDAV: itemUri.spec = " + itemUri.spec);
|
||||
|
||||
let thisCalendar = this;
|
||||
let self = this;
|
||||
let serializedItem = this.getSerializedItem(aItem);
|
||||
let addListener = {
|
||||
onStreamComplete: function onPutComplete(aLoader, aContext, aStatus, aResultLength, aResult) {
|
||||
|
@ -658,7 +658,7 @@ calDavCalendar.prototype = {
|
|||
try {
|
||||
responseStatus = request.responseStatus;
|
||||
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
if (self.verboseLogging()) {
|
||||
let str = cal.convertByteArray(aResult, aResultLength);
|
||||
cal.LOG("CalDAV: recv: " + (str || ""));
|
||||
}
|
||||
|
@ -673,13 +673,13 @@ calDavCalendar.prototype = {
|
|||
if (responseStatus == 201 || responseStatus == 204) {
|
||||
// 201 = HTTP "Created"
|
||||
// 204 = HTTP "No Content"
|
||||
cal.LOG("CalDAV: Item added to " + thisCalendar.name + " successfully");
|
||||
cal.LOG("CalDAV: Item added to " + self.name + " successfully");
|
||||
|
||||
let uriComponentParts = thisCalendar.makeUri().path.replace(/\/{2,}/g, "/").split("/").length;
|
||||
let uriComponentParts = self.makeUri().path.replace(/\/{2,}/g, "/").split("/").length;
|
||||
let targetParts = request.URI.path.split("/");
|
||||
targetParts.splice(0, uriComponentParts - 1);
|
||||
|
||||
thisCalendar.mItemInfoCache[parentItem.id] = {
|
||||
self.mItemInfoCache[parentItem.id] = {
|
||||
locationPath: targetParts.join("/")
|
||||
};
|
||||
// TODO: onOpComplete adds the item to the cache, probably after getUpdatedItem!
|
||||
|
@ -688,7 +688,7 @@ calDavCalendar.prototype = {
|
|||
// for instance) so we'd best re-fetch in order to know
|
||||
// the current state of the item
|
||||
// Observers will be notified in getUpdatedItem()
|
||||
thisCalendar.getUpdatedItem(parentItem, aListener);
|
||||
self.getUpdatedItem(parentItem, aListener);
|
||||
return;
|
||||
} else if (responseStatus >= 500 && responseStatus <= 510) {
|
||||
listenerStatus = Components.results.NS_ERROR_NOT_AVAILABLE;
|
||||
|
@ -697,7 +697,7 @@ calDavCalendar.prototype = {
|
|||
// There is a response status, but we haven't handled it yet. Any
|
||||
// error occurring here should consider being handled!
|
||||
cal.ERROR("CalDAV: Unexpected status adding item to " +
|
||||
thisCalendar.name + ": " + responseStatus + "\n" +
|
||||
self.name + ": " + responseStatus + "\n" +
|
||||
serializedItem);
|
||||
|
||||
listenerStatus = Components.results.NS_ERROR_FAILURE;
|
||||
|
@ -705,8 +705,8 @@ calDavCalendar.prototype = {
|
|||
}
|
||||
|
||||
// Still need to visually notify for uncached calendars.
|
||||
if (!thisCalendar.isCached && !Components.isSuccessCode(listenerStatus)) {
|
||||
thisCalendar.reportDavError(calIErrors.DAV_PUT_ERROR, listenerStatus, listenerDetail);
|
||||
if (!self.isCached && !Components.isSuccessCode(listenerStatus)) {
|
||||
self.reportDavError(calIErrors.DAV_PUT_ERROR, listenerStatus, listenerDetail);
|
||||
}
|
||||
|
||||
// Finally, notify listener.
|
||||
|
@ -766,7 +766,7 @@ calDavCalendar.prototype = {
|
|||
|
||||
let eventUri = this.makeUri(this.mItemInfoCache[aNewItem.id].locationPath);
|
||||
|
||||
let thisCalendar = this;
|
||||
let self = this;
|
||||
|
||||
let modifiedItemICS = this.getSerializedItem(aNewItem);
|
||||
|
||||
|
@ -780,7 +780,7 @@ calDavCalendar.prototype = {
|
|||
try {
|
||||
responseStatus = request.responseStatus;
|
||||
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
if (self.verboseLogging()) {
|
||||
let str = cal.convertByteArray(aResult, aResultLength);
|
||||
cal.LOG("CalDAV: recv: " + (str || ""));
|
||||
}
|
||||
|
@ -794,24 +794,24 @@ calDavCalendar.prototype = {
|
|||
// We should not accept a 201 status here indefinitely: it indicates a server error
|
||||
// of some kind that we want to know about. It's convenient to accept it for now
|
||||
// since a number of server impls don't get this right yet.
|
||||
cal.LOG("CalDAV: Item modified successfully on " + thisCalendar.name);
|
||||
cal.LOG("CalDAV: Item modified successfully on " + self.name);
|
||||
|
||||
// Some CalDAV servers will modify items on PUT (add X-props,
|
||||
// for instance) so we'd best re-fetch in order to know
|
||||
// the current state of the item
|
||||
// Observers will be notified in getUpdatedItem()
|
||||
thisCalendar.getUpdatedItem(aNewItem, aListener);
|
||||
self.getUpdatedItem(aNewItem, aListener);
|
||||
|
||||
// SOGo has calendarUri == inboxUri so we need to be careful
|
||||
// about deletions
|
||||
if (wasInboxItem && thisCalendar.mShouldPollInbox) {
|
||||
thisCalendar.doDeleteItem(aNewItem, null, true, true, null);
|
||||
if (wasInboxItem && self.mShouldPollInbox) {
|
||||
self.doDeleteItem(aNewItem, null, true, true, null);
|
||||
}
|
||||
return;
|
||||
} else if (responseStatus == 412 || responseStatus == 409) {
|
||||
// promptOverwrite will ask the user and then re-request
|
||||
thisCalendar.promptOverwrite(CALDAV_MODIFY_ITEM, aNewItem,
|
||||
aListener, aOldItem);
|
||||
self.promptOverwrite(CALDAV_MODIFY_ITEM, aNewItem,
|
||||
aListener, aOldItem);
|
||||
return;
|
||||
} else if (responseStatus >= 500 && responseStatus <= 510) {
|
||||
listenerStatus = Components.results.NS_ERROR_NOT_AVAILABLE;
|
||||
|
@ -820,7 +820,7 @@ calDavCalendar.prototype = {
|
|||
// There is a response status, but we haven't handled it yet. Any
|
||||
// error occurring here should consider being handled!
|
||||
cal.ERROR("CalDAV: Unexpected status modifying item to " +
|
||||
thisCalendar.name + ": " + responseStatus + "\n" +
|
||||
self.name + ": " + responseStatus + "\n" +
|
||||
modifiedItemICS);
|
||||
|
||||
listenerStatus = Components.results.NS_ERROR_FAILURE;
|
||||
|
@ -828,8 +828,8 @@ calDavCalendar.prototype = {
|
|||
}
|
||||
|
||||
// Still need to visually notify for uncached calendars.
|
||||
if (!thisCalendar.isCached && !Components.isSuccessCode(listenerStatus)) {
|
||||
thisCalendar.reportDavError(calIErrors.DAV_PUT_ERROR, listenerStatus, listenerDetail);
|
||||
if (!self.isCached && !Components.isSuccessCode(listenerStatus)) {
|
||||
self.reportDavError(calIErrors.DAV_PUT_ERROR, listenerStatus, listenerDetail);
|
||||
}
|
||||
|
||||
notifyListener(listenerStatus, listenerDetail, true);
|
||||
|
@ -897,7 +897,7 @@ calDavCalendar.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
let thisCalendar = this;
|
||||
let self = this;
|
||||
|
||||
let delListener = {
|
||||
onStreamComplete: function caldav_dDI_del_onStreamComplete(aLoader, aContext, aStatus, aResultLength, aResult) {
|
||||
|
@ -908,7 +908,7 @@ calDavCalendar.prototype = {
|
|||
try {
|
||||
responseStatus = request.responseStatus;
|
||||
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
if (self.verboseLogging()) {
|
||||
let str = cal.convertByteArray(aResult, aResultLength);
|
||||
cal.LOG("CalDAV: recv: " + (str || ""));
|
||||
}
|
||||
|
@ -923,23 +923,23 @@ calDavCalendar.prototype = {
|
|||
//
|
||||
if (responseStatus == 204 || responseStatus == 200 || responseStatus == 404) {
|
||||
if (!aFromInbox) {
|
||||
let decodedPath = thisCalendar.ensureDecodedPath(eventUri.path);
|
||||
delete thisCalendar.mHrefIndex[decodedPath];
|
||||
delete thisCalendar.mItemInfoCache[aItem.id];
|
||||
cal.LOG("CalDAV: Item deleted successfully from calendar " + thisCalendar.name);
|
||||
let decodedPath = self.ensureDecodedPath(eventUri.path);
|
||||
delete self.mHrefIndex[decodedPath];
|
||||
delete self.mItemInfoCache[aItem.id];
|
||||
cal.LOG("CalDAV: Item deleted successfully from calendar " + self.name);
|
||||
|
||||
if (!thisCalendar.isCached) {
|
||||
if (!self.isCached) {
|
||||
// If the calendar is not cached, we need to remove
|
||||
// the item from our memory calendar now. The
|
||||
// listeners will be notified there.
|
||||
thisCalendar.mOfflineStorage.deleteItem(aItem, aListener);
|
||||
self.mOfflineStorage.deleteItem(aItem, aListener);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (responseStatus == 412 || responseStatus == 409) {
|
||||
// item has either been modified or deleted by someone else check to see which
|
||||
cal.LOG("CalDAV: Item has been modified on server, checking if it has been deleted");
|
||||
thisCalendar.sendHttpRequest(eventUri, null, null, null, (channel) => {
|
||||
self.sendHttpRequest(eventUri, null, null, null, (channel) => {
|
||||
channel.requestMethod = "HEAD";
|
||||
return delListener2;
|
||||
}, () => {
|
||||
|
@ -952,7 +952,7 @@ calDavCalendar.prototype = {
|
|||
listenerDetail = "Server Replied with " + responseStatus;
|
||||
} else if (responseStatus) {
|
||||
cal.ERROR("CalDAV: Unexpected status deleting item from " +
|
||||
thisCalendar.name + ": " + responseStatus + "\n" +
|
||||
self.name + ": " + responseStatus + "\n" +
|
||||
"uri: " + eventUri.spec);
|
||||
|
||||
listenerStatus = Components.results.NS_ERROR_FAILURE;
|
||||
|
@ -960,8 +960,8 @@ calDavCalendar.prototype = {
|
|||
}
|
||||
|
||||
// Still need to visually notify for uncached calendars.
|
||||
if (!thisCalendar.isCached && !Components.isSuccessCode(listenerStatus)) {
|
||||
thisCalendar.reportDavError(calIErrors.DAV_REMOVE_ERROR, listenerStatus, listenerDetail);
|
||||
if (!self.isCached && !Components.isSuccessCode(listenerStatus)) {
|
||||
self.reportDavError(calIErrors.DAV_REMOVE_ERROR, listenerStatus, listenerDetail);
|
||||
}
|
||||
|
||||
// Finally, notify listener.
|
||||
|
@ -978,7 +978,7 @@ calDavCalendar.prototype = {
|
|||
try {
|
||||
responseStatus = request.responseStatus;
|
||||
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
if (self.verboseLogging()) {
|
||||
let str = cal.convertByteArray(aResult, aResultLength);
|
||||
cal.LOG("CalDAV: recv: " + (str || ""));
|
||||
}
|
||||
|
@ -998,7 +998,7 @@ calDavCalendar.prototype = {
|
|||
// The item still exists. We need to ask the user if he
|
||||
// really wants to delete the item. Remember, we only
|
||||
// made this request since the actual delete gave 409/412
|
||||
thisCalendar.promptOverwrite(CALDAV_DELETE_ITEM, aItem, aListener, null);
|
||||
self.promptOverwrite(CALDAV_DELETE_ITEM, aItem, aListener, null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1330,16 +1330,16 @@ calDavCalendar.prototype = {
|
|||
};
|
||||
|
||||
if (!this.mACLEntry) {
|
||||
let thisCalendar = this;
|
||||
let self = this;
|
||||
let opListener = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
|
||||
onGetResult: function(calendar, status, itemType, detail, count, items) {
|
||||
ASSERT(false, "unexpected!");
|
||||
},
|
||||
onOperationComplete: function(opCalendar, opStatus, opType, opId, opDetail) {
|
||||
thisCalendar.mACLEntry = opDetail;
|
||||
thisCalendar.fillACLProperties();
|
||||
thisCalendar.safeRefresh(aChangeLogListener);
|
||||
self.mACLEntry = opDetail;
|
||||
self.fillACLProperties();
|
||||
self.safeRefresh(aChangeLogListener);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1377,7 +1377,7 @@ calDavCalendar.prototype = {
|
|||
this.getUpdatedItems(this.calendarUri, aChangeLogListener);
|
||||
return;
|
||||
}
|
||||
let thisCalendar = this;
|
||||
let self = this;
|
||||
let queryXml =
|
||||
xmlHeader +
|
||||
'<D:propfind xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">' +
|
||||
|
@ -1396,31 +1396,31 @@ calDavCalendar.prototype = {
|
|||
let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
try {
|
||||
cal.LOG("CalDAV: Status " + request.responseStatus +
|
||||
" checking ctag for calendar " + thisCalendar.name);
|
||||
" checking ctag for calendar " + self.name);
|
||||
} catch (ex) {
|
||||
cal.LOG("CalDAV: Error without status on checking ctag for calendar " +
|
||||
thisCalendar.name);
|
||||
self.name);
|
||||
notifyListener(Components.results.NS_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.responseStatus == 404) {
|
||||
cal.LOG("CalDAV: Disabling calendar " + thisCalendar.name +
|
||||
cal.LOG("CalDAV: Disabling calendar " + self.name +
|
||||
" due to 404");
|
||||
notifyListener(Components.results.NS_ERROR_FAILURE);
|
||||
return;
|
||||
} else if (request.responseStatus == 207 && thisCalendar.mDisabled) {
|
||||
} else if (request.responseStatus == 207 && self.mDisabled) {
|
||||
// Looks like the calendar is there again, check its resource
|
||||
// type first.
|
||||
thisCalendar.setupAuthentication(aChangeLogListener);
|
||||
self.setupAuthentication(aChangeLogListener);
|
||||
return;
|
||||
}
|
||||
|
||||
let str = cal.convertByteArray(aResult, aResultLength);
|
||||
if (!str) {
|
||||
cal.LOG("CalDAV: Failed to get ctag from server for calendar " +
|
||||
thisCalendar.name);
|
||||
} else if (thisCalendar.verboseLogging()) {
|
||||
self.name);
|
||||
} else if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: recv: " + str);
|
||||
}
|
||||
|
||||
|
@ -1429,33 +1429,32 @@ calDavCalendar.prototype = {
|
|||
multistatus = cal.xml.parseString(str);
|
||||
} catch (ex) {
|
||||
cal.LOG("CalDAV: Failed to get ctag from server for calendar " +
|
||||
thisCalendar.name);
|
||||
self.name);
|
||||
notifyListener(Components.results.NS_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
let ctag = caldavXPathFirst(multistatus, "/D:multistatus/D:response/D:propstat/D:prop/CS:getctag/text()");
|
||||
if (!ctag || ctag != thisCalendar.mCtag) {
|
||||
if (!ctag || ctag != self.mCtag) {
|
||||
// ctag mismatch, need to fetch calendar-data
|
||||
thisCalendar.mProposedCtag = ctag;
|
||||
thisCalendar.getUpdatedItems(thisCalendar.calendarUri,
|
||||
aChangeLogListener);
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
self.mProposedCtag = ctag;
|
||||
self.getUpdatedItems(self.calendarUri, aChangeLogListener);
|
||||
if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: ctag mismatch on refresh, fetching data for " +
|
||||
"calendar " + thisCalendar.name);
|
||||
"calendar " + self.name);
|
||||
}
|
||||
} else {
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: ctag matches, no need to fetch data for " +
|
||||
"calendar " + thisCalendar.name);
|
||||
"calendar " + self.name);
|
||||
}
|
||||
|
||||
// Notify the listener, but don't return just yet...
|
||||
notifyListener(Components.results.NS_OK);
|
||||
|
||||
// ...we may still need to poll the inbox
|
||||
if (thisCalendar.firstInRealm()) {
|
||||
thisCalendar.pollInbox();
|
||||
if (self.firstInRealm()) {
|
||||
self.pollInbox();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1681,7 +1680,7 @@ calDavCalendar.prototype = {
|
|||
this.ensureTargetCalendar();
|
||||
|
||||
let resourceType = kDavResourceTypeNone;
|
||||
let thisCalendar = this;
|
||||
let self = this;
|
||||
|
||||
let queryXml =
|
||||
xmlHeader +
|
||||
|
@ -1706,26 +1705,26 @@ calDavCalendar.prototype = {
|
|||
let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
try {
|
||||
cal.LOG("CalDAV: Status " + request.responseStatus +
|
||||
" on initial PROPFIND for calendar " + thisCalendar.name);
|
||||
" on initial PROPFIND for calendar " + self.name);
|
||||
} catch (ex) {
|
||||
cal.LOG("CalDAV: Error without status on initial PROPFIND for calendar " +
|
||||
thisCalendar.name);
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.interfaces.calIErrors.DAV_NOT_DAV);
|
||||
self.name);
|
||||
self.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.interfaces.calIErrors.DAV_NOT_DAV);
|
||||
return;
|
||||
}
|
||||
|
||||
let isText = true;
|
||||
|
||||
if ((isText || request.URI.spec != request.originalURI.spec) &&
|
||||
thisCalendar.mLastRedirectStatus == 301) {
|
||||
self.mLastRedirectStatus == 301) {
|
||||
// The initial PROPFIND essentially goes against the calendar
|
||||
// collection url. If a 301 Moved Permanently redirect occurred
|
||||
// here, we want to modify the url we use in the future.
|
||||
let nIPS = Components.interfaces.nsIPromptService;
|
||||
|
||||
let promptTitle = cal.calGetString("calendar", "caldavRedirectTitle", [thisCalendar.name]);
|
||||
let promptText = cal.calGetString("calendar", "caldavRedirectText", [thisCalendar.name]) +
|
||||
let promptTitle = cal.calGetString("calendar", "caldavRedirectTitle", [self.name]);
|
||||
let promptText = cal.calGetString("calendar", "caldavRedirectText", [self.name]) +
|
||||
"\n\n" + request.URI.spec;
|
||||
let button1Title = cal.calGetString("calendar", "caldavRedirectDisableCalendar");
|
||||
let flags = (nIPS.BUTTON_TITLE_YES * nIPS.BUTTON_POS_0) +
|
||||
|
@ -1739,12 +1738,12 @@ calDavCalendar.prototype = {
|
|||
if (res == 0) { // YES
|
||||
let newUri = request.URI;
|
||||
cal.LOG("CalDAV: Migrating url due to redirect: " +
|
||||
thisCalendar.mUri.spec + " -> " + newUri.spec);
|
||||
thisCalendar.mUri = newUri;
|
||||
thisCalendar.setProperty("uri", newUri.spec);
|
||||
self.mUri.spec + " -> " + newUri.spec);
|
||||
self.mUri = newUri;
|
||||
self.setProperty("uri", newUri.spec);
|
||||
} else if (res == 1) { // DISABLE CALENDAR
|
||||
thisCalendar.setProperty("disabled", "true");
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener, Components.results.NS_ERROR_ABORT);
|
||||
self.setProperty("disabled", "true");
|
||||
self.completeCheckServerInfo(aChangeLogListener, Components.results.NS_ERROR_ABORT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1755,9 +1754,9 @@ calDavCalendar.prototype = {
|
|||
// something like method not allowed. This is a failure worth
|
||||
// disabling the calendar.
|
||||
if (responseStatusCategory == 4) {
|
||||
thisCalendar.setProperty("disabled", "true");
|
||||
thisCalendar.setProperty("auto-enabled", "true");
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener, Components.results.NS_ERROR_ABORT);
|
||||
self.setProperty("disabled", "true");
|
||||
self.setProperty("auto-enabled", "true");
|
||||
self.completeCheckServerInfo(aChangeLogListener, Components.results.NS_ERROR_ABORT);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1765,42 +1764,42 @@ calDavCalendar.prototype = {
|
|||
// i.e a backend server being disabled.
|
||||
if (responseStatusCategory == 5) {
|
||||
cal.LOG("CalDAV: Server not available " + request.responseStatus +
|
||||
", abort sync for calendar " + thisCalendar.name);
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener, Components.results.NS_ERROR_ABORT);
|
||||
", abort sync for calendar " + self.name);
|
||||
self.completeCheckServerInfo(aChangeLogListener, Components.results.NS_ERROR_ABORT);
|
||||
return;
|
||||
}
|
||||
|
||||
let wwwauth;
|
||||
try {
|
||||
wwwauth = request.getRequestHeader("Authorization");
|
||||
thisCalendar.mAuthScheme = wwwauth.split(" ")[0];
|
||||
self.mAuthScheme = wwwauth.split(" ")[0];
|
||||
} catch (ex) {
|
||||
// no auth header could mean a public calendar
|
||||
thisCalendar.mAuthScheme = "none";
|
||||
self.mAuthScheme = "none";
|
||||
}
|
||||
|
||||
if (thisCalendar.mUriParams) {
|
||||
thisCalendar.mAuthScheme = "Ticket";
|
||||
if (self.mUriParams) {
|
||||
self.mAuthScheme = "Ticket";
|
||||
}
|
||||
cal.LOG("CalDAV: Authentication scheme for " + thisCalendar.name +
|
||||
" is " + thisCalendar.mAuthScheme);
|
||||
cal.LOG("CalDAV: Authentication scheme for " + self.name +
|
||||
" is " + self.mAuthScheme);
|
||||
// we only really need the authrealm for Digest auth
|
||||
// since only Digest is going to time out on us
|
||||
if (thisCalendar.mAuthScheme == "Digest") {
|
||||
if (self.mAuthScheme == "Digest") {
|
||||
let realmChop = wwwauth.split("realm=\"")[1];
|
||||
thisCalendar.mAuthRealm = realmChop.split("\", ")[0];
|
||||
cal.LOG("CalDAV: realm " + thisCalendar.mAuthRealm);
|
||||
self.mAuthRealm = realmChop.split("\", ")[0];
|
||||
cal.LOG("CalDAV: realm " + self.mAuthRealm);
|
||||
}
|
||||
|
||||
let str = cal.convertByteArray(aResult, aResultLength);
|
||||
if (!str || request.responseStatus == 404) {
|
||||
// No response, or the calendar no longer exists.
|
||||
cal.LOG("CalDAV: Failed to determine resource type for" +
|
||||
thisCalendar.name);
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.interfaces.calIErrors.DAV_NOT_DAV);
|
||||
self.name);
|
||||
self.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.interfaces.calIErrors.DAV_NOT_DAV);
|
||||
return;
|
||||
} else if (thisCalendar.verboseLogging()) {
|
||||
} else if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: recv: " + str);
|
||||
}
|
||||
|
||||
|
@ -1809,9 +1808,9 @@ calDavCalendar.prototype = {
|
|||
multistatus = cal.xml.parseString(str);
|
||||
} catch (ex) {
|
||||
cal.LOG("CalDAV: Failed to determine resource type for" +
|
||||
thisCalendar.name + ": " + ex);
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.interfaces.calIErrors.DAV_NOT_DAV);
|
||||
self.name + ": " + ex);
|
||||
self.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.interfaces.calIErrors.DAV_NOT_DAV);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1820,22 +1819,22 @@ calDavCalendar.prototype = {
|
|||
if (caldavXPath(multistatus, "/D:multistatus/D:response/D:propstat/D:prop" +
|
||||
"/D:supported-report-set/D:supported-report/D:report/D:sync-collection")) {
|
||||
cal.LOG("CalDAV: Collection has webdav sync support");
|
||||
thisCalendar.mHasWebdavSyncSupport = true;
|
||||
self.mHasWebdavSyncSupport = true;
|
||||
}
|
||||
|
||||
// check for server-side ctag support only if webdav sync is not available
|
||||
let ctag = caldavXPathFirst(multistatus, "/D:multistatus/D:response/D:propstat/D:prop/CS:getctag/text()");
|
||||
if (!thisCalendar.mHasWebdavSyncSupport && ctag) {
|
||||
if (!self.mHasWebdavSyncSupport && ctag) {
|
||||
// We compare the stored ctag with the one we just got, if
|
||||
// they don't match, we update the items in safeRefresh.
|
||||
if (ctag == thisCalendar.mCtag) {
|
||||
thisCalendar.mFirstRefreshDone = true;
|
||||
if (ctag == self.mCtag) {
|
||||
self.mFirstRefreshDone = true;
|
||||
}
|
||||
|
||||
thisCalendar.mProposedCtag = ctag;
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
self.mProposedCtag = ctag;
|
||||
if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: initial ctag " + ctag + " for calendar " +
|
||||
thisCalendar.name);
|
||||
self.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1845,24 +1844,24 @@ calDavCalendar.prototype = {
|
|||
let supportedComponents = caldavXPath(multistatus,
|
||||
"/D:multistatus/D:response/D:propstat/D:prop/C:supported-calendar-component-set/C:comp/@*[local-name()='name']");
|
||||
if (supportedComponents && supportedComponents.length) {
|
||||
thisCalendar.mSupportedItemTypes = [];
|
||||
self.mSupportedItemTypes = [];
|
||||
for (compName of supportedComponents) {
|
||||
if (thisCalendar.mGenerallySupportedItemTypes.includes(compName)) {
|
||||
thisCalendar.mSupportedItemTypes.push(compName);
|
||||
if (self.mGenerallySupportedItemTypes.includes(compName)) {
|
||||
self.mSupportedItemTypes.push(compName);
|
||||
}
|
||||
}
|
||||
cal.LOG("Adding supported items: " + thisCalendar.mSupportedItemTypes.join(",") + " for calendar: " + thisCalendar.name);
|
||||
cal.LOG("Adding supported items: " + self.mSupportedItemTypes.join(",") + " for calendar: " + self.name);
|
||||
}
|
||||
|
||||
// check if owner is specified; might save some work
|
||||
let owner = caldavXPathFirst(multistatus, "/D:multistatus/D:response/D:propstat/D:prop/D:owner/D:href/text()");
|
||||
let cuprincipal = caldavXPathFirst(multistatus, "/D:multistatus/D:response/D:propstat/D:prop/D:current-user-principal/D:href/text()");
|
||||
if (cuprincipal) {
|
||||
thisCalendar.mPrincipalUrl = cuprincipal;
|
||||
cal.LOG("CalDAV: Found principal url from DAV:current-user-principal " + thisCalendar.mPrincipalUrl);
|
||||
self.mPrincipalUrl = cuprincipal;
|
||||
cal.LOG("CalDAV: Found principal url from DAV:current-user-principal " + self.mPrincipalUrl);
|
||||
} else if (owner) {
|
||||
thisCalendar.mPrincipalUrl = owner;
|
||||
cal.LOG("CalDAV: Found principal url from DAV:owner " + thisCalendar.mPrincipalUrl);
|
||||
self.mPrincipalUrl = owner;
|
||||
cal.LOG("CalDAV: Found principal url from DAV:owner " + self.mPrincipalUrl);
|
||||
}
|
||||
|
||||
let resourceTypeXml = caldavXPath(multistatus, "/D:multistatus/D:response/D:propstat/D:prop/D:resourcetype");
|
||||
|
@ -1875,33 +1874,33 @@ calDavCalendar.prototype = {
|
|||
}
|
||||
|
||||
if (resourceType == kDavResourceTypeNone) {
|
||||
cal.LOG("CalDAV: No resource type received, " + thisCalendar.name + " doesn't seem to point to a DAV resource");
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.interfaces.calIErrors.DAV_NOT_DAV);
|
||||
cal.LOG("CalDAV: No resource type received, " + self.name + " doesn't seem to point to a DAV resource");
|
||||
self.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.interfaces.calIErrors.DAV_NOT_DAV);
|
||||
return;
|
||||
}
|
||||
|
||||
if (resourceType == kDavResourceTypeCollection) {
|
||||
cal.LOG("CalDAV: " + thisCalendar.name + " points to a DAV resource, but not a CalDAV calendar");
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.interfaces.calIErrors.DAV_DAV_NOT_CALDAV);
|
||||
cal.LOG("CalDAV: " + self.name + " points to a DAV resource, but not a CalDAV calendar");
|
||||
self.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.interfaces.calIErrors.DAV_DAV_NOT_CALDAV);
|
||||
return;
|
||||
}
|
||||
|
||||
if (resourceType == kDavResourceTypeCalendar) {
|
||||
// If this calendar was previously offline we want to recover
|
||||
if (thisCalendar.mDisabled) {
|
||||
thisCalendar.mDisabled = false;
|
||||
thisCalendar.mReadOnly = false;
|
||||
if (self.mDisabled) {
|
||||
self.mDisabled = false;
|
||||
self.mReadOnly = false;
|
||||
}
|
||||
thisCalendar.setCalHomeSet(true);
|
||||
thisCalendar.checkServerCaps(aChangeLogListener);
|
||||
self.setCalHomeSet(true);
|
||||
self.checkServerCaps(aChangeLogListener);
|
||||
return;
|
||||
}
|
||||
|
||||
// If we get here something must have gone wrong. Abort with a
|
||||
// general error to avoid an endless loop.
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener, Components.results.NS_ERROR_FAILURE);
|
||||
self.completeCheckServerInfo(aChangeLogListener, Components.results.NS_ERROR_FAILURE);
|
||||
};
|
||||
|
||||
this.sendHttpRequest(this.makeUri(), queryXml, MIME_TEXT_XML, null, (channel) => {
|
||||
|
@ -1926,7 +1925,7 @@ calDavCalendar.prototype = {
|
|||
*/
|
||||
checkServerCaps: function caldav_checkServerCaps(aChangeLogListener, calHomeSetUrlRetry) {
|
||||
let homeSet = this.makeUri(null, this.mCalHomeSet);
|
||||
let thisCalendar = this;
|
||||
let self = this;
|
||||
|
||||
if (this.verboseLogging()) {
|
||||
cal.LOG("CalDAV: send: OPTIONS " + homeSet.spec);
|
||||
|
@ -1941,13 +1940,13 @@ calDavCalendar.prototype = {
|
|||
if (!calHomeSetUrlRetry && request.responseStatus == 404) {
|
||||
// try again with calendar URL, see https://bugzilla.mozilla.org/show_bug.cgi?id=588799
|
||||
cal.LOG("CalDAV: Calendar homeset was not found at parent url of calendar URL" +
|
||||
" while querying options " + thisCalendar.name + ", will try calendar URL itself now");
|
||||
thisCalendar.setCalHomeSet(false);
|
||||
thisCalendar.checkServerCaps(aChangeLogListener, true);
|
||||
" while querying options " + self.name + ", will try calendar URL itself now");
|
||||
self.setCalHomeSet(false);
|
||||
self.checkServerCaps(aChangeLogListener, true);
|
||||
} else {
|
||||
cal.LOG("CalDAV: Unexpected status " + request.responseStatus +
|
||||
" while querying options " + thisCalendar.name);
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener, Components.results.NS_ERROR_FAILURE);
|
||||
" while querying options " + self.name);
|
||||
self.completeCheckServerInfo(aChangeLogListener, Components.results.NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
// No further processing needed, we have called subsequent (async) functions above.
|
||||
|
@ -1957,52 +1956,52 @@ calDavCalendar.prototype = {
|
|||
let dav = null;
|
||||
try {
|
||||
dav = request.getResponseHeader("DAV");
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: DAV header: " + dav);
|
||||
}
|
||||
} catch (ex) {
|
||||
cal.LOG("CalDAV: Error getting DAV header for " + thisCalendar.name +
|
||||
cal.LOG("CalDAV: Error getting DAV header for " + self.name +
|
||||
", status " + request.responseStatus +
|
||||
", data: " + cal.convertByteArray(aResult, aResultLength));
|
||||
}
|
||||
// Google does not yet support OPTIONS but does support scheduling
|
||||
// so we'll spoof the DAV header until Google gets fixed
|
||||
if (thisCalendar.calendarUri.host == "www.google.com") {
|
||||
if (self.calendarUri.host == "www.google.com") {
|
||||
dav = "calendar-schedule";
|
||||
// Google also reports an inbox URL distinct from the calendar
|
||||
// URL but a) doesn't use it and b) 405s on etag queries to it
|
||||
thisCalendar.mShouldPollInbox = false;
|
||||
self.mShouldPollInbox = false;
|
||||
}
|
||||
if (dav && dav.includes("calendar-auto-schedule")) {
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
cal.LOG("CalDAV: Calendar " + thisCalendar.name +
|
||||
if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: Calendar " + self.name +
|
||||
" supports calendar-auto-schedule");
|
||||
}
|
||||
thisCalendar.hasAutoScheduling = true;
|
||||
self.hasAutoScheduling = true;
|
||||
// leave outbound inbox/outbox scheduling off
|
||||
} else if (dav && dav.includes("calendar-schedule")) {
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
cal.LOG("CalDAV: Calendar " + thisCalendar.name +
|
||||
if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: Calendar " + self.name +
|
||||
" generally supports calendar-schedule");
|
||||
}
|
||||
thisCalendar.hasScheduling = true;
|
||||
self.hasScheduling = true;
|
||||
}
|
||||
|
||||
if (thisCalendar.hasAutoScheduling || (dav && dav.includes("calendar-schedule"))) {
|
||||
if (self.hasAutoScheduling || (dav && dav.includes("calendar-schedule"))) {
|
||||
// XXX - we really shouldn't register with the fb service
|
||||
// if another calendar with the same principal-URL has already
|
||||
// done so. We also shouldn't register with the fb service if we
|
||||
// don't have an outbox.
|
||||
if (!thisCalendar.hasFreeBusy) {
|
||||
if (!self.hasFreeBusy) {
|
||||
// This may have already been set by fetchCachedMetaData,
|
||||
// we only want to add the freebusy provider once.
|
||||
thisCalendar.hasFreeBusy = true;
|
||||
getFreeBusyService().addProvider(thisCalendar);
|
||||
self.hasFreeBusy = true;
|
||||
getFreeBusyService().addProvider(self);
|
||||
}
|
||||
thisCalendar.findPrincipalNS(aChangeLogListener);
|
||||
self.findPrincipalNS(aChangeLogListener);
|
||||
} else {
|
||||
cal.LOG("CalDAV: Server does not support CalDAV scheduling.");
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener);
|
||||
self.completeCheckServerInfo(aChangeLogListener);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2035,7 +2034,7 @@ calDavCalendar.prototype = {
|
|||
}
|
||||
|
||||
let homeSet = this.makeUri(null, this.mCalHomeSet);
|
||||
let thisCalendar = this;
|
||||
let self = this;
|
||||
|
||||
let queryXml =
|
||||
xmlHeader +
|
||||
|
@ -2055,19 +2054,19 @@ calDavCalendar.prototype = {
|
|||
let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
if (request.responseStatus != 207) {
|
||||
cal.LOG("CalDAV: Unexpected status " + request.responseStatus +
|
||||
" while querying principal namespace for " + thisCalendar.name);
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.results.NS_ERROR_FAILURE);
|
||||
" while querying principal namespace for " + self.name);
|
||||
self.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.results.NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
let str = cal.convertByteArray(aResult, aResultLength);
|
||||
if (!str) {
|
||||
cal.LOG("CalDAV: Failed to propstat principal namespace for " + thisCalendar.name);
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.results.NS_ERROR_FAILURE);
|
||||
cal.LOG("CalDAV: Failed to propstat principal namespace for " + self.name);
|
||||
self.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.results.NS_ERROR_FAILURE);
|
||||
return;
|
||||
} else if (thisCalendar.verboseLogging()) {
|
||||
} else if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: recv: " + str);
|
||||
}
|
||||
|
||||
|
@ -2075,19 +2074,19 @@ calDavCalendar.prototype = {
|
|||
try {
|
||||
multistatus = cal.xml.parseString(str);
|
||||
} catch (ex) {
|
||||
cal.LOG("CalDAV: Failed to propstat principal namespace for " + thisCalendar.name);
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.results.NS_ERROR_FAILURE);
|
||||
cal.LOG("CalDAV: Failed to propstat principal namespace for " + self.name);
|
||||
self.completeCheckServerInfo(aChangeLogListener,
|
||||
Components.results.NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
let pcs = caldavXPath(multistatus, "/D:multistatus/D:response/D:propstat/D:prop/D:principal-collection-set/D:href/text()");
|
||||
let nsList = [];
|
||||
if (pcs) {
|
||||
nsList = pcs.map(x => thisCalendar.ensureDecodedPath(x));
|
||||
nsList = pcs.map(x => self.ensureDecodedPath(x));
|
||||
}
|
||||
|
||||
thisCalendar.checkPrincipalsNameSpace(nsList, aChangeLogListener);
|
||||
self.checkPrincipalsNameSpace(nsList, aChangeLogListener);
|
||||
};
|
||||
|
||||
this.sendHttpRequest(homeSet, queryXml, MIME_TEXT_XML, null, (channel) => {
|
||||
|
@ -2113,7 +2112,7 @@ calDavCalendar.prototype = {
|
|||
* @param aNameSpaceList List of available namespaces
|
||||
*/
|
||||
checkPrincipalsNameSpace: function caldav_checkPrincipalsNameSpace(aNameSpaceList, aChangeLogListener) {
|
||||
let thisCalendar = this;
|
||||
let self = this;
|
||||
let doesntSupportScheduling = () => {
|
||||
this.hasScheduling = false;
|
||||
this.mInboxUrl = null;
|
||||
|
@ -2182,10 +2181,10 @@ calDavCalendar.prototype = {
|
|||
let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
let str = cal.convertByteArray(aResult, aResultLength);
|
||||
if (!str) {
|
||||
cal.LOG("CalDAV: Failed to report principals namespace for " + thisCalendar.name);
|
||||
cal.LOG("CalDAV: Failed to report principals namespace for " + self.name);
|
||||
doesntSupportScheduling();
|
||||
return;
|
||||
} else if (thisCalendar.verboseLogging()) {
|
||||
} else if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: recv: " + str);
|
||||
}
|
||||
|
||||
|
@ -2208,12 +2207,12 @@ calDavCalendar.prototype = {
|
|||
let homeSets = caldavXPath(multistatus, "/D:multistatus/D:response/D:propstat/D:prop/C:calendar-home-set/D:href/text()");
|
||||
function homeSetMatches(homeSet) {
|
||||
let normalized = homeSet.replace(/([^\/])$/, "$1/");
|
||||
let chs = thisCalendar.mCalHomeSet;
|
||||
let chs = self.mCalHomeSet;
|
||||
return normalized == chs.path || normalized == chs.spec;
|
||||
}
|
||||
function createBoxUrl(path) {
|
||||
let url = thisCalendar.mUri.clone();
|
||||
url.path = thisCalendar.ensureDecodedPath(path);
|
||||
let url = self.mUri.clone();
|
||||
url.path = self.ensureDecodedPath(path);
|
||||
// Make sure the uri has a / at the end, as we do with the calendarUri.
|
||||
if (url.path.charAt(url.path.length - 1) != "/") {
|
||||
url.path += "/";
|
||||
|
@ -2229,7 +2228,7 @@ calDavCalendar.prototype = {
|
|||
if (cuaSets) {
|
||||
for (let addr of cuaSets) {
|
||||
if (addr.match(/^mailto:/i)) {
|
||||
thisCalendar.mCalendarUserAddress = addr;
|
||||
self.mCalendarUserAddress = addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2240,12 +2239,12 @@ calDavCalendar.prototype = {
|
|||
// most likely this is a Kerio server that omits the "href"
|
||||
inboxPath = caldavXPathFirst(multistatus, "/D:multistatus/D:response/D:propstat/D:prop/C:schedule-inbox-URL/text()");
|
||||
}
|
||||
thisCalendar.mInboxUrl = createBoxUrl(inboxPath);
|
||||
self.mInboxUrl = createBoxUrl(inboxPath);
|
||||
|
||||
if (thisCalendar.calendarUri.spec == thisCalendar.mInboxUrl.spec) {
|
||||
if (self.calendarUri.spec == self.mInboxUrl.spec) {
|
||||
// If the inbox matches the calendar uri (i.e SOGo), then we
|
||||
// don't need to poll the inbox.
|
||||
thisCalendar.mShouldPollInbox = false;
|
||||
self.mShouldPollInbox = false;
|
||||
}
|
||||
|
||||
let outboxPath = caldavXPathFirst(multistatus, "/D:multistatus/D:response/D:propstat/D:prop/C:schedule-outbox-URL/D:href/text()");
|
||||
|
@ -2253,25 +2252,25 @@ calDavCalendar.prototype = {
|
|||
// most likely this is a Kerio server that omits the "href"
|
||||
outboxPath = caldavXPathFirst(multistatus, "/D:multistatus/D:response/D:propstat/D:prop/C:schedule-outbox-URL/text()");
|
||||
}
|
||||
thisCalendar.mOutboxUrl = createBoxUrl(outboxPath);
|
||||
self.mOutboxUrl = createBoxUrl(outboxPath);
|
||||
}
|
||||
|
||||
if (!thisCalendar.calendarUserAddress ||
|
||||
!thisCalendar.mInboxUrl ||
|
||||
!thisCalendar.mOutboxUrl) {
|
||||
if (!self.calendarUserAddress ||
|
||||
!self.mInboxUrl ||
|
||||
!self.mOutboxUrl) {
|
||||
if (aNameSpaceList.length) {
|
||||
// Check the next namespace to find the info we need.
|
||||
thisCalendar.checkPrincipalsNameSpace(aNameSpaceList, aChangeLogListener);
|
||||
self.checkPrincipalsNameSpace(aNameSpaceList, aChangeLogListener);
|
||||
} else {
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: principal namespace list empty, calendar " +
|
||||
thisCalendar.name + " doesn't support scheduling");
|
||||
self.name + " doesn't support scheduling");
|
||||
}
|
||||
doesntSupportScheduling();
|
||||
}
|
||||
} else {
|
||||
// We have everything, complete.
|
||||
thisCalendar.completeCheckServerInfo(aChangeLogListener);
|
||||
self.completeCheckServerInfo(aChangeLogListener);
|
||||
}
|
||||
};
|
||||
this.sendHttpRequest(requestUri, queryXml, MIME_TEXT_XML, null, (channel) => {
|
||||
|
@ -2417,7 +2416,7 @@ calDavCalendar.prototype = {
|
|||
}
|
||||
let mailto_aCalId = aCalIdParts.join(":");
|
||||
|
||||
let thisCalendar = this;
|
||||
let self = this;
|
||||
|
||||
let organizer = this.calendarUserAddress;
|
||||
|
||||
|
@ -2455,8 +2454,8 @@ calDavCalendar.prototype = {
|
|||
let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
let str = cal.convertByteArray(aResult, aResultLength);
|
||||
if (!str) {
|
||||
cal.LOG("CalDAV: Failed to parse freebusy response from " + thisCalendar.name);
|
||||
} else if (thisCalendar.verboseLogging()) {
|
||||
cal.LOG("CalDAV: Failed to parse freebusy response from " + self.name);
|
||||
} else if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: recv: " + str);
|
||||
}
|
||||
|
||||
|
@ -2480,13 +2479,13 @@ calDavCalendar.prototype = {
|
|||
let status = caldavXPathFirst(fbResult, "/C:schedule-response/C:response/C:request-status/text()");
|
||||
if (!status || status.substr(0, 1) != "2") {
|
||||
cal.LOG("CalDAV: Got status " + status + " in response to " +
|
||||
"freebusy query for " + thisCalendar.name);
|
||||
"freebusy query for " + self.name);
|
||||
aListener.onResult(null, null);
|
||||
return;
|
||||
}
|
||||
if (status.substr(0, 3) != "2.0") {
|
||||
cal.LOG("CalDAV: Got status " + status + " in response to " +
|
||||
"freebusy query for" + thisCalendar.name);
|
||||
"freebusy query for" + self.name);
|
||||
}
|
||||
|
||||
let caldata = caldavXPathFirst(fbResult, "/C:schedule-response/C:response/C:calendar-data/text()");
|
||||
|
@ -2543,7 +2542,7 @@ calDavCalendar.prototype = {
|
|||
aListener.onResult(null, periodsToReturn);
|
||||
} else {
|
||||
cal.LOG("CalDAV: Received status " + request.responseStatus +
|
||||
" from freebusy query for " + thisCalendar.name);
|
||||
" from freebusy query for " + self.name);
|
||||
aListener.onResult(null, null);
|
||||
}
|
||||
};
|
||||
|
@ -2643,7 +2642,7 @@ calDavCalendar.prototype = {
|
|||
processItipReply: function caldav_processItipReply(aItem, aPath) {
|
||||
// modify partstat for in-calendar item
|
||||
// delete item from inbox
|
||||
let thisCalendar = this;
|
||||
let self = this;
|
||||
|
||||
let getItemListener = {};
|
||||
getItemListener.QueryInterface = XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]);
|
||||
|
@ -2674,8 +2673,8 @@ calDavCalendar.prototype = {
|
|||
newItem.addAttendee(att);
|
||||
}
|
||||
}
|
||||
thisCalendar.doModifyItem(newItem, itemToUpdate.parentItem /* related to bug 396182 */,
|
||||
modListener, true);
|
||||
self.doModifyItem(newItem, itemToUpdate.parentItem /* related to bug 396182 */,
|
||||
modListener, true);
|
||||
};
|
||||
|
||||
let modListener = {};
|
||||
|
@ -2686,13 +2685,13 @@ calDavCalendar.prototype = {
|
|||
aItemId,
|
||||
aDetail) {
|
||||
cal.LOG("CalDAV: status " + aStatus + " while processing iTIP REPLY " +
|
||||
" for " + thisCalendar.name);
|
||||
" for " + self.name);
|
||||
// don't delete the REPLY item from inbox unless modifying the master
|
||||
// item was successful
|
||||
if (aStatus == 0) { // aStatus undocumented; 0 seems to indicate no error
|
||||
let delUri = thisCalendar.calendarUri.clone();
|
||||
delUri.path = thisCalendar.ensureEncodedPath(aPath);
|
||||
thisCalendar.doDeleteItem(aItem, null, true, true, delUri);
|
||||
let delUri = self.calendarUri.clone();
|
||||
delUri.path = self.ensureEncodedPath(aPath);
|
||||
self.doDeleteItem(aItem, null, true, true, delUri);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2767,7 +2766,7 @@ calDavCalendar.prototype = {
|
|||
methodProp.value = aItipItem.responseMethod;
|
||||
serializer.addProperty(methodProp);
|
||||
|
||||
let thisCalendar = this;
|
||||
let self = this;
|
||||
let streamListener = {
|
||||
onStreamComplete: function caldav_sendItems_oSC(aLoader, aContext, aStatus,
|
||||
aResultLength, aResult) {
|
||||
|
@ -2778,22 +2777,22 @@ calDavCalendar.prototype = {
|
|||
} catch (ex) {
|
||||
status = Components.interfaces.calIErrors.DAV_POST_ERROR;
|
||||
cal.LOG("CalDAV: no response status when sending iTIP for" +
|
||||
thisCalendar.name);
|
||||
self.name);
|
||||
}
|
||||
|
||||
if (status != 200) {
|
||||
cal.LOG("CalDAV: Sending iTIP failed with status " + status +
|
||||
" for " + thisCalendar.name);
|
||||
" for " + self.name);
|
||||
}
|
||||
|
||||
let str = cal.convertByteArray(aResult, aResultLength, "UTF-8", false);
|
||||
if (str) {
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: recv: " + str);
|
||||
}
|
||||
} else {
|
||||
cal.LOG("CalDAV: Failed to parse iTIP response for" +
|
||||
thisCalendar.name);
|
||||
self.name);
|
||||
}
|
||||
|
||||
let responseXML;
|
||||
|
@ -2814,7 +2813,7 @@ calDavCalendar.prototype = {
|
|||
let recip = caldavXPathFirst(response, "C:recipient/D:href/text()");
|
||||
let reqstatus = caldavXPathFirst(response, "C:request-status/text()");
|
||||
if (reqstatus.substr(0, 1) != "2") {
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: Failed scheduling delivery to " + recip);
|
||||
}
|
||||
for (let att of aRecipients) {
|
||||
|
@ -2830,15 +2829,15 @@ calDavCalendar.prototype = {
|
|||
if (remainingAttendees.length) {
|
||||
// try to fall back to email delivery if CalDAV-sched
|
||||
// didn't work
|
||||
let imipTransport = cal.getImipTransport(thisCalendar);
|
||||
let imipTransport = cal.getImipTransport(self);
|
||||
if (imipTransport) {
|
||||
if (thisCalendar.verboseLogging()) {
|
||||
if (self.verboseLogging()) {
|
||||
cal.LOG("CalDAV: sending email to " + remainingAttendees.length + " recipients");
|
||||
}
|
||||
imipTransport.sendItems(remainingAttendees.length, remainingAttendees, aItipItem);
|
||||
} else {
|
||||
cal.LOG("CalDAV: no fallback to iTIP/iMIP transport for " +
|
||||
thisCalendar.name);
|
||||
self.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,30 +265,30 @@ calICSCalendar.prototype = {
|
|||
// That's why we put them in readOnly mode
|
||||
let parser = Components.classes["@mozilla.org/calendar/ics-parser;1"]
|
||||
.createInstance(Components.interfaces.calIIcsParser);
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let listener = { // calIIcsParsingListener
|
||||
onParsingComplete: function ics_onParsingComplete(rc, parser_) {
|
||||
try {
|
||||
for (let item of parser_.getItems({})) {
|
||||
this_.mMemoryCalendar.adoptItem(item, null);
|
||||
self.mMemoryCalendar.adoptItem(item, null);
|
||||
}
|
||||
this_.unmappedComponents = parser_.getComponents({});
|
||||
this_.unmappedProperties = parser_.getProperties({});
|
||||
cal.LOG("[calICSCalendar] Parsing ICS succeeded for " + this_.uri.spec);
|
||||
self.unmappedComponents = parser_.getComponents({});
|
||||
self.unmappedProperties = parser_.getProperties({});
|
||||
cal.LOG("[calICSCalendar] Parsing ICS succeeded for " + self.uri.spec);
|
||||
} catch (exc) {
|
||||
cal.LOG("[calICSCalendar] Parsing ICS failed for \nException: " + exc);
|
||||
this_.mObserver.onError(this_.superCalendar, exc.result, exc.toString());
|
||||
this_.mObserver.onError(this_.superCalendar, calIErrors.READ_FAILED, "");
|
||||
self.mObserver.onError(self.superCalendar, exc.result, exc.toString());
|
||||
self.mObserver.onError(self.superCalendar, calIErrors.READ_FAILED, "");
|
||||
}
|
||||
this_.mObserver.onEndBatch();
|
||||
this_.mObserver.onLoad(this_);
|
||||
self.mObserver.onEndBatch();
|
||||
self.mObserver.onLoad(self);
|
||||
|
||||
// Now that all items have been stuffed into the memory calendar
|
||||
// we should add ourselves as observer. It is important that this
|
||||
// happens *after* the calls to adoptItem in the above loop to prevent
|
||||
// the views from being notified.
|
||||
this_.mMemoryCalendar.addObserver(this_.mObserver);
|
||||
this_.unlock();
|
||||
self.mMemoryCalendar.addObserver(self.mObserver);
|
||||
self.unlock();
|
||||
}
|
||||
};
|
||||
parser.parseString(str, null, listener);
|
||||
|
@ -311,7 +311,7 @@ calICSCalendar.prototype = {
|
|||
|
||||
doWriteICS: function() {
|
||||
cal.LOG("[calICSCalendar] Writing ICS File " + this.uri.spec);
|
||||
let savedthis = this;
|
||||
let self = this;
|
||||
let listener =
|
||||
{
|
||||
serializer: null,
|
||||
|
@ -322,7 +322,7 @@ calICSCalendar.prototype = {
|
|||
// All events are returned. Now set up a channel and a
|
||||
// streamloader to upload. onStopRequest will be called
|
||||
// once the write has finished
|
||||
let channel = Services.io.newChannelFromURI2(savedthis.mUri,
|
||||
let channel = Services.io.newChannelFromURI2(self.mUri,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
|
@ -331,9 +331,9 @@ calICSCalendar.prototype = {
|
|||
|
||||
// Allow the hook to add things to the channel, like a
|
||||
// header that checks etags
|
||||
let notChanged = savedthis.mHooks.onBeforePut(channel);
|
||||
let notChanged = self.mHooks.onBeforePut(channel);
|
||||
if (notChanged) {
|
||||
channel.notificationCallbacks = savedthis;
|
||||
channel.notificationCallbacks = self;
|
||||
let uploadChannel = channel.QueryInterface(
|
||||
Components.interfaces.nsIUploadChannel);
|
||||
|
||||
|
@ -346,26 +346,26 @@ calICSCalendar.prototype = {
|
|||
|
||||
Services.startup.enterLastWindowClosingSurvivalArea();
|
||||
inLastWindowClosingSurvivalArea = true;
|
||||
channel.asyncOpen(savedthis, savedthis);
|
||||
channel.asyncOpen(self, self);
|
||||
} else {
|
||||
if (inLastWindowClosingSurvivalArea) {
|
||||
Services.startup.exitLastWindowClosingSurvivalArea();
|
||||
}
|
||||
savedthis.mObserver.onError(savedthis.superCalendar,
|
||||
calIErrors.MODIFICATION_FAILED,
|
||||
"The calendar has been changed remotely. Please reload and apply your changes again!");
|
||||
savedthis.unlock(calIErrors.MODIFICATION_FAILED);
|
||||
self.mObserver.onError(self.superCalendar,
|
||||
calIErrors.MODIFICATION_FAILED,
|
||||
"The calendar has been changed remotely. Please reload and apply your changes again!");
|
||||
self.unlock(calIErrors.MODIFICATION_FAILED);
|
||||
}
|
||||
} catch (ex) {
|
||||
if (inLastWindowClosingSurvivalArea) {
|
||||
Services.startup.exitLastWindowClosingSurvivalArea();
|
||||
}
|
||||
savedthis.mObserver.onError(savedthis.superCalendar,
|
||||
ex.result, "The calendar could not be saved; there " +
|
||||
"was a failure: 0x" + ex.result.toString(16));
|
||||
savedthis.mObserver.onError(savedthis.superCalendar, calIErrors.MODIFICATION_FAILED, "");
|
||||
savedthis.unlock(calIErrors.MODIFICATION_FAILED);
|
||||
savedthis.forceRefresh();
|
||||
self.mObserver.onError(self.superCalendar,
|
||||
ex.result, "The calendar could not be saved; there " +
|
||||
"was a failure: 0x" + ex.result.toString(16));
|
||||
self.mObserver.onError(self.superCalendar, calIErrors.MODIFICATION_FAILED, "");
|
||||
self.unlock(calIErrors.MODIFICATION_FAILED);
|
||||
self.forceRefresh();
|
||||
}
|
||||
},
|
||||
onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
|
||||
|
@ -788,7 +788,7 @@ calICSCalendar.prototype = {
|
|||
let downloader = Components.classes["@mozilla.org/network/downloader;1"]
|
||||
.createInstance(CI.nsIDownloader);
|
||||
|
||||
let savedthis = this;
|
||||
let self = this;
|
||||
let listener = {
|
||||
onDownloadComplete: function(opdownloader, request, ctxt, status, result) {
|
||||
if (doInitialBackup) {
|
||||
|
@ -798,7 +798,7 @@ calICSCalendar.prototype = {
|
|||
copyToOverwriting(result, backupDir, dailyBackupFileName);
|
||||
}
|
||||
|
||||
aCallback.call(savedthis);
|
||||
aCallback.call(self);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1000,7 +1000,7 @@ httpHooks.prototype = {
|
|||
// Try to do the best we can, by immediatly getting the etag.
|
||||
|
||||
let etagListener = {};
|
||||
let thisHook = this; // need to reference in callback
|
||||
let self = this; // need to reference in callback
|
||||
|
||||
etagListener.onStreamComplete =
|
||||
function ics_etLoSC(aLoader, aContext, aStatus, aResultLength,
|
||||
|
@ -1018,7 +1018,7 @@ httpHooks.prototype = {
|
|||
cal.LOG("[calICSCalendar] Failed to fetch channel etag");
|
||||
}
|
||||
|
||||
thisHook.mEtag = icsXPathFirst(multistatus, "/D:propfind/D:response/D:propstat/D:prop/D:getetag");
|
||||
self.mEtag = icsXPathFirst(multistatus, "/D:propfind/D:response/D:propstat/D:prop/D:getetag");
|
||||
aRespFunc();
|
||||
};
|
||||
let queryXml =
|
||||
|
|
|
@ -176,13 +176,13 @@ calMemoryCalendar.prototype = {
|
|||
throw Components.results.NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
function reportError(errStr, errId) {
|
||||
this_.notifyOperationComplete(aListener,
|
||||
errId ? errId : Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
aNewItem.id,
|
||||
errStr);
|
||||
self.notifyOperationComplete(aListener,
|
||||
errId ? errId : Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
aNewItem.id,
|
||||
errStr);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -352,10 +352,9 @@ calMemoryCalendar.prototype = {
|
|||
// in calIOperationListener aListener );
|
||||
getItems: function(aItemFilter, aCount,
|
||||
aRangeStart, aRangeEnd, aListener) {
|
||||
let this_ = this;
|
||||
cal.postPone(function() {
|
||||
this_.getItems_(aItemFilter, aCount, aRangeStart, aRangeEnd, aListener);
|
||||
});
|
||||
cal.postPone(() => {
|
||||
this.getItems_(aItemFilter, aCount, aRangeStart, aRangeEnd, aListener);
|
||||
});
|
||||
},
|
||||
getItems_: function(aItemFilter, aCount,
|
||||
aRangeStart, aRangeEnd, aListener) {
|
||||
|
|
|
@ -466,7 +466,7 @@ calStorageCalendar.prototype = {
|
|||
// void modifyItem( in calIItemBase aNewItem, in calIItemBase aOldItem, in calIOperationListener aListener );
|
||||
// Actually uses doModifyItem
|
||||
modifyItem: function cSC_modifyItem(aNewItem, aOldItem, aListener) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
|
||||
// HACK Just modifying the item would clear the offline flag, we need to
|
||||
// retrieve the flag and pass it to the real modify function.
|
||||
|
@ -474,7 +474,7 @@ calStorageCalendar.prototype = {
|
|||
onGetResult: function(calendar, status, opType, id, detail) {
|
||||
},
|
||||
onOperationComplete: function(opcalendar, status, opType, id, offlineFlag) {
|
||||
this_.doModifyItem(aNewItem, aOldItem, aListener, offlineFlag);
|
||||
self.doModifyItem(aNewItem, aOldItem, aListener, offlineFlag);
|
||||
}
|
||||
};
|
||||
this.getItemOfflineFlag(aOldItem, offlineJournalFlagListener);
|
||||
|
@ -494,13 +494,13 @@ calStorageCalendar.prototype = {
|
|||
throw Components.results.NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
function reportError(errStr, errId) {
|
||||
this_.notifyOperationComplete(aListener,
|
||||
errId ? errId : Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
aNewItem.id,
|
||||
errStr);
|
||||
self.notifyOperationComplete(aListener,
|
||||
errId ? errId : Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
aNewItem.id,
|
||||
errStr);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -661,9 +661,8 @@ calStorageCalendar.prototype = {
|
|||
// in calIOperationListener aListener );
|
||||
getItems: function cSC_getItems(aItemFilter, aCount,
|
||||
aRangeStart, aRangeEnd, aListener) {
|
||||
let this_ = this;
|
||||
cal.postPone(function() {
|
||||
this_.getItems_(aItemFilter, aCount, aRangeStart, aRangeEnd, aListener);
|
||||
cal.postPone(() => {
|
||||
this.getItems_(aItemFilter, aCount, aRangeStart, aRangeEnd, aListener);
|
||||
});
|
||||
},
|
||||
getItems_: function cSC_getItems_(aItemFilter, aCount,
|
||||
|
@ -951,20 +950,20 @@ calStorageCalendar.prototype = {
|
|||
Components.interfaces.calIOperationListener.GET, null, flag);
|
||||
} else {
|
||||
let aID = aItem.id;
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let listener = {
|
||||
handleResult: function(aResultSet) {
|
||||
let row = aResultSet.getNextRow();
|
||||
flag = row.getResultByName("offline_journal") || null;
|
||||
},
|
||||
handleError: function(aError) {
|
||||
this_.logError("Error getting offline flag", aError);
|
||||
aListener.onOperationComplete(this_, Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.GET, aItem.id, aItem);
|
||||
self.logError("Error getting offline flag", aError);
|
||||
aListener.onOperationComplete(self, Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.GET, aItem.id, aItem);
|
||||
},
|
||||
handleCompletion: function(aReason) {
|
||||
aListener.onOperationComplete(this_, Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.GET, aItem.id, flag);
|
||||
aListener.onOperationComplete(self, Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.GET, aItem.id, flag);
|
||||
}
|
||||
};
|
||||
if (cal.isEvent(aItem)) {
|
||||
|
@ -1020,7 +1019,7 @@ calStorageCalendar.prototype = {
|
|||
},
|
||||
|
||||
modifyOfflineItem: function(aItem, aListener) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let opListener = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
|
||||
onGetResult: function(calendar, status, itemType, detail, count, items) {
|
||||
|
@ -1030,20 +1029,20 @@ calStorageCalendar.prototype = {
|
|||
if (oldOfflineJournalFlag == cICL.OFFLINE_FLAG_CREATED_RECORD || oldOfflineJournalFlag == cICL.OFFLINE_FLAG_DELETED_RECORD) {
|
||||
// Do nothing since a flag of "created" or "deleted" exists
|
||||
} else {
|
||||
this_.setOfflineJournalFlag(aItem, newOfflineJournalFlag);
|
||||
self.setOfflineJournalFlag(aItem, newOfflineJournalFlag);
|
||||
}
|
||||
this_.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
aItem.id,
|
||||
aItem);
|
||||
self.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
aItem.id,
|
||||
aItem);
|
||||
}
|
||||
};
|
||||
this.getItemOfflineFlag(aItem, opListener);
|
||||
},
|
||||
|
||||
deleteOfflineItem: function(aItem, aListener) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let opListener = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
|
||||
onGetResult: function(calendar, status, itemType, detail, count, items) {
|
||||
|
@ -1053,21 +1052,21 @@ calStorageCalendar.prototype = {
|
|||
if (oldOfflineJournalFlag) {
|
||||
// Delete item if flag is c
|
||||
if (oldOfflineJournalFlag == cICL.OFFLINE_FLAG_CREATED_RECORD) {
|
||||
this_.deleteItemById(aItem.id);
|
||||
self.deleteItemById(aItem.id);
|
||||
} else if (oldOfflineJournalFlag == cICL.OFFLINE_FLAG_MODIFIED_RECORD) {
|
||||
this_.setOfflineJournalFlag(aItem, cICL.OFFLINE_FLAG_DELETED_RECORD);
|
||||
self.setOfflineJournalFlag(aItem, cICL.OFFLINE_FLAG_DELETED_RECORD);
|
||||
}
|
||||
} else {
|
||||
this_.setOfflineJournalFlag(aItem, cICL.OFFLINE_FLAG_DELETED_RECORD);
|
||||
self.setOfflineJournalFlag(aItem, cICL.OFFLINE_FLAG_DELETED_RECORD);
|
||||
}
|
||||
|
||||
this_.notifyOperationComplete(aListener,
|
||||
self.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
aItem.id,
|
||||
aItem);
|
||||
// notify observers
|
||||
this_.observers.notify("onDeleteItem", [aItem]);
|
||||
self.observers.notify("onDeleteItem", [aItem]);
|
||||
}
|
||||
};
|
||||
this.getItemOfflineFlag(aItem, opListener);
|
||||
|
|
|
@ -212,7 +212,7 @@ calWcapCalendar.prototype = {
|
|||
|
||||
issueNetworkRequest: function calWcapCalendar_issueNetworkRequest(
|
||||
request, respFunc, dataConvFunc, wcapCommand, params, accessRights) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
// - bootstrap problem: no cal_props, no access check, no default calId
|
||||
// - assure being logged in, thus the default cal_props are available
|
||||
// - every subscribed calendar will come along with cal_props
|
||||
|
@ -223,9 +223,9 @@ calWcapCalendar.prototype = {
|
|||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
this_.assureAccess(accessRights);
|
||||
params += ("&calid=" + encodeURIComponent(this_.calId));
|
||||
this_.session.issueNetworkRequest(request, respFunc, dataConvFunc, wcapCommand, params);
|
||||
self.assureAccess(accessRights);
|
||||
params += ("&calid=" + encodeURIComponent(self.calId));
|
||||
self.session.issueNetworkRequest(request, respFunc, dataConvFunc, wcapCommand, params);
|
||||
} catch (exc) {
|
||||
request.execSubRespFunc(respFunc, exc);
|
||||
}
|
||||
|
|
|
@ -293,7 +293,7 @@ function calWcapCalendar_storeItem(bAddItem, item, oldItem, request) {
|
|||
}
|
||||
atts = atts.concat([]);
|
||||
atts.sort(attendeeSort);
|
||||
return atts.map(this_.encodeAttendee, this_).join(";");
|
||||
return atts.map(self.encodeAttendee, self).join(";");
|
||||
}
|
||||
function encodeCategories(cats) {
|
||||
cats = cats.concat([]);
|
||||
|
@ -315,7 +315,7 @@ function calWcapCalendar_storeItem(bAddItem, item, oldItem, request) {
|
|||
} else if (wrappedAtt && wrappedAtt.uri) {
|
||||
strings.push(encodeURIComponent(wrappedAtt.uri.spec));
|
||||
} else { // xxx todo
|
||||
logError("only URLs supported as attachment, not: " + att, this_);
|
||||
logError("only URLs supported as attachment, not: " + att, self);
|
||||
}
|
||||
}
|
||||
strings.sort();
|
||||
|
@ -324,7 +324,7 @@ function calWcapCalendar_storeItem(bAddItem, item, oldItem, request) {
|
|||
return ret || "";
|
||||
}
|
||||
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let bIsEvent = isEvent(item);
|
||||
let bIsParent = isParent(item);
|
||||
|
||||
|
@ -634,16 +634,16 @@ function calWcapCalendar_tunnelXProps(destItem, srcItem) {
|
|||
|
||||
calWcapCalendar.prototype.adoptItem =
|
||||
function calWcapCalendar_adoptItem(item, listener) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let request = new calWcapRequest(
|
||||
function adoptItem_resp(oprequest, err, newItem) {
|
||||
this_.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.ADD,
|
||||
err ? item.id : newItem.id,
|
||||
err ? err : newItem);
|
||||
if (!err && this_ == this_.superCalendar) {
|
||||
this_.notifyObservers("onAddItem", [newItem]);
|
||||
self.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.ADD,
|
||||
err ? item.id : newItem.id,
|
||||
err ? err : newItem);
|
||||
if (!err && self == self.superCalendar) {
|
||||
self.notifyObservers("onAddItem", [newItem]);
|
||||
}
|
||||
},
|
||||
log("adoptItem() call: " + item.title, this));
|
||||
|
@ -663,15 +663,15 @@ function calWcapCalendar_addItem(item, listener) {
|
|||
|
||||
calWcapCalendar.prototype.modifyItem =
|
||||
function calWcapCalendar_modifyItem(newItem, oldItem, listener) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let request = new calWcapRequest(
|
||||
function modifyItem_resp(oprequest, err, item) {
|
||||
this_.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.MODIFY,
|
||||
newItem.id, err ? err : item);
|
||||
if (!err && this_ == this_.superCalendar) {
|
||||
this_.notifyObservers("onModifyItem", [item, oldItem]);
|
||||
self.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.MODIFY,
|
||||
newItem.id, err ? err : item);
|
||||
if (!err && self == self.superCalendar) {
|
||||
self.notifyObservers("onModifyItem", [item, oldItem]);
|
||||
}
|
||||
},
|
||||
log("modifyItem() call: " + newItem.id, this));
|
||||
|
@ -718,11 +718,11 @@ function calWcapCalendar_modifyItem(newItem, oldItem, listener) {
|
|||
// ignore any error and continue storing the item:
|
||||
if (LOG_LEVEL > 0) {
|
||||
log("modifyItem EXDATEs: " +
|
||||
(xml ? getWcapRequestStatusString(xml) : "failed!"), this_);
|
||||
(xml ? getWcapRequestStatusString(xml) : "failed!"), self);
|
||||
}
|
||||
// invalidate cached results:
|
||||
delete this_.m_cachedResults;
|
||||
this_.storeItem(false /* bAddItem */, newItem, oldItem_, request);
|
||||
delete self.m_cachedResults;
|
||||
self.storeItem(false /* bAddItem */, newItem, oldItem_, request);
|
||||
} finally {
|
||||
request.unlockPending();
|
||||
}
|
||||
|
@ -744,16 +744,16 @@ function calWcapCalendar_modifyItem(newItem, oldItem, listener) {
|
|||
|
||||
calWcapCalendar.prototype.deleteItem =
|
||||
function calWcapCalendar_deleteItem(item, listener) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let request = new calWcapRequest(
|
||||
function deleteItem_resp(oprequest, err) {
|
||||
// xxx todo: need to notify about each deleted item if multiple?
|
||||
this_.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.DELETE,
|
||||
item.id, err ? err : item);
|
||||
if (!err && this_ == this_.superCalendar) {
|
||||
this_.notifyObservers("onDeleteItem", [item]);
|
||||
self.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.DELETE,
|
||||
item.id, err ? err : item);
|
||||
if (!err && self == self.superCalendar) {
|
||||
self.notifyObservers("onDeleteItem", [item]);
|
||||
}
|
||||
},
|
||||
log("deleteItem() call: " + item.id, this));
|
||||
|
@ -784,9 +784,9 @@ function calWcapCalendar_deleteItem(item, listener) {
|
|||
throw err;
|
||||
}
|
||||
// invalidate cached results:
|
||||
delete this_.m_cachedResults;
|
||||
delete self.m_cachedResults;
|
||||
if (LOG_LEVEL > 0) {
|
||||
log("deleteItem(): " + getWcapRequestStatusString(xml), this_);
|
||||
log("deleteItem(): " + getWcapRequestStatusString(xml), self);
|
||||
}
|
||||
},
|
||||
stringToXml, isEvent(item) ? "deleteevents_by_id" : "deletetodos_by_id",
|
||||
|
@ -1035,7 +1035,7 @@ calWcapCalendar.prototype.parseItems = function calWcapCalendar_parseItems(
|
|||
|
||||
calWcapCalendar.prototype.getItem =
|
||||
function calWcapCalendar_getItem(id, listener) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let request = new calWcapRequest(
|
||||
function getItem_resp(oprequest, err, item) {
|
||||
if (checkErrorCode(err, calIWcapErrors.WCAP_FETCH_EVENTS_BY_ID_FAILED) ||
|
||||
|
@ -1043,11 +1043,11 @@ function calWcapCalendar_getItem(id, listener) {
|
|||
// querying by id is a valid use case, even if no item is returned:
|
||||
err = NS_OK;
|
||||
}
|
||||
this_.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.GET,
|
||||
item ? item.id : null,
|
||||
err || item);
|
||||
self.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.GET,
|
||||
item ? item.id : null,
|
||||
err || item);
|
||||
},
|
||||
log("getItem() call: id=" + id, this));
|
||||
|
||||
|
@ -1064,17 +1064,17 @@ function calWcapCalendar_getItem(id, listener) {
|
|||
request,
|
||||
function fetchEventById_resp(err, eventRootComp) {
|
||||
function notifyResult(rootComp) {
|
||||
let items = this_.parseItems(rootComp, calICalendar.ITEM_FILTER_ALL_ITEMS, 0, null, null);
|
||||
let items = self.parseItems(rootComp, calICalendar.ITEM_FILTER_ALL_ITEMS, 0, null, null);
|
||||
if (items.length < 1) {
|
||||
throw new Components.Exception("no such item!");
|
||||
}
|
||||
if (items.length > 1) {
|
||||
this_.notifyError(NS_ERROR_UNEXPECTED,
|
||||
"unexpected number of items: " + items.length);
|
||||
self.notifyError(NS_ERROR_UNEXPECTED,
|
||||
"unexpected number of items: " + items.length);
|
||||
}
|
||||
if (listener) {
|
||||
listener.onGetResult(this_.superCalendar, NS_OK,
|
||||
calIItemBase, log("getItem(): success. id=" + id, this_),
|
||||
listener.onGetResult(self.superCalendar, NS_OK,
|
||||
calIItemBase, log("getItem(): success. id=" + id, self),
|
||||
items.length, items);
|
||||
}
|
||||
request.execRespFunc(null, items[0]);
|
||||
|
@ -1085,7 +1085,7 @@ function calWcapCalendar_getItem(id, listener) {
|
|||
throw err;
|
||||
}
|
||||
// try todos:
|
||||
this_.issueNetworkRequest(
|
||||
self.issueNetworkRequest(
|
||||
request,
|
||||
function fetchTodosById_resp(fetcherr, todoRootComp) {
|
||||
if (fetcherr) {
|
||||
|
@ -1146,15 +1146,15 @@ function calWcapCalendar_getItems(itemFilter, maxResults, rangeStart, rangeEnd,
|
|||
let zRangeStart = getIcalUTC(rangeStart);
|
||||
let zRangeEnd = getIcalUTC(rangeEnd);
|
||||
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let request = new calWcapRequest(
|
||||
function getItems_resp(oprequest, err, data) {
|
||||
log("getItems() complete: " + errorToString(err), this_);
|
||||
this_.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.GET,
|
||||
null,
|
||||
err);
|
||||
log("getItems() complete: " + errorToString(err), self);
|
||||
self.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.GET,
|
||||
null,
|
||||
err);
|
||||
},
|
||||
log("getItems():\n\titemFilter=0x" + itemFilter.toString(0x10) +
|
||||
",\n\tmaxResults=" + maxResults +
|
||||
|
@ -1220,65 +1220,65 @@ function calWcapCalendar_getItems(itemFilter, maxResults, rangeStart, rangeEnd,
|
|||
for (let entry of result) {
|
||||
let item = createEvent();
|
||||
item.id = g_busyPhantomItemUuidPrefix + getIcalUTC(entry.interval.start);
|
||||
item.calendar = this_.superCalendar;
|
||||
item.calendar = self.superCalendar;
|
||||
item.title = g_busyItemTitle;
|
||||
item.startDate = entry.interval.start;
|
||||
item.endDate = entry.interval.end;
|
||||
item.makeImmutable();
|
||||
items.push(item);
|
||||
}
|
||||
listener.onGetResult(this_.superCalendar, NS_OK, calIItemBase,
|
||||
listener.onGetResult(self.superCalendar, NS_OK, calIItemBase,
|
||||
"getItems()/free-busy", items.length, items);
|
||||
}
|
||||
};
|
||||
request.attachSubRequest(
|
||||
this_.session.getFreeBusyIntervals(
|
||||
this_.calId, rangeStart, rangeEnd, calIFreeBusyInterval.BUSY_ALL,
|
||||
self.session.getFreeBusyIntervals(
|
||||
self.calId, rangeStart, rangeEnd, calIFreeBusyInterval.BUSY_ALL,
|
||||
freeBusyListener));
|
||||
}
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
} else if (listener) {
|
||||
let items = this_.parseItems(
|
||||
let items = self.parseItems(
|
||||
icalRootComp, itemFilter, maxResults,
|
||||
rangeStart, rangeEnd);
|
||||
|
||||
if (CACHE_LAST_RESULTS > 0) {
|
||||
// auto invalidate after X minutes:
|
||||
if (!this_.m_cachedResultsTimer) {
|
||||
if (!self.m_cachedResultsTimer) {
|
||||
let callback = {
|
||||
notify: function notify(timer) {
|
||||
if (!this_.m_cachedResults) {
|
||||
if (!self.m_cachedResults) {
|
||||
return;
|
||||
}
|
||||
let now = (new Date()).getTime();
|
||||
// sort out old entries:
|
||||
let entries = [];
|
||||
for (let i = 0; i < this_.m_cachedResults.length; ++i) {
|
||||
let entry = this_.m_cachedResults[i];
|
||||
for (let i = 0; i < self.m_cachedResults.length; ++i) {
|
||||
let entry = self.m_cachedResults[i];
|
||||
if ((now - entry.stamp) < (CACHE_LAST_RESULTS_INVALIDATE * 1000)) {
|
||||
entries.push(entry);
|
||||
} else {
|
||||
log("invalidating cached entry:\n\trangeStart=" +
|
||||
getIcalUTC(entry.rangeStart) + "\n\trangeEnd=" +
|
||||
getIcalUTC(entry.rangeEnd), this_);
|
||||
getIcalUTC(entry.rangeEnd), self);
|
||||
}
|
||||
}
|
||||
this_.m_cachedResults = entries;
|
||||
self.m_cachedResults = entries;
|
||||
}
|
||||
};
|
||||
// sort out freq:
|
||||
let freq = Math.min(20, // default: 20secs
|
||||
Math.max(1, CACHE_LAST_RESULTS_INVALIDATE));
|
||||
log("cached results sort out timer freq: " + freq, this_);
|
||||
this_.m_cachedResultsTimer = Components.classes["@mozilla.org/timer;1"]
|
||||
.createInstance(Components.interfaces.nsITimer);
|
||||
this_.m_cachedResultsTimer.initWithCallback(callback, freq * 1000,
|
||||
Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
|
||||
log("cached results sort out timer freq: " + freq, self);
|
||||
self.m_cachedResultsTimer = Components.classes["@mozilla.org/timer;1"]
|
||||
.createInstance(Components.interfaces.nsITimer);
|
||||
self.m_cachedResultsTimer.initWithCallback(callback, freq * 1000,
|
||||
Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
|
||||
}
|
||||
if (!this_.m_cachedResults) {
|
||||
this_.m_cachedResults = [];
|
||||
if (!self.m_cachedResults) {
|
||||
self.m_cachedResults = [];
|
||||
}
|
||||
let cacheEntry = {
|
||||
stamp: (new Date()).getTime(),
|
||||
|
@ -1287,13 +1287,13 @@ function calWcapCalendar_getItems(itemFilter, maxResults, rangeStart, rangeEnd,
|
|||
rangeEnd: (rangeEnd ? rangeEnd.clone() : null),
|
||||
results: items
|
||||
};
|
||||
this_.m_cachedResults.unshift(cacheEntry);
|
||||
if (this_.m_cachedResults.length > CACHE_LAST_RESULTS) {
|
||||
this_.m_cachedResults.length = CACHE_LAST_RESULTS;
|
||||
self.m_cachedResults.unshift(cacheEntry);
|
||||
if (self.m_cachedResults.length > CACHE_LAST_RESULTS) {
|
||||
self.m_cachedResults.length = CACHE_LAST_RESULTS;
|
||||
}
|
||||
}
|
||||
|
||||
listener.onGetResult(this_.superCalendar, NS_OK, calIItemBase, "getItems()", items.length, items);
|
||||
listener.onGetResult(self.superCalendar, NS_OK, calIItemBase, "getItems()", items.length, items);
|
||||
}
|
||||
},
|
||||
stringToIcal, "fetchcomponents_by_range", params, calIWcapCalendar.AC_COMP_READ);
|
||||
|
@ -1312,7 +1312,7 @@ function calWcapCalendar_resetLog() {
|
|||
|
||||
calWcapCalendar.prototype.replayChangesOn =
|
||||
function calWcapCalendar_replayChangesOn(listener) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let itemFilter = calICalendar.ITEM_FILTER_ALL_ITEMS;
|
||||
let dtFrom = getDatetimeFromIcalString(this.getProperty("replay.last_stamp"));
|
||||
let now = getTime(); // new stamp for this sync
|
||||
|
@ -1321,11 +1321,11 @@ function calWcapCalendar_replayChangesOn(listener) {
|
|||
function replayChangesOn_resp(request, err) {
|
||||
if (err) {
|
||||
logError("error replaying changes: " + errorToString(err));
|
||||
this_.notifyError(err);
|
||||
self.notifyError(err);
|
||||
} else {
|
||||
log("replay succeeded.", this_);
|
||||
this_.setProperty("replay.last_stamp", getIcalUTC(now));
|
||||
log("new replay stamp: " + getIcalUTC(now), this_);
|
||||
log("replay succeeded.", self);
|
||||
self.setProperty("replay.last_stamp", getIcalUTC(now));
|
||||
log("new replay stamp: " + getIcalUTC(now), self);
|
||||
}
|
||||
if (listener) {
|
||||
listener.onResult(request, null);
|
||||
|
@ -1352,33 +1352,33 @@ function calWcapCalendar_replayChangesOn(listener) {
|
|||
let bAdd = !dtCreated || !dtFrom || dtCreated.compare(dtFrom) >= 0;
|
||||
modifiedIds[item.id] = true;
|
||||
if (bAdd) {
|
||||
log("replayChangesOn(): new item " + item.id, this_);
|
||||
if (this_.offlineStorage) {
|
||||
this_.offlineStorage.addItem(item, writeListener);
|
||||
log("replayChangesOn(): new item " + item.id, self);
|
||||
if (self.offlineStorage) {
|
||||
self.offlineStorage.addItem(item, writeListener);
|
||||
}
|
||||
} else {
|
||||
log("replayChangesOn(): modified item " + item.id, this_);
|
||||
if (this_.offlineStorage) {
|
||||
this_.modifyItem(item, null, writeListener);
|
||||
log("replayChangesOn(): modified item " + item.id, self);
|
||||
if (self.offlineStorage) {
|
||||
self.modifyItem(item, null, writeListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let item of request.m_deletedItems) {
|
||||
// don't delete anything that has been touched by lastmods:
|
||||
if (modifiedIds[item.id]) {
|
||||
log("replayChangesOn(): skipping deletion of " + item.id, this_);
|
||||
log("replayChangesOn(): skipping deletion of " + item.id, self);
|
||||
} else if (isParent(item)) {
|
||||
log("replayChangesOn(): deleted item " + item.id, this_);
|
||||
if (this_.offlineStorage) {
|
||||
this_.offlineStorage.deleteItem(item, writeListener);
|
||||
log("replayChangesOn(): deleted item " + item.id, self);
|
||||
if (self.offlineStorage) {
|
||||
self.offlineStorage.deleteItem(item, writeListener);
|
||||
}
|
||||
} else { // modify parent instead of
|
||||
// straight-forward deleteItem(). WTF.
|
||||
let parent = item.parentItem.clone();
|
||||
parent.recurrenceInfo.removeOccurrenceAt(item.recurrenceId);
|
||||
log("replayChangesOn(): modified parent " + parent.id, this_);
|
||||
if (this_.offlineStorage) {
|
||||
this_.offlineStorage.modifyItem(parent, item, writeListener);
|
||||
log("replayChangesOn(): modified parent " + parent.id, self);
|
||||
if (self.offlineStorage) {
|
||||
self.offlineStorage.modifyItem(parent, item, writeListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1396,36 +1396,36 @@ function calWcapCalendar_replayChangesOn(listener) {
|
|||
let params = "&relativealarm=1&compressed=1&recurring=1" +
|
||||
"&emailorcalid=1&fmt-out=text%2Fcalendar";
|
||||
if (dtFrom) {
|
||||
dtFrom = this_.session.getServerTime(dtFrom);
|
||||
dtFrom = self.session.getServerTime(dtFrom);
|
||||
}
|
||||
params += "&dtstart=" + getIcalUTC(dtFrom);
|
||||
params += "&dtend=" + getIcalUTC(this_.session.getServerTime(now));
|
||||
params += "&dtend=" + getIcalUTC(self.session.getServerTime(now));
|
||||
|
||||
log("replayChangesOn(): getting last modifications...", this_);
|
||||
this_.issueNetworkRequest(
|
||||
log("replayChangesOn(): getting last modifications...", self);
|
||||
self.issueNetworkRequest(
|
||||
request,
|
||||
function modifiedNetResp(fetcherr, icalRootComp) {
|
||||
if (fetcherr) {
|
||||
throw fetcherr;
|
||||
}
|
||||
request.m_modifiedItems = this_.parseItems(icalRootComp,
|
||||
calICalendar.ITEM_FILTER_ALL_ITEMS,
|
||||
0, null, null);
|
||||
request.m_modifiedItems = self.parseItems(icalRootComp,
|
||||
calICalendar.ITEM_FILTER_ALL_ITEMS,
|
||||
0, null, null);
|
||||
},
|
||||
stringToIcal, "fetchcomponents_by_lastmod",
|
||||
params + getItemFilterParams(itemFilter),
|
||||
calIWcapCalendar.AC_COMP_READ);
|
||||
|
||||
log("replayChangesOn(): getting deleted items...", this_);
|
||||
this_.issueNetworkRequest(
|
||||
log("replayChangesOn(): getting deleted items...", self);
|
||||
self.issueNetworkRequest(
|
||||
request,
|
||||
function modifiedNetResp(fetcherr, icalRootComp) {
|
||||
if (fetcherr) {
|
||||
throw fetcherr;
|
||||
}
|
||||
request.m_deletedItems = this_.parseItems(icalRootComp,
|
||||
calICalendar.ITEM_FILTER_ALL_ITEMS,
|
||||
0, null, null);
|
||||
request.m_deletedItems = self.parseItems(icalRootComp,
|
||||
calICalendar.ITEM_FILTER_ALL_ITEMS,
|
||||
0, null, null);
|
||||
},
|
||||
stringToIcal, "fetch_deletedcomponents",
|
||||
params + getItemFilterParams(itemFilter & // only component types
|
||||
|
|
|
@ -221,26 +221,26 @@ calWcapSession.prototype = {
|
|||
getCalendarSearchService().removeProvider(this);
|
||||
}
|
||||
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
this.getSessionId_(null, // don't couple to parent request parent may be cancelled
|
||||
function getSessionId_resp_(err, sessionId) {
|
||||
log("getSessionId_resp_(): " + sessionId, this_);
|
||||
log("getSessionId_resp_(): " + sessionId, self);
|
||||
if (!err) {
|
||||
this_.m_sessionId = sessionId;
|
||||
getFreeBusyService().addProvider(this_);
|
||||
getCalendarSearchService().addProvider(this_);
|
||||
self.m_sessionId = sessionId;
|
||||
getFreeBusyService().addProvider(self);
|
||||
getCalendarSearchService().addProvider(self);
|
||||
}
|
||||
|
||||
let queue = this_.m_loginQueue;
|
||||
this_.m_loginLock = false;
|
||||
this_.m_loginQueue = [];
|
||||
log("unlocked login queue.", this_);
|
||||
let queue = self.m_loginQueue;
|
||||
self.m_loginLock = false;
|
||||
self.m_loginQueue = [];
|
||||
log("unlocked login queue.", self);
|
||||
|
||||
function getSessionId_exec(func) {
|
||||
try {
|
||||
func(err, sessionId);
|
||||
} catch (exc) { // unexpected
|
||||
this_.notifyError(exc);
|
||||
self.notifyError(exc);
|
||||
}
|
||||
}
|
||||
// answer first request:
|
||||
|
@ -255,7 +255,7 @@ calWcapSession.prototype = {
|
|||
recurrenceBound: 60,
|
||||
|
||||
getSessionId_: function calWcapSession_getSessionId_(request, respFunc) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
this.checkServerVersion(
|
||||
request,
|
||||
// probe whether server is accessible and responds:
|
||||
|
@ -265,40 +265,40 @@ calWcapSession.prototype = {
|
|||
return;
|
||||
}
|
||||
// lookup password manager, then try login or prompt/login:
|
||||
log("attempting to get a session id for " + this_.sessionUri.spec, this_);
|
||||
log("attempting to get a session id for " + self.sessionUri.spec, self);
|
||||
|
||||
if (!this_.sessionUri.schemeIs("https") &&
|
||||
!confirmInsecureLogin(this_.sessionUri)) {
|
||||
log("user rejected insecure login on " + this_.sessionUri.spec, this_);
|
||||
if (!self.sessionUri.schemeIs("https") &&
|
||||
!confirmInsecureLogin(self.sessionUri)) {
|
||||
log("user rejected insecure login on " + self.sessionUri.spec, self);
|
||||
respFunc(new Components.Exception(errorToString(calIWcapErrors.WCAP_LOGIN_FAILED),
|
||||
calIWcapErrors.WCAP_LOGIN_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
let outUser = { value: this_.credentials.userId };
|
||||
let outPW = { value: this_.credentials.pw };
|
||||
let outUser = { value: self.credentials.userId };
|
||||
let outPW = { value: self.credentials.pw };
|
||||
let outSavePW = { value: false };
|
||||
|
||||
if (outUser.value && !outPW.value) { // lookup pw manager
|
||||
log("looking in pw db for: " + this_.uri.spec, this_);
|
||||
cal.auth.passwordManagerGet(outUser.value, outPW, this_.uri.spec, "wcap login");
|
||||
log("looking in pw db for: " + self.uri.spec, self);
|
||||
cal.auth.passwordManagerGet(outUser.value, outPW, self.uri.spec, "wcap login");
|
||||
}
|
||||
|
||||
function promptAndLoginLoop_resp(loginerr, sessionId) {
|
||||
if (checkErrorCode(loginerr, calIWcapErrors.WCAP_LOGIN_FAILED)) {
|
||||
log("prompting for [user/]pw...", this_);
|
||||
log("prompting for [user/]pw...", self);
|
||||
if (cal.auth.getCredentials(cal.calGetString("wcap", "loginDialog.label"),
|
||||
this_.sessionUri.hostPort,
|
||||
self.sessionUri.hostPort,
|
||||
outUser,
|
||||
outPW,
|
||||
outSavePW,
|
||||
this_.credentials.userId != null)) {
|
||||
this_.login(request, promptAndLoginLoop_resp,
|
||||
outUser.value, outPW.value);
|
||||
self.credentials.userId != null)) {
|
||||
self.login(request, promptAndLoginLoop_resp,
|
||||
outUser.value, outPW.value);
|
||||
} else {
|
||||
log("login prompt cancelled.", this_);
|
||||
this_.defaultCalendar.setProperty("disabled", true);
|
||||
this_.defaultCalendar.setProperty("auto-enabled", true);
|
||||
log("login prompt cancelled.", self);
|
||||
self.defaultCalendar.setProperty("disabled", true);
|
||||
self.defaultCalendar.setProperty("auto-enabled", true);
|
||||
respFunc(new Components.Exception(errorToString(calIWcapErrors.WCAP_LOGIN_FAILED),
|
||||
calIWcapErrors.WCAP_LOGIN_FAILED));
|
||||
}
|
||||
|
@ -307,20 +307,20 @@ calWcapSession.prototype = {
|
|||
} else {
|
||||
if (outSavePW.value) {
|
||||
// so try to remove old pw from db first:
|
||||
cal.auth.passwordManagerSave(outUser.value, outPW.value, this_.uri.spec, "wcap login");
|
||||
cal.auth.passwordManagerSave(outUser.value, outPW.value, self.uri.spec, "wcap login");
|
||||
}
|
||||
this_.credentials.userId = outUser.value;
|
||||
this_.credentials.pw = outPW.value;
|
||||
this_.setupSession(sessionId,
|
||||
request,
|
||||
function setupSession_resp(setuperr) {
|
||||
respFunc(setuperr, sessionId);
|
||||
});
|
||||
self.credentials.userId = outUser.value;
|
||||
self.credentials.pw = outPW.value;
|
||||
self.setupSession(sessionId,
|
||||
request,
|
||||
function setupSession_resp(setuperr) {
|
||||
respFunc(setuperr, sessionId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (outPW.value) {
|
||||
this_.login(request, promptAndLoginLoop_resp, outUser.value, outPW.value);
|
||||
self.login(request, promptAndLoginLoop_resp, outUser.value, outPW.value);
|
||||
} else {
|
||||
promptAndLoginLoop_resp(calIWcapErrors.WCAP_LOGIN_FAILED);
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ calWcapSession.prototype = {
|
|||
},
|
||||
|
||||
login: function calWcapSession_login(request, respFunc, user, pw) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
issueNetworkRequest(
|
||||
request,
|
||||
function netResp(err, str) {
|
||||
|
@ -340,7 +340,7 @@ calWcapSession.prototype = {
|
|||
// currently, xml parsing at an early stage during
|
||||
// process startup does not work reliably, so use
|
||||
// libical parsing for now:
|
||||
let icalRootComp = stringToIcal(this_, str);
|
||||
let icalRootComp = stringToIcal(self, str);
|
||||
let prop = icalRootComp.getFirstProperty("X-NSCP-WCAP-SESSION-ID");
|
||||
if (!prop) {
|
||||
throw new Components.Exception("missing X-NSCP-WCAP-SESSION-ID in\n" + str);
|
||||
|
@ -350,36 +350,36 @@ calWcapSession.prototype = {
|
|||
if (prop) {
|
||||
let val = parseInt(prop.value, 10);
|
||||
if (!isNaN(val)) {
|
||||
this_.recurrenceBound = val;
|
||||
log("X-NSCP-RECURRENCE-BOUND:" + this_.recurrenceBound);
|
||||
self.recurrenceBound = val;
|
||||
log("X-NSCP-RECURRENCE-BOUND:" + self.recurrenceBound);
|
||||
}
|
||||
}
|
||||
log("login succeeded: " + sessionId, this_);
|
||||
log("login succeeded: " + sessionId, self);
|
||||
} catch (exc) {
|
||||
err = exc;
|
||||
if (checkErrorCode(err, calIWcapErrors.WCAP_LOGIN_FAILED)) {
|
||||
log("error: " + errorToString(exc), this_); // log login failure
|
||||
log("error: " + errorToString(exc), self); // log login failure
|
||||
} else if (getErrorModule(err) == NS_ERROR_MODULE_NETWORK) {
|
||||
// server seems unavailable:
|
||||
err = new Components.Exception(cal.calGetString("wcap", "accessingServerFailedError.text",
|
||||
[this_.sessionUri.hostPort]), exc);
|
||||
[self.sessionUri.hostPort]), exc);
|
||||
}
|
||||
}
|
||||
respFunc(err, sessionId);
|
||||
},
|
||||
this_.sessionUri.spec + "login.wcap?fmt-out=text%2Fcalendar&user=" +
|
||||
self.sessionUri.spec + "login.wcap?fmt-out=text%2Fcalendar&user=" +
|
||||
encodeURIComponent(user) + "&password=" + encodeURIComponent(pw),
|
||||
false /* no logging */);
|
||||
},
|
||||
|
||||
logout: function calWcapSession_logout(listener) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let request = new calWcapRequest(
|
||||
function logout_resp(oprequest, err) {
|
||||
if (err) {
|
||||
logError(err, this_);
|
||||
logError(err, self);
|
||||
} else {
|
||||
log("logout succeeded.", this_);
|
||||
log("logout succeeded.", self);
|
||||
}
|
||||
if (listener) {
|
||||
listener.onResult(oprequest, null);
|
||||
|
@ -407,7 +407,7 @@ calWcapSession.prototype = {
|
|||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
stringToXml(this_, str, -1 /* logout successfull */);
|
||||
stringToXml(self, str, -1 /* logout successfull */);
|
||||
}, url);
|
||||
} else {
|
||||
request.execRespFunc();
|
||||
|
@ -418,7 +418,7 @@ calWcapSession.prototype = {
|
|||
checkServerVersion: function calWcapSession_checkServerVersion(request, respFunc) {
|
||||
// currently, xml parsing at an early stage during process startup
|
||||
// does not work reliably, so use libical:
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
issueNetworkRequest(
|
||||
request,
|
||||
function netResp(err, str) {
|
||||
|
@ -426,7 +426,7 @@ calWcapSession.prototype = {
|
|||
let icalRootComp;
|
||||
if (!err) {
|
||||
try {
|
||||
icalRootComp = stringToIcal(this_, str);
|
||||
icalRootComp = stringToIcal(self, str);
|
||||
} catch (exc) {
|
||||
err = exc;
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ calWcapSession.prototype = {
|
|||
} else { // soft error; request denied etc.
|
||||
// map into localized message:
|
||||
throw new Components.Exception(cal.calGetString("wcap", "accessingServerFailedError.text",
|
||||
[this_.sessionUri.hostPort]),
|
||||
[self.sessionUri.hostPort]),
|
||||
calIWcapErrors.WCAP_LOGIN_FAILED);
|
||||
}
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ calWcapSession.prototype = {
|
|||
let wcapVersion = parseInt(prop.value, 10);
|
||||
if (wcapVersion < 3) {
|
||||
let strVers = prop.value;
|
||||
let vars = [this_.sessionUri.hostPort];
|
||||
let vars = [self.sessionUri.hostPort];
|
||||
prop = icalRootComp.getFirstProperty("PRODID");
|
||||
vars.push(prop ? prop.value : "<unknown>");
|
||||
prop = icalRootComp.getFirstProperty("X-NSCP-SERVERVERSION");
|
||||
|
@ -467,14 +467,14 @@ calWcapSession.prototype = {
|
|||
}
|
||||
respFunc(err);
|
||||
},
|
||||
this_.sessionUri.spec + "version.wcap?fmt-out=text%2Fcalendar");
|
||||
self.sessionUri.spec + "version.wcap?fmt-out=text%2Fcalendar");
|
||||
},
|
||||
|
||||
setupSession: function calWcapSession_setupSession(sessionId, request_, respFunc) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let request = new calWcapRequest(
|
||||
function setupSession_resp(oprequest, err) {
|
||||
log("setupSession_resp finished: " + errorToString(err), this_);
|
||||
log("setupSession_resp finished: " + errorToString(err), self);
|
||||
respFunc(err);
|
||||
},
|
||||
log("setupSession", this));
|
||||
|
@ -490,20 +490,20 @@ calWcapSession.prototype = {
|
|||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
this_.credentials.userPrefs = data;
|
||||
log("installed user prefs.", this_);
|
||||
self.credentials.userPrefs = data;
|
||||
log("installed user prefs.", self);
|
||||
|
||||
// get calprops for all registered calendars:
|
||||
let cals = this_.getRegisteredCalendars(true);
|
||||
let cals = self.getRegisteredCalendars(true);
|
||||
|
||||
let calprops_resp = null;
|
||||
let defaultCal = this_.defaultCalendar;
|
||||
let defaultCal = self.defaultCalendar;
|
||||
if (defaultCal && cals[defaultCal.calId] && // default calendar is registered
|
||||
getPref("calendar.wcap.subscriptions", true) &&
|
||||
!defaultCal.getProperty("subscriptions_registered")) {
|
||||
let hasSubscriptions = false;
|
||||
// post register subscribed calendars:
|
||||
let list = this_.getUserPreferences("X-NSCP-WCAP-PREF-icsSubscribed");
|
||||
let list = self.getUserPreferences("X-NSCP-WCAP-PREF-icsSubscribed");
|
||||
for (let item of list) {
|
||||
let ar = item.split(",");
|
||||
// ',', '$' are not encoded. ',' can be handled here. WTF.
|
||||
|
@ -511,7 +511,7 @@ calWcapSession.prototype = {
|
|||
let dollar = a.indexOf("$");
|
||||
if (dollar >= 0) {
|
||||
let calId = a.substring(0, dollar);
|
||||
if (calId != this_.defaultCalId) {
|
||||
if (calId != self.defaultCalId) {
|
||||
cals[calId] = null;
|
||||
hasSubscriptions = true;
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ calWcapSession.prototype = {
|
|||
// tweak name:
|
||||
aCalendar.setProperty("name", aCalendar.displayName);
|
||||
} else {
|
||||
log("registering subscribed calendar: " + aCalendar.calId, this_);
|
||||
log("registering subscribed calendar: " + aCalendar.calId, self);
|
||||
cal.getCalendarManager().registerCalendar(aCalendar);
|
||||
}
|
||||
};
|
||||
|
@ -535,14 +535,14 @@ calWcapSession.prototype = {
|
|||
}
|
||||
|
||||
if (!defaultCal.getProperty("user_id")) { // nail once:
|
||||
defaultCal.setProperty("user_id", this_.credentials.userId);
|
||||
defaultCal.setProperty("user_id", self.credentials.userId);
|
||||
}
|
||||
|
||||
if (getPref("calendar.wcap.no_get_calprops", false)) {
|
||||
// hack around the get/search calprops mess:
|
||||
this_.installCalProps_search_calprops(calprops_resp, sessionId, cals, request);
|
||||
self.installCalProps_search_calprops(calprops_resp, sessionId, cals, request);
|
||||
} else {
|
||||
this_.installCalProps_get_calprops(calprops_resp, sessionId, cals, request);
|
||||
self.installCalProps_get_calprops(calprops_resp, sessionId, cals, request);
|
||||
}
|
||||
},
|
||||
stringToXml, "get_userprefs",
|
||||
|
@ -557,7 +557,7 @@ calWcapSession.prototype = {
|
|||
|
||||
installCalProps_get_calprops:
|
||||
function calWcapSession_installCalProps_get_calprops(respFunc, sessionId, cals, request) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
function calprops_resp(err, data) {
|
||||
if (err) {
|
||||
throw err;
|
||||
|
@ -578,8 +578,8 @@ calWcapSession.prototype = {
|
|||
let calId = ar[0];
|
||||
let calendar = cals[calId];
|
||||
if (calendar === null) {
|
||||
calendar = new calWcapCalendar(this_);
|
||||
let uri = this_.uri.clone();
|
||||
calendar = new calWcapCalendar(self);
|
||||
let uri = self.uri.clone();
|
||||
uri.path += "?calid=" + encodeURIComponent(calId);
|
||||
calendar.uri = uri;
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ calWcapSession.prototype = {
|
|||
}
|
||||
}
|
||||
} catch (exc) { // ignore but log any errors on subscribed calendars:
|
||||
logError(exc, this_);
|
||||
logError(exc, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -603,15 +603,15 @@ calWcapSession.prototype = {
|
|||
}
|
||||
calidParam += encodeURIComponent(calId);
|
||||
}
|
||||
this_.issueNetworkRequest_(request, calprops_resp,
|
||||
null, "get_calprops",
|
||||
"&fmt-out=text%2Fxml&calid=" + calidParam,
|
||||
sessionId);
|
||||
self.issueNetworkRequest_(request, calprops_resp,
|
||||
null, "get_calprops",
|
||||
"&fmt-out=text%2Fxml&calid=" + calidParam,
|
||||
sessionId);
|
||||
},
|
||||
|
||||
installCalProps_search_calprops:
|
||||
function calWcapSession_installCalProps_search_calprops(respFunc, sessionId, cals, request) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let retrievedCals = {};
|
||||
let issuedSearchRequests = {};
|
||||
for (let calId in cals) {
|
||||
|
@ -637,11 +637,11 @@ calWcapSession.prototype = {
|
|||
}
|
||||
}
|
||||
} catch (exc) { // ignore but log any errors on subscribed calendars:
|
||||
logError(exc, this_);
|
||||
logError(exc, self);
|
||||
}
|
||||
}
|
||||
} catch (exc) { // ignore but log any errors on subscribed calendars:
|
||||
logError(exc, this_);
|
||||
logError(exc, self);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -659,7 +659,7 @@ calWcapSession.prototype = {
|
|||
},
|
||||
|
||||
installServerTimeDiff: function calWcapSession_installServerTimeDiff(sessionId, request) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
this.issueNetworkRequest_(
|
||||
request,
|
||||
function netResp(err, data) {
|
||||
|
@ -671,8 +671,8 @@ calWcapSession.prototype = {
|
|||
// than the current (real) server time:
|
||||
let localTime = getTime();
|
||||
let serverTime = getDatetimeFromIcalProp(data.getFirstProperty("X-NSCP-WCAPTIME"));
|
||||
this_.m_serverTimeDiff = serverTime.subtractDate(localTime);
|
||||
log("server time diff is: " + this_.m_serverTimeDiff, this_);
|
||||
self.m_serverTimeDiff = serverTime.subtractDate(localTime);
|
||||
log("server time diff is: " + self.m_serverTimeDiff, self);
|
||||
},
|
||||
stringToIcal, "gettime", "&fmt-out=text%2Fcalendar",
|
||||
sessionId);
|
||||
|
@ -680,8 +680,8 @@ calWcapSession.prototype = {
|
|||
|
||||
installServerTimezones: function calWcapSession_installServerTimezones(sessionId, request) {
|
||||
this.m_serverTimezones = {};
|
||||
let this_ = this;
|
||||
this_.issueNetworkRequest_(
|
||||
let self = this;
|
||||
self.issueNetworkRequest_(
|
||||
request,
|
||||
function netResp(err, data) {
|
||||
if (err) {
|
||||
|
@ -690,12 +690,12 @@ calWcapSession.prototype = {
|
|||
for (let subComp of cal.ical.calendarComponentIterator(data, "VTIMEZONE")) {
|
||||
try {
|
||||
let tzid = subComp.getFirstProperty("TZID").value;
|
||||
this_.m_serverTimezones[tzid] = new calWcapTimezone(this_, tzid, subComp);
|
||||
self.m_serverTimezones[tzid] = new calWcapTimezone(self, tzid, subComp);
|
||||
} catch (exc) { // ignore but errors:
|
||||
logError(exc, this_);
|
||||
logError(exc, self);
|
||||
}
|
||||
}
|
||||
log("installed timezones.", this_);
|
||||
log("installed timezones.", self);
|
||||
},
|
||||
stringToIcal, "get_all_timezones", "&fmt-out=text%2Fcalendar",
|
||||
sessionId);
|
||||
|
@ -711,19 +711,19 @@ calWcapSession.prototype = {
|
|||
|
||||
issueNetworkRequest: function calWcapSession_issueNetworkRequest(
|
||||
request, respFunc, dataConvFunc, wcapCommand, params) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let getSessionId_resp = function(err, sessionId) {
|
||||
if (err) {
|
||||
request.execSubRespFunc(respFunc, err);
|
||||
} else {
|
||||
// else have session uri and id:
|
||||
this_.issueNetworkRequest_(
|
||||
self.issueNetworkRequest_(
|
||||
request,
|
||||
function issueNetworkRequest_resp(loginerr, data) {
|
||||
// timeout?
|
||||
if (checkErrorCode(loginerr, calIWcapErrors.WCAP_LOGIN_FAILED)) {
|
||||
// try again:
|
||||
this_.getSessionId(
|
||||
self.getSessionId(
|
||||
request,
|
||||
getSessionId_resp,
|
||||
sessionId/* (old) timed-out session */);
|
||||
|
@ -740,14 +740,14 @@ calWcapSession.prototype = {
|
|||
issueNetworkRequest_: function calWcapSession_issueNetworkRequest_(
|
||||
request, respFunc, dataConvFunc, wcapCommand, params, sessionId) {
|
||||
let url = this.getCommandUrl(wcapCommand, params, sessionId);
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
issueNetworkRequest(request,
|
||||
function netResp(err, str) {
|
||||
let data;
|
||||
if (!err) {
|
||||
try {
|
||||
if (dataConvFunc) {
|
||||
data = dataConvFunc(this_, str);
|
||||
data = dataConvFunc(self, str);
|
||||
} else {
|
||||
data = str;
|
||||
}
|
||||
|
@ -869,11 +869,11 @@ calWcapSession.prototype = {
|
|||
// calICalendarSearchProvider:
|
||||
searchForCalendars:
|
||||
function calWcapSession_searchForCalendars(searchString, hints, maxResults, listener) {
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let request = new calWcapRequest(
|
||||
function searchForCalendars_resp(oprequest, err, data) {
|
||||
if (err && !checkErrorCode(err, calIErrors.OPERATION_CANCELLED)) {
|
||||
this_.notifyError(err);
|
||||
self.notifyError(err);
|
||||
}
|
||||
if (listener) {
|
||||
listener.onResult(oprequest, data);
|
||||
|
@ -916,8 +916,8 @@ calWcapSession.prototype = {
|
|||
if (calendar) {
|
||||
calendar.m_calProps = node; // update calprops
|
||||
} else {
|
||||
calendar = new calWcapCalendar(this_, node);
|
||||
let uri = this_.uri.clone();
|
||||
calendar = new calWcapCalendar(self, node);
|
||||
let uri = self.uri.clone();
|
||||
uri.path += "?calid=" + encodeURIComponent(calId);
|
||||
calendar.uri = uri;
|
||||
}
|
||||
|
@ -927,15 +927,15 @@ calWcapSession.prototype = {
|
|||
switch (getResultCode(exc)) {
|
||||
case calIWcapErrors.WCAP_NO_ERRNO: // workaround
|
||||
case calIWcapErrors.WCAP_ACCESS_DENIED_TO_CALENDAR:
|
||||
log("searchForCalendars_netResp() ignored error: " + errorToString(exc), this_);
|
||||
log("searchForCalendars_netResp() ignored error: " + errorToString(exc), self);
|
||||
break;
|
||||
default:
|
||||
this_.notifyError(exc);
|
||||
self.notifyError(exc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
log("search done. number of found calendars: " + ret.length, this_);
|
||||
log("search done. number of found calendars: " + ret.length, self);
|
||||
request.execRespFunc(null, ret);
|
||||
},
|
||||
null, "search_calprops", params);
|
||||
|
@ -953,7 +953,7 @@ calWcapSession.prototype = {
|
|||
let zRangeStart = getIcalUTC(rangeStart);
|
||||
let zRangeEnd = getIcalUTC(rangeEnd);
|
||||
|
||||
let this_ = this;
|
||||
let self = this;
|
||||
let request = new calWcapRequest(
|
||||
function _resp(oprequest, err, data) {
|
||||
let rc = getResultCode(err);
|
||||
|
@ -961,11 +961,11 @@ calWcapSession.prototype = {
|
|||
case calIWcapErrors.WCAP_NO_ERRNO: // workaround
|
||||
case calIWcapErrors.WCAP_ACCESS_DENIED_TO_CALENDAR:
|
||||
case calIWcapErrors.WCAP_CALENDAR_DOES_NOT_EXIST:
|
||||
log("getFreeBusyIntervals_resp() error: " + errorToString(err), this_);
|
||||
log("getFreeBusyIntervals_resp() error: " + errorToString(err), self);
|
||||
break;
|
||||
default:
|
||||
if (!Components.isSuccessCode(rc)) {
|
||||
this_.notifyError(err);
|
||||
self.notifyError(err);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1001,7 +1001,7 @@ calWcapSession.prototype = {
|
|||
}
|
||||
if (LOG_LEVEL > 0) {
|
||||
log("getFreeBusyIntervals net_resp(): " +
|
||||
getWcapRequestStatusString(xml), this_);
|
||||
getWcapRequestStatusString(xml), self);
|
||||
}
|
||||
if (listener) {
|
||||
let ret = [];
|
||||
|
|
|
@ -136,14 +136,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
let parser = this;
|
||||
let self = this;
|
||||
|
||||
// Takes a written day of the week and returns a js-date
|
||||
// corresponding to the nearest day in the future that is
|
||||
// that day of the week
|
||||
function getDateForDay(aWord) {
|
||||
for (let i in parser.mDayNames) {
|
||||
if (aWord != parser.mDayNames[i]) {
|
||||
for (let i in self.mDayNames) {
|
||||
if (aWord != self.mDayNames[i]) {
|
||||
continue;
|
||||
}
|
||||
// Figure out what day of the week today is.
|
||||
|
|
Загрузка…
Ссылка в новой задаче