summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/mime/public
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--comm/mailnews/mime/public/MimeEncoder.h44
-rw-r--r--comm/mailnews/mime/public/MimeHeaderParser.h178
-rw-r--r--comm/mailnews/mime/public/moz.build28
-rw-r--r--comm/mailnews/mime/public/msgIStructuredHeaders.idl175
-rw-r--r--comm/mailnews/mime/public/nsIMimeContentTypeHandler.idl39
-rw-r--r--comm/mailnews/mime/public/nsIMimeConverter.idl69
-rw-r--r--comm/mailnews/mime/public/nsIMimeEmitter.idl81
-rw-r--r--comm/mailnews/mime/public/nsIMimeHeaders.idl41
-rw-r--r--comm/mailnews/mime/public/nsIMimeObjectClassAccess.h53
-rw-r--r--comm/mailnews/mime/public/nsIMimeStreamConverter.idl93
-rw-r--r--comm/mailnews/mime/public/nsIMsgHeaderParser.idl200
-rw-r--r--comm/mailnews/mime/public/nsIPgpMimeProxy.idl90
-rw-r--r--comm/mailnews/mime/public/nsISimpleMimeConverter.idl51
-rw-r--r--comm/mailnews/mime/public/nsMailHeaders.h90
14 files changed, 1232 insertions, 0 deletions
diff --git a/comm/mailnews/mime/public/MimeEncoder.h b/comm/mailnews/mime/public/MimeEncoder.h
new file mode 100644
index 0000000000..19a06810a6
--- /dev/null
+++ b/comm/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/comm/mailnews/mime/public/MimeHeaderParser.h b/comm/mailnews/mime/public/MimeHeaderParser.h
new file mode 100644
index 0000000000..489e35f7e6
--- /dev/null
+++ b/comm/mailnews/mime/public/MimeHeaderParser.h
@@ -0,0 +1,178 @@
+/* -*- 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 "nsString.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<msgIAddressObject> 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<msgIAddressObject> EncodedHeader(const nsACString& aHeader,
+ const char* aCharset = nullptr);
+/**
+ * Same deal, but we're starting with an nsAString.
+ */
+nsCOMArray<msgIAddressObject> EncodedHeaderW(const nsAString& aHeader);
+
+namespace detail {
+void DoConversion(const nsTArray<nsString>& aUTF16, nsTArray<nsCString>& aUTF8);
+};
+/**
+ * This is a class designed for use as temporaries so that methods can pass
+ * an nsTArray<nsCString> into methods that expect nsTArray<nsString> for out
+ * parameters (this does not work for in-parameters).
+ *
+ * It works by internally providing an nsTArray<nsString> 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 <uint32_t N = 5>
+class UTF16ArrayAdapter {
+ public:
+ explicit UTF16ArrayAdapter(nsTArray<nsCString>& aUTF8Array)
+ : mUTF8Array(aUTF8Array) {}
+ ~UTF16ArrayAdapter() { detail::DoConversion(mUTF16Array, mUTF8Array); }
+ operator nsTArray<nsString>&() { return mUTF16Array; }
+
+ private:
+ nsTArray<nsCString>& mUTF8Array;
+ AutoTArray<nsString, N> 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 <email>. 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 <email>. 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 <email>. 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<msgIAddressObject>& aHeader,
+ nsTArray<nsString>& names, nsTArray<nsString>& emails);
+
+/**
+ * Given a raw message header value, extract display names for every address
+ * found in the header.
+ */
+void ExtractDisplayAddresses(const nsCOMArray<msgIAddressObject>& aHeader,
+ nsTArray<nsString>& 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<msgIAddressObject>& aHeader,
+ nsTArray<nsString>& 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<msgIAddressObject>& 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<msgIAddressObject>& aHeader,
+ nsAString& name, nsACString& email);
+
+/**
+ * Given a raw message header value, extract the first email address found in
+ * the header.
+ */
+void ExtractEmail(const nsCOMArray<msgIAddressObject>& 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<msgIAddressObject>& 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<msgIAddressObject>& aDecodedHeader,
+ nsAString& name);
+
+} // namespace mailnews
+} // namespace mozilla
+
+#endif
diff --git a/comm/mailnews/mime/public/moz.build b/comm/mailnews/mime/public/moz.build
new file mode 100644
index 0000000000..d048796af9
--- /dev/null
+++ b/comm/mailnews/mime/public/moz.build
@@ -0,0 +1,28 @@
+# 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",
+ "nsIMimeContentTypeHandler.idl",
+ "nsIMimeConverter.idl",
+ "nsIMimeEmitter.idl",
+ "nsIMimeHeaders.idl",
+ "nsIMimeStreamConverter.idl",
+ "nsIMsgHeaderParser.idl",
+ "nsIPgpMimeProxy.idl",
+ "nsISimpleMimeConverter.idl",
+]
+
+XPIDL_MODULE = "mime"
+
+EXPORTS += [
+ "nsIMimeObjectClassAccess.h",
+ "nsMailHeaders.h",
+]
+
+EXPORTS.mozilla.mailnews += [
+ "MimeEncoder.h",
+ "MimeHeaderParser.h",
+]
diff --git a/comm/mailnews/mime/public/msgIStructuredHeaders.idl b/comm/mailnews/mime/public/msgIStructuredHeaders.idl
new file mode 100644
index 0000000000..2f1e56a7b3
--- /dev/null
+++ b/comm/mailnews/mime/public/msgIStructuredHeaders.idl
@@ -0,0 +1,175 @@
+/* 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.
+ */
+ Array<msgIAddressObject> getAddressingHeader(in string aHeaderName,
+ [optional] in boolean aPreserveGroups);
+
+ /**
+ * 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.
+ *
+ * @param sanitizeDate If true convert the date to UTC and round to closest minute.
+ */
+ AUTF8String buildMimeText([optional] in boolean sanitizeDate);
+
+};
+
+/**
+ * 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 set.
+ * @param aAddresses The addresses to store.
+ */
+ void setAddressingHeader(in string aHeaderName,
+ in Array<msgIAddressObject> aAddresses);
+
+ /**
+ * Store the value of the header using a raw version as would be represented
+ * in MIME.
+ *
+ * @param aHeaderName The name of the header to store.
+ * @param aValue The raw MIME header value to store.
+ */
+ void setRawHeader(in string aHeaderName, in AUTF8String aValue);
+
+};
diff --git a/comm/mailnews/mime/public/nsIMimeContentTypeHandler.idl b/comm/mailnews/mime/public/nsIMimeContentTypeHandler.idl
new file mode 100644
index 0000000000..872ef6873c
--- /dev/null
+++ b/comm/mailnews/mime/public/nsIMimeContentTypeHandler.idl
@@ -0,0 +1,39 @@
+/* -*- 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
+ */
+#include "nsISupports.idl"
+
+%{C++
+typedef struct {
+ bool force_inline_display;
+} contentTypeHandlerInitStruct;
+
+#include "mimecth.h"
+%}
+
+[ptr] native MimeObjectClassPtr(MimeObjectClass);
+[ptr] native CTHInitStructPtr(contentTypeHandlerInitStruct);
+
+[scriptable, builtinclass, uuid(20DABD99-F8B5-11d2-8EE0-00A024A7D144)]
+interface nsIMimeContentTypeHandler : nsISupports {
+ readonly attribute string contentType;
+
+ [noscript] MimeObjectClassPtr CreateContentTypeHandlerClass(
+ in string content_type,
+ in CTHInitStructPtr initStruct
+ );
+};
diff --git a/comm/mailnews/mime/public/nsIMimeConverter.idl b/comm/mailnews/mime/public/nsIMimeConverter.idl
new file mode 100644
index 0000000000..98e474d234
--- /dev/null
+++ b/comm/mailnews/mime/public/nsIMimeConverter.idl
@@ -0,0 +1,69 @@
+/* -*- 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.
+ *
+ * @param aHeader UTF-8 header to encode.
+ * @param aAddressingHeader Is the header a list of email addresses?
+ * @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 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/comm/mailnews/mime/public/nsIMimeEmitter.idl b/comm/mailnews/mime/public/nsIMimeEmitter.idl
new file mode 100644
index 0000000000..ef292787a1
--- /dev/null
+++ b/comm/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 : nsISupports
+{
+ 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/comm/mailnews/mime/public/nsIMimeHeaders.idl b/comm/mailnews/mime/public/nsIMimeHeaders.idl
new file mode 100644
index 0000000000..3a0d05c491
--- /dev/null
+++ b/comm/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/comm/mailnews/mime/public/nsIMimeObjectClassAccess.h b/comm/mailnews/mime/public/nsIMimeObjectClassAccess.h
new file mode 100644
index 0000000000..1ec2aa5a1f
--- /dev/null
+++ b/comm/mailnews/mime/public/nsIMimeObjectClassAccess.h
@@ -0,0 +1,53 @@
+/* -*- 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 \
+ } \
+ }
+
+#include "nsISupports.h"
+
+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/comm/mailnews/mime/public/nsIMimeStreamConverter.idl b/comm/mailnews/mime/public/nsIMimeStreamConverter.idl
new file mode 100644
index 0000000000..b7fa35050e
--- /dev/null
+++ b/comm/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 : nsISupports
+{
+ 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 AUTF8String originalMsgURI;
+ attribute nsIMsgDBHdr origMsgHdr;
+};
diff --git a/comm/mailnews/mime/public/nsIMsgHeaderParser.idl b/comm/mailnews/mime/public/nsIMsgHeaderParser.idl
new file mode 100644
index 0000000000..8064cb104a
--- /dev/null
+++ b/comm/mailnews/mime/public/nsIMsgHeaderParser.idl
@@ -0,0 +1,200 @@
+/* -*- 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 <jdoe@machine.example>" 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.
+ */
+ Array<msgIAddressObject> parseEncodedHeader(in ACString aEncodedHeader,
+ [optional] in string aHeaderCharset,
+ [optional] in bool aPreserveGroups);
+
+ /**
+ * Parse an address-based header that has not yet been 2047-decoded and does not
+ * contain raw octets but instead wide (UTF-16) characters.
+ *
+ * @param aEncodedHeader The RFC 2047-encoded header to parse.
+ * @return An array corresponding to the header description.
+ */
+ Array<msgIAddressObject> parseEncodedHeaderW(in AString aEncodedHeader);
+
+/**
+ * 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.
+ */
+ Array<msgIAddressObject> parseDecodedHeader(in AString aDecodedHeader,
+ [optional] in bool aPreserveGroups);
+
+ /**
+ * 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.
+ * @return A string that is suitable for writing in a MIME message.
+ */
+ AString makeMimeHeader(in Array<msgIAddressObject> aAddresses);
+
+ /**
+ * Return the first address in the list in a format suitable for display.
+ *
+ * This is largely a convenience 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,
+ in Array<msgIAddressObject> aMembers);
+
+ /**
+ * 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 <agent007@mi5.invalid>" would produce one address object,
+ * while the string "webmaster@nowhere.invalid, child@nowhere.invalid" would
+ * produce two address objects.
+ */
+ Array<msgIAddressObject> makeFromDisplayAddress(in AString aDisplayAddresses);
+
+ /**
+ * 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.
+ */
+ ACString extractHeaderAddressMailboxes(in ACString 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/comm/mailnews/mime/public/nsIPgpMimeProxy.idl b/comm/mailnews/mime/public/nsIPgpMimeProxy.idl
new file mode 100644
index 0000000000..cd581bf107
--- /dev/null
+++ b/comm/mailnews/mime/public/nsIPgpMimeProxy.idl
@@ -0,0 +1,90 @@
+/* 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 \
+{ /* 815c4fbe-0e7c-45b6-8324-f7044c7252ac */ \
+ 0x815c4fbe, 0x0e7c, 0x45b6, \
+{0x83, 0x24, 0xf0, 0x04, 0x4C, 0x72, 0x52, 0xac } }
+%}
+
+native MimeDecodeCallbackFun(MimeDecodeCallbackFun);
+
+/**
+ * nsIPgpMimeProxy is a proxy for a (JS-)addon for OpenPGP/MIME decryption
+ */
+
+[scriptable, uuid(815c4fbe-0e7c-45b6-8324-f7044c7252ac)]
+interface nsIPgpMimeProxy : nsIStreamListener
+{
+ /**
+ * set the decoder callback into mimelib
+ */
+ [noscript] void setMimeCallback(in MimeDecodeCallbackFun outputFun,
+ in voidPtr outputClosure,
+ in nsIURI myUri);
+
+ [noscript] void removeMimeCallback();
+
+ /**
+ * 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;
+
+ /**
+ * holds the URI of the message currently being processed
+ */
+ readonly attribute nsIURI messageURI;
+
+ /**
+ * 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;
+
+ /**
+ * The application may restrict automatic decryption to the top level
+ * MIME part ("1"). In certain scenarios the application may allow
+ * a MIME part at another level ("nested") in the MIME tree to be
+ * decrypted, too. If the current MIME part is a nested MIME part,
+ * then this flag indicates whether automatic decryption is allowed.
+ */
+ attribute boolean allowNestedDecrypt;
+
+ /**
+ * Pass the decrypted data back from the decryptor and onto to libMime.
+ */
+ void outputDecryptedData(in string buf, in unsigned long count);
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
diff --git a/comm/mailnews/mime/public/nsISimpleMimeConverter.idl b/comm/mailnews/mime/public/nsISimpleMimeConverter.idl
new file mode 100644
index 0000000000..b6c7027971
--- /dev/null
+++ b/comm/mailnews/mime/public/nsISimpleMimeConverter.idl
@@ -0,0 +1,51 @@
+/* -*- 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 nsIMailChannel;
+interface nsIURI;
+
+/**
+ * nsISimpleMimeConverter provides an interface for rendering raw mime objects
+ * as HTML. It's used to provide converters for mime types not handled
+ * directly by the mime code.
+ * "text/calendar" - see calendar/base/src/CalMimeConverter.jsm
+ * "text/vcard" - see mailnews/addrbook/modules/VCardUtils.jsm
+ */
+[scriptable, uuid(FC6E8234-BBF3-44A1-9802-5F023A929173)]
+interface nsISimpleMimeConverter : nsISupports
+{
+ // uri of message getting displayed
+ attribute nsIURI uri;
+
+ // mailChannel of message getting displayed
+ attribute nsIMailChannel mailChannel;
+
+ /**
+ * Render mime data into HTML.
+ * NOTE: it is important that this function doesn't do anything which
+ * would allows other events to processed on the thread (that means
+ * calls to NS_ProcessNextEvent()). Using a synchronous XMLHttpRequest
+ * is a prime example - it spins the thread queue, processing other
+ * events while it waits.
+ *
+ * It's an issue because it's likely that convertToHTML() is being called
+ * in response to data coming in from an async inputstream. Letting other
+ * events be handled on the thread means that more data might come in
+ * from the stream, recursively calling the nsIStreamListener
+ * onDataAvailable() handler we're already inside! And it's tricky to
+ * track down this kind of problem - it only occurs if the data is big
+ * enough that it comes through in multiple chunks.
+ * See bug 1679299.
+ */
+ AUTF8String convertToHTML(in ACString contentType,
+ in AUTF8String data);
+};
+
+%{C++
+
+#define NS_SIMPLEMIMECONVERTERS_CATEGORY "simple-mime-converters"
+
+%}
diff --git a/comm/mailnews/mime/public/nsMailHeaders.h b/comm/mailnews/mime/public/nsMailHeaders.h
new file mode 100644
index 0000000000..29313eb6c8
--- /dev/null
+++ b/comm/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_ */