Bug 1659558 - Part 8: Convert `cal.createRecurrenceInfo()` to `new CalRecurrenceInfo()`. r=darktrojan

Differential Revision: https://phabricator.services.mozilla.com/D89276

--HG--
extra : rebase_source : 8a1b0dce7983dd054c04a7f8138081e1fae98365
This commit is contained in:
Paul Morris 2020-09-03 14:29:58 -04:00
Родитель a26956574a
Коммит 6ad3790174
10 изменённых файлов: 38 добавлений и 15 удалений

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

@ -11,6 +11,11 @@ var { splitRecurrenceRules } = ChromeUtils.import(
);
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
CalRecurrenceInfo: "resource:///modules/CalRecurrenceInfo.jsm",
});
var gIsReadOnly = false;
var gStartTime = null;
@ -622,7 +627,7 @@ function onSave(item) {
}
recurrenceInfo.item = item;
} else {
recurrenceInfo = cal.createRecurrenceInfo(item);
recurrenceInfo = new CalRecurrenceInfo(item);
}
let recRule = cal.createRecurrenceRule();

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

@ -39,11 +39,6 @@ var cal = {
Ci.calIRecurrenceRule,
"icalString"
),
createRecurrenceInfo: _instance(
"@mozilla.org/calendar/recurrence-info;1",
Ci.calIRecurrenceInfo,
"item"
),
getCalendarManager: _service("@mozilla.org/calendar/manager;1", "calICalendarManager"),
getIcsService: _service("@mozilla.org/calendar/ics-service;1", "calIICSService"),

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

@ -12,6 +12,7 @@ var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm")
XPCOMUtils.defineLazyModuleGetters(this, {
CalEvent: "resource:///modules/CalEvent.jsm",
CalTodo: "resource:///modules/CalTodo.jsm",
CalRecurrenceInfo: "resource:///modules/CalRecurrenceInfo.jsm",
});
function CalIcsParser() {
@ -80,7 +81,7 @@ CalIcsParser.prototype = {
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 = cal.createRecurrenceInfo(parent);
parent.recurrenceInfo = new CalRecurrenceInfo(parent);
fakedParents[item.id] = true;
state.uid2parent[item.id] = parent;
state.items.push(parent);

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

@ -17,10 +17,20 @@ function getRidKey(date) {
return date.icalString;
}
function CalRecurrenceInfo() {
/**
* Constructor for `calIRecurrenceInfo` objects.
*
* @class
* @implements {calIRecurrenceInfo}
* @param {calIItemBase} [item] - Optional calendar item for which this recurrence applies.
*/
function CalRecurrenceInfo(item) {
this.wrappedJSObject = this;
this.mRecurrenceItems = [];
this.mExceptionMap = {};
if (item) {
this.item = item;
}
}
CalRecurrenceInfo.prototype = {

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

@ -12,6 +12,7 @@ var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm")
XPCOMUtils.defineLazyModuleGetters(this, {
CalAlarm: "resource:///modules/CalAlarm.jsm",
CalRecurrenceInfo: "resource:///modules/CalRecurrenceInfo.jsm",
});
/**
@ -861,7 +862,7 @@ calItemBase.prototype = {
ritem.icalProperty = recprop;
if (!rec) {
rec = cal.createRecurrenceInfo(this);
rec = new CalRecurrenceInfo(this);
}
rec.appendRecurrenceItem(ritem);
}

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

@ -35,6 +35,7 @@ var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm")
XPCOMUtils.defineLazyModuleGetters(this, {
CalAttachment: "resource:///modules/CalAttachment.jsm",
CalAttendee: "resource:///modules/CalAttendee.jsm",
CalRecurrenceInfo: "resource:///modules/CalRecurrenceInfo.jsm",
});
var cloudFileAccounts;
@ -2945,7 +2946,7 @@ function updateRepeat(aSuppressDialogs, aItemRepeatCall) {
}
} else {
// New event proposes "forever" as default until date.
recurrenceInfo = cal.createRecurrenceInfo(item);
recurrenceInfo = new CalRecurrenceInfo(item);
setElementValue("repeat-until-datepicker", "forever");
}

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

@ -18,6 +18,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
CalAttachment: "resource:///modules/CalAttachment.jsm",
CalAttendee: "resource:///modules/CalAttendee.jsm",
CalEvent: "resource:///modules/CalEvent.jsm",
CalRecurrenceInfo: "resource:///modules/CalRecurrenceInfo.jsm",
CalRelation: "resource:///modules/CalRelation.jsm",
CalTodo: "resource:///modules/CalTodo.jsm",
});
@ -1765,7 +1766,7 @@ CalStorageCalendar.prototype = {
let recInfo = item.recurrenceInfo;
if (!recInfo) {
recInfo = cal.createRecurrenceInfo(item);
recInfo = new CalRecurrenceInfo(item);
item.recurrenceInfo = recInfo;
}
@ -1991,7 +1992,7 @@ CalStorageCalendar.prototype = {
throw Components.Exception("", Cr.NS_ERROR_UNEXPECTED);
}
let recInfo = cal.createRecurrenceInfo(item);
let recInfo = new CalRecurrenceInfo(item);
item.recurrenceInfo = recInfo;
try {

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

@ -8,10 +8,12 @@ var { CALENDARNAME, createCalendar, deleteCalendars } = ChromeUtils.import(
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
CalRecurrenceInfo: "resource:///modules/CalRecurrenceInfo.jsm",
CalTodo: "resource:///modules/CalTodo.jsm",
});
var mozmill = ChromeUtils.import("resource://testing-common/mozmill/mozmill.jsm");
var controller = mozmill.getMail3PaneController();
var calendarId = createCalendar(controller, CALENDARNAME);
@ -118,7 +120,7 @@ add_task(async () => {
let repeatingTask = new CalTodo();
repeatingTask.title = "Repeating";
repeatingTask.entryDate = yesterday;
repeatingTask.recurrenceInfo = cal.createRecurrenceInfo(repeatingTask);
repeatingTask.recurrenceInfo = new CalRecurrenceInfo(repeatingTask);
repeatingTask.recurrenceInfo.appendRecurrenceItem(
cal.createRecurrenceRule("RRULE:FREQ=DAILY;COUNT=3")
);

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

@ -8,6 +8,7 @@ var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm")
XPCOMUtils.defineLazyModuleGetters(this, {
CalAlarm: "resource:///modules/CalAlarm.jsm",
CalEvent: "resource:///modules/CalEvent.jsm",
CalRecurrenceInfo: "resource:///modules/CalRecurrenceInfo.jsm",
});
var EXPECT_NONE = 0;
@ -189,7 +190,7 @@ function createEventWithAlarm(aCalendar, aStart, aEnd, aOffset, aRRule) {
item.addAlarm(alarm);
}
if (aRRule) {
item.recurrenceInfo = cal.createRecurrenceInfo(item);
item.recurrenceInfo = new CalRecurrenceInfo(item);
item.recurrenceInfo.appendRecurrenceItem(cal.createRecurrenceRule(aRRule));
}
return [item, alarm];

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

@ -2,6 +2,12 @@
* 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 { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
CalRecurrenceInfo: "resource:///modules/CalRecurrenceInfo.jsm",
});
function makeEvent(str) {
return createEventFromIcalString("BEGIN:VEVENT\n" + str + "END:VEVENT");
}
@ -1116,7 +1122,7 @@ function test_failures() {
/Illegal value/,
"Invalid Argument"
);
throws(() => cal.createRecurrenceInfo().isFinite, /Component not initialized/);
throws(() => new CalRecurrenceInfo().isFinite, /Component not initialized/);
// modifyException with a different parent item
let occ = rinfo.getOccurrenceFor(cal.createDateTime("20120102T114500Z"));