- Use literal strings instead of integer constants, for better insulation

from libical changes, and a vastly improved debugging experience.
  The requisite data validation is coming once I figure out how best to
  get libical to do that validation in any reasonable fashion whatsoever.

- Remove METHOD from calIItemBase, as it's a bit of ICS specificity that should
  live elsewhere for manipulation in calling code.

- Remove useless getAttendees/setAttendees from calIIcalComponent, now that
  real property/parameter support exists.

- Unify property/x-property interfaces as much as possible.

- Likewise for parameters/x-parameters.

- Real property and parameters support, sufficient at least to whack ATTENDEE
  props in interesting ways.

- Properties on calIAttendee (mapped generally to ICS parameters, though
  somewhat fragilely).

- Round-trip X-WHATEVER ICS properties and params reliably.

- Attendee serialization/deserialization in calItemBase.

- In various places, SetIsVoid on empty strings returned to signify
  missing property/parameters.  Nicer from JS, to be sure.

- Fix test cases and one little spot in Sunbird to keep up.

CalDAV event modification works now.
This commit is contained in:
shaver%mozilla.org 2004-12-13 09:50:30 +00:00
Родитель 3d6119d928
Коммит 4cf75d27d9
13 изменённых файлов: 695 добавлений и 486 удалений

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

@ -38,6 +38,9 @@
#include "nsISupports.idl"
interface calIIcalProperty;
interface nsISimpleEnumerator;
[scriptable,uuid(5d1f2c7c-29bb-4090-94c2-cabe278fe567)]
interface calIAttendee : nsISupports
{
@ -53,22 +56,38 @@ interface calIAttendee : nsISupports
attribute AUTF8String commonName;
attribute boolean rsvp;
const PRUint32 ROLE_CHAIR = 20041;
const PRUint32 ROLE_REQ_PARTICIPANT = 20042;
const PRUint32 ROLE_OPT_PARTICIPANT = 20043;
const PRUint32 ROLE_NON_PARTICIPANT = 20044;
attribute PRUint32 role;
/**
* CHAIR
* REQUIRED_PARTICIPANT
* OPTIONAL_PARTICIPANT
* NON_PARTICIPANT
*/
attribute AUTF8String role;
const PRUint32 PARTSTAT_NEEDSACTION = 20018;
const PRUint32 PARTSTAT_ACCEPTED = 20019;
const PRUint32 PARTSTAT_DECLINED = 20020;
const PRUint32 PARTSTAT_NONE = 20025;
attribute PRUint32 participationStatus;
/**
* NEEDSACTION
* ACCEPTED
* DECLINED
* TENTATIVE
* DELEGATED
* COMPLETED
* INPROCESS
*/
attribute AUTF8String participationStatus;
const PRUint32 CUTYPE_INDIVIDUAL = 20001;
const PRUint32 CUTYPE_GROUP = 20002;
const PRUint32 CUTYPE_RESOURCE = 20003;
const PRUint32 CUTYPE_ROOM = 20004;
attribute PRUint32 userType;
/**
* INDIVIDUAL
* GROUP
* RESOURCE
* ROOM
* UNKNOWN
*/
attribute AUTF8String userType;
readonly attribute nsISimpleEnumerator propertyEnumerator;
AUTF8String getProperty(in AString name);
void setProperty(in AString name, in AUTF8String value);
void deleteProperty(in AString name);
attribute calIIcalProperty icalProperty;
};

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

@ -47,9 +47,6 @@
[scriptable, uuid(5ab15c1c-e295-4d8e-a9a9-ba5bc848b59a)]
interface calIEvent : calIItemBase
{
const long CAL_EVENT_STATUS_TENTATIVE = 2;
const long CAL_EVENT_STATUS_CONFIRMED = 3;
// these attributes are marked readonly, as the calIDates are owned
// by the event; however, the actual caIDate objects are not read
// only and are intended to be manipulated to adjust dates.

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

@ -36,6 +36,9 @@
*
* ***** END LICENSE BLOCK ***** */
// XXX use strings for kind values instead of enumerated constants?
#include "nsISupports.idl"
interface calIItemBase;
@ -43,6 +46,14 @@ interface calIDateTime;
interface calIIcalProperty;
/**
* General notes:
*
* As with libical, use of getNextFoo(footype) is only valid if there have been
* no intervening getNextFoo(otherfootype)s, or removeFoo()s, or addFoo()s. In
* general, you want to do as little manipulation of your FooContainers as
* possible while iterating over them.
*/
[scriptable,uuid(4d7e456b-cfd0-4ebf-8794-c57789dafdc3)]
interface calIIcalComponent : nsISupports
{
@ -52,54 +63,32 @@ interface calIIcalComponent : nsISupports
*/
const PRInt32 INVALID_VALUE = -1;
calIIcalComponent getFirstSubcomponent(in PRInt32 componentType);
calIIcalComponent getNextSubcomponent(in PRInt32 componentType);
/**
* @param kind ANY, XROOT, VCALENDAR, VEVENT, etc.
*/
calIIcalComponent getFirstSubcomponent(in AUTF8String componentType);
calIIcalComponent getNextSubcomponent(in AUTF8String componentType);
const PRInt32 ANY_COMPONENT = 1;
const PRInt32 XROOT_COMPONENT = 2;
const PRInt32 VEVENT_COMPONENT = 4;
const PRInt32 VTODO_COMPONENT = 5;
const PRInt32 VJOURNAL_COMPONENT = 6;
const PRInt32 VCALENDAR_COMPONENT = 7;
const PRInt32 VFREEBUSY_COMPONENT = 8;
readonly attribute PRInt32 isA;
readonly attribute AUTF8String componentType;
attribute AUTF8String uid;
attribute AUTF8String prodid;
attribute AUTF8String version;
const PRInt32 METHOD_PUBLISH = 10012;
const PRInt32 METHOD_REQUEST = 10013;
const PRInt32 METHOD_REPLY = 10014;
const PRInt32 METHOD_ADD = 10015;
const PRInt32 METHOD_CANCEL = 10016;
const PRInt32 METHOD_REFRESH = 10017;
const PRInt32 METHOD_COUNTER = 10018;
const PRInt32 METHOD_DECLINECOUNTER = 10019;
const PRInt32 METHOD_CREATE = 10020;
const PRInt32 METHOD_READ = 10021;
const PRInt32 METHOD_RESPONSE = 10022;
const PRInt32 METHOD_MOVE = 10023;
const PRInt32 METHOD_MODIFY = 10024;
const PRInt32 METHOD_GENERATEUID = 10025;
const PRInt32 METHOD_DELETE = 10026;
const PRInt32 METHOD_NONE = 10027;
attribute PRInt32 method;
/**
* PUBLISH, REQUEST, REPLY, etc.
*/
attribute AUTF8String method;
const PRInt32 STATUS_TENTATIVE = 10029;
const PRInt32 STATUS_CONFIRMED = 10030;
const PRInt32 STATUS_COMPLETED = 10031;
const PRInt32 STATUS_NEEDSACTION = 10032;
const PRInt32 STATUS_CANCELLED = 10033;
const PRInt32 STATUS_INPROCESS = 10034;
const PRInt32 STATUS_DRAFT = 10035;
const PRInt32 STATUS_FINAL = 10036;
const PRInt32 STATUS_NONE = 10037;
attribute PRInt32 status;
/**
* TENTATIVE, CONFIRMED, CANCELLED, etc.
*/
attribute AUTF8String status;
const PRInt32 TRANSP_OPAQUE = 10039;
const PRInt32 TRANSP_TRANSPARENT = 10040;
attribute PRInt32 transp;
/**
* OPAQUE, TRANSPARENT, etc.
*/
attribute AUTF8String transp;
attribute AUTF8String summary;
attribute AUTF8String description;
@ -109,11 +98,10 @@ interface calIIcalComponent : nsISupports
attribute PRInt32 priority;
const PRInt32 VISIBILITY_PUBLIC = 10007;
const PRInt32 VISIBILITY_PRIVATE = 10008;
const PRInt32 VISIBILITY_CONFIDENTIAL = 10009;
const PRInt32 VISIBILITY_NONE = 10010;
attribute PRInt32 icalClass;
/**
* PUBLIC, PRIVATE, CONFIDENTIAL, etc.
*/
attribute AUTF8String icalClass;
attribute calIDateTime startTime;
attribute calIDateTime endTime;
@ -124,73 +112,50 @@ interface calIIcalComponent : nsISupports
attribute calIDateTime completedTime;
attribute calIDateTime lastModified;
void getAttendees(out PRUint32 count,
[array,size_is(count),retval] out string attendees);
void setAttendees(in PRUint32 count,
[array,size_is(count)] in string attendees);
AUTF8String serializeToICS();
void addSubcomponent(in calIIcalComponent comp);
void removeSubcomponent(in calIIcalComponent comp);
const PRInt32 ANY_PROPERTY = 0;
const PRInt32 ACTION_PROPERTY = 1;
const PRInt32 ATTACH_PROPERTY = 2;
const PRInt32 ATTENDEE_PROPERTY = 3;
calIIcalProperty getFirstProperty(in PRInt32 kind);
calIIcalProperty getNextProperty(in PRInt32 kind);
calIIcalProperty addProperty(in PRInt32 kind);
/**
* @param kind ANY, ATTENDEE, X-WHATEVER, etc.
*/
calIIcalProperty getFirstProperty(in AUTF8String kind);
calIIcalProperty getNextProperty(in AUTF8String kind);
void addProperty(in calIIcalProperty prop);
void removeProperty(in calIIcalProperty prop);
calIIcalProperty getFirstXProperty(in AUTF8String xpropname);
calIIcalProperty getNextXProperty(in AUTF8String xpropname);
calIIcalProperty addXProperty(in AUTF8String xpropname,
in AUTF8String xpropval);
};
[scriptable,uuid(17349a10-5d80-47fa-9bea-f22957357675)]
interface calIIcalProperty : nsISupports
{
attribute AUTF8String stringValue;
readonly attribute PRInt32 isA;
// XXX attribute AUTF8String stringValueWithParams; ?
readonly attribute AUTF8String propertyName;
AUTF8String getXParameter(in AUTF8String xparamname);
void setXParameter(in AUTF8String xparamname, in AUTF8String xparamval);
void removeXParameter(in AUTF8String xparamname);
AUTF8String getParameter(in AUTF8String paramname);
void setParameter(in AUTF8String paramname, in AUTF8String paramval);
const PRInt32 ALTREP_PARAMETER = 1;
const PRInt32 CN_PARAMETER = 2;
const PRInt32 CUTYPE_PARAMETER = 3;
const PRInt32 DELEGATEDFROM_PARAMETER = 4;
const PRInt32 DELEGATEDTO_PARAMETER = 5;
const PRInt32 DIR_PARAMETER = 6;
const PRInt32 ENCODING_PARAMETER = 7;
const PRInt32 FBTYPE_PARAMETER = 8;
const PRInt32 FMTTYPE_PARAMETER = 9;
const PRInt32 LANGUAGE_PARAMETER = 10;
const PRInt32 MEMBER_PARAMETER = 11;
const PRInt32 PARTSTAT_PARAMETER = 12;
const PRInt32 RANGE_PARAMETER = 13;
const PRInt32 RELATED_PARAMETER = 14;
const PRInt32 RELTYPE_PARAMETER = 15;
const PRInt32 ROLE_PARAMETER = 16;
const PRInt32 RSVP_PARAMETER = 17;
const PRInt32 SENTBY_PARAMETER = 18;
const PRInt32 TZID_PARAMETER = 19;
const PRInt32 VALUE_PARAMETER = 20;
/* const PRUint32 X_PARAMETER = 21; */
const PRInt32 XLICCOMPARETYPE_PARAMETER = 22;
const PRInt32 XLICERRORTYPE_PARAMETER = 23;
AUTF8String getFirstParameterName();
AUTF8String getNextParameterName();
/**
* This does not work with X-PARAMETERS, due to limitations in libical.
* You have to use clearXParameters() and then rebuild the ones you wanted
* to preserve. Sorry about that.
*/
void removeParameter(in AUTF8String paramname);
void clearXParameters();
AUTF8String getParameter(in PRInt32 kind);
void setParameter(in PRInt32 kind, in AUTF8String value);
void removeParameter(in PRInt32 kind);
};
[scriptable,uuid(c788a1dc-0929-4029-9a14-e1bc654eafad)]
interface calIICSService : nsISupports
{
calIIcalComponent parseICS(in AUTF8String serialized);
calIIcalComponent createIcalComponent(in PRInt32 kind);
calIIcalComponent createIcalComponent(in AUTF8String kind);
calIIcalProperty createIcalProperty(in AUTF8String kind);
/* I wish I could write this function atop libical!
boolean isLegalParameterValue(in AUTF8String paramKind,
in AUTF8String paramValue);
*/
};

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

@ -87,18 +87,6 @@ interface calIItemBase : nsISupports
//
readonly attribute PRUint32 generation;
// methods
const PRUint32 METHOD_PUBLISH = 10012;
const PRUint32 METHOD_REQUEST = 10013;
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
const long CAL_ITEM_STATUS_NONE = 0;
const long CAL_ITEM_STATUS_CANCELLED = 1;
// the time when this item was created
readonly attribute calIDateTime creationDate;
@ -116,11 +104,10 @@ interface calIItemBase : nsISupports
// event priority
attribute short priority;
attribute boolean isPrivate;
attribute AUTF8String privacy;
// event/status of the event (see consts above)
attribute long method;
attribute long status;
// status of the event
attribute AUTF8String status;
// ical interop; writing this means parsing
// the ical string into this event

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

@ -1,6 +1,8 @@
/* GENERATED FILE; DO NOT EDIT. SOURCE IS calAttendee.js.pre */
function calAttendee() {
this.wrappedJSObject = this;
this.mProperties = Components.classes["@mozilla.org/hash-property-bag;1"].
createInstance(Components.interfaces.nsIWritablePropertyBag);
}
calAttendee.prototype = {
@ -27,6 +29,7 @@ calAttendee.prototype = {
"userType"];
for (var i in allProps)
a[allProps[i]] = this[allProps[i]];
return a;
},
@ -35,16 +38,87 @@ calAttendee.prototype = {
mId: null, get id() { return this.mId; }, set id(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mId = v; },
mCommonName: null, get commonName() { return this.mCommonName; }, set commonName(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mCommonName = v; },
mRsvp: false, get rsvp() { return this.mRsvp; }, set rsvp(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mRsvp = v; },
mRole: Components.interfaces.calIAttendee.ROLE_OPT_PARTICIPANT, get role() { return this.mRole; }, set role(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mRole = v; },
mRole: Components.interfaces.calIAttendee.ROLE_OPT_PARTICIPANT, get role() { return this.mRole; }, set role(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mRole = v; },
mParticipationStatus: Components.interfaces.calIAttendee.PARTSTAT_NEEDSACTION, get participationStatus() { return this.mParticipationStatus; }, set participationStatus(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mParticipationStatus = v; },
mRsvp: null, get rsvp() { return this.mRsvp; }, set rsvp(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mRsvp = v; },
mRole: null, get role() { return this.mRole; }, set role(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mRole = v; },
mParticipationStatus: "NEEDSACTION", get participationStatus() { return this.mParticipationStatus; }, set participationStatus(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mParticipationStatus = v; },
mUserType: "INDIVIDUAL", get userType() { return this.mUserType; }, set userType(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mUserType = v; },
mUserType: Components.interfaces.calIAttendee.CUTYPE_INDIVIDUAL, get userType() { return this.mUserType; }, set userType(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mUserType = v; }
icalAttendeePropMap: [
{ cal: "rsvp", ics: "RSVP" },
{ cal: "commonName", ics: "CN" },
{ cal: "participationStatus", ics: "PARTSTAT" },
{ cal: "userType", ics: "CUTYPE" },
{ cal: "role", ics: "ROLE" } ],
set icalProperty (icalatt) {
if (icalatt.propertyName != "ATTENDEE")
throw Components.results.NS_ERROR_INVALID_ARG;
this.id = icalatt.stringValue;
var promotedProps = { };
for (var i = 0; i < this.icalAttendeePropMap.length; i++) {
var prop = this.icalAttendeePropMap[i];
this[prop.cal] = icalatt.getParameter(prop.ics);
promotedProps[prop.ics] = true;
}
for (var paramname = icalatt.getFirstParameterName();
paramname;
paramname = icalatt.getNextParameterName()) {
if (promotedProps[paramname])
continue;
this.setProperty(paramname, icalatt.getParameter(paramname));
}
},
get icalProperty() {
const icssvc =
Components.classes["@mozilla.org/calendar/ics-service;1"].
getService(Components.interfaces.calIICSService);
var icalatt = icssvc.createIcalProperty("ATTENDEE");
if (!this.id)
throw Components.results.NS_ERROR_NOT_INITIALIZED;
icalatt.stringValue = this.id;
for (var i = 0; i < this.icalAttendeePropMap.length; i++) {
var prop = this.icalAttendeePropMap[i];
if (this[prop.cal])
icalatt.setParameter(prop.ics, this[prop.cal]);
}
var bagenum = this.mProperties.enumerator;
while (bagenum.hasMoreElements()) {
var iprop = bagenum.getNext().
QueryInterface(Components.interfaces.nsIProperty);
icalatt.setParameter(iprop.name, iprop.value);
}
return icalatt;
},
get propertyEnumerator() { return this.mProperties.enumerator; },
getProperty: function (aName) {
try {
return this.mProperties.getProperty(aName);
} catch (e) {
return null;
}
},
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;
try {
this.mProperties.deleteProperty(aName);
} catch (e) {
}
},
};

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

@ -1,87 +0,0 @@
/* -*- Mode: javascript; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Oracle Corporation code.
*
* The Initial Developer of the Original Code is
* Oracle Corporation
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mike Shaver <shaver@off.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function calAttendee() {
this.wrappedJSObject = this;
}
calAttendee.prototype = {
QueryInterface: function (aIID) {
if (!aIID.equals(Components.interfaces.nsISupports) &&
!aIID.equals(Components.interfaces.calIAttendee))
{
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
},
mImmutable: false,
get isMutable() { return !this.mImmutable; },
makeImmutable : function() {
this.mImmutable = true;
},
clone: function() {
var a = new calAttendee();
var allProps = ["id", "commonName", "rsvp", "role", "participantStatus",
"userType"];
for (var i in allProps)
a[allProps[i]] = this[allProps[i]];
return a;
},
#define MEMBER_ATTR(varname, initvalue, attrname) \
varname: initvalue, \
get attrname() { return this.varname; }, \
set attrname(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.varname = v; }
MEMBER_ATTR(mId, null, id),
MEMBER_ATTR(mCommonName, null, commonName),
MEMBER_ATTR(mRsvp, false, rsvp),
MEMBER_ATTR(mRole, Components.interfaces.calIAttendee.ROLE_OPT_PARTICIPANT, role),
MEMBER_ATTR(mRole, Components.interfaces.calIAttendee.ROLE_OPT_PARTICIPANT, role),
MEMBER_ATTR(mParticipationStatus,
Components.interfaces.calIAttendee.PARTSTAT_NEEDSACTION,
participationStatus),
MEMBER_ATTR(mUserType, Components.interfaces.calIAttendee.CUTYPE_INDIVIDUAL, userType)
#undef MEMBER_ATTR
};

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

@ -69,22 +69,32 @@ calEvent.prototype = {
set icalString(value) {
if (this.mImmutable)
throw Components.results.NS_ERROR_FAILURE;
var ical = icalFromString(value);
var event = ical.getFirstSubcomponent(Components.interfaces.calIIcalComponent.VEVENT_COMPONENT);
if (!event)
var event = icalFromString(value);
if (event.componentType != "VEVENT"); {
event = event.getFirstSubcomponent("VEVENT");
if (!event)
throw Components.results.NS_ERROR_INVALID_ARG;
throw Components.results.NS_ERROR_INVALID_ARG;
}
this.setItemBaseFromICS(event);
this.mapPropsFromICS(event, this.icsEventPropMap);
this.mIsAllDay = this.mStartDate && this.mStartDate.isDate;
var promotedProps = {
"DTSTART": true,
"DTEND": true,
"DTSTAMP": true,
__proto__: this.itemBasePromotedProps
};
this.importUnpromotedProperties(event, promotedProps);
},
get icalString() {
const icssvc = Components.
classes["@mozilla.org/calendar/ics-service;1"].
getService(Components.interfaces.calIICSService);
var calcomp = icssvc.createIcalComponent(ICAL.VCALENDAR_COMPONENT);
var calcomp = icssvc.createIcalComponent("VCALENDAR");
calcomp.prodid = "-//Mozilla Calendar//NONSGML Sunbird//EN";
calcomp.version = "2.0";
calcomp.addSubcomponent(this.icalComponent);
@ -95,9 +105,22 @@ calEvent.prototype = {
const icssvc = Components.
classes["@mozilla.org/calendar/ics-service;1"].
getService(Components.interfaces.calIICSService);
var icalcomp = icssvc.createIcalComponent(ICAL.VEVENT_COMPONENT);
var icalcomp = icssvc.createIcalComponent("VEVENT");
this.fillIcalComponentFromBase(icalcomp);
this.mapPropsToICS(icalcomp, this.icsEventPropMap);
var bagenum = this.mProperties.enumerator;
while (bagenum.hasMoreElements()) {
var iprop = bagenum.getNext().
QueryInterface(Components.interfaces.nsIProperty);
try {
var icalprop = icssvc.createIcalProperty(iprop.name);
icalprop.stringValue = iprop.value;
icalcomp.addProperty(icalprop);
} catch (e) {
}
}
return icalcomp;
},
};

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

@ -114,22 +114,32 @@ calEvent.prototype = {
set icalString(value) {
if (this.mImmutable)
throw Components.results.NS_ERROR_FAILURE;
var ical = icalFromString(value);
var event = ical.getFirstSubcomponent(Components.interfaces.calIIcalComponent.VEVENT_COMPONENT);
if (!event)
// throw Components.results.NS_ERROR_CALENDAR_WRONG_COMPONENT_TYPE;
throw Components.results.NS_ERROR_INVALID_ARG;
var event = icalFromString(value);
if (event.componentType != "VEVENT"); {
event = event.getFirstSubcomponent("VEVENT");
if (!event)
// throw Components.results.NS_ERROR_CALENDAR_WRONG_COMPONENT_TYPE;
throw Components.results.NS_ERROR_INVALID_ARG;
}
this.setItemBaseFromICS(event);
this.mapPropsFromICS(event, this.icsEventPropMap);
this.mIsAllDay = this.mStartDate && this.mStartDate.isDate;
var promotedProps = {
"DTSTART": true,
"DTEND": true,
"DTSTAMP": true,
__proto__: this.itemBasePromotedProps
};
this.importUnpromotedProperties(event, promotedProps);
},
get icalString() {
const icssvc = Components.
classes["@mozilla.org/calendar/ics-service;1"].
getService(Components.interfaces.calIICSService);
var calcomp = icssvc.createIcalComponent(ICAL.VCALENDAR_COMPONENT);
var calcomp = icssvc.createIcalComponent("VCALENDAR");
calcomp.prodid = "-//Mozilla Calendar//NONSGML Sunbird//EN";
calcomp.version = "2.0";
calcomp.addSubcomponent(this.icalComponent);
@ -140,9 +150,22 @@ calEvent.prototype = {
const icssvc = Components.
classes["@mozilla.org/calendar/ics-service;1"].
getService(Components.interfaces.calIICSService);
var icalcomp = icssvc.createIcalComponent(ICAL.VEVENT_COMPONENT);
var icalcomp = icssvc.createIcalComponent("VEVENT");
this.fillIcalComponentFromBase(icalcomp);
this.mapPropsToICS(icalcomp, this.icsEventPropMap);
var bagenum = this.mProperties.enumerator;
while (bagenum.hasMoreElements()) {
var iprop = bagenum.getNext().
QueryInterface(Components.interfaces.nsIProperty);
try {
var icalprop = icssvc.createIcalProperty(iprop.name);
icalprop.stringValue = iprop.value;
icalcomp.addProperty(icalprop);
} catch (e) {
// dump("failed to set " + iprop.name + " to " + iprop.value +
// ": " + e + "\n");
}
}
return icalcomp;
},
};

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

@ -73,18 +73,17 @@ protected:
NS_IMPL_ISUPPORTS1(calIcalProperty, calIIcalProperty)
NS_IMETHODIMP
calIcalProperty::GetIsA(PRInt32 *isa)
{
*isa = (PRInt32)icalproperty_isa(mProperty);
return NS_OK;
}
NS_IMETHODIMP
calIcalProperty::GetStringValue(nsACString &str)
{
const char *icalstr = icalproperty_get_value_as_string(mProperty);
if (!icalstr) {
if (icalerrno == ICAL_BADARG_ERROR) {
str.Truncate();
str.SetIsVoid(PR_TRUE);
return NS_OK;
}
#ifdef DEBUG
fprintf(stderr, "Error getting string value: %d (%s)\n",
icalerrno, icalerror_strerror(icalerrno));
@ -94,7 +93,6 @@ calIcalProperty::GetStringValue(nsACString &str)
str.Assign(icalstr);
return NS_OK;
}
NS_IMETHODIMP
@ -109,42 +107,168 @@ calIcalProperty::SetStringValue(const nsACString &str)
}
NS_IMETHODIMP
calIcalProperty::GetXParameter(const nsACString &xparamname,
nsACString &xparamvalue)
calIcalProperty::GetPropertyName(nsACString &name)
{
return NS_ERROR_NOT_IMPLEMENTED;
const char *icalstr = icalproperty_get_name(mProperty);
if (!icalstr) {
#ifdef DEBUG
fprintf(stderr, "Error getting property name: %d (%s)\n",
icalerrno, icalerror_strerror(icalerrno));
#endif
return NS_ERROR_FAILURE;
}
name.Assign(icalstr);
return NS_OK;
}
static icalparameter*
FindXParameter(icalproperty *prop, const nsACString &param)
{
for (icalparameter *icalparam =
icalproperty_get_first_parameter(prop, ICAL_X_PARAMETER);
icalparam;
icalparam = icalproperty_get_next_parameter(prop, ICAL_X_PARAMETER)) {
if (param.Equals(icalparameter_get_xname(icalparam)))
return icalparam;
}
return nsnull;
}
NS_IMETHODIMP
calIcalProperty::SetXParameter(const nsACString &xparamname,
const nsACString &xparamvalue)
calIcalProperty::GetParameter(const nsACString &param, nsACString &value)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
// More ridiculous parameter/X-PARAMETER handling.
icalparameter_kind paramkind =
icalparameter_string_to_kind(PromiseFlatCString(param).get());
if (paramkind == ICAL_NO_PARAMETER)
return NS_ERROR_INVALID_ARG;
NS_IMETHODIMP
calIcalProperty::RemoveXParameter(const nsACString &xparamname)
{
return NS_ERROR_NOT_IMPLEMENTED;
const char *icalstr = nsnull;
if (paramkind == ICAL_X_PARAMETER) {
icalparameter *icalparam = FindXParameter(mProperty, param);
if (icalparam)
icalstr = icalparameter_get_xvalue(icalparam);
} else {
icalstr = icalproperty_get_parameter_as_string(mProperty,
PromiseFlatCString(param).get());
}
if (!icalstr) {
value.Truncate();
value.SetIsVoid(PR_TRUE);
} else {
value.Assign(icalstr);
}
return NS_OK;
}
NS_IMETHODIMP
calIcalProperty::GetParameter(PRInt32 kind, nsACString &value)
calIcalProperty::SetParameter(const nsACString &param, const nsACString &value)
{
return NS_ERROR_NOT_IMPLEMENTED;
icalparameter_kind paramkind =
icalparameter_string_to_kind(PromiseFlatCString(param).get());
if (paramkind == ICAL_NO_PARAMETER)
return NS_ERROR_INVALID_ARG;
// Because libical's support for manipulating parameters is weak, and
// X-PARAMETERS doubly so, we walk the list looking for an existing one of
// that name, and reset its value if found.
if (paramkind == ICAL_X_PARAMETER) {
icalparameter *icalparam = FindXParameter(mProperty, param);
if (icalparam) {
icalparameter_set_xvalue(icalparam,
PromiseFlatCString(value).get());
return NS_OK;
}
// If not found, fall through to adding a new parameter below.
} else {
// We could try getting an existing parameter here and resetting its
// value, but this is easier and I don't care that much about parameter
// performance at this point.
RemoveParameter(param);
}
icalparameter *icalparam =
icalparameter_new_from_value_string(paramkind,
PromiseFlatCString(value).get());
if (!icalparam)
return NS_ERROR_OUT_OF_MEMORY;
// You might ask me "why does libical not do this for us?" and I would
// just nod knowingly but sadly at you in return.
//
// You might also, if you were not too distracted by the first question,
// ask why we have icalproperty_set_x_name but icalparameter_set_xname.
// More nodding would ensue.
if (paramkind == ICAL_X_PARAMETER)
icalparameter_set_xname(icalparam, PromiseFlatCString(param).get());
icalproperty_add_parameter(mProperty, icalparam);
// XXX check ical errno
return NS_OK;
}
static nsresult
FillParameterName(icalparameter *icalparam, nsACString &name)
{
if (!icalparam) {
name.Truncate();
name.SetIsVoid(PR_TRUE);
return NS_OK;
}
icalparameter_kind paramkind = icalparameter_isa(icalparam);
if (paramkind == ICAL_X_PARAMETER)
name.Assign(icalparameter_get_xname(icalparam));
else
name.Assign(icalparameter_kind_to_string(paramkind));
return NS_OK;
}
NS_IMETHODIMP
calIcalProperty::SetParameter(PRInt32 kind, const nsACString &value)
calIcalProperty::GetFirstParameterName(nsACString &name)
{
return NS_ERROR_NOT_IMPLEMENTED;
icalparameter *icalparam =
icalproperty_get_first_parameter(mProperty,
ICAL_ANY_PARAMETER);
return FillParameterName(icalparam, name);
}
NS_IMETHODIMP
calIcalProperty::RemoveParameter(PRInt32 kind)
calIcalProperty::GetNextParameterName(nsACString &name)
{
return NS_ERROR_NOT_IMPLEMENTED;
icalparameter *icalparam =
icalproperty_get_next_parameter(mProperty,
ICAL_ANY_PARAMETER);
return FillParameterName(icalparam, name);
}
NS_IMETHODIMP
calIcalProperty::RemoveParameter(const nsACString &param)
{
icalparameter_kind paramkind =
icalparameter_string_to_kind(PromiseFlatCString(param).get());
if (paramkind == ICAL_NO_PARAMETER || paramkind == ICAL_X_PARAMETER)
return NS_ERROR_INVALID_ARG;
icalproperty_remove_parameter(mProperty, paramkind);
// XXX check ical errno
return NS_OK;
}
NS_IMETHODIMP
calIcalProperty::ClearXParameters()
{
int oldcount, paramcount = 0;
do {
oldcount = paramcount;
icalproperty_remove_parameter(mProperty, ICAL_X_PARAMETER);
paramcount = icalproperty_count_parameters(mProperty);
} while (oldcount != paramcount);
return NS_OK;
}
class calIcalComponent : public calIIcalComponent
@ -237,6 +361,56 @@ calIcalComponent::SetProperty(icalproperty_kind kind, icalproperty *prop)
return NS_OK;
}
#define COMP_STRING_TO_GENERAL_ENUM_ATTRIBUTE(Attrname, ICALNAME, lcname) \
NS_IMETHODIMP \
calIcalComponent::Get##Attrname(nsACString &str) \
{ \
PRInt32 val; \
nsresult rv = GetIntProperty(ICAL_##ICALNAME##_PROPERTY, &val); \
if (NS_FAILED(rv)) \
return rv; \
if (val == -1) { \
str.Truncate(); \
str.SetIsVoid(PR_TRUE); \
} else { \
str.Assign(icalproperty_enum_to_string(val)); \
} \
return NS_OK; \
} \
\
NS_IMETHODIMP \
calIcalComponent::Set##Attrname(const nsACString &str) \
{ \
int val = icalproperty_string_to_enum(PromiseFlatCString(str).get()); \
icalvalue *ival = icalvalue_new_##lcname((icalproperty_##lcname)val); \
return SetPropertyValue(ICAL_##ICALNAME##_PROPERTY, ival); \
} \
#define COMP_STRING_TO_ENUM_ATTRIBUTE(Attrname, ICALNAME, lcname) \
NS_IMETHODIMP \
calIcalComponent::Get##Attrname(nsACString &str) \
{ \
PRInt32 val; \
nsresult rv = GetIntProperty(ICAL_##ICALNAME##_PROPERTY, &val); \
if (NS_FAILED(rv)) \
return rv; \
if (val == -1) { \
str.Truncate(); \
str.SetIsVoid(PR_TRUE); \
} else { \
str.Assign(icalproperty_##lcname##_to_string((icalproperty_##lcname)val)); \
} \
return NS_OK; \
} \
\
NS_IMETHODIMP \
calIcalComponent::Set##Attrname(const nsACString &str) \
{ \
icalproperty_##lcname val = \
icalproperty_string_to_##lcname(PromiseFlatCString(str).get()); \
icalproperty *prop = icalproperty_new_##lcname(val); \
return SetProperty(ICAL_##ICALNAME##_PROPERTY, prop); \
} \
#define COMP_GENERAL_STRING_ATTRIBUTE(Attrname, ICALNAME) \
NS_IMETHODIMP \
@ -268,26 +442,26 @@ calIcalComponent::Set##Attrname(const nsACString &str) \
#define COMP_GENERAL_INT_ATTRIBUTE(Attrname, ICALNAME) \
NS_IMETHODIMP \
calIcalComponent::Get##Attrname(PRInt32 *valp) \
calIcalComponent::Get##Attrname(PRInt32 *valp) \
{ \
return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp); \
} \
\
NS_IMETHODIMP \
calIcalComponent::Set##Attrname(PRInt32 val) \
calIcalComponent::Set##Attrname(PRInt32 val) \
{ \
return SetIntProperty(ICAL_##ICALNAME##_PROPERTY, val); \
} \
#define COMP_ENUM_ATTRIBUTE(Attrname, ICALNAME, lcname) \
NS_IMETHODIMP \
calIcalComponent::Get##Attrname(PRInt32 *valp) \
calIcalComponent::Get##Attrname(PRInt32 *valp) \
{ \
return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp); \
} \
\
NS_IMETHODIMP \
calIcalComponent::Set##Attrname(PRInt32 val) \
calIcalComponent::Set##Attrname(PRInt32 val) \
{ \
icalproperty *prop = \
icalproperty_new_##lcname((icalproperty_##lcname)val); \
@ -296,13 +470,13 @@ calIcalComponent::Set##Attrname(PRInt32 val) \
#define COMP_INT_ATTRIBUTE(Attrname, ICALNAME, lcname) \
NS_IMETHODIMP \
calIcalComponent::Get##Attrname(PRInt32 *valp) \
calIcalComponent::Get##Attrname(PRInt32 *valp) \
{ \
return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp); \
} \
\
NS_IMETHODIMP \
calIcalComponent::Set##Attrname(PRInt32 val) \
calIcalComponent::Set##Attrname(PRInt32 val) \
{ \
icalproperty *prop = icalproperty_new_##lcname(val); \
return SetProperty(ICAL_##ICALNAME##_PROPERTY, prop); \
@ -349,12 +523,18 @@ calIcalComponent::Set##Attrname(calIDateTime *dt) \
NS_IMPL_ISUPPORTS1(calIcalComponent, calIIcalComponent)
NS_IMETHODIMP
calIcalComponent::GetFirstSubcomponent(PRInt32 componentType,
calIcalComponent::GetFirstSubcomponent(const nsACString& kind,
calIIcalComponent **subcomp)
{
icalcomponent_kind compkind =
icalcomponent_string_to_kind(PromiseFlatCString(kind).get());
// Maybe someday I'll support X-COMPONENTs
if (compkind == ICAL_NO_COMPONENT || compkind == ICAL_X_COMPONENT)
return NS_ERROR_INVALID_ARG;
icalcomponent *ical =
icalcomponent_get_first_component(mComponent,
(icalcomponent_kind)componentType);
icalcomponent_get_first_component(mComponent, compkind);
if (!ical) {
*subcomp = nsnull;
return NS_OK;
@ -368,12 +548,18 @@ calIcalComponent::GetFirstSubcomponent(PRInt32 componentType,
}
NS_IMETHODIMP
calIcalComponent::GetNextSubcomponent(PRInt32 componentType,
calIcalComponent::GetNextSubcomponent(const nsACString& kind,
calIIcalComponent **subcomp)
{
icalcomponent_kind compkind =
icalcomponent_string_to_kind(PromiseFlatCString(kind).get());
// Maybe someday I'll support X-COMPONENTs
if (compkind == ICAL_NO_COMPONENT || compkind == ICAL_X_COMPONENT)
return NS_ERROR_INVALID_ARG;
icalcomponent *ical =
icalcomponent_get_next_component(mComponent,
(icalcomponent_kind)componentType);
icalcomponent_get_next_component(mComponent, compkind);
if (!ical) {
*subcomp = nsnull;
return NS_OK;
@ -387,9 +573,9 @@ calIcalComponent::GetNextSubcomponent(PRInt32 componentType,
}
NS_IMETHODIMP
calIcalComponent::GetIsA(PRInt32 *isa)
calIcalComponent::GetComponentType(nsACString &componentType)
{
*isa = icalcomponent_isa(mComponent);
componentType.Assign(icalcomponent_kind_to_string(icalcomponent_isa(mComponent)));
return NS_OK;
}
@ -397,16 +583,16 @@ calIcalComponent::GetIsA(PRInt32 *isa)
COMP_STRING_ATTRIBUTE(Uid, UID, uid)
COMP_STRING_ATTRIBUTE(Prodid, PRODID, prodid)
COMP_STRING_ATTRIBUTE(Version, VERSION, version)
COMP_ENUM_ATTRIBUTE(Method, METHOD, method)
COMP_ENUM_ATTRIBUTE(Status, STATUS, status)
COMP_GENERAL_INT_ATTRIBUTE(Transp, TRANSP)
COMP_STRING_TO_ENUM_ATTRIBUTE(Method, METHOD, method)
COMP_STRING_TO_ENUM_ATTRIBUTE(Status, STATUS, status)
COMP_STRING_TO_GENERAL_ENUM_ATTRIBUTE(Transp, TRANSP, transp)
COMP_STRING_ATTRIBUTE(Summary, SUMMARY, summary)
COMP_STRING_ATTRIBUTE(Description, DESCRIPTION, description)
COMP_STRING_ATTRIBUTE(Location, LOCATION, location)
COMP_STRING_ATTRIBUTE(Categories, CATEGORIES, categories)
COMP_STRING_ATTRIBUTE(URL, URL, url)
COMP_INT_ATTRIBUTE(Priority, PRIORITY, priority)
COMP_ENUM_ATTRIBUTE(IcalClass, CLASS, class)
COMP_STRING_TO_GENERAL_ENUM_ATTRIBUTE(IcalClass, CLASS, class)
COMP_DATE_ATTRIBUTE(StartTime, DTSTART)
COMP_DATE_ATTRIBUTE(EndTime, DTEND)
COMP_DATE_ATTRIBUTE(DueTime, DUE)
@ -415,38 +601,6 @@ COMP_DATE_ATTRIBUTE(LastModified, LASTMODIFIED)
COMP_DATE_ATTRIBUTE(CreatedTime, CREATED)
COMP_DATE_ATTRIBUTE(CompletedTime, COMPLETED)
NS_IMETHODIMP
calIcalComponent::GetAttendees(PRUint32 *count, char ***attendees)
{
char **attlist = nsnull;
PRUint32 attcount = 0;
for (icalproperty *prop =
icalcomponent_get_first_property(mComponent, ICAL_ATTENDEE_PROPERTY);
prop;
prop = icalcomponent_get_next_property(mComponent, ICAL_ATTENDEE_PROPERTY)) {
attcount++;
char **newlist =
NS_STATIC_CAST(char **,
NS_Realloc(attlist, attcount * sizeof(char *)));
if (!newlist)
goto oom;
attlist = newlist;
attlist[attcount - 1] = nsCRT::strdup(icalproperty_get_attendee(prop));
if (!attlist[attcount - 1])
goto oom;
}
*attendees = attlist;
*count = attcount;
return NS_OK;
oom:
for (PRUint32 i = 0; i < attcount - 1; i++)
NS_Free(attlist[i]);
NS_Free(attlist);
return NS_ERROR_OUT_OF_MEMORY;
}
void
calIcalComponent::ClearAllProperties(icalproperty_kind kind)
{
@ -460,20 +614,6 @@ calIcalComponent::ClearAllProperties(icalproperty_kind kind)
}
}
NS_IMETHODIMP
calIcalComponent::SetAttendees(PRUint32 count, const char **attendees)
{
ClearAllProperties(ICAL_ATTENDEE_PROPERTY);
for (PRUint32 i = 0; i < count; i++) {
icalproperty *prop = icalproperty_new_attendee(attendees[i]);
if (!prop)
return NS_ERROR_OUT_OF_MEMORY;
icalcomponent_add_property(mComponent, prop);
}
return NS_OK;
}
NS_IMETHODIMP
calIcalComponent::SerializeToICS(nsACString &serialized)
{
@ -518,10 +658,30 @@ calIcalComponent::RemoveSubcomponent(calIIcalComponent *comp)
}
NS_IMETHODIMP
calIcalComponent::GetFirstProperty(PRInt32 kind, calIIcalProperty **prop)
calIcalComponent::GetFirstProperty(const nsACString &kind,
calIIcalProperty **prop)
{
icalproperty *icalprop =
icalcomponent_get_first_property(mComponent, (icalproperty_kind)kind);
icalproperty_kind propkind =
icalproperty_string_to_kind(PromiseFlatCString(kind).get());
if (propkind == ICAL_NO_PROPERTY)
return NS_ERROR_INVALID_ARG;
icalproperty *icalprop = nsnull;
if (propkind == ICAL_X_PROPERTY) {
for (icalprop =
icalcomponent_get_first_property(mComponent, ICAL_X_PROPERTY);
icalprop;
icalprop = icalcomponent_get_next_property(mComponent,
ICAL_X_PROPERTY)) {
if (kind.Equals(icalproperty_get_x_name(icalprop)))
break;
}
} else {
icalprop = icalcomponent_get_first_property(mComponent, propkind);
}
if (!icalprop) {
*prop = nsnull;
return NS_OK;
@ -535,10 +695,29 @@ calIcalComponent::GetFirstProperty(PRInt32 kind, calIIcalProperty **prop)
}
NS_IMETHODIMP
calIcalComponent::GetNextProperty(PRInt32 kind, calIIcalProperty **prop)
calIcalComponent::GetNextProperty(const nsACString &kind,
calIIcalProperty **prop)
{
icalproperty *icalprop =
icalcomponent_get_next_property(mComponent, (icalproperty_kind)kind);
icalproperty_kind propkind =
icalproperty_string_to_kind(PromiseFlatCString(kind).get());
if (propkind == ICAL_NO_PROPERTY)
return NS_ERROR_INVALID_ARG;
icalproperty *icalprop = nsnull;
if (propkind == ICAL_X_PROPERTY) {
for (icalprop =
icalcomponent_get_next_property(mComponent, ICAL_X_PROPERTY);
icalprop;
icalprop = icalcomponent_get_next_property(mComponent,
ICAL_X_PROPERTY)) {
if (kind.Equals(icalproperty_get_x_name(icalprop)))
break;
}
} else {
icalprop = icalcomponent_get_next_property(mComponent, propkind);
}
if (!icalprop) {
*prop = nsnull;
return NS_OK;
@ -552,15 +731,12 @@ calIcalComponent::GetNextProperty(PRInt32 kind, calIIcalProperty **prop)
}
NS_IMETHODIMP
calIcalComponent::AddProperty(PRInt32 kind, calIIcalProperty **prop)
calIcalComponent::AddProperty(calIIcalProperty *prop)
{
icalproperty *icalprop = icalproperty_new((icalproperty_kind)kind);
if (!icalprop)
return NS_ERROR_OUT_OF_MEMORY; // XXX translate
*prop = new calIcalProperty(icalprop, this);
if (!*prop)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*prop);
// XXX like AddSubcomponent, this is questionable
calIcalProperty *ical = NS_STATIC_CAST(calIcalProperty *, prop);
icalcomponent_add_property(mComponent, ical->mProperty);
ical->mParent = this;
return NS_OK;
}
@ -574,72 +750,6 @@ calIcalComponent::RemoveProperty(calIIcalProperty *prop)
return NS_OK;
}
NS_IMETHODIMP
calIcalComponent::GetFirstXProperty(const nsACString &xpropname,
calIIcalProperty **prop)
{
for (icalproperty *icalprop =
icalcomponent_get_first_property(mComponent, ICAL_X_PROPERTY);
icalprop;
icalprop = icalcomponent_get_next_property(mComponent,
ICAL_X_PROPERTY)) {
if (xpropname.Equals(icalproperty_get_x_name(icalprop))) {
*prop = new calIcalProperty(icalprop, this);
if (!*prop)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*prop);
return NS_OK;
}
}
*prop = nsnull;
return NS_OK;
}
NS_IMETHODIMP
calIcalComponent::GetNextXProperty(const nsACString &xpropname,
calIIcalProperty **prop)
{
for (icalproperty *icalprop =
icalcomponent_get_next_property(mComponent, ICAL_X_PROPERTY);
icalprop;
icalprop = icalcomponent_get_next_property(mComponent,
ICAL_X_PROPERTY)) {
if (xpropname.Equals(icalproperty_get_x_name(icalprop))) {
*prop = new calIcalProperty(icalprop, this);
if (!*prop)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*prop);
return NS_OK;
}
}
*prop = nsnull;
return NS_OK;
}
NS_IMETHODIMP
calIcalComponent::AddXProperty(const nsACString &xpropname,
const nsACString &xpropval,
calIIcalProperty **prop)
{
icalproperty* icalprop = icalproperty_new(ICAL_X_PROPERTY);
if (!icalprop)
return NS_ERROR_OUT_OF_MEMORY;
icalproperty_set_value_from_string(icalprop,
PromiseFlatCString(xpropname).get(),
PromiseFlatCString(xpropval).get());
*prop = new calIcalProperty(icalprop, this);
if (!*prop) {
icalproperty_free(icalprop);
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*prop);
return NS_OK;
}
NS_IMPL_ISUPPORTS1(calICSService, calIICSService)
NS_IMETHODIMP
@ -666,9 +776,17 @@ calICSService::ParseICS(const nsACString& serialized,
}
NS_IMETHODIMP
calICSService::CreateIcalComponent(PRInt32 kind, calIIcalComponent **comp)
calICSService::CreateIcalComponent(const nsACString &kind,
calIIcalComponent **comp)
{
icalcomponent *ical = icalcomponent_new((icalcomponent_kind)kind);
icalcomponent_kind compkind =
icalcomponent_string_to_kind(PromiseFlatCString(kind).get());
// Maybe someday I'll support X-COMPONENTs
if (compkind == ICAL_NO_COMPONENT || compkind == ICAL_X_COMPONENT)
return NS_ERROR_INVALID_ARG;
icalcomponent *ical = icalcomponent_new(compkind);
if (!ical)
return NS_ERROR_OUT_OF_MEMORY; // XXX translate
@ -681,3 +799,27 @@ calICSService::CreateIcalComponent(PRInt32 kind, calIIcalComponent **comp)
NS_ADDREF(*comp);
return NS_OK;
}
NS_IMETHODIMP
calICSService::CreateIcalProperty(const nsACString &kind,
calIIcalProperty **prop)
{
icalproperty_kind propkind =
icalproperty_string_to_kind(PromiseFlatCString(kind).get());
if (propkind == ICAL_NO_PROPERTY)
return NS_ERROR_INVALID_ARG;
icalproperty *icalprop = icalproperty_new(propkind);
if (!icalprop)
return NS_ERROR_OUT_OF_MEMORY; // XXX translate
if (propkind == ICAL_X_PROPERTY)
icalproperty_set_x_name(icalprop, PromiseFlatCString(kind).get());
*prop = new calIcalProperty(icalprop, nsnull);
if (!*prop)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*prop);
return NS_OK;
}

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

@ -88,21 +88,20 @@ calItemBase.prototype = {
mGeneration: 0, get generation() { return this.mGeneration; }, set generation(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mGeneration = v; },
mCreationDate: null, get creationDate() { return this.mCreationDate; }, set creationDate(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mCreationDate = v; },
mLastModifiedTime: 0, get lastModifiedTime() { return this.mLastModifiedTime; }, set lastModifiedTime(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mLastModifiedTime = v; },
mParent: null, get parent() { return this.mParent; }, set parent(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mParent = v; },
mId: null, get id() { return this.mId; }, set id(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mId = 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; },
mIsPrivate: 0, get isPrivate() { return this.mIsPrivate; }, set isPrivate(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mIsPrivate = 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: 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; },
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; },
mAttachments: null, get attachments() { return this.mAttachments; }, set attachments(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mAttachments = v; },
mProperties: null, get properties() { return this.mProperties; }, set properties(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mProperties = v; },
mGeneration: 0, get generation() { return this.mGeneration; }, set generation(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mGeneration = v; dump("set " + "generation" + " to " + v + "\n");},
mCreationDate: null, get creationDate() { return this.mCreationDate; }, set creationDate(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mCreationDate = v; dump("set " + "creationDate" + " to " + v + "\n");},
mLastModifiedTime: null, get lastModifiedTime() { return this.mLastModifiedTime; }, set lastModifiedTime(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mLastModifiedTime = v; dump("set " + "lastModifiedTime" + " to " + v + "\n");},
mParent: null, get parent() { return this.mParent; }, set parent(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mParent = v; dump("set " + "parent" + " to " + v + "\n");},
mId: null, get id() { return this.mId; }, set id(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mId = v; dump("set " + "id" + " to " + v + "\n");},
mTitle: "", get title() { return this.mTitle; }, set title(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mTitle = v; dump("set " + "title" + " to " + v + "\n");},
mPriority: 0, get priority() { return this.mPriority; }, set priority(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mPriority = v; dump("set " + "priority" + " to " + v + "\n");},
mPrivacy: "PUBLIC", get isPrivate() { return this.mPrivacy; }, set isPrivate(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mPrivacy = v; dump("set " + "isPrivate" + " to " + v + "\n");},
mStatus: null, get status() { return this.mStatus; }, set status(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mStatus = v; dump("set " + "status" + " to " + v + "\n");},
mHasAlarm: false, get hasAlarm() { return this.mHasAlarm; }, set hasAlarm(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mHasAlarm = v; dump("set " + "hasAlarm" + " to " + v + "\n");},
mAlarmTime: null, get alarmTime() { return this.mAlarmTime; }, set alarmTime(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mAlarmTime = v; dump("set " + "alarmTime" + " to " + v + "\n");},
mRecurrenceInfo: null, get recurrenceInfo() { return this.mRecurrenceInfo; }, set recurrenceInfo(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mRecurrenceInfo = v; dump("set " + "recurrenceInfo" + " to " + v + "\n");},
mAttachments: null, get attachments() { return this.mAttachments; }, set attachments(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mAttachments = v; dump("set " + "attachments" + " to " + v + "\n");},
mProperties: null, get properties() { return this.mProperties; }, set properties(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.mProperties = v; dump("set " + "properties" + " to " + v + "\n");},
@ -163,15 +162,29 @@ calItemBase.prototype = {
get icalString() {
throw Components.results.NS_NOT_IMPLEMENTED;
},
set icalString() {
throw Components.results.NS_NOT_IMPLEMENTED;
},
itemBasePromotedProps: {
"CREATED": true,
"UID": true,
"LASTMODIFIED": true,
"SUMMARY": true,
"PRIORITY": true,
"METHOD": true,
"STATUS": true,
"CLASS": true,
"DTALARM": true,
"X-MOZILLA-GENERATION": true,
},
mapPropsFromICS: function(icalcomp, propmap) {
for (var i = 0; i < propmap.length; i++) {
var prop = propmap[i];
var val = icalcomp[prop.ics];
if (val != ICAL.INVALID_VALUE)
if (val != null && val != ICAL.INVALID_VALUE)
this[prop.cal] = val;
}
},
@ -194,17 +207,42 @@ calItemBase.prototype = {
{ cal: "mTitle", ics: "summary" },
{ cal: "mPriority", ics: "priority" },
{ cal: "mMethod", ics: "method" },
{ cal: "mStatus", ics: "status" }],
{ cal: "mStatus", ics: "status" },
{ cal: "mPrivacy", ics: "icalClass" }],
setItemBaseFromICS: function (icalcomp) {
if (this.mImmutable)
throw Components.results.NS_ERROR_FAILURE;
this.mapPropsFromICS(icalcomp, this.icsBasePropMap);
if (icalcomp.icalClass == ICAL.VISIBILITY_PUBLIC)
this.mPrivacy = icalcomp.icalClass;
if (icalcomp.icalClass == "PUBLIC")
this.mIsPrivate = false;
else
this.mIsPrivate = true;
for (var attprop = icalcomp.getFirstProperty("ATTENDEE");
attprop;
attprop = icalcomp.getNextProperty("ATTENDEE")) {
var att = new CalAttendee();
att.icalProperty = attprop;
this.addAttendee(att);
}
var gen = icalcomp.getFirstProperty("X-MOZILLA-GENERATION");
if (gen)
this.mGeneration = parseInt(gen.stringValue);
},
importUnpromotedProperties: function (icalcomp, promoted) {
for (var prop = icalcomp.getFirstProperty("ANY");
prop;
prop = icalcomp.getNextProperty("ANY")) {
if (!promoted[prop.propertyName]) {
this.setProperty(prop.propertyName, prop.stringValue);
}
}
},
get icalComponent() {
@ -213,11 +251,14 @@ calItemBase.prototype = {
fillIcalComponentFromBase: function (icalcomp) {
this.mapPropsToICS(icalcomp, this.icsBasePropMap);
if (this.mIsPrivate)
icalcomp.icalClass = ICAL.VISIBILITY_PRIVATE;
else
icalcomp.icalClass = ICAL.VISIBILITY_PUBLIC;
icalcomp.icalClass = this.mPrivacy;
for (var i = 0; i < this.mAttendees.length; i++)
icalcomp.addProperty(this.mAttendees[i].icalProperty);
if (this.mGeneration != 0) {
var genprop = icalProp("X-MOZILLA-GENERATION");
genprop.stringValue = String(this.mGeneration);
icalcomp.addProperty(genprop);
}
},
};
@ -273,8 +314,20 @@ const CalDateTime =
new Components.Constructor("@mozilla.org/calendar/datetime;1",
Components.interfaces.calIDateTime);
function icalFromString(str) {
const CalAttendee =
new Components.Constructor("@mozilla.org/calendar/attendee;1",
Components.interfaces.calIAttendee);
function icalFromString(str)
{
const icssvc = Components.classes["@mozilla.org/calendar/ics-service;1"].
getService(Components.interfaces.calIICSService);
return icssvc.parseICS(str);
}
function icalProp(kind)
{
const icssvc = Components.classes["@mozilla.org/calendar/ics-service;1"].
getService(Components.interfaces.calIICSService);
return icssvc.createIcalProperty(kind);
}

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

@ -128,18 +128,17 @@ calItemBase.prototype = {
#define MEMBER_ATTR(varname, initvalue, attrname) \
varname: initvalue, \
get attrname() { return this.varname; }, \
set attrname(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.varname = v; }
set attrname(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.varname = v; dump("set " + #attrname + " to " + v + "\n");}
MEMBER_ATTR(mGeneration, 0, generation),
MEMBER_ATTR(mCreationDate, null, creationDate),
MEMBER_ATTR(mLastModifiedTime, 0, lastModifiedTime),
MEMBER_ATTR(mLastModifiedTime, null, lastModifiedTime),
MEMBER_ATTR(mParent, null, parent),
MEMBER_ATTR(mId, null, id),
MEMBER_ATTR(mTitle, "", title),
MEMBER_ATTR(mPriority, 0, priority),
MEMBER_ATTR(mIsPrivate, 0, isPrivate),
MEMBER_ATTR(mMethod, ICAL.INVALID_VALUE, method),
MEMBER_ATTR(mStatus, ICAL.INVALID_VALUE, status),
MEMBER_ATTR(mPrivacy, "PUBLIC", isPrivate),
MEMBER_ATTR(mStatus, null, status),
MEMBER_ATTR(mHasAlarm, false, hasAlarm),
MEMBER_ATTR(mAlarmTime, null, alarmTime),
MEMBER_ATTR(mRecurrenceInfo, null, recurrenceInfo),
@ -205,10 +204,24 @@ calItemBase.prototype = {
get icalString() {
throw Components.results.NS_NOT_IMPLEMENTED;
},
set icalString() {
throw Components.results.NS_NOT_IMPLEMENTED;
},
itemBasePromotedProps: {
"CREATED": true,
"UID": true,
"LASTMODIFIED": true,
"SUMMARY": true,
"PRIORITY": true,
"METHOD": true,
"STATUS": true,
"CLASS": true,
"DTALARM": true,
"X-MOZILLA-GENERATION": true,
},
mapPropsFromICS: function(icalcomp, propmap) {
for (var i = 0; i < propmap.length; i++) {
var prop = propmap[i];
@ -236,17 +249,42 @@ calItemBase.prototype = {
{ cal: "mTitle", ics: "summary" },
{ cal: "mPriority", ics: "priority" },
{ cal: "mMethod", ics: "method" },
{ cal: "mStatus", ics: "status" }],
{ cal: "mStatus", ics: "status" },
{ cal: "mPrivacy", ics: "icalClass" }],
setItemBaseFromICS: function (icalcomp) {
if (this.mImmutable)
throw Components.results.NS_ERROR_FAILURE;
this.mapPropsFromICS(icalcomp, this.icsBasePropMap);
// XXX roundtrip
if (icalcomp.icalClass == ICAL.VISIBILITY_PUBLIC)
this.mPrivacy = icalcomp.icalClass;
if (icalcomp.icalClass == "PUBLIC")
this.mIsPrivate = false;
else
this.mIsPrivate = true;
for (var attprop = icalcomp.getFirstProperty("ATTENDEE");
attprop;
attprop = icalcomp.getNextProperty("ATTENDEE")) {
var att = new CalAttendee();
att.icalProperty = attprop;
this.addAttendee(att);
}
var gen = icalcomp.getFirstProperty("X-MOZILLA-GENERATION");
if (gen)
this.mGeneration = parseInt(gen.stringValue);
},
importUnpromotedProperties: function (icalcomp, promoted) {
for (var prop = icalcomp.getFirstProperty("ANY");
prop;
prop = icalcomp.getNextProperty("ANY")) {
if (!promoted[prop.propertyName]) {
// XXX keep parameters around, sigh
this.setProperty(prop.propertyName, prop.stringValue);
}
}
},
get icalComponent() {
@ -255,11 +293,14 @@ calItemBase.prototype = {
fillIcalComponentFromBase: function (icalcomp) {
this.mapPropsToICS(icalcomp, this.icsBasePropMap);
// XXX roundtrip
if (this.mIsPrivate)
icalcomp.icalClass = ICAL.VISIBILITY_PRIVATE;
else
icalcomp.icalClass = ICAL.VISIBILITY_PUBLIC;
icalcomp.icalClass = this.mPrivacy;
for (var i = 0; i < this.mAttendees.length; i++)
icalcomp.addProperty(this.mAttendees[i].icalProperty);
if (this.mGeneration != 0) {
var genprop = icalProp("X-MOZILLA-GENERATION");
genprop.stringValue = String(this.mGeneration);
icalcomp.addProperty(genprop);
}
},
};
@ -315,8 +356,20 @@ const CalDateTime =
new Components.Constructor("@mozilla.org/calendar/datetime;1",
Components.interfaces.calIDateTime);
function icalFromString(str) {
const CalAttendee =
new Components.Constructor("@mozilla.org/calendar/attendee;1",
Components.interfaces.calIAttendee);
function icalFromString(str)
{
const icssvc = Components.classes["@mozilla.org/calendar/ics-service;1"].
getService(Components.interfaces.calIICSService);
return icssvc.parseICS(str);
}
function icalProp(kind)
{
const icssvc = Components.classes["@mozilla.org/calendar/ics-service;1"].
getService(Components.interfaces.calIICSService);
return icssvc.createIcalProperty(kind);
}

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

@ -1,43 +0,0 @@
var C = Components;
var ICAL = C.interfaces.calIIcalComponent;
var eventClass = C.classes["@mozilla.org/calendar/event;1"];
var eventIID = C.interfaces.calIEvent;
dump("* Creating event.\n");
var e = eventClass.createInstance(eventIID);
var ics_xmas =
'BEGIN:VCALENDAR\nPRODID:-//ORACLE//NONSGML CSDK 9.0.5 - CalDAVServlet 9.0.5//EN\nVERSION:2.0\nBEGIN:VEVENT\nUID:20041119T052239Z-1000472-1-5c0746bb-Oracle\nORGANIZER;X-ORACLE-GUID=E9359406791C763EE0305794071A39A4;CN=Simon Vaillan\n court:mailto:simon.vaillancourt@oracle.com\nSEQUENCE:0\nDTSTAMP:20041124T010028Z\nCREATED:20041119T052239Z\nX-ORACLE-EVENTINSTANCE-GUID:I1+16778354+1+1+438153759\nX-ORACLE-EVENT-GUID:E1+16778354+1+438153759\nX-ORACLE-EVENTTYPE:DAY EVENT\nTRANSP:TRANSPARENT\nSUMMARY:Christmas\nSTATUS:CONFIRMED\nPRIORITY:0\nDTSTART;VALUE=DATE:20041125\nDTEND;VALUE=DATE:20041125\nCLASS:PUBLIC\nATTENDEE;X-ORACLE-GUID=E92F51FB4A48E91CE0305794071A149C;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=James Stevens;PARTSTAT=NEEDS-ACTION:mailto:james.stevens@o\n racle.com\nATTENDEE;X-ORACLE-GUID=E9359406791C763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=FALSE;CN=Simon Vaillancourt;PARTSTAT=ACCEPTED:mailto:simon.vaillan\n court@oracle.com\nATTENDEE;X-ORACLE-GUID=E9359406791D763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=Bernard Desruisseaux;PARTSTAT=NEEDS-ACTION:mailto:bernard.\n desruisseaux@oracle.com\nATTENDEE;X-ORACLE-GUID=E9359406791E763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=Mario Bonin;PARTSTAT=NEEDS-ACTION:mailto:mario.bonin@oracl\n e.com\nATTENDEE;X-ORACLE-GUID=E9359406791F763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=Jeremy Chone;PARTSTAT=NEEDS-ACTION:mailto:jeremy.chone@ora\n cle.com\nATTENDEE;X-ORACLE-PERSONAL-COMMENT-ISDIRTY=TRUE;X-ORACLE-GUID=E9359406792\n 0763EE0305794071A39A4;CUTYPE=INDIVIDUAL;RSVP=TRUE;CN=Mike Shaver;PARTSTA\n T=NEEDS-ACTION:mailto:mike.x.shaver@oracle.com\nATTENDEE;X-ORACLE-GUID=E93594067921763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=David Ball;PARTSTAT=NEEDS-ACTION:mailto:david.ball@oracle.\n com\nATTENDEE;X-ORACLE-GUID=E93594067922763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=Marten Haring;PARTSTAT=NEEDS-ACTION:mailto:marten.den.hari\n ng@oracle.com\nATTENDEE;X-ORACLE-GUID=E93594067923763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=Peter Egyed;PARTSTAT=NEEDS-ACTION:mailto:peter.egyed@oracl\n e.com\nATTENDEE;X-ORACLE-GUID=E93594067924763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=Francois Perrault;PARTSTAT=NEEDS-ACTION:mailto:francois.pe\n rrault@oracle.com\nATTENDEE;X-ORACLE-GUID=E93594067925763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=Vladimir Vukicevic;PARTSTAT=NEEDS-ACTION:mailto:vladimir.v\n ukicevic@oracle.com\nATTENDEE;X-ORACLE-GUID=E93594067926763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=Cyrus Daboo;PARTSTAT=NEEDS-ACTION:mailto:daboo@isamet.com\nATTENDEE;X-ORACLE-GUID=E93594067927763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=Lisa Dusseault;PARTSTAT=NEEDS-ACTION:mailto:lisa@osafounda\n tion.org\nATTENDEE;X-ORACLE-GUID=E93594067928763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=Dan Mosedale;PARTSTAT=NEEDS-ACTION:mailto:dan.mosedale@ora\n cle.com\nATTENDEE;X-ORACLE-GUID=E93594067929763EE0305794071A39A4;CUTYPE=INDIVIDUAL\n ;RSVP=TRUE;CN=Stuart Parmenter;PARTSTAT=NEEDS-ACTION:mailto:stuart.parme\n nter@oracle.com\nEND:VEVENT\nEND:VCALENDAR\n\n';
dump("* Setting ical string (xmas)\n");
e.icalString = ics_xmas;
dump("* Checking basic properties\n");
var expectedProps =
[["title", "Christmas"],
["id", "20041119T052239Z-1000472-1-5c0746bb-Oracle"],
["priority", 0],
["status", ICAL.STATUS_CONFIRMED],
["generation", 0],
["isAllDay", true]];
function checkProps(expectedProps, obj) {
for (var i = 0; i < expectedProps.length; i++) {
if (obj[expectedProps[i][0]] != expectedProps[i][1]) {
throw "FAILURE: expected " + expectedProps[i][0] + " to be " +
expectedProps[i][1] + " but got " + obj[expectedProps[i][0]];
}
}
}
checkProps(expectedProps, e);
dump("* Checking start date\n");
expectedProps =
[["month", 11],
["day", 25],
["year", 2004],
["isDate", true]];
checkProps(expectedProps, e.startDate);
dump("* Checking end date\n");
checkProps(expectedProps, e.endDate);
dump("PASSED!\n");

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

@ -371,7 +371,10 @@ function onOKCommand()
// calIItemBase properties
event.title = getFieldValue( "title-field" );
event.isPrivate = getFieldValue( "private-checkbox", "checked" );
if (getFieldValue("private-checkbox", "checked"))
event.privacy = "PRIVATE";
else
event.privacy = "PUBLIC";
if (getFieldValue( "alarm-type" ) != "" && getFieldValue( "alarm-type" ) != "none")
event.hasAlarm == 1
if (event.hasAlarm) {