Bug 686273 - Subscribed WCAP calendars not appearing (do not use "cal" as variable name because it shadows the namespace "cal"), r=philipp, a=philipp COMM70_20110911_RELBRANCH CALENDAR_1_0b6_BUILD4
authorStefan Sitter <ssitter@gmail.com>
Tue, 13 Sep 2011 22:07:16 +0200
branchCOMM70_20110911_RELBRANCH
changeset 10651 aa39967c4ace4e4018134125a198477f2f2ce9b4
parent 10650 43011b973467688e82e4df9f7ab46a9977e0ff5c
child 10652 37671eb00c900046515bb679abdd23bf8ecf8db0
push id6
push userbienvenu@nventure.com
push dateWed, 16 May 2012 22:24:51 +0000
treeherdertry-comm-central@ac395aea3008 [default view] [failures only]
reviewersphilipp, philipp
bugs686273
Bug 686273 - Subscribed WCAP calendars not appearing (do not use "cal" as variable name because it shadows the namespace "cal"), r=philipp, a=philipp
calendar/base/content/calendar-common-sets.js
calendar/base/content/calendar-item-editing.js
calendar/base/content/calendar-multiday-view.xml
calendar/base/content/dialogs/calendar-event-dialog.js
calendar/base/content/dialogs/calendar-migration-dialog.js
calendar/base/content/dialogs/calendar-subscriptions-dialog.js
calendar/base/content/dialogs/chooseCalendarDialog.xul
calendar/base/src/calCalendarManager.js
calendar/base/src/calItemBase.js
calendar/base/src/calTransactionManager.js
calendar/providers/storage/calStorageCalendar.js
calendar/providers/wcap/calWcapCalendar.js
calendar/providers/wcap/calWcapCalendarItems.js
calendar/providers/wcap/calWcapSession.js
calendar/resources/content/calendar.js
calendar/resources/content/publish.js
calendar/test/unit/head_consts.js
calendar/test/unit/test_providers.js
--- a/calendar/base/content/calendar-common-sets.js
+++ b/calendar/base/content/calendar-common-sets.js
@@ -569,20 +569,20 @@ var calendarController = {
     },
 
     /**
      * Returns a boolean indicating that all local calendars are readonly
      */
     get all_local_calendars_readonly() {
         // We might want to speed this part up by keeping track of this in the
         // calendar manager.
-        var cals = getCalendarManager().getCalendars({});
-        var count = cals.length;
-        for each (var cal in cals) {
-            if (!isCalendarWritable(cal)) {
+        var calendars = getCalendarManager().getCalendars({});
+        var count = calendars.length;
+        for each (var calendar in calendars) {
+            if (!isCalendarWritable(calendar)) {
                 count--;
             }
         }
         return (count == 0);
     },
 
     /**
      * Returns a boolean indicating if the items selected in the current view
@@ -598,37 +598,37 @@ var calendarController = {
     /**
      * Returns a boolean indicating that at least one of the calendars supports
      * tasks.
      */
     get calendars_support_tasks() {
         // XXX We might want to cache this
         var calendars = getCalendarManager().getCalendars({});
 
-        for each (var cal in calendars) {
-            if (isCalendarWritable(cal) &&
-                cal.getProperty("capabilities.tasks.supported") !== false) {
+        for each (var calendar in calendars) {
+            if (isCalendarWritable(calendar) &&
+                calendar.getProperty("capabilities.tasks.supported") !== false) {
                 return true;
             }
         }
         return false;
     },
 
 
     /**
      * Returns a boolean indicating that at least one of the calendars supports
      * events.
      */
     get calendars_support_events() {
         // XXX We might want to cache this
         var calendars = getCalendarManager().getCalendars({});
 
-        for each (var cal in calendars) {
-            if (isCalendarWritable(cal) &&
-                cal.getProperty("capabilities.events.supported") !== false) {
+        for each (var calendar in calendars) {
+            if (isCalendarWritable(calendar) &&
+                calendar.getProperty("capabilities.events.supported") !== false) {
                 return true;
             }
         }
         return false;
     },
 
     /**
      * Returns a boolean indicating that tasks are selected.
--- a/calendar/base/content/calendar-item-editing.js
+++ b/calendar/base/content/calendar-item-editing.js
@@ -243,22 +243,22 @@ function openEventDialog(calendarItem, c
     // Set up some defaults
     mode = mode || "new";
     calendar = calendar || getSelectedCalendar();
     var calendars = getCalendarManager().getCalendars({});
     calendars = calendars.filter(isCalendarWritable);
 
     var isItemSupported;
     if (isToDo(calendarItem)) {
-        isItemSupported = function isTodoSupported(cal) {
-            return (cal.getProperty("capabilities.tasks.supported") !== false);
+        isItemSupported = function isTodoSupported(aCalendar) {
+            return (aCalendar.getProperty("capabilities.tasks.supported") !== false);
         };
     } else if (isEvent(calendarItem)) {
-        isItemSupported = function isEventSupported(cal) {
-            return (cal.getProperty("capabilities.events.supported") !== false);
+        isItemSupported = function isEventSupported(aCalendar) {
+            return (aCalendar.getProperty("capabilities.events.supported") !== false);
         };
     }
 
     // Filter out calendars that don't support the given calendar item
     calendars = calendars.filter(isItemSupported);
 
     if (mode == "new" && calendars.length < 1 &&
         (!isCalendarWritable(calendar) || !isItemSupported(calendar))) {
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -1928,19 +1928,19 @@
       <!-- mouse down handler, in empty event column regions.  Starts sweeping out a new
          - event.
         -->
       <handler event="mousedown"><![CDATA[
         // select this column
         this.calendarView.selectedDay = this.mDate;
 
         // If the selected calendar is readOnly, we don't want any sweeping.
-        let cal = getSelectedCalendar();
-        if (!isCalendarWritable(cal) ||
-            cal.getProperty("capabilities.events.supported") === false) {
+        let calendar = getSelectedCalendar();
+        if (!isCalendarWritable(calendar) ||
+            calendar.getProperty("capabilities.events.supported") === false) {
             return;
         }
 
         // Only start sweeping out an event if the left button was clicked
         if (event.button != 0) {
             return;
         }
 
--- a/calendar/base/content/dialogs/calendar-event-dialog.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog.js
@@ -60,23 +60,23 @@ var gConfirmCancel = true;
 var gLastRepeatSelection = 0;
 var gIgnoreUpdate = false;
 var gShowTimeAs = null;
 
 /**
  * Checks if the given calendar supports notifying attendees. The item is needed
  * since calendars may support notifications for only some types of items.
  *
- * @param calendar    The calendar to check
+ * @param aCalendar   The calendar to check
  * @param item        The item to check support for.
  */
-function canNotifyAttendees(calendar, item) {
+function canNotifyAttendees(aCalendar, item) {
     try {
-        var cal = calendar.QueryInterface(Components.interfaces.calISchedulingSupport);
-        return (cal.canNotify("REQUEST", item) && cal.canNotify("CANCEL", item));
+        var calendar = aCalendar.QueryInterface(Components.interfaces.calISchedulingSupport);
+        return (calendar.canNotify("REQUEST", item) && calendar.canNotify("CANCEL", item));
     } catch (exc) {
         return false;
     }
 }
 
 /**
  * Update menu items that rely on focus
  */
--- a/calendar/base/content/dialogs/calendar-migration-dialog.js
+++ b/calendar/base/content/dialogs/calendar-migration-dialog.js
@@ -305,35 +305,35 @@ var gDataMigrator = {
                 return aNode.getAttributeNS("http://home.netscape.com/NC-rdf#",
                                             aAttr);
             }
 
             const RDFNS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
             var nodes = aDoc.getElementsByTagNameNS(RDFNS, "Description");
             LOG("nodes: " + nodes.length);
             for (var i = 0; i < nodes.length; i++) {
-                LOG("Beginning cal node");
-                var cal;
+                LOG("Beginning calendar node");
+                var calendar;
                 var node = nodes[i];
                 if (getRDFAttr(node, "remote") == "false") {
                     LOG("not remote");
                     var localFile = Components.classes["@mozilla.org/file/local;1"]
                                     .createInstance(Components.interfaces.nsILocalFile);
                     localFile.initWithPath(getRDFAttr(node, "path"));
-                    cal = gDataMigrator.importICSToStorage(localFile);
+                    calendar = gDataMigrator.importICSToStorage(localFile);
                 } else {
                     // Remote subscription
                     // XXX check for duplicates
                     var url = makeURL(getRDFAttr(node, "remotePath"));
-                    cal = calManager.createCalendar("ics", url);
+                    calendar = calManager.createCalendar("ics", url);
                 }
-                cal.name = getRDFAttr(node, "name");
-                cal.setProperty("color", getRDFAttr(node, "color"));
-                calManager.registerCalendar(cal);
-                getCompositeCalendar().addCalendar(cal);
+                calendar.name = getRDFAttr(node, "name");
+                calendar.setProperty("color", getRDFAttr(node, "color"));
+                calManager.registerCalendar(calendar);
+                getCompositeCalendar().addCalendar(calendar);
             }
             aCallback();
         }
 
         var migrators = [];
 
         // Look in our current profile directory, in case we're upgrading in
         // place
@@ -449,21 +449,21 @@ var gDataMigrator = {
                 var stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
                              .createInstance(Components.interfaces.nsIFileOutputStream);
                 stream.init(tempFile, 0x2A, parseInt("0600", 8), 0);
                 var convStream = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
                                 .createInstance(Components.interfaces.nsIConverterOutputStream);
                 convStream.init(stream, 'UTF-8', 0, 0x0000);
                 convStream.writeString(str);
 
-                var cal = gDataMigrator.importICSToStorage(tempFile);
-                cal.name = "iCalendar"+i;
+                var calendar = gDataMigrator.importICSToStorage(tempFile);
+                calendar.name = "iCalendar"+i;
                 i++;
-                calManager.registerCalendar(cal);
-                getCompositeCalendar().addCalendar(cal);
+                calManager.registerCalendar(calendar);
+                getCompositeCalendar().addCalendar(calendar);
             }
             LOG("icalMig making callback");
             aCallback();
         }
         var profileDir = this.dirService.get("ProfD", Components.interfaces.nsILocalFile);
         var icalSpec = profileDir.path;
         var icalFile;
         if (cal.isSunbird()) {
@@ -500,20 +500,20 @@ var gDataMigrator = {
      * stored there.
      */
     checkEvolution: function gdm_evolution() {
         function evoMigrate(aDataDir, aCallback) {
             var i = 1;
             function evoDataMigrate(dataStore) {
                 LOG("Migrating evolution data file in " + dataStore.path);
                 if (dataStore.exists()) {
-                    var cal = gDataMigrator.importICSToStorage(dataStore);
-                    cal.name = "Evolution " + (i++);
-                    calManager.registerCalendar(cal);
-                    getCompositeCalendar().addCalendar(cal);
+                    var calendar = gDataMigrator.importICSToStorage(dataStore);
+                    calendar.name = "Evolution " + (i++);
+                    calManager.registerCalendar(calendar);
+                    getCompositeCalendar().addCalendar(calendar);
                 }
                 return dataStore.exists();
             }
 
             var calManager = getCalendarManager();
             var dirs = aDataDir.directoryEntries;
             while (dirs.hasMoreElements()) {
                 var dataDir = dirs.getNext().QueryInterface(Components.interfaces.nsIFile);
@@ -534,17 +534,17 @@ var gDataMigrator = {
 
     /**
      * Creates and registers a storage calendar and imports the given ics file into it.
      *
      * @param icsFile     The nsI(Local)File to import.
      */
     importICSToStorage: function migrateIcsStorage(icsFile) {
         const uri = 'moz-storage-calendar://';
-        let cal = cal.getCalendarManager().createCalendar("storage", makeURL(uri));
+        let calendar = cal.getCalendarManager().createCalendar("storage", makeURL(uri));
         let icsImporter = Components.classes["@mozilla.org/calendar/import;1?type=ics"]
                                     .getService(Components.interfaces.calIImporter);
 
         let inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
                                     .createInstance(Components.interfaces.nsIFileInputStream);
         let items = [];
 
         try {
@@ -558,19 +558,19 @@ var gDataMigrator = {
                 default:
                     showError(calGetString("calendar", "unableToRead") + icsFile.path + "\n"+ ex);
             }
         } finally {
            inputStream.close();
         }
 
         // Defined in import-export.js
-        putItemsIntoCal(cal, items);
+        putItemsIntoCal(calendar, items);
 
-        return cal;
+        return calendar;
     },
 
     /**
      * Helper functions for getting the profile directory of various MozApps
      * (Getting the profile dir is way harder than it should be.)
      *
      * Sunbird:
      *     Unix:     ~jdoe/.mozilla/sunbird/
--- a/calendar/base/content/dialogs/calendar-subscriptions-dialog.js
+++ b/calendar/base/content/dialogs/calendar-subscriptions-dialog.js
@@ -125,18 +125,18 @@ function onCancel() {
  */
 function onSearch() {
     cancelPendingSearchOperation();
 
     var richListBox = document.getElementById("subscriptions-listbox");
     richListBox.clear();
 
     var registeredCals = {};
-    for each (var cal in getCalendarManager().getCalendars({})) {
-        registeredCals[cal.id] = true;
+    for each (var calendar in getCalendarManager().getCalendars({})) {
+        registeredCals[calendar.id] = true;
     }
 
     var opListener = {
         onResult: function search_onResult(op, result) {
             var richListBox = document.getElementById("subscriptions-listbox");
             if (result) {
                 for each (var calendar in result) {
                     richListBox.addCalendar(calendar, registeredCals[calendar.id]);
--- a/calendar/base/content/dialogs/chooseCalendarDialog.xul
+++ b/calendar/base/content/dialogs/chooseCalendarDialog.xul
@@ -67,36 +67,36 @@
             if (window.arguments[0].calendars) {
                 calendars = window.arguments[0].calendars;
             } else {
                 calendars = calendarManager.getCalendars({});
             }
             calendars = sortCalendarArray(calendars);
 
             for (var i = 0; i < calendars.length; i++) {
-                var cal = calendars[i];
+                var calendar = calendars[i];
                 var listItem = document.createElement("listitem");
 
                 var colorCell = document.createElement("listcell");
                 try {
-                    var calColor = cal.getProperty('color');
+                    var calColor = calendar.getProperty('color');
                     colorCell.style.background = calColor || "#a8c2e1";
                 } catch(e) {} 
                 listItem.appendChild(colorCell);
 
                 var nameCell = document.createElement("listcell");
-                nameCell.setAttribute("label", cal.name);
+                nameCell.setAttribute("label", calendar.name);
                 listItem.appendChild(nameCell);
 
-                listItem.calendar = cal;
+                listItem.calendar = calendar;
                 listbox.appendChild(listItem);
                 listItem.setAttribute("flex","1");
 
                 // Select the default calendar of the opening calendar window.
-                if (cal.id == composite.defaultCalendar.id) {
+                if (calendar.id == composite.defaultCalendar.id) {
                     selectedIndex = i;
                 }
             }
             document.getElementById("prompt").value = window.arguments[0].promptText;
 
             if (calendars.length) {
                 listbox.ensureIndexIsVisible(selectedIndex);
                 var selItem = listbox.getItemAtIndex(selectedIndex);
--- a/calendar/base/src/calCalendarManager.js
+++ b/calendar/base/src/calCalendarManager.js
@@ -101,18 +101,18 @@ var gCalendarManagerAddonListener = {
         }
     },
 
     queryUninstallProvider: function(aAddon) {
         const uri = "chrome://calendar/content/calendar-providerUninstall-dialog.xul";
         const features = "chrome,titlebar,resizable,modal";
         let calMgr = cal.getCalendarManager();
         let affectedCalendars =
-            [ cal for each (cal in calMgr.getCalendars({}))
-              if (cal.providerID == aAddon.id) ];
+            [ calendar for each (calendar in calMgr.getCalendars({}))
+              if (calendar.providerID == aAddon.id) ];
         if (!affectedCalendars.length) {
             // If no calendars are affected, then everything is fine.
             return true;
         }
 
         let args = { shouldUninstall: false, extension: aAddon };
 
         // Now find a window. The best choice would be the most recent
@@ -192,18 +192,18 @@ calCalendarManager.prototype = {
 
         Services.obs.addObserver(this, "http-on-modify-request", false);
         Services.obs.addObserver(this, "http-on-examine-response", false);
 
         aCompleteListener.onResult(null, Components.results.NS_OK);
     },
 
     shutdown: function ccm_shutdown(aCompleteListener) {
-        for each (var cal in this.mCache) {
-            cal.removeObserver(this.mCalObservers[cal.id]);
+        for each (var calendar in this.mCache) {
+            calendar.removeObserver(this.mCalObservers[calendar.id]);
         }
 
         this.cleanupOfflineObservers();
 
         Services.obs.removeObserver(this, "profile-after-change");
         Services.obs.removeObserver(this, "profile-before-change");
         Services.obs.removeObserver(this, "http-on-modify-request");
         Services.obs.removeObserver(this, "http-on-examine-response");
@@ -245,19 +245,19 @@ calCalendarManager.prototype = {
                 this.startup();
                 break;
             case "profile-before-change":
                 this.shutdown();
                 break;
             case "timer-callback":
                 // Refresh all the calendars that can be refreshed.
                 var cals = this.getCalendars({});
-                for each (var cal in cals) {
-                    if (!cal.getProperty("disabled") && cal.canRefresh) {
-                        cal.refresh();
+                for each (var calendar in cals) {
+                    if (!calendar.getProperty("disabled") && calendar.canRefresh) {
+                        calendar.refresh();
                     }
                 }
                 break;
             case "network:offline-status-changed":
                 for each (var calendar in this.mCache) {
                     if (calendar instanceof calCachedCalendar) {
                         calendar.onOfflineStatusChanged(aData == "offline");
                     }
@@ -776,18 +776,18 @@ calCalendarManager.prototype = {
                 Components.utils.reportError("error purging calendar: " + e);
             }
         }
     },
 
     getCalendars: function cmgr_getCalendars(count) {
         this.assureCache();
         var calendars = [];
-        for each (var cal in this.mCache) {
-            calendars.push(cal);
+        for each (var calendar in this.mCache) {
+            calendars.push(calendar);
         }
         count.value = calendars.length;
         return calendars;
     },
 
     assureCache: function cmgr_assureCache() {
         if (!this.mCache) {
             this.mCache = {};
--- a/calendar/base/src/calItemBase.js
+++ b/calendar/base/src/calItemBase.js
@@ -86,21 +86,21 @@ calItemBase.prototype = {
     /**
      * @see calIItemBase
      */
 
     // readonly attribute AUTF8String hashId;
     get hashId() {
         if (this.mHashId === null) {
             var rid = this.recurrenceId;
-            var cal = this.calendar;
+            var calendar = this.calendar;
             // some unused delim character:
             this.mHashId = [encodeURIComponent(this.id),
                             rid ? rid.getInTimezone(UTC()).icalString : "",
-                            cal ? encodeURIComponent(cal.id) : ""].join("#");
+                            calendar ? encodeURIComponent(calendar.id) : ""].join("#");
         }
         return this.mHashId;
     },
 
     // attribute AUTF8String id;
     get id() {
         return this.getProperty("UID");
     },
--- a/calendar/base/src/calTransactionManager.js
+++ b/calendar/base/src/calTransactionManager.js
@@ -92,18 +92,18 @@ calTransactionManager.prototype = {
     },
 
     checkWritable: function cTM_checkWritable(transaction) {
         if (transaction) {
             transaction = transaction.wrappedJSObject;
             if (transaction) {
                 function checkItem(item) {
                     if (item) {
-                        var cal = item.calendar;
-                        if (cal && !isCalendarWritable(cal)) {
+                        var calendar = item.calendar;
+                        if (calendar && !isCalendarWritable(calendar)) {
                             return false;
                         }
                     }
                     return true;
                 }
 
                 if (!checkItem(transaction.mItem) ||
                     !checkItem(transaction.mOldItem)) {
--- a/calendar/providers/storage/calStorageCalendar.js
+++ b/calendar/providers/storage/calStorageCalendar.js
@@ -119,18 +119,18 @@ calStorageCalendar.prototype = {
     get displayName() {
         return calGetString("calendar", "storageName");
     },
 
     createCalendar: function cSC_createCalendar() {
         throw NS_ERROR_NOT_IMPLEMENTED;
     },
 
-    deleteCalendar: function cSC_deleteCalendar(cal, listener) {
-        cal = cal.wrappedJSObject;
+    deleteCalendar: function cSC_deleteCalendar(aCalendar, listener) {
+        aCalendar = aCalendar.wrappedJSObject;
 
         for each (let stmt in this.mDeleteEventExtras) {
             try {
                 this.prepareStatement(stmt);
                 stmt.execute();
             } finally {
                 stmt.reset();
             }
@@ -163,17 +163,17 @@ calStorageCalendar.prototype = {
             this.prepareStatement(this.mDeleteAllMetaData);
             this.mDeleteAllMetaData.execute();
         } finally {
             this.mDeleteAllMetaData.reset();
         }
 
         try {
             if (listener) {
-                listener.onDeleteCalendar(cal, Components.results.NS_OK, null);
+                listener.onDeleteCalendar(aCalendar, Components.results.NS_OK, null);
             }
         } catch (ex) {
             this.logError("error calling listener.onDeleteCalendar", ex);
         }
     },
 
     mRelaxedMode: undefined,
     get relaxedMode() {
--- a/calendar/providers/wcap/calWcapCalendar.js
+++ b/calendar/providers/wcap/calWcapCalendar.js
@@ -198,19 +198,19 @@ calWcapCalendar.prototype = {
     },
 
     setProperty: function calWcapCalendar_setProperty(aName, aValue) {
         switch (aName) {
             case "disabled":
                 if (this.isDefaultCalendar) {
                     // disabling/enabling the default calendar will enable/disable all calendars
                     // belonging to the same session:
-                    for each (var cal in this.session.getRegisteredCalendars()) {
-                        if (!cal.isDefaultCalendar) {
-                            cal.setProperty("disabled", aValue);
+                    for each (let calendar in this.session.getRegisteredCalendars()) {
+                        if (!calendar.isDefaultCalendar) {
+                            calendar.setProperty("disabled", aValue);
                         }
                     }
                 }
                 // fallthru intended
             default:
                 this.__proto__.__proto__.setProperty.apply(this, arguments);
                 break;
         }
--- a/calendar/providers/wcap/calWcapCalendarItems.js
+++ b/calendar/providers/wcap/calWcapCalendarItems.js
@@ -1378,17 +1378,17 @@ function calWcapCalendar_replayChangesOn
             }
         },
         log("replayChangesOn():\n\titemFilter=0x" + itemFilter.toString(0x10) +
             "\n\tdtFrom=" + getIcalUTC(dtFrom), this));
 
     try {
         var writeListener = {
             onGetResult: function() {},
-            onOperationComplete: function(cal, status, opType, id, detail) {
+            onOperationComplete: function(aCalendar, status, opType, id, detail) {
                 if (!Components.isSuccessCode(status)) {
                     request.execRespFunc(status); // any error on writing breaks whole operation
                 }
             }
         };
         var request = new calWcapRequest(
             function netFinishedRespFunc(err, data) {
                 var modifiedIds = {};
--- a/calendar/providers/wcap/calWcapSession.js
+++ b/calendar/providers/wcap/calWcapSession.js
@@ -556,23 +556,23 @@ calWcapSession.prototype = {
                                         cals[calId] = null;
                                         hasSubscriptions = true;
                                     }
                                 }
                             }
                         }
 
                         if (hasSubscriptions) {
-                            calprops_resp = function(cal) {
-                                if (cal.isDefaultCalendar) {
+                            calprops_resp = function(aCalendar) {
+                                if (aCalendar.isDefaultCalendar) {
                                     // tweak name:
-                                    cal.setProperty("name", cal.displayName);
+                                    aCalendar.setProperty("name", aCalendar.displayName);
                                 } else {
-                                    log("registering subscribed calendar: " + cal.calId, this_);
-                                    cal.getCalendarManager().registerCalendar(cal);
+                                    log("registering subscribed calendar: " + aCalendar.calId, this_);
+                                    cal.getCalendarManager().registerCalendar(aCalendar);
                                 }
                             }
                             // do only once:
                             defaultCal.setProperty("subscriptions_registered", true);
                         }
                     }
 
                     if (!defaultCal.getProperty("user_id")) { // nail once:
@@ -614,27 +614,27 @@ calWcapSession.prototype = {
             var nodeList = xml.getElementsByTagName("iCal");
             for (var i = 0; i < nodeList.length; ++i) {
                 try {
                     var node = nodeList.item(i);
                     checkWcapXmlErrno(node);
                     var ar = filterXmlNodes("X-NSCP-CALPROPS-RELATIVE-CALID", node);
                     if (ar.length > 0) {
                         var calId = ar[0];
-                        var cal = cals[calId];
-                        if (cal === null) {
-                            cal = new calWcapCalendar(this_);
+                        let calendar = cals[calId];
+                        if (calendar === null) {
+                            calendar = new calWcapCalendar(this_);
                             var uri = this_.uri.clone();
                             uri.path += ("?calid=" + encodeURIComponent(calId));
-                            cal.uri = uri;
+                            calendar.uri = uri;
                         }
-                        if (cal) {
-                            cal.m_calProps = node;
+                        if (calendar) {
+                            calendar.m_calProps = node;
                             if (respFunc) {
-                                respFunc(cal);
+                                respFunc(calendar);
                             }
                         }
                     }
 
                 } catch (exc) { // ignore but log any errors on subscribed calendars:
                     logError(exc, this_);
                 }
             }
@@ -664,25 +664,25 @@ calWcapSession.prototype = {
                     onResult: function search_onResult(request, result) {
                         try {
                             if (!Components.isSuccessCode(request.status)) {
                                 throw request.status;
                             }
                             if (result.length < 1) {
                                 throw Components.results.NS_ERROR_UNEXPECTED;
                             }
-                            for each (var cal in result) {
+                            for each (let calendar in result) {
                                 // user may have dangling users referred in his subscription list, so
                                 // retrieve each by each, don't break:
                                 try {
-                                    var calId = cal.calId;
+                                    var calId = calendar.calId;
                                     if ((cals[calId] !== undefined) && !retrievedCals[calId]) {
-                                        retrievedCals[calId] = cal;
+                                        retrievedCals[calId] = calendar;
                                         if (respFunc) {
-                                            respFunc(cal);
+                                            respFunc(calendar);
                                         }
                                     }
                                 }
                                 catch (exc) { // ignore but log any errors on subscribed calendars:
                                     logError(exc, this_);
                                 }
                             }
                         } catch (exc) { // ignore but log any errors on subscribed calendars:
@@ -951,26 +951,26 @@ calWcapSession.prototype = {
                     var nodeList = xml.getElementsByTagName("iCal");
                     for (var i = 0; i < nodeList.length; ++i) {
                         var node = nodeList.item(i);
                         try {
                             checkWcapXmlErrno(node);
                             var ar = filterXmlNodes("X-NSCP-CALPROPS-RELATIVE-CALID", node);
                             if (ar.length > 0) {
                                 var calId = ar[0];
-                                var cal = registeredCalendars[calId];
-                                if (cal) {
-                                    cal.m_calProps = node; // update calprops
+                                let calendar = registeredCalendars[calId];
+                                if (calendar) {
+                                    calendar.m_calProps = node; // update calprops
                                 } else {
-                                    cal = new calWcapCalendar(this_, node);
+                                    calendar = new calWcapCalendar(this_, node);
                                     var uri = this_.uri.clone();
                                     uri.path += ("?calid=" + encodeURIComponent(calId));
-                                    cal.uri = uri;
+                                    calendar.uri = uri;
                                 }
-                                ret.push(cal);
+                                ret.push(calendar);
                             }
                         } catch (exc) {
                             switch (getResultCode(exc)) {
                                 case calIWcapErrors.WCAP_NO_ERRNO: // workaround
                                 case calIWcapErrors.WCAP_ACCESS_DENIED_TO_CALENDAR:
                                     log("searchForCalendars_netResp() ignored error: " + errorToString(exc), this_);
                                     break;
                                 default:
@@ -1095,29 +1095,29 @@ calWcapSession.prototype = {
                                             .getService(Components.interfaces.nsIObserverService);
             observerService.removeObserver(this, "quit-application");
         }
     },
 
     // calICalendarManagerObserver:
 
     // called after the calendar is registered
-    onCalendarRegistered: function calWcapSession_onCalendarRegistered(cal) {
+    onCalendarRegistered: function calWcapSession_onCalendarRegistered(aCalendar) {
         try {
             // make sure the calendar belongs to this session:
-            if (this.belongsTo(cal)) {
+            if (this.belongsTo(aCalendar)) {
 
                 function assureDefault(pref, val) {
-                    if (cal.getProperty(pref) === null) {
-                        cal.setProperty(pref, val);
+                    if (aCalendar.getProperty(pref) === null) {
+                        aCalendar.setProperty(pref, val);
                     }
                 }
 
                 assureDefault("shared_context", this.m_contextId);
-                assureDefault("name", cal.name);
+                assureDefault("name", aCalendar.name);
 
                 const s_colors = ["#FFCCCC", "#FFCC99", "#FFFF99", "#FFFFCC", "#99FF99",
                                   "#99FFFF", "#CCFFFF", "#CCCCFF", "#FFCCFF", "#FF6666",
                                   "#FF9966", "#FFFF66", "#FFFF33", "#66FF99", "#33FFFF",
                                   "#66FFFF", "#9999FF", "#FF99FF", "#FF0000", "#FF9900",
                                   "#FFCC66", "#FFFF00", "#33FF33", "#66CCCC", "#33CCFF",
                                   "#6666CC", "#CC66CC", "#CC0000", "#FF6600", "#FFCC33",
                                   "#FFCC00", "#33CC00", "#00CCCC", "#3366FF", "#6633FF",
@@ -1130,22 +1130,22 @@ calWcapSession.prototype = {
                 assureDefault("color", s_colors[(new Date()).getUTCMilliseconds() % s_colors.length]);
             }
         } catch (exc) { // never break the listener chain
             this.notifyError(exc);
         }
     },
 
     // called before the unregister actually takes place
-    onCalendarUnregistering: function calWcapSession_onCalendarUnregistering(cal) {
+    onCalendarUnregistering: function calWcapSession_onCalendarUnregistering(aCalendar) {
         try {
             // make sure the calendar belongs to this session and is the default calendar,
             // then remove all subscribed calendars:
-            cal = this.belongsTo(cal);
-            if (cal && cal.isDefaultCalendar) {
+            aCalendar = this.belongsTo(aCalendar);
+            if (aCalendar && aCalendar.isDefaultCalendar) {
                 getFreeBusyService().removeProvider(this);
                 getCalendarSearchService().removeProvider(this);
                 var registeredCalendars = this.getRegisteredCalendars();
                 for each (var regCal in registeredCalendars) {
                     try {
                         if (!regCal.isDefaultCalendar) {
                             cal.getCalendarManager().unregisterCalendar(regCal);
                         }
@@ -1155,17 +1155,17 @@ calWcapSession.prototype = {
                 }
             }
         } catch (exc) { // never break the listener chain
             this.notifyError(exc);
         }
     },
 
     // called before the delete actually takes place
-    onCalendarDeleting: function calWcapSession_onCalendarDeleting(cal) {
+    onCalendarDeleting: function calWcapSession_onCalendarDeleting(aCalendar) {
     }
 };
 
 function confirmInsecureLogin(uri)
 {
     if (!confirmInsecureLogin.m_confirmedHttpLogins) {
         confirmInsecureLogin.m_confirmedHttpLogins = {};
         var confirmedHttpLogins = getPref("calendar.wcap.confirmed_http_logins", "");
--- a/calendar/resources/content/calendar.js
+++ b/calendar/resources/content/calendar.js
@@ -114,32 +114,32 @@ function handleCommandLine(aComLine) {
                 comLine.removeArguments(i, i);
             }
         }
     }
 
     //subscribe to all files in the calurl array
     for (var i = 0; i < calurl.length; i++) {
         var uri = comLine.resolveURI(calurl[i]);
-        var cal = getCalendarManager().createCalendar("ics", uri);
+        var calendar = getCalendarManager().createCalendar("ics", uri);
 
         // Strip ".ics" from filename for use as calendar name
         var fullPathRegEx = new RegExp("([^/:]+)[.]ics$");
         var path = uri.path;
         var prettyName = path.match(fullPathRegEx);
 
         var name;
         if (prettyName && prettyName.length >= 1) {
             name = decodeURIComponent(prettyName[1]);
         } else {
             name = calGetString("calendar", "untitledCalendarName");
         }
-        cal.name = name;
+        calendar.name = name;
 
-        getCalendarManager().registerCalendar(cal);
+        getCalendarManager().registerCalendar(calendar);
     }
 }
 
 /* Called at midnight to tell us to update the views and other ui bits */
 function refreshUIBits() {
     try {
         currentView().goToDay(now());
         refreshEventTree();
--- a/calendar/resources/content/publish.js
+++ b/calendar/resources/content/publish.js
@@ -61,28 +61,28 @@ function publishCalendarDataDialogRespon
     publishItemArray(currentView().getSelectedItems({}), 
                      CalendarPublishObject.remotePath, aProgressDialog);
 }
 
 /**
  * publishEntireCalendar
  * Show publish dialog, ask for URL and publish all items from the calendar.
  *
- * @param cal   (optional) The calendar that will be published. If ommitted
- *                         the user will be prompted to select a calendar.
+ * @param aCalendar   (optional) The calendar that will be published. If ommitted
+ *                               the user will be prompted to select a calendar.
  */
-function publishEntireCalendar(cal)
+function publishEntireCalendar(aCalendar)
 {
-    if (!cal) {
+    if (!aCalendar) {
         var count = new Object();
         var calendars = getCalendarManager().getCalendars(count);
 
         if (count.value == 1) {
             // Do not ask user for calendar if only one calendar exists
-            cal = calendars[0];
+            aCalendar = calendars[0];
         } else {
             // Ask user to select the calendar that should be published.
             // publishEntireCalendar() will be called again if OK is pressed
             // in the dialog and the selected calendar will be passed in. 
             // Therefore return after openDialog().
             var args = new Object();
             args.onOk = publishEntireCalendar;
             args.promptText = calGetString("calendar", "publishPrompt");
@@ -92,20 +92,20 @@ function publishEntireCalendar(cal)
         }
     }
 
     var args = new Object();
     var publishObject = new Object( );
 
     args.onOk =  self.publishEntireCalendarDialogResponse;
 
-    publishObject.calendar = cal;
+    publishObject.calendar = aCalendar;
 
     // restore the remote ics path preference from the calendar passed in
-    var remotePath = cal.getProperty("remote-ics-path");
+    var remotePath = aCalendar.getProperty("remote-ics-path");
     if (remotePath && remotePath.length && remotePath.length > 0) {
         publishObject.remotePath = remotePath;
     }
 
     args.publishObject = publishObject;
     openDialog("chrome://calendar/content/publishDialog.xul", "caPublishEvents", 
                "chrome,titlebar,modal,resizable", args );
 
--- a/calendar/test/unit/head_consts.js
+++ b/calendar/test/unit/head_consts.js
@@ -90,27 +90,27 @@ function createTodoFromIcalString(icalSt
     var todo = Cc["@mozilla.org/calendar/todo;1"]
                .createInstance(Ci.calITodo);
     todo.icalString = icalString;
     return todo;
 }
 
 function getMemoryCal() {
     // create memory calendar
-    var cal = Cc["@mozilla.org/calendar/calendar;1?type=memory"]
-              .createInstance(Ci.calISyncWriteCalendar);
+    var memoryCalendar = Cc["@mozilla.org/calendar/calendar;1?type=memory"]
+                         .createInstance(Ci.calISyncWriteCalendar);
 
     // remove existing items
-    var calendar = cal.QueryInterface(Ci.calICalendarProvider);
+    var calendar = memoryCalendar.QueryInterface(Ci.calICalendarProvider);
     try {
         calendar.deleteCalendar(calendar, null);
     } catch (e) {
         print("*** error purging calendar: " + e);
     }
-    return cal;
+    return memoryCalendar;
 }
 
 function getStorageCal() {
     var dirSvc = Cc["@mozilla.org/file/directory_service;1"]
                  .getService(Ci.nsIProperties);
     var db = dirSvc.get("TmpD", Ci.nsIFile);
     db.append("test_storage.sqlite");
 
--- a/calendar/test/unit/test_providers.js
+++ b/calendar/test/unit/test_providers.js
@@ -386,64 +386,64 @@ function run_test() {
             calendar.addItem(aItem, listener);
         }
     }
 
     testMetaData();
 }
 
 function testMetaData() {
-    function testMetaData_(cal) {
-        dump("testMetaData_() calendar type: " + cal.type + "\n");
+    function testMetaData_(aCalendar) {
+        dump("testMetaData_() calendar type: " + aCalendar.type + "\n");
         var event1 = createEventFromIcalString("BEGIN:VEVENT\n" +
                                                "DTSTART;VALUE=DATE:20020402\n" +
                                                "END:VEVENT\n");
 
         event1.id = "item1";
-        cal.addItem(event1, null);
-        cal.setMetaData("item1", "meta1");
-        do_check_eq(cal.getMetaData("item1"), "meta1");
-        do_check_eq(cal.getMetaData("unknown"), null);
+        aCalendar.addItem(event1, null);
+        aCalendar.setMetaData("item1", "meta1");
+        do_check_eq(aCalendar.getMetaData("item1"), "meta1");
+        do_check_eq(aCalendar.getMetaData("unknown"), null);
 
         var event2 = event1.clone();
         event2.id = "item2";
-        cal.addItem(event2, null);
-        cal.setMetaData("item2", "meta2-");
-        do_check_eq(cal.getMetaData("item2"), "meta2-");
+        aCalendar.addItem(event2, null);
+        aCalendar.setMetaData("item2", "meta2-");
+        do_check_eq(aCalendar.getMetaData("item2"), "meta2-");
 
-        cal.setMetaData("item2", "meta2");
-        do_check_eq(cal.getMetaData("item2"), "meta2");
+        aCalendar.setMetaData("item2", "meta2");
+        do_check_eq(aCalendar.getMetaData("item2"), "meta2");
 
         var count = {};
         var ids = {};
         var values = {};
-        cal.getAllMetaData(count, ids, values);
+        aCalendar.getAllMetaData(count, ids, values);
         do_check_eq(count.value, 2);
         do_check_true(ids.value[0] ==  "item1" || ids.value[1] == "item1");
         do_check_true(ids.value[0] ==  "item2" || ids.value[1] == "item2");
         do_check_true(values.value[0] ==  "meta1" || values.value[1] == "meta1");
         do_check_true(values.value[0] ==  "meta2" || values.value[1] == "meta2");
 
-        cal.deleteItem(event1, null);
-        do_check_eq(cal.getMetaData("item1"), null);
-        cal.getAllMetaData(count, ids, values);
+        aCalendar.deleteItem(event1, null);
+        do_check_eq(aCalendar.getMetaData("item1"), null);
+        aCalendar.getAllMetaData(count, ids, values);
         do_check_eq(count.value, 1);
         do_check_true(ids.value[0] ==  "item2");
         do_check_true(values.value[0] ==  "meta2");
 
-        cal.deleteMetaData("item2");
-        do_check_eq(cal.getMetaData("item2"), null);
-        cal.getAllMetaData(count, ids, values);
+        aCalendar.deleteMetaData("item2");
+        do_check_eq(aCalendar.getMetaData("item2"), null);
+        aCalendar.getAllMetaData(count, ids, values);
         do_check_eq(count.value, 0);
 
-        cal.setMetaData("item2", "meta2");
-        do_check_eq(cal.getMetaData("item2"), "meta2");
-        cal.QueryInterface(Ci.calICalendarProvider).deleteCalendar(cal, null);
-        do_check_eq(cal.getMetaData("item2"), null);
-        cal.getAllMetaData(count, ids, values);
+        aCalendar.setMetaData("item2", "meta2");
+        do_check_eq(aCalendar.getMetaData("item2"), "meta2");
+        aCalendar.QueryInterface(Ci.calICalendarProvider).deleteCalendar(aCalendar, null);
+        do_check_eq(aCalendar.getMetaData("item2"), null);
+        aCalendar.getAllMetaData(count, ids, values);
         do_check_eq(count.value, 0);
 
-        cal.deleteMetaData("unknown"); // check graceful return
+        aCalendar.deleteMetaData("unknown"); // check graceful return
     }
 
     testMetaData_(getMemoryCal());
     testMetaData_(getStorageCal());
 }