mailnews/compose/public/nsIMsgComposeSecure.idl
author Mozilla Releng Treescript <release+treescript@mozilla.org>
Tue, 20 Apr 2021 08:38:25 +0000
changeset 42019 cce4fa6dd7542915bbdcef7001d730dbaef19490
parent 33769 78e76b014af7298d2faa7e5d786698a8c9a33577
permissions -rw-r--r--
no bug - Bumping Thunderbird l10n changesets r=release a=l10n-bump DONTBUILD ast -> 620865449e97c017725e82737b7ed6b099524ba1 cs -> db2ef469cce256f101b9903284692a9981870e87 es-AR -> 88f9db695e48836a1884d4c4f30537ba5256321c eu -> 95f3c5af809105718c8c2e3bf1f3c42344ec00a6 he -> 5949a2070a88172080ca36d614e602a61ce9ca41 hr -> 5baf4c12311b238fd5aa1c7da4d80b311c6fabf0 ko -> 10fca1b3e0bc00abcef72aad8ba11674558fac88 nb-NO -> d886a8d7c48166adcb9784e2a14ee046c043717b sk -> 07431c1c72e2d2084382254ccde4755b5bf0bf0c

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 *
 * 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 "nsIMsgSendReport.idl"
#include "nsISupports.idl"

interface nsIMsgCompFields;
interface nsIMsgIdentity;
interface nsIOutputStream;
interface nsIX509Cert;

/* Security interface */
[scriptable, uuid(245f2adc-410e-4bdb-91e2-a7bb42d61787)]
interface nsIMsgComposeSecure : nsISupports
{
    /**
     * Set to true if the outgoing message shall be signed.
     */
    attribute boolean signMessage;

    /**
     * Set to true if the outgoing message shall be encrypted.
     */
    attribute boolean requireEncryptMessage;

    /***************************************************************************
     * The following functions are called during message creation by nsMsgSend,
     * after the message source is completely prepared.
     ***************************************************************************/

    /**
     * Determine if encryption and/or signing is required.
     *
     * @param aIdentity   - The sender's identity
     * @param compFields  - Attributes of the composed message
     *
     * @return - Returns true if the creation of the message requires us to go through
     *           some encryption work, and false otherwise.
    */
    boolean requiresCryptoEncapsulation(in nsIMsgIdentity aIdentity, in nsIMsgCompFields aCompFields);

    /**
     * Start encryption work. Called before the encrypted data is processed.
     *
     * @param aStream     - Output stream that takes the resulting data
     * @param aRecipients - RFC 2047-encoded list of all recipients (To:, Cc:, Bcc:, ... fields), separated by "," or ", "
     *                      Recipients contain name and email addresses, just like they will be put into the message headers
     * @param compFields  - Attributes of the composed message
     * @param aIdentity   - The sender's identity
     * @param sendReport  - Report feedback to the user
     * @param aIsDraft    - True if send operation saves draft/template/etc., false if message is really sent (or sent later)
     */
    void beginCryptoEncapsulation(in nsIOutputStream aStream, in string aRecipients, in nsIMsgCompFields aCompFields, in nsIMsgIdentity aIdentity, in nsIMsgSendReport sendReport, in boolean aIsDraft);

    /**
     * Process a part of the message data. Called multiple times, usually for every
     * line of the data to be encrypted
     *
     * @param aBuf  - Buffer holding the data to be processed
     * @param aLen  - Length of the buffer (number of characters)
     */
    void mimeCryptoWriteBlock(in string aBuf, in long aLen);

    /**
     * End encryption work. Called after the encrypted data is processed.
     *
     * @param aAbort      - True if the send operation was aborted
     * @param sendReport  - Report feedback to the user
     */
    void finishCryptoEncapsulation(in boolean aAbort, in nsIMsgSendReport sendReport);

    /**
     *  Find a certificate by email address.
     *
     *  (Note: This function is used primarily for testing purposes. It runs
     *   on the main thread, which may cause nested event loop spinning.)
     *  (TODO: A better place for this might be nsISMimeJSHelper.idl,
     *   but it would require to move the C++ implementation.)
     *
     *  @param aEmailAddress     - The email address to be used as the key
     *                           - to find the certificate.
     *  @param aRequireValidCert - Set to False, to search for any certificate with a matching email address.
     *                             Set to True, if the returned certificate must be currently valid
     *                                          and usable for email security.
     *
     *  @return The matching certificate if found.
     */
    [must_use]
    nsIX509Cert findCertByEmailAddress(in ACString aEmailAddress, in boolean aRequireValidCert);
};