1999-04-02 06:39:21 +04:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1999-04-02 06:39:21 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1999-04-02 06:39:21 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-04-02 06:39:21 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:43:54 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2000-05-03 03:11:58 +04:00
|
|
|
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
|
|
|
|
* described herein are Copyright (c) International Business Machines Corporation, 2000.
|
|
|
|
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
|
|
|
|
*
|
|
|
|
* Date Modified by Description of modification
|
|
|
|
* 04/20/2000 IBM Corp. OS/2 VisualAge build.
|
1999-04-02 06:39:21 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This interface allows any module to access the encoder/decoder
|
|
|
|
* routines for RFC822 headers, base64 and QP encoders. This will
|
|
|
|
* allow any mail/news module to call on these routines.
|
|
|
|
*/
|
|
|
|
#ifndef nsIMimeConverter_h_
|
|
|
|
#define nsIMimeConverter_h_
|
|
|
|
|
|
|
|
#include "prtypes.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
2001-03-21 06:20:23 +03:00
|
|
|
// {ea5b631e-1dd1-11b2-be0d-e02825f300d0}
|
1999-04-02 06:39:21 +04:00
|
|
|
#define NS_IMIME_CONVERTER_IID \
|
2001-03-21 06:20:23 +03:00
|
|
|
{ 0xea5b631e, 0x1dd1, 0x11b2, \
|
|
|
|
{ 0xbe, 0x0d, 0xe0, 0x28, 0x25, 0xf3, 0x00, 0xd0 } }
|
1999-04-02 06:39:21 +04:00
|
|
|
|
|
|
|
// default line length for calling the encoder
|
|
|
|
#define kMIME_ENCODED_WORD_SIZE 72
|
|
|
|
|
|
|
|
// Max length of charset name.
|
|
|
|
#define kMAX_CSNAME 64
|
|
|
|
|
|
|
|
/* Opaque objects used by the encoder/decoder to store state. */
|
|
|
|
typedef struct MimeDecoderData MimeDecoderData;
|
|
|
|
typedef struct MimeEncoderData MimeEncoderData;
|
|
|
|
|
|
|
|
class nsIMimeConverter : public nsISupports {
|
|
|
|
public:
|
2002-06-26 07:38:55 +04:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMIME_CONVERTER_IID)
|
1999-04-02 06:39:21 +04:00
|
|
|
|
|
|
|
// These methods are all implemented by libmime to be used by
|
|
|
|
// modules that need to encode/decode mail headers
|
|
|
|
|
2001-03-21 06:20:23 +03:00
|
|
|
// Decode routine.
|
|
|
|
// If header does not need decoding, places nsnull in decodedString
|
|
|
|
NS_IMETHOD DecodeMimeHeader(const char *header,
|
|
|
|
char **decodedString,
|
|
|
|
const char *default_charset = nsnull,
|
|
|
|
PRBool override_charset = PR_FALSE,
|
|
|
|
PRBool eatContinuations = PR_TRUE) = 0;
|
1999-04-02 06:39:21 +04:00
|
|
|
|
|
|
|
// Decode routine (also converts output to unicode)
|
2001-03-21 06:20:23 +03:00
|
|
|
// On success, decodedString is never null
|
2001-04-06 03:00:38 +04:00
|
|
|
NS_IMETHOD DecodeMimeHeader(const char *header,
|
2001-03-21 06:20:23 +03:00
|
|
|
PRUnichar **decodedString,
|
|
|
|
const char *default_charset = nsnull,
|
|
|
|
PRBool override_charset = PR_FALSE,
|
|
|
|
PRBool eatContinuations = PR_TRUE) = 0;
|
2000-03-18 03:42:29 +03:00
|
|
|
|
2001-04-06 03:00:38 +04:00
|
|
|
// Decode routine (also converts output to unicode)
|
|
|
|
// On success, decodedString is never null
|
|
|
|
NS_IMETHOD DecodeMimeHeader(const char *header,
|
2002-03-24 00:03:32 +03:00
|
|
|
nsAString& decodedString,
|
2001-04-06 03:00:38 +04:00
|
|
|
const char *default_charset = nsnull,
|
|
|
|
PRBool override_charset = PR_FALSE,
|
|
|
|
PRBool eatContinuations = PR_TRUE) = 0;
|
|
|
|
|
1999-04-02 06:39:21 +04:00
|
|
|
// Encode routine
|
|
|
|
NS_IMETHOD EncodeMimePartIIStr(const char *header,
|
2002-02-20 10:18:11 +03:00
|
|
|
PRBool structured,
|
1999-04-02 06:39:21 +04:00
|
|
|
const char *mailCharset,
|
2002-02-20 10:18:11 +03:00
|
|
|
PRInt32 fieldnamelen,
|
1999-04-02 06:39:21 +04:00
|
|
|
const PRInt32 encodedWordSize,
|
|
|
|
char **encodedString) = 0;
|
|
|
|
|
1999-04-10 05:00:15 +04:00
|
|
|
// Encode routine (utf-8 input)
|
|
|
|
NS_IMETHOD EncodeMimePartIIStr_UTF8(const char *header,
|
2002-02-20 10:18:11 +03:00
|
|
|
PRBool structured,
|
1999-04-10 05:00:15 +04:00
|
|
|
const char *mailCharset,
|
2002-02-20 10:18:11 +03:00
|
|
|
PRInt32 fieldnamelen,
|
1999-04-10 05:00:15 +04:00
|
|
|
const PRInt32 encodedWordSize,
|
|
|
|
char **encodedString) = 0;
|
|
|
|
|
2001-04-13 08:38:01 +04:00
|
|
|
NS_IMETHOD B64EncoderInit(nsresult (*PR_CALLBACK output_fn) (const char *buf, PRInt32 size, void *closure),
|
1999-04-02 06:39:21 +04:00
|
|
|
void *closure, MimeEncoderData **returnEncoderData) = 0;
|
|
|
|
|
2001-04-13 08:38:01 +04:00
|
|
|
NS_IMETHOD QPEncoderInit (nsresult (*PR_CALLBACK output_fn) (const char *buf,
|
1999-04-02 06:39:21 +04:00
|
|
|
PRInt32 size, void *closure), void *closure,
|
|
|
|
MimeEncoderData ** returnEncoderData) = 0;
|
|
|
|
|
2001-04-13 08:38:01 +04:00
|
|
|
NS_IMETHOD UUEncoderInit (char *filename, nsresult (*PR_CALLBACK output_fn)
|
1999-04-02 06:39:21 +04:00
|
|
|
(const char *buf, PRInt32 size, void *closure), void *closure,
|
|
|
|
MimeEncoderData ** returnEncoderData) = 0;
|
|
|
|
|
|
|
|
NS_IMETHOD EncoderDestroy(MimeEncoderData *data, PRBool abort_p) = 0;
|
|
|
|
|
|
|
|
NS_IMETHOD EncoderWrite (MimeEncoderData *data, const char *buffer, PRInt32 size, PRInt32 *written) = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsIMimeConverter_h_ */
|
|
|
|
|
|
|
|
|