Fix bug 473053 - Missing QI causes exclamation mark and DAV_REPORT_ERROR. r=mschroeder
authorPhilipp Kewisch <mozilla@kewis.ch>
Sun, 11 Jan 2009 13:10:58 +0100
changeset 1600 2d3e259d2c1254f9b10103ae94c996940587a01d
parent 1599 092c03b4b309daea028b6481778490a1198eddff
child 1601 6f833beb10d0377df3c8f804ee874bbc679d2c18
push id1281
push usermozilla@kewis.ch
push dateSun, 11 Jan 2009 12:13:11 +0000
treeherdercomm-central@2d3e259d2c12 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmschroeder
bugs473053
Fix bug 473053 - Missing QI causes exclamation mark and DAV_REPORT_ERROR. r=mschroeder
calendar/providers/caldav/calDavCalendar.js
--- a/calendar/providers/caldav/calDavCalendar.js
+++ b/calendar/providers/caldav/calDavCalendar.js
@@ -466,17 +466,17 @@ calDavCalendar.prototype = {
         var itemUri = this.makeUri(locationPath);
         LOG("CalDAV: itemUri.spec = " + itemUri.spec);
 
         var addListener = {};
         var thisCalendar = this;
         addListener.onStreamComplete =
             function onPutComplete(aLoader, aContext, aStatus, aResultLength,
                                    aResult) {
-            let request = aLoader.request;
+            let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
             let status;
             try {
                 status = request.responseStatus;
             } catch (ex) {
                 status = Components.interfaces.calIErrors.DAV_PUT_ERROR;
             }
             if (thisCalendar.verboseLogging()) {
                 let str = cal.convertByteArray(aResult, aResultLength);
@@ -568,17 +568,17 @@ calDavCalendar.prototype = {
 
         var modListener = {};
         modListener.onStreamComplete =
             function caldav_mod_onStreamComplete(aLoader, aContext, aStatus,
                                                  aResultLength, aResult) {
             // 200 = HTTP "OK"
             // 204 = HTTP "No Content"
             //
-            let request = aLoader.request;
+            let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
             let status;
             try {
                 status = request.responseStatus;
             } catch (ex) {
                 status = Components.interfaces.calIErrors.DAV_PUT_ERROR;
             }
 
             // We should not accept a 201 status here indefinitely: it indicates a server error
@@ -662,17 +662,17 @@ calDavCalendar.prototype = {
         }
 
         var delListener = {};
         var thisCalendar = this;
         var realListener = aListener; // need to access from callback
 
         delListener.onStreamComplete =
         function caldav_dDI_del_onStreamComplete(aLoader, aContext, aStatus, aResultLength, aResult) {
-            let request = aLoader.request;
+            let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
             let status;
             try {
                 status = request.responseStatus;
             } catch (ex) {
                 status = Components.interfaces.calIErrors.DAV_REMOVE_ERROR;
             }
 
             // 204 = HTTP "No content"
@@ -705,17 +705,17 @@ calDavCalendar.prototype = {
             } else {
                 LOG("CalDAV: Unexpected status deleting item: " + status);
                 thisCalendar.reportDavError(Components.interfaces.calIErrors.DAV_REMOVE_ERROR);
             }
         };
         var delListener2 = {};
         delListener2.onStreamComplete =
         function caldav_dDI_del2_onStreamComplete(aLoader, aContext, aStatus, aResultLength, aResult) {
-            let request = aLoader.request;
+            let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
             let status = request.responseStatus;
             if (status == 404) {
                 // someone else already deleted it
                 return;
             } else {
                 thisCalendar.promptOverwrite(CALDAV_DELETE_ITEM, aItem,
                                              realListener, null);
             }
@@ -839,17 +839,17 @@ calDavCalendar.prototype = {
                                               "text/xml; charset=utf-8",
                                               this);
         httpchannel.setRequestHeader("Depth", "0", false);
         httpchannel.requestMethod = "PROPFIND";
 
         var streamListener = {};
         streamListener.onStreamComplete =
             function safeRefresh_safeRefresh_onStreamComplete(aLoader, aContext, aStatus, aResultLength, aResult) {
-            let request = aLoader.request;
+            let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
             try {
                 LOG("CalDAV: Status " + request.responseStatus +
                     " checking ctag for calendar " + thisCalendar.name);
             } catch (ex) {
                 LOG("CalDAV: Error without status on checking ctag for calendar " +
                     thisCalendar.name);
             }
 
@@ -959,17 +959,17 @@ calDavCalendar.prototype = {
         var thisCalendar = this;
 
         var etagListener = {};
 
         etagListener.onStreamComplete =
             function getUpdatedItems_getetag_onStreamComplete(aLoader, aContext, aStatus,
                                                               aResultLength, aResult) {
             let responseStatus;
-            let request = aLoader.request;
+            let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
             try {
                 LOG("CalDAV: Status " + request.responseStatus +
                     " on getetag for calendar " + thisCalendar.name);
                 responseStatus = request.responseStatus;
             } catch (ex) {
                 LOG("CalDAV: Error without status on getetag for calendar " +
                     thisCalendar.name);
                 responseStatus = "none";
@@ -1133,17 +1133,17 @@ calDavCalendar.prototype = {
         var thisCalendar = this;
         var caldataListener = {};
         var C = new Namespace("C", "urn:ietf:params:xml:ns:caldav");
         var D = new Namespace("D", "DAV:");
 
         caldataListener.onStreamComplete =
             function getCalendarData_gCD_onStreamComplete(aLoader, aContext, aStatus,
                                                           aResultLength, aResult) {
-            let request = aLoader.request;
+            let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
             let responseStatus;
             try {
                 LOG("CalDAV: Status " + request.responseStatus +
                     " fetching calendar-data for calendar " + thisCalendar.name);
                 responseStatus = request.responseStatus;
             } catch (ex) {
                 LOG("CalDAV: Error without status fetching calendar-data for calendar " +
                     thisCalendar.name);
@@ -1339,17 +1339,17 @@ calDavCalendar.prototype = {
                                               this);
         httpchannel.setRequestHeader("Depth", "0", false);
         httpchannel.requestMethod = "PROPFIND";
 
         var streamListener = {};
 
         streamListener.onStreamComplete =
             function checkDavResourceType_oSC(aLoader, aContext, aStatus, aResultLength, aResult) {
-            let request = aLoader.request;
+            let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
             try {
                 LOG("CalDAV: Status " + request.responseStatus +
                     " on initial PROPFIND for calendar " + thisCalendar.name);
             } catch (ex) {
                 LOG("CalDAV: Error without status on initial PROPFIND for calendar " +
                     thisCalendar.name);
             }
             var wwwauth;
@@ -1466,17 +1466,17 @@ calDavCalendar.prototype = {
         if (this.verboseLogging()) {
             LOG("CalDAV: send: OPTIONS");
         }
 
         var streamListener = {};
         streamListener.onStreamComplete =
             function checkServerCaps_oSC(aLoader, aContext, aStatus,
                                          aResultLength, aResult) {
-            let request = aLoader.request;
+            let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
             let dav = null;
             try {
                 dav = request.getResponseHeader("DAV");
                 if (thisCalendar.verboseLogging()) {
                     LOG("CalDAV: DAV header: " + dav);
                 }
             } catch (ex) {
                 LOG("CalDAV: Error getting DAV header, status " + request.responseStatus +
@@ -1559,17 +1559,17 @@ calDavCalendar.prototype = {
 
         httpchannel.setRequestHeader("Depth", "0", false);
         httpchannel.requestMethod = "PROPFIND";
 
         var streamListener = {};
         streamListener.onStreamComplete =
             function findInOutboxes_oSC(aLoader, aContext, aStatus,
                                          aResultLength, aResult) {
-            let request = aLoader.request;
+            let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
             if (request.responseStatus != 207) {
                 LOG("CalDAV: Unexpected status " + request.responseStatus +
                     " while querying principal namespace");
                 thisCalendar.completeCheckServerInfo(aChangeLogListener,
                                                      Components.results.NS_ERROR_FAILURE);
                 return;
             }
 
@@ -1688,39 +1688,41 @@ calDavCalendar.prototype = {
             // default.
             httpchannel.setRequestHeader("Depth", "0", false);
         }
 
         var streamListener = {};
         streamListener.onStreamComplete =
             function caldav_cPNS_oSC(aLoader, aContext, aStatus,
                                          aResultLength, aResult) {
+            let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
             let str = cal.convertByteArray(aResult, aResultLength);
             if (!str) {
                 LOG("CalDAV: Failed to report principals namespace");
                 doesntSupportScheduling();
                 return;
             } else if (thisCalendar.verboseLogging()) {
                 LOG("CalDAV: recv: " + str);
             }
 
-            if (aLoader.request.responseStatus != 207) {
+            if (request.responseStatus != 207) {
                 LOG("CalDAV: Bad response to in/outbox query, status " +
-                    aLoader.request.responseStatus);
+                    request.responseStatus);
                 doesntSupportScheduling();
                 return;
             }
 
             let multistatus = cal.safeNewXML(str);
             let multistatusLength = multistatus.*::response.length();
 
             for each (let response in multistatus.*::response) {
                 let responseCHS = null;
                 try {
-                    responseCHS = response..*::["calendar-home-set"]..*::href[0].toString().replace(/([^/])$/, "$1/");
+                    responseCHS = response..*::["calendar-home-set"]..*::href[0]
+                                          .toString().replace(/([^\/])$/, "$1/");
                 } catch (ex) {}
 
                 if (multistatusLength > 1 &&
                     (responseCHS != thisCalendar.mCalHomeSet.path &&
                      responseCHS != thisCalendar.mCalHomeSet.spec)) {
                     // If there are multiple home sets, then we need to match
                     // the home url. If there is only one, we can assume its the
                     // correct one, even if the home set doesn't quite match.
@@ -1914,17 +1916,17 @@ calDavCalendar.prototype = {
         httpchannel.setRequestHeader("Originator", organizer, false);
         httpchannel.setRequestHeader("Recipient", mailto_aCalId, false);
 
         var streamListener = {};
 
         streamListener.onStreamComplete =
             function caldav_GFBI_oSC(aLoader, aContext, aStatus,
                                          aResultLength, aResult) {
-            let request = aLoader.request;
+            let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
             let str = cal.convertByteArray(aResult, aResultLength);
             if (!str) {
                 LOG("CalDAV: Failed to parse freebusy response");
             } else if (thisCalendar.verboseLogging()) {
                 LOG("CalDAV: recv: " + str);
             }
 
             if (request.responseStatus == 200) {
@@ -2157,17 +2159,17 @@ calDavCalendar.prototype = {
             for each (var recipient in aRecipients) {
                 httpchannel.setRequestHeader("Recipient", recipient.id, true);
             }
 
             var thisCalendar = this;
             var streamListener = {
                 onStreamComplete: function caldav_sendItems_oSC(aLoader, aContext, aStatus,
                                                                 aResultLength, aResult) {
-                    let request = aLoader.request;
+                    let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
                     let status;
                     try {
                         status = request.responseStatus;
                     } catch (ex) {
                         status = Components.interfaces.calIErrors.DAV_POST_ERROR;
                         LOG("CalDAV: no response status when sending iTIP.");
                     }