1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38 #include "nsISupports.idl"
39
40 %{C++
41
42 #include "prtypes.h"
43
44 // default line length for calling the encoder
45 #define kMIME_ENCODED_WORD_SIZE 72
46
47 // Max length of charset name.
48 #define kMAX_CSNAME 64
49
50 /* Opaque objects used by the encoder/decoder to store state. */
51 typedef struct MimeDecoderData MimeDecoderData;
52 typedef struct MimeEncoderData MimeEncoderData;
53
54 %}
55
56 [scriptable, uuid(59B73615-2285-4d88-A31C-1ABFE4773F4F)]
57 interface nsIMimeConverter : nsISupports {
58
59 // These methods are all implemented by libmime to be used by
60 // modules that need to encode/decode mail headers
61
62 // Decode routine.
63 // If header does not need decoding, places nsnull in decodedString
64
65 // Encode routine
66 string encodeMimePartIIStr(in string header,
67 in boolean structured,
68 in string mailCharset,
69 in long fieldnamelen,
70 in long encodedWordSize);
71
72 // Encode routine (utf-8 input)
73 string encodeMimePartIIStr_UTF8(in string header,
74 in boolean structured,
75 in string mailCharset,
76 in long fieldnamelen,
77 in long encodedWordSize);
78
79 // TO DO: Comeback and convert the rest of these methods into scriptable methods when we have more time...
80 %{C++
81 NS_IMETHOD DecodeMimeHeader(const char *header,
82 char **decodedString,
83 const char *default_charset = nsnull,
84 PRBool override_charset = PR_FALSE,
85 PRBool eatContinuations = PR_TRUE) = 0;
86
87 // Decode routine (also converts output to unicode)
88 // On success, decodedString is never null
89 NS_IMETHOD DecodeMimeHeader(const char *header,
90 PRUnichar **decodedString,
91 const char *default_charset = nsnull,
92 PRBool override_charset = PR_FALSE,
93 PRBool eatContinuations = PR_TRUE) = 0;
94
95 // Decode routine (also converts output to unicode)
96 // On success, decodedString is never null
97 NS_IMETHOD DecodeMimeHeader(const char *header,
98 nsAString& decodedString,
99 const char *default_charset = nsnull,
100 PRBool override_charset = PR_FALSE,
101 PRBool eatContinuations = PR_TRUE) = 0;
102
103 NS_IMETHOD B64EncoderInit(nsresult (*PR_CALLBACK output_fn) (const char *buf, PRInt32 size, void *closure),
104 void *closure, MimeEncoderData **returnEncoderData) = 0;
105
106 NS_IMETHOD QPEncoderInit (nsresult (*PR_CALLBACK output_fn) (const char *buf,
107 PRInt32 size, void *closure), void *closure,
108 MimeEncoderData ** returnEncoderData) = 0;
109
110 NS_IMETHOD UUEncoderInit (char *filename, nsresult (*PR_CALLBACK output_fn)
111 (const char *buf, PRInt32 size, void *closure), void *closure,
112 MimeEncoderData ** returnEncoderData) = 0;
113
114 NS_IMETHOD EncoderDestroy(MimeEncoderData *data, PRBool abort_p) = 0;
115
116 NS_IMETHOD EncoderWrite (MimeEncoderData *data, const char *buffer, PRInt32 size, PRInt32 *written) = 0;
117 %}
118
119 };