Bug 1440587 - Move calProviderUtils to the cal.provider namespace - automatic provider changes. r=MakeMyDay
authorPhilipp Kewisch <mozilla@kewis.ch>
Thu, 22 Feb 2018 22:09:13 +0100
changeset 30554 7f803e1812568168252d97d586ea3e66bab610dc
parent 30553 96aefde64d3b8eb4dc3843cf4c5c3747f00c02eb
child 30555 495cc6dd8eaecd9a47cdac56fd4af1f70b5ea08d
push id2172
push usermozilla@kewis.ch
push dateSun, 15 Apr 2018 05:33:14 +0000
treeherdercomm-beta@33a67b0129b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMakeMyDay
bugs1440587
Bug 1440587 - Move calProviderUtils to the cal.provider namespace - automatic provider changes. r=MakeMyDay MozReview-Commit-ID: Jt0omp68ReS
calendar/base/modules/calUtilsCompat.jsm
calendar/base/src/calCachedCalendar.js
calendar/base/src/calCalendarManager.js
calendar/base/src/calDefaultACLManager.js
calendar/providers/caldav/calDavCalendar.js
calendar/providers/gdata/components/calGoogleCalendar.js
calendar/providers/gdata/modules/gdataRequest.jsm
calendar/providers/gdata/modules/gdataSession.jsm
calendar/providers/gdata/modules/gdataUtils.jsm
calendar/providers/ics/calICSCalendar.js
calendar/providers/memory/calMemoryCalendar.js
calendar/providers/storage/calStorageCalendar.js
calendar/providers/storage/calStorageUpgrade.jsm
calendar/providers/wcap/calWcapCalendar.js
calendar/providers/wcap/calWcapRequest.js
calendar/providers/wcap/calWcapSession.js
calendar/test/unit/test_freebusy_service.js
calendar/test/unit/test_gdata_provider.js
--- a/calendar/base/modules/calUtilsCompat.jsm
+++ b/calendar/base/modules/calUtilsCompat.jsm
@@ -173,33 +173,33 @@ function injectCalUtilsCompat(global) {
                            " and the parameter order has changed",
                            "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                            Components.stack.caller);
         return cal.l10n.getAnyString(aComponent, aBundleName, aStringName, aParams);
     };
 
     global.ProviderBase = class extends global.provider.BaseClass {
         initProviderBase() {
-            Deprecated.warning("calProviderUtils' cal.ProviderBase() has changed to cal.provider.BaseClass()",
+            Deprecated.warning("calProviderUtils' cal.provider.BaseClass() has changed to cal.provider.BaseClass()",
                                "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                                Components.stack.caller);
             super.initProviderBase();
         }
     };
 
     global.BadCertHandler = class extends global.provider.BadCertHandler {
         constructor() {
-            Deprecated.warning("calProviderUtils' cal.BadCertHandler() has changed to cal.provider.BadCertHandler()",
+            Deprecated.warning("calProviderUtils' cal.provider.BadCertHandler() has changed to cal.provider.BadCertHandler()",
                                "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                                Components.stack.caller);
             super();
         }
     };
 
     global.FreeBusyInterval = class extends global.provider.FreeBusyInterval {
         constructor() {
-            Deprecated.warning("calProviderUtils' cal.FreeBusyInterval() has changed to cal.provider.FreeBusyInterval()",
+            Deprecated.warning("calProviderUtils' cal.provider.FreeBusyInterval() has changed to cal.provider.FreeBusyInterval()",
                                "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                                Components.stack.caller);
             super();
         }
     };
 }
--- a/calendar/base/src/calCachedCalendar.js
+++ b/calendar/base/src/calCachedCalendar.js
@@ -196,17 +196,17 @@ calCachedCalendar.prototype = {
                     case "memory": {
                         if (this.supportsChangeLog) {
                             // start with full sync:
                             this.mUncachedCalendar.resetLog();
                         }
                         break;
                     }
                     case "storage": {
-                        let file = cal.getCalendarDirectory();
+                        let file = cal.provider.getCalendarDirectory();
                         file.append("cache.sqlite");
                         cachedCalendar.uri = Services.io.newFileURI(file);
                         cachedCalendar.id = this.id;
                         break;
                     }
                     default: {
                         throw new Error("unsupported cache calendar type: " + calType);
                     }
@@ -402,17 +402,17 @@ calCachedCalendar.prototype = {
                                         self.promptOverwrite("modify", item, null, null);
                                     } else {
                                         // Our item is newer, just modify the item
                                         self.modifyOfflineItem(item, null, null);
                                     }
                                 } else {
                                     // The item has been deleted from the server, ask if it should be added again
                                     cal.WARN("[calCachedCalendar] Item '" + item.title + "' has been deleted from the server");
-                                    if (cal.promptOverwrite("modify", item, null, null)) {
+                                    if (cal.provider.promptOverwrite("modify", item, null, null)) {
                                         self.adoptOfflineItem(item.clone(), null);
                                     }
                                 }
                                 break;
                             case cICL.OFFLINE_FLAG_DELETED_RECORD:
                                 if (item.id in completeListener.modifiedTimes) {
                                     // The item seems to exist on the server...
                                     if (item.lastModifiedTime.compare(completeListener.modifiedTimes[item.id]) < 0) {
@@ -453,17 +453,17 @@ calCachedCalendar.prototype = {
         } else {
             // Going online (start replaying changes to the remote calendar)
             this.refresh();
         }
     },
 
     // aOldItem is already in the cache
     promptOverwrite: function(aMethod, aItem, aListener, aOldItem) {
-        let overwrite = cal.promptOverwrite(aMethod, aItem, aListener, aOldItem);
+        let overwrite = cal.provider.promptOverwrite(aMethod, aItem, aListener, aOldItem);
         if (overwrite) {
             if (aMethod == "modify") {
                 this.modifyOfflineItem(aItem, aOldItem, aListener);
             } else {
                 this.deleteOfflineItem(aItem, aListener);
             }
         }
     },
--- a/calendar/base/src/calCalendarManager.js
+++ b/calendar/base/src/calCalendarManager.js
@@ -1025,17 +1025,17 @@ calMgrCalendarObserver.prototype = {
     }
 };
 
 function calDummyCalendar(type) {
     this.initProviderBase();
     this.type = type;
 }
 calDummyCalendar.prototype = {
-    __proto__: cal.ProviderBase.prototype,
+    __proto__: cal.provider.BaseClass.prototype,
 
     getProperty: function(aName) {
         switch (aName) {
             case "force-disabled":
                 return true;
             default:
                 return this.__proto__.__proto__.getProperty.apply(this, arguments);
         }
--- a/calendar/base/src/calDefaultACLManager.js
+++ b/calendar/base/src/calDefaultACLManager.js
@@ -81,17 +81,17 @@ calDefaultCalendarACLEntry.prototype = {
 
     getUserAddresses: function(aCount) {
         let identities = this.getUserIdentities(aCount);
         let addresses = identities.map(id => id.email);
         return addresses;
     },
 
     getUserIdentities: function(aCount) {
-        let identity = cal.getEmailIdentityOfCalendar(this.mCalendar);
+        let identity = cal.provider.getEmailIdentityOfCalendar(this.mCalendar);
         if (identity) {
             aCount.value = 1;
             return [identity];
         } else {
             return this._getIdentities(aCount);
         }
     },
     getOwnerIdentities: function(aCount) {
--- a/calendar/providers/caldav/calDavCalendar.js
+++ b/calendar/providers/caldav/calDavCalendar.js
@@ -99,17 +99,17 @@ var calDavCalendarInterfaces = [
     Components.interfaces.nsIChannelEventSink,
     Components.interfaces.calIItipTransport,
     Components.interfaces.calISchedulingSupport,
     Components.interfaces.calICalendar,
     Components.interfaces.calIChangeLog,
     calICalDavCalendar,
 ];
 calDavCalendar.prototype = {
-    __proto__: cal.ProviderBase.prototype,
+    __proto__: cal.provider.BaseClass.prototype,
     classID: calDavCalendarClassID,
     QueryInterface: XPCOMUtils.generateQI(calDavCalendarInterfaces),
     classInfo: XPCOMUtils.generateCI({
         classID: calDavCalendarClassID,
         contractID: "@mozilla.org/calendar/calendar;1?type=caldav",
         classDescription: "Calendar CalDAV back-end",
         interfaces: calDavCalendarInterfaces,
     }),
@@ -361,24 +361,24 @@ calDavCalendar.prototype = {
                 self.sendHttpRequest(...origArgs);
             } else {
                 let nextArguments = Array.from(arguments).slice(1);
                 nextMethod(...nextArguments);
             }
         }
 
         function authSuccess() {
-            let channel = cal.prepHttpChannel(aUri, aUploadData, aContentType, self, aExisting);
+            let channel = cal.provider.prepHttpChannel(aUri, aUploadData, aContentType, self, aExisting);
             if (usesGoogleOAuth) {
                 let hdr = "Bearer " + self.oauth.accessToken;
                 channel.setRequestHeader("Authorization", hdr, false);
             }
             let listener = aSetupChannelFunc(channel);
             if (aUseStreamLoader) {
-                let loader = cal.createStreamLoader();
+                let loader = cal.provider.createStreamLoader();
                 listener.onStreamComplete = oauthCheck.bind(null, listener.onStreamComplete.bind(listener));
                 loader.init(listener);
                 listener = loader;
             } else {
                 listener.onStartRequest = oauthCheck.bind(null, listener.onStartRequest.bind(listener));
             }
 
             self.mLastRedirectStatus = null;
@@ -567,30 +567,30 @@ calDavCalendar.prototype = {
                     return this.calendarUserAddress;
                 } // else use configured email identity
                 break;
             case "organizerCN":
                 return null; // xxx todo
             case "itip.transport":
                 if (this.hasAutoScheduling || this.hasScheduling) {
                     return this.QueryInterface(Components.interfaces.calIItipTransport);
-                } // else use outbound email-based iTIP (from cal.ProviderBase)
+                } // else use outbound email-based iTIP (from cal.provider.BaseClass)
                 break;
             case "capabilities.tasks.supported":
                 return this.supportedItemTypes.includes("VTODO");
             case "capabilities.events.supported":
                 return this.supportedItemTypes.includes("VEVENT");
             case "capabilities.autoschedule.supported":
                 return this.hasAutoScheduling;
         }
         return this.__proto__.__proto__.getProperty.apply(this, arguments);
     },
 
     promptOverwrite: function(aMethod, aItem, aListener, aOldItem) {
-        let overwrite = cal.promptOverwrite(aMethod, aItem, aListener, aOldItem);
+        let overwrite = cal.provider.promptOverwrite(aMethod, aItem, aListener, aOldItem);
         if (overwrite) {
             if (aMethod == CALDAV_MODIFY_ITEM) {
                 this.doModifyItem(aItem, aOldItem, aListener, true);
             } else {
                 this.doDeleteItem(aItem, aListener, true, false, null);
             }
         } else {
             this.getUpdatedItem(aItem, aListener);
@@ -665,17 +665,17 @@ calDavCalendar.prototype = {
                 let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
                 let listenerStatus = Components.results.NS_OK;
                 let listenerDetail = parentItem;
                 let responseStatus;
                 try {
                     responseStatus = request.responseStatus;
 
                     if (self.verboseLogging()) {
-                        let str = cal.convertByteArray(aResult, aResultLength);
+                        let str = cal.provider.convertByteArray(aResult, aResultLength);
                         cal.LOG("CalDAV: recv: " + (str || ""));
                     }
                 } catch (ex) {
                     listenerStatus = ex.result;
                     listenerDetail = "Request Failed: " + ex.message;
                     cal.LOG("CalDAV: Request error during add: " + ex);
                 }
 
@@ -784,17 +784,17 @@ calDavCalendar.prototype = {
                 let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
                 let listenerStatus = Components.results.NS_OK;
                 let listenerDetail = aNewItem;
                 let responseStatus;
                 try {
                     responseStatus = request.responseStatus;
 
                     if (self.verboseLogging()) {
-                        let str = cal.convertByteArray(aResult, aResultLength);
+                        let str = cal.provider.convertByteArray(aResult, aResultLength);
                         cal.LOG("CalDAV: recv: " + (str || ""));
                     }
                 } catch (ex) {
                     listenerStatus = ex.result;
                     listenerDetail = "Request Failed: " + ex.message;
                     cal.LOG("CalDAV: Request error during add: " + ex);
                 }
 
@@ -912,17 +912,17 @@ calDavCalendar.prototype = {
                 let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
                 let listenerStatus = Components.results.NS_OK;
                 let listenerDetail = aItem;
                 let responseStatus;
                 try {
                     responseStatus = request.responseStatus;
 
                     if (self.verboseLogging()) {
-                        let str = cal.convertByteArray(aResult, aResultLength);
+                        let str = cal.provider.convertByteArray(aResult, aResultLength);
                         cal.LOG("CalDAV: recv: " + (str || ""));
                     }
                 } catch (ex) {
                     listenerStatus = ex.result;
                     listenerDetail = "Request Failed: " + ex.message;
                     cal.LOG("CalDAV: Request error during delete: " + ex);
                 }
 
@@ -982,17 +982,17 @@ calDavCalendar.prototype = {
                 let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
                 let listenerStatus = Components.results.NS_OK;
                 let listenerDetail = aItem;
                 let responseStatus;
                 try {
                     responseStatus = request.responseStatus;
 
                     if (self.verboseLogging()) {
-                        let str = cal.convertByteArray(aResult, aResultLength);
+                        let str = cal.provider.convertByteArray(aResult, aResultLength);
                         cal.LOG("CalDAV: recv: " + (str || ""));
                     }
                 } catch (ex) {
                     listenerStatus = ex.result;
                     listenerDetail = "Request Failed: " + ex.message;
                     cal.LOG("CalDAV: Request error during add: " + ex);
                 }
 
@@ -1352,17 +1352,17 @@ calDavCalendar.prototype = {
 
         this.ensureTargetCalendar();
 
         if (this.mAuthScheme == "Digest") {
             // the auth could have timed out and be in need of renegotiation
             // we can't risk several calendars doing this simultaneously so
             // we'll force the renegotiation in a sync query, using OPTIONS to keep
             // it quick
-            let headchannel = cal.prepHttpChannel(this.makeUri(), null, null, this);
+            let headchannel = cal.provider.prepHttpChannel(this.makeUri(), null, null, this);
             headchannel.requestMethod = "OPTIONS";
             headchannel.open();
             headchannel.QueryInterface(Components.interfaces.nsIHttpChannel);
             try {
                 if (headchannel.responseStatus != 200) {
                     throw "OPTIONS returned unexpected status code: " + headchannel.responseStatus;
                 }
             } catch (e) {
@@ -1413,17 +1413,17 @@ calDavCalendar.prototype = {
                 return;
             } else if (request.responseStatus == 207 && self.mDisabled) {
                 // Looks like the calendar is there again, check its resource
                 // type first.
                 self.setupAuthentication(aChangeLogListener);
                 return;
             }
 
-            let str = cal.convertByteArray(aResult, aResultLength);
+            let str = cal.provider.convertByteArray(aResult, aResultLength);
             if (!str) {
                 cal.LOG("CalDAV: Failed to get ctag from server for calendar " +
                         self.name);
             } else if (self.verboseLogging()) {
                 cal.LOG("CalDAV: recv: " + str);
             }
 
             let multistatus;
@@ -1546,17 +1546,17 @@ calDavCalendar.prototype = {
             }
         }, false);
     },
 
     /**
      * @see nsIInterfaceRequestor
      * @see calProviderUtils.jsm
      */
-    getInterface: cal.InterfaceRequestor_getInterface,
+    getInterface: cal.provider.InterfaceRequestor_getInterface,
 
     //
     // Helper functions
     //
 
     /**
      * Sets up any needed prerequisites regarding authentication. This is the
      * beginning of a chain of asynchronous calls. This function will, when
@@ -1789,17 +1789,17 @@ calDavCalendar.prototype = {
             // we only really need the authrealm for Digest auth
             // since only Digest is going to time out on us
             if (self.mAuthScheme == "Digest") {
                 let realmChop = wwwauth.split("realm=\"")[1];
                 self.mAuthRealm = realmChop.split("\", ")[0];
                 cal.LOG("CalDAV: realm " + self.mAuthRealm);
             }
 
-            let str = cal.convertByteArray(aResult, aResultLength);
+            let str = cal.provider.convertByteArray(aResult, aResultLength);
             if (!str || request.responseStatus == 404) {
                 // No response, or the calendar no longer exists.
                 cal.LOG("CalDAV: Failed to determine resource type for" +
                         self.name);
                 self.completeCheckServerInfo(aChangeLogListener,
                                              Components.interfaces.calIErrors.DAV_NOT_DAV);
                 return;
             } else if (self.verboseLogging()) {
@@ -1958,17 +1958,17 @@ calDavCalendar.prototype = {
             try {
                 dav = request.getResponseHeader("DAV");
                 if (self.verboseLogging()) {
                     cal.LOG("CalDAV: DAV header: " + dav);
                 }
             } catch (ex) {
                 cal.LOG("CalDAV: Error getting DAV header for " + self.name +
                         ", status " + request.responseStatus +
-                        ", data: " + cal.convertByteArray(aResult, aResultLength));
+                        ", data: " + cal.provider.convertByteArray(aResult, aResultLength));
             }
             // Google does not yet support OPTIONS but does support scheduling
             // so we'll spoof the DAV header until Google gets fixed
             if (self.calendarUri.host == "www.google.com") {
                 dav = "calendar-schedule";
                 // Google also reports an inbox URL distinct from the calendar
                 // URL but a) doesn't use it and b) 405s on etag queries to it
                 self.mShouldPollInbox = false;
@@ -2054,17 +2054,17 @@ calDavCalendar.prototype = {
             if (request.responseStatus != 207) {
                 cal.LOG("CalDAV: Unexpected status " + request.responseStatus +
                     " while querying principal namespace for " + self.name);
                 self.completeCheckServerInfo(aChangeLogListener,
                                              Components.results.NS_ERROR_FAILURE);
                 return;
             }
 
-            let str = cal.convertByteArray(aResult, aResultLength);
+            let str = cal.provider.convertByteArray(aResult, aResultLength);
             if (!str) {
                 cal.LOG("CalDAV: Failed to propstat principal namespace for " + self.name);
                 self.completeCheckServerInfo(aChangeLogListener,
                                              Components.results.NS_ERROR_FAILURE);
                 return;
             } else if (self.verboseLogging()) {
                 cal.LOG("CalDAV: recv: " + str);
             }
@@ -2171,17 +2171,17 @@ calDavCalendar.prototype = {
 
         if (this.verboseLogging()) {
             cal.LOG("CalDAV: send: " + queryMethod + " " + requestUri.spec + "\n" + queryXml);
         }
 
         let streamListener = {};
         streamListener.onStreamComplete = function(aLoader, aContext, aStatus, aResultLength, aResult) {
             let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
-            let str = cal.convertByteArray(aResult, aResultLength);
+            let str = cal.provider.convertByteArray(aResult, aResultLength);
             if (!str) {
                 cal.LOG("CalDAV: Failed to report principals namespace for " + self.name);
                 doesntSupportScheduling();
                 return;
             } else if (self.verboseLogging()) {
                 cal.LOG("CalDAV: recv: " + str);
             }
 
@@ -2441,17 +2441,17 @@ calDavCalendar.prototype = {
                     ",Recipient=" + mailto_aCalId + "): " + fbQuery);
         }
 
         let streamListener = {};
 
         streamListener.onStreamComplete = function(aLoader, aContext, aStatus,
                                                    aResultLength, aResult) {
             let request = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
-            let str = cal.convertByteArray(aResult, aResultLength);
+            let str = cal.provider.convertByteArray(aResult, aResultLength);
             if (!str) {
                 cal.LOG("CalDAV: Failed to parse freebusy response from " + self.name);
             } else if (self.verboseLogging()) {
                 cal.LOG("CalDAV: recv: " + str);
             }
 
             if (request.responseStatus == 200) {
                 let periodsToReturn = [];
@@ -2485,28 +2485,28 @@ calDavCalendar.prototype = {
                 let caldata = caldavXPathFirst(fbResult, "/C:schedule-response/C:response/C:calendar-data/text()");
                 try {
                     let calComp = cal.getIcsService().parseICS(caldata, null);
                     for (let calFbComp of cal.ical.calendarComponentIterator(calComp)) {
                         let interval;
 
                         let replyRangeStart = calFbComp.startTime;
                         if (replyRangeStart && (aRangeStart.compare(replyRangeStart) == -1)) {
-                            interval = new cal.FreeBusyInterval(aCalId,
-                                                                calIFreeBusyInterval.UNKNOWN,
-                                                                aRangeStart,
-                                                                replyRangeStart);
+                            interval = new cal.provider.FreeBusyInterval(aCalId,
+                                                                         calIFreeBusyInterval.UNKNOWN,
+                                                                         aRangeStart,
+                                                                         replyRangeStart);
                             periodsToReturn.push(interval);
                         }
                         let replyRangeEnd = calFbComp.endTime;
                         if (replyRangeEnd && (aRangeEnd.compare(replyRangeEnd) == 1)) {
-                            interval = new cal.FreeBusyInterval(aCalId,
-                                                                calIFreeBusyInterval.UNKNOWN,
-                                                                replyRangeEnd,
-                                                                aRangeEnd);
+                            interval = new cal.provider.FreeBusyInterval(aCalId,
+                                                                         calIFreeBusyInterval.UNKNOWN,
+                                                                         replyRangeEnd,
+                                                                         aRangeEnd);
                             periodsToReturn.push(interval);
                         }
 
                         for (let fbProp of cal.ical.propertyIterator(calFbComp, "FREEBUSY")) {
                             let fbType = fbProp.getParameter("FBTYPE");
                             if (fbType) {
                                 fbType = fbTypeMap[fbType];
                             } else {
@@ -2517,20 +2517,20 @@ calDavCalendar.prototype = {
                             let end;
                             if (parts[1].charAt(0) == "P") { // this is a duration
                                 end = begin.clone();
                                 end.addDuration(cal.createDuration(parts[1]));
                             } else {
                                 // This is a date string
                                 end = cal.createDateTime(parts[1]);
                             }
-                            interval = new cal.FreeBusyInterval(aCalId,
-                                                                fbType,
-                                                                begin,
-                                                                end);
+                            interval = new cal.provider.FreeBusyInterval(aCalId,
+                                                                         fbType,
+                                                                         begin,
+                                                                         end);
                             periodsToReturn.push(interval);
                         }
                     }
                 } catch (exc) {
                     cal.ERROR("CalDAV: Error parsing free-busy info.");
                 }
 
                 aListener.onResult(null, periodsToReturn);
@@ -2625,17 +2625,17 @@ calDavCalendar.prototype = {
         if ((!this.hasScheduling && !this.hasAutoScheduling) || !this.mShouldPollInbox || !this.firstInRealm()) {
             return;
         }
 
         this.getUpdatedItems(this.mInboxUrl, null);
     },
 
     //
-    // take calISchedulingSupport interface base implementation (cal.ProviderBase)
+    // take calISchedulingSupport interface base implementation (cal.provider.BaseClass)
     //
 
     processItipReply: function(aItem, aPath) {
         // modify partstat for in-calendar item
         // delete item from inbox
         let self = this;
 
         let getItemListener = {};
@@ -2718,17 +2718,17 @@ calDavCalendar.prototype = {
     },
     set senderAddress(aString) {
         return (this.mSenderAddress = aString);
     },
 
     sendItems: function(aCount, aRecipients, aItipItem) {
         function doImipScheduling(aCalendar, aRecipientList) {
             let result = false;
-            let imipTransport = cal.getImipTransport(aCalendar);
+            let imipTransport = cal.provider.getImipTransport(aCalendar);
             let recipients = [];
             aRecipientList.forEach(rec => recipients.push(rec.toString()));
             if (imipTransport) {
                 cal.LOG("Enforcing client-side email scheduling instead of server-side scheduling" +
                         " for " + recipients.join());
                 result = imipTransport.sendItems(aCount, aRecipientList, aItipItem);
             } else {
                 cal.ERROR("No imip transport available for " + aCalendar.id + ", failed to notify" +
@@ -2801,17 +2801,17 @@ calDavCalendar.prototype = {
                                 self.name);
                     }
 
                     if (status != 200) {
                         cal.LOG("CalDAV: Sending iTIP failed with status " + status +
                                 " for " + self.name);
                     }
 
-                    let str = cal.convertByteArray(aResult, aResultLength, "UTF-8", false);
+                    let str = cal.provider.convertByteArray(aResult, aResultLength, "UTF-8", false);
                     if (str) {
                         if (self.verboseLogging()) {
                             cal.LOG("CalDAV: recv: " + str);
                         }
                     } else {
                         cal.LOG("CalDAV: Failed to parse iTIP response for" +
                                 self.name);
                     }
@@ -2845,17 +2845,17 @@ calDavCalendar.prototype = {
                                 }
                             }
                         }
                     }
 
                     if (remainingAttendees.length) {
                         // try to fall back to email delivery if CalDAV-sched
                         // didn't work
-                        let imipTransport = cal.getImipTransport(self);
+                        let imipTransport = cal.provider.getImipTransport(self);
                         if (imipTransport) {
                             if (self.verboseLogging()) {
                                 cal.LOG("CalDAV: sending email to " + remainingAttendees.length + " recipients");
                             }
                             imipTransport.sendItems(remainingAttendees.length, remainingAttendees, aItipItem);
                         } else {
                             cal.LOG("CalDAV: no fallback to iTIP/iMIP transport for " +
                                     self.name);
@@ -2909,17 +2909,17 @@ calDavCalendar.prototype = {
         let uploadContent;
         if (aOldChannel instanceof Components.interfaces.nsIUploadChannel &&
             aOldChannel instanceof Components.interfaces.nsIHttpChannel &&
             aOldChannel.uploadStream) {
             uploadData = aOldChannel.uploadStream;
             uploadContent = aOldChannel.getRequestHeader("Content-Type");
         }
 
-        cal.prepHttpChannel(null,
+        cal.provider.prepHttpChannel(null,
                             uploadData,
                             uploadContent,
                             this,
                             aNewChannel);
 
         // Make sure we can get/set headers on both channels.
         aNewChannel.QueryInterface(Components.interfaces.nsIHttpChannel);
         aOldChannel.QueryInterface(Components.interfaces.nsIHttpChannel);
--- a/calendar/providers/gdata/components/calGoogleCalendar.js
+++ b/calendar/providers/gdata/components/calGoogleCalendar.js
@@ -35,17 +35,17 @@ function calGoogleCalendar() {
 
 var calGoogleCalendarClassID = Components.ID("{d1a6e988-4b4d-45a5-ba46-43e501ea96e3}");
 var calGoogleCalendarInterfaces = [
     Components.interfaces.calICalendar,
     Components.interfaces.calISchedulingSupport,
     Components.interfaces.calIChangeLog
 ];
 calGoogleCalendar.prototype = {
-    __proto__: cal.ProviderBase.prototype,
+    __proto__: cal.provider.BaseClass.prototype,
 
     classID: calGoogleCalendarClassID,
     QueryInterface: XPCOMUtils.generateQI(calGoogleCalendarInterfaces),
     classInfo: XPCOMUtils.generateCI({
         classDescription: "Google Calendar Provider",
         contractID: "@mozilla.org/calendar/calendar;1?type=gdata",
         classID: calGoogleCalendarClassID,
         interfaces: calGoogleCalendarInterfaces
--- a/calendar/providers/gdata/modules/gdataRequest.jsm
+++ b/calendar/providers/gdata/modules/gdataRequest.jsm
@@ -212,19 +212,19 @@ calGoogleRequest.prototype = {
             cal.LOG("[calGoogleRequest] Requesting " + this.method + " " +
                     channel.URI.spec);
 
             this.prepareChannel(channel);
 
             channel = channel.QueryInterface(Components.interfaces.nsIHttpChannel);
             channel.redirectionLimit = 3;
 
-            this.mLoader = cal.createStreamLoader();
+            this.mLoader = cal.provider.createStreamLoader();
             channel.notificationCallbacks = this;
-            cal.sendHttpRequest(this.mLoader, channel, this);
+            cal.provider.sendHttpRequest(this.mLoader, channel, this);
         } catch (e) {
             // Let the response function handle the error that happens here
             this.fail(e.result, e.message);
         }
         return promise;
     },
 
     /**
@@ -322,17 +322,17 @@ calGoogleRequest.prototype = {
                      aChannel.URI.spec);
         }
     },
 
     /**
      * @see nsIInterfaceRequestor
      * @see calProviderUtils.jsm
      */
-    getInterface: cal.InterfaceRequestor_getInterface,
+    getInterface: cal.provider.InterfaceRequestor_getInterface,
 
     /**
      * @see nsIChannelEventSink
      */
     asyncOnChannelRedirect: function(aOldChannel, aNewChannel, aFlags, aCallback) {
         // all we need to do to the new channel is the basic preparation
         this.prepareChannel(aNewChannel);
         aCallback.onRedirectVerifyCallback(Components.results.NS_OK);
@@ -345,17 +345,17 @@ calGoogleRequest.prototype = {
         if (!aResult || !Components.isSuccessCode(aStatus)) {
             this.fail(aStatus, aResult);
             return;
         }
 
         let httpChannel = aLoader.request.QueryInterface(Components.interfaces.nsIHttpChannel);
 
         // Convert the stream, falling back to utf-8 in case its not given.
-        let result = cal.convertByteArray(aResult, aResultLength, httpChannel.contentCharset);
+        let result = cal.provider.convertByteArray(aResult, aResultLength, httpChannel.contentCharset);
         if (result === null) {
             this.fail(Components.results.NS_ERROR_FAILURE,
                       "Could not convert bytestream to Unicode: " + e);
             return;
         }
 
         let objData;
         try {
--- a/calendar/providers/gdata/modules/gdataSession.jsm
+++ b/calendar/providers/gdata/modules/gdataSession.jsm
@@ -459,17 +459,17 @@ calGoogleSession.prototype = {
                     cal.LOG("[calGoogleCalendar] Could not request freebusy for " + strippedCalId + ": " + reason);
                     failSync(Components.results.NS_ERROR_FAILURE, reason);
                 } else {
                     let utcZone = cal.dtz.UTC;
                     cal.LOG("[calGoogleCalendar] Found " + calData.busy.length + " busy slots within range for " + strippedCalId);
                     let busyRanges = calData.busy.map((entry) => {
                         let start = cal.dtz.fromRFC3339(entry.start, utcZone);
                         let end = cal.dtz.fromRFC3339(entry.end, utcZone);
-                        let interval = new cal.FreeBusyInterval(aCalId, cIFBI.BUSY, start, end);
+                        let interval = new cal.provider.FreeBusyInterval(aCalId, cIFBI.BUSY, start, end);
                         LOGinterval(interval);
                         return interval;
                     });
                     completeSync(busyRanges);
                 }
             } else {
                 cal.ERROR("[calGoogleCalendar] Invalid freebusy response: " + aData.toSource());
                 failSync(Components.results.NS_ERROR_FAILURE, (aData && aData.toSource()));
--- a/calendar/providers/gdata/modules/gdataUtils.jsm
+++ b/calendar/providers/gdata/modules/gdataUtils.jsm
@@ -1284,17 +1284,17 @@ ActivityShell.prototype = {
  * @param aCalendar         The calendar this operation happens in
  * @param aItem             The item that was passed to the server
  * @return                  A promise resolved when the conflict has been resolved
  */
 async function checkResolveConflict(aOperation, aCalendar, aItem) {
     cal.LOG("[calGoogleCalendar] A conflict occurred for " + aItem.title);
 
     let method = (aOperation.type == aOperation.DELETE ? "delete" : "modify");
-    let overwrite = cal.promptOverwrite(method, aItem);
+    let overwrite = cal.provider.promptOverwrite(method, aItem);
     if (overwrite) {
         // The user has decided to overwrite the server version. Send again
         // overwriting the server version with If-Match: *
         cal.LOG("[calGoogleCalendar] Resending " + method + " and ignoring ETag");
         aOperation.addRequestHeader("If-Match", "*");
         try {
             return await aCalendar.session.asyncItemRequest(aOperation);
         } catch (e) {
--- a/calendar/providers/ics/calICSCalendar.js
+++ b/calendar/providers/ics/calICSCalendar.js
@@ -45,17 +45,17 @@ var calICSCalendarInterfaces = [
     Components.interfaces.calICalendar,
     Components.interfaces.calISchedulingSupport,
     Components.interfaces.nsIStreamListener,
     Components.interfaces.nsIStreamLoaderObserver,
     Components.interfaces.nsIChannelEventSink,
     Components.interfaces.nsIInterfaceRequestor,
 ];
 calICSCalendar.prototype = {
-    __proto__: cal.ProviderBase.prototype,
+    __proto__: cal.provider.BaseClass.prototype,
     classID: calICSCalendarClassID,
     QueryInterface: XPCOMUtils.generateQI(calICSCalendarInterfaces),
     classInfo: XPCOMUtils.generateCI({
         classID: calICSCalendarClassID,
         contractID: "@mozilla.org/calendar/calendar;1?type=ics",
         classDescription: "Calendar ICS provider",
         interfaces: calICSCalendarInterfaces,
     }),
@@ -611,17 +611,17 @@ calICSCalendar.prototype = {
     endBatch: function() {
         this.mObserver.onEndBatch();
     },
 
     /**
      * @see nsIInterfaceRequestor
      * @see calProviderUtils.jsm
      */
-    getInterface: cal.InterfaceRequestor_getInterface,
+    getInterface: cal.provider.InterfaceRequestor_getInterface,
 
     /**
      * Make a backup of the (remote) calendar
      *
      * This will download the remote file into the profile dir.
      * It should be called before every upload, so every change can be
      * restored. By default, it will keep 3 backups. It also keeps one
      * file each day, for 3 days. That way, even if the user doesn't notice
@@ -720,17 +720,17 @@ calICSCalendar.prototype = {
             }
         }
 
         let backupDays = Preferences.get("calendar.backup.days", 1);
         let numBackupFiles = Preferences.get("calendar.backup.filenum", 3);
 
         let backupDir;
         try {
-            backupDir = cal.getCalendarDirectory();
+            backupDir = cal.provider.getCalendarDirectory();
             backupDir.append("backup");
             if (!backupDir.exists()) {
                 backupDir.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt("0755", 8));
             }
         } catch (e) {
             // Backup dir wasn't found. Likely because we are running in
             // xpcshell. Don't die, but continue the upload.
             cal.ERROR("[calICSCalendar] Backup failed, no backupdir:" + e);
@@ -1023,26 +1023,26 @@ httpHooks.prototype = {
             };
             let queryXml =
                 '<D:propfind xmlns:D="DAV:">' +
                   "<D:prop>" +
                     "<D:getetag/>" +
                   "</D:prop>" +
                 "</D:propfind>";
 
-            let etagChannel = cal.prepHttpChannel(aChannel.URI, queryXml,
-                                                  "text/xml; charset=utf-8",
-                                                  this);
+            let etagChannel = cal.provider.prepHttpChannel(aChannel.URI, queryXml,
+                                                           "text/xml; charset=utf-8",
+                                                           this);
             etagChannel.setRequestHeader("Depth", "0", false);
             etagChannel.requestMethod = "PROPFIND";
             let streamLoader = Components.classes["@mozilla.org/network/stream-loader;1"]
                                          .createInstance(Components.interfaces
                                          .nsIStreamLoader);
 
-            cal.sendHttpRequest(streamLoader, etagChannel, etagListener);
+            cal.provider.sendHttpRequest(streamLoader, etagChannel, etagListener);
         }
         return true;
     },
 
     // nsIProgressEventSink
     onProgress: function(aRequest, aContext, aProgress, aProgressMax) {},
     onStatus: function(aRequest, aContext, aStatus, aStatusArg) {},
 
--- a/calendar/providers/memory/calMemoryCalendar.js
+++ b/calendar/providers/memory/calMemoryCalendar.js
@@ -22,17 +22,17 @@ var calMemoryCalendarClassID = Component
 var calMemoryCalendarInterfaces = [
     Components.interfaces.calICalendar,
     Components.interfaces.calISchedulingSupport,
     Components.interfaces.calIOfflineStorage,
     Components.interfaces.calISyncWriteCalendar,
     Components.interfaces.calICalendarProvider
 ];
 calMemoryCalendar.prototype = {
-    __proto__: cal.ProviderBase.prototype,
+    __proto__: cal.provider.BaseClass.prototype,
     classID: calMemoryCalendarClassID,
     QueryInterface: XPCOMUtils.generateQI(calMemoryCalendarInterfaces),
     classInfo: XPCOMUtils.generateCI({
         classID: calMemoryCalendarClassID,
         contractID: "@mozilla.org/calendar/calendar;1?type=memory",
         classDescription: "Calendar Memory Provider",
         interfaces: calMemoryCalendarInterfaces
     }),
--- a/calendar/providers/storage/calStorageCalendar.js
+++ b/calendar/providers/storage/calStorageCalendar.js
@@ -28,17 +28,17 @@ var calStorageCalendarClassID = Componen
 var calStorageCalendarInterfaces = [
     Components.interfaces.calICalendar,
     Components.interfaces.calICalendarProvider,
     Components.interfaces.calIOfflineStorage,
     Components.interfaces.calISchedulingSupport,
     Components.interfaces.calISyncWriteCalendar,
 ];
 calStorageCalendar.prototype = {
-    __proto__: cal.ProviderBase.prototype,
+    __proto__: cal.provider.BaseClass.prototype,
     classID: calStorageCalendarClassID,
     QueryInterface: XPCOMUtils.generateQI(calStorageCalendarInterfaces),
     classInfo: XPCOMUtils.generateCI({
         classID: calStorageCalendarClassID,
         contractID: "@mozilla.org/calendar/calendar;1?type=storage",
         classDescription: "Calendar Storage Provider",
         interfaces: calStorageCalendarInterfaces
     }),
@@ -197,17 +197,17 @@ calStorageCalendar.prototype = {
             // open the database
             this.mDB = Services.storage.openDatabase(fileURL.file);
             this.mDB.executeSimpleSQL("PRAGMA journal_mode=WAL");
             upgradeDB(this.mDB);
         } else if (this.uri.schemeIs("moz-profile-calendar")) {
             // This is an old-style moz-profile-calendar. It requires some
             // migration steps.
 
-            let localDB = cal.getCalendarDirectory();
+            let localDB = cal.provider.getCalendarDirectory();
             localDB.append("local.sqlite");
             localDB = Services.storage.openDatabase(localDB);
 
             // First, we need to check if this is from 0.9, i.e we need to
             // migrate from storage.sdb to local.sqlite.
             let storageSdb = Services.dirsvc.get("ProfD", Components.interfaces.nsIFile);
             storageSdb.append("storage.sdb");
             this.mDB = Services.storage.openDatabase(storageSdb);
@@ -342,17 +342,17 @@ calStorageCalendar.prototype = {
                 }
             } catch (exc) {
                 this.logError("prepareInitDB  moz-profile-calendar migration exception", exc);
                 this.mDB.rollbackTransaction();
                 throw exc;
             }
         } else if (this.uri.schemeIs("moz-storage-calendar")) {
             // New style uri, no need for migration here
-            let localDB = cal.getCalendarDirectory();
+            let localDB = cal.provider.getCalendarDirectory();
             localDB.append("local.sqlite");
 
             this.mDB = Services.storage.openDatabase(localDB);
             upgradeDB(this.mDB);
         } else {
             throw new Components.Exception("Invalid Scheme " + this.uri.spec);
         }
 
--- a/calendar/providers/storage/calStorageUpgrade.jsm
+++ b/calendar/providers/storage/calStorageUpgrade.jsm
@@ -179,17 +179,17 @@ function getVersion(db) {
 /**
  * Backup the database and notify the user via error console of the process
  */
 function backupDB(db, currentVersion) {
     cal.LOG("Storage: Backing up current database...");
     try {
         // Prepare filenames and path
         let backupFilename = "local.v" + currentVersion + ".sqlite";
-        let backupPath = cal.getCalendarDirectory();
+        let backupPath = cal.provider.getCalendarDirectory();
         backupPath.append("backup");
         if (!backupPath.exists()) {
             backupPath.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, parseInt("0755", 8));
         }
 
         // Create a backup file and notify the user via WARN, since LOG will not
         // be visible unless a pref is set.
         let file = Services.storage.backupDatabaseFile(db.databaseFile, backupFilename, backupPath);
--- a/calendar/providers/wcap/calWcapCalendar.js
+++ b/calendar/providers/wcap/calWcapCalendar.js
@@ -22,17 +22,17 @@ var calWcapCalendarClassID = Components.
 var calWcapCalendarInterfaces = [
     calIWcapCalendar,
     calICalendar,
     Components.interfaces.calISchedulingSupport,
     Components.interfaces.calIChangeLog,
     Components.interfaces.calICalendarProvider,
 ];
 calWcapCalendar.prototype = {
-    __proto__: cal.ProviderBase.prototype,
+    __proto__: cal.provider.BaseClass.prototype,
     classID: calWcapCalendarClassID,
     QueryInterface: XPCOMUtils.generateQI(calWcapCalendarInterfaces),
     classInfo: XPCOMUtils.generateCI({
         classID: calWcapCalendarClassID,
         contractID: "@mozilla.org/calendar/calendar;1?type=wcap",
         classDescription: "Sun Java System Calendar Server WCAP Provider",
         interfaces: calWcapCalendarInterfaces
     }),
--- a/calendar/providers/wcap/calWcapRequest.js
+++ b/calendar/providers/wcap/calWcapRequest.js
@@ -214,17 +214,17 @@ calWcapNetworkRequest.prototype = {
         classDescription: "Sun Java System Calendar Server WCAP Network Request",
         interfaces: calWcapNetworkRequestInterfaces
     }),
 
     /**
      * @see nsIInterfaceRequestor
      * @see calProviderUtils.jsm
      */
-    getInterface: cal.InterfaceRequestor_getInterface,
+    getInterface: cal.provider.InterfaceRequestor_getInterface,
 
     /**
      * prepareChannel
      * Prepares the passed channel to match this objects properties
      *
      * @param aChannel    The Channel to be prepared
      */
     prepareChannel: function(aChannel) {
--- a/calendar/providers/wcap/calWcapSession.js
+++ b/calendar/providers/wcap/calWcapSession.js
@@ -993,17 +993,17 @@ calWcapSession.prototype = {
                                 if (!fbType) {
                                     fbType = calIFreeBusyInterval.UNKNOWN;
                                 }
                                 let str = node.textContent;
                                 let slash = str.indexOf("/");
                                 let start = getDatetimeFromIcalString(str.substr(0, slash));
                                 let end = getDatetimeFromIcalString(str.substr(slash + 1));
 
-                                ret.push(new cal.FreeBusyInterval(calId, fbType, start, end));
+                                ret.push(new cal.provider.FreeBusyInterval(calId, fbType, start, end));
                             }
                         }
                         request.execRespFunc(null, ret);
                     }
                 },
                 stringToXml_, "get_freebusy", params);
         } catch (exc) {
             request.execRespFunc(exc);
--- a/calendar/test/unit/test_freebusy_service.js
+++ b/calendar/test/unit/test_freebusy_service.js
@@ -32,17 +32,17 @@ function test_found() {
 
     let provider2 = {
         id: 2,
         called: false,
         getFreeBusyIntervals: function(aCalId, aStart, aEnd, aTypes, aListener) {
             ok(!this.called);
             this.called = true;
 
-            let interval = new cal.FreeBusyInterval(aCalId, cIFI.BUSY, aStart, aEnd);
+            let interval = new cal.provider.FreeBusyInterval(aCalId, cIFI.BUSY, aStart, aEnd);
             aListener.onResult(null, [interval]);
         }
     };
     provider2.wrappedJSObject = provider2;
 
     freebusy.addProvider(provider1);
     equal(_countProviders(), 1);
     freebusy.addProvider(provider2);
--- a/calendar/test/unit/test_gdata_provider.js
+++ b/calendar/test/unit/test_gdata_provider.js
@@ -29,26 +29,26 @@ ChromeUtils.import("resource://testing-c
 
 var gServer;
 
 var MockConflictPrompt = {
     _origFunc: null,
     overwrite: false,
     register: function() {
         if (!this._origFunc) {
-            this._origFunc = cal.promptOverwrite;
-            cal.promptOverwrite = (aMode, aItem) => {
+            this._origFunc = cal.provider.promptOverwrite;
+            cal.provider.promptOverwrite = (aMode, aItem) => {
                 return this.overwrite;
             };
         }
     },
 
     unregister: function() {
         if (this._origFunc) {
-            cal.promptOverwrite = this._origFunc;
+            cal.provider.promptOverwrite = this._origFunc;
             this._origFunc = null;
         }
     }
 };
 
 function MockAlertsService() {}
 
 MockAlertsService.prototype = {