Bug 1436199 - Include the gdata provider in eslint. r=MakeMyDay
MozReview-Commit-ID: 6LYTd7BIZTB
This commit is contained in:
Родитель
34f0e6d774
Коммит
2b6b9153a3
|
@ -34,9 +34,6 @@ suite/**
|
|||
calendar/lightning/content/lightning.js
|
||||
calendar/locales/en-US/lightning-l10n.js
|
||||
|
||||
# gdata-provider uses non-standard javascript for Postbox compatibility
|
||||
calendar/providers/gdata/**
|
||||
|
||||
# third party library
|
||||
calendar/base/modules/ical.js
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ ChromeUtils.import("resource://gdata-provider/modules/gdataRequest.jsm");
|
|||
ChromeUtils.import("resource://gdata-provider/modules/gdataSession.jsm");
|
||||
ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
|
||||
|
||||
var cICL = Components.interfaces.calIChangeLog;
|
||||
var cIOL = Components.interfaces.calIOperationListener;
|
||||
|
||||
var MIN_REFRESH_INTERVAL = 30;
|
||||
|
@ -60,9 +59,9 @@ calGoogleCalendar.prototype = {
|
|||
mCalendarName: null,
|
||||
mThrottle: null,
|
||||
mThrottleLimits: {
|
||||
"calendarList": 3600 * 1000,
|
||||
"events": 30 * 1000,
|
||||
"tasks": 30 * 1000
|
||||
calendarList: 3600 * 1000,
|
||||
events: 30 * 1000,
|
||||
tasks: 30 * 1000
|
||||
},
|
||||
|
||||
/* Public Members */
|
||||
|
@ -123,8 +122,9 @@ calGoogleCalendar.prototype = {
|
|||
if (aUri && aUri.schemeIs("googleapi")) {
|
||||
// new format: googleapi://session-id/?calendar=calhash@group.calendar.google.com&tasks=taskhash
|
||||
let [fullUser, path] = aUri.pathQueryRef.substr(2).split("/", 2);
|
||||
let parameters = new Map(path.substr(1).split("&").filter(Boolean)
|
||||
.map(function(x) { return x.split("=", 2).map(decodeURIComponent); }));
|
||||
let keyvalues = path.substr(1).split("&").filter(Boolean);
|
||||
let pairs = keyvalues.map(keyvalue => keyvalue.split("=", 2).map(decodeURIComponent));
|
||||
let parameters = new Map(pairs);
|
||||
|
||||
if (parameters.size == 0) {
|
||||
this.mCalendarName = fullUser;
|
||||
|
@ -152,7 +152,7 @@ calGoogleCalendar.prototype = {
|
|||
API_BASE.EVENTS = "http://localhost:" + port + "/calendar/v3/";
|
||||
API_BASE.TASKS = "http://localhost:" + port + "/tasks/v1/";
|
||||
}
|
||||
} else if (aUri && protocols.some(function(scheme) { return aUri.schemeIs(scheme); })) {
|
||||
} else if (aUri && protocols.some(scheme => aUri.schemeIs(scheme))) {
|
||||
// Parse google url, catch private cookies, public calendars,
|
||||
// basic and full types, bogus ics file extensions, invalid hostnames
|
||||
let re = new RegExp("/calendar/(feeds|ical)/" +
|
||||
|
@ -186,7 +186,7 @@ calGoogleCalendar.prototype = {
|
|||
return this.mUri;
|
||||
},
|
||||
|
||||
createEventsURI: function (...extraParts) {
|
||||
createEventsURI: function(...extraParts) {
|
||||
let eventsURI = null;
|
||||
if (this.mCalendarName) {
|
||||
let encodedName = encodeURIComponent(this.mCalendarName);
|
||||
|
@ -211,7 +211,7 @@ calGoogleCalendar.prototype = {
|
|||
return tasksURI;
|
||||
},
|
||||
|
||||
getUpdatedMin: function getUpdatedMin(aWhich) {
|
||||
getUpdatedMin: function(aWhich) {
|
||||
let updatedMin = null;
|
||||
let lastUpdated = this.getProperty("lastUpdated." + aWhich);
|
||||
if (lastUpdated) {
|
||||
|
@ -268,17 +268,18 @@ calGoogleCalendar.prototype = {
|
|||
return ["DEFAULT", "PUBLIC", "PRIVATE"];
|
||||
case "capabilities.alarms.maxCount":
|
||||
return 5;
|
||||
case "capabilities.alarms.actionValues":
|
||||
case "capabilities.alarms.actionValues": {
|
||||
let actionValues = ["DISPLAY", "EMAIL"];
|
||||
if (Preferences.get("calendar.google.enableSMSReminders", false)) {
|
||||
actionValues.push("SMS");
|
||||
}
|
||||
return actionValues;
|
||||
}
|
||||
case "capabilities.tasks.supported":
|
||||
return !!this.mTasklistName;
|
||||
case "capabilities.events.supported":
|
||||
return !!this.mCalendarName;
|
||||
case "readOnly":
|
||||
case "readOnly": {
|
||||
// If this calendar displays events, make it readonly if we are
|
||||
// not the owner or have write access.
|
||||
let accessRole = this.getProperty("settings.accessRole");
|
||||
|
@ -288,6 +289,7 @@ calGoogleCalendar.prototype = {
|
|||
}
|
||||
// Otherwise fall through
|
||||
break;
|
||||
}
|
||||
case "organizerId":
|
||||
return "mailto:" + this.mCalendarName;
|
||||
case "itip.transport":
|
||||
|
@ -322,7 +324,7 @@ calGoogleCalendar.prototype = {
|
|||
MIN_REFRESH_INTERVAL + " minutes would cause the quota " +
|
||||
"to be reached too fast.");
|
||||
this.superCalendar.setProperty("refreshInterval", 2 * MIN_REFRESH_INTERVAL);
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -332,8 +334,7 @@ calGoogleCalendar.prototype = {
|
|||
|
||||
addItem: function(aItem, aListener) { return this.adoptItem(aItem.clone(), aListener); },
|
||||
adoptItem: function(aItem, aListener) {
|
||||
function stackContains(part, max) {
|
||||
if (max === undefined) max = 8;
|
||||
function stackContains(part, max=8) {
|
||||
let stack = Components.stack.caller;
|
||||
while (stack && --max) {
|
||||
if (stack.filename && stack.filename.endsWith(part)) {
|
||||
|
@ -407,24 +408,24 @@ calGoogleCalendar.prototype = {
|
|||
await pcal.deleteItem(aItem);
|
||||
}
|
||||
return item;
|
||||
})().then(function(item) {
|
||||
})().then((item) => {
|
||||
cal.LOG("[calGoogleCalendar] Adding " + item.title + " succeeded");
|
||||
this.observers.notify("onAddItem", [item]);
|
||||
this.notifyOperationComplete(aListener, Components.results.NS_OK,
|
||||
cIOL.ADD, item.id, item);
|
||||
}.bind(this), function(e) {
|
||||
}, (e) => {
|
||||
let code = e.result || Components.results.NS_ERROR_FAILURE;
|
||||
cal.ERROR("[calGoogleCalendar] Adding Item " + aItem.title +
|
||||
" failed:" + code + ": " + e.message);
|
||||
this.notifyPureOperationComplete(aListener, code, cIOL.ADD, aItem.id, e.message);
|
||||
}.bind(this));
|
||||
});
|
||||
return request;
|
||||
},
|
||||
|
||||
modifyItem: function(aNewItem, aOldItem, aListener) {
|
||||
cal.LOG("[calGoogleCalendar] Modifying item " + aNewItem.title + " (" +
|
||||
(aNewItem.recurrenceId ? aNewItem.recurrenceId.icalString :
|
||||
"master item") + ")");
|
||||
(aNewItem.recurrenceId ? aNewItem.recurrenceId.icalString
|
||||
: "master item") + ")");
|
||||
|
||||
// Set up the request
|
||||
let request = new calGoogleRequest();
|
||||
|
@ -507,20 +508,19 @@ calGoogleCalendar.prototype = {
|
|||
}
|
||||
|
||||
return item;
|
||||
})().then(function (item) {
|
||||
})().then((item) => {
|
||||
cal.LOG("[calGoogleCalendar] Modifying " + aNewItem.title + " succeeded");
|
||||
this.observers.notify("onModifyItem", [item, aOldItem]);
|
||||
this.notifyOperationComplete(aListener, Components.results.NS_OK,
|
||||
cIOL.MODIFY, item.id, item);
|
||||
|
||||
}.bind(this), function(e) {
|
||||
}, (e) => {
|
||||
let code = e.result || Components.results.NS_ERROR_FAILURE;
|
||||
if (code != Components.interfaces.calIErrors.OPERATION_CANCELLED) {
|
||||
cal.ERROR("[calGoogleCalendar] Modifying item " + aNewItem.title +
|
||||
" failed:" + code + ": " + e.message);
|
||||
}
|
||||
this.notifyPureOperationComplete(aListener, code, cIOL.MODIFY, aNewItem.id, e.message);
|
||||
}.bind(this));
|
||||
});
|
||||
return request;
|
||||
},
|
||||
|
||||
|
@ -560,36 +560,36 @@ calGoogleCalendar.prototype = {
|
|||
if (e.result == calGoogleRequest.CONFLICT_MODIFY ||
|
||||
e.result == calGoogleRequest.CONFLICT_DELETED) {
|
||||
await checkResolveConflict(request, this, aItem);
|
||||
} else {
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deleteItemMetadata(this.offlineStorage, aItem);
|
||||
|
||||
return aItem;
|
||||
})().then(function (item) {
|
||||
})().then((item) => {
|
||||
cal.LOG("[calGoogleCalendar] Deleting " + aItem.title + " succeeded");
|
||||
this.observers.notify("onDeleteItem", [item]);
|
||||
this.notifyOperationComplete(aListener, Components.results.NS_OK,
|
||||
cIOL.DELETE, item.id, item);
|
||||
}.bind(this), function(e) {
|
||||
}, (e) => {
|
||||
let code = e.result || Components.results.NS_ERROR_FAILURE;
|
||||
if (code != Components.interfaces.calIErrors.OPERATION_CANCELLED) {
|
||||
cal.ERROR("[calGoogleCalendar] Deleting item " + aItem.title +
|
||||
" failed:" + code + ": " + e.message);
|
||||
}
|
||||
this.notifyPureOperationComplete(aListener, code, cIOL.DELETE, aItem.id, e.message);
|
||||
}.bind(this));
|
||||
});
|
||||
return request;
|
||||
},
|
||||
|
||||
getItem: function(aId, aListener) {
|
||||
this.mOfflineStorage.getItem.apply(this.mOfflineStorage, arguments);
|
||||
this.mOfflineStorage.getItem(...arguments);
|
||||
},
|
||||
|
||||
getItems: function(aFilter, aCount, aRangeStart, aRangeEnd, aListener) {
|
||||
this.mOfflineStorage.getItems.apply(this.mOfflineStorage, arguments);
|
||||
this.mOfflineStorage.getItems(...arguments);
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
|
@ -625,10 +625,10 @@ calGoogleCalendar.prototype = {
|
|||
|
||||
// Migration all done. Reset if requested.
|
||||
if (needsReset) {
|
||||
return this.resetSync().then(function() {
|
||||
return this.resetSync().then(() => {
|
||||
this.setProperty("cache.version", this.CACHE_DB_VERSION);
|
||||
return needsReset;
|
||||
}.bind(this));
|
||||
});
|
||||
} else {
|
||||
this.setProperty("cache.version", this.CACHE_DB_VERSION);
|
||||
return Promise.resolve(needsReset);
|
||||
|
@ -646,28 +646,29 @@ calGoogleCalendar.prototype = {
|
|||
},
|
||||
|
||||
resetLog: function() {
|
||||
this.resetSync().then(function() {
|
||||
this.resetSync().then(() => {
|
||||
this.mObservers.notify("onLoad", [this]);
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
|
||||
resetSync: function() {
|
||||
let deferred = PromiseUtils.defer();
|
||||
cal.LOG("[calGoogleCalendar] Resetting last updated counter for " + this.name);
|
||||
this.setProperty("syncToken.events", "");
|
||||
this.setProperty("lastUpdated.tasks", "");
|
||||
this.mThrottle = Object.create(null);
|
||||
this.mOfflineStorage.QueryInterface(Components.interfaces.calICalendarProvider)
|
||||
.deleteCalendar(this.mOfflineStorage, {
|
||||
onDeleteCalendar: function(aCalendar, aStatus, aDetail) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
deferred.resolve();
|
||||
} else {
|
||||
deferred.reject(aDetail);
|
||||
return new Promise((resolve, reject) => {
|
||||
cal.LOG("[calGoogleCalendar] Resetting last updated counter for " + this.name);
|
||||
this.setProperty("syncToken.events", "");
|
||||
this.setProperty("lastUpdated.tasks", "");
|
||||
this.mThrottle = Object.create(null);
|
||||
let listener = {
|
||||
onDeleteCalendar: function(aCalendar, aStatus, aDetail) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(aDetail);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
this.mOfflineStorage.QueryInterface(Components.interfaces.calICalendarProvider)
|
||||
.deleteCalendar(this.mOfflineStorage, listener);
|
||||
});
|
||||
},
|
||||
|
||||
replayChangesOn: function(aListener) {
|
||||
|
@ -696,21 +697,25 @@ calGoogleCalendar.prototype = {
|
|||
let calendarRequest = new calGoogleRequest();
|
||||
calendarRequest.calendar = this;
|
||||
calendarRequest.type = calendarRequest.GET;
|
||||
calendarRequest.uri = this.createUsersURI("calendarList", this.mCalendarName)
|
||||
calendarPromise = this.session.asyncItemRequest(calendarRequest).then(function(aData) {
|
||||
calendarRequest.uri = this.createUsersURI("calendarList", this.mCalendarName);
|
||||
calendarPromise = this.session.asyncItemRequest(calendarRequest).then((aData) => {
|
||||
if (aData.defaultReminders) {
|
||||
this.defaultReminders = aData.defaultReminders.map(function(x) { return JSONToAlarm(x, true); });
|
||||
this.defaultReminders = aData.defaultReminders.map(reminder => JSONToAlarm(reminder, true));
|
||||
} else {
|
||||
this.defaultReminders = [];
|
||||
}
|
||||
|
||||
for (let k of ["accessRole", "backgroundColor", "description",
|
||||
"foregroundColor", "location", "primary",
|
||||
"summary", "summaryOverride", "timeZone"]) {
|
||||
let settings = [
|
||||
"accessRole", "backgroundColor", "description",
|
||||
"foregroundColor", "location", "primary", "summary",
|
||||
"summaryOverride", "timeZone"
|
||||
];
|
||||
|
||||
for (let k of settings) {
|
||||
this.setProperty("settings." + k, aData[k]);
|
||||
}
|
||||
this.setProperty("settings.defaultReminders", JSON.stringify(aData.defaultReminders));
|
||||
}.bind(this));
|
||||
});
|
||||
}
|
||||
|
||||
// Set up a request for the events
|
||||
|
@ -727,19 +732,19 @@ calGoogleCalendar.prototype = {
|
|||
}
|
||||
if (eventsRequest.uri && this.checkThrottle("events")) {
|
||||
let saver = new ItemSaver(this);
|
||||
eventsPromise = this.session.asyncPaginatedRequest(eventsRequest, null, function(aData) {
|
||||
eventsPromise = this.session.asyncPaginatedRequest(eventsRequest, null, (aData) => {
|
||||
// On each request...
|
||||
return saver.parseItemStream(aData);
|
||||
}.bind(this), function(aData) {
|
||||
}, (aData) => {
|
||||
// On last request...
|
||||
return saver.complete().then(function() {
|
||||
return saver.complete().then(() => {
|
||||
if (aData.nextSyncToken) {
|
||||
cal.LOG("[calGoogleCalendar] New sync token for " +
|
||||
this.name + "(events) is now: " + aData.nextSyncToken);
|
||||
this.setProperty("syncToken.events", aData.nextSyncToken);
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Set up a request for tasks
|
||||
|
@ -756,46 +761,46 @@ calGoogleCalendar.prototype = {
|
|||
}
|
||||
if (tasksRequest.uri && this.checkThrottle("tasks")) {
|
||||
let saver = new ItemSaver(this);
|
||||
let lastUpdated = null;
|
||||
tasksPromise = this.session.asyncPaginatedRequest(tasksRequest, function(aData) {
|
||||
let newLastUpdated = null;
|
||||
tasksPromise = this.session.asyncPaginatedRequest(tasksRequest, (aData) => {
|
||||
// On the first request...
|
||||
lastUpdated = tasksRequest.requestDate.icalString;
|
||||
}.bind(this), function(aData) {
|
||||
newLastUpdated = tasksRequest.requestDate.icalString;
|
||||
}, (aData) => {
|
||||
// On each request...
|
||||
return saver.parseItemStream(aData);
|
||||
}.bind(this), function(aData) {
|
||||
}, (aData) => {
|
||||
// On last request...
|
||||
return saver.complete().then(function() {
|
||||
return saver.complete().then(() => {
|
||||
cal.LOG("[calGoogleCalendar] Last sync date for " + this.name +
|
||||
"(tasks) is now: " + tasksRequest.requestDate.toString());
|
||||
this.setProperty("lastUpdated.tasks", lastUpdated);
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
this.setProperty("newLastUpdated.tasks", newLastUpdated);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.all([calendarPromise, eventsPromise, tasksPromise]).then(function() {
|
||||
return Promise.all([calendarPromise, eventsPromise, tasksPromise]).then(() => {
|
||||
this.mOfflineStorage.endBatch();
|
||||
aListener.onResult({ status: Components.results.NS_OK }, null);
|
||||
}.bind(this), function(e) {
|
||||
}, (e) => {
|
||||
this.mOfflineStorage.endBatch();
|
||||
let code = e.result || Components.results.NS_ERROR_FAILURE;
|
||||
if (code == calGoogleRequest.RESOURCE_GONE) {
|
||||
cal.LOG("[calGoogleCalendar] Server did not accept " +
|
||||
"incremental update, resetting calendar and " +
|
||||
"starting over.");
|
||||
this.resetSync().then(function() {
|
||||
this.resetSync().then(() => {
|
||||
this.replayChangesOn(aListener);
|
||||
}.bind(this), function(e) {
|
||||
}, (err) => {
|
||||
cal.ERROR("[calGoogleCalendar] Error resetting calendar:\n" +
|
||||
stringException(e));
|
||||
aListener.onResult({ status: e.result }, e.message);
|
||||
}.bind(this));
|
||||
stringException(err));
|
||||
aListener.onResult({ status: err.result }, err.message);
|
||||
});
|
||||
} else {
|
||||
cal.LOG("[calGoogleCalendar] Error syncing:\n" + code + ":" +
|
||||
stringException(e));
|
||||
aListener.onResult({ status: code }, e.message);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -806,4 +811,4 @@ calGoogleCalendar.prototype = {
|
|||
canNotify: function(aMethod, aItem) { return true; }
|
||||
};
|
||||
|
||||
var NSGetFactory = XPCOMUtils.generateNSGetFactory([calGoogleCalendar]);
|
||||
var NSGetFactory = XPCOMUtils.generateNSGetFactory([calGoogleCalendar]); /* exported NSGetFactory */
|
||||
|
|
|
@ -2,119 +2,102 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
/* exported cancelRequest, loadRequestedUrl, reportUserClosed */
|
||||
|
||||
var wpl = Components.interfaces.nsIWebProgressListener;
|
||||
|
||||
var reporterListener = {
|
||||
_isBusy: false,
|
||||
get securityButton() {
|
||||
delete this.securityButton;
|
||||
return this.securityButton = document.getElementById("security-button");
|
||||
},
|
||||
_isBusy: false,
|
||||
get securityButton() {
|
||||
delete this.securityButton;
|
||||
return (this.securityButton = document.getElementById("security-button"));
|
||||
},
|
||||
|
||||
QueryInterface: function(aIID) {
|
||||
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
|
||||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
|
||||
aIID.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Components.interfaces.nsIWebProgressListener,
|
||||
Components.interfaces.nsISupportsWeakReference,
|
||||
]),
|
||||
|
||||
onStateChange: function(/*in nsIWebProgress*/ aWebProgress,
|
||||
/*in nsIRequest*/ aRequest,
|
||||
/*in unsigned long*/ aStateFlags,
|
||||
/*in nsresult*/ aStatus) {
|
||||
},
|
||||
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
|
||||
},
|
||||
|
||||
onProgressChange: function(/*in nsIWebProgress*/ aWebProgress,
|
||||
/*in nsIRequest*/ aRequest,
|
||||
/*in long*/ aCurSelfProgress,
|
||||
/*in long */aMaxSelfProgress,
|
||||
/*in long */aCurTotalProgress,
|
||||
/*in long */aMaxTotalProgress) {
|
||||
},
|
||||
onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress,
|
||||
aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) {
|
||||
},
|
||||
|
||||
onLocationChange: function(/*in nsIWebProgress*/ aWebProgress,
|
||||
/*in nsIRequest*/ aRequest,
|
||||
/*in nsIURI*/ aLocation) {
|
||||
document.getElementById("headerMessage").textContent = aLocation.spec;
|
||||
},
|
||||
onLocationChange: function(aWebProgress, aRequest, aLocation) {
|
||||
document.getElementById("headerMessage").textContent = aLocation.spec;
|
||||
},
|
||||
|
||||
onStatusChange: function(/*in nsIWebProgress*/ aWebProgress,
|
||||
/*in nsIRequest*/ aRequest,
|
||||
/*in nsresult*/ aStatus,
|
||||
/*in wstring*/ aMessage) {
|
||||
},
|
||||
onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage) {
|
||||
},
|
||||
|
||||
onSecurityChange: function(/*in nsIWebProgress*/ aWebProgress,
|
||||
/*in nsIRequest*/ aRequest,
|
||||
/*in unsigned long*/ aState) {
|
||||
const wpl_security_bits = wpl.STATE_IS_SECURE |
|
||||
wpl.STATE_IS_BROKEN |
|
||||
wpl.STATE_IS_INSECURE |
|
||||
wpl.STATE_SECURE_HIGH |
|
||||
wpl.STATE_SECURE_MED |
|
||||
wpl.STATE_SECURE_LOW;
|
||||
var browser = document.getElementById("requestFrame");
|
||||
var level;
|
||||
onSecurityChange: function(aWebProgress, aRequest, aState) {
|
||||
const wpl_security_bits = wpl.STATE_IS_SECURE |
|
||||
wpl.STATE_IS_BROKEN |
|
||||
wpl.STATE_IS_INSECURE |
|
||||
wpl.STATE_SECURE_HIGH |
|
||||
wpl.STATE_SECURE_MED |
|
||||
wpl.STATE_SECURE_LOW;
|
||||
let browser = document.getElementById("requestFrame");
|
||||
let level;
|
||||
|
||||
switch (aState & wpl_security_bits) {
|
||||
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_HIGH:
|
||||
level = "high";
|
||||
break;
|
||||
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_MED:
|
||||
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_LOW:
|
||||
level = "low";
|
||||
break;
|
||||
case wpl.STATE_IS_BROKEN:
|
||||
level = "broken";
|
||||
break;
|
||||
switch (aState & wpl_security_bits) {
|
||||
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_HIGH:
|
||||
level = "high";
|
||||
break;
|
||||
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_MED:
|
||||
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_LOW:
|
||||
level = "low";
|
||||
break;
|
||||
case wpl.STATE_IS_BROKEN:
|
||||
level = "broken";
|
||||
break;
|
||||
}
|
||||
if (level) {
|
||||
this.securityButton.setAttribute("level", level);
|
||||
this.securityButton.hidden = false;
|
||||
} else {
|
||||
this.securityButton.hidden = true;
|
||||
this.securityButton.removeAttribute("level");
|
||||
}
|
||||
this.securityButton.setAttribute("tooltiptext", browser.securityUI.tooltipText);
|
||||
}
|
||||
if (level) {
|
||||
this.securityButton.setAttribute("level", level);
|
||||
this.securityButton.hidden = false;
|
||||
};
|
||||
|
||||
function cancelRequest() {
|
||||
reportUserClosed();
|
||||
window.close();
|
||||
}
|
||||
|
||||
function reportUserClosed() {
|
||||
let request = window.arguments[0].wrappedJSObject;
|
||||
request.cancelled();
|
||||
}
|
||||
|
||||
function loadRequestedUrl() {
|
||||
let request = window.arguments[0].wrappedJSObject;
|
||||
document.getElementById("headerMessage").textContent = request.promptText;
|
||||
if (request.iconURI != "") {
|
||||
document.getElementById("headerImage").src = request.iconURI;
|
||||
}
|
||||
|
||||
let browser = document.getElementById("requestFrame");
|
||||
browser.addProgressListener(reporterListener,
|
||||
Components.interfaces.nsIWebProgress.NOTIFY_ALL);
|
||||
let url = request.url;
|
||||
if (url != "") {
|
||||
browser.setAttribute("src", url);
|
||||
document.getElementById("headerMessage").textContent = url;
|
||||
}
|
||||
|
||||
let dialogMessage = document.getElementById("dialogMessage");
|
||||
if (request.description) {
|
||||
dialogMessage.textContent = request.description;
|
||||
} else {
|
||||
this.securityButton.hidden = true;
|
||||
this.securityButton.removeAttribute("level");
|
||||
dialogMessage.setAttribute("hidden", "true");
|
||||
}
|
||||
this.securityButton.setAttribute("tooltiptext",
|
||||
browser.securityUI.tooltipText);
|
||||
}
|
||||
}
|
||||
|
||||
function cancelRequest()
|
||||
{
|
||||
reportUserClosed();
|
||||
window.close();
|
||||
}
|
||||
|
||||
function reportUserClosed()
|
||||
{
|
||||
let request = window.arguments[0].wrappedJSObject;
|
||||
request.cancelled();
|
||||
}
|
||||
|
||||
function loadRequestedUrl()
|
||||
{
|
||||
let request = window.arguments[0].wrappedJSObject;
|
||||
document.getElementById("headerMessage").textContent = request.promptText;
|
||||
let account = request.account;
|
||||
if (request.iconURI != "")
|
||||
document.getElementById("headerImage").src = request.iconURI;
|
||||
|
||||
var browser = document.getElementById("requestFrame");
|
||||
browser.addProgressListener(reporterListener,
|
||||
Components.interfaces.nsIWebProgress.NOTIFY_ALL);
|
||||
var url = request.url;
|
||||
if (url != "") {
|
||||
browser.setAttribute("src", url);
|
||||
document.getElementById("headerMessage").textContent = url;
|
||||
}
|
||||
|
||||
var dialogMessage = document.getElementById("dialogMessage");
|
||||
if (request.description) {
|
||||
dialogMessage.textContent = request.description;
|
||||
} else {
|
||||
dialogMessage.setAttribute("hidden", "true");
|
||||
}
|
||||
request.loaded(window, browser.webProgress);
|
||||
request.loaded(window, browser.webProgress);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
|
|||
function selectProvider(type) {
|
||||
let isGdata = (type == "gdata");
|
||||
let curi = document.getElementById("calendar-uri");
|
||||
let wizard = document.documentElement;
|
||||
|
||||
curi.parentNode.style.visibility = (isGdata ? "hidden" : "visible");
|
||||
document.getElementById("cache").parentNode.style.visibility = (isGdata ? "hidden" : "visible");
|
||||
|
@ -59,7 +58,7 @@ ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
|
|||
this.gdataSelectProvider = selectProvider;
|
||||
|
||||
if (typeof tmpCalendarCreation == "undefined") {
|
||||
monkeyPatch(window, "onSelectProvider", function(protofunc, type) {
|
||||
monkeyPatch(window, "onSelectProvider", (protofunc, type) => {
|
||||
selectProvider(type);
|
||||
return protofunc(type);
|
||||
});
|
||||
|
@ -69,7 +68,7 @@ ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
|
|||
// handler, which causes our provider to fail. Given the exchange
|
||||
// provider is currently not maintained and we want them to work
|
||||
// together, here is a workaround.
|
||||
monkeyPatch(tmpCalendarCreation, "doRadioExchangeCalendar", function(protofunc, target) {
|
||||
monkeyPatch(tmpCalendarCreation, "doRadioExchangeCalendar", (protofunc, target) => {
|
||||
// We need to run our function first, otherwise resetting the
|
||||
// pageorder will overwrite what the exchange provider does.
|
||||
selectProvider(target.value);
|
||||
|
@ -86,12 +85,12 @@ ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
|
|||
});
|
||||
}
|
||||
|
||||
monkeyPatch(window, "prepareCreateCalendar", function(protofunc) {
|
||||
let type = document.getElementById('calendar-format').selectedItem.value;
|
||||
monkeyPatch(window, "prepareCreateCalendar", (protofunc) => {
|
||||
let type = document.getElementById("calendar-format").selectedItem.value;
|
||||
return (type == "gdata" ? true : protofunc());
|
||||
});
|
||||
|
||||
monkeyPatch(window, "checkRequired", function(protofunc) {
|
||||
monkeyPatch(window, "checkRequired", (protofunc) => {
|
||||
let wizard = document.documentElement;
|
||||
let currentPageId = wizard.currentPage && wizard.currentPage.pageid;
|
||||
|
||||
|
@ -100,32 +99,33 @@ ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
|
|||
let sessionName = document.getElementById("gdata-session-name");
|
||||
let sessionNameIsValid = document.getAnonymousElementByAttribute(sessionName, "anonid", "input").validity.valid;
|
||||
// TODO for some reason the validity doesn't work on windows. Here is a hack:
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
sessionNameIsValid = !!sessionName.value.match(/^[^\/]+@[^\/]+\.[^\/]+$/);
|
||||
wizard.canAdvance = sessionGroup.value || (sessionName.value && sessionNameIsValid);
|
||||
} else if (currentPageId == "gdata-calendars") {
|
||||
let calendarList = document.getElementById("calendar-list");
|
||||
let calendars = calendarList.selectedCalendars.filter(function(x) { return !x.getProperty("disabled") && !x.readOnly; });
|
||||
let calendars = calendarList.selectedCalendars.filter(calendar => !calendar.getProperty("disabled") && !calendar.readOnly);
|
||||
wizard.canAdvance = !!calendars.length;
|
||||
} else {
|
||||
protofunc();
|
||||
}
|
||||
});
|
||||
|
||||
this.gdataSessionShow = trycatch(function() {
|
||||
this.gdataSessionShow = trycatch(() => {
|
||||
let sessionMgr = getGoogleSessionManager();
|
||||
let sessionContainer = document.getElementById("gdata-session-group");
|
||||
let newSessionItem = document.getElementById("session-new");
|
||||
let calendars = cal.getCalendarManager().getCalendars({});
|
||||
let sessions = new Set(calendars.map(function(calendar) {
|
||||
return sessionMgr.getSessionByCalendar(calendar, true);
|
||||
let sessions = new Set(calendars.map((calendar) => {
|
||||
return sessionMgr.getSessionByCalendar(calendar, true);
|
||||
}));
|
||||
|
||||
while (sessionContainer.firstChild.id != "session-new") {
|
||||
sessionContainer.removeChild(sessionContainer.firstChild);
|
||||
sessionContainer.firstChild.remove();
|
||||
}
|
||||
|
||||
// forEach is needed for backwards compatibility.
|
||||
sessions.forEach(function(session) {
|
||||
sessions.forEach((session) => {
|
||||
if (!session) {
|
||||
return;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
|
|||
}
|
||||
});
|
||||
|
||||
this.gdataCalendarsShow = trycatch(function() {
|
||||
this.gdataCalendarsShow = trycatch(() => {
|
||||
let calMgr = cal.getCalendarManager();
|
||||
let sessionMgr = getGoogleSessionManager();
|
||||
let sessionContainer = document.getElementById("gdata-session-group");
|
||||
|
@ -157,8 +157,7 @@ ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
|
|||
session = sessionMgr.getSessionById(newSessionItem.value, true);
|
||||
}
|
||||
|
||||
Promise.all([session.getTasksList(), session.getCalendarList()])
|
||||
.then(function([tasksLists, calendarList]) {
|
||||
Promise.all([session.getTasksList(), session.getCalendarList()]).then(([tasksLists, calendarList]) => {
|
||||
let existing = new Set();
|
||||
let sessionPrefix = "googleapi://" + session.id;
|
||||
for (let calendar of calMgr.getCalendars({})) {
|
||||
|
@ -174,7 +173,7 @@ ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
|
|||
}
|
||||
}
|
||||
|
||||
let taskcals = tasksLists.map(function(tasklist) {
|
||||
let taskcals = tasksLists.map((tasklist) => {
|
||||
let uri = "googleapi://" + session.id + "/?tasks=" + encodeURIComponent(tasklist.id);
|
||||
let calendar = calMgr.createCalendar("gdata", Services.io.newURI(uri));
|
||||
calendar.id = cal.getUUID();
|
||||
|
@ -185,7 +184,7 @@ ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
|
|||
}
|
||||
return calendar;
|
||||
});
|
||||
let calcals = calendarList.map(function(calendarEntry) {
|
||||
let calcals = calendarList.map((calendarEntry) => {
|
||||
let uri = "googleapi://" + session.id + "/?calendar=" + encodeURIComponent(calendarEntry.id);
|
||||
let calendar = calMgr.createCalendar("gdata", Services.io.newURI(uri));
|
||||
calendar.name = calendarEntry.summary;
|
||||
|
@ -203,25 +202,25 @@ ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
|
|||
.concat(taskcals);
|
||||
|
||||
calendarListWidget.calendars = calendars;
|
||||
}.bind(this), function(e) {
|
||||
}, (e) => {
|
||||
Components.utils.reportError(e);
|
||||
}.bind(this));
|
||||
});
|
||||
});
|
||||
|
||||
this.gdataCalendarsAdvance = trycatch(function() {
|
||||
this.gdataCalendarsAdvance = trycatch(() => {
|
||||
let calendarList = document.getElementById("calendar-list");
|
||||
let calendars = calendarList.selectedCalendars.filter(function(x) { return !x.getProperty("disabled") && !x.readOnly; });
|
||||
let calendars = calendarList.selectedCalendars.filter(calendar => !calendar.getProperty("disabled") && !calendar.readOnly);
|
||||
let calMgr = cal.getCalendarManager();
|
||||
calendars.forEach(calMgr.registerCalendar, calMgr);
|
||||
return true;
|
||||
});
|
||||
|
||||
this.gdataFocusNewSession = trycatch(function() {
|
||||
this.gdataFocusNewSession = trycatch(() => {
|
||||
let sessionContainer = document.getElementById("gdata-session-group");
|
||||
sessionContainer.value = "";
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Older versions of Lightning don't set the onselect attribute at all.
|
||||
let calendarFormat = document.getElementById("calendar-format");
|
||||
if (!calendarFormat.hasAttribute("onselect")) {
|
||||
|
|
|
@ -8,7 +8,6 @@ ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
|
|||
ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
|
||||
|
||||
(function() {
|
||||
|
||||
// Older versions of Lightning don't have this variable.
|
||||
if (!("gOldEndTimezone" in window)) {
|
||||
window.gOldEndTimezone = null;
|
||||
|
@ -83,7 +82,7 @@ ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
|
|||
if (isGoogleTask) {
|
||||
let floating = cal.dtz.floating;
|
||||
if (gEndTimezone != floating) {
|
||||
gOldEndTimezone = gEndTimezone;
|
||||
gOldEndTimezone = gEndTimezone;
|
||||
}
|
||||
gEndTimezone = cal.dtz.floating;
|
||||
gEndTime = gEndTime.getInTimezone(gEndTimezone);
|
||||
|
@ -115,7 +114,9 @@ ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
|
|||
if (!document.getElementById("item-categories-panel")) {
|
||||
let categoriesLabel = document.getElementById("event-grid-category-color-row").firstChild;
|
||||
let calendarLabel = document.getElementById("item-categories").nextSibling;
|
||||
if (!categoriesLabel.origLabel) categoriesLabel.origLabel = categoriesLabel.value;
|
||||
if (!categoriesLabel.origLabel) {
|
||||
categoriesLabel.origLabel = categoriesLabel.value;
|
||||
}
|
||||
|
||||
setBooleanAttribute("item-categories", "hidden", isGoogleTask);
|
||||
setBooleanAttribute(calendarLabel, "hidden", isGoogleTask);
|
||||
|
@ -134,9 +135,9 @@ ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
|
|||
let calendar = getCurrentCalendar();
|
||||
if (calendar.type == "gdata" && cal.item.isToDo(window.calendarItem)) {
|
||||
let unwrappedCal = calendar.getProperty("cache.uncachedCalendar").wrappedJSObject;
|
||||
unwrappedCal.mProperties['capabilities.categories.maxCount'] = 0;
|
||||
unwrappedCal.mProperties["capabilities.categories.maxCount"] = 0;
|
||||
rv = protofunc.apply(this, args);
|
||||
delete unwrappedCal.mProperties['capabilities.categories.maxCount'];
|
||||
delete unwrappedCal.mProperties["capabilities.categories.maxCount"];
|
||||
} else {
|
||||
rv = protofunc.apply(this, args);
|
||||
}
|
||||
|
@ -171,7 +172,7 @@ ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
|
|||
item.deleteProperty("X-DEFAULT-ALARM");
|
||||
return protofunc.apply(this, args);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
monkeyPatch(window, "loadReminders", function(protofunc, reminders, ...args) {
|
||||
let reminderList = document.getElementById("item-alarm");
|
||||
|
@ -186,7 +187,7 @@ ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
|
|||
let rv = null;
|
||||
let usesDefault;
|
||||
if (reminders.length) {
|
||||
usesDefault = reminders.every(function(x) { return x.hasProperty("X-DEFAULT-ALARM"); });
|
||||
usesDefault = reminders.every(reminder => reminder.hasProperty("X-DEFAULT-ALARM"));
|
||||
} else {
|
||||
usesDefault = window.calendarItem.getProperty("X-DEFAULT-ALARM") == "TRUE";
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
|
||||
// Don't allow setting refresh interval to less than 30 minutes
|
||||
let refInterval = document.getElementById("calendar-refreshInterval-menupopup");
|
||||
Array.from(refInterval.childNodes).filter(function(n) {
|
||||
let nv = parseInt(n.getAttribute("value"), 10);
|
||||
return nv < 30 && nv != 0;
|
||||
}).forEach(function(n) { refInterval.removeChild(n); });
|
||||
Array.from(refInterval.childNodes).filter((node) => {
|
||||
let nodeval = parseInt(node.getAttribute("value"), 10);
|
||||
return nodeval < 30 && nodeval != 0;
|
||||
}).forEach((node) => { refInterval.removeChild(node); });
|
||||
|
||||
// Old Lightning doesn't hide the cache label
|
||||
let oldCacheLabel = document.getElementById("cache");
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
notification.setAttribute("type", "critical");
|
||||
notification.setAttribute("hideclose", "true");
|
||||
|
||||
function calculateAlarmOffset(item, reminder) {
|
||||
let offset = cal.alarms.calculateAlarmOffset(item, reminder);
|
||||
function calculateAlarmOffset(alarmitem, reminder) {
|
||||
let offset = cal.alarms.calculateAlarmOffset(alarmitem, reminder);
|
||||
// bug 1196455: The offset calcuated for absolute alarms is flipped
|
||||
if (Services.vc.compare(Services.appinfo.platformVersion, "43.0") < 0) {
|
||||
if (reminder.related == reminder.ALARM_RELATED_ABSOLUTE) {
|
||||
|
@ -87,15 +87,15 @@
|
|||
event.explicitOriginalTarget.id == "reminder-remove-button" ||
|
||||
!document.commandDispatcher.focusedElement) {
|
||||
// Same hack from the original dialog
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
checkAllReminders();
|
||||
return rv;
|
||||
});
|
||||
|
||||
monkeyPatch(window, "loadReminders", function(protofunc /*, ...args */) {
|
||||
let rv = protofunc.apply(this, Array.from(arguments).slice(1));
|
||||
monkeyPatch(window, "loadReminders", function(protofunc, ...args) {
|
||||
let rv = protofunc.apply(this, args);
|
||||
checkAllReminders();
|
||||
hideReminderRelations();
|
||||
hideSMSReminders();
|
||||
|
|
|
@ -64,30 +64,30 @@
|
|||
|
||||
<implementation>
|
||||
<constructor><![CDATA[
|
||||
this.tree.view = this;
|
||||
this.tree.view = this;
|
||||
]]></constructor>
|
||||
|
||||
<property name="mockCalendarHeader" readonly="true">
|
||||
<getter><![CDATA[
|
||||
let calmgr = cal.getCalendarManager();
|
||||
let uri = "dummy://calendar";
|
||||
let mem = calmgr.createCalendar("memory", Services.io.newURI(uri));
|
||||
mem.setProperty("disabled", true);
|
||||
mem.name = "Calendars";
|
||||
mem.id = cal.getUUID();
|
||||
return mem;
|
||||
let calmgr = cal.getCalendarManager();
|
||||
let uri = "dummy://calendar";
|
||||
let mem = calmgr.createCalendar("memory", Services.io.newURI(uri));
|
||||
mem.setProperty("disabled", true);
|
||||
mem.name = "Calendars";
|
||||
mem.id = cal.getUUID();
|
||||
return mem;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<property name="mockTaskHeader" readonly="true">
|
||||
<getter><![CDATA[
|
||||
let calmgr = cal.getCalendarManager();
|
||||
let uri = "dummy://tasks";
|
||||
let mem = calmgr.createCalendar("memory", Services.io.newURI(uri));
|
||||
mem.setProperty("disabled", true);
|
||||
mem.name = "Task Lists";
|
||||
mem.id = cal.getUUID();
|
||||
return mem;
|
||||
let calmgr = cal.getCalendarManager();
|
||||
let uri = "dummy://tasks";
|
||||
let mem = calmgr.createCalendar("memory", Services.io.newURI(uri));
|
||||
mem.setProperty("disabled", true);
|
||||
mem.name = "Task Lists";
|
||||
mem.id = cal.getUUID();
|
||||
return mem;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
|
@ -98,43 +98,43 @@
|
|||
|
||||
<property name="calendars">
|
||||
<getter><![CDATA[
|
||||
return this.mCalendarList;
|
||||
return this.mCalendarList;
|
||||
]]></getter>
|
||||
<setter><![CDATA[
|
||||
for (let i = 0; i < val.length; i++) {
|
||||
let calendar = val[i];
|
||||
let spec = calendar.uri.spec;
|
||||
if (calendar.type == "memory") {
|
||||
if (spec == "dummy://calendar") {
|
||||
this.mCalendarHeaderIndex = i;
|
||||
} else if (spec == "dummy://tasks") {
|
||||
this.mTasksHeaderIndex = i;
|
||||
}
|
||||
}
|
||||
this.addCalendar(calendar);
|
||||
}
|
||||
return this.mCalendarList;
|
||||
for (let i = 0; i < val.length; i++) {
|
||||
let calendar = val[i];
|
||||
let spec = calendar.uri.spec;
|
||||
if (calendar.type == "memory") {
|
||||
if (spec == "dummy://calendar") {
|
||||
this.mCalendarHeaderIndex = i;
|
||||
} else if (spec == "dummy://tasks") {
|
||||
this.mTasksHeaderIndex = i;
|
||||
}
|
||||
}
|
||||
this.addCalendar(calendar);
|
||||
}
|
||||
return this.mCalendarList;
|
||||
]]></setter>
|
||||
</property>
|
||||
|
||||
<method name="removeCalendar">
|
||||
<parameter name="aCalendar"/>
|
||||
<body><![CDATA[
|
||||
let index = this.findIndexById(aCalendar.id);
|
||||
if (index < this.mCalendarHeaderIndex) {
|
||||
this.mCalendarHeaderIndex--;
|
||||
}
|
||||
if (index < this.mTasksHeaderIndex) {
|
||||
this.mTasksHeaderIndex--;
|
||||
}
|
||||
return this.__proto__.__proto__.removeCalendar.call(this, aCalendar);
|
||||
let index = this.findIndexById(aCalendar.id);
|
||||
if (index < this.mCalendarHeaderIndex) {
|
||||
this.mCalendarHeaderIndex--;
|
||||
}
|
||||
if (index < this.mTasksHeaderIndex) {
|
||||
this.mTasksHeaderIndex--;
|
||||
}
|
||||
return this.__proto__.__proto__.removeCalendar.call(this, aCalendar);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="clear">
|
||||
<body><![CDATA[
|
||||
let calendars = this.mCalendarList.concat([]);
|
||||
calendars.forEach(this.removeCalendar, this);
|
||||
let calendars = this.mCalendarList.concat([]);
|
||||
calendars.forEach(this.removeCalendar, this);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
@ -142,58 +142,58 @@
|
|||
<parameter name="aRow"/>
|
||||
<parameter name="aProps"/>
|
||||
<body><![CDATA[
|
||||
let props = this.__proto__.__proto__.getRowProperties.call(this, aRow, aProps);
|
||||
let calendar = this.getCalendar(aRow);
|
||||
let props = this.__proto__.__proto__.getRowProperties.call(this, aRow, aProps);
|
||||
let calendar = this.getCalendar(aRow);
|
||||
|
||||
if (calendar.readOnly) {
|
||||
if (aProps) {
|
||||
// Compatibility with old tree props code
|
||||
aProps.AppendElement(cal.getAtomFromService("checked"));
|
||||
} else {
|
||||
props += " checked";
|
||||
}
|
||||
}
|
||||
if (calendar.readOnly) {
|
||||
if (aProps) {
|
||||
// Compatibility with old tree props code
|
||||
aProps.AppendElement(cal.getAtomFromService("checked"));
|
||||
} else {
|
||||
props += " checked";
|
||||
}
|
||||
}
|
||||
|
||||
return props;
|
||||
return props;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="isContainerEmpty">
|
||||
<parameter name="aRow"/>
|
||||
<body><![CDATA[
|
||||
return (aRow == this.mCalendarHeaderIndex &&
|
||||
aRow + 1 == this.mTasksHeaderIndex) ||
|
||||
(aRow == this.mTasksHeaderIndex &&
|
||||
aRow == this.mCalendarList.length);
|
||||
return (aRow == this.mCalendarHeaderIndex &&
|
||||
aRow + 1 == this.mTasksHeaderIndex) ||
|
||||
(aRow == this.mTasksHeaderIndex &&
|
||||
aRow == this.mCalendarList.length);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="isContainer">
|
||||
<parameter name="aRow"/>
|
||||
<body><![CDATA[
|
||||
let calendar = this.getCalendar(aRow);
|
||||
return (calendar.type == "memory" && calendar.uri.schemeIs("dummy"));
|
||||
let calendar = this.getCalendar(aRow);
|
||||
return (calendar.type == "memory" && calendar.uri.schemeIs("dummy"));
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="isContainerOpen">
|
||||
<parameter name="aRow"/>
|
||||
<body><![CDATA[
|
||||
return true;
|
||||
return true;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="getParentIndex">
|
||||
<parameter name="aRow"/>
|
||||
<body><![CDATA[
|
||||
let calendar = this.getCalendar(aRow);
|
||||
if (calendar.uri.path.includes("?calendar")) {
|
||||
return this.mCalendarHeaderIndex;
|
||||
} else if (calendar.uri.path.includes("?tasks")) {
|
||||
return this.mTasksHeaderIndex;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
let calendar = this.getCalendar(aRow);
|
||||
if (calendar.uri.path.includes("?calendar")) {
|
||||
return this.mCalendarHeaderIndex;
|
||||
} else if (calendar.uri.path.includes("?tasks")) {
|
||||
return this.mTasksHeaderIndex;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
@ -201,14 +201,14 @@
|
|||
<parameter name="aRow"/>
|
||||
<parameter name="aAfterIndex"/>
|
||||
<body><![CDATA[
|
||||
if (aRow == this.mCalendarHeaderIndex) {
|
||||
return aAfterIndex < this.mTasksHeaderIndex;
|
||||
} else if (aRow == this.mTasksHeaderIndex) {
|
||||
return false;
|
||||
} else {
|
||||
return aAfterIndex != this.mCalendarHeaderIndex - 1 &&
|
||||
aAfterIndex != this.mTasksHeaderIndex - 1;
|
||||
}
|
||||
if (aRow == this.mCalendarHeaderIndex) {
|
||||
return aAfterIndex < this.mTasksHeaderIndex;
|
||||
} else if (aRow == this.mTasksHeaderIndex) {
|
||||
return false;
|
||||
} else {
|
||||
return aAfterIndex != this.mCalendarHeaderIndex - 1 &&
|
||||
aAfterIndex != this.mTasksHeaderIndex - 1;
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
@ -216,21 +216,21 @@
|
|||
<parameter name="aRow"/>
|
||||
<parameter name="aCol"/>
|
||||
<body><![CDATA[
|
||||
let calendar = this.getCalendar(aRow);
|
||||
let composite = this.compositeCalendar;
|
||||
if (composite.getCalendarById(calendar.id)) {
|
||||
composite.removeCalendar(calendar);
|
||||
} else {
|
||||
composite.addCalendar(calendar);
|
||||
}
|
||||
this.treebox.invalidateRow(aRow);
|
||||
let calendar = this.getCalendar(aRow);
|
||||
let composite = this.compositeCalendar;
|
||||
if (composite.getCalendarById(calendar.id)) {
|
||||
composite.removeCalendar(calendar);
|
||||
} else {
|
||||
composite.addCalendar(calendar);
|
||||
}
|
||||
this.treebox.invalidateRow(aRow);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="getLevel">
|
||||
<parameter name="aRow"/>
|
||||
<body><![CDATA[
|
||||
return this.isContainer(aRow) ? 0 : 1;
|
||||
return this.isContainer(aRow) ? 0 : 1;
|
||||
]]></body>
|
||||
</method>
|
||||
</implementation>
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Preferences.jsm");
|
||||
|
||||
/* exported migrateSelectedCalendars */
|
||||
|
||||
/**
|
||||
* Migrate the calendar selected in the wizard from ics to gdata.
|
||||
*/
|
||||
|
@ -55,12 +57,12 @@ function migrateSelectedCalendars() {
|
|||
* @return An array of calendars that are migratable
|
||||
*/
|
||||
function getMigratableCalendars() {
|
||||
function isMigratable(c) {
|
||||
function isMigratable(calendar) {
|
||||
let re = new RegExp("^http[s]?://www\\.google\\.com/calendar/ical/" +
|
||||
"[^/]+/(private(-[^/]+)?|public)/" +
|
||||
"(full|full-noattendees|composite|" +
|
||||
"attendees-only|free-busy|basic)(\\.ics)?$");
|
||||
return c.type == "ics" && c.uri.spec.match(re);
|
||||
return calendar.type == "ics" && calendar.uri.spec.match(re);
|
||||
}
|
||||
|
||||
return cal.getCalendarManager().getCalendars({}).filter(isMigratable);
|
||||
|
@ -83,25 +85,22 @@ function gdata_migration_loader() {
|
|||
// Set up the "always check" field
|
||||
document.getElementById("showagain-checkbox").checked =
|
||||
Preferences.get("calendar.google.migrate", true);
|
||||
} else {
|
||||
} else if (Preferences.get("calendar.google.migrate", true) &&
|
||||
getMigratableCalendars().length > 0) {
|
||||
// This is not the migration wizard, so it must be a main window. Check
|
||||
// if the migration wizard needs to be shown.
|
||||
if (Preferences.get("calendar.google.migrate", true)) {
|
||||
// Check if there are calendars that are worth migrating.
|
||||
if (getMigratableCalendars().length > 0) {
|
||||
// Do this after load, so the calendar window appears before the
|
||||
// wizard is opened.
|
||||
// if the migration wizard needs to be shown and calendars are worth
|
||||
// migrating.
|
||||
|
||||
// XXX Waiting a second gives the views enough time to display
|
||||
// right, at least on my system. The viewloaded event is quite
|
||||
// view specific, so there is no good non-hacked way to do this.
|
||||
setTimeout(function() {
|
||||
window.openDialog("chrome://gdata-provider/content/gdata-migration-wizard.xul",
|
||||
"GdataMigrationWizard",
|
||||
"chrome,titlebar,modal,alwaysRaised");
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
// Do this after load, so the calendar window appears before the
|
||||
// wizard is opened.
|
||||
// XXX Waiting a second gives the views enough time to display
|
||||
// right, at least on my system. The viewloaded event is quite
|
||||
// view specific, so there is no good non-hacked way to do this.
|
||||
setTimeout(() => {
|
||||
window.openDialog("chrome://gdata-provider/content/gdata-migration-wizard.xul",
|
||||
"GdataMigrationWizard",
|
||||
"chrome,titlebar,modal,alwaysRaised");
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
/**
|
||||
* Provides OAuth 2.0 authentication
|
||||
*/
|
||||
var EXPORTED_SYMBOLS = ["OAuth2"];
|
||||
|
||||
var {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
|
||||
var EXPORTED_SYMBOLS = ["OAuth2"]; /* exported OAuth2 */
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
@ -15,12 +13,12 @@ ChromeUtils.import("resource:///modules/gloda/log4moz.js");
|
|||
ChromeUtils.import("resource://gre/modules/Http.jsm");
|
||||
|
||||
function parseURLData(aData) {
|
||||
let result = {};
|
||||
aData.split(/[?#]/, 2)[1].split("&").forEach(function (aParam) {
|
||||
let [key, value] = aParam.split("=");
|
||||
result[key] = value;
|
||||
});
|
||||
return result;
|
||||
let result = {};
|
||||
aData.split(/[?#]/, 2)[1].split("&").forEach((aParam) => {
|
||||
let [key, value] = aParam.split("=");
|
||||
result[key] = value;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function OAuth2(aBaseURI, aScope, aAppKey, aAppSecret) {
|
||||
|
@ -54,7 +52,7 @@ OAuth2.prototype = {
|
|||
tokenExpires: 0,
|
||||
connecting: false,
|
||||
|
||||
connect: function connect(aSuccess, aFailure, aWithUI, aRefresh) {
|
||||
connect: function(aSuccess, aFailure, aWithUI, aRefresh) {
|
||||
if (this.connecting) {
|
||||
return;
|
||||
}
|
||||
|
@ -77,7 +75,7 @@ OAuth2.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
requestAuthorization: function requestAuthorization() {
|
||||
requestAuthorization: function() {
|
||||
let params = [
|
||||
["response_type", this.responseType],
|
||||
["client_id", this.consumerKey],
|
||||
|
@ -92,7 +90,7 @@ OAuth2.prototype = {
|
|||
Array.prototype.push.apply(params, this.extraAuthParams);
|
||||
|
||||
// Now map the parameters to a string
|
||||
params = params.map(function([k, v]) { return k + "=" + encodeURIComponent(v); }).join("&");
|
||||
params = params.map(([k, v]) => k + "=" + encodeURIComponent(v)).join("&");
|
||||
|
||||
this._browserRequest = {
|
||||
account: this,
|
||||
|
@ -109,7 +107,7 @@ OAuth2.prototype = {
|
|||
this.account.onAuthorizationFailed(Components.results.NS_ERROR_ABORT, '{ "error": "cancelled"}');
|
||||
},
|
||||
|
||||
loaded: function (aWindow, aWebProgress) {
|
||||
loaded: function(aWindow, aWebProgress) {
|
||||
if (!this._active) {
|
||||
return;
|
||||
}
|
||||
|
@ -119,56 +117,59 @@ OAuth2.prototype = {
|
|||
webProgress: aWebProgress,
|
||||
_parent: this.account,
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference]),
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Components.interfaces.nsIWebProgressListener,
|
||||
Components.interfaces.nsISupportsWeakReference
|
||||
]),
|
||||
|
||||
_cleanUp: function() {
|
||||
this.webProgress.removeProgressListener(this);
|
||||
this.window.close();
|
||||
delete this.window;
|
||||
this.webProgress.removeProgressListener(this);
|
||||
this.window.close();
|
||||
delete this.window;
|
||||
},
|
||||
|
||||
_checkForRedirect: function(aURL) {
|
||||
if (!aURL.startsWith(this._parent.completionURI)) {
|
||||
return;
|
||||
}
|
||||
if (!aURL.startsWith(this._parent.completionURI)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._parent.finishAuthorizationRequest();
|
||||
this._parent.onAuthorizationReceived(aURL);
|
||||
this._parent.finishAuthorizationRequest();
|
||||
this._parent.onAuthorizationReceived(aURL);
|
||||
},
|
||||
|
||||
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
|
||||
const wpl = Ci.nsIWebProgressListener;
|
||||
if (aStateFlags & (wpl.STATE_STOP)) {
|
||||
try {
|
||||
let httpchannel = aRequest.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
onStateChange: function(aChangedWebProgress, aRequest, aStateFlags, aStatus) {
|
||||
const wpl = Components.interfaces.nsIWebProgressListener;
|
||||
if (aStateFlags & (wpl.STATE_STOP)) {
|
||||
try {
|
||||
let httpchannel = aRequest.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
|
||||
let responseCategory = Math.floor(httpchannel.responseStatus / 100);
|
||||
let responseCategory = Math.floor(httpchannel.responseStatus / 100);
|
||||
|
||||
if (responseCategory != 2 && responseCategory != 3) {
|
||||
this._parent.finishAuthorizationRequest();
|
||||
this._parent.onAuthorizationFailed(null, '{ "error": "http_' + httpchannel.responseStatus + '" }');
|
||||
}
|
||||
} catch (e) {
|
||||
// Throw the case where it's a http channel.
|
||||
if (e.result != Components.results.NS_ERROR_NO_INTERFACE) {
|
||||
throw e;
|
||||
if (responseCategory != 2 && responseCategory != 3) {
|
||||
this._parent.finishAuthorizationRequest();
|
||||
this._parent.onAuthorizationFailed(null, '{ "error": "http_' + httpchannel.responseStatus + '" }');
|
||||
}
|
||||
} catch (e) {
|
||||
// Throw the case where it's a http channel.
|
||||
if (e.result != Components.results.NS_ERROR_NO_INTERFACE) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aStateFlags & (wpl.STATE_START | wpl.STATE_IS_NETWORK))
|
||||
this._checkForRedirect(aRequest.name);
|
||||
if (aStateFlags & (wpl.STATE_START | wpl.STATE_IS_NETWORK)) {
|
||||
this._checkForRedirect(aRequest.name);
|
||||
}
|
||||
},
|
||||
onLocationChange: function(aWebProgress, aRequest, aLocation) {
|
||||
this._checkForRedirect(aLocation.spec);
|
||||
onLocationChange: function(aChangedWebProgress, aRequest, aLocation) {
|
||||
this._checkForRedirect(aLocation.spec);
|
||||
},
|
||||
onProgressChange: function() {},
|
||||
onStatusChange: function() {},
|
||||
onSecurityChange: function() {},
|
||||
};
|
||||
aWebProgress.addProgressListener(this._listener,
|
||||
Ci.nsIWebProgress.NOTIFY_ALL);
|
||||
Components.interfaces.nsIWebProgress.NOTIFY_ALL);
|
||||
aWindow.document.title = this.account.requestWindowTitle;
|
||||
}
|
||||
};
|
||||
|
@ -203,7 +204,7 @@ OAuth2.prototype = {
|
|||
this.connectFailureCallback(aData);
|
||||
},
|
||||
|
||||
requestAccessToken: function requestAccessToken(aCode, aType) {
|
||||
requestAccessToken: function(aCode, aType) {
|
||||
let params = [
|
||||
["client_id", this.consumerKey],
|
||||
["client_secret", this.consumerSecret],
|
||||
|
@ -218,14 +219,14 @@ OAuth2.prototype = {
|
|||
}
|
||||
|
||||
let options = {
|
||||
postData: params,
|
||||
onLoad: this.onAccessTokenReceived.bind(this),
|
||||
onError: this.onAccessTokenFailed.bind(this)
|
||||
}
|
||||
postData: params,
|
||||
onLoad: this.onAccessTokenReceived.bind(this),
|
||||
onError: this.onAccessTokenFailed.bind(this)
|
||||
};
|
||||
httpRequest(this.tokenURI, options);
|
||||
},
|
||||
|
||||
onAccessTokenFailed: function onAccessTokenFailed(aError, aData) {
|
||||
onAccessTokenFailed: function(aError, aData) {
|
||||
if (aError != "offline") {
|
||||
this.refreshToken = null;
|
||||
}
|
||||
|
@ -233,7 +234,7 @@ OAuth2.prototype = {
|
|||
this.connectFailureCallback(aData);
|
||||
},
|
||||
|
||||
onAccessTokenReceived: function onRequestTokenReceived(aData) {
|
||||
onAccessTokenReceived: function(aData) {
|
||||
let result = JSON.parse(aData);
|
||||
|
||||
this.accessToken = result.access_token;
|
||||
|
|
|
@ -95,9 +95,11 @@ function LOGalarm(aAlarm) {
|
|||
|
||||
let enumerator = aAlarm.propertyEnumerator;
|
||||
let xpropstr = "";
|
||||
while (enumerator && enumerator.hasMoreElements()) {
|
||||
let el = enumerator.getNext();
|
||||
xpropstr += "\n\t\t\t" + el.key + ":" + el.value;
|
||||
if (enumerator) {
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let elem = enumerator.getNext();
|
||||
xpropstr += "\n\t\t\t" + elem.key + ":" + elem.value;
|
||||
}
|
||||
}
|
||||
|
||||
return ("\n\t\tAction: " + aAlarm.action +
|
||||
|
|
|
@ -110,7 +110,7 @@ calGoogleRequest.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
cancel: function cGR_cancel(aStatus) {
|
||||
cancel: function(aStatus) {
|
||||
if (this.isPending) {
|
||||
if (this.mLoader) {
|
||||
this.mLoader.request.cancel(aStatus);
|
||||
|
@ -126,13 +126,13 @@ calGoogleRequest.prototype = {
|
|||
*/
|
||||
get type() { return this.method; },
|
||||
|
||||
set type(v) {
|
||||
set type(val) {
|
||||
let valid = [this.GET, this.ADD, this.MODIFY, this.PATCH, this.DELETE];
|
||||
if (!valid.includes(v)) {
|
||||
throw new Components.Exception("Invalid request type: " + v,
|
||||
if (!valid.includes(val)) {
|
||||
throw new Components.Exception("Invalid request type: " + val,
|
||||
Components.results.NS_ERROR_ILLEGAL_VALUE);
|
||||
}
|
||||
return (this.method = v);
|
||||
return (this.method = val);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -142,12 +142,12 @@ calGoogleRequest.prototype = {
|
|||
* @param aContentType The Content type of the Data.
|
||||
* @param aData The Data to upload.
|
||||
*/
|
||||
setUploadData: function cGR_setUploadData(aContentType, aData) {
|
||||
setUploadData: function(aContentType, aData) {
|
||||
this.mUploadContent = aContentType;
|
||||
this.mUploadData = aData;
|
||||
},
|
||||
|
||||
addQueryParameter: function cGR_addQueryParameter(aKey, aValue) {
|
||||
addQueryParameter: function(aKey, aValue) {
|
||||
if (aValue) {
|
||||
this.mQueryParameters.set(aKey, aValue);
|
||||
} else {
|
||||
|
@ -155,7 +155,7 @@ calGoogleRequest.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
addRequestHeader: function cGR_addRequestHeader(aKey, aValue) {
|
||||
addRequestHeader: function(aKey, aValue) {
|
||||
if (aValue) {
|
||||
this.mRequestHeaders.set(aKey, aValue);
|
||||
} else {
|
||||
|
@ -171,7 +171,7 @@ calGoogleRequest.prototype = {
|
|||
* @param aSession The session object this request should be made with.
|
||||
* This parameter is optional.
|
||||
*/
|
||||
commit: function cGR_commit(aSession) {
|
||||
commit: function(aSession) {
|
||||
if (!this.mDeferred) {
|
||||
this.mDeferred = PromiseUtils.defer();
|
||||
}
|
||||
|
@ -189,8 +189,8 @@ calGoogleRequest.prototype = {
|
|||
let params = [];
|
||||
|
||||
// Using forEach is needed for backwards compatibility
|
||||
this.mQueryParameters.forEach(function(v, k) {
|
||||
params.push(k + "=" + encodeURIComponent(v));
|
||||
this.mQueryParameters.forEach((val, key) => {
|
||||
params.push(key + "=" + encodeURIComponent(val));
|
||||
});
|
||||
uristring += "?" + params.join("&");
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ calGoogleRequest.prototype = {
|
|||
* @param aMessage The Error message. If this is null, an error Message
|
||||
* from calGoogleRequest will be used.
|
||||
*/
|
||||
fail: function cGR_fail(aCode, aMessage) {
|
||||
fail: function(aCode, aMessage) {
|
||||
let ex = new Components.Exception(aMessage, aCode);
|
||||
this.mLoader = null;
|
||||
this.mStatus = aCode;
|
||||
|
@ -249,7 +249,7 @@ calGoogleRequest.prototype = {
|
|||
*
|
||||
* @param aResult The result Text of this request.
|
||||
*/
|
||||
succeed: function cGR_succeed(aResult) {
|
||||
succeed: function(aResult) {
|
||||
this.mLoader = null;
|
||||
this.mStatus = Components.results.NS_OK;
|
||||
this.mDeferred.resolve(aResult);
|
||||
|
@ -262,14 +262,14 @@ calGoogleRequest.prototype = {
|
|||
*
|
||||
* @param aChannel The Channel to be prepared.
|
||||
*/
|
||||
prepareChannel: function cGR_prepareChannel(aChannel) {
|
||||
prepareChannel: function(aChannel) {
|
||||
// No caching
|
||||
aChannel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
|
||||
// Set upload Data
|
||||
if (this.mUploadData) {
|
||||
let converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].
|
||||
createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
|
||||
let converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
|
||||
.createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
|
||||
converter.charset = "UTF-8";
|
||||
|
||||
let stream = converter.convertToInputStream(this.mUploadData);
|
||||
|
@ -286,7 +286,6 @@ calGoogleRequest.prototype = {
|
|||
// get around some proxies. This will default to true.
|
||||
if (Preferences.get("calendar.google.useHTTPMethodOverride", true) &&
|
||||
(this.method == "PUT" || this.method == "DELETE")) {
|
||||
|
||||
aChannel.requestMethod = "POST";
|
||||
aChannel.setRequestHeader("X-HTTP-Method-Override",
|
||||
this.method,
|
||||
|
@ -308,8 +307,8 @@ calGoogleRequest.prototype = {
|
|||
}
|
||||
|
||||
// Using forEach is needed for backwards compatibility
|
||||
this.mRequestHeaders.forEach(function(v, k) {
|
||||
aChannel.setRequestHeader(k, v, false);
|
||||
this.mRequestHeaders.forEach((val, key) => {
|
||||
aChannel.setRequestHeader(key, val, false);
|
||||
});
|
||||
|
||||
// Add Authorization
|
||||
|
@ -333,10 +332,7 @@ calGoogleRequest.prototype = {
|
|||
/**
|
||||
* @see nsIChannelEventSink
|
||||
*/
|
||||
asyncOnChannelRedirect: function cGR_onChannelRedirect(aOldChannel,
|
||||
aNewChannel,
|
||||
aFlags,
|
||||
aCallback) {
|
||||
asyncOnChannelRedirect: function(aOldChannel, aNewChannel, aFlags, aCallback) {
|
||||
// all we need to do to the new channel is the basic preparation
|
||||
this.prepareChannel(aNewChannel);
|
||||
aCallback.onRedirectVerifyCallback(Components.results.NS_OK);
|
||||
|
@ -345,11 +341,7 @@ calGoogleRequest.prototype = {
|
|||
/**
|
||||
* @see nsIStreamLoaderObserver
|
||||
*/
|
||||
onStreamComplete: function cGR_onStreamComplete(aLoader,
|
||||
aContext,
|
||||
aStatus,
|
||||
aResultLength,
|
||||
aResult) {
|
||||
onStreamComplete: function(aLoader, aContext, aStatus, aResultLength, aResult) {
|
||||
if (!aResult || !Components.isSuccessCode(aStatus)) {
|
||||
this.fail(aStatus, aResult);
|
||||
return;
|
||||
|
@ -397,8 +389,8 @@ calGoogleRequest.prototype = {
|
|||
this.requestDate.nativeTime = serverDate.getTime() * 1000;
|
||||
|
||||
cal.LOG("[calGoogleCalendar] Request " + this.method + " " +
|
||||
httpChannel.URI.spec + " responded with HTTP "
|
||||
+ httpChannel.responseStatus);
|
||||
httpChannel.URI.spec + " responded with HTTP " +
|
||||
httpChannel.responseStatus);
|
||||
|
||||
// Handle all (documented) error codes
|
||||
switch (httpChannel.responseStatus) {
|
||||
|
@ -438,7 +430,7 @@ calGoogleRequest.prototype = {
|
|||
// once.
|
||||
this.mSession.invalidate();
|
||||
if (this.reauthenticate) {
|
||||
cal.LOG("[calGoogleRequest] The access token is not authorized, trying to refresh token.")
|
||||
cal.LOG("[calGoogleRequest] The access token is not authorized, trying to refresh token.");
|
||||
this.reauthenticate = false;
|
||||
this.mSession.asyncItemRequest(this);
|
||||
} else {
|
||||
|
@ -515,7 +507,7 @@ calGoogleRequest.prototype = {
|
|||
}
|
||||
}
|
||||
// Otherwise fall through
|
||||
default:
|
||||
default: {
|
||||
// The following codes are caught here:
|
||||
// 500 INTERNAL SERVER ERROR: Internal error. This is the
|
||||
// default code that is used for
|
||||
|
@ -531,6 +523,7 @@ calGoogleRequest.prototype = {
|
|||
|
||||
this.fail(Components.results.NS_ERROR_NOT_AVAILABLE, msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -41,19 +41,25 @@ var calGoogleSessionManager = {
|
|||
getSessionByCalendar: function(aCalendar, aCreate) {
|
||||
let id = null;
|
||||
let uri = aCalendar.uri;
|
||||
let host = (function() { try { return uri.host; } catch (e) {} })();
|
||||
let host = (function() {
|
||||
try {
|
||||
return uri.host;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
const protocols = ["http", "https", "webcal", "webcals"];
|
||||
|
||||
if (aCalendar.type != "gdata") {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (uri.schemeIs("googleapi")) {
|
||||
let [fullUser, path] = uri.pathQueryRef.substr(2).split("/", 2);
|
||||
id = fullUser || cal.getUUID();
|
||||
} else if (host == "www.google.com" && uri.pathQueryRef.startsWith("/calendar/feeds") && protocols.some(function(s) { return uri.schemeIs(s); })) {
|
||||
let parts = uri.pathQueryRef.substr(2).split("/", 2);
|
||||
id = parts[0] || cal.getUUID();
|
||||
} else if (host == "www.google.com" && uri.pathQueryRef.startsWith("/calendar/feeds") && protocols.some(scheme => uri.schemeIs(scheme))) {
|
||||
let googleCalendarName = aCalendar.getProperty("googleCalendarName");
|
||||
let googleUser = Preferences.get("calendar.google.calPrefs." + googleCalendarName + ".googleUser");
|
||||
let googleUser = Preferences.get("calendar.google.calPrefs." + googleCalendarName + ".googleUser");
|
||||
id = googleUser || googleCalendarName || cal.getUUID();
|
||||
}
|
||||
|
||||
|
@ -101,7 +107,6 @@ calGoogleSession.prototype = {
|
|||
|
||||
notifyQuotaExceeded: function() {
|
||||
let now = new Date();
|
||||
let tt = (now - this.mLastNotified);
|
||||
if (!this.mLastNotified || (now - this.mLastNotified) > NOTIFY_TIMEOUT) {
|
||||
this.mLastNotified = now;
|
||||
let title = getProviderString("extensions.{a62ef8ec-5fdc-40c2-873c-223b8a6925cc}.name");
|
||||
|
@ -114,7 +119,6 @@ calGoogleSession.prototype = {
|
|||
|
||||
notifyOutdated: function() {
|
||||
let now = new Date();
|
||||
let tt = (now - this.mLastNotified);
|
||||
if (!this.mLastNotified || (now - this.mLastNotified) > NOTIFY_TIMEOUT) {
|
||||
this.mLastNotified = now;
|
||||
let title = getProviderString("extensions.{a62ef8ec-5fdc-40c2-873c-223b8a6925cc}.name");
|
||||
|
@ -125,7 +129,7 @@ calGoogleSession.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
setupOAuth: function setupOAuth() {
|
||||
setupOAuth: function() {
|
||||
let sessionId = this.mId;
|
||||
let authDescr = getProviderString("requestWindowDescription", sessionId);
|
||||
let authTitle = getProviderString("requestWindowTitle", sessionId);
|
||||
|
@ -146,7 +150,7 @@ calGoogleSession.prototype = {
|
|||
// the password manager
|
||||
let pwMgrId = "Google Calendar OAuth Token";
|
||||
Object.defineProperty(this.oauth, "refreshToken", {
|
||||
get: function getRefreshToken() {
|
||||
get: function() {
|
||||
if (!this.mRefreshToken) {
|
||||
let pass = { value: null };
|
||||
try {
|
||||
|
@ -162,7 +166,7 @@ calGoogleSession.prototype = {
|
|||
}
|
||||
return this.mRefreshToken;
|
||||
},
|
||||
set: function setRefreshToken(val) {
|
||||
set: function(val) {
|
||||
try {
|
||||
let origin = "oauth:" + sessionId;
|
||||
if (val) {
|
||||
|
@ -213,7 +217,7 @@ calGoogleSession.prototype = {
|
|||
/**
|
||||
* Resets the access token, it will be re-retrieved on the next request.
|
||||
*/
|
||||
invalidate: function cGS_invalidate() {
|
||||
invalidate: function() {
|
||||
cal.LOG("[calGoogleSession] Invalidating session, will reauthenticate on next request");
|
||||
this.oauth.accessToken = null;
|
||||
},
|
||||
|
@ -231,7 +235,6 @@ calGoogleSession.prototype = {
|
|||
// Start logging in
|
||||
cal.LOG("[calGoogleCalendar] Logging in session " + this.mId);
|
||||
let accessToken = this.accessToken;
|
||||
let refreshToken = this.refreshToken;
|
||||
|
||||
let authSuccess = function() {
|
||||
cal.LOG("[calGoogleCalendar] Successfully acquired a new" +
|
||||
|
@ -315,13 +318,13 @@ calGoogleSession.prototype = {
|
|||
cal.LOG("[calGoogleCalendar] Error Logging In: " + e);
|
||||
deferred.reject(e);
|
||||
}
|
||||
return deferred.promise.then(function(accessToken) {
|
||||
return deferred.promise.then((accessToken) => {
|
||||
this.mLoginPromise = null;
|
||||
return accessToken;
|
||||
}.bind(this), function(e) {
|
||||
}, (e) => {
|
||||
this.mLoginPromise = null;
|
||||
throw e;
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -331,7 +334,7 @@ calGoogleSession.prototype = {
|
|||
* @param aRequest The Request Object. This is an instance of
|
||||
* calGoogleRequest.
|
||||
*/
|
||||
asyncItemRequest: function cGS_asyncItemRequest(aRequest) {
|
||||
asyncItemRequest: function(aRequest) {
|
||||
let tokenExpiresIn = Math.floor((this.oauth.tokenExpires - (new Date()).getTime()) / 1000);
|
||||
if (tokenExpiresIn < 0 && !this.mLoginPromise) {
|
||||
cal.LOG("[calGoogleSession] Token expired " + (-tokenExpiresIn) + " seconds ago, resetting");
|
||||
|
@ -344,7 +347,7 @@ calGoogleSession.prototype = {
|
|||
if (tokenExpiresIn < 30 && !this.mLoginPromise) {
|
||||
cal.LOG("[calGoogleSession] Token will expire in " + tokenExpiresIn + " seconds, refreshing");
|
||||
this.mLoginPromise = this.login();
|
||||
this.mLoginPromise.then(function() {
|
||||
this.mLoginPromise.then(() => {
|
||||
cal.LOG("[calGoogleSession] Premature token refresh completed");
|
||||
});
|
||||
}
|
||||
|
@ -352,9 +355,9 @@ calGoogleSession.prototype = {
|
|||
} else if (this.mLoginPromise) {
|
||||
// We are logging in and have no token, queue the request
|
||||
cal.LOG("[calGoogleSession] Adding item " + aRequest.uri + " to queue");
|
||||
return this.mLoginPromise.then(function() {
|
||||
return this.mLoginPromise.then(() => {
|
||||
return aRequest.commit(this);
|
||||
}.bind(this), function(e) {
|
||||
}, (e) => {
|
||||
// If the user cancelled the login dialog, then disable the
|
||||
// calendar until the next startup or manual enable.
|
||||
if (aRequest.calendar && e.message == "cancelled") {
|
||||
|
@ -365,7 +368,7 @@ calGoogleSession.prototype = {
|
|||
}
|
||||
|
||||
throw e;
|
||||
}.bind(this));
|
||||
});
|
||||
} else {
|
||||
// Not logging in and no token, get the login promise and retry.
|
||||
this.mLoginPromise = this.login();
|
||||
|
@ -384,36 +387,37 @@ calGoogleSession.prototype = {
|
|||
await onEach(data);
|
||||
}
|
||||
|
||||
// In bug 1410672 it turns out this doesn't work without return await
|
||||
/* eslint-disable no-return-await */
|
||||
if (data.nextPageToken) {
|
||||
aRequest.addQueryParameter("pageToken", data.nextPageToken);
|
||||
return await this.asyncPaginatedRequest(aRequest, null, onEach, onLast);
|
||||
} else if (onLast) {
|
||||
return await onLast(data);
|
||||
}
|
||||
/* eslint-enable no-return-await */
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* calIFreeBusyProvider Implementation
|
||||
*/
|
||||
getFreeBusyIntervals: function cGS_getFreeBusyIntervals(aCalId,
|
||||
aRangeStart,
|
||||
aRangeEnd,
|
||||
aBusyTypes,
|
||||
aListener) {
|
||||
let completeSync = function(aIntervals) {
|
||||
getFreeBusyIntervals: function(aCalId, aRangeStart, aRangeEnd, aBusyTypes, aListener) {
|
||||
let completeSync = (aIntervals) => {
|
||||
cal.LOG("[calGoogleCalendar] Freebusy query for " + aCalId +
|
||||
"suceeded, returning " + aIntervals.length + " intervals");
|
||||
aListener.onResult({ status: Components.results.NS_OK }, aIntervals);
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
let failSync = function(aStatus, aMessage) {
|
||||
let failSync = (aStatus, aMessage) => {
|
||||
cal.LOG("[calGoogleCalendar] Freebusy query for " + aCalId +
|
||||
" failed (" + aStatus + "): " + aMessage);
|
||||
|
||||
// Usually we would notify with a result, but this causes trouble
|
||||
// with Lightning 3.9 and older.
|
||||
aListener.onResult({ status: aStatus }, null);
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
if (!aCalId.includes("@") || !aCalId.includes(".") ||
|
||||
!aCalId.toLowerCase().startsWith("mailto:")) {
|
||||
|
@ -434,9 +438,9 @@ calGoogleSession.prototype = {
|
|||
let strippedCalId = aCalId.substr(7);
|
||||
|
||||
let requestData = {
|
||||
timeMin: rfcRangeStart,
|
||||
timeMax: rfcRangeEnd,
|
||||
items: [ { id: strippedCalId } ]
|
||||
timeMin: rfcRangeStart,
|
||||
timeMax: rfcRangeEnd,
|
||||
items: [{ id: strippedCalId }]
|
||||
};
|
||||
|
||||
let request = new calGoogleRequest();
|
||||
|
@ -448,7 +452,7 @@ calGoogleSession.prototype = {
|
|||
JSON.stringify(requestData));
|
||||
|
||||
// Request Parameters
|
||||
this.asyncItemRequest(request).then(function(aData) {
|
||||
this.asyncItemRequest(request).then((aData) => {
|
||||
if ("calendars" in aData && strippedCalId in aData.calendars) {
|
||||
let calData = aData.calendars[strippedCalId];
|
||||
let reason = calData.errors && calData.errors[0] && calData.errors[0].reason;
|
||||
|
@ -458,7 +462,7 @@ calGoogleSession.prototype = {
|
|||
} else {
|
||||
let utcZone = cal.dtz.UTC;
|
||||
cal.LOG("[calGoogleCalendar] Found " + calData.busy.length + " busy slots within range for " + strippedCalId);
|
||||
let busyRanges = calData.busy.map(function(entry) {
|
||||
let busyRanges = calData.busy.map((entry) => {
|
||||
let start = cal.fromRFC3339(entry.start, utcZone);
|
||||
let end = cal.fromRFC3339(entry.end, utcZone);
|
||||
let interval = new cal.FreeBusyInterval(aCalId, cIFBI.BUSY, start, end);
|
||||
|
@ -471,10 +475,10 @@ calGoogleSession.prototype = {
|
|||
cal.ERROR("[calGoogleCalendar] Invalid freebusy response: " + aData.toSource());
|
||||
failSync(Components.results.NS_ERROR_FAILURE, (aData && aData.toSource()));
|
||||
}
|
||||
}.bind(this), function(e) {
|
||||
}, (e) => {
|
||||
cal.ERROR("[calGoogleCalendar] Failed freebusy request: " + e);
|
||||
return failSync(request.status, null);
|
||||
}.bind(this));
|
||||
});
|
||||
|
||||
return request;
|
||||
},
|
||||
|
@ -485,11 +489,11 @@ calGoogleSession.prototype = {
|
|||
calendarRequest.uri = API_BASE.EVENTS + "users/me/calendarList";
|
||||
|
||||
let items = [];
|
||||
return this.asyncPaginatedRequest(calendarRequest, null, function(data) {
|
||||
Array.prototype.push.apply(items, data.items);
|
||||
}.bind(this), function() {
|
||||
return this.asyncPaginatedRequest(calendarRequest, null, (data) => {
|
||||
items.push(...data.items);
|
||||
}, () => {
|
||||
return items;
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
|
||||
getTasksList: function() {
|
||||
|
@ -497,11 +501,11 @@ calGoogleSession.prototype = {
|
|||
tasksRequest.type = tasksRequest.GET;
|
||||
tasksRequest.uri = API_BASE.TASKS + "users/@me/lists";
|
||||
let items = [];
|
||||
return this.asyncPaginatedRequest(tasksRequest, null, function(data) {
|
||||
Array.prototype.push.apply(items, data.items);
|
||||
}.bind(this), function() {
|
||||
return this.asyncPaginatedRequest(tasksRequest, null, (data) => {
|
||||
items.push(...data.items);
|
||||
}, () => {
|
||||
return items;
|
||||
}.bind(this));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -515,6 +519,7 @@ calGoogleSession.prototype = {
|
|||
//
|
||||
// Do you really want all of this to be your fault? Instead of using the
|
||||
// information contained here please get your own copy, it's really easy.
|
||||
/* eslint-disable */
|
||||
(zqdx=>{zqdx["\x65\x76\x61\x6C"](zqdx["\x41\x72\x72\x61\x79"]["\x70\x72\x6F\x74"+
|
||||
"\x6F\x74\x79\x70\x65"]["\x6D\x61\x70"]["\x63\x61\x6C\x6C"]("uijt/PBVUI`CBTF`VS"+
|
||||
"J>#iuuqt;00bddpvout/hpphmf/dpn0p0#<uijt/PBVUI`TDPQF>#iuuqt;00xxx/hpphmfbqjt/dp"+
|
||||
|
@ -525,3 +530,4 @@ calGoogleSession.prototype = {
|
|||
"\x43\x6F\x64\x65\x41\x74"](0)-1),this)[""+"\x6A\x6F\x69\x6E"](""))})["\x63\x61"+
|
||||
"\x6C\x6C"]((this),Components["\x75\x74\x69\x6c\x73"]["\x67\x65\x74\x47\x6c\x6f"+
|
||||
"\x62\x61\x6c\x46\x6f\x72\x4f\x62\x6a\x65\x63\x74"](this));
|
||||
/* eslint-enable */
|
||||
|
|
|
@ -82,7 +82,7 @@ function migrateItemMetadata(aOfflineStorage, aOldItem, aNewItem, aMetadata) {
|
|||
|
||||
// If an exception was turned into an EXDATE, we need to clear its metadata
|
||||
if (aOldItem.recurrenceInfo && aNewItem.recurrenceInfo) {
|
||||
let newExIds = new Set(aNewItem.recurrenceInfo.getExceptionIds({}).map(function(x) { return x.icalString; }));
|
||||
let newExIds = new Set(aNewItem.recurrenceInfo.getExceptionIds({}).map(exception => exception.icalString));
|
||||
for (let exId of aOldItem.recurrenceInfo.getExceptionIds({})) {
|
||||
if (!newExIds.has(exId.icalString)) {
|
||||
let ex = aOldItem.recurrenceInfo.getExceptionFor(exId);
|
||||
|
@ -123,7 +123,7 @@ function getItemMetadata(aOfflineStorage, aItem) {
|
|||
data = { etag: parts[0], path: parts[1] };
|
||||
} else if (parts && parts.length == 1) {
|
||||
// Temporary migration for alpha versions of this provider.
|
||||
data = { etag: parts[0], path: aItem.getProperty("X-GOOGLE-ID") }
|
||||
data = { etag: parts[0], path: aItem.getProperty("X-GOOGLE-ID") };
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ function dateToJSON(aDate) {
|
|||
if (tzid in windowsTimezoneMap) {
|
||||
// A Windows timezone, likely an outlook invitation.
|
||||
jsonData.timeZone = windowsTimezoneMap[tzid];
|
||||
} else if (tzid.match(/^[^\/ ]+(\/[^\/ ]+){1,2}$/)) {
|
||||
} else if (tzid.match(/^[^\/ ]+(\/[^\/ ]+){1,2}$/)) { // eslint-disable-line no-useless-escape
|
||||
// An Olson timezone id
|
||||
jsonData.timeZone = aDate.timezone.tzid;
|
||||
} else {
|
||||
|
@ -161,7 +161,7 @@ function dateToJSON(aDate) {
|
|||
|
||||
if (jsonData.timeZone) {
|
||||
// Strip the timezone offset if a timeZone was specified.
|
||||
jsonData.dateTime = jsonData.dateTime.replace(/[+-]\d{2}:\d{2}$/, '');
|
||||
jsonData.dateTime = jsonData.dateTime.replace(/[+-]\d{2}:\d{2}$/, "");
|
||||
|
||||
// Strip the Z for zones other than UTC, this usually happens for
|
||||
// unknown timezones.
|
||||
|
@ -262,11 +262,11 @@ fromRFC3339FixedZone.regex = new RegExp(
|
|||
* Like cal.toRFC3339, but include milliseconds. Google timestamps require
|
||||
* this.
|
||||
*
|
||||
* @param dt The calIDateTime to convert.
|
||||
* @param date The calIDateTime to convert.
|
||||
* @return The RFC3339 string stamp.
|
||||
*/
|
||||
function toRFC3339Fraction(dt) {
|
||||
let str = cal.toRFC3339(dt);
|
||||
function toRFC3339Fraction(date) {
|
||||
let str = cal.toRFC3339(date);
|
||||
return str ? str.replace(/(Z?)$/, ".000$1") : null;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,9 @@ function EventToJSON(aItem, aOfflineStorage, aIsImport) {
|
|||
}
|
||||
}
|
||||
function setIf(data, prop, value) {
|
||||
if (value) data[prop] = value;
|
||||
if (value) {
|
||||
data[prop] = value;
|
||||
}
|
||||
}
|
||||
|
||||
let itemData = {};
|
||||
|
@ -378,7 +380,9 @@ function EventToJSON(aItem, aOfflineStorage, aIsImport) {
|
|||
}
|
||||
}
|
||||
|
||||
if (attendeeData.length) itemData.attendees = attendeeData;
|
||||
if (attendeeData.length) {
|
||||
itemData.attendees = attendeeData;
|
||||
}
|
||||
}
|
||||
|
||||
// reminder
|
||||
|
@ -405,15 +409,13 @@ function EventToJSON(aItem, aOfflineStorage, aIsImport) {
|
|||
|
||||
if (alarm.related == alarm.ALARM_RELATED_ABSOLUTE) {
|
||||
alarmOffset = aItem.startDate.subtractDate(alarm.alarmDate);
|
||||
} else if (alarm.related == alarm.ALARM_RELATED_END) {
|
||||
// Google always uses an alarm offset related to the start time
|
||||
// for relative alarms.
|
||||
alarmOffset = alarm.alarmOffset.clone();
|
||||
alarmOffset.addDuration(aItem.endDate.subtractDate(aItem.startDate));
|
||||
} else {
|
||||
if (alarm.related == alarm.ALARM_RELATED_END) {
|
||||
// Google always uses an alarm offset related to the start time
|
||||
// for relative alarms.
|
||||
alarmOffset = alarm.alarmOffset.clone();
|
||||
alarmOffset.addDuration(aItem.endDate.subtractDate(aItem.startDate));
|
||||
} else {
|
||||
alarmOffset = alarm.offset;
|
||||
}
|
||||
alarmOffset = alarm.offset;
|
||||
}
|
||||
alarmData.minutes = -alarmOffset.inSeconds / 60;
|
||||
|
||||
|
@ -501,7 +503,9 @@ function EventToJSON(aItem, aOfflineStorage, aIsImport) {
|
|||
*/
|
||||
function TaskToJSON(aItem, aOfflineStorage, aIsImport) {
|
||||
function setIf(data, prop, value) {
|
||||
if (value) data[prop] = value;
|
||||
if (value) {
|
||||
data[prop] = value;
|
||||
}
|
||||
}
|
||||
|
||||
let itemData = {};
|
||||
|
@ -528,7 +532,9 @@ function TaskToJSON(aItem, aOfflineStorage, aIsImport) {
|
|||
}
|
||||
|
||||
let attachments = aItem.getAttachments({});
|
||||
if (attachments.length) itemData.links = [];
|
||||
if (attachments.length) {
|
||||
itemData.links = [];
|
||||
}
|
||||
for (let attach of aItem.getAttachments({})) {
|
||||
let attachData = {};
|
||||
attachData.link = attach.uri.spec;
|
||||
|
@ -569,10 +575,10 @@ function setupRecurrence(aItem, aRecurrence, aTimezone) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!aItem.recurrenceInfo) {
|
||||
aItem.recurrenceInfo = cal.createRecurrenceInfo(aItem);
|
||||
} else {
|
||||
if (aItem.recurrenceInfo) {
|
||||
aItem.recurrenceInfo.clearRecurrenceItems();
|
||||
} else {
|
||||
aItem.recurrenceInfo = cal.createRecurrenceInfo(aItem);
|
||||
}
|
||||
|
||||
let rootComp;
|
||||
|
@ -587,11 +593,11 @@ function setupRecurrence(aItem, aRecurrence, aTimezone) {
|
|||
for (let prop = rootComp.getFirstProperty("ANY");
|
||||
prop;
|
||||
prop = rootComp.getNextProperty("ANY")) {
|
||||
switch (prop.propertyName) {
|
||||
switch (prop.propertyName) {
|
||||
case "RDATE":
|
||||
case "EXDATE":
|
||||
case "EXDATE": {
|
||||
let recItem = Components.classes["@mozilla.org/calendar/recurrence-date;1"]
|
||||
.createInstance(Components.interfaces.calIRecurrenceDate);
|
||||
.createInstance(Components.interfaces.calIRecurrenceDate);
|
||||
try {
|
||||
recItem.icalProperty = prop;
|
||||
aItem.recurrenceInfo.appendRecurrenceItem(recItem);
|
||||
|
@ -602,7 +608,8 @@ function setupRecurrence(aItem, aRecurrence, aTimezone) {
|
|||
prop.icalString + "):" + e);
|
||||
}
|
||||
break;
|
||||
case "RRULE":
|
||||
}
|
||||
case "RRULE": {
|
||||
let recRule = cal.createRecurrenceRule();
|
||||
try {
|
||||
recRule.icalProperty = prop;
|
||||
|
@ -613,6 +620,7 @@ function setupRecurrence(aItem, aRecurrence, aTimezone) {
|
|||
prop.icalString + "):" + e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -873,7 +881,7 @@ function JSONToTask(aEntry, aCalendar, aDefaultReminders, aReferenceItem, aMetad
|
|||
|
||||
// Google Tasks don't have a due time, but still use 0:00 UTC. They
|
||||
// should really be using floating time.
|
||||
item.dueDate = cal.fromRFC3339(aEntry.due, cal.dtz.floating)
|
||||
item.dueDate = cal.fromRFC3339(aEntry.due, cal.dtz.floating);
|
||||
if (item.dueDate) {
|
||||
item.dueDate.timezone = cal.dtz.floating;
|
||||
item.dueDate.isDate = true;
|
||||
|
@ -928,9 +936,9 @@ function JSONToItem(aEntry, aCalendar, aDefaultReminders, aReferenceItem, aMetad
|
|||
aDefaultReminders = aDefaultReminders || [];
|
||||
aMetadata = aMetadata || {};
|
||||
if (aEntry.kind == "tasks#task") {
|
||||
return JSONToTask.apply(null, arguments);
|
||||
return JSONToTask(...arguments);
|
||||
} else if (aEntry.kind == "calendar#event") {
|
||||
return JSONToEvent.apply(null, arguments);
|
||||
return JSONToEvent(...arguments);
|
||||
} else {
|
||||
cal.ERROR("[calGoogleCalendar] Invalid item type: " + (aEntry ? aEntry.kind : "<no entry>"));
|
||||
return null;
|
||||
|
@ -994,7 +1002,7 @@ ItemSaver.prototype = {
|
|||
|
||||
for (let cur = 0; cur < total; cur++) {
|
||||
let entry = aData.items[cur];
|
||||
//let metaData = Object.create(null);
|
||||
// let metaData = Object.create(null);
|
||||
let metaData = {};
|
||||
let item = JSONToTask(entry, this.calendar, null, null, metaData);
|
||||
this.metaData[item.hashId] = metaData;
|
||||
|
@ -1029,7 +1037,7 @@ ItemSaver.prototype = {
|
|||
}
|
||||
|
||||
let exceptionItems = [];
|
||||
let defaultReminders = (aData.defaultReminders || []).map(function(x) { return JSONToAlarm(x, true); });
|
||||
let defaultReminders = (aData.defaultReminders || []).map(reminder => JSONToAlarm(reminder, true));
|
||||
|
||||
// In the first pass, we go through the data and sort into master items and
|
||||
// exception items, as the master item might be after the exception in the
|
||||
|
@ -1158,9 +1166,9 @@ ItemSaver.prototype = {
|
|||
* after the last request.
|
||||
*/
|
||||
complete: function() {
|
||||
return this.processRemainingExceptions().then(function() {
|
||||
return this.processRemainingExceptions().then(() => {
|
||||
this.activity.complete();
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1179,23 +1187,23 @@ ItemSaver.prototype = {
|
|||
// user is invited to an instance of a recurring event.
|
||||
// Unless this is a cancelled exception, create a mock
|
||||
// parent item with one positive RDATE.
|
||||
let item = exc.clone();
|
||||
item.recurrenceId = null;
|
||||
item.calendar = this.calendar.superCalendar;
|
||||
item.startDate = exc.recurrenceId.clone();
|
||||
item.setProperty("X-MOZ-FAKED-MASTER", "1");
|
||||
if (!item.id) {
|
||||
let parent = exc.clone();
|
||||
parent.recurrenceId = null;
|
||||
parent.calendar = this.calendar.superCalendar;
|
||||
parent.startDate = exc.recurrenceId.clone();
|
||||
parent.setProperty("X-MOZ-FAKED-MASTER", "1");
|
||||
if (!parent.id) {
|
||||
// Exceptions often don't have the iCalUID field set,
|
||||
// we need to fake it from the google id.
|
||||
let meta = this.metaData[exc.hashId];
|
||||
item.id = meta.path + "@google.com";
|
||||
parent.id = meta.path + "@google.com";
|
||||
}
|
||||
item.recurrenceInfo = cal.createRecurrenceInfo(item);
|
||||
parent.recurrenceInfo = cal.createRecurrenceInfo(parent);
|
||||
let rdate = Components.classes["@mozilla.org/calendar/recurrence-date;1"]
|
||||
.createInstance(Components.interfaces.calIRecurrenceDate);
|
||||
rdate.date = exc.recurrenceId;
|
||||
item.recurrenceInfo.appendRecurrenceItem(rdate);
|
||||
await this.commitItem(item);
|
||||
parent.recurrenceInfo.appendRecurrenceItem(rdate);
|
||||
await this.commitItem(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1209,7 +1217,7 @@ ItemSaver.prototype = {
|
|||
function ActivityShell(aCalendar) {
|
||||
this.calendar = aCalendar;
|
||||
|
||||
if ('@mozilla.org/activity-process;1' in Components.classes) {
|
||||
if ("@mozilla.org/activity-process;1" in Components.classes) {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
@ -1221,10 +1229,10 @@ ActivityShell.prototype = {
|
|||
type: null,
|
||||
|
||||
init: function() {
|
||||
this.actMgr = Components.classes['@mozilla.org/activity-manager;1']
|
||||
this.actMgr = Components.classes["@mozilla.org/activity-manager;1"]
|
||||
.getService(Components.interfaces.nsIActivityManager);
|
||||
this.act = Components.classes['@mozilla.org/activity-process;1']
|
||||
.createInstance(Components.interfaces.nsIActivityProcess);
|
||||
this.act = Components.classes["@mozilla.org/activity-process;1"]
|
||||
.createInstance(Components.interfaces.nsIActivityProcess);
|
||||
this.act.init(getProviderString("syncStatus", this.calendar.name), this);
|
||||
this.act.iconClass = "syncMail";
|
||||
this.act.contextType = "gdata-calendar";
|
||||
|
@ -1341,7 +1349,7 @@ function monkeyPatch(obj, x, func) {
|
|||
Components.utils.reportError(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче