Fix bug 679669 - Update calendar for nsIUnicharStreamLoader changes. r=mmecca
authorPhilipp Kewisch <mozilla@kewis.ch>
Wed, 17 Aug 2011 14:02:00 +0200
changeset 8784 71929579880ee2319d98b9351c77bcbe64ef4da9
parent 8783 7cd890eced944dbe3d88dc1c3352bf8f3888ceb7
child 8785 8cd8084c08e99aab5bfba38e22d168e63beb3ad4
push id158
push userbugzilla@standard8.plus.com
push dateTue, 27 Sep 2011 19:18:14 +0000
treeherdercomm-beta@e47b99c61e4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmmecca
bugs679669
Fix bug 679669 - Update calendar for nsIUnicharStreamLoader changes. r=mmecca
calendar/base/content/calendar-dnd-listener.js
calendar/providers/wcap/calWcapRequest.js
--- a/calendar/base/content/calendar-dnd-listener.js
+++ b/calendar/base/content/calendar-dnd-listener.js
@@ -325,28 +325,21 @@ calDNDBaseObserver.prototype = {
                             charset = channel.contentCharset;
                         }
                         if (!charset || charset.length == 0) {
                             charset = "UTF-8";
                         }
                         return charset;
                     },
 
-                    onStreamComplete: function(loader, context, status, unicharData) {
-                        if (unicharData) {
-                            var str = "";
-                            var str_ = {};
-                            while (unicharData.readString(-1, str_)) {
-                                str += str_.value;
-                            }
-                            var parser = Components.classes["@mozilla.org/calendar/ics-parser;1"]
-                                         .createInstance(Components.interfaces.calIIcsParser);
-                            parser.parseString(str);
-                            self.onDropItems(parser.getItems({}).concat(parser.getParentlessItems({})));
-                        }
+                    onStreamComplete: function(loader, context, status, unicharString) {
+                        var parser = Components.classes["@mozilla.org/calendar/ics-parser;1"]
+                                     .createInstance(Components.interfaces.calIIcsParser);
+                        parser.parseString(unicharString);
+                        self.onDropItems(parser.getItems({}).concat(parser.getParentlessItems({})));
                     }
                 };
 
                 try {
                     loader.init(listener, Components.interfaces.nsIUnicharStreamLoader.DEFAULT_SEGMENT_SIZE);
                     channel.asyncOpen(loader, null);
                 } catch(e) {
                     Components.utils.reportError(e)
--- a/calendar/providers/wcap/calWcapRequest.js
+++ b/calendar/providers/wcap/calWcapRequest.js
@@ -306,55 +306,43 @@ calWcapNetworkRequest.prototype = {
     },
 
     /**
      * @see nsIUnicharStreamLoaderObserver
      */
     onStreamComplete: function calWcapNetworkRequest_onStreamComplete(aLoader,
                                                                       aContext,
                                                                       aStatus,
-                                                                      /* nsIUnicharInputStream */ unicharData) {
+                                                                      unicharData) {
         this.m_loader = null;
 
         if (LOG_LEVEL > 0 && this.m_bLogging) {
             log("status: " + errorToString(aStatus), this);
         }
         if (aStatus != Components.results.NS_OK) {
             this.execRespFunc(aStatus);
             return;
         }
 
-        var result = "";
-        try {
-            if (unicharData) {
-                var str_ = {};
-                while (unicharData.readString(-1, str_)) {
-                    result += str_.value;
-                }
-            }
-            if (LOG_LEVEL > 2 && this.m_bLogging) {
-                log("contentCharset = " + aLoader.charset + "\nrequest result:\n" + result, this);
-            }
-        } catch (exc) {
-            this.execRespFunc(exc);
-            return;
+        if (LOG_LEVEL > 2 && this.m_bLogging) {
+            log("contentCharset = " + aLoader.charset + "\nrequest result:\n" + unicharData, this);
         }
 
         var httpChannel = aLoader.channel.QueryInterface(Components.interfaces.nsIHttpChannel);
         switch (httpChannel.responseStatus / 100) {
             case 2: /* 2xx codes */
                 // Everything worked out, we are done
-                this.execRespFunc(aStatus, result);
+                this.execRespFunc(aStatus, unicharData);
                 break;
             default: {
                 // Something else went wrong
                 var error = ("A request Error Occurred. Status Code: " +
                              httpChannel.responseStatus + " " +
                              httpChannel.responseStatusText + " Body: " +
-                             result);
+                             unicharData);
                 this.execRespFunc(Components.Exception(error, NS_BINDING_FAILED));
                 break;
             }
         }
     },
 
     toString: function calWcapNetworkRequest_toString() {
         var ret = ("calWcapNetworkRequest id=" + this.id +