Bug 905097 - The final nail in the coffin of calUtils.js. r=MakeMyDay
authorPhilipp Kewisch <mozilla@kewis.ch>
Sun, 25 Feb 2018 19:50:18 +0100
changeset 31398 52d3403860a3b8c923f13189f64a02662aba5d28
parent 31397 f0dc8dca11f86cbbf51b5bb4d48ca701700d6a54
child 31399 2d0822c5a149c89e047b2e368d91083fbe8badda
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersMakeMyDay
bugs905097
Bug 905097 - The final nail in the coffin of calUtils.js. r=MakeMyDay MozReview-Commit-ID: AGfDXZjSn2z
calendar/.eslintrc.js
calendar/base/content/calendar-month-view.xml
calendar/base/content/calendar-task-tree.xml
calendar/base/modules/calACLUtils.jsm
calendar/base/modules/calAlarmUtils.jsm
calendar/base/modules/calAsyncUtils.jsm
calendar/base/modules/calAuthUtils.jsm
calendar/base/modules/calCategoryUtils.jsm
calendar/base/modules/calDataUtils.jsm
calendar/base/modules/calDateTimeUtils.jsm
calendar/base/modules/calEmailUtils.jsm
calendar/base/modules/calItemUtils.jsm
calendar/base/modules/calIteratorUtils.jsm
calendar/base/modules/calItipUtils.jsm
calendar/base/modules/calL10NUtils.jsm
calendar/base/modules/calPrintUtils.jsm
calendar/base/modules/calProviderUtils.jsm
calendar/base/modules/calUnifinderUtils.jsm
calendar/base/modules/calUtils.jsm
calendar/base/modules/calViewUtils.jsm
calendar/base/modules/calWindowUtils.jsm
calendar/base/modules/calXMLUtils.jsm
calendar/base/modules/moz.build
calendar/base/modules/shim/calAlarmUtils.jsm
calendar/base/modules/shim/calAsyncUtils.jsm
calendar/base/modules/shim/calAuthUtils.jsm
calendar/base/modules/shim/calItemUtils.jsm
calendar/base/modules/shim/calIteratorUtils.jsm
calendar/base/modules/shim/calItipUtils.jsm
calendar/base/modules/shim/calPrintUtils.jsm
calendar/base/modules/shim/calProviderUtils.jsm
calendar/base/modules/shim/calViewUtils.jsm
calendar/base/modules/shim/calXMLUtils.jsm
calendar/base/modules/utils/calACLUtils.jsm
calendar/base/modules/utils/calAlarmUtils.jsm
calendar/base/modules/utils/calAsyncUtils.jsm
calendar/base/modules/utils/calAuthUtils.jsm
calendar/base/modules/utils/calCategoryUtils.jsm
calendar/base/modules/utils/calDataUtils.jsm
calendar/base/modules/utils/calDateTimeUtils.jsm
calendar/base/modules/utils/calEmailUtils.jsm
calendar/base/modules/utils/calItemUtils.jsm
calendar/base/modules/utils/calIteratorUtils.jsm
calendar/base/modules/utils/calItipUtils.jsm
calendar/base/modules/utils/calL10NUtils.jsm
calendar/base/modules/utils/calPrintUtils.jsm
calendar/base/modules/utils/calProviderUtils.jsm
calendar/base/modules/utils/calUnifinderUtils.jsm
calendar/base/modules/utils/calViewUtils.jsm
calendar/base/modules/utils/calWindowUtils.jsm
calendar/base/modules/utils/calXMLUtils.jsm
calendar/base/src/calUtils.js
calendar/base/src/moz.build
calendar/providers/gdata/modules/calUtilsShim.jsm
--- a/calendar/.eslintrc.js
+++ b/calendar/.eslintrc.js
@@ -478,23 +478,23 @@ module.exports = {
         "indent-legacy": [2, 4, { SwitchCase: 1, }],
 
         // The following rules will not be enabled currently, but are kept here for
         // easier updates in the future.
         "no-else-return": 0,
     },
     "overrides": [{
         files: [
-            "base/modules/calAuthUtils.jsm",
-            "base/modules/calEmailUtils.jsm",
-            "base/modules/calIteratorUtils.jsm",
-            "base/modules/calItipUtils.jsm",
-            "base/modules/calUnifinderUtils.jsm",
-            "base/modules/calL10NUtils.jsm",
-            "base/modules/calProviderUtils.jsm",
+            "base/modules/utils/calAuthUtils.jsm",
+            "base/modules/utils/calEmailUtils.jsm",
+            "base/modules/utils/calIteratorUtils.jsm",
+            "base/modules/utils/calItipUtils.jsm",
+            "base/modules/utils/calL10NUtils.jsm",
+            "base/modules/utils/calProviderUtils.jsm",
+            "base/modules/utils/calUnifinderUtils.jsm",
         ],
         rules: {
             "require-jsdoc": [2, { require: { ClassDeclaration: true } }],
 
             "valid-jsdoc": [2, {
                 prefer: { returns: "return" },
                 preferType: {
                     "boolean": "Boolean",
--- a/calendar/base/content/calendar-month-view.xml
+++ b/calendar/base/content/calendar-month-view.xml
@@ -415,17 +415,16 @@
           </xul:rows>
         </xul:grid>
       </xul:vbox>
     </content>
 
     <implementation implements="calICalendarView">
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-          ChromeUtils.import("resource://calendar/modules/calViewUtils.jsm");
           ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
           // Set the preference for the default start of the week
           this.weekStartOffset = Preferences.get("calendar.week.start", 0);
 
           for (let i = 0; i < 7; i++) {
               let hdr = createXULElement("calendar-day-label");
               this.labeldaybox.appendChild(hdr);
--- a/calendar/base/content/calendar-task-tree.xml
+++ b/calendar/base/content/calendar-task-tree.xml
@@ -111,17 +111,16 @@
       </xul:tree>
     </content>
 
     <implementation implements="nsIObserver">
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
           ChromeUtils.import("resource://gre/modules/Services.jsm");
           ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-          ChromeUtils.import("resource://calendar/modules/calItemUtils.jsm");
           ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
           // set up the tree filter
           this.mFilter = new calFilter();
 
           // set up the custom tree view
           let tree = document.getAnonymousElementByAttribute(this, "anonid", "calendar-task-tree");
           this.mTreeView.tree = tree;
--- a/calendar/base/modules/calUtils.jsm
+++ b/calendar/base/modules/calUtils.jsm
@@ -381,34 +381,34 @@ var cal = {
 
 // Preferences
 XPCOMUtils.defineLazyPreferenceGetter(cal, "debugLogEnabled", "calendar.debug.log", false, (pref, prev, value) => {
     gCalendarConsole.maxLogLevel = value ? "all" : "warn";
 });
 XPCOMUtils.defineLazyPreferenceGetter(cal, "threadingEnabled", "calendar.threading.disabled", false);
 
 // Sub-modules for calUtils
-XPCOMUtils.defineLazyModuleGetter(cal, "acl", "resource://calendar/modules/calACLUtils.jsm", "calacl");
-XPCOMUtils.defineLazyModuleGetter(cal, "alarms", "resource://calendar/modules/calAlarmUtils.jsm", "calalarms");
-XPCOMUtils.defineLazyModuleGetter(cal, "async", "resource://calendar/modules/calAsyncUtils.jsm", "calasync");
-XPCOMUtils.defineLazyModuleGetter(cal, "auth", "resource://calendar/modules/calAuthUtils.jsm", "calauth");
-XPCOMUtils.defineLazyModuleGetter(cal, "category", "resource://calendar/modules/calCategoryUtils.jsm", "calcategory");
-XPCOMUtils.defineLazyModuleGetter(cal, "data", "resource://calendar/modules/calDataUtils.jsm", "caldata");
-XPCOMUtils.defineLazyModuleGetter(cal, "dtz", "resource://calendar/modules/calDateTimeUtils.jsm", "caldtz");
-XPCOMUtils.defineLazyModuleGetter(cal, "email", "resource://calendar/modules/calEmailUtils.jsm", "calemail");
-XPCOMUtils.defineLazyModuleGetter(cal, "item", "resource://calendar/modules/calItemUtils.jsm", "calitem");
-XPCOMUtils.defineLazyModuleGetter(cal, "iterate", "resource://calendar/modules/calIteratorUtils.jsm", "caliterate");
-XPCOMUtils.defineLazyModuleGetter(cal, "itip", "resource://calendar/modules/calItipUtils.jsm", "calitip");
-XPCOMUtils.defineLazyModuleGetter(cal, "l10n", "resource://calendar/modules/calL10NUtils.jsm", "call10n");
-XPCOMUtils.defineLazyModuleGetter(cal, "print", "resource://calendar/modules/calPrintUtils.jsm", "calprint");
-XPCOMUtils.defineLazyModuleGetter(cal, "provider", "resource://calendar/modules/calProviderUtils.jsm", "calprovider");
-XPCOMUtils.defineLazyModuleGetter(cal, "unifinder", "resource://calendar/modules/calUnifinderUtils.jsm", "calunifinder");
-XPCOMUtils.defineLazyModuleGetter(cal, "view", "resource://calendar/modules/calViewUtils.jsm", "calview");
-XPCOMUtils.defineLazyModuleGetter(cal, "window", "resource://calendar/modules/calWindowUtils.jsm", "calwindow");
-XPCOMUtils.defineLazyModuleGetter(cal, "xml", "resource://calendar/modules/calXMLUtils.jsm", "calxml");
+XPCOMUtils.defineLazyModuleGetter(cal, "acl", "resource://calendar/modules/utils/calACLUtils.jsm", "calacl");
+XPCOMUtils.defineLazyModuleGetter(cal, "alarms", "resource://calendar/modules/utils/calAlarmUtils.jsm", "calalarms");
+XPCOMUtils.defineLazyModuleGetter(cal, "async", "resource://calendar/modules/utils/calAsyncUtils.jsm", "calasync");
+XPCOMUtils.defineLazyModuleGetter(cal, "auth", "resource://calendar/modules/utils/calAuthUtils.jsm", "calauth");
+XPCOMUtils.defineLazyModuleGetter(cal, "category", "resource://calendar/modules/utils/calCategoryUtils.jsm", "calcategory");
+XPCOMUtils.defineLazyModuleGetter(cal, "data", "resource://calendar/modules/utils/calDataUtils.jsm", "caldata");
+XPCOMUtils.defineLazyModuleGetter(cal, "dtz", "resource://calendar/modules/utils/calDateTimeUtils.jsm", "caldtz");
+XPCOMUtils.defineLazyModuleGetter(cal, "email", "resource://calendar/modules/utils/calEmailUtils.jsm", "calemail");
+XPCOMUtils.defineLazyModuleGetter(cal, "item", "resource://calendar/modules/utils/calItemUtils.jsm", "calitem");
+XPCOMUtils.defineLazyModuleGetter(cal, "iterate", "resource://calendar/modules/utils/calIteratorUtils.jsm", "caliterate");
+XPCOMUtils.defineLazyModuleGetter(cal, "itip", "resource://calendar/modules/utils/calItipUtils.jsm", "calitip");
+XPCOMUtils.defineLazyModuleGetter(cal, "l10n", "resource://calendar/modules/utils/calL10NUtils.jsm", "call10n");
+XPCOMUtils.defineLazyModuleGetter(cal, "print", "resource://calendar/modules/utils/calPrintUtils.jsm", "calprint");
+XPCOMUtils.defineLazyModuleGetter(cal, "provider", "resource://calendar/modules/utils/calProviderUtils.jsm", "calprovider");
+XPCOMUtils.defineLazyModuleGetter(cal, "unifinder", "resource://calendar/modules/utils/calUnifinderUtils.jsm", "calunifinder");
+XPCOMUtils.defineLazyModuleGetter(cal, "view", "resource://calendar/modules/utils/calViewUtils.jsm", "calview");
+XPCOMUtils.defineLazyModuleGetter(cal, "window", "resource://calendar/modules/utils/calWindowUtils.jsm", "calwindow");
+XPCOMUtils.defineLazyModuleGetter(cal, "xml", "resource://calendar/modules/utils/calXMLUtils.jsm", "calxml");
 
 /**
  * Returns a function that provides access to the given service.
  *
  * @param cid           The contract id to create
  * @param iid           The interface id to create with
  * @return {function}   A function that returns the given service
  */
@@ -452,19 +452,11 @@ function shutdownCleanup(obj, prop) {
                 }
             }
             delete shutdownCleanup.mEntries;
         });
     }
     shutdownCleanup.mEntries.push({ mObj: obj, mProp: prop });
 }
 
-// Interim import of all symbols into cal:
-// This should serve as a clean start for new code, e.g. new code could use
-// cal.createDatetime instead of plain createDatetime NOW.
-cal.loadScripts(["calUtils.js"], cal);
-// Some functions in calUtils.js refer to other in the same file, thus include
-// the code in global scope (although only visible to this module file), too:
-cal.loadScripts(["calUtils.js"], Components.utils.getGlobalForObject(cal));
-
 // Backwards compatibility for bug 905097. Please remove with Thunderbird 61.
 ChromeUtils.import("resource://calendar/modules/calUtilsCompat.jsm");
 injectCalUtilsCompat(cal);
--- a/calendar/base/modules/moz.build
+++ b/calendar/base/modules/moz.build
@@ -1,32 +1,47 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+EXTRA_JS_MODULES.utils += [
+    'utils/calACLUtils.jsm',
+    'utils/calAlarmUtils.jsm',
+    'utils/calAsyncUtils.jsm',
+    'utils/calAuthUtils.jsm',
+    'utils/calCategoryUtils.jsm',
+    'utils/calDataUtils.jsm',
+    'utils/calDateTimeUtils.jsm',
+    'utils/calEmailUtils.jsm',
+    'utils/calItemUtils.jsm',
+    'utils/calIteratorUtils.jsm',
+    'utils/calItipUtils.jsm',
+    'utils/calL10NUtils.jsm',
+    'utils/calPrintUtils.jsm',
+    'utils/calProviderUtils.jsm',
+    'utils/calUnifinderUtils.jsm',
+    'utils/calViewUtils.jsm',
+    'utils/calWindowUtils.jsm',
+    'utils/calXMLUtils.jsm',
+]
+
 EXTRA_JS_MODULES += [
-    'calACLUtils.jsm',
-    'calAlarmUtils.jsm',
-    'calAsyncUtils.jsm',
-    'calAuthUtils.jsm',
-    'calCategoryUtils.jsm',
-    'calDataUtils.jsm',
-    'calDateTimeUtils.jsm',
-    'calEmailUtils.jsm',
+    'shim/calAlarmUtils.jsm',
+    'shim/calAsyncUtils.jsm',
+    'shim/calAuthUtils.jsm',
+    'shim/calItemUtils.jsm',
+    'shim/calIteratorUtils.jsm',
+    'shim/calItipUtils.jsm',
+    'shim/calPrintUtils.jsm',
+    'shim/calProviderUtils.jsm',
+    'shim/calViewUtils.jsm',
+    'shim/calXMLUtils.jsm',
+]
+
+EXTRA_JS_MODULES += [
     'calExtract.jsm',
     'calHashedArray.jsm',
-    'calItemUtils.jsm',
-    'calIteratorUtils.jsm',
-    'calItipUtils.jsm',
-    'calL10NUtils.jsm',
-    'calPrintUtils.jsm',
-    'calProviderUtils.jsm',
     'calRecurrenceUtils.jsm',
-    'calUnifinderUtils.jsm',
     'calUtils.jsm',
     'calUtilsCompat.jsm',
-    'calViewUtils.jsm',
-    'calWindowUtils.jsm',
-    'calXMLUtils.jsm',
     'ical.js',
 ]
-
new file mode 100644
--- /dev/null
+++ b/calendar/base/modules/shim/calAlarmUtils.jsm
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
+ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+
+this.EXPORTED_SYMBOLS = ["cal"];
+
+Deprecated.warning("calAlarmUtils.jsm must no longer be imported directly, it" +
+                   " is already available via calUtils.jsm",
+                   "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
+                   Components.stack.caller);
new file mode 100644
--- /dev/null
+++ b/calendar/base/modules/shim/calAsyncUtils.jsm
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
+ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+
+this.EXPORTED_SYMBOLS = ["cal"];
+
+Deprecated.warning("calAsyncUtils.jsm must no longer be imported directly, it" +
+                   " is already available via calUtils.jsm",
+                   "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
+                   Components.stack.caller);
new file mode 100644
--- /dev/null
+++ b/calendar/base/modules/shim/calAuthUtils.jsm
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
+ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+
+this.EXPORTED_SYMBOLS = ["cal"];
+
+Deprecated.warning("calAuthUtils.jsm must no longer be imported directly, it" +
+                   " is already available via calUtils.jsm",
+                   "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
+                   Components.stack.caller);
new file mode 100644
--- /dev/null
+++ b/calendar/base/modules/shim/calItemUtils.jsm
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
+ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+
+this.EXPORTED_SYMBOLS = ["cal"];
+
+Deprecated.warning("calItemUtils.jsm must no longer be imported directly, it" +
+                   " is already available via calUtils.jsm",
+                   "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
+                   Components.stack.caller);
new file mode 100644
--- /dev/null
+++ b/calendar/base/modules/shim/calIteratorUtils.jsm
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
+ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+
+this.EXPORTED_SYMBOLS = ["cal"];
+
+Deprecated.warning("calIteratorUtils.jsm must no longer be imported directly, it" +
+                   " is already available via calUtils.jsm",
+                   "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
+                   Components.stack.caller);
new file mode 100644
--- /dev/null
+++ b/calendar/base/modules/shim/calItipUtils.jsm
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
+ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+
+this.EXPORTED_SYMBOLS = ["cal"];
+
+Deprecated.warning("calItipUtils.jsm must no longer be imported directly, it" +
+                   " is already available via calUtils.jsm",
+                   "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
+                   Components.stack.caller);
new file mode 100644
--- /dev/null
+++ b/calendar/base/modules/shim/calPrintUtils.jsm
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
+ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+
+this.EXPORTED_SYMBOLS = ["cal"];
+
+Deprecated.warning("calPrintUtils.jsm must no longer be imported directly, it" +
+                   " is already available via calUtils.jsm",
+                   "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
+                   Components.stack.caller);
new file mode 100644
--- /dev/null
+++ b/calendar/base/modules/shim/calProviderUtils.jsm
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
+ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+
+this.EXPORTED_SYMBOLS = ["cal"];
+
+Deprecated.warning("calProviderUtils.jsm must no longer be imported directly, it" +
+                   " is already available via calUtils.jsm",
+                   "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
+                   Components.stack.caller);
new file mode 100644
--- /dev/null
+++ b/calendar/base/modules/shim/calViewUtils.jsm
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
+ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+
+this.EXPORTED_SYMBOLS = ["cal"];
+
+Deprecated.warning("calViewUtils.jsm must no longer be imported directly, it" +
+                   " is already available via calUtils.jsm",
+                   "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
+                   Components.stack.caller);
new file mode 100644
--- /dev/null
+++ b/calendar/base/modules/shim/calXMLUtils.jsm
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
+ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+
+this.EXPORTED_SYMBOLS = ["cal"];
+
+Deprecated.warning("calXMLUtils.jsm must no longer be imported directly, it" +
+                   " is already available via calUtils.jsm",
+                   "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
+                   Components.stack.caller);
rename from calendar/base/modules/calACLUtils.jsm
rename to calendar/base/modules/utils/calACLUtils.jsm
--- a/calendar/base/modules/calACLUtils.jsm
+++ b/calendar/base/modules/utils/calACLUtils.jsm
@@ -1,14 +1,23 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
+
+/*
+ * Helpers for permission checks and other ACL features
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.acl namespace.
 
 this.EXPORTED_SYMBOLS = ["calacl"]; /* exported calacl */
 
 var calacl = {
     /**
      * Check if the specified calendar is writable. This is the case when it is
      * not marked readOnly, we are not offline, or we are offline and the
      * calendar is local.
rename from calendar/base/modules/calAlarmUtils.jsm
rename to calendar/base/modules/utils/calAlarmUtils.jsm
--- a/calendar/base/modules/calAlarmUtils.jsm
+++ b/calendar/base/modules/utils/calAlarmUtils.jsm
@@ -2,16 +2,23 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
+/*
+ * Helpers for manipulating calendar alarms
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.alarm namespace.
+
 this.EXPORTED_SYMBOLS = ["calalarms"]; /* exported calalarms */
 
 var calalarms = {
     /**
      * Read default alarm settings from user preferences and apply them to the
      * event/todo passed in. The item's calendar should be set to ensure the
      * correct alarm type is set.
      *
rename from calendar/base/modules/calAsyncUtils.jsm
rename to calendar/base/modules/utils/calAsyncUtils.jsm
--- a/calendar/base/modules/calAsyncUtils.jsm
+++ b/calendar/base/modules/utils/calAsyncUtils.jsm
@@ -1,19 +1,22 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 /*
- * Asynchronous tools for handling calendar operations.
+ * Asynchronous tools for handling calendar operations
  */
 
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.async namespace.
+
 this.EXPORTED_SYMBOLS = ["calasync"]; /* exported calasync */
 
 var cIOL = Components.interfaces.calIOperationListener;
 var cIC = Components.interfaces.calICalendar;
 
 var promisifyProxyHandler = {
     promiseOperation: function(target, name, args) {
         let deferred = PromiseUtils.defer();
rename from calendar/base/modules/calAuthUtils.jsm
rename to calendar/base/modules/utils/calAuthUtils.jsm
--- a/calendar/base/modules/calAuthUtils.jsm
+++ b/calendar/base/modules/utils/calAuthUtils.jsm
@@ -4,19 +4,22 @@
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
 /*
- * Authentication helper code
+ * Authentication tools and prompts, mostly for providers
  */
 
+// NOTE: This module should not be loaded directly, it is available when including
+// calUtils.jsm under the cal.auth namespace.
+
 this.EXPORTED_SYMBOLS = ["calauth"]; /* exported calauth */
 
 var calauth = {
     /**
      * Calendar Auth prompt implementation. This instance of the auth prompt should
      * be used by providers and other components that handle authentication using
      * nsIAuthPrompt2 and friends.
      *
rename from calendar/base/modules/calCategoryUtils.jsm
rename to calendar/base/modules/utils/calCategoryUtils.jsm
--- a/calendar/base/modules/calCategoryUtils.jsm
+++ b/calendar/base/modules/utils/calCategoryUtils.jsm
@@ -2,16 +2,23 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
+/*
+ * Helpers for reading and writing calendar categories
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.category namespace.
+
 this.EXPORTED_SYMBOLS = ["calcategory"]; /* exported calcategory */
 
 var calcategory = {
     /**
      * Sets up the default categories from the localized string
      *
      * @return      The default set of categories as a comma separated string.
      */
rename from calendar/base/modules/calDataUtils.jsm
rename to calendar/base/modules/utils/calDataUtils.jsm
--- a/calendar/base/modules/calDataUtils.jsm
+++ b/calendar/base/modules/utils/calDataUtils.jsm
@@ -1,16 +1,23 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
+/*
+ * Data structures and algorithms used within the codebase
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.data namespace.
+
 this.EXPORTED_SYMBOLS = ["caldata"]; /* exported caldata */
 
 class PropertyMap extends Map {
     get simpleEnumerator() {
         let entries = [...this.entries()].filter(([key, value]) => value !== undefined);
         let index = 0;
 
         return {
rename from calendar/base/modules/calDateTimeUtils.jsm
rename to calendar/base/modules/utils/calDateTimeUtils.jsm
--- a/calendar/base/modules/calDateTimeUtils.jsm
+++ b/calendar/base/modules/utils/calDateTimeUtils.jsm
@@ -1,24 +1,24 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/*
- * date, time and timezone related functions via cal.dtz.*
- *
- * NOTE this module should never be imported directly. Instead, load
- * calUtils.jsm and accss them via cal.dtz.*
- */
-
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
+/*
+ * Date, time and timezone related functions
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.dtz namespace.
+
 this.EXPORTED_SYMBOLS = ["caldtz"]; /* exported caldtz */
 
 var caldtz = {
     /**
      * Shortcut to the timezone service's defaultTimezone
      */
     get defaultTimezone() {
         return cal.getTimezoneService().defaultTimezone;
rename from calendar/base/modules/calEmailUtils.jsm
rename to calendar/base/modules/utils/calEmailUtils.jsm
--- a/calendar/base/modules/calEmailUtils.jsm
+++ b/calendar/base/modules/utils/calEmailUtils.jsm
@@ -2,16 +2,23 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource:///modules/mailServices.js");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
+/*
+ * Functions for processing email addresses and sending email
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.email namespace.
+
 this.EXPORTED_SYMBOLS = ["calemail"]; /* exported calemail */
 
 var calemail = {
     /**
      * Convenience function to open the compose window pre-filled with the information from the
      * parameters. These parameters are mostly raw header fields, see #createRecipientList function
      * to create a recipient list string.
      *
rename from calendar/base/modules/calItemUtils.jsm
rename to calendar/base/modules/utils/calItemUtils.jsm
--- a/calendar/base/modules/calItemUtils.jsm
+++ b/calendar/base/modules/utils/calItemUtils.jsm
@@ -6,16 +6,23 @@ ChromeUtils.import("resource://gre/modul
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.import("resource://calendar/modules/calHashedArray.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
+/*
+ * Calendar item related functions
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.item namespace.
+
 this.EXPORTED_SYMBOLS = ["calitem", "itemDiff"]; /* exported calitem, itemDiff */
 
 var calitem = {
     ItemDiff: (function() {
         /**
          * Given two sets of items, find out which items were added, changed or
          * removed.
          *
rename from calendar/base/modules/calIteratorUtils.jsm
rename to calendar/base/modules/utils/calIteratorUtils.jsm
--- a/calendar/base/modules/calIteratorUtils.jsm
+++ b/calendar/base/modules/utils/calIteratorUtils.jsm
@@ -3,16 +3,23 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
+/*
+ * Iterators for various data structures
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.iterate namespace.
+
 this.EXPORTED_SYMBOLS = ["caliterate"]; /* exported caliterate */
 
 var caliterate = {
     /**
      * Iterates an array of items, i.e. the passed item including all
      * overridden instances of a recurring series.
      *
      * @param {calIItemBase[]} items        array of items to iterate
rename from calendar/base/modules/calItipUtils.jsm
rename to calendar/base/modules/utils/calItipUtils.jsm
--- a/calendar/base/modules/calItipUtils.jsm
+++ b/calendar/base/modules/utils/calItipUtils.jsm
@@ -1,22 +1,28 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.import("resource:///modules/mailServices.js");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
-/**
+XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
+
+/*
  * Scheduling and iTIP helper code
  */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.itip namespace.
+
 this.EXPORTED_SYMBOLS = ["calitip"]; /* exported calitip */
+
 var calitip = {
     /**
      * Gets the sequence/revision number, either of the passed item or the last received one of an
      * attendee; see <http://tools.ietf.org/html/draft-desruisseaux-caldav-sched-04#section-7.1>.
      *
      * @param {calIAttendee|calIItemBase} aItem     The item or attendee to get the sequence info
      *                                                from.
      * @return {Number}                             The sequence number
rename from calendar/base/modules/calL10NUtils.jsm
rename to calendar/base/modules/utils/calL10NUtils.jsm
--- a/calendar/base/modules/calL10NUtils.jsm
+++ b/calendar/base/modules/utils/calL10NUtils.jsm
@@ -1,14 +1,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
+/*
+ * Localization and locale functions
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.l10n namespace.
+
 this.EXPORTED_SYMBOLS = ["call10n"]; /* exported call10n */
 
 /**
  * Gets the value of a string in a .properties file.
  *
  * @param {String} aComponent       Stringbundle component name
  * @param {String} aBundleName      The name of the properties file
  * @param {String} aStringName      The name of the string within the properties file
rename from calendar/base/modules/calPrintUtils.jsm
rename to calendar/base/modules/utils/calPrintUtils.jsm
--- a/calendar/base/modules/calPrintUtils.jsm
+++ b/calendar/base/modules/utils/calPrintUtils.jsm
@@ -2,16 +2,23 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
+/*
+ * Helpers for printing and print preparation
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.print namespace.
+
 this.EXPORTED_SYMBOLS = ["calprint"]; /* exported calprint */
 
 var calprint = {
     /**
      * Returns a simple key in the format YYYY-MM-DD for use in the table of
      * dates to day boxes
      *
      * @param dt    The date to translate
rename from calendar/base/modules/calProviderUtils.jsm
rename to calendar/base/modules/utils/calProviderUtils.jsm
--- a/calendar/base/modules/calProviderUtils.jsm
+++ b/calendar/base/modules/utils/calProviderUtils.jsm
@@ -6,19 +6,22 @@ ChromeUtils.import("resource:///modules/
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
 /*
- * Provider helper code
+ * Helpers and base class for calendar providers
  */
 
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.provider namespace.
+
 this.EXPORTED_SYMBOLS = ["calprovider"]; /* exported calprovider */
 
 var calprovider = {
     /**
      * Prepare HTTP channel with standard request headers and upload data/content-type if needed.
      *
      * @param {nsIURI} aUri                                     Channel Uri, will only be used for a
      *                                                            new channel.
rename from calendar/base/modules/calUnifinderUtils.jsm
rename to calendar/base/modules/utils/calUnifinderUtils.jsm
--- a/calendar/base/modules/calUnifinderUtils.jsm
+++ b/calendar/base/modules/utils/calUnifinderUtils.jsm
@@ -2,16 +2,23 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource:///modules/mailServices.js");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
+/*
+ * Helpers for the unifinder
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.unifinder namespace.
+
 this.EXPORTED_SYMBOLS = ["calunifinder"]; /* exported calunifinder */
 
 var calunifinder = {
     /**
      * Retrieves the value that is used for comparison for the item with the given
      * property.
      *
      * @param {calIItemBaes} aItem      The item to retrieve the sort key for
rename from calendar/base/modules/calViewUtils.jsm
rename to calendar/base/modules/utils/calViewUtils.jsm
--- a/calendar/base/modules/calViewUtils.jsm
+++ b/calendar/base/modules/utils/calViewUtils.jsm
@@ -1,16 +1,23 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
+/*
+ * View and DOM related helper functions
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.view namespace.
+
 this.EXPORTED_SYMBOLS = ["calview"]; /* exported calview */
 
 var calview = {
     /**
      * Checks if the mousepointer of an event resides over a XULBox during an event
      *
      * @param aMouseEvent   The event eg. a 'mouseout' or 'mousedown' event
      * @param aXULBox       The xul element
rename from calendar/base/modules/calWindowUtils.jsm
rename to calendar/base/modules/utils/calWindowUtils.jsm
--- a/calendar/base/modules/calWindowUtils.jsm
+++ b/calendar/base/modules/utils/calWindowUtils.jsm
@@ -1,15 +1,22 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
+/*
+ * Calendar window helpers, e.g. to open our dialogs
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.window namespace.
+
 this.EXPORTED_SYMBOLS = ["calwindow"]; /* exported calwindow */
 
 var calwindow = {
     /**
      * Opens the Create Calendar wizard
      *
      * @param aWindow    the window to open the dialog on, or null for the main calendar window
      * @param aCallback  a function to be performed after calendar creation
rename from calendar/base/modules/calXMLUtils.jsm
rename to calendar/base/modules/utils/calXMLUtils.jsm
--- a/calendar/base/modules/calXMLUtils.jsm
+++ b/calendar/base/modules/utils/calXMLUtils.jsm
@@ -1,20 +1,25 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/** Helper functions for parsing and serializing XML */
-
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
 Components.utils.importGlobalProperties(["XMLHttpRequest"]);
 
+/*
+ * Helper functions for parsing and serializing XML
+ */
+
+// NOTE: This module should not be loaded directly, it is available when
+// including calUtils.jsm under the cal.xml namespace.
+
 this.EXPORTED_SYMBOLS = ["calxml"]; /* exported calxml */
 
 var calxml = {
     /**
      * Evaluate an XPath query for the given node. Be careful with the return value
      * here, as it may be:
      *
      * - null, if there are no results
deleted file mode 100644
--- a/calendar/base/src/calUtils.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* Goodbye, calUtils.js. You've been a great friend over the years. We'll miss
- * you and wish you all the best for your departure in one of the next
- * changesets. */
--- a/calendar/base/src/moz.build
+++ b/calendar/base/src/moz.build
@@ -41,17 +41,16 @@ FINAL_TARGET_FILES['calendar-js'] += [
     'calProtocolHandler.js',
     'calRecurrenceDate.js',
     'calRecurrenceInfo.js',
     'calRelation.js',
     'calStartupService.js',
     'calTimezone.js',
     'calTodo.js',
     'calTransactionManager.js',
-    'calUtils.js',
     'calWeekInfoService.js',
 ]
 
 with Files('**'):
     BUG_COMPONENT = ('Calendar', 'Internal Components')
 
 with Files('calAlarm*'):
     BUG_COMPONENT = ('Calendar', 'Alarms')
--- a/calendar/providers/gdata/modules/calUtilsShim.jsm
+++ b/calendar/providers/gdata/modules/calUtilsShim.jsm
@@ -1,17 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 // Load these modules, which will inject into calUtils.jsm on old versions, and
-// just load an unused symbol on newer versions.
-ChromeUtils.import("resource://calendar/modules/calAsyncUtils.jsm");
+// silently fail on newer versions.
+try {
+    ChromeUtils.import("resource://calendar/modules/calAsyncUtils.jsm");
+} catch (e) {}
 
 this.EXPORTED_SYMBOLS = ["cal"];
 
 if (!cal.dtz) {
     cal.dtz = {
         get defaultTimezone() { return cal.calendarDefaultTimezone(); },
         get floating() { return cal.floating(); },
         get UTC() { return cal.UTC(); },