Bug 1517658 - Rename some variables in extensions parent scope; r=Fallen DONTBUILD
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 07 Jan 2019 21:56:49 +1300
changeset 34135 b5994bd3ba7619d27bbae69c8243911afb2e1583
parent 34134 f8ef458411f47cdc8d7b39dc4ccbf4ab0afaf546
child 34136 3df2a9ba3c3933f9e48286fe70858a1708a70d3f
push id389
push userclokep@gmail.com
push dateMon, 18 Mar 2019 19:01:53 +0000
reviewersFallen
bugs1517658
Bug 1517658 - Rename some variables in extensions parent scope; r=Fallen DONTBUILD
mail/components/extensions/parent/ext-addressBook.js
mail/components/extensions/parent/ext-cloudFile.js
mail/components/extensions/parent/ext-mail.js
--- a/mail/components/extensions/parent/ext-addressBook.js
+++ b/mail/components/extensions/parent/ext-addressBook.js
@@ -21,17 +21,17 @@ const hiddenProperties = [
 /**
  * Cache of items in the address book "tree". This cache is
  * completely blown away by most changes, so operations should
  * be as lightweight as possible.
  *
  * @implements {nsIAbListener}
  * @implements {nsIObserver}
  */
-var cache = new class extends EventEmitter {
+var addressBookCache = new class extends EventEmitter {
   constructor() {
     super();
     this.listenerCount = 0;
   }
   _makeContactNode(contact, parent) {
     contact.QueryInterface(Ci.nsIAbCard);
     return {
       id: contact.UID,
@@ -49,27 +49,27 @@ var cache = new class extends EventEmitt
       get contacts() {
         delete this.contacts;
         if (directory.isMailList) {
           this.contacts = [...directory.addressLists.enumerate()];
         } else {
           this.contacts = [...directory.childCards]
             .filter(c => !c.isMailList);
         }
-        this.contacts = this.contacts.map(c => cache._makeContactNode(c, directory));
+        this.contacts = this.contacts.map(c => addressBookCache._makeContactNode(c, directory));
         return this.contacts;
       },
       get mailingLists() {
         delete this.mailingLists;
         if (directory.isMailList) {
           return undefined;
         }
         this.mailingLists = [];
         for (let al of directory.addressLists.enumerate()) {
-          this.mailingLists.push(cache._makeDirectoryNode(al, directory));
+          this.mailingLists.push(addressBookCache._makeDirectoryNode(al, directory));
         }
         return this.mailingLists;
       },
     };
     if (parent) {
       node.parentId = parent.UID;
     }
     return node;
@@ -294,298 +294,298 @@ this.addressBook = class extends Extensi
         },
         async closeUI() {
           for (let win of Services.wm.getEnumerator(AB_WINDOW_TYPE)) {
             win.close();
           }
         },
 
         list(complete = false) {
-          return cache.convert(cache.tree, complete);
+          return addressBookCache.convert(addressBookCache.tree, complete);
         },
         get(id, complete = false) {
-          return cache.convert(cache.findAddressBookById(id), complete);
+          return addressBookCache.convert(addressBookCache.findAddressBookById(id), complete);
         },
         create({ name }) {
           let dirName = MailServices.ab.newAddressBook(name, "", kPABDirectory);
           let directory = MailServices.ab.getDirectoryFromId(dirName);
           return directory.UID;
         },
         update(id, { name }) {
-          let node = cache.findAddressBookById(id);
+          let node = addressBookCache.findAddressBookById(id);
           node.item.dirName = name;
         },
         delete(id) {
-          let node = cache.findAddressBookById(id);
+          let node = addressBookCache.findAddressBookById(id);
           MailServices.ab.deleteAddressBook(node.item.URI);
         },
 
         onCreated: new EventManager({
           context,
           name: "addressBooks.onCreated",
           register: fire => {
             let listener = (event, node) => {
-              fire.sync(cache.convert(node));
+              fire.sync(addressBookCache.convert(node));
             };
 
-            cache.on("address-book-created", listener);
-            cache.incrementListeners();
+            addressBookCache.on("address-book-created", listener);
+            addressBookCache.incrementListeners();
             return () => {
-              cache.off("address-book-created", listener);
-              cache.decrementListeners();
+              addressBookCache.off("address-book-created", listener);
+              addressBookCache.decrementListeners();
             };
           },
         }).api(),
         onUpdated: new EventManager({
           context,
           name: "addressBooks.onUpdated",
           register: fire => {
             let listener = (event, node) => {
-              fire.sync(cache.convert(node));
+              fire.sync(addressBookCache.convert(node));
             };
 
-            cache.on("address-book-updated", listener);
-            cache.incrementListeners();
+            addressBookCache.on("address-book-updated", listener);
+            addressBookCache.incrementListeners();
             return () => {
-              cache.off("address-book-updated", listener);
-              cache.decrementListeners();
+              addressBookCache.off("address-book-updated", listener);
+              addressBookCache.decrementListeners();
             };
           },
         }).api(),
         onDeleted: new EventManager({
           context,
           name: "addressBooks.onDeleted",
           register: fire => {
             let listener = (event, item) => {
               fire.sync(item.UID);
             };
 
-            cache.on("address-book-deleted", listener);
-            cache.incrementListeners();
+            addressBookCache.on("address-book-deleted", listener);
+            addressBookCache.incrementListeners();
             return () => {
-              cache.off("address-book-deleted", listener);
-              cache.decrementListeners();
+              addressBookCache.off("address-book-deleted", listener);
+              addressBookCache.decrementListeners();
             };
           },
         }).api(),
       },
       contacts: {
         list(parentId) {
-          let parentNode = cache.findAddressBookById(parentId);
-          return cache.convert(parentNode.contacts, false);
+          let parentNode = addressBookCache.findAddressBookById(parentId);
+          return addressBookCache.convert(parentNode.contacts, false);
         },
         get(id) {
-          return cache.convert(cache.findContactById(id), false);
+          return addressBookCache.convert(addressBookCache.findContactById(id), false);
         },
         create(parentId, properties) {
           let card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(Ci.nsIAbCard);
           for (let [name, value] of Object.entries(properties)) {
             if (!hiddenProperties.includes(name)) {
               card.setProperty(name, value);
             }
           }
-          let parentNode = cache.findAddressBookById(parentId);
+          let parentNode = addressBookCache.findAddressBookById(parentId);
           let newCard = parentNode.item.addCard(card);
           return newCard.UID;
         },
         update(id, properties) {
-          let node = cache.findContactById(id);
-          let parentNode = cache.findAddressBookById(node.parentId);
+          let node = addressBookCache.findContactById(id);
+          let parentNode = addressBookCache.findAddressBookById(node.parentId);
 
           for (let [name, value] of Object.entries(properties)) {
             if (!hiddenProperties.includes(name)) {
               node.item.setProperty(name, value);
             }
           }
           parentNode.item.modifyCard(node.item);
         },
         delete(id) {
-          let node = cache.findContactById(id);
-          let parentNode = cache.findAddressBookById(node.parentId);
+          let node = addressBookCache.findContactById(id);
+          let parentNode = addressBookCache.findAddressBookById(node.parentId);
 
           let cardArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
           cardArray.appendElement(node.item);
           parentNode.item.deleteCards(cardArray);
         },
 
         onCreated: new EventManager({
           context,
           name: "contacts.onCreated",
           register: fire => {
             let listener = (event, node) => {
-              fire.sync(cache.convert(node));
+              fire.sync(addressBookCache.convert(node));
             };
 
-            cache.on("contact-created", listener);
-            cache.incrementListeners();
+            addressBookCache.on("contact-created", listener);
+            addressBookCache.incrementListeners();
             return () => {
-              cache.off("contact-created", listener);
-              cache.decrementListeners();
+              addressBookCache.off("contact-created", listener);
+              addressBookCache.decrementListeners();
             };
           },
         }).api(),
         onUpdated: new EventManager({
           context,
           name: "contacts.onUpdated",
           register: fire => {
             let listener = (event, node) => {
-              fire.sync(cache.convert(node));
+              fire.sync(addressBookCache.convert(node));
             };
 
-            cache.on("contact-updated", listener);
-            cache.incrementListeners();
+            addressBookCache.on("contact-updated", listener);
+            addressBookCache.incrementListeners();
             return () => {
-              cache.off("contact-updated", listener);
-              cache.decrementListeners();
+              addressBookCache.off("contact-updated", listener);
+              addressBookCache.decrementListeners();
             };
           },
         }).api(),
         onDeleted: new EventManager({
           context,
           name: "contacts.onDeleted",
           register: fire => {
             let listener = (event, parent, item) => {
               fire.sync(parent.UID, item.UID);
             };
 
-            cache.on("contact-deleted", listener);
-            cache.incrementListeners();
+            addressBookCache.on("contact-deleted", listener);
+            addressBookCache.incrementListeners();
             return () => {
-              cache.off("contact-deleted", listener);
-              cache.decrementListeners();
+              addressBookCache.off("contact-deleted", listener);
+              addressBookCache.decrementListeners();
             };
           },
         }).api(),
       },
       mailingLists: {
         list(parentId) {
-          let parentNode = cache.findAddressBookById(parentId);
-          return cache.convert(parentNode.mailingLists, false);
+          let parentNode = addressBookCache.findAddressBookById(parentId);
+          return addressBookCache.convert(parentNode.mailingLists, false);
         },
         get(id) {
-          return cache.convert(cache.findMailingListById(id), false);
+          return addressBookCache.convert(addressBookCache.findMailingListById(id), false);
         },
         create(parentId, { name, nickName, description }) {
           let mailList = Cc["@mozilla.org/addressbook/directoryproperty;1"].createInstance();
           mailList.QueryInterface(Ci.nsIAbDirectory);
           mailList.isMailList = true;
           mailList.dirName = name;
           mailList.listNickName = (nickName === null) ? "" : nickName;
           mailList.description = (description === null) ? "" : description;
 
-          let parentNode = cache.findAddressBookById(parentId);
+          let parentNode = addressBookCache.findAddressBookById(parentId);
           let newMailList = parentNode.item.addMailList(mailList);
           return newMailList.UID;
         },
         update(id, { name, nickName, description }) {
-          let node = cache.findMailingListById(id);
+          let node = addressBookCache.findMailingListById(id);
           node.item.dirName = name;
           node.item.listNickName = (nickName === null) ? "" : nickName;
           node.item.description = (description === null) ? "" : description;
           node.item.editMailListToDatabase(null);
         },
         delete(id) {
-          let node = cache.findMailingListById(id);
+          let node = addressBookCache.findMailingListById(id);
           MailServices.ab.deleteAddressBook(node.item.URI);
         },
 
         listMembers(id) {
-          let node = cache.findMailingListById(id);
-          return cache.convert(node.contacts, false);
+          let node = addressBookCache.findMailingListById(id);
+          return addressBookCache.convert(node.contacts, false);
         },
         addMember(id, contactId) {
-          let node = cache.findMailingListById(id);
-          let contactNode = cache.findContactById(contactId);
+          let node = addressBookCache.findMailingListById(id);
+          let contactNode = addressBookCache.findContactById(contactId);
           node.item.addCard(contactNode.item);
         },
         removeMember(id, contactId) {
-          let node = cache.findMailingListById(id);
-          let contactNode = cache.findContactById(contactId);
+          let node = addressBookCache.findMailingListById(id);
+          let contactNode = addressBookCache.findContactById(contactId);
 
           let cardArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
           cardArray.appendElement(contactNode.item);
           node.item.deleteCards(cardArray);
         },
 
         onCreated: new EventManager({
           context,
           name: "mailingLists.onCreated",
           register: fire => {
             let listener = (event, node) => {
-              fire.sync(cache.convert(node));
+              fire.sync(addressBookCache.convert(node));
             };
 
-            cache.on("mailing-list-created", listener);
-            cache.incrementListeners();
+            addressBookCache.on("mailing-list-created", listener);
+            addressBookCache.incrementListeners();
             return () => {
-              cache.off("mailing-list-created", listener);
-              cache.decrementListeners();
+              addressBookCache.off("mailing-list-created", listener);
+              addressBookCache.decrementListeners();
             };
           },
         }).api(),
         onUpdated: new EventManager({
           context,
           name: "mailingLists.onUpdated",
           register: fire => {
             let listener = (event, node) => {
-              fire.sync(cache.convert(node));
+              fire.sync(addressBookCache.convert(node));
             };
 
-            cache.on("mailing-list-updated", listener);
-            cache.incrementListeners();
+            addressBookCache.on("mailing-list-updated", listener);
+            addressBookCache.incrementListeners();
             return () => {
-              cache.off("mailing-list-updated", listener);
-              cache.decrementListeners();
+              addressBookCache.off("mailing-list-updated", listener);
+              addressBookCache.decrementListeners();
             };
           },
         }).api(),
         onDeleted: new EventManager({
           context,
           name: "mailingLists.onDeleted",
           register: fire => {
             let listener = (event, parent, item) => {
               fire.sync(parent.UID, item.UID);
             };
 
-            cache.on("mailing-list-deleted", listener);
-            cache.incrementListeners();
+            addressBookCache.on("mailing-list-deleted", listener);
+            addressBookCache.incrementListeners();
             return () => {
-              cache.off("mailing-list-deleted", listener);
-              cache.decrementListeners();
+              addressBookCache.off("mailing-list-deleted", listener);
+              addressBookCache.decrementListeners();
             };
           },
         }).api(),
         onMemberAdded: new EventManager({
           context,
           name: "mailingLists.onMemberAdded",
           register: fire => {
             let listener = (event, node) => {
-              fire.sync(cache.convert(node));
+              fire.sync(addressBookCache.convert(node));
             };
 
-            cache.on("mailing-list-member-added", listener);
-            cache.incrementListeners();
+            addressBookCache.on("mailing-list-member-added", listener);
+            addressBookCache.incrementListeners();
             return () => {
-              cache.off("mailing-list-member-added", listener);
-              cache.decrementListeners();
+              addressBookCache.off("mailing-list-member-added", listener);
+              addressBookCache.decrementListeners();
             };
           },
         }).api(),
         onMemberRemoved: new EventManager({
           context,
           name: "mailingLists.onMemberRemoved",
           register: fire => {
             let listener = (event, parent, item) => {
               fire.sync(parent.UID, item.UID);
             };
 
-            cache.on("mailing-list-member-removed", listener);
-            cache.incrementListeners();
+            addressBookCache.on("mailing-list-member-removed", listener);
+            addressBookCache.incrementListeners();
             return () => {
-              cache.off("mailing-list-member-removed", listener);
-              cache.decrementListeners();
+              addressBookCache.off("mailing-list-member-removed", listener);
+              addressBookCache.decrementListeners();
             };
           },
         }).api(),
       },
     };
   }
 };
--- a/mail/components/extensions/parent/ext-cloudFile.js
+++ b/mail/components/extensions/parent/ext-cloudFile.js
@@ -185,17 +185,17 @@ class CloudFileProvider extends EventEmi
   }
 
   unregister() {
     cloudFileAccounts.unregisterProvider(this.type);
   }
 }
 CloudFileProvider.prototype.QueryInterface = ChromeUtils.generateQI([Ci.nsIMsgCloudFileProvider]);
 
-function convertAccount(nativeAccount) {
+function convertCloudFileAccount(nativeAccount) {
   return {
     id: nativeAccount.accountKey,
     name: nativeAccount.displayName,
     configured: nativeAccount.configured,
     uploadSizeLimit: nativeAccount.fileUploadSizeLimit,
     spaceRemaining: nativeAccount.remainingFileSpace,
     spaceUsed: nativeAccount.fileSpaceUsed,
     managementUrl: nativeAccount.managementURL,
@@ -221,49 +221,49 @@ this.cloudFile = class extends Extension
     let self = this;
     return {
       cloudFile: {
         onFileUpload: new EventManager({
           context,
           name: "cloudFile.onFileUpload",
           register: fire => {
             let listener = (event, { id, name, data }) => {
-              let account = convertAccount(self.provider);
+              let account = convertCloudFileAccount(self.provider);
               return fire.async(account, { id, name, data });
             };
 
             self.provider.on("uploadFile", listener);
             return () => {
               self.provider.off("uploadFile", listener);
             };
           },
         }).api(),
 
         onFileUploadAbort: new EventManager({
           context,
           name: "cloudFile.onFileUploadAbort",
           register: fire => {
             let listener = (event, { id }) => {
-              let account = convertAccount(self.provider);
+              let account = convertCloudFileAccount(self.provider);
               return fire.async(account, id);
             };
 
             self.provider.on("uploadAbort", listener);
             return () => {
               self.provider.off("uploadAbort", listener);
             };
           },
         }).api(),
 
         onFileDeleted: new EventManager({
           context,
           name: "cloudFile.onFileDeleted",
           register: fire => {
             let listener = (event, { id }) => {
-              let account = convertAccount(self.provider);
+              let account = convertCloudFileAccount(self.provider);
               return fire.async(account, id);
             };
 
             self.provider.on("deleteFile", listener);
             return () => {
               self.provider.off("deleteFile", listener);
             };
           },
@@ -273,17 +273,17 @@ this.cloudFile = class extends Extension
           context,
           name: "cloudFile.onAccountAdded",
           register: fire => {
             let listener = (event, nativeAccount) => {
               if (nativeAccount.type != this.provider.type) {
                 return null;
               }
 
-              return fire.async(convertAccount(nativeAccount));
+              return fire.async(convertCloudFileAccount(nativeAccount));
             };
 
             cloudFileAccounts.on("accountAdded", listener);
             return () => {
               cloudFileAccounts.off("accountAdded", listener);
             };
           },
         }).api(),
@@ -309,21 +309,21 @@ this.cloudFile = class extends Extension
 
         async getAccount(accountId) {
           let account = cloudFileAccounts.getAccount(accountId);
 
           if (!account || account.type != self.provider.type) {
             return undefined;
           }
 
-          return convertAccount(account);
+          return convertCloudFileAccount(account);
         },
 
         async getAllAccounts() {
-          return cloudFileAccounts.getAccountsForType(self.provider.type).map(convertAccount);
+          return cloudFileAccounts.getAccountsForType(self.provider.type).map(convertCloudFileAccount);
         },
 
         async updateAccount(accountId, updateProperties) {
           let account = cloudFileAccounts.getAccount(accountId);
 
           if (!account || account.type != self.provider.type) {
             return undefined;
           }
@@ -341,14 +341,14 @@ this.cloudFile = class extends Extension
           }
           if (updateProperties.managementUrl !== null) {
             account.managementURL = updateProperties.managementUrl;
           }
           if (updateProperties.settingsUrl !== null) {
             account.settingsURL = updateProperties.settingsUrl;
           }
 
-          return convertAccount(account);
+          return convertCloudFileAccount(account);
         },
       },
     };
   }
 };
--- a/mail/components/extensions/parent/ext-mail.js
+++ b/mail/components/extensions/parent/ext-mail.js
@@ -1074,15 +1074,8 @@ function convertMessage(msgHdr) {
     flagged: msgHdr.isFlagged,
     ccList: msgHdr.ccList,
     bccList: msgHdr.bccList,
     author: msgHdr.mime2DecodedAuthor,
     subject: msgHdr.mime2DecodedSubject,
     recipients: msgHdr.mime2DecodedRecipients,
   };
 }
-
-Object.assign(global, {
-  convertFolder,
-  convertMessage,
-  folderPathToURI,
-  folderURIToPath,
-});