A bouquet garni of fragrant fixes:

- set prodid and version in generated ICS
- don't set empty-valued properties on the icalcomp; it makes some
  parsers sad
- save the listener's "outer this" so that we find it to call the notification
  methods on when adding an item is well and truly done.

Can now create events on a CalDAV server.
This commit is contained in:
shaver%mozilla.org 2004-12-10 11:00:27 +00:00
Родитель 2ca7a4da92
Коммит 3ace56c44c
5 изменённых файлов: 13 добавлений и 4 удалений

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

@ -85,6 +85,8 @@ calEvent.prototype = {
classes["@mozilla.org/calendar/ics-service;1"].
getService(Components.interfaces.calIICSService);
var calcomp = icssvc.createIcalComponent(ICAL.VCALENDAR_COMPONENT);
calcomp.prodid = "-//Mozilla Calendar//NONSGML Sunbird//EN";
calcomp.version = "2.0";
calcomp.addSubcomponent(this.icalComponent);
return calcomp.serializeToICS();
},

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

@ -130,6 +130,8 @@ calEvent.prototype = {
classes["@mozilla.org/calendar/ics-service;1"].
getService(Components.interfaces.calIICSService);
var calcomp = icssvc.createIcalComponent(ICAL.VCALENDAR_COMPONENT);
calcomp.prodid = "-//Mozilla Calendar//NONSGML Sunbird//EN";
calcomp.version = "2.0";
calcomp.addSubcomponent(this.icalComponent);
return calcomp.serializeToICS();
},

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

@ -177,7 +177,9 @@ calItemBase.prototype = {
mapPropsToICS: function(icalcomp, propmap) {
for (var i = 0; i < propmap.length; i++) {
var prop = propmap[i];
icalcomp[prop.ics] = this[prop.cal];
var val = this[prop.cal];
if (prop.force || val)
icalcomp[prop.ics] = this[prop.cal];
}
},

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

@ -219,7 +219,9 @@ calItemBase.prototype = {
mapPropsToICS: function(icalcomp, propmap) {
for (var i = 0; i < propmap.length; i++) {
var prop = propmap[i];
icalcomp[prop.ics] = this[prop.cal];
var val = this[prop.cal];
if (prop.force || val)
icalcomp[prop.ics] = this[prop.cal];
}
},

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

@ -145,6 +145,7 @@ calDavCalendar.prototype = {
var eventResource = new WebDavResource(eventUri);
var listener = new WebDavListener();
var savedthis = this;
listener.onOperationComplete = function(aStatusCode, aResource,
aOperation, aClosure) {
@ -156,7 +157,7 @@ calDavCalendar.prototype = {
// notify observers
// XXX should be called after listener?
this.observeAddItem(aItem);
savedthis.observeAddItem(aItem);
} else {
dump("Error adding item: " + aStatusCode + "\n");
@ -168,7 +169,7 @@ calDavCalendar.prototype = {
// notify the listener
if (aListener)
aListener.onOperationComplete (this,
aListener.onOperationComplete (savedthis,
retVal,
aListener.ADD,
aItem.id,