Bug 1682939 - Remove nsISimpleEnumerator from imICoreService. r=clokep
authorBen Campbell <benc@thunderbird.net>
Mon, 01 Feb 2021 12:16:15 +0200
changeset 31567 18b87f375fdadfa751215f37f3541af012a90857
parent 31566 fd3657f525d598a9527918467c5e1bdaa208868b
child 31568 cfa8ec857ac297bae3f690df0eab199773c9ee9b
push id18411
push usermkmelin@iki.fi
push dateMon, 01 Feb 2021 10:51:40 +0000
treeherdercomm-central@056822744fc3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersclokep
bugs1682939
Bug 1682939 - Remove nsISimpleEnumerator from imICoreService. r=clokep
chat/components/public/imICoreService.idl
chat/components/src/imCore.jsm
mail/components/im/content/imAccountWizard.js
--- a/chat/components/public/imICoreService.idl
+++ b/chat/components/public/imICoreService.idl
@@ -1,29 +1,28 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 #include "imIUserStatusInfo.idl"
-#include "nsISimpleEnumerator.idl"
 #include "prplIProtocol.idl"
 
 [scriptable, uuid(205d4b2b-1ccf-4879-9ef1-f08942566151)]
 interface imICoreService: nsISupports {
   readonly attribute boolean initialized;
 
   // This will emit a prpl-init notification. After this point the 'initialized'
   // attribute will be 'true' and it's safe to access the services for accounts,
   // contacts, conversations and commands.
   void init();
 
   // This will emit a prpl-quit notification. This is the last opportunity to
   // use the aforementioned services before they are uninitialized.
   void quit();
 
-  // returns an enumerator on a pplIProtocol array
-  nsISimpleEnumerator getProtocols();
+  // Returns the available protocols.
+  Array<prplIProtocol> getProtocols();
 
   prplIProtocol getProtocolById(in AUTF8String aProtocolId);
 
   readonly attribute imIUserStatusInfo globalUserStatus;
 };
--- a/chat/components/src/imCore.jsm
+++ b/chat/components/src/imCore.jsm
@@ -1,21 +1,18 @@
 /* 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 EXPORTED_SYMBOLS = ["CoreService"];
 
 var { Services } = ChromeUtils.import("resource:///modules/imServices.jsm");
-var {
-  XPCOMUtils,
-  ClassInfo,
-  initLogModule,
-  nsSimpleEnumerator,
-} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
+var { XPCOMUtils, ClassInfo, initLogModule } = ChromeUtils.import(
+  "resource:///modules/imXPCOMUtils.jsm"
+);
 
 XPCOMUtils.defineLazyServiceGetter(
   this,
   "categoryManager",
   "@mozilla.org/categorymanager;1",
   "nsICategoryManager"
 );
 
@@ -363,17 +360,17 @@ CoreService.prototype = {
         continue;
       }
 
       let proto = this.getProtocolById(id);
       if (proto) {
         protocols.push(proto);
       }
     }
-    return new nsSimpleEnumerator(protocols);
+    return protocols;
   },
 
   getProtocolById(aPrplId) {
     if (!this._initialized) {
       throw Components.Exception("", Cr.NS_ERROR_NOT_INITIALIZED);
     }
 
     if (this._protos.hasOwnProperty(aPrplId)) {
--- a/mail/components/im/content/imAccountWizard.js
+++ b/mail/components/im/content/imAccountWizard.js
@@ -43,20 +43,17 @@ var accountWizard = {
     );
 
     // Ensure the im core is initialized before we get a list of protocols.
     Services.core.init();
 
     accountWizard.setGetMoreProtocols();
 
     var protoList = document.getElementById("protolist");
-    var protos = [];
-    for (let proto of this.getProtocols()) {
-      protos.push(proto);
-    }
+    var protos = Services.core.getProtocols();
     protos.sort((a, b) => {
       if (a.name < b.name) {
         return -1;
       }
       return a.name > b.name ? 1 : 0;
     });
     protos.forEach(function(proto) {
       let image = document.createXULElement("image");
@@ -433,19 +430,16 @@ var accountWizard = {
     return undefined;
   },
 
   *getIter(aEnumerator) {
     for (let iter of aEnumerator) {
       yield iter;
     }
   },
-  getProtocols() {
-    return this.getIter(Services.core.getProtocols());
-  },
   getProtoOptions() {
     return this.getIter(this.proto.getOptions());
   },
   getProtoUserSplits() {
     return this.getIter(this.proto.getUsernameSplit());
   },
 
   /* Check for correctness and set URL for the "Get more protocols..."-link