From 302bf1b523012e11b60425d6eee1221ebc2724eb Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sun, 3 Nov 2019 00:17:46 -0400 Subject: Issue #1258 - Part 1: Import mailnews, ldap, and mork from comm-esr52.9.1 --- mailnews/mime/public/MimeEncoder.h | 44 +++++ mailnews/mime/public/MimeHeaderParser.h | 174 +++++++++++++++++ mailnews/mime/public/moz.build | 36 ++++ mailnews/mime/public/msgIStructuredHeaders.idl | 209 ++++++++++++++++++++ mailnews/mime/public/nsICMSDecoder.idl | 29 +++ mailnews/mime/public/nsICMSEncoder.idl | 30 +++ mailnews/mime/public/nsICMSMessage.idl | 39 ++++ mailnews/mime/public/nsICMSMessage2.idl | 64 ++++++ mailnews/mime/public/nsICMSMessageErrors.idl | 35 ++++ mailnews/mime/public/nsICMSSecureMessage.idl | 42 ++++ mailnews/mime/public/nsIMimeContentTypeHandler.h | 65 +++++++ mailnews/mime/public/nsIMimeConverter.idl | 75 ++++++++ mailnews/mime/public/nsIMimeEmitter.idl | 81 ++++++++ mailnews/mime/public/nsIMimeHeaders.idl | 41 ++++ mailnews/mime/public/nsIMimeMiscStatus.idl | 76 ++++++++ mailnews/mime/public/nsIMimeObjectClassAccess.h | 49 +++++ mailnews/mime/public/nsIMimeStreamConverter.idl | 93 +++++++++ mailnews/mime/public/nsIMsgHeaderParser.idl | 235 +++++++++++++++++++++++ mailnews/mime/public/nsIPgpMimeProxy.idl | 69 +++++++ mailnews/mime/public/nsISimpleMimeConverter.idl | 22 +++ mailnews/mime/public/nsMailHeaders.h | 90 +++++++++ mailnews/mime/public/nsMsgMimeCID.h | 33 ++++ 22 files changed, 1631 insertions(+) create mode 100644 mailnews/mime/public/MimeEncoder.h create mode 100644 mailnews/mime/public/MimeHeaderParser.h create mode 100644 mailnews/mime/public/moz.build create mode 100644 mailnews/mime/public/msgIStructuredHeaders.idl create mode 100644 mailnews/mime/public/nsICMSDecoder.idl create mode 100644 mailnews/mime/public/nsICMSEncoder.idl create mode 100644 mailnews/mime/public/nsICMSMessage.idl create mode 100644 mailnews/mime/public/nsICMSMessage2.idl create mode 100644 mailnews/mime/public/nsICMSMessageErrors.idl create mode 100644 mailnews/mime/public/nsICMSSecureMessage.idl create mode 100644 mailnews/mime/public/nsIMimeContentTypeHandler.h create mode 100644 mailnews/mime/public/nsIMimeConverter.idl create mode 100644 mailnews/mime/public/nsIMimeEmitter.idl create mode 100644 mailnews/mime/public/nsIMimeHeaders.idl create mode 100644 mailnews/mime/public/nsIMimeMiscStatus.idl create mode 100644 mailnews/mime/public/nsIMimeObjectClassAccess.h create mode 100644 mailnews/mime/public/nsIMimeStreamConverter.idl create mode 100644 mailnews/mime/public/nsIMsgHeaderParser.idl create mode 100644 mailnews/mime/public/nsIPgpMimeProxy.idl create mode 100644 mailnews/mime/public/nsISimpleMimeConverter.idl create mode 100644 mailnews/mime/public/nsMailHeaders.h create mode 100644 mailnews/mime/public/nsMsgMimeCID.h (limited to 'mailnews/mime/public') diff --git a/mailnews/mime/public/MimeEncoder.h b/mailnews/mime/public/MimeEncoder.h new file mode 100644 index 000000000..7883af70e --- /dev/null +++ b/mailnews/mime/public/MimeEncoder.h @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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/. */ + +#ifndef MimeEncoder_h__ +#define MimeEncoder_h__ + +#include "nscore.h" + +namespace mozilla { +namespace mailnews { + +/// A class for encoding the bodies of MIME parts. +class MimeEncoder { +public: + virtual ~MimeEncoder() {} + + /// A callback for writing the encoded output + typedef nsresult (*OutputCallback) + (const char *buf, int32_t size, void *closure); + + /// Encodes the string in the buffer and sends it to the callback + virtual nsresult Write(const char *buffer, int32_t size) = 0; + /// Flush all pending data when no more data exists + virtual nsresult Flush() { return NS_OK; } + + /// Get an encoder that outputs Base64-encoded data + static MimeEncoder *GetBase64Encoder(OutputCallback callback, void *closure); + /// Get an encoder that outputs quoted-printable data + static MimeEncoder *GetQPEncoder(OutputCallback callback, void *closure); + +protected: + MimeEncoder(OutputCallback callback, void *closure); + OutputCallback mCallback; + void *mClosure; + uint32_t mCurrentColumn; +}; + +} // namespace mailnews +} // namespace mozilla + +#endif diff --git a/mailnews/mime/public/MimeHeaderParser.h b/mailnews/mime/public/MimeHeaderParser.h new file mode 100644 index 000000000..429e759b1 --- /dev/null +++ b/mailnews/mime/public/MimeHeaderParser.h @@ -0,0 +1,174 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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/. */ + +#ifndef MimeHeaderParser_h__ +#define MimeHeaderParser_h__ + +#include "nsCOMArray.h" +#include "nsStringGlue.h" +#include "nsTArray.h" + +class msgIAddressObject; + +namespace mozilla { +namespace mailnews { + +/** + * This is used to signal that the input header value has already been decoded + * according to RFC 2047 and is in UTF-16 form. + */ +nsCOMArray DecodedHeader(const nsAString &aHeader); + +/** + * This is used to signal that the input header value needs to be decoded + * according to RFC 2047. The charset parameter indicates the charset to assume + * that non-ASCII data is in; if the value is null (the default), then the + * charset is assumed to be UTF-8. + */ +nsCOMArray EncodedHeader(const nsACString &aHeader, + const char *aCharset = nullptr); + +namespace detail { +void DoConversion(const nsTArray &aUTF16, nsTArray &aUTF8); +}; +/** + * This is a class designed for use as temporaries so that methods can pass + * an nsTArray into methods that expect nsTArray for out + * parameters (this does not work for in-parameters). + * + * It works by internally providing an nsTArray which it uses for its + * external API operations. If the user requests an array of nsCString elements + * instead, it converts the UTF-16 array to a UTF-8 array on destruction. + */ +template +class UTF16ArrayAdapter +{ +public: + UTF16ArrayAdapter(nsTArray &aUTF8Array) + : mUTF8Array(aUTF8Array) {} + ~UTF16ArrayAdapter() { detail::DoConversion(mUTF16Array, mUTF8Array); } + operator nsTArray&() { return mUTF16Array; } +private: + nsTArray &mUTF8Array; + AutoTArray mUTF16Array; +}; + +/** + * Given a name and an email, both encoded in UTF-8, produce a string suitable + * for writing in an email header by quoting where necessary. + * + * If name is not empty, the output string will be name . If it is empty, + * the output string is just the email. Note that this DOES NOT do any RFC 2047 + * encoding. + */ +void MakeMimeAddress(const nsACString &aName, const nsACString &aEmail, + nsACString &full); + +/** + * Given a name and an email, produce a string suitable for writing in an email + * header by quoting where necessary. + * + * If name is not empty, the output string will be name . If it is empty, + * the output string is just the email. Note that this DOES NOT do any RFC 2047 + * encoding. + */ +void MakeMimeAddress(const nsAString &aName, const nsAString &aEmail, + nsAString &full); + +/** + * Given a name and an email, both encoded in UTF-8, produce a string suitable + * for displaying in UI. + * + * If name is not empty, the output string will be name . If it is empty, + * the output string is just the email. + */ +void MakeDisplayAddress(const nsAString &aName, const nsAString &aEmail, + nsAString &full); + +/** + * Returns a copy of the input which may have had some addresses removed. + * Addresses are removed if they are already in either of the supplied + * address lists. + * + * Addresses are considered to be the same if they contain the same email + * address parts, ignoring case. Display names or comments are not compared. + * + * @param aHeader The addresses to remove duplicates from. + * @param aOtherEmails Other addresses that the duplicate removal process also + * checks for duplicates against. Addresses in this list + * will not be added to the result. + * @return The original header with duplicate addresses removed. + */ +void RemoveDuplicateAddresses(const nsACString &aHeader, + const nsACString &aOtherEmails, + nsACString &result); + +/** + * Given a message header, extract all names and email addresses found in that + * header into the two arrays. + */ +void ExtractAllAddresses(const nsCOMArray &aHeader, + nsTArray &names, nsTArray &emails); + +/** + * Given a raw message header value, extract display names for every address + * found in the header. + */ +void ExtractDisplayAddresses(const nsCOMArray &aHeader, + nsTArray &addresses); + +/** + * Given a raw message header value, extract all the email addresses into an + * array. + * + * Duplicate email addresses are not removed from the output list. + */ +void ExtractEmails(const nsCOMArray &aHeader, + nsTArray &emails); + +/** + * Given a raw message header value, extract the first name/email address found + * in the header. This is essentially equivalent to grabbing the first entry of + * ExtractAllAddresses. + */ +void ExtractFirstAddress(const nsCOMArray &aHeader, + nsACString &name, nsACString &email); + +/** + * Given an RFC 2047-decoded message header value, extract the first name/email + * address found in the header. This is essentially equivalent to grabbing the + * first entry of ExtractAllAddresses. + */ +void ExtractFirstAddress(const nsCOMArray &aHeader, + nsAString &name, nsACString &email); + +/** + * Given a raw message header value, extract the first email address found in + * the header. + */ +void ExtractEmail(const nsCOMArray &aHeader, + nsACString &email); + +/** + * Given a raw message header value, extract and clean up the first display + * name found in the header. If there is no display name, the email address is + * used instead. + */ +void ExtractName(const nsCOMArray &aHeader, + nsACString &name); + +/** + * Given an RFC 2047-decoded message header value, extract the first display + * name found in the header. If there is no display name, the email address is + * returned instead. + */ +void ExtractName(const nsCOMArray &aDecodedHeader, + nsAString &name); + +} // namespace mailnews +} // namespace mozilla + +#endif diff --git a/mailnews/mime/public/moz.build b/mailnews/mime/public/moz.build new file mode 100644 index 000000000..58243068e --- /dev/null +++ b/mailnews/mime/public/moz.build @@ -0,0 +1,36 @@ +# vim: set filetype=python: +# 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/. + +XPIDL_SOURCES += [ + 'msgIStructuredHeaders.idl', + 'nsICMSDecoder.idl', + 'nsICMSEncoder.idl', + 'nsICMSMessage.idl', + 'nsICMSMessage2.idl', + 'nsICMSMessageErrors.idl', + 'nsICMSSecureMessage.idl', + 'nsIMimeConverter.idl', + 'nsIMimeEmitter.idl', + 'nsIMimeHeaders.idl', + 'nsIMimeMiscStatus.idl', + 'nsIMimeStreamConverter.idl', + 'nsIMsgHeaderParser.idl', + 'nsIPgpMimeProxy.idl', + 'nsISimpleMimeConverter.idl', +] + +XPIDL_MODULE = 'mime' + +EXPORTS += [ + 'nsIMimeContentTypeHandler.h', + 'nsIMimeObjectClassAccess.h', + 'nsMailHeaders.h', + 'nsMsgMimeCID.h', +] + +EXPORTS.mozilla.mailnews += [ + 'MimeEncoder.h', + 'MimeHeaderParser.h', +] diff --git a/mailnews/mime/public/msgIStructuredHeaders.idl b/mailnews/mime/public/msgIStructuredHeaders.idl new file mode 100644 index 000000000..9d3b3aa9a --- /dev/null +++ b/mailnews/mime/public/msgIStructuredHeaders.idl @@ -0,0 +1,209 @@ +/* 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" + +%{C++ +#include "nsCOMArray.h" + +#define NS_ISTRUCTUREDHEADERS_CONTRACTID \ + "@mozilla.org/messenger/structuredheaders;1" +%} + +interface msgIAddressObject; +interface nsIUTF8StringEnumerator; + +/** + * A collection of MIME headers that are stored in a rich, structured format. + * + * The structured forms defined in this method use the structured decoder and + * encoder functionality found in jsmime to interconvert between the raw string + * forms found in the actual message text and the structured forms supported by + * this interface. Extensions can register their own custom structured headers + * by listing the source URL of their code under the category + * "custom-mime-encoder". + * + * The alternative modes of access for specific headers are expected to only + * work for the headers for which that mode of access is the correct one. For + * example, retrieving the "To" header from getUnstructuredHeader would fail, + * since the To header is not an unstructured header but an addressing header. + * They are provided mostly as a convenience to C++ which is much less able to + * utilize a fully generic format. + * + * With the exception of mismatched headers, the methods do not throw an + * exception if the header is missing but rather return an appropriate default + * value as indicated in their documentation. + */ +[scriptable, uuid(e109bf4f-788f-47ba-bfa8-1236ede05597)] +interface msgIStructuredHeaders : nsISupports { + /** + * Retrieve the value of the header stored in this set of headers. If the + * header is not present, then undefined is returned. + * + * @param aHeaderName The name of the header to retrieve. + */ + jsval getHeader(in string aHeaderName); + + /** + * Return true if and only if the given header is already set. + * + * @param aHeaderName The name of the header to retrieve. + */ + bool hasHeader(in string aHeaderName); + + /** + * Retrieve the value of the header as if it is an unstructured header. Such + * headers include most notably the Subject header. If the header is not + * present, then null is returned. This is reflected in C++ as an empty string + * with IsVoid() set to true (distinguishing it from a header that is present + * but contains an empty string). + * + * @param aHeaderName The name of the header to retrieve. + */ + AString getUnstructuredHeader(in string aHeaderName); + + /** + * Retrieve the value of the header if it is an addressing header, such as the + * From or To headers. If the header is not present, then an empty array is + * returned. + * + * @param aHeaderName The name of the header to retrieve. + * @param aPreserveGroups If false (the default), then the result is a flat + * list of addresses, with all group annotations + * removed. + * If true, then some address objects may represent + * groups in the header, preserving the original header + * structure. + */ + void getAddressingHeader(in string aHeaderName, + [optional] in boolean aPreserveGroups, [optional] out unsigned long count, + [array, size_is(count), retval] out msgIAddressObject addresses); + + /** + * Retrieve a raw version of the header value as would be represented in MIME. + * This form does not include the header name and colon, trailing whitespace, + * nor embedded CRLF pairs in the case of very long header names. + * + * @param aHeaderName The name of the header to retrieve. + */ + AUTF8String getRawHeader(in string aHeaderName); + + /** + * Retrieve an enumerator of the names of all headers in this set of headers. + * The header names returned may be in different cases depending on the + * precise implementation of this interface, so implementations should not + * rely on an exact kind of case being returned. + */ + readonly attribute nsIUTF8StringEnumerator headerNames; + + /** + * Retrieve the MIME representation of all of the headers. + * + * The header values are emitted in an ASCII form, unless internationalized + * email addresses are involved. The extra CRLF indicating the end of headers + * is not included in this representation. + * + * This accessor is provided mainly for the benefit of C++ consumers of this + * interface, since the JSMime headeremitter functionality allows more + * fine-grained customization of the results. + */ + AUTF8String buildMimeText(); + +%{C++ + /** + * A special variant of getAddressingHeader that is specialized better for C++ + * users of this API. + */ + nsresult GetAddressingHeader(const char *aPropertyName, + nsCOMArray &addrs, + bool aPreserveGroups = false) + { + msgIAddressObject **addrPtr; + uint32_t length; + nsresult rv = GetAddressingHeader(aPropertyName, aPreserveGroups, &length, + &addrPtr); + NS_ENSURE_SUCCESS(rv, rv); + addrs.Adopt(addrPtr, length); + return NS_OK; + } +%} + +}; + +/** + * An interface that enhances msgIStructuredHeaders by allowing the values of + * headers to be modified. + */ +[scriptable, uuid(5dcbbef6-2356-45d8-86d7-b3e73f9c9a0c)] +interface msgIWritableStructuredHeaders : msgIStructuredHeaders { + /** + * Store the given value for the given header, overwriting any previous value + * that was stored for said header. + * + * @param aHeaderName The name of the header to store. + * @param aValue The rich, structured value of the header to store. + */ + void setHeader(in string aHeaderName, in jsval aValue); + + /** + * Forget any previous value that was stored for the given header. + * + * @param aHeaderName The name of the header to delete. + */ + void deleteHeader(in string aHeaderName); + + /** + * Copy all of the structured values from another set of structured headers to + * the current one, overwriting any values that may have been specified + * locally. Note that the copy is a shallow copy of the value. + * + * @param aOtherHeaders A set of header values to be copied. + */ + void addAllHeaders(in msgIStructuredHeaders aOtherHeaders); + + /** + * Set the value of the header as if it were an unstructured header. Such + * headers include most notably the Subject header. + * + * @param aHeaderName The name of the header to store. + * @param aValue The value to store. + */ + void setUnstructuredHeader(in string aHeaderName, in AString aValue); + + /** + * Set the value of the header as if it were an addressing header, such as the + * From or To headers. + * + * @param aHeaderName The name of the header to store. + */ + void setAddressingHeader(in string aHeaderName, + [array, size_is(aCount)] in msgIAddressObject aAddresses, + in unsigned long aCount); + + /** + * Store the value of the header using a raw version as would be represented + * in MIME. So as to handle 8-bit headers properly, the charset needs to be + * specified, although it may be null. + * + * @param aHeaderName The name of the header to store. + * @param aValue The raw MIME header value to store. + * @param aCharset The expected charset of aValue. + */ + void setRawHeader(in string aHeaderName, in ACString aValue, + in string aCharset); + +%{C++ + /** + * A special variant of setAddressingHeader that is specialized better for C++ + * users of this API. + */ + nsresult SetAddressingHeader(const char *aPropertyName, + const nsCOMArray &addrs) + { + return SetAddressingHeader(aPropertyName, + const_cast&>(addrs).Elements(), + addrs.Length()); + } +%} +}; diff --git a/mailnews/mime/public/nsICMSDecoder.idl b/mailnews/mime/public/nsICMSDecoder.idl new file mode 100644 index 000000000..f67f1e640 --- /dev/null +++ b/mailnews/mime/public/nsICMSDecoder.idl @@ -0,0 +1,29 @@ +/* -*- Mode: C++; tab-width: 2; 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 "nsISupports.idl" + +%{ C++ +typedef void (*NSSCMSContentCallback)(void *arg, const char *buf, unsigned long len); + +#define NS_CMSDECODER_CONTRACTID "@mozilla.org/nsCMSDecoder;1" +%} + +native NSSCMSContentCallback(NSSCMSContentCallback); + +interface nsICMSMessage; + +/** + * nsICMSDecoder + * Interface to decode an CMS message + */ +[uuid(c7c7033b-f341-4065-aadd-7eef55ce0dda)] +interface nsICMSDecoder : nsISupports +{ + void start(in NSSCMSContentCallback cb, in voidPtr arg); + void update(in string aBuf, in long aLen); + void finish(out nsICMSMessage msg); +}; + diff --git a/mailnews/mime/public/nsICMSEncoder.idl b/mailnews/mime/public/nsICMSEncoder.idl new file mode 100644 index 000000000..a82f5e0de --- /dev/null +++ b/mailnews/mime/public/nsICMSEncoder.idl @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 2; 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 "nsISupports.idl" + +%{ C++ +typedef void (*NSSCMSContentCallback)(void *arg, const char *buf, unsigned long len); + +#define NS_CMSENCODER_CONTRACTID "@mozilla.org/nsCMSEncoder;1" +%} + +native NSSCMSContentCallback(NSSCMSContentCallback); + +interface nsICMSMessage; + +/** + * nsICMSEncoder + * Interface to Encode an CMS message + */ +[uuid(17dc4fb4-e379-4e56-a4a4-57cdcc74816f)] +interface nsICMSEncoder : nsISupports +{ + void start(in nsICMSMessage aMsg, in NSSCMSContentCallback cb, in voidPtr arg); + void update(in string aBuf, in long aLen); + void finish(); + void encode(in nsICMSMessage aMsg); +}; + diff --git a/mailnews/mime/public/nsICMSMessage.idl b/mailnews/mime/public/nsICMSMessage.idl new file mode 100644 index 000000000..1d67bf51d --- /dev/null +++ b/mailnews/mime/public/nsICMSMessage.idl @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 2; 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 "nsISupports.idl" + +%{ C++ +#define NS_CMSMESSAGE_CONTRACTID "@mozilla.org/nsCMSMessage;1" +%} + +[ptr] native UnsignedCharPtr(unsigned char); + +interface nsIX509Cert; +interface nsIArray; + +/** + * nsICMSMessage + * Interface to a CMS Message + */ +[uuid(c6d51c22-73e9-4dad-86b9-bde584e33c63)] +interface nsICMSMessage : nsISupports +{ + void contentIsSigned(out boolean aSigned); + void contentIsEncrypted(out boolean aEncrypted); + void getSignerCommonName(out string aName); + void getSignerEmailAddress(out string aEmail); + void getSignerCert(out nsIX509Cert scert); + void getEncryptionCert(out nsIX509Cert ecert); + void verifySignature(); + void verifyDetachedSignature(in UnsignedCharPtr aDigestData, in unsigned long aDigestDataLen); + void CreateEncrypted(in nsIArray aRecipientCerts); + + /* The parameter aDigestType must be one of the values in nsICryptoHash */ + void CreateSigned(in nsIX509Cert scert, in nsIX509Cert ecert, + in UnsignedCharPtr aDigestData, + in unsigned long aDigestDataLen, in int16_t aDigestType); +}; + diff --git a/mailnews/mime/public/nsICMSMessage2.idl b/mailnews/mime/public/nsICMSMessage2.idl new file mode 100644 index 000000000..9360279c6 --- /dev/null +++ b/mailnews/mime/public/nsICMSMessage2.idl @@ -0,0 +1,64 @@ +/* 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" + +interface nsISMimeVerificationListener; + +[ptr] native UnsignedCharPtr(unsigned char); + +/* + * This interface is currently not marked scriptable, + * because its verification functions are meant to look like those + * in nsICMSMessage. At the time the ptr type is eliminated in both + * interfaces, both should be made scriptable. + */ + +[uuid(b21a3636-2287-4b9f-9a22-25f245981ef0)] +interface nsICMSMessage2 : nsISupports +{ + /** + * Async version of nsICMSMessage::VerifySignature. + * Code will be executed on a background thread and + * availability of results will be notified using a + * call to nsISMimeVerificationListener. + */ + void asyncVerifySignature(in nsISMimeVerificationListener listener); + + /** + * Async version of nsICMSMessage::VerifyDetachedSignature. + * Code will be executed on a background thread and + * availability of results will be notified using a + * call to nsISMimeVerificationListener. + * + * We are using "native unsigned char" ptr, because the function + * signatures of this one and nsICMSMessage::verifyDetachedSignature + * should be the identical. Cleaning up nsICMSMessages needs to be + * postponed, because this async version is needed on MOZILLA_1_8_BRANCH. + * + * Once both interfaces get cleaned up, the function signature should + * look like: + * [array, length_is(aDigestDataLen)] + * in octet aDigestData, + * in unsigned long aDigestDataLen); + */ + void asyncVerifyDetachedSignature(in nsISMimeVerificationListener listener, + in UnsignedCharPtr aDigestData, + in unsigned long aDigestDataLen); +}; + +[uuid(5226d698-0773-4f25-b94c-7944b3fc01d3)] +interface nsISMimeVerificationListener : nsISupports { + + /** + * Notify that results are ready, that have been requested + * using nsICMSMessage2::asyncVerify[Detached]Signature() + * + * verificationResultCode matches synchronous result code from + * nsICMSMessage::verify[Detached]Signature + */ + void notify(in nsICMSMessage2 verifiedMessage, + in nsresult verificationResultCode); +}; + diff --git a/mailnews/mime/public/nsICMSMessageErrors.idl b/mailnews/mime/public/nsICMSMessageErrors.idl new file mode 100644 index 000000000..d429cc671 --- /dev/null +++ b/mailnews/mime/public/nsICMSMessageErrors.idl @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 2; 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 "nsISupports.idl" + +/** + * nsICMSMessageErrors + * Scriptable error constants for nsICMSMessage + */ +[scriptable,uuid(267f1a5b-88f7-413b-bc49-487e745282f1)] +interface nsICMSMessageErrors : nsISupports +{ + const long SUCCESS = 0; + const long GENERAL_ERROR = 1; + const long VERIFY_NOT_SIGNED = 1024; + const long VERIFY_NO_CONTENT_INFO = 1025; + const long VERIFY_BAD_DIGEST = 1026; + const long VERIFY_NOCERT = 1028; + const long VERIFY_UNTRUSTED = 1029; + const long VERIFY_ERROR_UNVERIFIED = 1031; + const long VERIFY_ERROR_PROCESSING = 1032; + const long VERIFY_BAD_SIGNATURE = 1033; + const long VERIFY_DIGEST_MISMATCH = 1034; + const long VERIFY_UNKNOWN_ALGO = 1035; + const long VERIFY_UNSUPPORTED_ALGO = 1036; + const long VERIFY_MALFORMED_SIGNATURE = 1037; + const long VERIFY_HEADER_MISMATCH = 1038; + const long VERIFY_NOT_YET_ATTEMPTED = 1039; + const long VERIFY_CERT_WITHOUT_ADDRESS = 1040; + + const long ENCRYPT_NO_BULK_ALG = 1056; + const long ENCRYPT_INCOMPLETE = 1057; +}; diff --git a/mailnews/mime/public/nsICMSSecureMessage.idl b/mailnews/mime/public/nsICMSSecureMessage.idl new file mode 100644 index 000000000..6442e319a --- /dev/null +++ b/mailnews/mime/public/nsICMSSecureMessage.idl @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 2; 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 "nsISupports.idl" + +interface nsIX509Cert; + +/** + * nsICMSManager (service) + * Interface to access users certificate store + */ +[scriptable, uuid(17103436-0111-4819-a751-0fc4aa6e3d79)] +interface nsICMSSecureMessage : nsISupports +{ + /** + * getCertByPrefID - a BASE64 string representing a user's + * certificate (or NULL if there isn't one) + */ + string getCertByPrefID(in string certID); + + /** + * decodeCert - decode a BASE64 string into an X509Certificate object + */ + nsIX509Cert decodeCert(in string value); + + /** + * sendMessage - send a text message to the recipient indicated + * by the base64-encoded cert. + */ + string sendMessage(in string msg, in string cert); + + /** + * receiveMessage - receive an encrypted (enveloped) message + */ + string receiveMessage(in string msg); +}; + +%{C++ +#define NS_CMSSECUREMESSAGE_CONTRACTID "@mozilla.org/nsCMSSecureMessage;1" +%} diff --git a/mailnews/mime/public/nsIMimeContentTypeHandler.h b/mailnews/mime/public/nsIMimeContentTypeHandler.h new file mode 100644 index 000000000..f1b828673 --- /dev/null +++ b/mailnews/mime/public/nsIMimeContentTypeHandler.h @@ -0,0 +1,65 @@ +/* -*- 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/. */ + +/* + * This interface is implemented by content type handlers that will be + * called upon by libmime to process various attachments types. The primary + * purpose of these handlers will be to represent the attached data in a + * viewable HTML format that is useful for the user + * + * Note: These will all register by their content type prefixed by the + * following: mimecth:text/vcard + * + * libmime will then use the XPCOM Component Manager to + * locate the appropriate Content Type handler + */ +#ifndef nsIMimeContentTypeHandler_h_ +#define nsIMimeContentTypeHandler_h_ + +typedef struct { + bool force_inline_display; +} contentTypeHandlerInitStruct; + +#include "nsISupports.h" +#include "mimecth.h" + +// {20DABD99-F8B5-11d2-8EE0-00A024A7D144} +#define NS_IMIME_CONTENT_TYPE_HANDLER_IID \ + { 0x20dabd99, 0xf8b5, 0x11d2, \ + { 0x8e, 0xe0, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } } + +// {20DABDA1-F8B5-11d2-8EE0-00A024A7D144} +#define NS_VCARD_CONTENT_TYPE_HANDLER_CID \ + { 0x20dabda1, 0xf8b5, 0x11d2, \ + { 0x8e, 0xe0, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } } + +#define NS_SMIME_CONTENT_TYPE_HANDLER_CID \ + { 0x20dabdac, 0xf8b5, 0x11d2, \ + { 0xFF, 0xe0, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } } + +#define NS_SIGNED_CONTENT_TYPE_HANDLER_CID \ + { 0x20dabdac, 0xf8b5, 0x11d2, \ + { 0xFF, 0xe0, 0x0, 0xaf, 0x19, 0xa7, 0xd1, 0x44 } } + +#define NS_PGPMIME_CONTENT_TYPE_HANDLER_CID \ + { 0x212f415f, 0xf8b5, 0x11d2, \ + { 0xFF, 0xe0, 0x0, 0xaf, 0x19, 0xa7, 0xd1, 0x44 } } + + +class nsIMimeContentTypeHandler : public nsISupports { +public: + NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMIME_CONTENT_TYPE_HANDLER_IID) + + NS_IMETHOD GetContentType(char **contentType) = 0; + + NS_IMETHOD CreateContentTypeHandlerClass(const char *content_type, + contentTypeHandlerInitStruct *initStruct, + MimeObjectClass **objClass) = 0; +}; + +NS_DEFINE_STATIC_IID_ACCESSOR(nsIMimeContentTypeHandler, + NS_IMIME_CONTENT_TYPE_HANDLER_IID) + +#endif /* nsIMimeContentTypeHandler_h_ */ diff --git a/mailnews/mime/public/nsIMimeConverter.idl b/mailnews/mime/public/nsIMimeConverter.idl new file mode 100644 index 000000000..05aae7662 --- /dev/null +++ b/mailnews/mime/public/nsIMimeConverter.idl @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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" + +/** + * Encode/decode mail headers (via libmime). + */ +[scriptable, uuid(0d3f5531-2dbe-40d3-9280-f6ac45a6f5e0)] +interface nsIMimeConverter : nsISupports { + /** + * Suggested byte length limit for use when calling encodeMimePartIIStr_UTF8. + */ + const long MIME_ENCODED_WORD_SIZE = 72; + const long MAX_CHARSET_NAME_LENGTH = 64; + + /** + * Encode a UTF-8 string into a form containing only ASCII characters using + * RFC 2047 encoded words where necessary. + * + * Note that, although allowed for the present time, encoding to charsets + * other than UTF-8 is considered deprecated. + * + * @param aHeader UTF-8 header to encode. + * @param aAddressingHeader Is the header a list of email addresses? + * @param aMailCharset Charset to use when encoding (see above for note). + * @param aFieldNameLen Header field name length (ex: "From: " = 6) + * @param aMaxLineLen Maximum length of an individual line. Use + * MIME_ENCODED_WORD_SIZE for best results. + * + * @return The encoded header. + */ + AUTF8String encodeMimePartIIStr_UTF8(in AUTF8String aHeader, + in boolean aAddressingHeader, + in string aMailCharset, + in long aFieldNameLen, + in long aMaxLineLen); + + /** + * Decode a MIME header to UTF-8 if conversion is required. Marked as + * noscript because the return value may contain non-ASCII characters. + * + * @param header A (possibly encoded) header to decode. + * @param default_charset The charset to apply to un-labeled non-UTF-8 data. + * @param override_charset If true, default_charset is used instead of any + * charset labeling other than UTF-8. + * @param eatContinuations If true, unfold headers. + * + * @return UTF-8 encoded value if conversion was required, nullptr if no + * conversion was required. + */ + AUTF8String decodeMimeHeaderToUTF8(in ACString header, + in string default_charset, + in boolean override_charset, + in boolean eatContinuations); + + /** + * Decode a MIME header to UTF-16. + * + * @param header A (possibly encoded) header to decode. + * @param default_charset The charset to apply to un-labeled non-UTF-8 data. + * @param override_charset If true, default_charset is used instead of any + * charset labeling other than UTF-8. + * @param eatContinuations If true, unfold headers. + * + * @return UTF-16 encoded value as an AString. + */ + AString decodeMimeHeader(in string header, + in string default_charset, + in boolean override_charset, + in boolean eatContinuations); +}; + diff --git a/mailnews/mime/public/nsIMimeEmitter.idl b/mailnews/mime/public/nsIMimeEmitter.idl new file mode 100644 index 000000000..b129b4e86 --- /dev/null +++ b/mailnews/mime/public/nsIMimeEmitter.idl @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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 "nsrootidl.idl" + +interface nsIOutputStream; +interface nsIInputStream; +interface nsIURI; +interface nsIStreamListener; +interface nsIChannel; + +[scriptable, uuid(eb9beb09-44de-4ad2-a560-f572b1afd534)] +interface nsMimeHeaderDisplayTypes +{ + const long MicroHeaders = 0; + const long NormalHeaders = 1; + const long AllHeaders = 2; +}; + +%{C++ +#define NS_IMIME_MISC_STATUS_KEY "@mozilla.org/MimeMiscStatus;1?type=" +%} + +[scriptable, uuid(7a57166f-2891-4122-9a74-6c3fab0caac3)] +interface nsIMimeEmitter : nsISupports { + + // Output listener to allow access to it from mime. + attribute nsIStreamListener outputListener; + + // These will be called to start and stop the total operation. + void initialize(in nsIURI url, in nsIChannel aChannel, in long aFormat); + void complete(); + + // Set the output stream/listener for processed data. + void setPipe(in nsIInputStream inputStream, in nsIOutputStream outStream); + + // Header handling routines. + void startHeader(in boolean rootMailHeader, in boolean headerOnly, + [const] in string msgID, [const] in string outCharset); + void addHeaderField([const] in string field, [const] in string value); + void addAllHeaders(in ACString allheaders); + + /** + * Write the HTML Headers for the current attachment. + * Note: Book case this with an EndHeader call. + * + * @param name The name of this attachment. + */ + void writeHTMLHeaders([const] in AUTF8String name); + + /** + * Finish writing the headers for the current attachment. + * + * @param name The name of this attachment. + */ + void endHeader([const] in AUTF8String name); + + void updateCharacterSet([const] in string aCharset); + + // Attachment handling routines. + void startAttachment([const] in AUTF8String name, + [const] in string contentType, + [const] in string url, in boolean aNotDownloaded); + void addAttachmentField([const] in string field, [const] in string value); + void endAttachment(); + + void endAllAttachments(); + + // Body handling routines. + void startBody(in boolean bodyOnly, [const] in string msgID, [const] in string outCharset); + void writeBody([const] in AUTF8String buf, out uint32_t amountWritten); + void endBody(); + + // Generic write routine. This is necessary for output that + // libmime needs to pass through without any particular parsing + // involved (i.e. decoded images, HTML Body Text, etc... + void write([const] in ACString buf, out uint32_t amountWritten); + void utilityWrite([const] in string buf); +}; diff --git a/mailnews/mime/public/nsIMimeHeaders.idl b/mailnews/mime/public/nsIMimeHeaders.idl new file mode 100644 index 000000000..3a0d05c49 --- /dev/null +++ b/mailnews/mime/public/nsIMimeHeaders.idl @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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 "msgIStructuredHeaders.idl" + +%{C++ +#define NS_IMIMEHEADERS_CONTRACTID \ + "@mozilla.org/messenger/mimeheaders;1" +%} + +/** + * An interface that can extract individual headers from a body of headers. + */ +[scriptable, uuid(a9222679-b991-4786-8314-f8819c3a2ba3)] +interface nsIMimeHeaders : msgIStructuredHeaders { + /// Feed in the text of headers + void initialize(in ACString allHeaders); + + /** + * Get the text of a header. + * + * Leading and trailing whitespace from headers will be stripped from the + * return value. If getAllOfThem is set to true, then the returned string will + * have all of the values of the header, in order, joined with the ',\r\n\t'. + * + * If the header is not present, then the returned value is NULL. + */ + ACString extractHeader(in string headerName, in boolean getAllOfThem); + + /** + * The current text of all header data. + * + * Unlike the asMimeText property, this result preserves the original + * representation of the header text, including alternative line endings or + * custom, non-8-bit text. For instances of this interface, this attribute is + * usually preferable to asMimeText. + */ + readonly attribute ACString allHeaders; +}; diff --git a/mailnews/mime/public/nsIMimeMiscStatus.idl b/mailnews/mime/public/nsIMimeMiscStatus.idl new file mode 100644 index 000000000..3621cdb85 --- /dev/null +++ b/mailnews/mime/public/nsIMimeMiscStatus.idl @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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 "nsrootidl.idl" + +interface nsIChannel; +interface nsIMsgMailNewsUrl; +interface nsIUTF8StringEnumerator; +interface nsIMsgDBHdr; +interface nsIURI; +interface nsIWritablePropertyBag2; + +[scriptable, uuid(4644FB25-5255-11d3-82B8-444553540002)] +interface nsIMimeMiscStatus : nsISupports{ + + string GetWindowXULandJS(); + string GetGlobalXULandJS(); + string GetIndividualXUL(in string aName, in string aHeader, in string aEmail); + + long GetMiscStatus(in string aName, in string aEmail); + string GetImageURL(in long aStatus); +}; + +// this is a simple interface which allows someone to listen to all the headers +// that are discovered by mime. We can use this when displaying a message to update +// the msg header in JS. +[scriptable, uuid(e0e821f0-cecf-4cb3-be5b-ee58b6868343)] +interface nsIMsgHeaderSink : nsISupports +{ + // You must finish consuming the iterators before returning from processHeaders. aHeaderNames and aHeaderValues will ALWAYS have the same + // number of elements in them + void processHeaders(in nsIUTF8StringEnumerator aHeaderNames, in nsIUTF8StringEnumerator aHeaderValues, in boolean dontCollectAddress); + + void handleAttachment(in string contentType, in string url, in wstring displayName, in string uri, + in boolean aNotDownloaded); + + /** + * Add a metadata field to the current attachment, e.g. "X-Mozilla-PartSize". + * + * @param field The field to add + * @param value The value of the field + */ + void addAttachmentField(in string field, in string value); + void onEndAllAttachments(); + + // onEndMsgHeaders is called after libmime is done processing a message. At this point it is safe for + // elements like the UI to update junk status, process return receipts, etc. + void onEndMsgHeaders(in nsIMsgMailNewsUrl url); + + // onEndMsgDownload is triggered when layout says it is actually done rendering + // the message body in the UI. + void onEndMsgDownload(in nsIMsgMailNewsUrl url); + + attribute nsISupports securityInfo; + + /** + * onMsgHasRemoteContent is called each time content policy encounters remote + * content that it will block from loading. + * @param aMsgHdr header of the message the content is located in + * @param aContentURI location that will be blocked. + * @param aCanOverride can the blocking be overridden or not + */ + void onMsgHasRemoteContent(in nsIMsgDBHdr aMsgHdr, in nsIURI aContentURI, in boolean aCanOverride); + + readonly attribute nsIMsgDBHdr dummyMsgHeader; + + // used as a hook for extension mime content handlers to store data that can later + // be accessed by other parts of the code, e.g., UI code. + // TODO - Should replace securityInfo + readonly attribute nsIWritablePropertyBag2 properties; + // When streaming a new message, properties should be reset, so that there are + // not previous values lurking around. + void resetProperties(); +}; diff --git a/mailnews/mime/public/nsIMimeObjectClassAccess.h b/mailnews/mime/public/nsIMimeObjectClassAccess.h new file mode 100644 index 000000000..55d7a86ad --- /dev/null +++ b/mailnews/mime/public/nsIMimeObjectClassAccess.h @@ -0,0 +1,49 @@ +/* -*- 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/. */ + +/* + * This interface is implemented by libmime. This interface is used by + * a Content-Type handler "Plug In" (i.e. vCard) for accessing various + * internal information about the object class system of libmime. When + * libmime progresses to a C++ object class, this would probably change. + */ +#ifndef nsIMimeObjectClassAccess_h_ +#define nsIMimeObjectClassAccess_h_ + +// {C09EDB23-B7AF-11d2-B35E-525400E2D63A} +#define NS_IMIME_OBJECT_CLASS_ACCESS_IID \ + { 0xc09edb23, 0xb7af, 0x11d2, \ + { 0xb3, 0x5e, 0x52, 0x54, 0x0, 0xe2, 0xd6, 0x3a } } + +class nsIMimeObjectClassAccess : public nsISupports { +public: + NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMIME_OBJECT_CLASS_ACCESS_IID) + + // These methods are all implemented by libmime to be used by + // content type handler plugins for processing stream data. + + // This is the write call for outputting processed stream data. + NS_IMETHOD MimeObjectWrite(void *mimeObject, + char *data, + int32_t length, + bool user_visible_p) = 0; + + // The following group of calls expose the pointers for the object + // system within libmime. + NS_IMETHOD GetmimeInlineTextClass(void **ptr) = 0; + NS_IMETHOD GetmimeLeafClass(void **ptr) = 0; + NS_IMETHOD GetmimeObjectClass(void **ptr) = 0; + NS_IMETHOD GetmimeContainerClass(void **ptr) = 0; + NS_IMETHOD GetmimeMultipartClass(void **ptr) = 0; + NS_IMETHOD GetmimeMultipartSignedClass(void **ptr) = 0; + NS_IMETHOD GetmimeEncryptedClass(void **ptr) = 0; + + NS_IMETHOD MimeCreate(char* content_type, void * hdrs, void * opts, void **ptr) = 0; +}; + +NS_DEFINE_STATIC_IID_ACCESSOR(nsIMimeObjectClassAccess, + NS_IMIME_OBJECT_CLASS_ACCESS_IID) + +#endif /* nsIMimeObjectClassAccess_h_ */ diff --git a/mailnews/mime/public/nsIMimeStreamConverter.idl b/mailnews/mime/public/nsIMimeStreamConverter.idl new file mode 100644 index 000000000..bde6175c4 --- /dev/null +++ b/mailnews/mime/public/nsIMimeStreamConverter.idl @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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 "nsrootidl.idl" +#include "nsIMimeHeaders.idl" +#include "nsIMsgIdentity.idl" +#include "nsIMsgHdr.idl" + +interface nsIURI; + +typedef long nsMimeOutputType; + +[scriptable, uuid(fdc2956e-d558-43fb-bfdd-fb9511229aa5)] +interface nsMimeOutput +{ + const long nsMimeMessageSplitDisplay = 0; + const long nsMimeMessageHeaderDisplay = 1; + const long nsMimeMessageBodyDisplay = 2; + const long nsMimeMessageQuoting = 3; + const long nsMimeMessageBodyQuoting = 4; + const long nsMimeMessageRaw = 5; + const long nsMimeMessageDraftOrTemplate = 6; + const long nsMimeMessageEditorTemplate = 7; + const long nsMimeMessagePrintOutput = 9; + const long nsMimeMessageSaveAs = 10; + const long nsMimeMessageSource = 11; + const long nsMimeMessageFilterSniffer = 12; + const long nsMimeMessageDecrypt = 13; + const long nsMimeMessageAttach = 14; + const long nsMimeUnknown = 15; +}; + +[scriptable, uuid(FA81CAA0-6261-11d3-8311-00805F2A0107)] +interface nsIMimeStreamConverterListener : nsISupports{ + void onHeadersReady(in nsIMimeHeaders headers); +}; + +/** + * This interface contains mailnews mime specific information for stream + * converters. Most of the code is just stuff that has been moved out + * of nsIStreamConverter.idl to make it more generic. + */ +[scriptable, uuid(d894c833-29c5-495b-880c-9a9f847bfdc9)] +interface nsIMimeStreamConverter : nsISupports { + + /** + * Set the desired mime output type on the converer. + */ + void SetMimeOutputType(in nsMimeOutputType aType); + + void GetMimeOutputType(out nsMimeOutputType aOutFormat); + + /** + * This is needed by libmime for MHTML link processing...the url is the URL + * string associated with this input stream. + */ + void SetStreamURI(in nsIURI aURI); + + /** + * Used to extract headers while parsing a message. + */ + void SetMimeHeadersListener(in nsIMimeStreamConverterListener listener, in nsMimeOutputType aType); + + /** + * This is used for forward inline, both as a filter action, and from the UI. + */ + attribute boolean forwardInline; + + /** + * This is used for a forward inline filter action. When streaming is done, + * we won't open a compose window with the editor contents. + */ + attribute boolean forwardInlineFilter; + + /** + * Address for the forward inline filter to forward the message to. + */ + attribute AString forwardToAddress; + /** + * Use the opposite compose format, used for forward inline. + */ + attribute boolean overrideComposeFormat; + + /** + * This is used for OpenDraft, OpenEditorTemplate and Forward inline (which use OpenDraft) + */ + attribute nsIMsgIdentity identity; + attribute string originalMsgURI; + attribute nsIMsgDBHdr origMsgHdr; +}; diff --git a/mailnews/mime/public/nsIMsgHeaderParser.idl b/mailnews/mime/public/nsIMsgHeaderParser.idl new file mode 100644 index 000000000..2512623d8 --- /dev/null +++ b/mailnews/mime/public/nsIMsgHeaderParser.idl @@ -0,0 +1,235 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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" + +%{C++ +#define NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID \ + "@mozilla.org/messenger/headerparser;1" +%} + +/** + * A structured representation of an address. + * + * This is meant to correspond to the address production from RFC 5322. As a + * result, an instance of this interface is either a single mailbox or a group + * of mailboxes. The difference between the two forms is in which attribute is + * undefined: mailboxes leave the members attribute undefined while groups leave + * the email attribute undefined. + * + * For example, an address like "John Doe " will, when + * parsed, result in an instance with the name attribute set to "John Doe", the + * email attribute set to "jdoe@machine.example", and the members variable left + * undefined. + * + * A group like "undisclosed-recipients:;" will, when parsed, result in an + * instance with the name attribute set to "undisclosed-recipients", the email + * attribute left defined, and the members variable set to an empty array. + * + * In general, the attributes of this interface are always meant to be in a form + * suitable for display purposes, and not in a form usable for MIME emission. In + * particular, email addresses could be fully internationalized and non-ASCII, + * RFC 2047-encoded words may appear in names, and the name or email parameters + * are unquoted. + */ +[scriptable, uuid(b19f5636-ebc4-470e-b46c-98b5fc7e88c9)] +interface msgIAddressObject : nsISupports { + /// The name of the mailbox or group. + readonly attribute AString name; + + /// The email of the mailbox. + readonly attribute AString email; + + /** + * The member mailboxes of this group, which may be an empty list. + * + * Due to the limitations of XPIDL, the type of this attribute cannot be + * properly reflected. It is actually an array of msgIAddressObject instances, + * although it is instead undefined if this object does not represent a group. + */ + readonly attribute jsval group; + + /// Return a string form of this object that is suitable for display. + AString toString(); +}; + +/** + * A utility service for manipulating addressing headers in email messages. + * + * This interface is designed primarily for use from JavaScript code; code in + * C++ should use the methods in MimeHeaderParser.h instead, as it is better + * designed to take advantage of C++'s features, particularly with respect to + * arrays. + * + * There are two methods for parsing MIME headers, one for RFC 2047-decoded + * strings, and one for non-RFC 2047-decoded strings. + * + * In general, this API attempts to preserve the format of addresses as + * faithfully as possible. No case normalization is performed at any point. + * However, internationalized email addresses generally need extra processing to + * work properly, so while this API should handle them without issues, consumers + * of this API may fail to work properly when presented with such addresses. To + * ease use for such cases, future versions of the API may incorporate necessary + * normalization steps to make oblivious consumers more likely to work properly. + */ +[scriptable, uuid(af2f9dd1-0226-4835-b981-a4f88b5e97cc)] +interface nsIMsgHeaderParser : nsISupports { + /** + * Parse an address-based header that has not yet been 2047-decoded. + * + * The result of this method is an array of objects described in the above + * comment. Note that the header is a binary string that will be decoded as if + * passed into nsIMimeConverter. + * + * @param aEncodedHeader The RFC 2047-encoded header to parse. + * @param aHeaderCharset The charset to assume for raw octets. + * @param aPreserveGroups If false (the default), the result is a flat array + * of mailbox objects, containing no group objects. + * @return An array corresponding to the header description. + */ + void parseEncodedHeader(in ACString aEncodedHeader, + in string aHeaderCharset, + [optional] in bool aPreserveGroups, + [optional] out unsigned long length, + [retval, array, size_is(length)] + out msgIAddressObject addresses); + + /** + * Parse an address-based header that has been 2047-decoded. + * + * The result of this method is an array of objects described in the above + * comment. Note that the header is a binary string that will be decoded as if + * passed into nsIMimeConverter. + * + * @param aDecodedHeader The non-RFC 2047-encoded header to parse. + * @param aPreserveGroups If false (the default), the result is a flat array + * of mailbox objects, containing no group objects. + * @return An array corresponding to the header description. + */ + void parseDecodedHeader(in AString aDecodedHeader, + [optional] in bool aPreserveGroups, + [optional] out unsigned long length, + [retval, array, size_is(length)] + out msgIAddressObject addresses); + + /** + * Given an array of addresses, make a MIME header suitable for emission. + * + * The return value of this method is not directly suitable for use in a MIME + * message but rather needs to be passed through nsIMimeConverter first to + * have RFC-2047 encoding applied and the resulting output wrapped to adhere + * to maximum line length formats. + * + * @param aAddresses An array corresponding to the header description. + * @param aLength The length of said array of addresses. + * @return A string that is suitable for writing in a MIME message. + */ + AString makeMimeHeader([array, size_is(aLength)] + in msgIAddressObject aAddresses, + in unsigned long aLength); + + /** + * Return the first address in the list in a format suitable for display. + * + * This is largely a convience method for handling From headers (or similar), + * which are expected to only have a single element in them. It is exactly + * equivalent to saying (parseDecodedHeader(decodedHeader))[0].toString(). + * + * @param decodedHeader The non-RFC 2047-encoded header to parse. + * @return The first address, suitable for display. + */ + AString extractFirstName(in AString aDecodedHeader); + + /** + * Returns a copy of the input which may have had some addresses removed. + * Addresses are removed if they are already in either of the supplied + * address lists. + * + * Addresses are considered to be the same if they contain the same email + * part (case-insensitive). Since the email part should never be RFC + * 2047-encoded, this method should work whether or not the header is + * RFC 2047-encoded. + * + * @param aAddrs The addresses to remove duplicates from. + * @param aOtherAddrs Other addresses that the duplicate removal process also + * checks for duplicates against. Addresses in this list + * will not be added to the result. + * @return The original header with duplicate addresses removed. + */ + AUTF8String removeDuplicateAddresses(in AUTF8String aAddrs, + [optional] in AUTF8String aOtherAddrs); + + /// Return a structured mailbox object having the given name and email. + msgIAddressObject makeMailboxObject(in AString aName, in AString aEmail); + + /// Return a structured group object having the given name and members. + msgIAddressObject makeGroupObject(in AString aName, + [array, size_is(aLength)] in msgIAddressObject aMembers, + in unsigned long aLength); + + /** + * Return an array of structured mailbox objects for the given display name + * string. + * + * The string is expected to be a comma-separated sequence of strings that + * would be produced by msgIAddressObject::toString(). For example, the string + * "Bond, James " would produce one address object, + * while the string "webmaster@nowhere.invalid, child@nowhere.invalid" would + * produce two address objects. + * + * Note that the input string is RFC 2231 and RFC 2047 decoded but no UTF-8 + * decoding takes place. + */ + void makeFromDisplayAddress(in AString aDisplayAddresses, + [optional] out unsigned long count, + [retval, array, size_is(count)] out msgIAddressObject addresses); + + [deprecated] void parseHeadersWithArray(in wstring aLine, + [array, size_is(count)] out wstring aEmailAddresses, + [array, size_is(count)] out wstring aNames, + [array, size_is(count)] out wstring aFullNames, + [retval] out unsigned long count); + + + /** + * Given a string which contains a list of Header addresses, returns a + * comma-separated list of just the `mailbox' portions. + * + * @param aLine The header line to parse. + * @return A comma-separated list of just the mailbox parts + * of the email-addresses. + */ + [deprecated] ACString extractHeaderAddressMailboxes(in ACString aLine); + + /** + * Given a string which contains a list of Header addresses, returns a + * comma-separated list of just the `user name' portions. If any of + * the addresses doesn't have a name, then the mailbox is used instead. + * + * @param aLine The header line to parse. + * @return A comma-separated list of just the name parts + * of the addresses. + */ + [deprecated] AUTF8String extractHeaderAddressNames(in AUTF8String aLine); + + /* + * Like extractHeaderAddressNames, but only returns the first name in the + * header if there is one. This function will return unquoted strings suitable + * for display. + * + * @param aLine The header line to parse. + * @return The first name found in the list. + */ + [deprecated] AUTF8String extractHeaderAddressName(in AUTF8String aLine); + + /** + * Given a name and email address, produce a string that is suitable for + * emitting in a MIME header (after applying RFC 2047 encoding). + * + * @note This is a temporary method. + */ + [deprecated] AString makeMimeAddress(in AString aName, in AString aEmail); +}; + diff --git a/mailnews/mime/public/nsIPgpMimeProxy.idl b/mailnews/mime/public/nsIPgpMimeProxy.idl new file mode 100644 index 000000000..375a7b776 --- /dev/null +++ b/mailnews/mime/public/nsIPgpMimeProxy.idl @@ -0,0 +1,69 @@ +/* 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 "nsIStreamListener.idl" +#include "nsIURI.idl" + +%{C++ +typedef int (*MimeDecodeCallbackFun)(const char *buf, int32_t buf_size, void *output_closure); + +#define NS_PGPMIMEPROXY_CLASSNAME "PGP/Mime Decryption" +#define NS_PGPMIMEPROXY_CONTRACTID "@mozilla.org/mime/pgp-mime-decrypt;1" + +#define NS_PGPMIMEPROXY_CID \ +{ /* 6b7e094f-536b-40dc-b3a4-e3d729205ce1 */ \ + 0x6b7e094f, 0x536b, 0x40dc, \ +{0xb3, 0xa4, 0xe3, 0xd7, 0x29, 0x20, 0x5c, 0xe1 } } +%} + +native MimeDecodeCallbackFun(MimeDecodeCallbackFun); + +/** + * nsIPgpMimeProxy is a proxy for a (JS-)addon for OpenPGP/MIME decryption + */ + +[scriptable, uuid(6b7e094f-536b-40dc-b3a4-e3d729205ce1)] +interface nsIPgpMimeProxy : nsIStreamListener +{ + /** + * set the decoder callback into mimelib + */ + [noscript] void setMimeCallback(in MimeDecodeCallbackFun outputFun, + in voidPtr outputClosure, + in nsIURI myUri); + + /** + * init function + */ + void init(); + + /** + * process encoded data received from mimelib + */ + void write(in string buf, in unsigned long count); + + /** + * finish writing (EOF) from mimelib + */ + void finish(); + + /** + * the listener that receives the OpenPGP/MIME data stream and decrypts + * the message + */ + attribute nsIStreamListener decryptor; + + attribute ACString contentType; + + /** + * The particular part number of the multipart object we are working on. The + * numbering is the same as in URLs that use the form "...?part=1.1.2". + * + * The value stored in mimePart is only the number, e.g. "1" or "1.1.2" + */ + attribute ACString mimePart; +}; + + +/////////////////////////////////////////////////////////////////////////////// diff --git a/mailnews/mime/public/nsISimpleMimeConverter.idl b/mailnews/mime/public/nsISimpleMimeConverter.idl new file mode 100644 index 000000000..907a1bb0e --- /dev/null +++ b/mailnews/mime/public/nsISimpleMimeConverter.idl @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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" +interface nsIURI; + +[scriptable, uuid(FC6E8234-BBF3-44A1-9802-5F023A929173)] +interface nsISimpleMimeConverter : nsISupports +{ + // uri of message getting displayed + attribute nsIURI uri; + AUTF8String convertToHTML(in ACString contentType, + in AUTF8String data); +}; + +%{C++ + +#define NS_SIMPLEMIMECONVERTERS_CATEGORY "simple-mime-converters" + +%} diff --git a/mailnews/mime/public/nsMailHeaders.h b/mailnews/mime/public/nsMailHeaders.h new file mode 100644 index 000000000..d8a3131a5 --- /dev/null +++ b/mailnews/mime/public/nsMailHeaders.h @@ -0,0 +1,90 @@ +/* -*- 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/. */ + +/* + * This interface allows any module to access the encoder/decoder + * routines for RFC822 headers. This will allow any mail/news module + * to call on these routines. + */ +#ifndef nsMailHeaders_h_ +#define nsMailHeaders_h_ + +/* + * These are the defines for standard header field names. + */ +#define HEADER_BCC "BCC" +#define HEADER_CC "CC" +#define HEADER_CONTENT_BASE "Content-Base" +#define HEADER_CONTENT_LOCATION "Content-Location" +#define HEADER_CONTENT_ID "Content-ID" +#define HEADER_CONTENT_DESCRIPTION "Content-Description" +#define HEADER_CONTENT_DISPOSITION "Content-Disposition" +#define HEADER_CONTENT_ENCODING "Content-Encoding" +#define HEADER_CONTENT_LANGUAGE "Content-Language" +#define HEADER_CONTENT_LENGTH "Content-Length" +#define HEADER_CONTENT_NAME "Content-Name" +#define HEADER_CONTENT_TRANSFER_ENCODING "Content-Transfer-Encoding" +#define HEADER_CONTENT_TYPE "Content-Type" +#define HEADER_DATE "Date" +#define HEADER_DISTRIBUTION "Distribution" +#define HEADER_FCC "FCC" +#define HEADER_FOLLOWUP_TO "Followup-To" +#define HEADER_FROM "From" +#define HEADER_STATUS "Status" +#define HEADER_LINES "Lines" +#define HEADER_LIST_POST "List-Post" +#define HEADER_MAIL_FOLLOWUP_TO "Mail-Followup-To" +#define HEADER_MAIL_REPLY_TO "Mail-Reply-To" +#define HEADER_MESSAGE_ID "Message-ID" +#define HEADER_MIME_VERSION "MIME-Version" +#define HEADER_NEWSGROUPS "Newsgroups" +#define HEADER_ORGANIZATION "Organization" +#define HEADER_REFERENCES "References" +#define HEADER_REPLY_TO "Reply-To" +#define HEADER_RESENT_COMMENTS "Resent-Comments" +#define HEADER_RESENT_DATE "Resent-Date" +#define HEADER_RESENT_FROM "Resent-From" +#define HEADER_RESENT_MESSAGE_ID "Resent-Message-ID" +#define HEADER_RESENT_SENDER "Resent-Sender" +#define HEADER_RESENT_TO "Resent-To" +#define HEADER_RESENT_CC "Resent-CC" +#define HEADER_SENDER "Sender" +#define HEADER_SUBJECT "Subject" +#define HEADER_TO "To" +#define HEADER_APPROVED_BY "Approved-By" +#define HEADER_X_MAILER "X-Mailer" +#define HEADER_USER_AGENT "User-Agent" +#define HEADER_X_NEWSREADER "X-Newsreader" +#define HEADER_X_POSTING_SOFTWARE "X-Posting-Software" +#define HEADER_X_MOZILLA_STATUS "X-Mozilla-Status" +#define HEADER_X_MOZILLA_STATUS2 "X-Mozilla-Status2" +#define HEADER_X_MOZILLA_NEWSHOST "X-Mozilla-News-Host" +#define HEADER_X_MOZILLA_DRAFT_INFO "X-Mozilla-Draft-Info" +#define HEADER_X_UIDL "X-UIDL" +#define HEADER_XREF "XREF" +#define HEADER_X_SUN_CHARSET "X-Sun-Charset" +#define HEADER_X_SUN_CONTENT_LENGTH "X-Sun-Content-Length" +#define HEADER_X_SUN_CONTENT_LINES "X-Sun-Content-Lines" +#define HEADER_X_SUN_DATA_DESCRIPTION "X-Sun-Data-Description" +#define HEADER_X_SUN_DATA_NAME "X-Sun-Data-Name" +#define HEADER_X_SUN_DATA_TYPE "X-Sun-Data-Type" +#define HEADER_X_SUN_ENCODING_INFO "X-Sun-Encoding-Info" +#define HEADER_X_PRIORITY "X-Priority" + +#define HEADER_PARM_CHARSET "charset" +#define HEADER_PARM_START "start" +#define HEADER_PARM_BOUNDARY "BOUNDARY" +#define HEADER_PARM_FILENAME "FILENAME" +#define HEADER_PARM_NAME "NAME" +#define HEADER_PARM_TYPE "TYPE" + +#define HEADER_X_MOZILLA_PART_URL "X-Mozilla-PartURL" +#define HEADER_X_MOZILLA_PART_SIZE "X-Mozilla-PartSize" +#define HEADER_X_MOZILLA_PART_DOWNLOADED "X-Mozilla-PartDownloaded" +#define HEADER_X_MOZILLA_CLOUD_PART "X-Mozilla-Cloud-Part" +#define HEADER_X_MOZILLA_IDENTITY_KEY "X-Identity-Key" +#define HEADER_X_MOZILLA_ACCOUNT_KEY "X-Account-Key" +#define HEADER_X_MOZILLA_KEYWORDS "X-Mozilla-Keys" +#endif /* nsMailHeaders_h_ */ diff --git a/mailnews/mime/public/nsMsgMimeCID.h b/mailnews/mime/public/nsMsgMimeCID.h new file mode 100644 index 000000000..07dec95e5 --- /dev/null +++ b/mailnews/mime/public/nsMsgMimeCID.h @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 2; 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/. */ + +#ifndef nsMessageMimeCID_h__ +#define nsMessageMimeCID_h__ + +#define NS_MAILNEWS_MIME_STREAM_CONVERTER_CONTRACTID \ + NS_ISTREAMCONVERTER_KEY "?from=message/rfc822&to=application/vnd.mozilla.xul+xml" + +#define NS_MAILNEWS_MIME_STREAM_CONVERTER_CONTRACTID1 \ + NS_ISTREAMCONVERTER_KEY "?from=message/rfc822&to=text/html" + +#define NS_MAILNEWS_MIME_STREAM_CONVERTER_CONTRACTID2 \ + NS_ISTREAMCONVERTER_KEY "?from=message/rfc822&to=*/*" + +#define NS_MAILNEWS_MIME_STREAM_CONVERTER_CID \ +{ /* FAF4F9A6-60AD-11d3-989A-001083010E9B */ \ + 0xfaf4f9a6, 0x60ad, 0x11d3, { 0x98, 0x9a, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } } + +#define NS_MIME_CONVERTER_CONTRACTID \ + "@mozilla.org/messenger/mimeconverter;1" + +// {403B0540-B7C3-11d2-B35E-525400E2D63A} +#define NS_MIME_OBJECT_CLASS_ACCESS_CID \ + { 0x403b0540, 0xb7c3, 0x11d2, \ + { 0xb3, 0x5e, 0x52, 0x54, 0x0, 0xe2, 0xd6, 0x3a } } + +#define NS_MIME_OBJECT_CONTRACTID \ + "@mozilla.org/messenger/mimeobject;1" + +#endif // nsMessageMimeCID_h__ -- cgit v1.2.3