From 2e31de3c35bb2619ae74d0b960757b93a8d8987d Mon Sep 17 00:00:00 2001 From: "mattwillis%gmail.com" Date: Sun, 3 Dec 2006 18:45:25 +0000 Subject: [PATCH] bug 357756 - Make CalDAV handle trailing parameters on the URL. Patch by Bruno Browning r=lilmatt, jminta --- calendar/providers/caldav/calDavCalendar.js | 31 +++++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/calendar/providers/caldav/calDavCalendar.js b/calendar/providers/caldav/calDavCalendar.js index 7842ea468caa..40784db0886a 100644 --- a/calendar/providers/caldav/calDavCalendar.js +++ b/calendar/providers/caldav/calDavCalendar.js @@ -64,6 +64,7 @@ function calDavCalendar() { this.wrappedJSObject = this; this.mObservers = Array(); this.unmappedProperties = []; + this.mUriParams = null; } // some shorthand @@ -165,6 +166,11 @@ calDavCalendar.prototype = { return false; }, + // mUriParams stores trailing ?parameters from the + // supplied calendar URI. Needed for (at least) Cosmo + // tickets + mUriParams: null, + // attribute nsIURI uri; mUri: null, get uri() { return this.mUri; }, @@ -172,11 +178,24 @@ calDavCalendar.prototype = { get mCalendarUri() { calUri = this.mUri.clone(); + var parts = calUri.spec.split('?'); + if (parts.length > 1) { + calUri.spec = parts.shift(); + this.mUriParams = '?' + parts.join('?'); + } if (calUri.spec.charAt(calUri.spec.length-1) != '/') { calUri.spec += "/"; } return calUri; }, + + mMakeUri: function caldav_makeUri(aInsertString) { + var spec = this.mCalendarUri.spec + aInsertString; + if (this.mUriParams) { + return spec + this.mUriParams; + } + return spec; + }, refresh: function() { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; @@ -231,7 +250,7 @@ calDavCalendar.prototype = { // XXX how are we REALLY supposed to figure this out? var locationPath = aItem.id + ".ics"; var itemUri = this.mCalendarUri.clone(); - itemUri.spec = itemUri.spec + locationPath; + itemUri.spec = this.mMakeUri(locationPath); LOG("itemUri.spec = " + itemUri.spec); var eventResource = new WebDavResource(itemUri); @@ -334,11 +353,11 @@ calDavCalendar.prototype = { var eventUri = this.mCalendarUri.clone(); try { - eventUri.spec = this.mCalendarUri.spec + aNewItem.getProperty("X-MOZ-LOCATIONPATH"); + eventUri.spec = this.mMakeUri(aNewItem.getProperty("X-MOZ-LOCATIONPATH")); LOG("using X-MOZ-LOCATIONPATH: " + eventUri.spec); } catch (ex) { // XXX how are we REALLY supposed to figure this out? - eventUri.spec = eventUri.spec + aNewItem.id + ".ics"; + eventUri.spec = this.mMakeUri(aNewItem.id + ".ics"); } if (aOldItem.parentItem.generation != aNewItem.generation) { @@ -450,12 +469,11 @@ calDavCalendar.prototype = { var eventUri = this.mCalendarUri.clone(); try { - eventUri.spec = this.mCalendarUri.spec + - aItem.getProperty("X-MOZ-LOCATIONPATH"); + eventUri.spec = this.mMakeUri(aItem.getProperty("X-MOZ-LOCATIONPATH")); LOG("using X-MOZ-LOCATIONPATH: " + eventUri.spec); } catch (ex) { // XXX how are we REALLY supposed to figure this out? - eventUri.spec = eventUri.spec + aItem.id + ".ics"; + eventUri.spec = this.mMakeUri(aItem.id + ".ics"); } var eventResource = new WebDavResource(eventUri); @@ -806,6 +824,7 @@ calDavCalendar.prototype = { // construct the resource we want to search against var calendarDirUri = this.mCalendarUri.clone(); + calendarDirUri.spec = this.mMakeUri(''); LOG("report uri = " + calendarDirUri.spec); var calendarDirResource = new WebDavResource(calendarDirUri);