Bug 1774362 - Changes needed for bug 1607331 - Reject global this usage in JSM. calendar/ part. r=freaktechnik
Differential Revision: https://phabricator.services.mozilla.com/D149363 --HG-- extra : amend_source : d6ca973ad20fa0136c3e1e488fa911df18eb9b78
This commit is contained in:
Родитель
b0914c4ba8
Коммит
fe4e2fd124
|
@ -2,16 +2,16 @@
|
|||
* 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/. */
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/*
|
||||
/**
|
||||
* Helpers for permission checks and other ACL features
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.acl namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calacl"]; /* exported calacl */
|
||||
const EXPORTED_SYMBOLS = ["calacl"];
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var calacl = {
|
||||
/**
|
||||
|
|
|
@ -2,23 +2,24 @@
|
|||
* 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/. */
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
});
|
||||
|
||||
/*
|
||||
/**
|
||||
* Helpers for manipulating calendar alarms
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.alarm namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calalarms"]; /* exported calalarms */
|
||||
const EXPORTED_SYMBOLS = ["calalarms"];
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const lazy = {};
|
||||
|
||||
ChromeUtils.defineModuleGetter(lazy, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
});
|
||||
|
||||
var calalarms = {
|
||||
/**
|
||||
|
@ -31,8 +32,8 @@ var calalarms = {
|
|||
setDefaultValues(aItem) {
|
||||
let type = aItem.isEvent() ? "event" : "todo";
|
||||
if (Services.prefs.getIntPref("calendar.alarms.onfor" + type + "s", 0) == 1) {
|
||||
let alarmOffset = cal.createDuration();
|
||||
let alarm = new CalAlarm();
|
||||
let alarmOffset = lazy.cal.createDuration();
|
||||
let alarm = new lazy.CalAlarm();
|
||||
let units = Services.prefs.getStringPref("calendar.alarms." + type + "alarmunit", "minutes");
|
||||
|
||||
// Make sure the alarm pref is valid, default to minutes otherwise
|
||||
|
@ -45,7 +46,7 @@ var calalarms = {
|
|||
alarmOffset.isNegative = true;
|
||||
if (type == "todo" && !aItem.entryDate) {
|
||||
// You can't have an alarm if the entryDate doesn't exist.
|
||||
aItem.entryDate = cal.dtz.now();
|
||||
aItem.entryDate = lazy.cal.dtz.now();
|
||||
}
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_START;
|
||||
alarm.offset = alarmOffset;
|
||||
|
@ -73,9 +74,9 @@ var calalarms = {
|
|||
}
|
||||
let returnDate;
|
||||
if (aAlarm.related == Ci.calIAlarm.ALARM_RELATED_START) {
|
||||
returnDate = aItem[cal.dtz.startDateProp(aItem)];
|
||||
returnDate = aItem[lazy.cal.dtz.startDateProp(aItem)];
|
||||
} else if (aAlarm.related == Ci.calIAlarm.ALARM_RELATED_END) {
|
||||
returnDate = aItem[cal.dtz.endDateProp(aItem)];
|
||||
returnDate = aItem[lazy.cal.dtz.endDateProp(aItem)];
|
||||
}
|
||||
|
||||
if (returnDate && aAlarm.offset) {
|
||||
|
@ -83,12 +84,12 @@ var calalarms = {
|
|||
// have a well defined startTime. We just consider the start/end
|
||||
// to be midnight in the user's timezone.
|
||||
if (returnDate.isDate) {
|
||||
let timezone = cal.dtz.defaultTimezone;
|
||||
let timezone = lazy.cal.dtz.defaultTimezone;
|
||||
// This returns a copy, so no extra cloning needed.
|
||||
returnDate = returnDate.getInTimezone(timezone);
|
||||
returnDate.isDate = false;
|
||||
} else if (returnDate.timezone.tzid == "floating") {
|
||||
let timezone = cal.dtz.defaultTimezone;
|
||||
let timezone = lazy.cal.dtz.defaultTimezone;
|
||||
returnDate = returnDate.getInTimezone(timezone);
|
||||
} else {
|
||||
// Clone the date to correctly add the duration.
|
||||
|
@ -118,9 +119,9 @@ var calalarms = {
|
|||
if (aAlarm.related == Ci.calIAlarm.ALARM_RELATED_ABSOLUTE) {
|
||||
let returnDate;
|
||||
if (aRelated === undefined || aRelated == Ci.calIAlarm.ALARM_RELATED_START) {
|
||||
returnDate = aItem[cal.dtz.startDateProp(aItem)];
|
||||
returnDate = aItem[lazy.cal.dtz.startDateProp(aItem)];
|
||||
} else if (aRelated == Ci.calIAlarm.ALARM_RELATED_END) {
|
||||
returnDate = aItem[cal.dtz.endDateProp(aItem)];
|
||||
returnDate = aItem[lazy.cal.dtz.endDateProp(aItem)];
|
||||
}
|
||||
|
||||
if (returnDate && aAlarm.alarmDate) {
|
||||
|
|
|
@ -2,23 +2,25 @@
|
|||
* 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/. */
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
cal: "resource:///modules/calendar/calUtils.jsm",
|
||||
MsgAuthPrompt: "resource:///modules/MsgAsyncPrompter.jsm",
|
||||
setTimeout: "resource://gre/modules/Timer.jsm",
|
||||
});
|
||||
|
||||
/*
|
||||
/**
|
||||
* Authentication tools and prompts, mostly for providers
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when including
|
||||
// calUtils.jsm under the cal.auth namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calauth"]; /* exported calauth */
|
||||
const EXPORTED_SYMBOLS = ["calauth"];
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const lazy = {};
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
cal: "resource:///modules/calendar/calUtils.jsm",
|
||||
MsgAuthPrompt: "resource:///modules/MsgAsyncPrompter.jsm",
|
||||
setTimeout: "resource://gre/modules/Timer.jsm",
|
||||
});
|
||||
|
||||
/**
|
||||
* The userContextId of nsIHttpChannel is currently implemented as a uint32, so
|
||||
|
@ -139,7 +141,7 @@ var calauth = {
|
|||
*/
|
||||
Prompt: class {
|
||||
constructor() {
|
||||
this.mWindow = cal.window.getCalendarWindow();
|
||||
this.mWindow = lazy.cal.window.getCalendarWindow();
|
||||
this.mReturnedLogins = {};
|
||||
this.mProvider = null;
|
||||
}
|
||||
|
@ -185,7 +187,7 @@ var calauth = {
|
|||
this.mReturnedLogins[keyStr] &&
|
||||
now.getTime() - this.mReturnedLogins[keyStr].getTime() < 60000
|
||||
) {
|
||||
cal.LOG(
|
||||
lazy.cal.LOG(
|
||||
"Credentials removed for: user=" +
|
||||
username +
|
||||
", host=" +
|
||||
|
@ -219,7 +221,7 @@ var calauth = {
|
|||
}
|
||||
hostRealm.passwordRealm = aChannel.URI.host + ":" + port + " (" + aAuthInfo.realm + ")";
|
||||
|
||||
let requestedUser = cal.auth.containerMap.getUsernameForUserContextId(
|
||||
let requestedUser = lazy.cal.auth.containerMap.getUsernameForUserContextId(
|
||||
aChannel.loadInfo.originAttributes.userContextId
|
||||
);
|
||||
let pwInfo = this.getPasswordInfo(hostRealm, requestedUser);
|
||||
|
@ -230,10 +232,14 @@ var calauth = {
|
|||
}
|
||||
let savePasswordLabel = null;
|
||||
if (Services.prefs.getBoolPref("signon.rememberSignons", true)) {
|
||||
savePasswordLabel = cal.l10n.getAnyString("passwordmgr", "passwordmgr", "rememberPassword");
|
||||
savePasswordLabel = lazy.cal.l10n.getAnyString(
|
||||
"passwordmgr",
|
||||
"passwordmgr",
|
||||
"rememberPassword"
|
||||
);
|
||||
}
|
||||
let savePassword = {};
|
||||
let returnValue = new MsgAuthPrompt().promptAuth(
|
||||
let returnValue = new lazy.MsgAuthPrompt().promptAuth(
|
||||
aChannel,
|
||||
aLevel,
|
||||
aAuthInfo,
|
||||
|
@ -290,7 +296,7 @@ var calauth = {
|
|||
},
|
||||
};
|
||||
|
||||
let requestedUser = cal.auth.containerMap.getUsernameForUserContextId(
|
||||
let requestedUser = lazy.cal.auth.containerMap.getUsernameForUserContextId(
|
||||
aChannel.loadInfo.originAttributes.userContextId
|
||||
);
|
||||
let hostKey = aChannel.URI.prePath + ":" + aAuthInfo.realm + ":" + requestedUser;
|
||||
|
@ -313,9 +319,9 @@ var calauth = {
|
|||
};
|
||||
|
||||
let tryUntilReady = function() {
|
||||
self.mWindow = cal.window.getCalendarWindow();
|
||||
self.mWindow = lazy.cal.window.getCalendarWindow();
|
||||
if (!self.mWindow) {
|
||||
setTimeout(tryUntilReady, 1000);
|
||||
lazy.setTimeout(tryUntilReady, 1000);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -354,23 +360,23 @@ var calauth = {
|
|||
throw new Components.Exception("", Cr.NS_ERROR_XPC_NEED_OUT_OBJECT);
|
||||
}
|
||||
|
||||
let prompter = new MsgAuthPrompt();
|
||||
let prompter = new lazy.MsgAuthPrompt();
|
||||
|
||||
// Only show the save password box if we are supposed to.
|
||||
let savepassword = null;
|
||||
if (Services.prefs.getBoolPref("signon.rememberSignons", true)) {
|
||||
savepassword = cal.l10n.getAnyString("passwordmgr", "passwordmgr", "rememberPassword");
|
||||
savepassword = lazy.cal.l10n.getAnyString("passwordmgr", "passwordmgr", "rememberPassword");
|
||||
}
|
||||
|
||||
let aText;
|
||||
if (aFixedUsername) {
|
||||
aText = cal.l10n.getAnyString("global", "commonDialogs", "EnterPasswordFor", [
|
||||
aText = lazy.cal.l10n.getAnyString("global", "commonDialogs", "EnterPasswordFor", [
|
||||
aUsername.value,
|
||||
aCalendarName,
|
||||
]);
|
||||
return prompter.promptPassword(aTitle, aText, aPassword, savepassword, aSavePassword);
|
||||
}
|
||||
aText = cal.l10n.getAnyString("global", "commonDialogs", "EnterUserPasswordFor2", [
|
||||
aText = lazy.cal.l10n.getAnyString("global", "commonDialogs", "EnterUserPasswordFor2", [
|
||||
aCalendarName,
|
||||
]);
|
||||
return prompter.promptUsernameAndPassword(
|
||||
|
@ -412,8 +418,8 @@ var calauth = {
|
|||
* @param {String} aRealm The password realm (unused on branch)
|
||||
*/
|
||||
passwordManagerSave(aUsername, aPassword, aOrigin, aRealm) {
|
||||
cal.ASSERT(aUsername);
|
||||
cal.ASSERT(aPassword);
|
||||
lazy.cal.ASSERT(aUsername);
|
||||
lazy.cal.ASSERT(aPassword);
|
||||
|
||||
let origin = this._ensureOrigin(aOrigin);
|
||||
|
||||
|
@ -441,7 +447,7 @@ var calauth = {
|
|||
} catch (exc) {
|
||||
// Only show the message if its not an abort, which can happen if
|
||||
// the user canceled the primary password dialog
|
||||
cal.ASSERT(exc.result == Cr.NS_ERROR_ABORT, exc);
|
||||
lazy.cal.ASSERT(exc.result == Cr.NS_ERROR_ABORT, exc);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -455,7 +461,7 @@ var calauth = {
|
|||
* @return {Boolean} True, if an entry exists in the password manager
|
||||
*/
|
||||
passwordManagerGet(aUsername, aPassword, aOrigin, aRealm) {
|
||||
cal.ASSERT(aUsername);
|
||||
lazy.cal.ASSERT(aUsername);
|
||||
|
||||
if (typeof aPassword != "object") {
|
||||
throw new Components.Exception("", Cr.NS_ERROR_XPC_NEED_OUT_OBJECT);
|
||||
|
@ -475,7 +481,7 @@ var calauth = {
|
|||
}
|
||||
}
|
||||
} catch (exc) {
|
||||
cal.ASSERT(false, exc);
|
||||
lazy.cal.ASSERT(false, exc);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
@ -489,7 +495,7 @@ var calauth = {
|
|||
* @return {Boolean} Could the user be removed?
|
||||
*/
|
||||
passwordManagerRemove(aUsername, aOrigin, aRealm) {
|
||||
cal.ASSERT(aUsername);
|
||||
lazy.cal.ASSERT(aUsername);
|
||||
|
||||
let origin = this._ensureOrigin(aOrigin);
|
||||
|
||||
|
|
|
@ -2,18 +2,19 @@
|
|||
* 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/. */
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
/*
|
||||
/**
|
||||
* Helpers for reading and writing calendar categories
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.category namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calcategory"]; /* exported calcategory */
|
||||
const EXPORTED_SYMBOLS = ["calcategory"];
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineModuleGetter(lazy, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
var calcategory = {
|
||||
/**
|
||||
|
@ -25,16 +26,16 @@ var calcategory = {
|
|||
let defaultBranch = Services.prefs.getDefaultBranch("");
|
||||
|
||||
// First, set up the category names
|
||||
let categories = cal.l10n.getString("categories", "categories2");
|
||||
let categories = lazy.cal.l10n.getString("categories", "categories2");
|
||||
defaultBranch.setStringPref("calendar.categories.names", categories);
|
||||
|
||||
// Now, initialize the category default colors
|
||||
let categoryArray = calcategory.stringToArray(categories);
|
||||
for (let category of categoryArray) {
|
||||
let prefName = cal.view.formatStringForCSSRule(category);
|
||||
let prefName = lazy.cal.view.formatStringForCSSRule(category);
|
||||
defaultBranch.setStringPref(
|
||||
"calendar.category.color." + prefName,
|
||||
cal.view.hashColor(category)
|
||||
lazy.cal.view.hashColor(category)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,16 +2,17 @@
|
|||
* 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.defineModuleGetter(this, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
/*
|
||||
/**
|
||||
* Data structures and algorithms used within the codebase
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.data namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["caldata"]; /* exported caldata */
|
||||
const EXPORTED_SYMBOLS = ["caldata"];
|
||||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineModuleGetter(lazy, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
class ListenerSet extends Set {
|
||||
constructor(iid, iterable) {
|
||||
|
@ -97,7 +98,7 @@ class OperationGroup {
|
|||
}
|
||||
|
||||
constructor(aCancelFunc) {
|
||||
this.mId = cal.getUUID() + "-" + OperationGroup.nextGroupId();
|
||||
this.mId = lazy.cal.getUUID() + "-" + OperationGroup.nextGroupId();
|
||||
this.mIsPending = true;
|
||||
|
||||
this.mCancelFunc = aCancelFunc;
|
||||
|
@ -131,7 +132,7 @@ class OperationGroup {
|
|||
}
|
||||
|
||||
notifyCompleted(aStatus) {
|
||||
cal.ASSERT(this.isPending, "[OperationGroup_notifyCompleted] this.isPending");
|
||||
lazy.cal.ASSERT(this.isPending, "[OperationGroup_notifyCompleted] this.isPending");
|
||||
if (this.isPending) {
|
||||
this.mIsPending = false;
|
||||
if (aStatus) {
|
||||
|
|
|
@ -2,39 +2,40 @@
|
|||
* 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/. */
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
/*
|
||||
/**
|
||||
* Date, time and timezone related functions
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.dtz namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["caldtz"]; /* exported caldtz */
|
||||
const EXPORTED_SYMBOLS = ["caldtz"];
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineModuleGetter(lazy, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
var caldtz = {
|
||||
/**
|
||||
* Shortcut to the timezone service's defaultTimezone
|
||||
*/
|
||||
get defaultTimezone() {
|
||||
return cal.timezoneService.defaultTimezone;
|
||||
return lazy.cal.timezoneService.defaultTimezone;
|
||||
},
|
||||
|
||||
/**
|
||||
* Shorcut to the UTC timezone
|
||||
*/
|
||||
get UTC() {
|
||||
return cal.timezoneService.UTC;
|
||||
return lazy.cal.timezoneService.UTC;
|
||||
},
|
||||
|
||||
/**
|
||||
* Shortcut to the floating (local) timezone
|
||||
*/
|
||||
get floating() {
|
||||
return cal.timezoneService.floating;
|
||||
return lazy.cal.timezoneService.floating;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -182,7 +183,7 @@ var caldtz = {
|
|||
* but only its local time portions are be taken.
|
||||
*/
|
||||
jsDateToDateTime(aDate, aTimezone) {
|
||||
let newDate = cal.createDateTime();
|
||||
let newDate = lazy.cal.createDateTime();
|
||||
if (aTimezone) {
|
||||
newDate.resetTo(
|
||||
aDate.getFullYear(),
|
||||
|
@ -228,7 +229,7 @@ var caldtz = {
|
|||
fromRFC3339(aStr, aTimezone) {
|
||||
// XXX I have not covered leapseconds (matches[8]), this might need to
|
||||
// be done. The only reference to leap seconds I found is bug 227329.
|
||||
let dateTime = cal.createDateTime();
|
||||
let dateTime = lazy.cal.createDateTime();
|
||||
|
||||
// Killer regex to parse RFC3339 dates
|
||||
let re = new RegExp(
|
||||
|
@ -260,7 +261,7 @@ var caldtz = {
|
|||
if (matches[9] == "Z" || matches[9] == "z") {
|
||||
// If the dates timezone is "Z" or "z", then this is UTC, no matter
|
||||
// what timezone was passed
|
||||
dateTime.timezone = cal.dtz.UTC;
|
||||
dateTime.timezone = lazy.cal.dtz.UTC;
|
||||
} else if (matches[9] == null) {
|
||||
// We have no timezone info, only a date. We have no way to
|
||||
// know what timezone we are in, so lets assume we are in the
|
||||
|
@ -280,15 +281,15 @@ var caldtz = {
|
|||
// TODO A patch to Bug 363191 should make this more efficient.
|
||||
|
||||
// Enumerate timezones, set them, check their offset
|
||||
for (let id of cal.timezoneService.timezoneIds) {
|
||||
dateTime.timezone = cal.timezoneService.getTimezone(id);
|
||||
for (let id of lazy.cal.timezoneService.timezoneIds) {
|
||||
dateTime.timezone = lazy.cal.timezoneService.getTimezone(id);
|
||||
if (dateTime.timezoneOffset == offset_in_s) {
|
||||
// This is our last step, so go ahead and return
|
||||
return dateTime;
|
||||
}
|
||||
}
|
||||
// We are still here: no timezone was found
|
||||
dateTime.timezone = cal.dtz.UTC;
|
||||
dateTime.timezone = lazy.cal.dtz.UTC;
|
||||
if (!dateTime.isDate) {
|
||||
dateTime.hour += (matches[11] == "-" ? -1 : 1) * matches[12];
|
||||
dateTime.minute += (matches[11] == "-" ? -1 : 1) * matches[13];
|
||||
|
@ -366,7 +367,7 @@ var caldtz = {
|
|||
if (aConvertZones) {
|
||||
let oldZonesLength = recentTimezones.length;
|
||||
for (let i = 0; i < recentTimezones.length; i++) {
|
||||
let timezone = cal.timezoneService.getTimezone(recentTimezones[i]);
|
||||
let timezone = lazy.cal.timezoneService.getTimezone(recentTimezones[i]);
|
||||
if (timezone) {
|
||||
// Replace id with found timezone
|
||||
recentTimezones[i] = timezone;
|
||||
|
@ -397,14 +398,14 @@ var caldtz = {
|
|||
* @return {string} A string representation of the datetime.
|
||||
*/
|
||||
getStringForDateTime(dateTime) {
|
||||
const kDefaultTimezone = cal.dtz.defaultTimezone;
|
||||
const kDefaultTimezone = lazy.cal.dtz.defaultTimezone;
|
||||
let localTime = dateTime.getInTimezone(kDefaultTimezone);
|
||||
let formatter = cal.dtz.formatter;
|
||||
let formatter = lazy.cal.dtz.formatter;
|
||||
let formattedLocalTime = formatter.formatDateTime(localTime);
|
||||
|
||||
if (!dateTime.timezone.isFloating && dateTime.timezone.tzid != kDefaultTimezone.tzid) {
|
||||
// Additionally display the original datetime with timezone.
|
||||
let originalTime = cal.l10n.getCalString("datetimeWithTimezone", [
|
||||
let originalTime = lazy.cal.l10n.getCalString("datetimeWithTimezone", [
|
||||
formatter.formatDateTime(dateTime),
|
||||
dateTime.timezone.tzid,
|
||||
]);
|
||||
|
|
|
@ -2,18 +2,19 @@
|
|||
* 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/. */
|
||||
|
||||
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
/*
|
||||
/**
|
||||
* Functions for processing email addresses and sending email
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.email namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calemail"]; /* exported calemail */
|
||||
const EXPORTED_SYMBOLS = ["calemail"];
|
||||
|
||||
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
|
||||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineModuleGetter(lazy, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
var calemail = {
|
||||
/**
|
||||
|
@ -92,7 +93,7 @@ var calemail = {
|
|||
let cbEmail = function(aVal) {
|
||||
let email = calemail.getAttendeeEmail(aVal, true);
|
||||
if (!email.length) {
|
||||
cal.LOG("Dropping invalid recipient for email transport: " + aVal.toString());
|
||||
lazy.cal.LOG("Dropping invalid recipient for email transport: " + aVal.toString());
|
||||
}
|
||||
return email;
|
||||
};
|
||||
|
|
|
@ -2,18 +2,19 @@
|
|||
* 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/. */
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
/*
|
||||
/**
|
||||
* Iterators for various data structures
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.iterate namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["caliterate"]; /* exported caliterate */
|
||||
const EXPORTED_SYMBOLS = ["caliterate"];
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineModuleGetter(lazy, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
var caliterate = {
|
||||
/**
|
||||
|
@ -76,7 +77,7 @@ var caliterate = {
|
|||
|
||||
if (!done) {
|
||||
let rc = body(next.value);
|
||||
if (rc == cal.iterate.forEach.BREAK) {
|
||||
if (rc == lazy.cal.iterate.forEach.BREAK) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
@ -118,10 +119,10 @@ var caliterate = {
|
|||
*/
|
||||
*icalComponent(aComponent, aCompType = "ANY") {
|
||||
if (aComponent && aComponent.componentType == "VCALENDAR") {
|
||||
yield* cal.iterate.icalSubcomponent(aComponent, aCompType);
|
||||
yield* lazy.cal.iterate.icalSubcomponent(aComponent, aCompType);
|
||||
} else if (aComponent && aComponent.componentType == "XROOT") {
|
||||
for (let calComp of cal.iterate.icalSubcomponent(aComponent, "VCALENDAR")) {
|
||||
yield* cal.iterate.icalSubcomponent(calComp, aCompType);
|
||||
for (let calComp of lazy.cal.iterate.icalSubcomponent(aComponent, "VCALENDAR")) {
|
||||
yield* lazy.cal.iterate.icalSubcomponent(calComp, aCompType);
|
||||
}
|
||||
} else if (aComponent && (aCompType == "ANY" || aCompType == aComponent.componentType)) {
|
||||
yield aComponent;
|
||||
|
|
|
@ -2,6 +2,15 @@
|
|||
* 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/. */
|
||||
|
||||
/**
|
||||
* Scheduling and iTIP helper code
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.itip namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calitip"];
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
|
||||
var { calendarDeactivator } = ChromeUtils.import(
|
||||
|
@ -9,24 +18,15 @@ var { calendarDeactivator } = ChromeUtils.import(
|
|||
);
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
const lazy = {};
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
CalRelation: "resource:///modules/CalRelation.jsm",
|
||||
CalItipDefaultEmailTransport: "resource:///modules/CalItipEmailTransport.jsm",
|
||||
CalItipMessageSender: "resource:///modules/CalItipMessageSender.jsm",
|
||||
CalItipOutgoingMessage: "resource:///modules/CalItipOutgoingMessage.jsm",
|
||||
});
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
/*
|
||||
* Scheduling and iTIP helper code
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.itip namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calitip"]; /* exported calitip */
|
||||
ChromeUtils.defineModuleGetter(lazy, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
var calitip = {
|
||||
/**
|
||||
|
@ -78,7 +78,7 @@ var calitip = {
|
|||
if (calitip.isAttendee(aItem)) {
|
||||
let stamp = aItem.getProperty("RECEIVED-DTSTAMP");
|
||||
if (stamp) {
|
||||
dtstamp = cal.createDateTime(stamp);
|
||||
dtstamp = lazy.cal.createDateTime(stamp);
|
||||
}
|
||||
} else if (aItem) {
|
||||
// Unless the below is standardized, we store the last original
|
||||
|
@ -86,7 +86,7 @@ var calitip = {
|
|||
// when updates come in:
|
||||
let stamp = aItem.getProperty("X-MOZ-RECEIVED-DTSTAMP");
|
||||
if (stamp) {
|
||||
dtstamp = cal.createDateTime(stamp);
|
||||
dtstamp = lazy.cal.createDateTime(stamp);
|
||||
} else {
|
||||
// xxx todo: are there similar X-MICROSOFT-CDO properties to be considered here?
|
||||
dtstamp = aItem.stampTime;
|
||||
|
@ -163,7 +163,7 @@ var calitip = {
|
|||
if (!orgId) {
|
||||
return null;
|
||||
}
|
||||
let organizer = new CalAttendee();
|
||||
let organizer = new lazy.CalAttendee();
|
||||
organizer.id = orgId;
|
||||
organizer.commonName = aCalendar.getProperty("organizerCN");
|
||||
organizer.role = "REQ-PARTICIPANT";
|
||||
|
@ -181,7 +181,7 @@ var calitip = {
|
|||
*/
|
||||
isSchedulingCalendar(aCalendar) {
|
||||
return (
|
||||
cal.acl.isCalendarWritable(aCalendar) &&
|
||||
lazy.cal.acl.isCalendarWritable(aCalendar) &&
|
||||
aCalendar.getProperty("organizerId") &&
|
||||
aCalendar.getProperty("itip.transport")
|
||||
);
|
||||
|
@ -217,16 +217,16 @@ var calitip = {
|
|||
// Fall back to using the one from the itipItem's ICS.
|
||||
imipMethod = itipItem.receivedMethod;
|
||||
}
|
||||
cal.LOG("iTIP method: " + imipMethod);
|
||||
lazy.cal.LOG("iTIP method: " + imipMethod);
|
||||
|
||||
let isWritableCalendar = function(aCalendar) {
|
||||
/* TODO: missing ACL check for existing items (require callback API) */
|
||||
return (
|
||||
calitip.isSchedulingCalendar(aCalendar) && cal.acl.userCanAddItemsToCalendar(aCalendar)
|
||||
calitip.isSchedulingCalendar(aCalendar) && lazy.cal.acl.userCanAddItemsToCalendar(aCalendar)
|
||||
);
|
||||
};
|
||||
|
||||
let writableCalendars = cal.manager.getCalendars().filter(isWritableCalendar);
|
||||
let writableCalendars = lazy.cal.manager.getCalendars().filter(isWritableCalendar);
|
||||
if (writableCalendars.length > 0) {
|
||||
let compCal = Cc["@mozilla.org/calendar/calendar;1?type=composite"].createInstance(
|
||||
Ci.calICompositeCalendar
|
||||
|
@ -252,17 +252,17 @@ var calitip = {
|
|||
if (Components.isSuccessCode(aStatus)) {
|
||||
switch (aOperationType) {
|
||||
case cIOL.ADD:
|
||||
text = cal.l10n.getLtnString("imipAddedItemToCal2");
|
||||
text = lazy.cal.l10n.getLtnString("imipAddedItemToCal2");
|
||||
break;
|
||||
case cIOL.MODIFY:
|
||||
text = cal.l10n.getLtnString("imipUpdatedItem2");
|
||||
text = lazy.cal.l10n.getLtnString("imipUpdatedItem2");
|
||||
break;
|
||||
case cIOL.DELETE:
|
||||
text = cal.l10n.getLtnString("imipCanceledItem2");
|
||||
text = lazy.cal.l10n.getLtnString("imipCanceledItem2");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
text = cal.l10n.getLtnString("imipBarProcessingFailed", [aStatus.toString(16)]);
|
||||
text = lazy.cal.l10n.getLtnString("imipBarProcessingFailed", [aStatus.toString(16)]);
|
||||
}
|
||||
return text;
|
||||
},
|
||||
|
@ -279,23 +279,23 @@ var calitip = {
|
|||
getMethodText(method) {
|
||||
switch (method) {
|
||||
case "REFRESH":
|
||||
return cal.l10n.getLtnString("imipBarRefreshText");
|
||||
return lazy.cal.l10n.getLtnString("imipBarRefreshText");
|
||||
case "REQUEST":
|
||||
return cal.l10n.getLtnString("imipBarRequestText");
|
||||
return lazy.cal.l10n.getLtnString("imipBarRequestText");
|
||||
case "PUBLISH":
|
||||
return cal.l10n.getLtnString("imipBarPublishText");
|
||||
return lazy.cal.l10n.getLtnString("imipBarPublishText");
|
||||
case "CANCEL":
|
||||
return cal.l10n.getLtnString("imipBarCancelText");
|
||||
return lazy.cal.l10n.getLtnString("imipBarCancelText");
|
||||
case "REPLY":
|
||||
return cal.l10n.getLtnString("imipBarReplyText");
|
||||
return lazy.cal.l10n.getLtnString("imipBarReplyText");
|
||||
case "COUNTER":
|
||||
return cal.l10n.getLtnString("imipBarCounterText");
|
||||
return lazy.cal.l10n.getLtnString("imipBarCounterText");
|
||||
case "DECLINECOUNTER":
|
||||
return cal.l10n.getLtnString("imipBarDeclineCounterText");
|
||||
return lazy.cal.l10n.getLtnString("imipBarDeclineCounterText");
|
||||
default:
|
||||
cal.ERROR("Unknown iTIP method: " + method);
|
||||
let appName = cal.l10n.getAnyString("branding", "brand", "brandShortName");
|
||||
return cal.l10n.getLtnString("imipBarUnsupportedText2", [appName]);
|
||||
lazy.cal.ERROR("Unknown iTIP method: " + method);
|
||||
let appName = lazy.cal.l10n.getAnyString("branding", "brand", "brandShortName");
|
||||
return lazy.cal.l10n.getLtnString("imipBarUnsupportedText2", [appName]);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -337,34 +337,37 @@ var calitip = {
|
|||
}
|
||||
if (!calendarDeactivator.isCalendarActivated) {
|
||||
// Calendar is deactivated (no calendars are enabled).
|
||||
data.label = cal.l10n.getLtnString("imipBarCalendarDeactivated");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarCalendarDeactivated");
|
||||
data.showItems.push("imipGoToCalendarButton", "imipMoreButton");
|
||||
data.hideItems.push("imipMoreButton_SaveCopy");
|
||||
} else if (rc == Ci.calIErrors.CAL_IS_READONLY) {
|
||||
// No writable calendars, tell the user about it
|
||||
data.label = cal.l10n.getLtnString("imipBarNotWritable");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarNotWritable");
|
||||
data.showItems.push("imipGoToCalendarButton", "imipMoreButton");
|
||||
data.hideItems.push("imipMoreButton_SaveCopy");
|
||||
} else if (Components.isSuccessCode(rc) && !actionFunc) {
|
||||
// This case, they clicked on an old message that has already been
|
||||
// added/updated, we want to tell them that.
|
||||
data.label = cal.l10n.getLtnString("imipBarAlreadyProcessedText");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarAlreadyProcessedText");
|
||||
if (foundItems && foundItems.length) {
|
||||
data.showItems.push("imipDetailsButton");
|
||||
if (itipItem.receivedMethod == "COUNTER" && itipItem.sender) {
|
||||
if (disallowedCounter) {
|
||||
data.label = cal.l10n.getLtnString("imipBarDisallowedCounterText");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarDisallowedCounterText");
|
||||
} else {
|
||||
let comparison;
|
||||
for (let item of itipItem.getItemList()) {
|
||||
let attendees = cal.itip.getAttendeesBySender(item.getAttendees(), itipItem.sender);
|
||||
let attendees = lazy.cal.itip.getAttendeesBySender(
|
||||
item.getAttendees(),
|
||||
itipItem.sender
|
||||
);
|
||||
if (attendees.length == 1) {
|
||||
comparison = calitip.compareSequence(item, foundItems[0]);
|
||||
if (comparison == 1) {
|
||||
data.label = cal.l10n.getLtnString("imipBarCounterErrorText");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarCounterErrorText");
|
||||
break;
|
||||
} else if (comparison == -1) {
|
||||
data.label = cal.l10n.getLtnString("imipBarCounterPreviousVersionText");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarCounterPreviousVersionText");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -382,21 +385,21 @@ var calitip = {
|
|||
delTime = delmgr.getDeletedDate(items[0].id);
|
||||
}
|
||||
if (delTime) {
|
||||
data.label = cal.l10n.getLtnString("imipBarReplyToRecentlyRemovedItem", [
|
||||
cal.dtz.formatter.formatTime(delTime),
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarReplyToRecentlyRemovedItem", [
|
||||
lazy.cal.dtz.formatter.formatTime(delTime),
|
||||
]);
|
||||
} else {
|
||||
data.label = cal.l10n.getLtnString("imipBarReplyToNotExistingItem");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarReplyToNotExistingItem");
|
||||
}
|
||||
} else if (itipItem.receivedMethod == "DECLINECOUNTER") {
|
||||
data.label = cal.l10n.getLtnString("imipBarDeclineCounterText");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarDeclineCounterText");
|
||||
}
|
||||
} else if (Components.isSuccessCode(rc)) {
|
||||
cal.LOG("iTIP options on: " + actionFunc.method);
|
||||
lazy.cal.LOG("iTIP options on: " + actionFunc.method);
|
||||
switch (actionFunc.method) {
|
||||
case "PUBLISH:UPDATE":
|
||||
case "REQUEST:UPDATE-MINOR":
|
||||
data.label = cal.l10n.getLtnString("imipBarUpdateText");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarUpdateText");
|
||||
// falls through
|
||||
case "REPLY":
|
||||
data.showItems.push("imipUpdateButton");
|
||||
|
@ -416,19 +419,19 @@ var calitip = {
|
|||
|
||||
if (actionFunc.method == "REQUEST:UPDATE") {
|
||||
if (isRecurringMaster) {
|
||||
data.label = cal.l10n.getLtnString("imipBarUpdateSeriesText");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarUpdateSeriesText");
|
||||
} else if (itipItem.getItemList().length > 1) {
|
||||
data.label = cal.l10n.getLtnString("imipBarUpdateMultipleText");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarUpdateMultipleText");
|
||||
} else {
|
||||
data.label = cal.l10n.getLtnString("imipBarUpdateText");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarUpdateText");
|
||||
}
|
||||
} else if (actionFunc.method == "REQUEST:NEEDS-ACTION") {
|
||||
if (isRecurringMaster) {
|
||||
data.label = cal.l10n.getLtnString("imipBarProcessedSeriesNeedsAction");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarProcessedSeriesNeedsAction");
|
||||
} else if (itipItem.getItemList().length > 1) {
|
||||
data.label = cal.l10n.getLtnString("imipBarProcessedMultipleNeedsAction");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarProcessedMultipleNeedsAction");
|
||||
} else {
|
||||
data.label = cal.l10n.getLtnString("imipBarProcessedNeedsAction");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarProcessedNeedsAction");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -483,20 +486,20 @@ var calitip = {
|
|||
}
|
||||
case "COUNTER": {
|
||||
if (disallowedCounter) {
|
||||
data.label = cal.l10n.getLtnString("imipBarDisallowedCounterText");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarDisallowedCounterText");
|
||||
}
|
||||
data.showItems.push("imipDeclineCounterButton");
|
||||
data.showItems.push("imipRescheduleButton");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
let appName = cal.l10n.getAnyString("branding", "brand", "brandShortName");
|
||||
data.label = cal.l10n.getLtnString("imipBarUnsupportedText2", [appName]);
|
||||
let appName = lazy.cal.l10n.getAnyString("branding", "brand", "brandShortName");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarUnsupportedText2", [appName]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
let appName = cal.l10n.getAnyString("branding", "brand", "brandShortName");
|
||||
data.label = cal.l10n.getLtnString("imipBarUnsupportedText2", [appName]);
|
||||
let appName = lazy.cal.l10n.getAnyString("branding", "brand", "brandShortName");
|
||||
data.label = lazy.cal.l10n.getLtnString("imipBarUnsupportedText2", [appName]);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
@ -516,7 +519,7 @@ var calitip = {
|
|||
);
|
||||
let addresses = compFields.splitRecipients(author, true);
|
||||
if (addresses.length != 1) {
|
||||
cal.LOG("No unique email address for lookup in message.\r\n" + cal.STACK(20));
|
||||
lazy.cal.LOG("No unique email address for lookup in message.\r\n" + lazy.cal.STACK(20));
|
||||
}
|
||||
return addresses[0] || null;
|
||||
},
|
||||
|
@ -627,7 +630,7 @@ var calitip = {
|
|||
}
|
||||
|
||||
if (needsCalendar) {
|
||||
let calendars = cal.manager.getCalendars().filter(calitip.isSchedulingCalendar);
|
||||
let calendars = lazy.cal.manager.getCalendars().filter(calitip.isSchedulingCalendar);
|
||||
|
||||
if (aItipItem.receivedMethod == "REQUEST") {
|
||||
// try to further limit down the list to those calendars that
|
||||
|
@ -643,7 +646,7 @@ var calitip = {
|
|||
}
|
||||
|
||||
if (calendars.length == 0) {
|
||||
let msg = cal.l10n.getLtnString("imipNoCalendarAvailable");
|
||||
let msg = lazy.cal.l10n.getLtnString("imipNoCalendarAvailable");
|
||||
aWindow.alert(msg);
|
||||
} else if (calendars.length == 1) {
|
||||
// There's only one calendar, so it's silly to ask what calendar
|
||||
|
@ -656,7 +659,7 @@ var calitip = {
|
|||
args.onOk = aCal => {
|
||||
targetCalendar = aCal;
|
||||
};
|
||||
args.promptText = cal.l10n.getCalString("importPrompt");
|
||||
args.promptText = lazy.cal.l10n.getCalString("importPrompt");
|
||||
aWindow.openDialog(
|
||||
"chrome://calendar/content/chooseCalendarDialog.xhtml",
|
||||
"_blank",
|
||||
|
@ -715,7 +718,7 @@ var calitip = {
|
|||
cancelled = true;
|
||||
},
|
||||
onOk(identity) {
|
||||
att = new CalAttendee();
|
||||
att = new lazy.CalAttendee();
|
||||
att.id = `mailto:${identity.email}`;
|
||||
att.commonName = identity.fullName;
|
||||
att.isOrganizer = false;
|
||||
|
@ -832,7 +835,7 @@ var calitip = {
|
|||
* to ask the user whether to send)
|
||||
*/
|
||||
checkAndSend(aOpType, aItem, aOriginalItem, aExtResponse = null) {
|
||||
let sender = new CalItipMessageSender(aOriginalItem, calitip.getInvitedAttendee(aItem));
|
||||
let sender = new lazy.CalItipMessageSender(aOriginalItem, calitip.getInvitedAttendee(aItem));
|
||||
if (sender.detectChanges(aOpType, aItem, aExtResponse)) {
|
||||
sender.send(calitip.getImipTransport(aItem));
|
||||
}
|
||||
|
@ -854,7 +857,7 @@ var calitip = {
|
|||
// XXX todo: there's still the bug that modifyItem is called with mixed occurrence/parent,
|
||||
// find original occurrence
|
||||
oldItem = oldItem.recurrenceInfo.getOccurrenceFor(newItem.recurrenceId);
|
||||
cal.ASSERT(oldItem, "unexpected!");
|
||||
lazy.cal.ASSERT(oldItem, "unexpected!");
|
||||
if (!oldItem) {
|
||||
return newItem;
|
||||
}
|
||||
|
@ -874,8 +877,8 @@ var calitip = {
|
|||
};
|
||||
|
||||
let propStrings = [];
|
||||
for (let item of cal.iterate.items([aItem])) {
|
||||
for (let prop of cal.iterate.icalProperty(item.icalComponent)) {
|
||||
for (let item of lazy.cal.iterate.items([aItem])) {
|
||||
for (let prop of lazy.cal.iterate.icalProperty(item.icalComponent)) {
|
||||
if (prop.propertyName in majorProps) {
|
||||
propStrings.push(item.recurrenceId + "#" + prop.icalString);
|
||||
}
|
||||
|
@ -912,7 +915,7 @@ var calitip = {
|
|||
let itipItem = Cc["@mozilla.org/calendar/itip-item;1"].createInstance(Ci.calIItipItem);
|
||||
let serializedItems = "";
|
||||
for (let item of aItems) {
|
||||
serializedItems += cal.item.serialize(item);
|
||||
serializedItems += lazy.cal.item.serialize(item);
|
||||
}
|
||||
itipItem.init(serializedItems);
|
||||
|
||||
|
@ -962,9 +965,9 @@ var calitip = {
|
|||
// avoid changing aItem
|
||||
let item = aItem.clone();
|
||||
// reset to a new UUID if applicable
|
||||
item.id = aUid || cal.getUUID();
|
||||
item.id = aUid || lazy.cal.getUUID();
|
||||
// add a relation to the original item
|
||||
let relation = new CalRelation();
|
||||
let relation = new lazy.CalRelation();
|
||||
relation.relId = aItem.id;
|
||||
relation.relType = "SIBLING";
|
||||
item.addRelation(relation);
|
||||
|
@ -986,7 +989,7 @@ var calitip = {
|
|||
* @return {boolean}
|
||||
*/
|
||||
isAttendee(val) {
|
||||
return val && (val instanceof Ci.calIAttendee || val instanceof CalAttendee);
|
||||
return val && (val instanceof Ci.calIAttendee || val instanceof lazy.CalAttendee);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1103,14 +1106,14 @@ var calitip = {
|
|||
);
|
||||
let addresses = compFields.splitRecipients(aEmailAddress, true);
|
||||
if (addresses.length == 1) {
|
||||
let searchFor = cal.email.prependMailTo(addresses[0]);
|
||||
let searchFor = lazy.cal.email.prependMailTo(addresses[0]);
|
||||
aAttendees.forEach(aAttendee => {
|
||||
if ([aAttendee.id, aAttendee.getProperty("SENT-BY")].includes(searchFor)) {
|
||||
attendees.push(aAttendee);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
cal.WARN("No unique email address for lookup!");
|
||||
lazy.cal.WARN("No unique email address for lookup!");
|
||||
}
|
||||
return attendees;
|
||||
},
|
||||
|
@ -1133,7 +1136,7 @@ var calitip = {
|
|||
|
||||
if (server) {
|
||||
let account = MailServices.accounts.FindAccountForServer(server);
|
||||
return new CalItipDefaultEmailTransport(account, identity);
|
||||
return new lazy.CalItipDefaultEmailTransport(account, identity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1161,7 +1164,7 @@ function setReceivedInfo(item, itipItemItem) {
|
|||
if (dtstamp) {
|
||||
item.setProperty(
|
||||
isAttendee ? "RECEIVED-DTSTAMP" : "X-MOZ-RECEIVED-DTSTAMP",
|
||||
dtstamp.getInTimezone(cal.dtz.UTC).icalString
|
||||
dtstamp.getInTimezone(lazy.cal.dtz.UTC).icalString
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1202,7 +1205,7 @@ function updateItem(item, itipItemItem) {
|
|||
// keep care of installing all overridden items, and mind existing alarms, categories:
|
||||
for (let rid of recInfo.getExceptionIds()) {
|
||||
let excItem = recInfo.getExceptionFor(rid).clone();
|
||||
cal.ASSERT(excItem, "unexpected!");
|
||||
lazy.cal.ASSERT(excItem, "unexpected!");
|
||||
let newExc = newItem.recurrenceInfo.getOccurrenceFor(rid).clone();
|
||||
newExc.icalComponent = excItem.icalComponent;
|
||||
setReceivedInfo(newExc, itipItemItem);
|
||||
|
@ -1249,7 +1252,7 @@ function copyProviderProperties(itipItem, itipItemItem, item) {
|
|||
* @return {Boolean} True, if the message could be sent
|
||||
*/
|
||||
function sendMessage(aItem, aMethod, aRecipientsList, autoResponse) {
|
||||
new CalItipOutgoingMessage(
|
||||
new lazy.CalItipOutgoingMessage(
|
||||
aMethod,
|
||||
aRecipientsList,
|
||||
aItem,
|
||||
|
@ -1281,7 +1284,7 @@ ItipOpListener.prototype = {
|
|||
mExtResponse: null,
|
||||
|
||||
onOperationComplete(aCalendar, aStatus, aOperationType, aId, aDetail) {
|
||||
cal.ASSERT(Components.isSuccessCode(aStatus), "error on iTIP processing");
|
||||
lazy.cal.ASSERT(Components.isSuccessCode(aStatus), "error on iTIP processing");
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
calitip.checkAndSend(aOperationType, aDetail, this.mOldItem, this.mExtResponse);
|
||||
}
|
||||
|
@ -1450,7 +1453,7 @@ ItipItemFinder.prototype = {
|
|||
this.mItipItem.targetCalendar = this.mFoundItems[0].calendar;
|
||||
this._observeChanges(this.mItipItem.targetCalendar);
|
||||
|
||||
cal.LOG("iTIP on " + method + ": found " + this.mFoundItems.length + " items.");
|
||||
lazy.cal.LOG("iTIP on " + method + ": found " + this.mFoundItems.length + " items.");
|
||||
switch (method) {
|
||||
// XXX todo: there's still a potential flaw, if multiple PUBLISH/REPLY/REQUEST on
|
||||
// occurrences happen at once; those lead to multiple
|
||||
|
@ -1485,7 +1488,7 @@ ItipItemFinder.prototype = {
|
|||
case "REFRESH": {
|
||||
// xxx todo test
|
||||
let attendees = itipItemItem.getAttendees();
|
||||
cal.ASSERT(attendees.length == 1, "invalid number of attendees in REFRESH!");
|
||||
lazy.cal.ASSERT(attendees.length == 1, "invalid number of attendees in REFRESH!");
|
||||
if (attendees.length > 0) {
|
||||
let action = function(opListener, partStat, extResponse) {
|
||||
if (!item.organizer) {
|
||||
|
@ -1507,7 +1510,7 @@ ItipItemFinder.prototype = {
|
|||
break;
|
||||
}
|
||||
case "PUBLISH":
|
||||
cal.ASSERT(
|
||||
lazy.cal.ASSERT(
|
||||
itipItemItem.getAttendees().length == 0,
|
||||
"invalid number of attendees in PUBLISH!"
|
||||
);
|
||||
|
@ -1659,10 +1662,13 @@ ItipItemFinder.prototype = {
|
|||
case "REPLY": {
|
||||
let attendees = itipItemItem.getAttendees();
|
||||
if (method == "REPLY") {
|
||||
cal.ASSERT(attendees.length == 1, "invalid number of attendees in REPLY!");
|
||||
lazy.cal.ASSERT(attendees.length == 1, "invalid number of attendees in REPLY!");
|
||||
} else {
|
||||
attendees = cal.itip.getAttendeesBySender(attendees, this.mItipItem.sender);
|
||||
cal.ASSERT(
|
||||
attendees = lazy.cal.itip.getAttendeesBySender(
|
||||
attendees,
|
||||
this.mItipItem.sender
|
||||
);
|
||||
lazy.cal.ASSERT(
|
||||
attendees.length == 1,
|
||||
"ambiguous resolution of replying attendee in COUNTER!"
|
||||
);
|
||||
|
@ -1826,7 +1832,7 @@ ItipItemFinder.prototype = {
|
|||
}
|
||||
} else {
|
||||
// not found:
|
||||
cal.LOG("iTIP on " + method + ": no existing items.");
|
||||
lazy.cal.LOG("iTIP on " + method + ": no existing items.");
|
||||
// If the item was not found, observe the target calendar anyway.
|
||||
// It will likely be the composite calendar, so we should update
|
||||
// if an item was added or removed
|
||||
|
@ -1844,23 +1850,23 @@ ItipItemFinder.prototype = {
|
|||
|
||||
if (partStat) {
|
||||
if (partStat != "DECLINED") {
|
||||
cal.alarms.setDefaultValues(newItem);
|
||||
lazy.cal.alarms.setDefaultValues(newItem);
|
||||
}
|
||||
|
||||
let att = calitip.getInvitedAttendee(newItem);
|
||||
if (!att) {
|
||||
cal.WARN(
|
||||
lazy.cal.WARN(
|
||||
`Encountered item without invited attendee! id=${newItem.id}, method=${method} Exiting...`
|
||||
);
|
||||
return null;
|
||||
}
|
||||
att.participationStatus = partStat;
|
||||
} else {
|
||||
cal.ASSERT(
|
||||
lazy.cal.ASSERT(
|
||||
itipItemItem.getAttendees().length == 0,
|
||||
"invalid number of attendees in PUBLISH!"
|
||||
);
|
||||
cal.alarms.setDefaultValues(newItem);
|
||||
lazy.cal.alarms.setDefaultValues(newItem);
|
||||
}
|
||||
|
||||
let listener =
|
||||
|
@ -1900,7 +1906,7 @@ ItipItemFinder.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
cal.LOG("iTIP operations: " + operations.length);
|
||||
lazy.cal.LOG("iTIP operations: " + operations.length);
|
||||
let actionFunc = null;
|
||||
if (operations.length > 0) {
|
||||
actionFunc = function(opListener, partStat = null, extResponse = null) {
|
||||
|
@ -1908,7 +1914,7 @@ ItipItemFinder.prototype = {
|
|||
try {
|
||||
operation(opListener, partStat, extResponse);
|
||||
} catch (exc) {
|
||||
cal.ERROR(exc);
|
||||
lazy.cal.ERROR(exc);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
* 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/. */
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/*
|
||||
/**
|
||||
* Localization and locale functions
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.l10n namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["call10n"]; /* exported call10n */
|
||||
const EXPORTED_SYMBOLS = ["call10n"];
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/**
|
||||
* Gets the value of a string in a .properties file.
|
||||
|
|
|
@ -12,14 +12,15 @@
|
|||
* by the user.
|
||||
*/
|
||||
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.print namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calprint"]; /* exported calprint */
|
||||
const EXPORTED_SYMBOLS = ["calprint"];
|
||||
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineModuleGetter(lazy, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
var calprint = {
|
||||
ensureInitialized() {
|
||||
|
@ -28,7 +29,7 @@ var calprint = {
|
|||
},
|
||||
|
||||
async draw(document, type, startDate, endDate, filter, notDueTasks) {
|
||||
cal.view.colorTracker.addColorsToDocument(document);
|
||||
lazy.cal.view.colorTracker.addColorsToDocument(document);
|
||||
|
||||
let listContainer = document.getElementById("list-container");
|
||||
while (listContainer.lastChild) {
|
||||
|
@ -92,17 +93,17 @@ function addItemToDaybox(document, item, boxDate, dayContainer) {
|
|||
// Fill in category details
|
||||
let categoriesArray = item.getCategories();
|
||||
if (categoriesArray.length > 0) {
|
||||
let cssClassesArray = categoriesArray.map(cal.view.formatStringForCSSRule);
|
||||
let cssClassesArray = categoriesArray.map(lazy.cal.view.formatStringForCSSRule);
|
||||
itemNode.style.borderInlineEnd = `2px solid var(--category-${cssClassesArray[0]}-color)`;
|
||||
}
|
||||
|
||||
// Fill in calendar color
|
||||
let cssSafeId = cal.view.formatStringForCSSRule(item.calendar.id);
|
||||
let cssSafeId = lazy.cal.view.formatStringForCSSRule(item.calendar.id);
|
||||
itemNode.style.color = `var(--calendar-${cssSafeId}-forecolor)`;
|
||||
itemNode.style.backgroundColor = `var(--calendar-${cssSafeId}-backcolor)`;
|
||||
|
||||
// Add it to the day container in the right order
|
||||
cal.data.binaryInsertNode(dayContainer, itemNode, item, cal.view.compareItems);
|
||||
lazy.cal.data.binaryInsertNode(dayContainer, itemNode, item, lazy.cal.view.compareItems);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,7 +130,7 @@ function addItemToDayboxNodate(document, item) {
|
|||
if (taskListBox.hasAttribute("hidden")) {
|
||||
let tasksTitle = document.getElementById("tasks-title");
|
||||
taskListBox.removeAttribute("hidden");
|
||||
tasksTitle.textContent = cal.l10n.getCalString("tasksWithNoDueDate");
|
||||
tasksTitle.textContent = lazy.cal.l10n.getCalString("tasksWithNoDueDate");
|
||||
}
|
||||
|
||||
// Fill in details of the task
|
||||
|
@ -140,7 +141,7 @@ function addItemToDayboxNodate(document, item) {
|
|||
taskNode.querySelector(".task-title").textContent = item.title;
|
||||
|
||||
const collator = new Intl.Collator();
|
||||
cal.data.binaryInsertNode(
|
||||
lazy.cal.data.binaryInsertNode(
|
||||
taskContainer,
|
||||
taskNode,
|
||||
item,
|
||||
|
@ -157,9 +158,9 @@ function addItemToDayboxNodate(document, item) {
|
|||
*/
|
||||
function getItemIntervalString(aItem, aBoxDate) {
|
||||
// omit time label for all-day items
|
||||
let formatter = cal.dtz.formatter;
|
||||
let startDate = aItem[cal.dtz.startDateProp(aItem)];
|
||||
let endDate = aItem[cal.dtz.endDateProp(aItem)];
|
||||
let formatter = lazy.cal.dtz.formatter;
|
||||
let startDate = aItem[lazy.cal.dtz.startDateProp(aItem)];
|
||||
let endDate = aItem[lazy.cal.dtz.endDateProp(aItem)];
|
||||
if ((startDate && startDate.isDate) || (endDate && endDate.isDate)) {
|
||||
return "";
|
||||
}
|
||||
|
@ -169,7 +170,7 @@ function getItemIntervalString(aItem, aBoxDate) {
|
|||
return formatter.formatItemTimeInterval(aItem);
|
||||
}
|
||||
|
||||
let defaultTimezone = cal.dtz.defaultTimezone;
|
||||
let defaultTimezone = lazy.cal.dtz.defaultTimezone;
|
||||
startDate = startDate.getInTimezone(defaultTimezone);
|
||||
endDate = endDate.getInTimezone(defaultTimezone);
|
||||
let start = startDate.clone();
|
||||
|
@ -204,10 +205,10 @@ function getItemIntervalString(aItem, aBoxDate) {
|
|||
*/
|
||||
async function getItems(startDate, endDate, filter, notDueTasks) {
|
||||
let window = Services.wm.getMostRecentWindow("mail:3pane");
|
||||
let compositeCalendar = cal.view.getCompositeCalendar(window);
|
||||
let compositeCalendar = lazy.cal.view.getCompositeCalendar(window);
|
||||
|
||||
let itemList = [];
|
||||
for await (let items of cal.iterate.streamValues(
|
||||
for await (let items of lazy.cal.iterate.streamValues(
|
||||
compositeCalendar.getItems(filter, 0, startDate, endDate)
|
||||
)) {
|
||||
if (!notDueTasks) {
|
||||
|
@ -239,11 +240,11 @@ let listView = {
|
|||
// Get and sort items.
|
||||
let items = await getItems(startDate, endDate, filter, notDueTasks);
|
||||
items.sort((a, b) => {
|
||||
let start_a = a[cal.dtz.startDateProp(a)];
|
||||
let start_a = a[lazy.cal.dtz.startDateProp(a)];
|
||||
if (!start_a) {
|
||||
return -1;
|
||||
}
|
||||
let start_b = b[cal.dtz.startDateProp(b)];
|
||||
let start_b = b[lazy.cal.dtz.startDateProp(b)];
|
||||
if (!start_b) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -256,7 +257,7 @@ let listView = {
|
|||
|
||||
let setupTextRow = function(classKey, propValue, prefixKey) {
|
||||
if (propValue) {
|
||||
let prefix = cal.l10n.getCalString(prefixKey);
|
||||
let prefix = lazy.cal.l10n.getCalString(prefixKey);
|
||||
itemNode.querySelector("." + classKey + "key").textContent = prefix;
|
||||
itemNode.querySelector("." + classKey).textContent = propValue;
|
||||
} else {
|
||||
|
@ -271,15 +272,15 @@ let listView = {
|
|||
}
|
||||
};
|
||||
|
||||
let itemStartDate = item[cal.dtz.startDateProp(item)];
|
||||
let itemEndDate = item[cal.dtz.endDateProp(item)];
|
||||
let itemStartDate = item[lazy.cal.dtz.startDateProp(item)];
|
||||
let itemEndDate = item[lazy.cal.dtz.endDateProp(item)];
|
||||
if (itemStartDate || itemEndDate) {
|
||||
// This is a task with a start or due date, format accordingly
|
||||
let prefixWhen = cal.l10n.getCalString("htmlPrefixWhen");
|
||||
let prefixWhen = lazy.cal.l10n.getCalString("htmlPrefixWhen");
|
||||
itemNode.querySelector(".intervalkey").textContent = prefixWhen;
|
||||
|
||||
let startNode = itemNode.querySelector(".dtstart");
|
||||
let dateString = cal.dtz.formatter.formatItemInterval(item);
|
||||
let dateString = lazy.cal.dtz.formatter.formatItemInterval(item);
|
||||
startNode.setAttribute("title", itemStartDate ? itemStartDate.icalString : "none");
|
||||
startNode.textContent = dateString;
|
||||
} else {
|
||||
|
@ -295,7 +296,7 @@ let listView = {
|
|||
}
|
||||
|
||||
let itemTitle = item.isCompleted
|
||||
? cal.l10n.getCalString("htmlTaskCompleted", [item.title])
|
||||
? lazy.cal.l10n.getCalString("htmlTaskCompleted", [item.title])
|
||||
: item.title;
|
||||
setupTextRow("summary", itemTitle, "htmlPrefixTitle");
|
||||
|
||||
|
@ -307,7 +308,7 @@ let listView = {
|
|||
|
||||
// Set the page title.
|
||||
endDate.day--;
|
||||
document.title = cal.dtz.formatter.formatInterval(startDate, endDate);
|
||||
document.title = lazy.cal.dtz.formatter.formatInterval(startDate, endDate);
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -338,19 +339,21 @@ let monthGridView = {
|
|||
} while (current.compare(endDate) < 0);
|
||||
|
||||
// Extend the date range to include adjacent days that will be printed.
|
||||
startDate = cal.weekInfoService.getStartOfWeek(startDate);
|
||||
startDate = lazy.cal.weekInfoService.getStartOfWeek(startDate);
|
||||
// Get the end of the week containing the last day of the month, not the
|
||||
// week containing the first day of the next month.
|
||||
endDate.day--;
|
||||
endDate = cal.weekInfoService.getEndOfWeek(endDate);
|
||||
endDate = lazy.cal.weekInfoService.getEndOfWeek(endDate);
|
||||
endDate.day++; // Add a day to include items from the last day.
|
||||
|
||||
// Get and display the items.
|
||||
let items = await getItems(startDate, endDate, filter, notDueTasks);
|
||||
let defaultTimezone = cal.dtz.defaultTimezone;
|
||||
let defaultTimezone = lazy.cal.dtz.defaultTimezone;
|
||||
for (let item of items) {
|
||||
let itemStartDate = item[cal.dtz.startDateProp(item)] || item[cal.dtz.endDateProp(item)];
|
||||
let itemEndDate = item[cal.dtz.endDateProp(item)] || item[cal.dtz.startDateProp(item)];
|
||||
let itemStartDate =
|
||||
item[lazy.cal.dtz.startDateProp(item)] || item[lazy.cal.dtz.endDateProp(item)];
|
||||
let itemEndDate =
|
||||
item[lazy.cal.dtz.endDateProp(item)] || item[lazy.cal.dtz.startDateProp(item)];
|
||||
|
||||
if (!itemStartDate && !itemEndDate) {
|
||||
addItemToDayboxNodate(document, item);
|
||||
|
@ -394,22 +397,22 @@ let monthGridView = {
|
|||
let month = monthTemplate.content.firstElementChild.cloneNode(true);
|
||||
|
||||
// Set up the month title
|
||||
let monthName = cal.l10n.formatMonth(startOfMonth.month + 1, "calendar", "monthInYear");
|
||||
let monthTitle = cal.l10n.getCalString("monthInYear", [monthName, startOfMonth.year]);
|
||||
let monthName = lazy.cal.l10n.formatMonth(startOfMonth.month + 1, "calendar", "monthInYear");
|
||||
let monthTitle = lazy.cal.l10n.getCalString("monthInYear", [monthName, startOfMonth.year]);
|
||||
month.rows[0].cells[0].firstElementChild.textContent = monthTitle;
|
||||
|
||||
// Set up the weekday titles
|
||||
let weekStart = Services.prefs.getIntPref("calendar.week.start", 0);
|
||||
for (let i = 0; i < 7; i++) {
|
||||
let dayNumber = ((i + weekStart) % 7) + 1;
|
||||
month.rows[1].cells[i].firstElementChild.textContent = cal.l10n.getDateFmtString(
|
||||
month.rows[1].cells[i].firstElementChild.textContent = lazy.cal.l10n.getDateFmtString(
|
||||
`day.${dayNumber}.Mmm`
|
||||
);
|
||||
}
|
||||
|
||||
// Set up each week
|
||||
let endOfMonthView = cal.weekInfoService.getEndOfWeek(startOfMonth.endOfMonth);
|
||||
let startOfMonthView = cal.weekInfoService.getStartOfWeek(startOfMonth);
|
||||
let endOfMonthView = lazy.cal.weekInfoService.getEndOfWeek(startOfMonth.endOfMonth);
|
||||
let startOfMonthView = lazy.cal.weekInfoService.getStartOfWeek(startOfMonth);
|
||||
let mainMonth = startOfMonth.month;
|
||||
|
||||
for (
|
||||
|
@ -499,10 +502,12 @@ let weekPlannerView = {
|
|||
|
||||
// Get and display the items.
|
||||
let items = await getItems(startDate, endDate, filter, notDueTasks);
|
||||
let defaultTimezone = cal.dtz.defaultTimezone;
|
||||
let defaultTimezone = lazy.cal.dtz.defaultTimezone;
|
||||
for (let item of items) {
|
||||
let itemStartDate = item[cal.dtz.startDateProp(item)] || item[cal.dtz.endDateProp(item)];
|
||||
let itemEndDate = item[cal.dtz.endDateProp(item)] || item[cal.dtz.startDateProp(item)];
|
||||
let itemStartDate =
|
||||
item[lazy.cal.dtz.startDateProp(item)] || item[lazy.cal.dtz.endDateProp(item)];
|
||||
let itemEndDate =
|
||||
item[lazy.cal.dtz.endDateProp(item)] || item[lazy.cal.dtz.startDateProp(item)];
|
||||
|
||||
if (!itemStartDate && !itemEndDate) {
|
||||
addItemToDayboxNodate(document, item);
|
||||
|
@ -524,9 +529,9 @@ let weekPlannerView = {
|
|||
// Set the page title.
|
||||
let weeks = container.querySelectorAll("table");
|
||||
if (weeks.length == 1) {
|
||||
document.title = cal.l10n.getCalString("singleLongCalendarWeek", [weeks[0].number]);
|
||||
document.title = lazy.cal.l10n.getCalString("singleLongCalendarWeek", [weeks[0].number]);
|
||||
} else {
|
||||
document.title = cal.l10n.getCalString("severalLongCalendarWeeks", [
|
||||
document.title = lazy.cal.l10n.getCalString("severalLongCalendarWeeks", [
|
||||
weeks[0].number,
|
||||
weeks[weeks.length - 1].number,
|
||||
]);
|
||||
|
@ -555,8 +560,8 @@ let weekPlannerView = {
|
|||
let week = weekTemplate.content.firstElementChild.cloneNode(true);
|
||||
|
||||
// Set up the week number title
|
||||
week.number = cal.weekInfoService.getWeekTitle(monday);
|
||||
week.querySelector(".week-title").textContent = cal.l10n.getCalString("WeekTitle", [
|
||||
week.number = lazy.cal.weekInfoService.getWeekTitle(monday);
|
||||
week.querySelector(".week-title").textContent = lazy.cal.l10n.getCalString("WeekTitle", [
|
||||
week.number,
|
||||
]);
|
||||
|
||||
|
@ -566,7 +571,7 @@ let weekPlannerView = {
|
|||
let day = week.rows[1].cells[i];
|
||||
|
||||
let titleNode = day.querySelector(".day-title");
|
||||
titleNode.textContent = cal.dtz.formatter.formatDateLong(currentDate);
|
||||
titleNode.textContent = lazy.cal.dtz.formatter.formatDateLong(currentDate);
|
||||
|
||||
this.dayTable[currentDate.icalString] = day.querySelector(".items");
|
||||
|
||||
|
|
|
@ -6,18 +6,17 @@ var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm"
|
|||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const lazy = {};
|
||||
|
||||
ChromeUtils.defineModuleGetter(lazy, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
/*
|
||||
/**
|
||||
* Helpers and base class for calendar providers
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.provider namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calprovider"]; /* exported calprovider */
|
||||
const EXPORTED_SYMBOLS = ["calprovider"];
|
||||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineModuleGetter(lazy, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
var calprovider = {
|
||||
/**
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
* 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/. */
|
||||
|
||||
/*
|
||||
/**
|
||||
* Helpers for the unifinder
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.unifinder namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calunifinder"]; /* exported calunifinder */
|
||||
const EXPORTED_SYMBOLS = ["calunifinder"];
|
||||
|
||||
var calunifinder = {
|
||||
/**
|
||||
|
|
|
@ -2,32 +2,6 @@
|
|||
* 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/. */
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
this,
|
||||
"gParserUtils",
|
||||
"@mozilla.org/parserutils;1",
|
||||
"nsIParserUtils"
|
||||
);
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
this,
|
||||
"gTextToHtmlConverter",
|
||||
"@mozilla.org/txttohtmlconv;1",
|
||||
"mozITXTToHTMLConv"
|
||||
);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"calendarSortOrder",
|
||||
"calendar.list.sortOrder",
|
||||
null,
|
||||
null,
|
||||
val => (val ? val.split(" ") : [])
|
||||
);
|
||||
|
||||
/**
|
||||
* View and DOM related helper functions
|
||||
*/
|
||||
|
@ -35,7 +9,33 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.view namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calview"]; /* exported calview */
|
||||
const EXPORTED_SYMBOLS = ["calview"];
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineModuleGetter(lazy, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
lazy,
|
||||
"gParserUtils",
|
||||
"@mozilla.org/parserutils;1",
|
||||
"nsIParserUtils"
|
||||
);
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
lazy,
|
||||
"gTextToHtmlConverter",
|
||||
"@mozilla.org/txttohtmlconv;1",
|
||||
"mozITXTToHTMLConv"
|
||||
);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
lazy,
|
||||
"calendarSortOrder",
|
||||
"calendar.list.sortOrder",
|
||||
null,
|
||||
null,
|
||||
val => (val ? val.split(" ") : [])
|
||||
);
|
||||
|
||||
var calview = {
|
||||
/**
|
||||
|
@ -172,8 +172,8 @@ var calview = {
|
|||
},
|
||||
onCalendarDeleting(calendar) {},
|
||||
};
|
||||
cal.manager.addObserver(calManagerObserver);
|
||||
aWindow.addEventListener("unload", () => cal.manager.removeObserver(calManagerObserver));
|
||||
lazy.cal.manager.addObserver(calManagerObserver);
|
||||
aWindow.addEventListener("unload", () => lazy.cal.manager.removeObserver(calManagerObserver));
|
||||
|
||||
comp.prefPrefix = prefix; // populate calendar from existing calendars
|
||||
|
||||
|
@ -358,7 +358,9 @@ var calview = {
|
|||
}
|
||||
|
||||
if (a.calendar && b.calendar) {
|
||||
cmp = calendarSortOrder.indexOf(a.calendar.id) - calendarSortOrder.indexOf(b.calendar.id);
|
||||
cmp =
|
||||
lazy.calendarSortOrder.indexOf(a.calendar.id) -
|
||||
lazy.calendarSortOrder.indexOf(b.calendar.id);
|
||||
if (cmp != 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
@ -369,7 +371,7 @@ var calview = {
|
|||
},
|
||||
|
||||
get calendarSortOrder() {
|
||||
return calendarSortOrder;
|
||||
return lazy.calendarSortOrder;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -386,18 +388,18 @@ var calview = {
|
|||
Ci.mozITXTToHTMLConv.kStructPhrase |
|
||||
Ci.mozITXTToHTMLConv.kGlyphSubstitution |
|
||||
Ci.mozITXTToHTMLConv.kURLs;
|
||||
html = gTextToHtmlConverter.scanTXT(text, mode);
|
||||
html = lazy.gTextToHtmlConverter.scanTXT(text, mode);
|
||||
html = html.replace(/\r?\n/g, "<br>");
|
||||
}
|
||||
|
||||
// Sanitize and convert the HTML into a document fragment.
|
||||
let flags =
|
||||
gParserUtils.SanitizerLogRemovals |
|
||||
gParserUtils.SanitizerDropForms |
|
||||
gParserUtils.SanitizerDropMedia;
|
||||
lazy.gParserUtils.SanitizerLogRemovals |
|
||||
lazy.gParserUtils.SanitizerDropForms |
|
||||
lazy.gParserUtils.SanitizerDropMedia;
|
||||
|
||||
let uri = Services.io.newURI(doc.baseURI);
|
||||
return gParserUtils.parseFragment(html, flags, false, uri, doc.createElement("div"));
|
||||
return lazy.gParserUtils.parseFragment(html, flags, false, uri, doc.createElement("div"));
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -418,7 +420,7 @@ var calview = {
|
|||
? body.innerText
|
||||
: entity; // Entity didn't decode to a character, so leave it
|
||||
});
|
||||
description = gTextToHtmlConverter.scanHTML(description, mode);
|
||||
description = lazy.gTextToHtmlConverter.scanHTML(description, mode);
|
||||
let stamp = item.stampTime;
|
||||
let lastModified = item.lastModifiedTime;
|
||||
item.descriptionHTML = description.replace(/\r?\n/g, "<br>");
|
||||
|
@ -441,9 +443,9 @@ calview.colorTracker = {
|
|||
// Deregistration is not required.
|
||||
registerWindow(aWindow) {
|
||||
if (this.calendars === null) {
|
||||
this.calendars = new Set(cal.manager.getCalendars());
|
||||
cal.manager.addObserver(this);
|
||||
cal.manager.addCalendarObserver(this);
|
||||
this.calendars = new Set(lazy.cal.manager.getCalendars());
|
||||
lazy.cal.manager.addObserver(this);
|
||||
lazy.cal.manager.addCalendarObserver(this);
|
||||
|
||||
this.categoryBranch = Services.prefs.getBranch("calendar.category.color.");
|
||||
this.categoryBranch.addObserver("", this);
|
||||
|
|
|
@ -2,26 +2,24 @@
|
|||
* 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/. */
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const lazy = {};
|
||||
|
||||
XPCOMUtils.defineLazyGetter(
|
||||
lazy,
|
||||
"l10nDeletePrompt",
|
||||
() => new Localization(["calendar/calendar-delete-prompt.ftl"], true)
|
||||
);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Calendar window helpers, e.g. to open our dialogs
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.window namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calwindow"]; /* exported calwindow */
|
||||
const EXPORTED_SYMBOLS = ["calwindow"];
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const lazy = {};
|
||||
XPCOMUtils.defineLazyGetter(
|
||||
lazy,
|
||||
"l10nDeletePrompt",
|
||||
() => new Localization(["calendar/calendar-delete-prompt.ftl"], true)
|
||||
);
|
||||
|
||||
var calwindow = {
|
||||
/**
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
* 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/. */
|
||||
|
||||
/*
|
||||
/**
|
||||
* Helper functions for parsing and serializing XML
|
||||
*/
|
||||
|
||||
// NOTE: This module should not be loaded directly, it is available when
|
||||
// including calUtils.jsm under the cal.xml namespace.
|
||||
|
||||
const EXPORTED_SYMBOLS = ["calxml"]; /* exported calxml */
|
||||
const EXPORTED_SYMBOLS = ["calxml"];
|
||||
|
||||
var calxml = {
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,9 @@ var { PluralForm } = ChromeUtils.import("resource://gre/modules/PluralForm.jsm")
|
|||
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
const lazy = {};
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
CalAttachment: "resource:///modules/CalAttachment.jsm",
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
});
|
||||
|
@ -526,7 +528,7 @@ CalAlarm.prototype = {
|
|||
// Set up attendees
|
||||
this.clearAttendees();
|
||||
for (let attendeeProp of cal.iterate.icalProperty(aComp, "ATTENDEE")) {
|
||||
let attendee = new CalAttendee();
|
||||
let attendee = new lazy.CalAttendee();
|
||||
attendee.icalProperty = attendeeProp;
|
||||
this.addAttendee(attendee);
|
||||
}
|
||||
|
@ -534,7 +536,7 @@ CalAlarm.prototype = {
|
|||
// Set up attachments
|
||||
this.clearAttachments();
|
||||
for (let attachProp of cal.iterate.icalProperty(aComp, "ATTACH")) {
|
||||
let attach = new CalAttachment();
|
||||
let attach = new lazy.CalAttachment();
|
||||
attach.icalProperty = attachProp;
|
||||
this.addAttachment(attach);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ var { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
|||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
const lazy = {};
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
CalEvent: "resource:///modules/CalEvent.jsm",
|
||||
CalTodo: "resource:///modules/CalTodo.jsm",
|
||||
CalRecurrenceInfo: "resource:///modules/CalRecurrenceInfo.jsm",
|
||||
|
@ -78,11 +80,11 @@ CalIcsParser.prototype = {
|
|||
|
||||
if (!parent) {
|
||||
// a parentless one, fake a master and override it's occurrence
|
||||
parent = item.isEvent() ? new CalEvent() : new CalTodo();
|
||||
parent = item.isEvent() ? new lazy.CalEvent() : new lazy.CalTodo();
|
||||
parent.id = item.id;
|
||||
parent.setProperty("DTSTART", item.recurrenceId);
|
||||
parent.setProperty("X-MOZ-FAKED-MASTER", "1"); // this tag might be useful in the future
|
||||
parent.recurrenceInfo = new CalRecurrenceInfo(parent);
|
||||
parent.recurrenceInfo = new lazy.CalRecurrenceInfo(parent);
|
||||
fakedParents[item.id] = true;
|
||||
state.uid2parent[item.id] = parent;
|
||||
state.items.push(parent);
|
||||
|
@ -268,7 +270,7 @@ parserState.prototype = {
|
|||
let item = null;
|
||||
switch (subComp.componentType) {
|
||||
case "VEVENT":
|
||||
item = new CalEvent();
|
||||
item = new lazy.CalEvent();
|
||||
item.icalComponent = subComp;
|
||||
if (isGCal) {
|
||||
cal.view.fixGoogleCalendarDescription(item);
|
||||
|
@ -277,7 +279,7 @@ parserState.prototype = {
|
|||
self.checkTimezone(item, item.endDate);
|
||||
break;
|
||||
case "VTODO":
|
||||
item = new CalTodo();
|
||||
item = new lazy.CalTodo();
|
||||
item.icalComponent = subComp;
|
||||
self.checkTimezone(item, item.entryDate);
|
||||
self.checkTimezone(item, item.dueDate);
|
||||
|
|
|
@ -13,7 +13,9 @@ var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm")
|
|||
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
var { ICAL, unwrapSingle } = ChromeUtils.import("resource:///modules/calendar/Ical.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(this, "gUseIcaljs", "calendar.icaljs", false);
|
||||
const lazy = {};
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(lazy, "gUseIcaljs", "calendar.icaljs", false);
|
||||
|
||||
Services.scriptloader.loadSubScript("resource:///components/calTimezone.js");
|
||||
|
||||
|
@ -158,7 +160,7 @@ CalTimezoneService.prototype = {
|
|||
get UTC() {
|
||||
if (!this.mZones.has("UTC")) {
|
||||
let utc;
|
||||
if (gUseIcaljs) {
|
||||
if (lazy.gUseIcaljs) {
|
||||
utc = new calICALJSTimezone(ICAL.Timezone.utcTimezone);
|
||||
} else {
|
||||
utc = new calLibicalTimezone("UTC", null, "", "");
|
||||
|
@ -174,7 +176,7 @@ CalTimezoneService.prototype = {
|
|||
get floating() {
|
||||
if (!this.mZones.has("floating")) {
|
||||
let floating;
|
||||
if (gUseIcaljs) {
|
||||
if (lazy.gUseIcaljs) {
|
||||
floating = new calICALJSTimezone(ICAL.Timezone.localTimezone);
|
||||
} else {
|
||||
floating = new calLibicalTimezone("floating", null, "", "");
|
||||
|
@ -216,7 +218,7 @@ CalTimezoneService.prototype = {
|
|||
"\r\n" +
|
||||
timezone.ics.join("\r\n") +
|
||||
"\r\nEND:VTIMEZONE";
|
||||
if (gUseIcaljs) {
|
||||
if (lazy.gUseIcaljs) {
|
||||
timezone.zone = new calICALJSTimezone(
|
||||
ICAL.Timezone.fromData({
|
||||
tzid,
|
||||
|
|
|
@ -9,7 +9,9 @@ var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm")
|
|||
const SUNDAY = 0;
|
||||
const THURSDAY = 4;
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(this, "startWeekday", "calendar.week.start", SUNDAY);
|
||||
const lazy = {};
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(lazy, "startWeekday", "calendar.week.start", SUNDAY);
|
||||
|
||||
function CalWeekInfoService() {
|
||||
this.wrappedJSObject = this;
|
||||
|
@ -55,11 +57,11 @@ CalWeekInfoService.prototype = {
|
|||
// The number of days since the start of the week.
|
||||
// Notice that the result of the subtraction might be negative.
|
||||
// We correct for that by adding 7, and then using the remainder operator.
|
||||
let sinceStartOfWeek = (aDateTime.weekday - startWeekday + 7) % 7;
|
||||
let sinceStartOfWeek = (aDateTime.weekday - lazy.startWeekday + 7) % 7;
|
||||
|
||||
// The number of days to Thursday is the difference between Thursday
|
||||
// and the start-day of the week (again corrected for negative values).
|
||||
let startToThursday = (THURSDAY - startWeekday + 7) % 7;
|
||||
let startToThursday = (THURSDAY - lazy.startWeekday + 7) % 7;
|
||||
|
||||
// The yearday number of the Thursday this week.
|
||||
let thisWeeksThursday = aDateTime.yearday - sinceStartOfWeek + startToThursday;
|
||||
|
@ -88,7 +90,7 @@ CalWeekInfoService.prototype = {
|
|||
getStartOfWeek(aDate) {
|
||||
let date = aDate.clone();
|
||||
date.isDate = true;
|
||||
let offset = startWeekday - aDate.weekday;
|
||||
let offset = lazy.startWeekday - aDate.weekday;
|
||||
date.day += offset;
|
||||
if (offset > 0) {
|
||||
date.day -= 7;
|
||||
|
|
|
@ -7,7 +7,9 @@ var EXPORTED_SYMBOLS = ["ItipChannel", "ItipProtocolHandler", "ItipContentHandle
|
|||
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
const lazy = {};
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
CalEvent: "resource:///modules/CalEvent.jsm",
|
||||
});
|
||||
|
||||
|
@ -94,7 +96,7 @@ ItipContentHandler.prototype = {
|
|||
paramBlock[parts[0]] = unescape(unescape(parts[1]));
|
||||
});
|
||||
// dump("content-handler: have params " + paramBlock.toSource() + "\n");
|
||||
let event = new CalEvent(paramBlock.data);
|
||||
let event = new lazy.CalEvent(paramBlock.data);
|
||||
dump(
|
||||
"Processing iTIP event '" +
|
||||
event.title +
|
||||
|
|
|
@ -17,7 +17,9 @@ const { CalStorageModelBase } = ChromeUtils.import(
|
|||
|
||||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
const lazy = {};
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
CalAttachment: "resource:///modules/CalAttachment.jsm",
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
|
@ -496,7 +498,7 @@ class CalStorageItemModel extends CalStorageModelBase {
|
|||
return;
|
||||
}
|
||||
|
||||
let attendee = new CalAttendee(row.getResultByName("icalString"));
|
||||
let attendee = new lazy.CalAttendee(row.getResultByName("icalString"));
|
||||
if (attendee && attendee.id) {
|
||||
if (attendee.isOrganizer) {
|
||||
item.organizer = attendee;
|
||||
|
@ -560,7 +562,7 @@ class CalStorageItemModel extends CalStorageModelBase {
|
|||
|
||||
let recInfo = item.recurrenceInfo;
|
||||
if (!recInfo) {
|
||||
recInfo = new CalRecurrenceInfo(item);
|
||||
recInfo = new lazy.CalRecurrenceInfo(item);
|
||||
item.recurrenceInfo = recInfo;
|
||||
}
|
||||
|
||||
|
@ -596,7 +598,7 @@ class CalStorageItemModel extends CalStorageModelBase {
|
|||
await this.db.executeAsync(this.statements.mSelectAllAttachments, row => {
|
||||
let item = itemsMap.get(row.getResultByName("item_id"));
|
||||
if (item) {
|
||||
item.addAttachment(new CalAttachment(row.getResultByName("icalString")));
|
||||
item.addAttachment(new lazy.CalAttachment(row.getResultByName("icalString")));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -604,7 +606,7 @@ class CalStorageItemModel extends CalStorageModelBase {
|
|||
await this.db.executeAsync(this.statements.mSelectAllRelations, row => {
|
||||
let item = itemsMap.get(row.getResultByName("item_id"));
|
||||
if (item) {
|
||||
item.addRelation(new CalRelation(row.getResultByName("icalString")));
|
||||
item.addRelation(new lazy.CalRelation(row.getResultByName("icalString")));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -612,7 +614,7 @@ class CalStorageItemModel extends CalStorageModelBase {
|
|||
await this.db.executeAsync(this.statements.mSelectAllAlarms, row => {
|
||||
let item = itemsMap.get(row.getResultByName("item_id"));
|
||||
if (item) {
|
||||
item.addAlarm(new CalAlarm(row.getResultByName("icalString")));
|
||||
item.addAlarm(new lazy.CalAlarm(row.getResultByName("icalString")));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -646,7 +648,7 @@ class CalStorageItemModel extends CalStorageModelBase {
|
|||
* @param {boolean} getAdditionalData
|
||||
*/
|
||||
async getEventFromRow(row, getAdditionalData = true) {
|
||||
let item = new CalEvent();
|
||||
let item = new lazy.CalEvent();
|
||||
let flags = row.getResultByName("flags");
|
||||
|
||||
if (row.getResultByName("event_start")) {
|
||||
|
@ -683,7 +685,7 @@ class CalStorageItemModel extends CalStorageModelBase {
|
|||
* @param {boolean} getAdditionalData
|
||||
*/
|
||||
async getTodoFromRow(row, getAdditionalData = true) {
|
||||
let item = new CalTodo();
|
||||
let item = new lazy.CalTodo();
|
||||
|
||||
if (row.getResultByName("todo_entry")) {
|
||||
item.entryDate = newDateTime(
|
||||
|
@ -740,7 +742,7 @@ class CalStorageItemModel extends CalStorageModelBase {
|
|||
this.db.prepareStatement(selectItem);
|
||||
selectItem.params.item_id = item.id;
|
||||
await this.db.executeAsync(selectItem, row => {
|
||||
let attendee = new CalAttendee(row.getResultByName("icalString"));
|
||||
let attendee = new lazy.CalAttendee(row.getResultByName("icalString"));
|
||||
if (attendee && attendee.id) {
|
||||
if (attendee.isOrganizer) {
|
||||
item.organizer = attendee;
|
||||
|
@ -813,7 +815,7 @@ class CalStorageItemModel extends CalStorageModelBase {
|
|||
throw Components.Exception("", Cr.NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
|
||||
let recInfo = new CalRecurrenceInfo(item);
|
||||
let recInfo = new lazy.CalRecurrenceInfo(item);
|
||||
item.recurrenceInfo = recInfo;
|
||||
|
||||
try {
|
||||
|
@ -884,7 +886,7 @@ class CalStorageItemModel extends CalStorageModelBase {
|
|||
this.db.prepareStatement(selectAttachment);
|
||||
selectAttachment.params.item_id = item.id;
|
||||
await this.db.executeAsync(selectAttachment, row => {
|
||||
item.addAttachment(new CalAttachment(row.getResultByName("icalString")));
|
||||
item.addAttachment(new lazy.CalAttachment(row.getResultByName("icalString")));
|
||||
});
|
||||
} catch (e) {
|
||||
this.db.logError(
|
||||
|
@ -904,7 +906,7 @@ class CalStorageItemModel extends CalStorageModelBase {
|
|||
this.db.prepareStatement(selectRelation);
|
||||
selectRelation.params.item_id = item.id;
|
||||
await this.db.executeAsync(selectRelation, row => {
|
||||
item.addRelation(new CalRelation(row.getResultByName("icalString")));
|
||||
item.addRelation(new lazy.CalRelation(row.getResultByName("icalString")));
|
||||
});
|
||||
} catch (e) {
|
||||
this.db.logError(
|
||||
|
@ -924,7 +926,7 @@ class CalStorageItemModel extends CalStorageModelBase {
|
|||
selectAlarm.params.item_id = item.id;
|
||||
this.db.prepareStatement(selectAlarm);
|
||||
await this.db.executeAsync(selectAlarm, row => {
|
||||
item.addAlarm(new CalAlarm(row.getResultByName("icalString")));
|
||||
item.addAlarm(new lazy.CalAlarm(row.getResultByName("icalString")));
|
||||
});
|
||||
} catch (e) {
|
||||
this.db.logError(
|
||||
|
|
|
@ -66,7 +66,14 @@
|
|||
* please file a bug.
|
||||
*/
|
||||
|
||||
/* exported upgradeDB */
|
||||
var EXPORTED_SYMBOLS = [
|
||||
"DB_SCHEMA_VERSION",
|
||||
"getSql",
|
||||
"getAllSql",
|
||||
"getSqlTable",
|
||||
"upgradeDB",
|
||||
"backupDB",
|
||||
];
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
|
@ -75,7 +82,9 @@ var { CAL_ITEM_FLAG, textToDate, getTimezone, newDateTime } = ChromeUtils.import
|
|||
);
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
const lazy = {};
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
CalAttachment: "resource:///modules/CalAttachment.jsm",
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
|
@ -86,15 +95,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
// updater.
|
||||
var DB_SCHEMA_VERSION = 23;
|
||||
|
||||
var EXPORTED_SYMBOLS = [
|
||||
"DB_SCHEMA_VERSION",
|
||||
"getSql",
|
||||
"getAllSql",
|
||||
"getSqlTable",
|
||||
"upgradeDB",
|
||||
"backupDB",
|
||||
];
|
||||
|
||||
/**
|
||||
* Gets the SQL for the given table data and table name. This can be both a real
|
||||
* table or the name of an index. Indexes must contain the idx_ prefix.
|
||||
|
@ -1277,7 +1277,7 @@ upgrade.v16 = function(db, version) {
|
|||
try {
|
||||
let [aOffset, aRelated, aAlarmTime, aTzId] = mapStorageArgs(storArgs);
|
||||
|
||||
let alarm = new CalAlarm();
|
||||
let alarm = new lazy.CalAlarm();
|
||||
if (aOffset) {
|
||||
alarm.related = parseInt(aRelated, 10) + 1;
|
||||
alarm.offset = cal.createDuration();
|
||||
|
@ -1630,7 +1630,7 @@ upgrade.v22 = function(db, version) {
|
|||
try {
|
||||
let [aData, aFmtType, aEncoding] = mapStorageArgs(storArgs);
|
||||
|
||||
let attach = new CalAttachment();
|
||||
let attach = new lazy.CalAttachment();
|
||||
attach.uri = Services.io.newURI(aData);
|
||||
attach.formatType = aFmtType;
|
||||
attach.encoding = aEncoding;
|
||||
|
@ -1654,7 +1654,7 @@ upgrade.v22 = function(db, version) {
|
|||
onFunctionCall(storArgs) {
|
||||
try {
|
||||
let [aRelType, aRelId] = mapStorageArgs(storArgs);
|
||||
let relation = new CalRelation();
|
||||
let relation = new lazy.CalRelation();
|
||||
relation.relType = aRelType;
|
||||
relation.relId = aRelId;
|
||||
return relation.icalString;
|
||||
|
@ -1681,7 +1681,7 @@ upgrade.v22 = function(db, version) {
|
|||
aProperties,
|
||||
] = mapStorageArgs(storArgs);
|
||||
|
||||
let attendee = new CalAttendee();
|
||||
let attendee = new lazy.CalAttendee();
|
||||
|
||||
attendee.id = aAttendeeId;
|
||||
attendee.commonName = aCommonName;
|
||||
|
|
|
@ -19,8 +19,10 @@ var { TestUtils } = ChromeUtils.import("resource://testing-common/TestUtils.jsm"
|
|||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const lazy = {};
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
lazy,
|
||||
"CalendarTestUtils",
|
||||
"resource://testing-common/calendar/CalendarTestUtils.jsm"
|
||||
);
|
||||
|
@ -63,7 +65,7 @@ async function execEventDialogCallback(callback) {
|
|||
let eventWindow = Services.wm.getMostRecentWindow(EVENT_DIALOG_NAME);
|
||||
|
||||
if (!eventWindow) {
|
||||
eventWindow = await CalendarTestUtils.waitForEventDialog("edit");
|
||||
eventWindow = await lazy.CalendarTestUtils.waitForEventDialog("edit");
|
||||
}
|
||||
|
||||
let iframe = eventWindow.document.getElementById("calendar-item-panel-iframe");
|
||||
|
@ -80,6 +82,6 @@ async function execEventDialogCallback(callback) {
|
|||
* @param {number} day - Day to check between 1-7.
|
||||
*/
|
||||
function checkMonthAlarmIcon(window, week, day) {
|
||||
let dayBox = CalendarTestUtils.monthView.getItemAt(window, week, day, 1);
|
||||
let dayBox = lazy.CalendarTestUtils.monthView.getItemAt(window, week, day, 1);
|
||||
Assert.ok(dayBox.querySelector(".alarm-icons-box > .reminder-icon"));
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче