Bug 1557504 - remove [array] use in xpidl from calIIcsSerializer.idl. r=pmorris
authorKhushil Mistry <khushil324@gmail.com>
Thu, 21 Nov 2019 11:05:15 +1300
changeset 37576 dd38ba65ea9896e8f757c784962d59a64b666ff2
parent 37575 8dc56944ca5a67b077a7726f55b08e208b46cc97
child 37577 aec0ee0dc9f8612f6b15792936bc45ddd3796a14
push id396
push userclokep@gmail.com
push dateMon, 06 Jan 2020 23:11:57 +0000
reviewerspmorris
bugs1557504
Bug 1557504 - remove [array] use in xpidl from calIIcsSerializer.idl. r=pmorris
calendar/base/content/calendar-clipboard.js
calendar/base/content/calendar-dnd-listener.js
calendar/base/modules/utils/calItemUtils.jsm
calendar/base/public/calIIcsSerializer.idl
calendar/base/src/calIcsSerializer.js
calendar/import-export/calIcsImportExport.js
calendar/itip/calItipEmailTransport.js
calendar/providers/caldav/calDavCalendar.js
calendar/providers/ics/calICSCalendar.js
calendar/resources/content/publish.js
calendar/test/unit/test_bug1199942.js
calendar/test/unit/test_ics_parser.js
--- a/calendar/base/content/calendar-clipboard.js
+++ b/calendar/base/content/calendar-clipboard.js
@@ -91,17 +91,17 @@ function copyToClipboard(aCalendarItemAr
   if (!response) {
     // The user canceled the dialog, bail out
     return;
   }
 
   let icsSerializer = Cc["@mozilla.org/calendar/ics-serializer;1"].createInstance(
     Ci.calIIcsSerializer
   );
-  icsSerializer.addItems(targetItems, targetItems.length);
+  icsSerializer.addItems(targetItems);
   let icsString = icsSerializer.serializeToString();
 
   let clipboard = Services.clipboard;
   let trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
 
   if (trans && clipboard) {
     // Register supported data flavors
     trans.init(null);
--- a/calendar/base/content/calendar-dnd-listener.js
+++ b/calendar/base/content/calendar-dnd-listener.js
@@ -569,17 +569,17 @@ function invokeEventDragSession(aItem, a
     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 = Cc["@mozilla.org/calendar/ics-serializer;1"].createInstance(
     Ci.calIIcsSerializer
   );
-  serializer.addItems([aItem], 1);
+  serializer.addItems([aItem]);
 
   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 = Ci.nsIDragService.DRAGDROP_ACTION_MOVE;
   let mutArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
--- a/calendar/base/modules/utils/calItemUtils.jsm
+++ b/calendar/base/modules/utils/calItemUtils.jsm
@@ -582,17 +582,17 @@ var calitem = {
 
   /**
    * Shortcut function to serialize an item (including all overridden items).
    */
   serialize: function(aItem) {
     let serializer = Cc["@mozilla.org/calendar/ics-serializer;1"].createInstance(
       Ci.calIIcsSerializer
     );
-    serializer.addItems([aItem], 1);
+    serializer.addItems([aItem]);
     return serializer.serializeToString();
   },
 
   /**
    * Centralized functions for accessing prodid and version
    */
   get productId() {
     return "-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN";
--- a/calendar/base/public/calIIcsSerializer.idl
+++ b/calendar/base/public/calIIcsSerializer.idl
@@ -20,21 +20,18 @@ interface nsIInputStream;
 interface calIIcsSerializer : nsISupports
 {
   /**
    * Add some items to the items that are to be serialized. Can be called
    * multiple times, and appends to the set on every call.
    *
    * @param aItems
    *    The items to be added
-   * @param aCount
-   *    The number of items to add
    */
-  void addItems([array, size_is(aCount)] in calIItemBase aItems,
-                in unsigned long aCount);
+  void addItems(in Array<calIItemBase> aItems);
 
   /**
    * Add a property to the top-level properties to be added on serializing. Can
    * be called multiple times, and appends to the set on every call.
    *
    * @param aProperty
    *    The property to be added
    */
--- a/calendar/base/src/calIcsSerializer.js
+++ b/calendar/base/src/calIcsSerializer.js
@@ -9,18 +9,18 @@ function calIcsSerializer() {
   this.mItems = [];
   this.mProperties = [];
   this.mComponents = [];
 }
 calIcsSerializer.prototype = {
   QueryInterface: ChromeUtils.generateQI([Ci.calIIcsSerializer]),
   classID: Components.ID("{207a6682-8ff1-4203-9160-729ec28c8766}"),
 
-  addItems: function(aItems, aCount) {
-    if (aCount > 0) {
+  addItems: function(aItems) {
+    if (aItems.length > 0) {
       this.mItems = this.mItems.concat(aItems);
     }
   },
 
   addProperty: function(aProperty) {
     this.mProperties.push(aProperty);
   },
 
--- a/calendar/import-export/calIcsImportExport.js
+++ b/calendar/import-export/calIcsImportExport.js
@@ -48,12 +48,12 @@ calIcsExporter.prototype = {
   classID: Components.ID("{a6a524ce-adff-4a0f-bb7d-d1aaad4adc60}"),
 
   getFileTypes: getIcsFileTypes,
 
   exportToStream: function(aStream, aItems, aTitle) {
     let serializer = Cc["@mozilla.org/calendar/ics-serializer;1"].createInstance(
       Ci.calIIcsSerializer
     );
-    serializer.addItems(aItems, aItems.length);
+    serializer.addItems(aItems);
     serializer.serializeToStream(aStream);
   },
 };
--- a/calendar/itip/calItipEmailTransport.js
+++ b/calendar/itip/calItipEmailTransport.js
@@ -321,17 +321,17 @@ calItipEmailTransport.prototype = {
   },
 
   _createTempImipFile: function(aToList, aSubject, aBody, aItipItem, aIdentity, aMessageId) {
     try {
       let itemList = aItipItem.getItemList();
       let serializer = Cc["@mozilla.org/calendar/ics-serializer;1"].createInstance(
         Ci.calIIcsSerializer
       );
-      serializer.addItems(itemList, itemList.length);
+      serializer.addItems(itemList);
       let methodProp = cal.getIcsService().createIcalProperty("METHOD");
       methodProp.value = aItipItem.responseMethod;
       serializer.addProperty(methodProp);
       let calText = serializer.serializeToString();
       let utf8CalText = ltn.invitation.encodeUTF8(calText);
 
       // Home-grown mail composition; I'd love to use nsIMimeEmitter, but it's not clear to me whether
       // it can cope with nested attachments,
--- a/calendar/providers/caldav/calDavCalendar.js
+++ b/calendar/providers/caldav/calDavCalendar.js
@@ -3026,17 +3026,17 @@ calDavCalendar.prototype = {
       // work around BUG 351589, the below just removes RSVP:
       aItipItem.setAttendeeStatus(attendee.id, attendee.participationStatus);
     }
 
     for (let item of aItipItem.getItemList()) {
       let serializer = Cc["@mozilla.org/calendar/ics-serializer;1"].createInstance(
         Ci.calIIcsSerializer
       );
-      serializer.addItems([item], 1);
+      serializer.addItems([item]);
       let methodProp = cal.getIcsService().createIcalProperty("METHOD");
       methodProp.value = aItipItem.responseMethod;
       serializer.addProperty(methodProp);
 
       let self = this;
       let streamListener = {
         onStreamComplete: function(aLoader, aContext, aStatus, aResultLength, aResult) {
           let request = aLoader.request.QueryInterface(Ci.nsIHttpChannel);
@@ -3146,17 +3146,17 @@ calDavCalendar.prototype = {
     }
     return this.mVerboseLogging;
   },
 
   getSerializedItem: function(aItem) {
     let serializer = Cc["@mozilla.org/calendar/ics-serializer;1"].createInstance(
       Ci.calIIcsSerializer
     );
-    serializer.addItems([aItem], 1);
+    serializer.addItems([aItem]);
     let serializedItem = serializer.serializeToString();
     if (this.verboseLogging()) {
       cal.LOG("CalDAV: send: " + serializedItem);
     }
     return serializedItem;
   },
 
   // nsIChannelEventSink implementation
--- a/calendar/providers/ics/calICSCalendar.js
+++ b/calendar/providers/ics/calICSCalendar.js
@@ -362,17 +362,17 @@ calICSCalendar.prototype = {
             "The calendar could not be saved; there was a failure: 0x" + ex.result.toString(16)
           );
           self.mObserver.onError(self.superCalendar, calIErrors.MODIFICATION_FAILED, "");
           self.unlock(calIErrors.MODIFICATION_FAILED);
           self.forceRefresh();
         }
       },
       onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aItems) {
-        this.serializer.addItems(aItems, aItems.length);
+        this.serializer.addItems(aItems);
       },
     };
     listener.serializer = Cc["@mozilla.org/calendar/ics-serializer;1"].createInstance(
       Ci.calIIcsSerializer
     );
     for (let comp of this.unmappedComponents) {
       listener.serializer.addComponent(comp);
     }
--- a/calendar/resources/content/publish.js
+++ b/calendar/resources/content/publish.js
@@ -171,17 +171,17 @@ function publishItemArray(aItemArray, aP
 
   storageStream = Cc["@mozilla.org/storagestream;1"].createInstance(Ci.nsIStorageStream);
   storageStream.init(32768, 0xffffffff, null);
   outputStream = storageStream.getOutputStream(0);
 
   let serializer = Cc["@mozilla.org/calendar/ics-serializer;1"].createInstance(
     Ci.calIIcsSerializer
   );
-  serializer.addItems(aItemArray, aItemArray.length);
+  serializer.addItems(aItemArray);
   // Outlook requires METHOD:PUBLISH property:
   let methodProp = cal.getIcsService().createIcalProperty("METHOD");
   methodProp.value = "PUBLISH";
   serializer.addProperty(methodProp);
   serializer.serializeToStream(outputStream);
   outputStream.close();
 
   inputStream = storageStream.newInputStream(0);
--- a/calendar/test/unit/test_bug1199942.js
+++ b/calendar/test/unit/test_bug1199942.js
@@ -62,14 +62,14 @@ function serializeEvent_test() {
   for (let attendee of attendees) {
     ok(expectedIds.includes(attendee.id));
   }
 
   // serialize the event again and check whether the attendees still are in shape
   let serializer = Cc["@mozilla.org/calendar/ics-serializer;1"].createInstance(
     Ci.calIIcsSerializer
   );
-  serializer.addItems([event], [event].length);
+  serializer.addItems([event]);
   let serialized = ics_unfoldline(serializer.serializeToString());
   for (let id of expectedIds) {
     ok(serialized.search(id) != -1);
   }
 }
--- a/calendar/test/unit/test_ics_parser.js
+++ b/calendar/test/unit/test_ics_parser.js
@@ -163,17 +163,17 @@ function test_roundtrip() {
     "END:VJOURNAL",
     "END:VCALENDAR",
     "",
   ].join("\r\n");
 
   parser.parseString(str);
 
   let items = parser.getItems({});
-  serializer.addItems(items, items.length);
+  serializer.addItems(items);
 
   parser.getProperties({}).forEach(serializer.addProperty, serializer);
   parser.getComponents({}).forEach(serializer.addComponent, serializer);
 
   equal(
     serializer
       .serializeToString()
       .split("\r\n")