moved properties out of calIItemBase; replaced with explicit get/set/delete methods, to control mutable access. notpartofthebuild

This commit is contained in:
vladimir%pobox.com 2004-11-30 00:23:37 +00:00
parent d776eff0fb
commit be882eca76
3 changed files with 45 additions and 5 deletions

View File

@ -40,6 +40,8 @@
interface nsIArray;
interface nsIMutableArray;
interface nsISimpleEnumerator;
interface nsIVariant;
interface nsIPropertyBag;
interface nsIWritablePropertyBag;
@ -155,7 +157,13 @@ interface calIItemBase : nsISupports
// nsIWritablePropertyBag also)
// if this item is mutable, the returned bag will be a nsIWritablePropertyBag
readonly attribute nsIPropertyBag properties;
//readonly attribute nsIPropertyBag properties;
// these forward to an internal property bag; implemented here, so we can
// do access control on set/delete.
readonly attribute nsISimpleEnumerator propertyEnumerator;
nsIVariant getProperty(in AString name);
void setProperty(in AString name, in nsIVariant value);
void deleteProperty(in AString name);
};
//

View File

@ -68,7 +68,8 @@ calItemBase.prototype = {
m.mAttachments = this.mAttachments;
m.mContacts = this.mContacts;
m.mProperties = this.mProperties;
return m;
},
@ -94,9 +95,24 @@ calItemBase.prototype = {
mRecurrenceInfo: null, get recurrenceInfo() { return this.mRecurrenceInfo; }, set recurrenceInfo(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mRecurrenceInfo = v; },
mAttachments: null, get attachments() { return this.mAttachments; }, set attachments(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mAttachments = v; },
mContacts: null, get contacts() { return this.mContacts; }, set contacts(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mContacts = v; },
mProperties: null, get properties() { return this.mProperties; }, set properties(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mProperties = v; }
mProperties: null, get properties() { return this.mProperties; }, set properties(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mProperties = v; },
get propertyEnumerator() { return this.mProperties.enumerator; },
getProperty: function (aName) {
return this.mProperties.getProperty(aName);
},
setProperty: function (aName, aValue) {
if (this.mImmutable)
throw Components.results.NS_ERROR_FAILURE;
this.mProperties.setProperty(aName, aValue);
},
deleteProperty: function (aName) {
if (this.mImmutable)
throw Components.results.NS_ERROR_FAILURE;
this.mProperties.deleteProperty(aName);
}
};
function calItemOccurrence () {

View File

@ -110,7 +110,8 @@ calItemBase.prototype = {
// these need fixing
m.mAttachments = this.mAttachments;
m.mContacts = this.mContacts;
m.mProperties = this.mProperties;
// m.mProperties = this.mProperties;
return m;
},
@ -136,9 +137,24 @@ calItemBase.prototype = {
MEMBER_ATTR(mRecurrenceInfo, null, recurrenceInfo),
MEMBER_ATTR(mAttachments, null, attachments),
MEMBER_ATTR(mContacts, null, contacts),
MEMBER_ATTR(mProperties, null, properties)
MEMBER_ATTR(mProperties, null, properties),
#undef MEMBER_ATTR
get propertyEnumerator() { return this.mProperties.enumerator; },
getProperty: function (aName) {
return this.mProperties.getProperty(aName);
},
setProperty: function (aName, aValue) {
if (this.mImmutable)
throw Components.results.NS_ERROR_FAILURE;
this.mProperties.setProperty(aName, aValue);
},
deleteProperty: function (aName) {
if (this.mImmutable)
throw Components.results.NS_ERROR_FAILURE;
this.mProperties.deleteProperty(aName);
}
};
function calItemOccurrence () {