- Use signed constants for calIIcalComponent, so that we can express

the absence of integer-valued properties consistently.
- Add calIIcalComponent.INVALID_VALUE for just that purpose.
- Use the same constant values for method in calIItemBase as we use in
  calIIcalComponent, for the sake of my sanity.  (Tempted to just remove them
  and have people who care about setting .method do it on the icalComponent
  of their choice.)
- Make calIItemBase.generation unsigned, since 0 means not-stored.
- Voidify string properties returned from calICSService to indicate a missing
  property.
- Don't propagate null or INVALID_VALUE props when copying to/from ICS.
- calIItemBase.generation has precisely nothing to do with ICS VERSION, so
  remove the mapping.
This commit is contained in:
shaver%mozilla.org 2004-12-11 21:17:36 +00:00
Родитель 5b19fde8b1
Коммит 086a3d6388
5 изменённых файлов: 137 добавлений и 120 удалений

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

@ -46,54 +46,60 @@ interface calIIcalProperty;
[scriptable,uuid(4d7e456b-cfd0-4ebf-8794-c57789dafdc3)] [scriptable,uuid(4d7e456b-cfd0-4ebf-8794-c57789dafdc3)]
interface calIIcalComponent : nsISupports interface calIIcalComponent : nsISupports
{ {
calIIcalComponent getFirstSubcomponent(in PRUint32 componentType); /**
calIIcalComponent getNextSubcomponent(in PRUint32 componentType); * This is the value that an integer-valued getter will provide if
* there is no such property on the wrapped ical structure.
*/
const PRInt32 INVALID_VALUE = -1;
const PRUint32 ANY_COMPONENT = 1; calIIcalComponent getFirstSubcomponent(in PRInt32 componentType);
const PRUint32 XROOT_COMPONENT = 2; calIIcalComponent getNextSubcomponent(in PRInt32 componentType);
const PRUint32 VEVENT_COMPONENT = 4;
const PRUint32 VTODO_COMPONENT = 5; const PRInt32 ANY_COMPONENT = 1;
const PRUint32 VJOURNAL_COMPONENT = 6; const PRInt32 XROOT_COMPONENT = 2;
const PRUint32 VCALENDAR_COMPONENT = 7; const PRInt32 VEVENT_COMPONENT = 4;
const PRUint32 VFREEBUSY_COMPONENT = 8; const PRInt32 VTODO_COMPONENT = 5;
readonly attribute PRUint32 isA; const PRInt32 VJOURNAL_COMPONENT = 6;
const PRInt32 VCALENDAR_COMPONENT = 7;
const PRInt32 VFREEBUSY_COMPONENT = 8;
readonly attribute PRInt32 isA;
attribute AUTF8String uid; attribute AUTF8String uid;
attribute AUTF8String prodid; attribute AUTF8String prodid;
attribute AUTF8String version; attribute AUTF8String version;
const PRUint32 METHOD_PUBLISH = 10012; const PRInt32 METHOD_PUBLISH = 10012;
const PRUint32 METHOD_REQUEST = 10013; const PRInt32 METHOD_REQUEST = 10013;
const PRUint32 METHOD_REPLY = 10014; const PRInt32 METHOD_REPLY = 10014;
const PRUint32 METHOD_ADD = 10015; const PRInt32 METHOD_ADD = 10015;
const PRUint32 METHOD_CANCEL = 10016; const PRInt32 METHOD_CANCEL = 10016;
const PRUint32 METHOD_REFRESH = 10017; const PRInt32 METHOD_REFRESH = 10017;
const PRUint32 METHOD_COUNTER = 10018; const PRInt32 METHOD_COUNTER = 10018;
const PRUint32 METHOD_DECLINECOUNTER = 10019; const PRInt32 METHOD_DECLINECOUNTER = 10019;
const PRUint32 METHOD_CREATE = 10020; const PRInt32 METHOD_CREATE = 10020;
const PRUint32 METHOD_READ = 10021; const PRInt32 METHOD_READ = 10021;
const PRUint32 METHOD_RESPONSE = 10022; const PRInt32 METHOD_RESPONSE = 10022;
const PRUint32 METHOD_MOVE = 10023; const PRInt32 METHOD_MOVE = 10023;
const PRUint32 METHOD_MODIFY = 10024; const PRInt32 METHOD_MODIFY = 10024;
const PRUint32 METHOD_GENERATEUID = 10025; const PRInt32 METHOD_GENERATEUID = 10025;
const PRUint32 METHOD_DELETE = 10026; const PRInt32 METHOD_DELETE = 10026;
const PRUint32 METHOD_NONE = 10027; const PRInt32 METHOD_NONE = 10027;
attribute PRUint32 method; attribute PRInt32 method;
const PRUint32 STATUS_TENTATIVE = 10029; const PRInt32 STATUS_TENTATIVE = 10029;
const PRUint32 STATUS_CONFIRMED = 10030; const PRInt32 STATUS_CONFIRMED = 10030;
const PRUint32 STATUS_COMPLETED = 10031; const PRInt32 STATUS_COMPLETED = 10031;
const PRUint32 STATUS_NEEDSACTION = 10032; const PRInt32 STATUS_NEEDSACTION = 10032;
const PRUint32 STATUS_CANCELLED = 10033; const PRInt32 STATUS_CANCELLED = 10033;
const PRUint32 STATUS_INPROCESS = 10034; const PRInt32 STATUS_INPROCESS = 10034;
const PRUint32 STATUS_DRAFT = 10035; const PRInt32 STATUS_DRAFT = 10035;
const PRUint32 STATUS_FINAL = 10036; const PRInt32 STATUS_FINAL = 10036;
const PRUint32 STATUS_NONE = 10037; const PRInt32 STATUS_NONE = 10037;
attribute PRUint32 status; attribute PRInt32 status;
const PRUint32 TRANSP_OPAQUE = 10039; const PRInt32 TRANSP_OPAQUE = 10039;
const PRUint32 TRANSP_TRANSPARENT = 10040; const PRInt32 TRANSP_TRANSPARENT = 10040;
attribute PRUint32 transp; attribute PRInt32 transp;
attribute AUTF8String summary; attribute AUTF8String summary;
attribute AUTF8String description; attribute AUTF8String description;
@ -101,13 +107,13 @@ interface calIIcalComponent : nsISupports
attribute AUTF8String categories; attribute AUTF8String categories;
attribute AUTF8String URL; attribute AUTF8String URL;
attribute PRUint32 priority; attribute PRInt32 priority;
const PRUint32 VISIBILITY_PUBLIC = 10007; const PRInt32 VISIBILITY_PUBLIC = 10007;
const PRUint32 VISIBILITY_PRIVATE = 10008; const PRInt32 VISIBILITY_PRIVATE = 10008;
const PRUint32 VISIBILITY_CONFIDENTIAL = 10009; const PRInt32 VISIBILITY_CONFIDENTIAL = 10009;
const PRUint32 VISIBILITY_NONE = 10010; const PRInt32 VISIBILITY_NONE = 10010;
attribute PRUint32 icalClass; attribute PRInt32 icalClass;
attribute calIDateTime startTime; attribute calIDateTime startTime;
attribute calIDateTime endTime; attribute calIDateTime endTime;
@ -128,13 +134,13 @@ interface calIIcalComponent : nsISupports
void addSubcomponent(in calIIcalComponent comp); void addSubcomponent(in calIIcalComponent comp);
void removeSubcomponent(in calIIcalComponent comp); void removeSubcomponent(in calIIcalComponent comp);
const PRUint32 ANY_PROPERTY = 0; const PRInt32 ANY_PROPERTY = 0;
const PRUint32 ACTION_PROPERTY = 1; const PRInt32 ACTION_PROPERTY = 1;
const PRUint32 ATTACH_PROPERTY = 2; const PRInt32 ATTACH_PROPERTY = 2;
const PRUint32 ATTENDEE_PROPERTY = 3; const PRInt32 ATTENDEE_PROPERTY = 3;
calIIcalProperty getFirstProperty(in PRUint32 kind); calIIcalProperty getFirstProperty(in PRInt32 kind);
calIIcalProperty getNextProperty(in PRUint32 kind); calIIcalProperty getNextProperty(in PRInt32 kind);
calIIcalProperty addProperty(in PRUint32 kind); calIIcalProperty addProperty(in PRInt32 kind);
void removeProperty(in calIIcalProperty prop); void removeProperty(in calIIcalProperty prop);
calIIcalProperty getFirstXProperty(in AUTF8String xpropname); calIIcalProperty getFirstXProperty(in AUTF8String xpropname);
@ -147,44 +153,44 @@ interface calIIcalComponent : nsISupports
interface calIIcalProperty : nsISupports interface calIIcalProperty : nsISupports
{ {
attribute AUTF8String stringValue; attribute AUTF8String stringValue;
readonly attribute PRUint32 isA; readonly attribute PRInt32 isA;
AUTF8String getXParameter(in AUTF8String xparamname); AUTF8String getXParameter(in AUTF8String xparamname);
void setXParameter(in AUTF8String xparamname, in AUTF8String xparamval); void setXParameter(in AUTF8String xparamname, in AUTF8String xparamval);
void removeXParameter(in AUTF8String xparamname); void removeXParameter(in AUTF8String xparamname);
const PRUint32 ALTREP_PARAMETER = 1; const PRInt32 ALTREP_PARAMETER = 1;
const PRUint32 CN_PARAMETER = 2; const PRInt32 CN_PARAMETER = 2;
const PRUint32 CUTYPE_PARAMETER = 3; const PRInt32 CUTYPE_PARAMETER = 3;
const PRUint32 DELEGATEDFROM_PARAMETER = 4; const PRInt32 DELEGATEDFROM_PARAMETER = 4;
const PRUint32 DELEGATEDTO_PARAMETER = 5; const PRInt32 DELEGATEDTO_PARAMETER = 5;
const PRUint32 DIR_PARAMETER = 6; const PRInt32 DIR_PARAMETER = 6;
const PRUint32 ENCODING_PARAMETER = 7; const PRInt32 ENCODING_PARAMETER = 7;
const PRUint32 FBTYPE_PARAMETER = 8; const PRInt32 FBTYPE_PARAMETER = 8;
const PRUint32 FMTTYPE_PARAMETER = 9; const PRInt32 FMTTYPE_PARAMETER = 9;
const PRUint32 LANGUAGE_PARAMETER = 10; const PRInt32 LANGUAGE_PARAMETER = 10;
const PRUint32 MEMBER_PARAMETER = 11; const PRInt32 MEMBER_PARAMETER = 11;
const PRUint32 PARTSTAT_PARAMETER = 12; const PRInt32 PARTSTAT_PARAMETER = 12;
const PRUint32 RANGE_PARAMETER = 13; const PRInt32 RANGE_PARAMETER = 13;
const PRUint32 RELATED_PARAMETER = 14; const PRInt32 RELATED_PARAMETER = 14;
const PRUint32 RELTYPE_PARAMETER = 15; const PRInt32 RELTYPE_PARAMETER = 15;
const PRUint32 ROLE_PARAMETER = 16; const PRInt32 ROLE_PARAMETER = 16;
const PRUint32 RSVP_PARAMETER = 17; const PRInt32 RSVP_PARAMETER = 17;
const PRUint32 SENTBY_PARAMETER = 18; const PRInt32 SENTBY_PARAMETER = 18;
const PRUint32 TZID_PARAMETER = 19; const PRInt32 TZID_PARAMETER = 19;
const PRUint32 VALUE_PARAMETER = 20; const PRInt32 VALUE_PARAMETER = 20;
/* const PRUint32 X_PARAMETER = 21; */ /* const PRUint32 X_PARAMETER = 21; */
const PRUint32 XLICCOMPARETYPE_PARAMETER = 22; const PRInt32 XLICCOMPARETYPE_PARAMETER = 22;
const PRUint32 XLICERRORTYPE_PARAMETER = 23; const PRInt32 XLICERRORTYPE_PARAMETER = 23;
AUTF8String getParameter(in PRUint32 kind); AUTF8String getParameter(in PRInt32 kind);
void setParameter(in PRUint32 kind, in AUTF8String value); void setParameter(in PRInt32 kind, in AUTF8String value);
void removeParameter(in PRUint32 kind); void removeParameter(in PRInt32 kind);
}; };
[scriptable,uuid(c788a1dc-0929-4029-9a14-e1bc654eafad)] [scriptable,uuid(c788a1dc-0929-4029-9a14-e1bc654eafad)]
interface calIICSService : nsISupports interface calIICSService : nsISupports
{ {
calIIcalComponent parseICS(in AUTF8String serialized); calIIcalComponent parseICS(in AUTF8String serialized);
calIIcalComponent createIcalComponent(in PRUint32 kind); calIIcalComponent createIcalComponent(in PRInt32 kind);
}; };

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

@ -85,12 +85,15 @@ interface calIItemBase : nsISupports
// the generation number of this item; 0 means // the generation number of this item; 0 means
// that it's never been stored in a store // that it's never been stored in a store
// //
readonly attribute long generation; readonly attribute PRUint32 generation;
// methods // methods
const long CAL_METHOD_NONE = 0; const PRUint32 METHOD_PUBLISH = 10012;
const long CAL_METHOD_PUBLISH = 1; const PRUint32 METHOD_REQUEST = 10013;
const long CAL_METHOD_REQUEST = 2; const PRUint32 METHOD_REPLY = 10014;
const PRUint32 METHOD_ADD = 10015;
const PRUint32 METHOD_CANCEL = 10016;
const PRUint32 METHOD_NONE = 10027;
// statuses, extended by each event/todo/journal subclass // statuses, extended by each event/todo/journal subclass
const long CAL_ITEM_STATUS_NONE = 0; const long CAL_ITEM_STATUS_NONE = 0;

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

@ -74,9 +74,9 @@ protected:
NS_IMPL_ISUPPORTS1(calIcalProperty, calIIcalProperty) NS_IMPL_ISUPPORTS1(calIcalProperty, calIIcalProperty)
NS_IMETHODIMP NS_IMETHODIMP
calIcalProperty::GetIsA(PRUint32 *isa) calIcalProperty::GetIsA(PRInt32 *isa)
{ {
*isa = (PRUint32)icalproperty_isa(mProperty); *isa = (PRInt32)icalproperty_isa(mProperty);
return NS_OK; return NS_OK;
} }
@ -130,19 +130,19 @@ calIcalProperty::RemoveXParameter(const nsACString &xparamname)
} }
NS_IMETHODIMP NS_IMETHODIMP
calIcalProperty::GetParameter(PRUint32 kind, nsACString &value) calIcalProperty::GetParameter(PRInt32 kind, nsACString &value)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
calIcalProperty::SetParameter(PRUint32 kind, const nsACString &value) calIcalProperty::SetParameter(PRInt32 kind, const nsACString &value)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
calIcalProperty::RemoveParameter(PRUint32 kind) calIcalProperty::RemoveParameter(PRInt32 kind)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@ -170,10 +170,12 @@ protected:
{ {
icalproperty *prop = icalproperty *prop =
icalcomponent_get_first_property(mComponent, kind); icalcomponent_get_first_property(mComponent, kind);
if (!prop) if (!prop) {
str.Truncate(); str.Truncate();
else str.SetIsVoid(PR_TRUE);
} else {
str.Assign(icalvalue_get_string(icalproperty_get_value(prop))); str.Assign(icalvalue_get_string(icalproperty_get_value(prop)));
}
return NS_OK; return NS_OK;
} }
@ -185,18 +187,18 @@ protected:
return SetPropertyValue(kind, val); return SetPropertyValue(kind, val);
} }
nsresult GetIntProperty(icalproperty_kind kind, PRUint32 *valp) nsresult GetIntProperty(icalproperty_kind kind, PRInt32 *valp)
{ {
icalproperty *prop = icalproperty *prop =
icalcomponent_get_first_property(mComponent, kind); icalcomponent_get_first_property(mComponent, kind);
if (!prop) if (!prop)
*valp = PR_UINT32_MAX; *valp = calIIcalComponent::INVALID_VALUE;
else else
*valp = (PRUint32)icalvalue_get_integer(icalproperty_get_value(prop)); *valp = (PRInt32)icalvalue_get_integer(icalproperty_get_value(prop));
return NS_OK; return NS_OK;
} }
nsresult SetIntProperty(icalproperty_kind kind, PRUint32 i) nsresult SetIntProperty(icalproperty_kind kind, PRInt32 i)
{ {
icalvalue *val = icalvalue_new_integer(i); icalvalue *val = icalvalue_new_integer(i);
if (!val) if (!val)
@ -266,26 +268,26 @@ calIcalComponent::Set##Attrname(const nsACString &str) \
#define COMP_GENERAL_INT_ATTRIBUTE(Attrname, ICALNAME) \ #define COMP_GENERAL_INT_ATTRIBUTE(Attrname, ICALNAME) \
NS_IMETHODIMP \ NS_IMETHODIMP \
calIcalComponent::Get##Attrname(PRUint32 *valp) \ calIcalComponent::Get##Attrname(PRInt32 *valp) \
{ \ { \
return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp); \ return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp); \
} \ } \
\ \
NS_IMETHODIMP \ NS_IMETHODIMP \
calIcalComponent::Set##Attrname(PRUint32 val) \ calIcalComponent::Set##Attrname(PRInt32 val) \
{ \ { \
return SetIntProperty(ICAL_##ICALNAME##_PROPERTY, val); \ return SetIntProperty(ICAL_##ICALNAME##_PROPERTY, val); \
} \ } \
#define COMP_ENUM_ATTRIBUTE(Attrname, ICALNAME, lcname) \ #define COMP_ENUM_ATTRIBUTE(Attrname, ICALNAME, lcname) \
NS_IMETHODIMP \ NS_IMETHODIMP \
calIcalComponent::Get##Attrname(PRUint32 *valp) \ calIcalComponent::Get##Attrname(PRInt32 *valp) \
{ \ { \
return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp); \ return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp); \
} \ } \
\ \
NS_IMETHODIMP \ NS_IMETHODIMP \
calIcalComponent::Set##Attrname(PRUint32 val) \ calIcalComponent::Set##Attrname(PRInt32 val) \
{ \ { \
icalproperty *prop = \ icalproperty *prop = \
icalproperty_new_##lcname((icalproperty_##lcname)val); \ icalproperty_new_##lcname((icalproperty_##lcname)val); \
@ -294,13 +296,13 @@ calIcalComponent::Set##Attrname(PRUint32 val) \
#define COMP_INT_ATTRIBUTE(Attrname, ICALNAME, lcname) \ #define COMP_INT_ATTRIBUTE(Attrname, ICALNAME, lcname) \
NS_IMETHODIMP \ NS_IMETHODIMP \
calIcalComponent::Get##Attrname(PRUint32 *valp) \ calIcalComponent::Get##Attrname(PRInt32 *valp) \
{ \ { \
return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp); \ return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp); \
} \ } \
\ \
NS_IMETHODIMP \ NS_IMETHODIMP \
calIcalComponent::Set##Attrname(PRUint32 val) \ calIcalComponent::Set##Attrname(PRInt32 val) \
{ \ { \
icalproperty *prop = icalproperty_new_##lcname(val); \ icalproperty *prop = icalproperty_new_##lcname(val); \
return SetProperty(ICAL_##ICALNAME##_PROPERTY, prop); \ return SetProperty(ICAL_##ICALNAME##_PROPERTY, prop); \
@ -347,7 +349,7 @@ calIcalComponent::Set##Attrname(calIDateTime *dt) \
NS_IMPL_ISUPPORTS1(calIcalComponent, calIIcalComponent) NS_IMPL_ISUPPORTS1(calIcalComponent, calIIcalComponent)
NS_IMETHODIMP NS_IMETHODIMP
calIcalComponent::GetFirstSubcomponent(PRUint32 componentType, calIcalComponent::GetFirstSubcomponent(PRInt32 componentType,
calIIcalComponent **subcomp) calIIcalComponent **subcomp)
{ {
icalcomponent *ical = icalcomponent *ical =
@ -366,7 +368,7 @@ calIcalComponent::GetFirstSubcomponent(PRUint32 componentType,
} }
NS_IMETHODIMP NS_IMETHODIMP
calIcalComponent::GetNextSubcomponent(PRUint32 componentType, calIcalComponent::GetNextSubcomponent(PRInt32 componentType,
calIIcalComponent **subcomp) calIIcalComponent **subcomp)
{ {
icalcomponent *ical = icalcomponent *ical =
@ -385,7 +387,7 @@ calIcalComponent::GetNextSubcomponent(PRUint32 componentType,
} }
NS_IMETHODIMP NS_IMETHODIMP
calIcalComponent::GetIsA(PRUint32 *isa) calIcalComponent::GetIsA(PRInt32 *isa)
{ {
*isa = icalcomponent_isa(mComponent); *isa = icalcomponent_isa(mComponent);
return NS_OK; return NS_OK;
@ -516,7 +518,7 @@ calIcalComponent::RemoveSubcomponent(calIIcalComponent *comp)
} }
NS_IMETHODIMP NS_IMETHODIMP
calIcalComponent::GetFirstProperty(PRUint32 kind, calIIcalProperty **prop) calIcalComponent::GetFirstProperty(PRInt32 kind, calIIcalProperty **prop)
{ {
icalproperty *icalprop = icalproperty *icalprop =
icalcomponent_get_first_property(mComponent, (icalproperty_kind)kind); icalcomponent_get_first_property(mComponent, (icalproperty_kind)kind);
@ -533,7 +535,7 @@ calIcalComponent::GetFirstProperty(PRUint32 kind, calIIcalProperty **prop)
} }
NS_IMETHODIMP NS_IMETHODIMP
calIcalComponent::GetNextProperty(PRUint32 kind, calIIcalProperty **prop) calIcalComponent::GetNextProperty(PRInt32 kind, calIIcalProperty **prop)
{ {
icalproperty *icalprop = icalproperty *icalprop =
icalcomponent_get_next_property(mComponent, (icalproperty_kind)kind); icalcomponent_get_next_property(mComponent, (icalproperty_kind)kind);
@ -550,7 +552,7 @@ calIcalComponent::GetNextProperty(PRUint32 kind, calIIcalProperty **prop)
} }
NS_IMETHODIMP NS_IMETHODIMP
calIcalComponent::AddProperty(PRUint32 kind, calIIcalProperty **prop) calIcalComponent::AddProperty(PRInt32 kind, calIIcalProperty **prop)
{ {
icalproperty *icalprop = icalproperty_new((icalproperty_kind)kind); icalproperty *icalprop = icalproperty_new((icalproperty_kind)kind);
if (!icalprop) if (!icalprop)
@ -664,7 +666,7 @@ calICSService::ParseICS(const nsACString& serialized,
} }
NS_IMETHODIMP NS_IMETHODIMP
calICSService::CreateIcalComponent(PRUint32 kind, calIIcalComponent **comp) calICSService::CreateIcalComponent(PRInt32 kind, calIIcalComponent **comp)
{ {
icalcomponent *ical = icalcomponent_new((icalcomponent_kind)kind); icalcomponent *ical = icalcomponent_new((icalcomponent_kind)kind);
if (!ical) if (!ical)

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

@ -96,8 +96,8 @@ calItemBase.prototype = {
mTitle: "", get title() { return this.mTitle; }, set title(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mTitle = v; }, mTitle: "", get title() { return this.mTitle; }, set title(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mTitle = v; },
mPriority: 0, get priority() { return this.mPriority; }, set priority(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mPriority = v; }, mPriority: 0, get priority() { return this.mPriority; }, set priority(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mPriority = v; },
mIsPrivate: 0, get isPrivate() { return this.mIsPrivate; }, set isPrivate(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mIsPrivate = v; }, mIsPrivate: 0, get isPrivate() { return this.mIsPrivate; }, set isPrivate(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mIsPrivate = v; },
mMethod: 0, get method() { return this.mMethod; }, set method(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mMethod = v; }, mMethod: ICAL.INVALID_VALUE, get method() { return this.mMethod; }, set method(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mMethod = v; },
mStatus: 0, get status() { return this.mStatus; }, set status(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mStatus = v; }, mStatus: ICAL.INVALID_VALUE, get status() { return this.mStatus; }, set status(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mStatus = v; },
mHasAlarm: false, get hasAlarm() { return this.mHasAlarm; }, set hasAlarm(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mHasAlarm = v; }, mHasAlarm: false, get hasAlarm() { return this.mHasAlarm; }, set hasAlarm(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mHasAlarm = v; },
mAlarmTime: null, get alarmTime() { return this.mAlarmTime; }, set alarmTime(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mAlarmTime = v; }, mAlarmTime: null, get alarmTime() { return this.mAlarmTime; }, set alarmTime(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mAlarmTime = v; },
mRecurrenceInfo: null, get recurrenceInfo() { return this.mRecurrenceInfo; }, set recurrenceInfo(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mRecurrenceInfo = v; }, mRecurrenceInfo: null, get recurrenceInfo() { return this.mRecurrenceInfo; }, set recurrenceInfo(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mRecurrenceInfo = v; },
@ -170,23 +170,26 @@ calItemBase.prototype = {
mapPropsFromICS: function(icalcomp, propmap) { mapPropsFromICS: function(icalcomp, propmap) {
for (var i = 0; i < propmap.length; i++) { for (var i = 0; i < propmap.length; i++) {
var prop = propmap[i]; var prop = propmap[i];
this[prop.cal] = icalcomp[prop.ics]; var val = icalcomp[prop.ics];
if (val != ICAL.INVALID_VALUE)
this[prop.cal] = val;
} }
}, },
mapPropsToICS: function(icalcomp, propmap) { mapPropsToICS: function(icalcomp, propmap) {
for (var i = 0; i < propmap.length; i++) { for (var i = 0; i < propmap.length; i++) {
var prop = propmap[i]; var prop = propmap[i];
if (!(prop.cal in this))
continue;
var val = this[prop.cal]; var val = this[prop.cal];
if (prop.force || val) if (val != null && val != ICAL.INVALID_VALUE)
icalcomp[prop.ics] = this[prop.cal]; icalcomp[prop.ics] = val;
} }
}, },
icsBasePropMap: [ icsBasePropMap: [
{ cal: "mCreationDate", ics: "createdTime" }, { cal: "mCreationDate", ics: "createdTime" },
{ cal: "mLastModifiedTime", ics: "lastModified" }, { cal: "mLastModifiedTime", ics: "lastModified" },
{ cal: "mGeneration", ics: "version" },
{ cal: "mId", ics: "uid" }, { cal: "mId", ics: "uid" },
{ cal: "mTitle", ics: "summary" }, { cal: "mTitle", ics: "summary" },
{ cal: "mPriority", ics: "priority" }, { cal: "mPriority", ics: "priority" },

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

@ -138,8 +138,8 @@ calItemBase.prototype = {
MEMBER_ATTR(mTitle, "", title), MEMBER_ATTR(mTitle, "", title),
MEMBER_ATTR(mPriority, 0, priority), MEMBER_ATTR(mPriority, 0, priority),
MEMBER_ATTR(mIsPrivate, 0, isPrivate), MEMBER_ATTR(mIsPrivate, 0, isPrivate),
MEMBER_ATTR(mMethod, 0, method), MEMBER_ATTR(mMethod, ICAL.INVALID_VALUE, method),
MEMBER_ATTR(mStatus, 0, status), MEMBER_ATTR(mStatus, ICAL.INVALID_VALUE, status),
MEMBER_ATTR(mHasAlarm, false, hasAlarm), MEMBER_ATTR(mHasAlarm, false, hasAlarm),
MEMBER_ATTR(mAlarmTime, null, alarmTime), MEMBER_ATTR(mAlarmTime, null, alarmTime),
MEMBER_ATTR(mRecurrenceInfo, null, recurrenceInfo), MEMBER_ATTR(mRecurrenceInfo, null, recurrenceInfo),
@ -212,23 +212,26 @@ calItemBase.prototype = {
mapPropsFromICS: function(icalcomp, propmap) { mapPropsFromICS: function(icalcomp, propmap) {
for (var i = 0; i < propmap.length; i++) { for (var i = 0; i < propmap.length; i++) {
var prop = propmap[i]; var prop = propmap[i];
this[prop.cal] = icalcomp[prop.ics]; var val = icalcomp[prop.ics];
if (val != null && val != ICAL.INVALID_VALUE)
this[prop.cal] = val;
} }
}, },
mapPropsToICS: function(icalcomp, propmap) { mapPropsToICS: function(icalcomp, propmap) {
for (var i = 0; i < propmap.length; i++) { for (var i = 0; i < propmap.length; i++) {
var prop = propmap[i]; var prop = propmap[i];
if (!(prop.cal in this))
continue;
var val = this[prop.cal]; var val = this[prop.cal];
if (prop.force || val) if (val != null && val != ICAL.INVALID_VALUE)
icalcomp[prop.ics] = this[prop.cal]; icalcomp[prop.ics] = val;
} }
}, },
icsBasePropMap: [ icsBasePropMap: [
{ cal: "mCreationDate", ics: "createdTime" }, { cal: "mCreationDate", ics: "createdTime" },
{ cal: "mLastModifiedTime", ics: "lastModified" }, { cal: "mLastModifiedTime", ics: "lastModified" },
{ cal: "mGeneration", ics: "version" },
{ cal: "mId", ics: "uid" }, { cal: "mId", ics: "uid" },
{ cal: "mTitle", ics: "summary" }, { cal: "mTitle", ics: "summary" },
{ cal: "mPriority", ics: "priority" }, { cal: "mPriority", ics: "priority" },