Bug 1442985 - Extend eslint coverage for calendar. r=philipp
authoreslint <eslint@bugzilla.kewis.ch>
Mon, 30 Apr 2018 10:32:18 +0200
changeset 32237 0698244578e94f305e64cb31e484eb969b79c3cf
parent 32236 acc624aeb11f1ce299fbd9465d9628b38077b6d0
child 32238 6361dc5b5b057f160e05e98206997d015cd90753
push id385
push userclokep@gmail.com
push dateTue, 04 Sep 2018 23:26:14 +0000
reviewersphilipp
bugs1442985
Bug 1442985 - Extend eslint coverage for calendar. r=philipp This patch was created by makemyday@gmx-topmail.de - I just borrowed Philipp's eslint user for more transparency when using blame
.eslintignore
calendar/base/content/calendar-dnd-listener.js
calendar/base/content/dialogs/calendar-migration-dialog.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -31,12 +31,8 @@ suite/**
 # calendar/ exclusions
 
 # prefs files
 calendar/lightning/content/lightning.js
 calendar/locales/en-US/lightning-l10n.js
 
 # third party library
 calendar/base/modules/ical.js
-
-# preprocessed files
-calendar/base/content/dialogs/calendar-migration-dialog.js
-calendar/base/content/calendar-dnd-listener.js
--- a/calendar/base/content/calendar-dnd-listener.js
+++ b/calendar/base/content/calendar-dnd-listener.js
@@ -3,38 +3,43 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
+/* exported invokeEventDragSession, calendarViewDNDObserver,
+ *          calendarMailButtonDNDObserver, calendarCalendarButtonDNDObserver,
+ *          calendarTaskButtonDNDObserver
+ */
+
 var itemConversion = {
 
     /**
      * Converts an email message to a calendar item.
      *
      * @param aItem     The target calIItemBase.
      * @param aMessage  The nsIMsgHdr to convert from.
      */
-    calendarItemFromMessage: function iC_calendarItemFromMessage(aItem, aMsgHdr) {
+    calendarItemFromMessage: function(aItem, aMsgHdr) {
         let msgFolder = aMsgHdr.folder;
         let msgUri = msgFolder.getUriForMsg(aMsgHdr);
 
         aItem.calendar = getSelectedCalendar();
         aItem.title = aMsgHdr.mime2DecodedSubject;
 
         cal.dtz.setDefaultStartEndHour(aItem);
         cal.alarms.setDefaultValues(aItem);
 
-        let messenger = Components.classes["@mozilla.org/messenger;1"]
-                                  .createInstance(Components.interfaces.nsIMessenger);
-        let streamListener = Components.classes["@mozilla.org/network/sync-stream-listener;1"]
-                                       .createInstance(Components.interfaces.nsISyncStreamListener);
+        let messenger = Cc["@mozilla.org/messenger;1"]
+                        .createInstance(Ci.nsIMessenger);
+        let streamListener = Cc["@mozilla.org/network/sync-stream-listener;1"]
+                             .createInstance(Ci.nsISyncStreamListener);
         messenger.messageServiceFromURI(msgUri).streamMessage(msgUri,
                                                               streamListener,
                                                               null,
                                                               null,
                                                               false,
                                                               "",
                                                               false);
 
@@ -52,32 +57,33 @@ var itemConversion = {
     /**
      * Copy base item properties from aItem to aTarget. This includes properties
      * like title, location, description, priority, transparency,
      * attendees, categories, calendar, recurrence and possibly more.
      *
      * @param aItem     The item to copy from.
      * @param aTarget   the item to copy to.
      */
-    copyItemBase: function iC_copyItemBase(aItem, aTarget) {
-        const copyProps = ["SUMMARY", "LOCATION", "DESCRIPTION",
-                           "URL", "CLASS", "PRIORITY"];
+    copyItemBase: function(aItem, aTarget) {
+        const copyProps = [
+            "SUMMARY", "LOCATION", "DESCRIPTION", "URL", "CLASS", "PRIORITY"
+        ];
 
-        for (var prop of copyProps) {
+        for (let prop of copyProps) {
             aTarget.setProperty(prop, aItem.getProperty(prop));
         }
 
         // Attendees
-        var attendees = aItem.getAttendees({});
-        for (var attendee of attendees) {
+        let attendees = aItem.getAttendees({});
+        for (let attendee of attendees) {
             aTarget.addAttendee(attendee.clone());
         }
 
         // Categories
-        var categories = aItem.getCategories({});
+        let categories = aItem.getCategories({});
         aTarget.setCategories(categories.length, categories);
 
         // Organizer
         aTarget.organizer = (aItem.organizer ? aItem.organizer.clone() : null);
 
         // Calendar
         aTarget.calendar = getSelectedCalendar();
 
@@ -90,57 +96,57 @@ var itemConversion = {
 
     /**
      * Creates a task from the passed event. This function copies the base item
      * and a few event specific properties (dates, alarms, ...).
      *
      * @param aEvent    The event to copy from.
      * @return          The resulting task.
      */
-    taskFromEvent: function iC_taskFromEvent(aEvent) {
+    taskFromEvent: function(aEvent) {
         let item = cal.createTodo();
 
         this.copyItemBase(aEvent, item);
 
         // Dates and alarms
         if (!aEvent.startDate.isDate && !aEvent.endDate.isDate) {
             // Dates
             item.entryDate = aEvent.startDate.clone();
             item.dueDate = aEvent.endDate.clone();
 
             // Alarms
             for (let alarm of aEvent.getAlarms({})) {
                 item.addAlarm(alarm.clone());
             }
-            item.alarmLastAck = (aEvent.alarmLastAck ?
-                                 aEvent.alarmLastAck.clone() :
-                                 null);
+            item.alarmLastAck = aEvent.alarmLastAck
+                                ? aEvent.alarmLastAck.clone()
+                                : null;
         }
 
         // Map Status values
         let statusMap = {
-            "TENTATIVE": "NEEDS-ACTION",
-            "CONFIRMED": "IN-PROCESS",
-            "CANCELLED": "CANCELLED"
+            TENTATIVE: "NEEDS-ACTION",
+            CONFIRMED: "IN-PROCESS",
+            CANCELLED: "CANCELLED"
         };
         if (aEvent.getProperty("STATUS") in statusMap) {
             item.setProperty("STATUS", statusMap[aEvent.getProperty("STATUS")]);
         }
         return item;
     },
 
     /**
      * Creates an event from the passed task. This function copies the base item
      * and a few task specific properties (dates, alarms, ...). If the task has
      * no due date, the default event length is used.
      *
      * @param aTask     The task to copy from.
      * @return          The resulting event.
      */
-    eventFromTask: function iC_eventFromTask(aTask) {
+    eventFromTask: function(aTask) {
         let item = cal.createEvent();
 
         this.copyItemBase(aTask, item);
 
         // Dates and alarms
         item.startDate = aTask.entryDate;
         if (!item.startDate) {
             if (aTask.dueDate) {
@@ -158,19 +164,19 @@ var itemConversion = {
             item.endDate = item.startDate.clone();
             item.endDate.minute += Preferences.get("calendar.event.defaultlength", 60);
         }
 
         // Alarms
         for (let alarm of aTask.getAlarms({})) {
             item.addAlarm(alarm.clone());
         }
-        item.alarmLastAck = (aTask.alarmLastAck ?
-                             aTask.alarmLastAck.clone() :
-                             null);
+        item.alarmLastAck = aTask.alarmLastAck
+                            ? aTask.alarmLastAck.clone()
+                            : null;
 
         // Map Status values
         let statusMap = {
             "NEEDS-ACTION": "TENTATIVE",
             "COMPLETED": "CONFIRMED",
             "IN-PROCESS": "CONFIRMED",
             "CANCELLED": "CANCELLED"
         };
@@ -186,174 +192,181 @@ var itemConversion = {
  * @class calDNDBaseObserver
  */
 function calDNDBaseObserver() {
     cal.ASSERT(false, "Inheriting objects call calDNDBaseObserver!");
 }
 
 calDNDBaseObserver.prototype = {
     // initialize this class's members
-    initBase: function calDNDInitBase() {
+    initBase: function() {
     },
 
-    getSupportedFlavours: function calDNDGetFlavors() {
-        var flavourSet = new FlavourSet();
+    getSupportedFlavours: function() {
+        let flavourSet = new FlavourSet();
         flavourSet.appendFlavour("text/calendar");
         flavourSet.appendFlavour("text/x-moz-url");
         flavourSet.appendFlavour("text/x-moz-message");
         flavourSet.appendFlavour("text/unicode");
         flavourSet.appendFlavour("application/x-moz-file");
         return flavourSet;
     },
 
     /**
      * Action to take when dropping the event.
      */
 
-    onDrop: function calDNDDrop(aEvent, aTransferData, aDragSession) {
-        var transferable = Components.classes["@mozilla.org/widget/transferable;1"]
-                           .createInstance(Components.interfaces.nsITransferable);
+    onDrop: function(aEvent, aTransferData, aDragSession) {
+        let transferable = Cc["@mozilla.org/widget/transferable;1"]
+                           .createInstance(Ci.nsITransferable);
         transferable.init(null);
         transferable.addDataFlavor("text/calendar");
         transferable.addDataFlavor("text/x-moz-url");
         transferable.addDataFlavor("text/x-moz-message");
         transferable.addDataFlavor("text/unicode");
         transferable.addDataFlavor("application/x-moz-file");
 
         aDragSession.getData(transferable, 0);
 
-        var data = new Object();
-        var bestFlavor = new Object();
-        var length = new Object();
+        let data = {};
+        let bestFlavor = {};
+        let length = {};
         transferable.getAnyTransferData(bestFlavor, data, length);
 
         try {
-            data = data.value.QueryInterface(Components.interfaces.nsISupportsString);
+            data = data.value.QueryInterface(Ci.nsISupportsString);
         } catch (exc) {
             // we currently only supports strings:
             return;
         }
 
         // Treat unicode data with VEVENT in it as text/calendar
-        if (bestFlavor.value == "text/unicode" && data.toString().includes("VEVENT")) {
+        if (bestFlavor.value == "text/unicode" &&
+            data.toString().includes("VEVENT")) {
             bestFlavor.value = "text/calendar";
         }
 
-        var destCal = getSelectedCalendar();
         switch (bestFlavor.value) {
-            case "text/calendar":
+            case "text/calendar": {
                 if (AppConstants.platform == "macosx") {
                     // Mac likes to convert all \r to \n, we need to reverse this.
                     data = data.data.replace(/\n\n/g, "\r\n");
                 }
-                var parser = Components.classes["@mozilla.org/calendar/ics-parser;1"]
-                             .createInstance(Components.interfaces.calIIcsParser);
+                let parser = Cc["@mozilla.org/calendar/ics-parser;1"]
+                             .createInstance(Ci.calIIcsParser);
                 parser.parseString(data);
-                this.onDropItems(parser.getItems({}).concat(parser.getParentlessItems({})));
+                this.onDropItems(
+                    parser.getItems({}).concat(parser.getParentlessItems({}))
+                );
                 break;
-            case "text/unicode":
-                var droppedUrl = this.retrieveURLFromData(data, bestFlavor.value);
-                if (!droppedUrl)
+            }
+            case "text/unicode": {
+                let droppedUrl = this.retrieveURLFromData(data, bestFlavor.value);
+                if (!droppedUrl) {
                     return;
+                }
 
-                var url = Services.io.newURI(droppedUrl);
+                let url = Services.io.newURI(droppedUrl);
 
-                var localFileInstance = Components.classes["@mozilla.org/file/local;1"]
-                                        .createInstance(Components.interfaces.nsIFile);
+                let localFileInstance = Cc["@mozilla.org/file/local;1"]
+                                        .createInstance(Ci.nsIFile);
                 localFileInstance.initWithPath(url.pathQueryRef);
 
-                var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
-                                  .createInstance(Components.interfaces.nsIFileInputStream);
+                let inputStream = Cc["@mozilla.org/network/file-input-stream;1"]
+                                  .createInstance(Ci.nsIFileInputStream);
                 inputStream.init(localFileInstance,
                                  MODE_RDONLY,
                                  parseInt("0444", 8),
                                  {});
 
                 try {
-                    //XXX support csv
-                    var importer = Components.classes["@mozilla.org/calendar/import;1?type=ics"]
-                                   .getService(Components.interfaces.calIImporter);
-                    var items = importer.importFromStream(inputStream, {});
+                    // XXX support csv
+                    let importer = Cc["@mozilla.org/calendar/import;1?type=ics"]
+                                   .getService(Ci.calIImporter);
+                    let items = importer.importFromStream(inputStream, {});
                     this.onDropItems(items);
-                }
-                finally {
+                } finally {
                     inputStream.close();
                 }
 
                 break;
+            }
             case "application/x-moz-file-promise":
-            case "text/x-moz-url":
-                var uri = Services.io.newURI(data.toString());
-                var loader = Components.classes["@mozilla.org/network/unichar-stream-loader;1"]
-                             .createInstance(Components.interfaces.nsIUnicharStreamLoader);
-                var channel = Services.io.newChannelFromURI2(uri,
-                                                             null,
-                                                             Services.scriptSecurityManager.getSystemPrincipal(),
-                                                             null,
-                                                             Components.interfaces.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-                                                             Components.interfaces.nsIContentPolicy.TYPE_OTHER);
-                channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
+            case "text/x-moz-url": {
+                let uri = Services.io.newURI(data.toString());
+                let loader = Cc["@mozilla.org/network/unichar-stream-loader;1"]
+                             .createInstance(Ci.nsIUnicharStreamLoader);
+                let channel = Services.io.newChannelFromURI2(
+                    uri,
+                    null,
+                    Services.scriptSecurityManager.getSystemPrincipal(),
+                    null,
+                    Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
+                    Ci.nsIContentPolicy.TYPE_OTHER
+                );
+                channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
 
-                var self = this;
-
-                var listener = {
+                let self = this;
 
+                let listener = {
                     // nsIUnicharStreamLoaderObserver:
-                    onDetermineCharset: function(loader, context, firstSegment, length) {
-                        var charset = null;
-                        if (loader && loader.channel) {
+                    onDetermineCharset: function(aLoader, context, firstSegment, aLength) {
+                        let charset = null;
+                        if (aLoader && aLoader.channel) {
                             charset = channel.contentCharset;
                         }
                         if (!charset || charset.length == 0) {
                             charset = "UTF-8";
                         }
                         return charset;
                     },
 
-                    onStreamComplete: function(loader, context, status, unicharString) {
-                        var parser = Components.classes["@mozilla.org/calendar/ics-parser;1"]
-                                     .createInstance(Components.interfaces.calIIcsParser);
+                    onStreamComplete: function(aLoader, context, status, unicharString) {
+                        let parser = Cc["@mozilla.org/calendar/ics-parser;1"]
+                                     .createInstance(Ci.calIIcsParser);
                         parser.parseString(unicharString);
                         self.onDropItems(parser.getItems({}).concat(parser.getParentlessItems({})));
                     }
                 };
 
                 try {
-                    loader.init(listener, Components.interfaces.nsIUnicharStreamLoader.DEFAULT_SEGMENT_SIZE);
+                    loader.init(listener, Ci.nsIUnicharStreamLoader.DEFAULT_SEGMENT_SIZE);
                     channel.asyncOpen(loader, null);
-                } catch(e) {
-                    Components.utils.reportError(e)
+                } catch (e) {
+                    cal.ERROR(e);
                 }
                 break;
+            }
             case "text/x-moz-message":
                 this.onDropMessage(messenger.msgHdrFromURI(data));
                 break;
             default:
-                cal.ASSERT(false, "unknown data flavour:" + bestFlavor.value+'\n');
+                cal.ASSERT(false, "unknown data flavour:" + bestFlavor.value+"\n");
                 break;
         }
     },
 
-    onDragStart: function calDNDStart(aEvent, aTransferData, aDragAction) {},
-    onDragOver: function calDNDOver(aEvent, aFlavor, aDragSession) {},
-    onDragExit: function calDNDExit(aEvent, aDragSession) {},
+    onDragStart: function(aEvent, aTransferData, aDragAction) {},
+    onDragOver: function(aEvent, aFlavor, aDragSession) {},
+    onDragExit: function(aEvent, aDragSession) {},
 
-    onDropItems: function calDNDDropItems(aItems) {},
-    onDropMessage: function calDNDDropMessage(aMessage) {},
+    onDropItems: function(aItems) {},
+    onDropMessage: function(aMessage) {},
 
 
-    retrieveURLFromData: function calDNDRetrieveURL(aData, aFlavor) {
-        var data;
+    retrieveURLFromData: function(aData, aFlavor) {
         switch (aFlavor) {
-            case "text/unicode":
-                data = aData.toString();
-                var separator = data.indexOf("\n");
-                if (separator != -1)
+            case "text/unicode": {
+                let data = aData.toString();
+                let separator = data.indexOf("\n");
+                if (separator != -1) {
                     data = data.substr(0, separator);
+                }
                 return data;
+            }
             case "application/x-moz-file":
                 return aData.URL;
             default:
                 return null;
         }
     }
 };
 
@@ -383,18 +396,17 @@ calViewDNDObserver.prototype = {
         startBatchTransaction();
         // we fall back explicitely to the popup to ask whether to send a
         // notification to partticipants if required
         let extResp = { responseMode: Ci.calIItipItem.USER };
         try {
             for (let item of aItems) {
                 doTransaction("add", item, destCal, null, null, extResp);
             }
-        }
-        finally {
+        } finally {
             endBatchTransaction();
         }
     }
 };
 
 /**
  * calMailButtonDNDObserver::calMailButtonDNDObserver
  *
@@ -456,18 +468,18 @@ calCalendarButtonDNDObserver.prototype =
      * calCalendarButtonDNDObserver::onDropItems
      *
      * Gets called in case we're dropping an array of items
      * on the 'calendar mode'-button.
      *
      * @param aItems        An array of items to handle.
      */
     onDropItems: function(aItems) {
-        for (var item of aItems) {
-            var newItem = item;
+        for (let item of aItems) {
+            let newItem = item;
             if (cal.item.isToDo(item)) {
                 newItem = itemConversion.eventFromTask(item);
             }
             createEventWithDialog(null, null, null, null, newItem);
         }
     },
 
     /**
@@ -476,17 +488,17 @@ calCalendarButtonDNDObserver.prototype =
      * Gets called in case we're dropping a message on the
      * 'calendar mode'-button. In this case we create a new
      * event from the mail. We open the default event dialog
      * and just use the subject of the message as the event title.
      *
      * @param aMessage     The message to handle.
      */
     onDropMessage: function(aMessage) {
-        var newItem = cal.createEvent();
+        let newItem = cal.createEvent();
         itemConversion.calendarItemFromMessage(newItem, aMessage);
         createEventWithDialog(null, null, null, null, newItem);
     }
 };
 
 /**
  * calTaskButtonDNDObserver::calTaskButtonDNDObserver
  *
@@ -505,90 +517,90 @@ calTaskButtonDNDObserver.prototype = {
      * calTaskButtonDNDObserver::onDropItems
      *
      * Gets called in case we're dropping an array of items
      * on the 'task mode'-button.
      *
      * @param aItems        An array of items to handle.
      */
     onDropItems: function(aItems) {
-        for (var item of aItems) {
-            var newItem = item;
+        for (let item of aItems) {
+            let newItem = item;
             if (cal.item.isEvent(item)) {
                 newItem = itemConversion.taskFromEvent(item);
             }
             createTodoWithDialog(null, null, null, newItem);
         }
     },
 
     /**
      * calTaskButtonDNDObserver::onDropMessage
      *
      * Gets called in case we're dropping a message
      * on the 'task mode'-button.
      *
      * @param aMessage     The message to handle.
      */
     onDropMessage: function(aMessage) {
-        var todo = cal.createTodo();
+        let todo = cal.createTodo();
         itemConversion.calendarItemFromMessage(todo, aMessage);
         createTodoWithDialog(null, null, null, todo);
     }
 };
 
 /**
  * Invoke a drag session for the passed item. The passed box will be used as a
  * source.
  *
  * @param aItem     The item to drag.
  * @param aXULBox   The XUL box to invoke the drag session from.
  */
 function invokeEventDragSession(aItem, aXULBox) {
-    let transfer = Components.classes["@mozilla.org/widget/transferable;1"]
-                   .createInstance(Components.interfaces.nsITransferable);
+    let transfer = Cc["@mozilla.org/widget/transferable;1"]
+                   .createInstance(Ci.nsITransferable);
     transfer.init(null);
     transfer.addDataFlavor("text/calendar");
 
     let flavourProvider = {
-        QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIFlavorDataProvider]),
+        QueryInterface: XPCOMUtils.generateQI([Ci.nsIFlavorDataProvider]),
 
         item: aItem,
         getFlavorData: function(aInTransferable, aInFlavor, aOutData, aOutDataLen) {
             if ((aInFlavor == "application/vnd.x-moz-cal-event") ||
                 (aInFlavor == "application/vnd.x-moz-cal-task")) {
                 aOutData.value = aItem;
                 aOutDataLen.value = 1;
             } else {
                 cal.ASSERT(false, "error:" + aInFlavor);
             }
         }
     };
 
     if (cal.item.isEvent(aItem)) {
-      transfer.addDataFlavor("application/vnd.x-moz-cal-event");
-      transfer.setTransferData("application/vnd.x-moz-cal-event", flavourProvider, 0);
+        transfer.addDataFlavor("application/vnd.x-moz-cal-event");
+        transfer.setTransferData("application/vnd.x-moz-cal-event", flavourProvider, 0);
     } else if (cal.item.isToDo(aItem)) {
-      transfer.addDataFlavor("application/vnd.x-moz-cal-task");
-      transfer.setTransferData("application/vnd.x-moz-cal-task", flavourProvider, 0);
+        transfer.addDataFlavor("application/vnd.x-moz-cal-task");
+        transfer.setTransferData("application/vnd.x-moz-cal-task", flavourProvider, 0);
     }
 
     // Also set some normal data-types, in case we drag into another app
-    let serializer = Components.classes["@mozilla.org/calendar/ics-serializer;1"]
-                               .createInstance(Components.interfaces.calIIcsSerializer);
+    let serializer = Cc["@mozilla.org/calendar/ics-serializer;1"]
+                     .createInstance(Ci.calIIcsSerializer);
     serializer.addItems([aItem], 1);
 
-    let supportsString = Components.classes["@mozilla.org/supports-string;1"]
-                         .createInstance(Components.interfaces.nsISupportsString);
+    let supportsString = Cc["@mozilla.org/supports-string;1"]
+                         .createInstance(Ci.nsISupportsString);
     supportsString.data = serializer.serializeToString();
     transfer.setTransferData("text/calendar", supportsString, supportsString.data.length * 2);
     transfer.setTransferData("text/unicode", supportsString, supportsString.data.length * 2);
 
-    let action = Components.interfaces.nsIDragService.DRAGDROP_ACTION_MOVE;
-    let mutArray = Components.classes["@mozilla.org/array;1"]
-                   .createInstance(Components.interfaces.nsIMutableArray);
+    let action = Ci.nsIDragService.DRAGDROP_ACTION_MOVE;
+    let mutArray = Cc["@mozilla.org/array;1"]
+                   .createInstance(Ci.nsIMutableArray);
     mutArray.appendElement(transfer);
     aXULBox.sourceObject = aItem;
     try {
         cal.getDragService().invokeDragSession(aXULBox, "", mutArray, null, action);
     } catch (e) {
         if (e.result != Components.results.NS_ERROR_FAILURE) {
             // Pressing Escape on some platforms results in NS_ERROR_FAILURE
             // being thrown. Catch this exception, but throw anything else.
--- a/calendar/base/content/dialogs/calendar-migration-dialog.js
+++ b/calendar/base/content/dialogs/calendar-migration-dialog.js
@@ -1,130 +1,128 @@
 /* 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/. */
 
-var SUNBIRD_UID = "{718e30fb-e89b-41dd-9da7-e25a45638b28}";
 var FIREFOX_UID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
 
 ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 //
 // The front-end wizard bits.
 //
 var gMigrateWizard = {
     /**
      * Called from onload of the migrator window.  Takes all of the migrators
      * that were passed in via window.arguments and adds them to checklist. The
      * user can then check these off to migrate the data from those sources.
      */
-    loadMigrators: function gmw_load() {
-        var listbox = document.getElementById("datasource-list");
+    loadMigrators: function() {
+        let listbox = document.getElementById("datasource-list");
 
-        //XXX Once we have branding for lightning, this hack can go away
-        var props = Services.strings.createBundle("chrome://calendar/locale/migration.properties");
+        // XXX Once we have branding for lightning, this hack can go away
+        let props = Services.strings.createBundle("chrome://calendar/locale/migration.properties");
 
-        var wizard = document.getElementById("migration-wizard");
-        var desc = document.getElementById("wizard-desc");
+        let wizard = document.getElementById("migration-wizard");
+        let desc = document.getElementById("wizard-desc");
         // Since we don't translate "Lightning"...
         wizard.title = props.formatStringFromName("migrationTitle",
                                                   ["Lightning"],
                                                   1);
         desc.textContent = props.formatStringFromName("migrationDescription",
                                                       ["Lightning"],
                                                       1);
 
         migLOG("migrators: " + window.arguments.length);
-        for (var migrator of window.arguments[0]) {
-            var listItem = document.createElement("listitem");
+        for (let migrator of window.arguments[0]) {
+            let listItem = document.createElement("listitem");
             listItem.setAttribute("type", "checkbox");
             listItem.setAttribute("checked", true);
             listItem.setAttribute("label", migrator.title);
             listItem.migrator = migrator;
             listbox.appendChild(listItem);
         }
     },
 
     /**
      * Called from the second page of the wizard.  Finds all of the migrators
      * that were checked and begins migrating their data.  Also controls the
      * progress dialog so the user can see what is happening. (somewhat)
      */
-    migrateChecked: function gmw_migrate() {
-        var migrators = [];
+    migrateChecked: function() {
+        let migrators = [];
 
         // Get all the checked migrators into an array
-        var listbox = document.getElementById("datasource-list");
-        for (var i = listbox.childNodes.length-1; i >= 0; i--) {
+        let listbox = document.getElementById("datasource-list");
+        for (let i = listbox.childNodes.length-1; i >= 0; i--) {
             if (listbox.childNodes[i].getAttribute("checked")) {
                 migrators.push(listbox.childNodes[i].migrator);
             }
         }
 
         // If no migrators were checked, then we're done
         if (migrators.length == 0) {
             window.close();
         }
 
         // Don't let the user get away while we're migrating
-        //XXX may want to wire this into the 'cancel' function once that's
+        // XXX may want to wire this into the 'cancel' function once that's
         //    written
-        var wizard = document.getElementById("migration-wizard");
+        let wizard = document.getElementById("migration-wizard");
         wizard.canAdvance = false;
         wizard.canRewind = false;
 
         // We're going to need this for the progress meter's description
-        var props = Services.strings.createBundle("chrome://calendar/locale/migration.properties");
-        var label = document.getElementById("progress-label");
-        var meter = document.getElementById("migrate-progressmeter");
+        let props = Services.strings.createBundle("chrome://calendar/locale/migration.properties");
+        let label = document.getElementById("progress-label");
+        let meter = document.getElementById("migrate-progressmeter");
 
-        var i = 0;
+        let i = 0;
         // Because some of our migrators involve async code, we need this
         // call-back function so we know when to start the next migrator.
         function getNextMigrator() {
             if (migrators[i]) {
-                var mig = migrators[i];
+                let mig = migrators[i];
 
                 // Increment i to point to the next migrator
                 i++;
                 migLOG("starting migrator: " + mig.title);
                 label.value = props.formatStringFromName("migratingApp",
-                                                         [mig.title],
-                                                         1);
+                                                         [mig.title], 1);
                 meter.value = (i-1)/migrators.length*100;
                 mig.args.push(getNextMigrator);
 
                 try {
-                    mig.migrate.apply(mig, mig.args);
+                    mig.migrate(...mig.args);
                 } catch (e) {
                     migLOG("Failed to migrate: " + mig.title);
                     migLOG(e);
                     getNextMigrator();
                 }
             } else {
                 migLOG("migration done");
                 wizard.canAdvance = true;
                 label.value = props.GetStringFromName("finished");
                 meter.value = 100;
                 gMigrateWizard.setCanRewindFalse();
             }
-         }
+        }
 
         // And get the first migrator
         getNextMigrator();
-   },
+    },
 
     /**
      * Makes sure the wizard "back" button can not be pressed.
      */
-    setCanRewindFalse: function gmw_finish() {
-        document.getElementById('migration-wizard').canRewind = false;
+    setCanRewindFalse: function() {
+        document.getElementById("migration-wizard").canRewind = false;
     }
 };
 
 //
 // The more back-end data detection bits
 //
 
 
@@ -160,312 +158,308 @@ var gDataMigrator = {
 
     /**
      * Call to do a general data migration (for a clean profile)  Will run
      * through all of the known migrator-checkers.  These checkers will return
      * an array of valid dataMigrator objects, for each kind of data they find.
      * If there is at least one valid migrator, we'll pop open the migration
      * wizard, otherwise, we'll return silently.
      */
-    checkAndMigrate: function gdm_migrate() {
+    checkAndMigrate: function() {
         if (Services.appinfo.ID == FIREFOX_UID) {
             this.mIsInFirefox = true;
             // We can't handle Firefox Lightning yet
             migLOG("Holy cow, you're Firefox-Lightning! sorry, can't help.");
             return;
         }
 
         this.mPlatform = Services.appinfo.OS.toLowerCase();
 
         migLOG("mPlatform is: " + this.mPlatform);
 
-        var DMs = [];
-        var migrators = [this.checkOldCal,
-                         this.checkEvolution,
-                         this.checkWindowsMail,
-                         this.checkIcal];
+        let DMs = [];
+        let migrators = [
+            this.checkOldCal, this.checkEvolution,
+            this.checkWindowsMail, this.checkIcal
+        ];
         // XXX also define a category and an interface here for pluggability
-        for (var migrator of migrators) {
-            var migs = migrator.call(this);
-            for (var dm of migs) {
-                DMs.push(dm);
+        for (let migrator of migrators) {
+            let migs = migrator.call(this);
+            for (let mig of migs) {
+                DMs.push(mig);
             }
         }
 
         if (DMs.length == 0) {
             // No migration available
             return;
         }
         migLOG("DMs: " + DMs.length);
 
-        var url = "chrome://calendar/content/calendar-migration-dialog.xul";
+        let url = "chrome://calendar/content/calendar-migration-dialog.xul";
         if (AppConstants.platform == "macosx") {
-            var win = Services.wm.getMostRecentWindow("Calendar:MigrationWizard");
+            let win = Services.wm.getMostRecentWindow("Calendar:MigrationWizard");
             if (win) {
                 win.focus();
             } else {
                 openDialog(url, "migration", "centerscreen,chrome,resizable=no,width=500,height=400", DMs);
             }
         } else {
             openDialog(url, "migration", "modal,centerscreen,chrome,resizable=no,width=500,height=400", DMs);
         }
     },
 
     /**
      * Checks to see if we can find any traces of an older moz-cal program.
      * This could be either the old calendar-extension, or Sunbird 0.2.  If so,
      * it offers to move that data into our new storage format.
      */
-    checkOldCal: function gdm_calold() {
-        migLOG("Checking for the old calendar extension/app");
-
+    checkOldCal: function() {
         // This is the function that the migration wizard will call to actually
         // migrate the data.  It's defined here because we may use it multiple
         // times (with different aProfileDirs), for instance if there is both
         // a Thunderbird and Firefox cal-extension
         function extMigrator(aProfileDir, aCallback) {
             // Get the old datasource
-            var dataSource = aProfileDir.clone();
+            let dataSource = aProfileDir.clone();
             dataSource.append("CalendarManager.rdf");
             if (!dataSource.exists()) {
                 return;
             }
 
             // Let this be a lesson to anyone designing APIs. The RDF API is so
             // impossibly confusing that it's actually simpler/cleaner/shorter
             // to simply parse as XML and use the better DOM APIs.
-            var req = new XMLHttpRequest();
-            req.open('GET', "file://" + dataSource.path, true);
-            req.onreadystatechange = function calext_onreadychange() {
+            let req = new XMLHttpRequest();
+            req.open("GET", "file://" + dataSource.path, true);
+            req.onreadystatechange = function() {
                 if (req.readyState == 4) {
                     migLOG(req.responseText);
-                    parseAndMigrate(req.responseXML, aCallback)
+                    parseAndMigrate(req.responseXML, aCallback);
                 }
             };
             req.send(null);
         }
 
         // Callback from the XHR above.  Parses CalendarManager.rdf and imports
         // the data describe therein.
         function parseAndMigrate(aDoc, aCallback) {
-            // For duplicate detection
-            var calManager = cal.getCalendarManager();
-            var uris = [];
-            for (var oldCal of calManager.getCalendars({})) {
-                uris.push(oldCal.uri);
-            }
-
             function getRDFAttr(aNode, aAttr) {
                 return aNode.getAttributeNS("http://home.netscape.com/NC-rdf#",
                                             aAttr);
             }
 
+            // For duplicate detection
+            let calManager = cal.getCalendarManager();
+            let uris = [];
+            for (let oldCal of calManager.getCalendars({})) {
+                uris.push(oldCal.uri);
+            }
+
             const RDFNS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-            var nodes = aDoc.getElementsByTagNameNS(RDFNS, "Description");
+            let nodes = aDoc.getElementsByTagNameNS(RDFNS, "Description");
             migLOG("nodes: " + nodes.length);
-            for (var i = 0; i < nodes.length; i++) {
+            for (let i = 0; i < nodes.length; i++) {
                 migLOG("Beginning calendar node");
-                var calendar;
-                var node = nodes[i];
+                let calendar;
+                let node = nodes[i];
                 if (getRDFAttr(node, "remote") == "false") {
                     migLOG("not remote");
-                    var localFile = Components.classes["@mozilla.org/file/local;1"]
-                                    .createInstance(Components.interfaces.nsIFile);
+                    let localFile = Cc["@mozilla.org/file/local;1"]
+                                    .createInstance(Ci.nsIFile);
                     localFile.initWithPath(getRDFAttr(node, "path"));
                     calendar = gDataMigrator.importICSToStorage(localFile);
                 } else {
                     // Remote subscription
                     // XXX check for duplicates
-                    var url = Services.io.newURI(getRDFAttr(node, "remotePath"));
+                    let url = Services.io.newURI(getRDFAttr(node, "remotePath"));
                     calendar = calManager.createCalendar("ics", url);
                 }
                 calendar.name = getRDFAttr(node, "name");
                 calendar.setProperty("color", getRDFAttr(node, "color"));
                 calManager.registerCalendar(calendar);
                 cal.view.getCompositeCalendar(window).addCalendar(calendar);
             }
             aCallback();
         }
 
-        var migrators = [];
+        migLOG("Checking for the old calendar extension/app");
+        let migrators = [];
 
         // Look in our current profile directory, in case we're upgrading in
         // place
-        var profileDir = this.dirService.get("ProfD", Components.interfaces.nsIFile);
+        let profileDir = this.dirService.get("ProfD", Ci.nsIFile);
         profileDir.append("Calendar");
         if (profileDir.exists()) {
             migLOG("Found old extension directory in current app");
             let title = "Mozilla Calendar Extension";
             migrators.push(new dataMigrator(title, extMigrator, [profileDir]));
         }
 
         // Check the profiles of the various other moz-apps for calendar data
-        var profiles = [];
+        let profiles = [];
 
         // Do they use Firefox?
-        var ffProf, sbProf, tbProf;
+        let ffProf, sbProf;
         if ((ffProf = this.getFirefoxProfile())) {
             profiles.push(ffProf);
         }
 
         // We're lightning, check Sunbird
         if ((sbProf = this.getSunbirdProfile())) {
             profiles.push(sbProf);
         }
 
         // Now check all of the profiles in each of these folders for data
-        for (var prof of profiles) {
-            var dirEnum = prof.directoryEntries;
+        for (let prof of profiles) {
+            let dirEnum = prof.directoryEntries;
             while (dirEnum.hasMoreElements()) {
-                var profile = dirEnum.getNext().QueryInterface(Components.interfaces.nsIFile);
+                let profile = dirEnum.getNext().QueryInterface(Ci.nsIFile);
                 if (profile.isFile()) {
                     continue;
                 } else {
                     profile.append("Calendar");
                     if (profile.exists()) {
                         migLOG("Found old extension directory at" + profile.path);
-                        var title = "Mozilla Calendar";
+                        let title = "Mozilla Calendar";
                         migrators.push(new dataMigrator(title, extMigrator, [profile]));
                     }
                 }
             }
         }
 
         return migrators;
     },
 
     /**
      * Checks to see if Apple's iCal is installed and offers to migrate any data
      * the user has created in it.
      */
-    checkIcal: function gdm_ical() {
-        migLOG("Checking for ical data");
-
+    checkIcal: function() {
         function icalMigrate(aDataDir, aCallback) {
             aDataDir.append("Sources");
-            var dirs = aDataDir.directoryEntries;
-            var calManager = cal.getCalendarManager();
+            let dirs = aDataDir.directoryEntries;
+            let calManager = cal.getCalendarManager();
 
-            var i = 1;
-            while(dirs.hasMoreElements()) {
-                var dataDir = dirs.getNext().QueryInterface(Components.interfaces.nsIFile);
-                var dataStore = dataDir.clone();
+            let i = 1;
+            while (dirs.hasMoreElements()) {
+                let dataDir = dirs.getNext().QueryInterface(Ci.nsIFile);
+                let dataStore = dataDir.clone();
                 dataStore.append("corestorage.ics");
                 if (!dataStore.exists()) {
                     continue;
                 }
 
-                var chars = [];
-                var fileStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
-                                 .createInstance(Components.interfaces.nsIFileInputStream);
+                let fileStream = Cc["@mozilla.org/network/file-input-stream;1"]
+                                 .createInstance(Ci.nsIFileInputStream);
 
                 fileStream.init(dataStore, 0x01, parseInt("0444", 8), {});
-                var convStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
-                                 .getService(Components.interfaces.nsIConverterInputStream);
-                                 convStream.init(fileStream, 'UTF-8', 0, 0x0000);
-                var tmpStr = {};
-                var str = "";
-                while (convStream.readString(-1, tmpStr)) {
+                let convIStream = Cc["@mozilla.org/intl/converter-input-stream;1"]
+                                  .getService(Ci.nsIConverterInputStream);
+                convIStream.init(fileStream, "UTF-8", 0, 0x0000);
+                let tmpStr = {};
+                let str = "";
+                while (convIStream.readString(-1, tmpStr)) {
                     str += tmpStr.value;
                 }
 
                 // Strip out the timezone definitions, since it makes the file
                 // invalid otherwise
-                var index = str.indexOf(";TZID=");
+                let index = str.indexOf(";TZID=");
                 while (index != -1) {
-                    var endIndex = str.indexOf(':', index);
-                    var otherEnd = str.indexOf(';', index+2);
+                    let endIndex = str.indexOf(":", index);
+                    let otherEnd = str.indexOf(";", index+2);
                     if (otherEnd < endIndex) {
                         endIndex = otherEnd;
                     }
-                    var sub = str.substring(index, endIndex);
+                    let sub = str.substring(index, endIndex);
                     str = str.split(sub).join("");
                     index = str.indexOf(";TZID=");
                 }
-                var tempFile = gDataMigrator.dirService.get("TmpD", Components.interfaces.nsIFile);
+                let tempFile = gDataMigrator.dirService.get("TmpD", Ci.nsIFile);
                 tempFile.append("icalTemp.ics");
-                tempFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE,
+                tempFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE,
                                       parseInt("0600", 8));
-                var tempUri = Services.io.newFileURI(tempFile);
 
-                var stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
-                             .createInstance(Components.interfaces.nsIFileOutputStream);
+                let stream = Cc["@mozilla.org/network/file-output-stream;1"]
+                             .createInstance(Ci.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');
-                convStream.writeString(str);
+                let convOStream = Cc["@mozilla.org/intl/converter-output-stream;1"]
+                                 .createInstance(Ci.nsIConverterOutputStream);
+                convOStream.init(stream, "UTF-8");
+                convOStream.writeString(str);
 
-                var calendar = gDataMigrator.importICSToStorage(tempFile);
+                let calendar = gDataMigrator.importICSToStorage(tempFile);
                 calendar.name = "iCalendar"+i;
                 i++;
                 calManager.registerCalendar(calendar);
                 cal.view.getCompositeCalendar(window).addCalendar(calendar);
             }
             migLOG("icalMig making callback");
             aCallback();
         }
-        var profileDir = this.dirService.get("ProfD", Components.interfaces.nsIFile);
-        var icalSpec = profileDir.path;
-        var diverge = icalSpec.indexOf("Thunderbird");
+
+        migLOG("Checking for ical data");
+        let profileDir = this.dirService.get("ProfD", Ci.nsIFile);
+        let icalSpec = profileDir.path;
+        let diverge = icalSpec.indexOf("Thunderbird");
         if (diverge == -1) {
             return [];
         }
         icalSpec = icalSpec.substr(0, diverge);
-        var icalFile = Components.classes["@mozilla.org/file/local;1"]
-                   .createInstance(Components.interfaces.nsIFile);
+        let icalFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
         icalFile.initWithPath(icalSpec);
         icalFile.append("Application Support");
 
         icalFile.append("iCal");
         if (icalFile.exists()) {
             return [new dataMigrator("Apple iCal", icalMigrate, [icalFile])];
         }
 
         return [];
     },
 
     /**
      * Checks to see if Evolution is installed and offers to migrate any data
      * stored there.
      */
-    checkEvolution: function gdm_evolution() {
+    checkEvolution: function() {
         function evoMigrate(aDataDir, aCallback) {
-            var i = 1;
-            function evoDataMigrate(dataStore) {
+            let i = 1;
+            let evoDataMigrate = function(dataStore) {
                 migLOG("Migrating evolution data file in " + dataStore.path);
                 if (dataStore.exists()) {
-                    var calendar = gDataMigrator.importICSToStorage(dataStore);
+                    let calendar = gDataMigrator.importICSToStorage(dataStore);
                     calendar.name = "Evolution " + (i++);
                     calManager.registerCalendar(calendar);
                     cal.view.getCompositeCalendar(window).addCalendar(calendar);
                 }
                 return dataStore.exists();
-            }
+            };
 
-            var calManager = cal.getCalendarManager();
-            var dirs = aDataDir.directoryEntries;
+            let calManager = cal.getCalendarManager();
+            let dirs = aDataDir.directoryEntries;
             while (dirs.hasMoreElements()) {
-                var dataDir = dirs.getNext().QueryInterface(Components.interfaces.nsIFile);
-                var dataStore = dataDir.clone();
+                let dataDir = dirs.getNext().QueryInterface(Ci.nsIFile);
+                let dataStore = dataDir.clone();
                 dataStore.append("calendar.ics");
                 evoDataMigrate(dataStore);
             }
 
             aCallback();
         }
 
-        var evoDir = this.dirService.get("Home", Components.interfaces.nsIFile);
+        let evoDir = this.dirService.get("Home", Ci.nsIFile);
         evoDir.append(".evolution");
         evoDir.append("calendar");
         evoDir.append("local");
         return (evoDir.exists() ? [new dataMigrator("Evolution", evoMigrate, [evoDir])] : []);
     },
 
-    checkWindowsMail: function gdm_windowsMail() {
+    checkWindowsMail: function() {
         function doMigrate(aCalendarNodes, aMailDir, aCallback) {
             let calManager = cal.getCalendarManager();
 
             for (let node of aCalendarNodes) {
                 let name = node.getElementsByTagName("Name")[0].textContent;
                 let color = node.getElementsByTagName("Color")[0].textContent;
                 let enabled = node.getElementsByTagName("Enabled")[0].textContent == "True";
 
@@ -474,17 +468,17 @@ var gDataMigrator = {
                 // color part.
                 name = name.replace(/(^'|'$)/g, "");
                 color = color.replace(/0x[0-9a-fA-F]{2}([0-9a-fA-F]{4})/, "#$1");
 
                 let calfile = aMailDir.clone();
                 calfile.append(name + ".ics");
 
                 if (calfile.exists()) {
-                    let storage = gDataMigrator.importICSToStorage(calfile)
+                    let storage = gDataMigrator.importICSToStorage(calfile);
                     storage.name = name;
 
                     if (color) {
                         storage.setProperty("color", color);
                     }
                     calManager.registerCalendar(storage);
 
                     if (enabled) {
@@ -495,18 +489,17 @@ var gDataMigrator = {
             aCallback();
         }
 
         if (!this.dirService.has("LocalAppData")) {
             // We are probably not on windows
             return [];
         }
 
-        let maildir = this.dirService.get("LocalAppData",
-                                          Components.interfaces.nsIFile);
+        let maildir = this.dirService.get("LocalAppData", Ci.nsIFile);
 
         maildir.append("Microsoft");
         maildir.append("Windows Calendar");
         maildir.append("Calendars");
 
         let settingsxml = maildir.clone();
         settingsxml.append("Settings.xml");
 
@@ -515,58 +508,60 @@ var gDataMigrator = {
             let settingsXmlUri = Services.io.newFileURI(settingsxml);
 
             let req = new XMLHttpRequest();
             req.open("GET", settingsXmlUri.spec, false);
             req.send(null);
             if (req.status == 0) {
                 // The file was found, it seems we are on windows vista.
                 let doc = req.responseXML;
-                let root = doc.documentElement;
 
                 // Get all calendar property tags and return the migrator.
                 let calendars = doc.getElementsByTagName("VCalendar");
                 if (calendars.length > 0) {
                     migrators = [new dataMigrator("Windows Calendar", doMigrate.bind(null, calendars, maildir))];
                 }
             }
         }
         return migrators;
     },
 
     /**
      * 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 calendar = cal.getCalendarManager().createCalendar("storage", Services.io.newURI(uri));
-        let icsImporter = Components.classes["@mozilla.org/calendar/import;1?type=ics"]
-                                    .getService(Components.interfaces.calIImporter);
+    importICSToStorage: function(icsFile) {
+        const uri = "moz-storage-calendar://";
+        let calendar = cal.getCalendarManager().createCalendar(
+            "storage",
+            Services.io.newURI(uri)
+        );
+        let icsImporter = Cc["@mozilla.org/calendar/import;1?type=ics"]
+                          .getService(Ci.calIImporter);
 
-        let inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
-                                    .createInstance(Components.interfaces.nsIFileInputStream);
+        let inputStream = Cc["@mozilla.org/network/file-input-stream;1"]
+                          .createInstance(Ci.nsIFileInputStream);
         let items = [];
 
         calendar.id = cal.getUUID();
 
         try {
             inputStream.init(icsFile, MODE_RDONLY, parseInt("0444", 8), {});
             items = icsImporter.importFromStream(inputStream, {});
-        } catch(ex) {
+        } catch (ex) {
             switch (ex.result) {
-                case Components.interfaces.calIErrors.INVALID_TIMEZONE:
+                case Ci.calIErrors.INVALID_TIMEZONE:
                     cal.showError(cal.l10n.getCalString("timezoneError", [icsFile.path]), window);
                     break;
                 default:
                     cal.showError(cal.l10n.getCalString("unableToRead") + icsFile.path + "\n"+ ex, window);
             }
         } finally {
-           inputStream.close();
+            inputStream.close();
         }
 
         // Defined in import-export.js
         putItemsIntoCal(calendar, items, icsFile.leafName);
 
         return calendar;
     },
 
@@ -587,43 +582,43 @@ var gDataMigrator = {
      * Thunderbird:
      *     Unix:     ~jdoe/.thunderbird/
      *     Windows:  %APPDATA%\Thunderbird\Profiles
      *     Mac OS X: ~jdoe/Library/Thunderbird/Profiles
      *
      * Notice that Firefox and Sunbird follow essentially the same pattern, so
      * we group them with getNormalProfile
      */
-    getFirefoxProfile: function gdm_getFF() {
+    getFirefoxProfile: function() {
         return this.getNormalProfile("Firefox");
     },
 
     /**
      * @see getFirefoxProfile
      */
-    getThunderbirdProfile: function gdm_getTB() {
-        let profileRoot = this.dirService.get("DefProfRt", Components.interfaces.nsIFile);
+    getThunderbirdProfile: function() {
+        let profileRoot = this.dirService.get("DefProfRt", Ci.nsIFile);
         migLOG("searching for Thunderbird in " + profileRoot.path);
         return profileRoot.exists() ? profileRoot : null;
     },
 
     /**
      * @see getFirefoxProfile
      */
-    getSunbirdProfile: function gdm_getSB() {
+    getSunbirdProfile: function() {
         return this.getNormalProfile("Sunbird");
     },
 
     /**
      * Common function to retrieve the profile directory for a given app.
      * @see getFirefoxProfile
      */
-    getNormalProfile: function gdm_getNorm(aAppName) {
-        var localFile;
-        var profileRoot = this.dirService.get("DefProfRt", Components.interfaces.nsIFile);
+    getNormalProfile: function(aAppName) {
+        let localFile;
+        let profileRoot = this.dirService.get("DefProfRt", Ci.nsIFile);
         migLOG("profileRoot = " + profileRoot.path);
 
         switch (this.mPlatform) {
             case "darwin": // Mac OS X
                 localFile = profileRoot.parent.parent;
                 localFile.append("Application Support");
                 localFile.append(aAppName);
                 localFile.append("Profiles");