/* 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 CheckAttachmentBeforeSendHelper = {
  confirm: function() {
    return true;
  }
};

window.addEventListener('load', function CheckAttachmentBeforeSendOnLoad(aEvent) {
  window.removeEventListener(aEvent.type, CheckAttachmentBeforeSendOnLoad, false);

  window.__checkattachmentbeforesend__SendMessage = window.SendMessage;
  window.SendMessage = function SendMessage(...aArgs) {
    if (!CheckAttachmentBeforeSendHelper.confirm()) {
      return;
    }
    window.__checkattachmentbeforesend__SendMessage.apply(this, aArgs);
  };

  window.__checkattachmentbeforesend__SendMessageWithCheck = window.SendMessageWithCheck;
  window.SendMessageWithCheck = function SendMessageWithCheck(...aArgs) {
    if (!CheckAttachmentBeforeSendHelper.confirm()) {
      return;
    }
    window.__checkattachmentbeforesend__SendMessageWithCheck.apply(this, aArgs);
  };

  window.__checkattachmentbeforesend__SendMessageLater = window.SendMessageLater;
  window.SendMessageLater = function SendMessageLater(...aArgs) {
    if (!CheckAttachmentBeforeSendHelper.confirm()) {
      return;
    }
    window.__checkattachmentbeforesend__SendMessageLater.apply(this, aArgs);
  };
}, false);

@@ -283,16 +283,1092 @@
 rue;%0A  %7D
+,%0A%0A  getAllRecipients: function() %7B%0A    var msgCompFields = gMsgCompose.compFields;%0A    Recipients2CompFields(msgCompFields);%0A    gMsgCompose.expandMailingLists();%0A%0A    var recipients = %7B%0A      to:  this.splitRecipients(msgCompFields.to, 'To'),%0A      cc:  this.splitRecipients(msgCompFields.cc, 'Cc'),%0A      bcc: this.splitRecipients(msgCompFields.bcc, 'Bcc')%0A    %7D;%0A  %7D,%0A%0A  splitRecipients: function(aAddressesSource, aType)%7B%0A    var gMimeHeaderParser = Components.classes%5B'@mozilla.org/messenger/headerparser;1'%5D%0A                              .getService(Components.interfaces.nsIMsgHeaderParser);%0A    var addresses = %7B%7D;%0A    var names = %7B%7D;%0A    var fullNames = %7B%7D;%0A    var numAddresses = gMimeHeaderParser.parseHeadersWithArray(%0A                         aAddressesSource, addresses, names, fullNames);%0A    var recipients = %5B%5D;%0A    for (let i = 0; i %3C numAddresses; i++) %7B%0A      recipients.push(%7B%0A        address:  addresses.value%5Bi%5D,%0A        name:     names.value%5Bi%5D,%0A        fullName: fullNames.value%5Bi%5D,%0A        type:     aType%0A      %7D);%0A    %7D%0A    return recipients;%0A  %7D,
 %0A%7D;%0A%0Awin

Implement methods to collect recipients