Bug 1601848 - Enforce immutability in recurrenceRule and recurrenceDate; r=Fallen
--HG-- extra : rebase_source : 2cc18b4c8e6b59954491291549590400a19ad777 extra : histedit_source : 78b3b16ef2152395261dc35dc19e0b179adacb0a
This commit is contained in:
Родитель
de28700811
Коммит
7ee199d4cf
|
@ -32,6 +32,11 @@ calRecurrenceRule.prototype = {
|
|||
makeImmutable: function() {
|
||||
this.isMutable = false;
|
||||
},
|
||||
ensureMutable: function() {
|
||||
if (!this.isMutable) {
|
||||
throw Cr.NS_ERROR_OBJECT_IS_IMMUTABLE;
|
||||
}
|
||||
},
|
||||
clone: function() {
|
||||
return new calRecurrenceRule(new ICAL.Recur(this.innerObject));
|
||||
},
|
||||
|
@ -108,6 +113,7 @@ calRecurrenceRule.prototype = {
|
|||
return "RRULE:" + this.innerObject.toString() + ICAL.newLineChar;
|
||||
},
|
||||
set icalString(val) {
|
||||
this.ensureMutable();
|
||||
this.innerObject = ICAL.Recur.fromString(val.replace(/^RRULE:/i, ""));
|
||||
},
|
||||
|
||||
|
@ -117,6 +123,7 @@ calRecurrenceRule.prototype = {
|
|||
return new calIcalProperty(prop);
|
||||
},
|
||||
set icalProperty(rawval) {
|
||||
this.ensureMutable();
|
||||
unwrapSetter(
|
||||
ICAL.Property,
|
||||
rawval,
|
||||
|
@ -131,6 +138,7 @@ calRecurrenceRule.prototype = {
|
|||
return this.innerObject.freq;
|
||||
},
|
||||
set type(val) {
|
||||
this.ensureMutable();
|
||||
this.innerObject.freq = val;
|
||||
},
|
||||
|
||||
|
@ -138,6 +146,7 @@ calRecurrenceRule.prototype = {
|
|||
return this.innerObject.interval;
|
||||
},
|
||||
set interval(val) {
|
||||
this.ensureMutable();
|
||||
this.innerObject.interval = val;
|
||||
},
|
||||
|
||||
|
@ -148,6 +157,7 @@ calRecurrenceRule.prototype = {
|
|||
return this.innerObject.count || -1;
|
||||
},
|
||||
set count(val) {
|
||||
this.ensureMutable();
|
||||
this.innerObject.count = val && val > 0 ? val : null;
|
||||
},
|
||||
|
||||
|
@ -159,6 +169,7 @@ calRecurrenceRule.prototype = {
|
|||
}
|
||||
},
|
||||
set untilDate(rawval) {
|
||||
this.ensureMutable();
|
||||
unwrapSetter(
|
||||
ICAL.Time,
|
||||
rawval,
|
||||
|
@ -184,6 +195,7 @@ calRecurrenceRule.prototype = {
|
|||
return this.innerObject.wkst - 1;
|
||||
},
|
||||
set weekStart(val) {
|
||||
this.ensureMutable();
|
||||
this.innerObject.wkst = val + 1;
|
||||
},
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ calRecurrenceRule::GetType(nsACString &aType) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
calRecurrenceRule::SetType(const nsACString &aType) {
|
||||
if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE;
|
||||
#define RECUR_HELPER(x) \
|
||||
if (aType.EqualsLiteral(#x)) mIcalRecur.freq = ICAL_##x##_RECURRENCE
|
||||
RECUR_HELPER(SECONDLY);
|
||||
|
@ -142,6 +143,7 @@ calRecurrenceRule::GetCount(int32_t *aRecurCount) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
calRecurrenceRule::SetCount(int32_t aRecurCount) {
|
||||
if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE;
|
||||
if (aRecurCount != -1) {
|
||||
if (aRecurCount < 0 || aRecurCount > INT_MAX) return NS_ERROR_ILLEGAL_VALUE;
|
||||
mIcalRecur.count = static_cast<int>(aRecurCount);
|
||||
|
@ -176,6 +178,7 @@ calRecurrenceRule::GetUntilDate(calIDateTime **aRecurEnd) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
calRecurrenceRule::SetUntilDate(calIDateTime *aRecurEnd) {
|
||||
if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE;
|
||||
if (aRecurEnd) {
|
||||
nsresult rv;
|
||||
bool b;
|
||||
|
@ -227,6 +230,7 @@ calRecurrenceRule::GetInterval(int32_t *aInterval) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
calRecurrenceRule::SetInterval(int32_t aInterval) {
|
||||
if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE;
|
||||
if (aInterval < 0 || aInterval > SHRT_MAX) return NS_ERROR_ILLEGAL_VALUE;
|
||||
mIcalRecur.interval = static_cast<short>(aInterval);
|
||||
return NS_OK;
|
||||
|
@ -283,6 +287,7 @@ NS_IMETHODIMP
|
|||
calRecurrenceRule::SetComponent(const nsACString &aComponentType,
|
||||
uint32_t aCount, int16_t *aValues) {
|
||||
NS_ENSURE_ARG_POINTER(aValues);
|
||||
if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE;
|
||||
|
||||
// Copy the passed-in array into the ical structure array
|
||||
#define HANDLE_COMPONENT(_comptype, _icalvar, _icalmax) \
|
||||
|
@ -559,6 +564,8 @@ calRecurrenceRule::SetIcalProperty(calIIcalProperty *aProp) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
calRecurrenceRule::SetIcalString(const nsACString &str) {
|
||||
if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoCString name;
|
||||
nsCOMPtr<calIICSService> icsSvc = cal::getICSService();
|
||||
|
|
|
@ -31,7 +31,7 @@ calRecurrenceDate.prototype = {
|
|||
|
||||
ensureMutable: function() {
|
||||
if (!this.isMutable) {
|
||||
throw Cr.NS_ERROR_OBJECT_IS_MUTABLE;
|
||||
throw Cr.NS_ERROR_OBJECT_IS_IMMUTABLE;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче