Bug 1659558 - Part 6: Convert `cal.createAlarm()` to `new CalAlarm()`. r=darktrojan
Differential Revision: https://phabricator.services.mozilla.com/D89273 --HG-- extra : rebase_source : f873f68d9591ce9d4f7a32140335f3264a0da11a
This commit is contained in:
Родитель
6863b2ab8d
Коммит
4ada409e33
|
@ -15,6 +15,11 @@
|
|||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
});
|
||||
|
||||
// Variables related to whether we are in a tab or a window dialog.
|
||||
var gInTab = false;
|
||||
|
@ -106,7 +111,7 @@ function applyPersistedProperties(aDialog) {
|
|||
* @return The calIAlarm with information from the menuitem.
|
||||
*/
|
||||
function createReminderFromMenuitem(aMenuitem, aCalendar) {
|
||||
let reminder = aMenuitem.reminder || cal.createAlarm();
|
||||
let reminder = aMenuitem.reminder || new CalAlarm();
|
||||
// clone immutable reminders if necessary to set default values
|
||||
let isImmutable = !reminder.isMutable;
|
||||
if (isImmutable) {
|
||||
|
@ -118,8 +123,8 @@ function createReminderFromMenuitem(aMenuitem, aCalendar) {
|
|||
offset.isNegative = aMenuitem.getAttribute("origin") == "before";
|
||||
reminder.related =
|
||||
aMenuitem.getAttribute("relation") == "START"
|
||||
? reminder.ALARM_RELATED_START
|
||||
: reminder.ALARM_RELATED_END;
|
||||
? Ci.calIAlarm.ALARM_RELATED_START
|
||||
: Ci.calIAlarm.ALARM_RELATED_END;
|
||||
reminder.offset = offset;
|
||||
reminder.action = getDefaultAlarmType(aCalendar);
|
||||
// make reminder immutable in case it was before
|
||||
|
@ -224,7 +229,7 @@ function updateReminderDetails(reminderDetails, reminderList, calendar) {
|
|||
// This is one of the predefined dropdown items. We should show a
|
||||
// single icon in the icons box to tell the user what kind of alarm
|
||||
// this will be.
|
||||
let mockAlarm = cal.createAlarm();
|
||||
let mockAlarm = new CalAlarm();
|
||||
mockAlarm.action = getDefaultAlarmType(calendar);
|
||||
cal.alarms.addReminderImages(iconBox, [mockAlarm]);
|
||||
}
|
||||
|
@ -249,7 +254,7 @@ function matchCustomReminderToMenuitem(reminder, reminderList, calendar) {
|
|||
) {
|
||||
// Exactly one reminder that's not absolute, we may be able to match up
|
||||
// popup items.
|
||||
let relation = reminder.related == reminder.ALARM_RELATED_START ? "START" : "END";
|
||||
let relation = reminder.related == Ci.calIAlarm.ALARM_RELATED_START ? "START" : "END";
|
||||
|
||||
// If the time duration for offset is 0, means the reminder is '0 minutes before'
|
||||
let origin = reminder.offset.inSeconds == 0 || reminder.offset.isNegative ? "before" : "after";
|
||||
|
@ -483,7 +488,7 @@ function commonUpdateReminder(
|
|||
let reminders = menuitem.reminders || [createReminderFromMenuitem(menuitem, calendar)];
|
||||
|
||||
// If a reminder is related to the entry date...
|
||||
if (reminders.some(x => x.related == x.ALARM_RELATED_START)) {
|
||||
if (reminders.some(x => x.related == Ci.calIAlarm.ALARM_RELATED_START)) {
|
||||
// ...automatically check 'has entrydate'.
|
||||
if (!getElementValue("todo-has-entrydate", "checked")) {
|
||||
setElementValue("todo-has-entrydate", "true", "checked");
|
||||
|
@ -497,7 +502,7 @@ function commonUpdateReminder(
|
|||
}
|
||||
|
||||
// If a reminder is related to the due date...
|
||||
if (reminders.some(x => x.related == x.ALARM_RELATED_END)) {
|
||||
if (reminders.some(x => x.related == Ci.calIAlarm.ALARM_RELATED_END)) {
|
||||
// ...automatically check 'has duedate'.
|
||||
if (!getElementValue("todo-has-duedate", "checked")) {
|
||||
setElementValue("todo-has-duedate", "true", "checked");
|
||||
|
|
|
@ -13,6 +13,10 @@ var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
});
|
||||
|
||||
var allowedActionsMap = {};
|
||||
var suppressListUpdate = false;
|
||||
|
||||
|
@ -395,7 +399,7 @@ function onNewReminder() {
|
|||
let itemType = cal.item.isEvent(window.arguments[0].item) ? "event" : "todo";
|
||||
let listbox = document.getElementById("reminder-listbox");
|
||||
|
||||
let reminder = cal.createAlarm();
|
||||
let reminder = new CalAlarm();
|
||||
let alarmlen = Services.prefs.getIntPref("calendar.alarms." + itemType + "alarmlen", 15);
|
||||
let alarmunit = Services.prefs.getStringPref(
|
||||
"calendar.alarms." + itemType + "alarmunit",
|
||||
|
@ -415,7 +419,7 @@ function onNewReminder() {
|
|||
}
|
||||
offset.normalize();
|
||||
offset.isNegative = true;
|
||||
reminder.related = reminder.ALARM_RELATED_START;
|
||||
reminder.related = Ci.calIAlarm.ALARM_RELATED_START;
|
||||
reminder.offset = offset;
|
||||
if ("DISPLAY" in allowedActionsMap) {
|
||||
reminder.action = "DISPLAY";
|
||||
|
|
|
@ -29,7 +29,6 @@ var cal = {
|
|||
// as well as getting services and other (cached) objects.
|
||||
createDateTime: _instance("@mozilla.org/calendar/datetime;1", Ci.calIDateTime, "icalString"),
|
||||
createDuration: _instance("@mozilla.org/calendar/duration;1", Ci.calIDuration, "icalString"),
|
||||
createAlarm: _instance("@mozilla.org/calendar/alarm;1", Ci.calIAlarm, "icalString"),
|
||||
createRelation: _instance("@mozilla.org/calendar/relation;1", Ci.calIRelation, "icalString"),
|
||||
createRecurrenceDate: _instance(
|
||||
"@mozilla.org/calendar/recurrence-date;1",
|
||||
|
|
|
@ -3,9 +3,14 @@
|
|||
* 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
|
||||
*/
|
||||
|
@ -27,7 +32,7 @@ var calalarms = {
|
|||
let type = cal.item.isEvent(aItem) ? "event" : "todo";
|
||||
if (Services.prefs.getIntPref("calendar.alarms.onfor" + type + "s", 0) == 1) {
|
||||
let alarmOffset = cal.createDuration();
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
let units = Services.prefs.getStringPref("calendar.alarms." + type + "alarmunit", "minutes");
|
||||
|
||||
// Make sure the alarm pref is valid, default to minutes otherwise
|
||||
|
@ -63,13 +68,13 @@ var calalarms = {
|
|||
* @return The alarm date.
|
||||
*/
|
||||
calculateAlarmDate(aItem, aAlarm) {
|
||||
if (aAlarm.related == aAlarm.ALARM_RELATED_ABSOLUTE) {
|
||||
if (aAlarm.related == Ci.calIAlarm.ALARM_RELATED_ABSOLUTE) {
|
||||
return aAlarm.alarmDate;
|
||||
}
|
||||
let returnDate;
|
||||
if (aAlarm.related == aAlarm.ALARM_RELATED_START) {
|
||||
if (aAlarm.related == Ci.calIAlarm.ALARM_RELATED_START) {
|
||||
returnDate = aItem[cal.dtz.startDateProp(aItem)];
|
||||
} else if (aAlarm.related == aAlarm.ALARM_RELATED_END) {
|
||||
} else if (aAlarm.related == Ci.calIAlarm.ALARM_RELATED_END) {
|
||||
returnDate = aItem[cal.dtz.endDateProp(aItem)];
|
||||
}
|
||||
|
||||
|
@ -110,11 +115,11 @@ var calalarms = {
|
|||
*/
|
||||
calculateAlarmOffset(aItem, aAlarm, aRelated) {
|
||||
let offset = aAlarm.offset;
|
||||
if (aAlarm.related == aAlarm.ALARM_RELATED_ABSOLUTE) {
|
||||
if (aAlarm.related == Ci.calIAlarm.ALARM_RELATED_ABSOLUTE) {
|
||||
let returnDate;
|
||||
if (aRelated === undefined || aRelated == aAlarm.ALARM_RELATED_START) {
|
||||
if (aRelated === undefined || aRelated == Ci.calIAlarm.ALARM_RELATED_START) {
|
||||
returnDate = aItem[cal.dtz.startDateProp(aItem)];
|
||||
} else if (aRelated == aAlarm.ALARM_RELATED_END) {
|
||||
} else if (aRelated == Ci.calIAlarm.ALARM_RELATED_END) {
|
||||
returnDate = aItem[cal.dtz.endDateProp(aItem)];
|
||||
}
|
||||
|
||||
|
|
|
@ -13,16 +13,26 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
});
|
||||
|
||||
var ALARM_RELATED_ABSOLUTE = Ci.calIAlarm.ALARM_RELATED_ABSOLUTE;
|
||||
var ALARM_RELATED_START = Ci.calIAlarm.ALARM_RELATED_START;
|
||||
var ALARM_RELATED_END = Ci.calIAlarm.ALARM_RELATED_END;
|
||||
const ALARM_RELATED_ABSOLUTE = Ci.calIAlarm.ALARM_RELATED_ABSOLUTE;
|
||||
const ALARM_RELATED_START = Ci.calIAlarm.ALARM_RELATED_START;
|
||||
const ALARM_RELATED_END = Ci.calIAlarm.ALARM_RELATED_END;
|
||||
|
||||
function CalAlarm() {
|
||||
/**
|
||||
* Constructor for `calIAlarm` objects.
|
||||
*
|
||||
* @class
|
||||
* @implements {calIAlarm}
|
||||
* @param {string} [icalString] - Optional iCal string for initializing existing alarms.
|
||||
*/
|
||||
function CalAlarm(icalString) {
|
||||
this.wrappedJSObject = this;
|
||||
this.mProperties = new Map();
|
||||
this.mPropertyParams = {};
|
||||
this.mAttendees = [];
|
||||
this.mAttachments = [];
|
||||
if (icalString) {
|
||||
this.icalString = icalString;
|
||||
}
|
||||
}
|
||||
|
||||
CalAlarm.prototype = {
|
||||
|
@ -209,7 +219,7 @@ CalAlarm.prototype = {
|
|||
},
|
||||
|
||||
get repeat() {
|
||||
if ((this.mRepeat != 0) ^ (this.mDuration != null)) {
|
||||
if (!this.mDuration) {
|
||||
return 0;
|
||||
}
|
||||
return this.mRepeat || 0;
|
||||
|
@ -227,7 +237,7 @@ CalAlarm.prototype = {
|
|||
},
|
||||
|
||||
get repeatOffset() {
|
||||
if ((this.mRepeat != 0) ^ (this.mDuration != null)) {
|
||||
if (!this.mRepeat) {
|
||||
return null;
|
||||
}
|
||||
return this.mDuration;
|
||||
|
|
|
@ -8,6 +8,11 @@ var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
|||
var { CalAttendee } = ChromeUtils.import("resource:///modules/CalAttendee.jsm");
|
||||
var { CalRelation } = ChromeUtils.import("resource:///modules/CalRelation.jsm");
|
||||
var { CalAttachment } = ChromeUtils.import("resource:///modules/CalAttachment.jsm");
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
});
|
||||
|
||||
/**
|
||||
* calItemBase prototype definition
|
||||
|
@ -865,7 +870,7 @@ calItemBase.prototype = {
|
|||
|
||||
this.mAlarms = []; // don't inherit anything from parent
|
||||
for (let alarmComp of cal.iterate.icalSubcomponent(icalcomp, "VALARM")) {
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
try {
|
||||
alarm.icalComponent = alarmComp;
|
||||
this.addAlarm(alarm, true);
|
||||
|
|
|
@ -9,6 +9,7 @@ var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
CalEvent: "resource:///modules/CalEvent.jsm",
|
||||
});
|
||||
|
||||
|
@ -352,8 +353,8 @@ CalOutlookCSVImporter.prototype = {
|
|||
);
|
||||
// Only set the alarm if a date was parsed
|
||||
if (alarmDate) {
|
||||
let alarm = cal.createAlarm();
|
||||
alarm.related = alarm.ALARM_RELATED_ABSOLUTE;
|
||||
let alarm = new CalAlarm();
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_ABSOLUTE;
|
||||
alarm.alarmDate = alarmDate;
|
||||
event.addAlarm(alarm);
|
||||
} else {
|
||||
|
|
|
@ -14,6 +14,7 @@ var { CAL_ITEM_FLAG, newDateTime } = ChromeUtils.import(
|
|||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
CalAttachment: "resource:///modules/CalAttachment.jsm",
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
CalEvent: "resource:///modules/CalEvent.jsm",
|
||||
|
@ -1815,7 +1816,7 @@ CalStorageCalendar.prototype = {
|
|||
await this.executeAsync(this.mSelectAllAlarms, row => {
|
||||
let item = itemsMap.get(row.getResultByName("item_id"));
|
||||
if (item) {
|
||||
item.addAlarm(cal.createAlarm(row.getResultByName("icalString")));
|
||||
item.addAlarm(new CalAlarm(row.getResultByName("icalString")));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2100,7 +2101,7 @@ CalStorageCalendar.prototype = {
|
|||
selectAlarm.params.item_id = item.id;
|
||||
this.prepareStatement(selectAlarm);
|
||||
await this.executeAsync(selectAlarm, row => {
|
||||
item.addAlarm(cal.createAlarm(row.getResultByName("icalString")));
|
||||
item.addAlarm(new CalAlarm(row.getResultByName("icalString")));
|
||||
});
|
||||
} catch (e) {
|
||||
this.logError("Error getting alarms for item '" + item.title + "' (" + item.id + ")!", e);
|
||||
|
|
|
@ -76,6 +76,7 @@ var { CAL_ITEM_FLAG, textToDate, getTimezone, newDateTime } = ChromeUtils.import
|
|||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
CalAttachment: "resource:///modules/CalAttachment.jsm",
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
});
|
||||
|
@ -1275,7 +1276,7 @@ upgrade.v16 = function(db, version) {
|
|||
try {
|
||||
let [aOffset, aRelated, aAlarmTime, aTzId] = mapStorageArgs(storArgs);
|
||||
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
if (aOffset) {
|
||||
alarm.related = parseInt(aRelated, 10) + 1;
|
||||
alarm.offset = cal.createDuration();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
CalAttachment: "resource:///modules/CalAttachment.jsm",
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
CalTodo: "resource:///modules/CalTodo.jsm",
|
||||
|
@ -33,7 +34,7 @@ function run_test() {
|
|||
|
||||
function test_initial_creation() {
|
||||
dump("Testing initial creation...");
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
|
||||
let passed;
|
||||
try {
|
||||
|
@ -51,7 +52,7 @@ function test_initial_creation() {
|
|||
|
||||
function test_display_alarm() {
|
||||
dump("Testing DISPLAY alarms...");
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
// Set ACTION to DISPLAY, make sure this was not rejected
|
||||
alarm.action = "DISPLAY";
|
||||
equal(alarm.action, "DISPLAY");
|
||||
|
@ -83,7 +84,7 @@ function test_display_alarm() {
|
|||
|
||||
function test_email_alarm() {
|
||||
dump("Testing EMAIL alarms...");
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
// Set ACTION to DISPLAY, make sure this was not rejected
|
||||
alarm.action = "EMAIL";
|
||||
equal(alarm.action, "EMAIL");
|
||||
|
@ -145,7 +146,7 @@ function test_email_alarm() {
|
|||
|
||||
function test_audio_alarm() {
|
||||
dump("Testing AUDIO alarms...");
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_ABSOLUTE;
|
||||
alarm.alarmDate = cal.createDateTime();
|
||||
// Set ACTION to AUDIO, make sure this was not rejected
|
||||
|
@ -226,7 +227,7 @@ function test_audio_alarm() {
|
|||
|
||||
function test_custom_alarm() {
|
||||
dump("Testing X-SMS (custom) alarms...");
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
// Set ACTION to a custom value, make sure this was not rejected
|
||||
alarm.action = "X-SMS";
|
||||
equal(alarm.action, "X-SMS");
|
||||
|
@ -285,7 +286,7 @@ function test_custom_alarm() {
|
|||
// Check if any combination of REPEAT and DURATION work as expected.
|
||||
function test_repeat() {
|
||||
dump("Testing REPEAT and DURATION properties...");
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
|
||||
// Check initial value
|
||||
equal(alarm.repeat, 0);
|
||||
|
@ -317,7 +318,7 @@ function test_repeat() {
|
|||
equal(alarm.repeatOffset, null);
|
||||
|
||||
// Check repeatDate
|
||||
alarm = cal.createAlarm();
|
||||
alarm = new CalAlarm();
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_ABSOLUTE;
|
||||
alarm.alarmDate = cal.createDateTime();
|
||||
alarm.repeat = 1;
|
||||
|
@ -333,7 +334,7 @@ function test_repeat() {
|
|||
|
||||
function test_xprop() {
|
||||
dump("Testing X-Props...");
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
alarm.setProperty("X-PROP", "X-VALUE");
|
||||
ok(alarm.hasProperty("X-PROP"));
|
||||
equal(alarm.getProperty("X-PROP"), "X-VALUE");
|
||||
|
@ -359,7 +360,7 @@ function test_dates() {
|
|||
dump("Testing alarm dates...");
|
||||
let passed;
|
||||
// Initial value
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
equal(alarm.alarmDate, null);
|
||||
equal(alarm.offset, null);
|
||||
|
||||
|
@ -419,7 +420,7 @@ var clonePropMap = {
|
|||
|
||||
function test_immutable() {
|
||||
dump("Testing immutable alarms...");
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
// Set up each attribute
|
||||
for (let prop in propMap) {
|
||||
alarm[prop] = propMap[prop];
|
||||
|
@ -464,7 +465,7 @@ function test_immutable() {
|
|||
|
||||
function test_clone() {
|
||||
dump("Testing cloning alarms...");
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
// Set up each attribute
|
||||
for (let prop in propMap) {
|
||||
alarm[prop] = propMap[prop];
|
||||
|
@ -528,7 +529,7 @@ function test_clone() {
|
|||
|
||||
function test_serialize() {
|
||||
// most checks done by other tests, these don't fit into categories
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
let srv = cal.getIcsService();
|
||||
|
||||
throws(
|
||||
|
@ -645,7 +646,7 @@ function test_serialize() {
|
|||
function test_strings() {
|
||||
// Serializing the string shouldn't throw, but we don't really care about
|
||||
// the string itself.
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
alarm.action = "DISPLAY";
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_ABSOLUTE;
|
||||
alarm.alarmDate = cal.createDateTime();
|
||||
|
|
|
@ -6,6 +6,7 @@ var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
CalEvent: "resource:///modules/CalEvent.jsm",
|
||||
});
|
||||
|
||||
|
@ -167,7 +168,7 @@ function initializeAlarmService() {
|
|||
}
|
||||
|
||||
function createAlarmFromDuration(aOffset) {
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_START;
|
||||
alarm.offset = cal.createDuration(aOffset);
|
||||
|
|
|
@ -7,6 +7,7 @@ var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
|||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
CalEvent: "resource:///modules/CalEvent.jsm",
|
||||
CalTodo: "resource:///modules/CalTodo.jsm",
|
||||
});
|
||||
|
@ -25,7 +26,7 @@ add_task(async function test_setDefaultValues_events() {
|
|||
cal.alarms.setDefaultValues(item);
|
||||
alarm = item.getAlarms()[0];
|
||||
ok(alarm);
|
||||
equal(alarm.related, alarm.ALARM_RELATED_START);
|
||||
equal(alarm.related, Ci.calIAlarm.ALARM_RELATED_START);
|
||||
equal(alarm.action, "DISPLAY");
|
||||
equal(alarm.offset.icalString, "-P2DT12H");
|
||||
|
||||
|
@ -36,7 +37,7 @@ add_task(async function test_setDefaultValues_events() {
|
|||
cal.alarms.setDefaultValues(item);
|
||||
alarm = item.getAlarms()[0];
|
||||
ok(alarm);
|
||||
equal(alarm.related, alarm.ALARM_RELATED_START);
|
||||
equal(alarm.related, Ci.calIAlarm.ALARM_RELATED_START);
|
||||
equal(alarm.action, "DISPLAY");
|
||||
equal(alarm.offset.icalString, "-PT20M");
|
||||
|
||||
|
@ -59,7 +60,7 @@ add_task(async function test_setDefaultValues_events() {
|
|||
cal.alarms.setDefaultValues(item);
|
||||
alarm = item.getAlarms()[0];
|
||||
ok(alarm);
|
||||
equal(alarm.related, alarm.ALARM_RELATED_START);
|
||||
equal(alarm.related, Ci.calIAlarm.ALARM_RELATED_START);
|
||||
equal(alarm.action, "SHOUT");
|
||||
equal(alarm.offset.icalString, "-P2DT12H");
|
||||
|
||||
|
@ -84,7 +85,7 @@ add_task(async function test_setDefaultValues_tasks() {
|
|||
cal.alarms.setDefaultValues(item);
|
||||
alarm = item.getAlarms()[0];
|
||||
ok(alarm);
|
||||
equal(alarm.related, alarm.ALARM_RELATED_START);
|
||||
equal(alarm.related, Ci.calIAlarm.ALARM_RELATED_START);
|
||||
equal(alarm.action, "DISPLAY");
|
||||
equal(alarm.offset.icalString, "-P2DT12H");
|
||||
equal(item.entryDate, nowDate);
|
||||
|
@ -96,7 +97,7 @@ add_task(async function test_setDefaultValues_tasks() {
|
|||
cal.alarms.setDefaultValues(item);
|
||||
alarm = item.getAlarms()[0];
|
||||
ok(alarm);
|
||||
equal(alarm.related, alarm.ALARM_RELATED_START);
|
||||
equal(alarm.related, Ci.calIAlarm.ALARM_RELATED_START);
|
||||
equal(alarm.action, "DISPLAY");
|
||||
equal(alarm.offset.icalString, "-PT20M");
|
||||
|
||||
|
@ -119,7 +120,7 @@ add_task(async function test_setDefaultValues_tasks() {
|
|||
cal.alarms.setDefaultValues(item);
|
||||
alarm = item.getAlarms()[0];
|
||||
ok(alarm);
|
||||
equal(alarm.related, alarm.ALARM_RELATED_START);
|
||||
equal(alarm.related, Ci.calIAlarm.ALARM_RELATED_START);
|
||||
equal(alarm.action, "SHOUT");
|
||||
equal(alarm.offset.icalString, "-P2DT12H");
|
||||
|
||||
|
@ -136,37 +137,37 @@ add_task(async function test_calculateAlarmDate() {
|
|||
|
||||
let calculateAlarmDate = cal.alarms.calculateAlarmDate.bind(cal.alarms, item);
|
||||
|
||||
let alarm = cal.createAlarm();
|
||||
alarm.related = alarm.ALARM_RELATED_ABSOLUTE;
|
||||
let alarm = new CalAlarm();
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_ABSOLUTE;
|
||||
alarm.alarmDate = cal.createDateTime("20150815T110000");
|
||||
equal(calculateAlarmDate(alarm).icalString, "20150815T110000");
|
||||
|
||||
alarm = cal.createAlarm();
|
||||
alarm.related = alarm.ALARM_RELATED_START;
|
||||
alarm = new CalAlarm();
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_START;
|
||||
alarm.offset = cal.createDuration("-PT1H");
|
||||
equal(calculateAlarmDate(alarm).icalString, "20150815T110000");
|
||||
|
||||
alarm = cal.createAlarm();
|
||||
alarm.related = alarm.ALARM_RELATED_END;
|
||||
alarm = new CalAlarm();
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_END;
|
||||
alarm.offset = cal.createDuration("-PT2H");
|
||||
equal(calculateAlarmDate(alarm).icalString, "20150815T110000");
|
||||
|
||||
item.startDate.isDate = true;
|
||||
alarm = cal.createAlarm();
|
||||
alarm.related = alarm.ALARM_RELATED_START;
|
||||
alarm = new CalAlarm();
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_START;
|
||||
alarm.offset = cal.createDuration("-PT1H");
|
||||
equal(calculateAlarmDate(alarm).icalString, "20150814T230000");
|
||||
item.startDate.isDate = false;
|
||||
|
||||
item.endDate.isDate = true;
|
||||
alarm = cal.createAlarm();
|
||||
alarm.related = alarm.ALARM_RELATED_END;
|
||||
alarm = new CalAlarm();
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_END;
|
||||
alarm.offset = cal.createDuration("-PT2H");
|
||||
equal(calculateAlarmDate(alarm).icalString, "20150814T220000");
|
||||
item.endDate.isDate = false;
|
||||
|
||||
alarm = cal.createAlarm();
|
||||
alarm.related = alarm.ALARM_RELATED_END;
|
||||
alarm = new CalAlarm();
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_END;
|
||||
equal(calculateAlarmDate(alarm), null);
|
||||
});
|
||||
|
||||
|
@ -177,20 +178,20 @@ add_task(async function test_calculateAlarmOffset() {
|
|||
|
||||
let calculateAlarmOffset = cal.alarms.calculateAlarmOffset.bind(cal.alarms, item);
|
||||
|
||||
let alarm = cal.createAlarm();
|
||||
alarm.related = alarm.ALARM_RELATED_ABSOLUTE;
|
||||
let alarm = new CalAlarm();
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_ABSOLUTE;
|
||||
alarm.alarmDate = cal.createDateTime("20150815T110000");
|
||||
equal(calculateAlarmOffset(alarm).icalString, "-PT1H");
|
||||
equal(calculateAlarmOffset(alarm, alarm.ALARM_RELATED_START).icalString, "-PT1H");
|
||||
equal(calculateAlarmOffset(alarm, alarm.ALARM_RELATED_END).icalString, "-PT2H");
|
||||
equal(calculateAlarmOffset(alarm, Ci.calIAlarm.ALARM_RELATED_START).icalString, "-PT1H");
|
||||
equal(calculateAlarmOffset(alarm, Ci.calIAlarm.ALARM_RELATED_END).icalString, "-PT2H");
|
||||
|
||||
alarm = cal.createAlarm();
|
||||
alarm.related = alarm.ALARM_RELATED_START;
|
||||
alarm = new CalAlarm();
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_START;
|
||||
alarm.offset = cal.createDuration("-PT1H");
|
||||
equal(calculateAlarmOffset(alarm).icalString, "-PT1H");
|
||||
|
||||
alarm = cal.createAlarm();
|
||||
alarm.related = alarm.ALARM_RELATED_END;
|
||||
alarm = new CalAlarm();
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_END;
|
||||
alarm.offset = cal.createDuration("-PT1H");
|
||||
equal(calculateAlarmOffset(alarm).icalString, "-PT1H");
|
||||
});
|
||||
|
@ -199,7 +200,7 @@ add_task(async function test_addReminderImages() {
|
|||
function createReminders(actions) {
|
||||
let reminders = [];
|
||||
for (let action of actions) {
|
||||
let reminder = cal.createAlarm();
|
||||
let reminder = new CalAlarm();
|
||||
reminder.action = action;
|
||||
reminders.push(reminder);
|
||||
}
|
||||
|
|
|
@ -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, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
// Check that the RELATED property is correctly set
|
||||
// after parsing the given VALARM component
|
||||
|
@ -77,7 +83,7 @@ function run_test() {
|
|||
}
|
||||
|
||||
function check_relative(aIcalString, aRelated) {
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
alarm.icalString = aIcalString;
|
||||
equal(alarm.related, aRelated);
|
||||
equal(alarm.alarmDate, null);
|
||||
|
@ -85,7 +91,7 @@ function check_relative(aIcalString, aRelated) {
|
|||
}
|
||||
|
||||
function check_absolute(aIcalString) {
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
alarm.icalString = aIcalString;
|
||||
equal(alarm.related, Ci.calIAlarm.ALARM_RELATED_ABSOLUTE);
|
||||
notEqual(alarm.alarmDate, null);
|
||||
|
|
|
@ -2,9 +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/. */
|
||||
|
||||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
// ensure that RELATED property is correctly set on the VALARM component
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
alarm.action = "DISPLAY";
|
||||
alarm.description = "test";
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_END;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
CalAttachment: "resource:///modules/CalAttachment.jsm",
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
CalEvent: "resource:///modules/CalEvent.jsm",
|
||||
|
@ -171,7 +172,7 @@ function test_categories() {
|
|||
|
||||
function test_alarm() {
|
||||
let e = new CalEvent();
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
|
||||
alarm.action = "DISPLAY";
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_ABSOLUTE;
|
||||
|
@ -206,10 +207,10 @@ function test_immutable() {
|
|||
org.id = "one";
|
||||
event.organizer = org;
|
||||
|
||||
let alarm = cal.createAlarm();
|
||||
let alarm = new CalAlarm();
|
||||
alarm.action = "DISPLAY";
|
||||
alarm.description = "foo";
|
||||
alarm.related = alarm.ALARM_RELATED_START;
|
||||
alarm.related = Ci.calIAlarm.ALARM_RELATED_START;
|
||||
alarm.offset = cal.createDuration("PT1S");
|
||||
event.addAlarm(alarm);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче