/usr/lib/thunderbird-addons/extensions/{e2fda1a4-762b-4020-b5ad-a41df1933103}/calendar-js/calRecurrenceRule.js is in xul-ext-lightning 1:24.4.0+build1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | /* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
Components.utils.import("resource://calendar/modules/ical.js");
Components.utils.import("resource://calendar/modules/calUtils.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
function calRecurrenceRule(innerObject) {
this.innerObject = innerObject || new ICAL.Recur();
this.wrappedJSObject = this;
}
const calRecurrenceRuleInterfaces = [Components.interfaces.calIRecurrenceRule];
const calRecurrenceRuleClassID = Components.ID("{df19281a-5389-4146-b941-798cb93a7f0d}");
calRecurrenceRule.prototype = {
QueryInterface: XPCOMUtils.generateQI(calRecurrenceRuleInterfaces),
classID: calRecurrenceRuleClassID,
classInfo: XPCOMUtils.generateCI({
contractID: "@mozilla.org/calendar/recurrence-rule;1",
classDescription: "Calendar Recurrence Rule",
classID: calRecurrenceRuleClassID,
interfaces: calRecurrenceRuleInterfaces
}),
innerObject: null,
isMutable: true,
makeImmutable: function() this.isMutable = false,
clone: function() new calRecurrenceRule(new ICAL.Recur(this.innerObject)),
isNegative: false, // We don't support EXRULE anymore
get isFinite() this.innerObject.isFinite(),
getNextOccurrence: function(aStartTime, aRecId) {
aStartTime = unwrapSingle(ICAL.Time, aStartTime);
aRecId = unwrapSingle(ICAL.Time, aRecId);
return wrapGetter(calDateTime, this.innerObject.getNextOccurrence(aStartTime, aRecId));
},
getOccurrences: function(aStartTime, aRangeStart, aRangeEnd, aMaxCount, aCount) {
aStartTime = unwrapSingle(ICAL.Time, aStartTime);
aRangeStart = unwrapSingle(ICAL.Time, aRangeStart);
aRangeEnd = unwrapSingle(ICAL.Time, aRangeEnd);
if (!aMaxCount && !aRangeEnd && this.count == 0 && this.until == null) {
throw Components.results.NS_ERROR_INVALID_ARG;
}
let occurrences = [];
let rangeStart = aRangeStart.clone();
rangeStart.isDate = false;
let dtend = null;
if (aRangeEnd) {
dtend = aRangeEnd.clone();
dtend.isDate = false;
// If the start of the recurrence is past the end, we have no dates
if (aStartTime.compare(dtend) >= 0) {
aCount.value = 0;
return [];
}
}
let iter = this.innerObject.iterator(aStartTime);
for (let next = iter.next(); next ; next = iter.next()) {
let dtNext = next.clone();
dtNext.isDate = false;
if (dtNext.compare(rangeStart) < 0) {
continue;
}
if (dtend && dtNext.compare(dtend) >= 0) {
break;
}
next = next.clone();
if (aStartTime.zone) {
next.zone = aStartTime.zone;
}
occurrences.push(new calDateTime(next));
if (aMaxCount && aMaxCount >= occurrences.length) {
break;
}
}
aCount.value = occurrences.length;
return occurrences;
},
get icalString() "RRULE:" + this.innerObject.toString() + ICAL.newLineChar,
set icalString(val) this.innerObject = ICAL.Recur.fromString(val.replace(/^RRULE:/i, "")),
get icalProperty() {
let prop = new ICAL.Property("rrule");
prop.setValue(this.innerObject);
return new calIcalProperty(prop);
},
set icalProperty(val) unwrapSetter(ICAL.Property, val, function(val) {
this.innerObject = val.getFirstValue();
}, this),
get type() this.innerObject.freq,
set type(val) this.innerObject.freq = val,
get interval() this.innerObject.interval,
set interval(val) this.innerObject.interval = val,
get count() {
if (!this.isByCount) {
throw Components.results.NS_ERROR_FAILURE;
}
return this.innerObject.count || -1;
},
set count(val) this.innerObject.count = (val && val > 0 ? val : null),
get untilDate() {
if (this.innerObject.until) {
return new calDateTime(this.innerObject.until);
} else {
return null;
}
},
set untilDate(val) unwrapSetter(ICAL.Time, val, function(val) {
this.innerObject.until = val;
}, this),
get isByCount() this.innerObject.isByCount(),
get weekStart() this.innerObject.wkst - 1,
set weekStart(val) this.innerObject.wkst = val + 1,
getComponent: function(aType, aCount) {
return this.innerObject.getComponent(aType, aCount)
.map(ICAL.Recur.icalDayToNumericDay);
},
setComponent: function(aType, aCount, aValues) {
let values = aValues.map(ICAL.Recur.numericDayToIcalDay);
this.innerObject.setComponent(aType, values);
}
};
|