File: CWMIMEUtility.h

package info (click to toggle)
pantomime1.2 1.2.2%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,012 kB
  • ctags: 398
  • sloc: objc: 21,201; ansic: 510; cpp: 22; makefile: 21; sh: 4
file content (158 lines) | stat: -rw-r--r-- 5,793 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
**  CWMIMEUtility.h
**
**  Copyright (c) 2001-2004
**
**  Author: Ludovic Marcotte <ludovic@Sophos.ca>
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**  
**  This library is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
**  Lesser General Public License for more details.
**  
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef _Pantomime_H_CWMIMEUtility
#define _Pantomime_H_CWMIMEUtility

#import <Foundation/NSArray.h>
#import <Foundation/NSData.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>

#include <Pantomime/CWConstants.h>

@class CWMessage;
@class CWMIMEMultipart;
@class CWPart;


/*!
  @class CWMIMEUtility
  @abstract MIME utility class.
  @discussion This class provides static methods to deal with the MIME standard.
              Normally, you should not invoke any of those methods directly.
*/
@interface CWMIMEUtility: NSObject


/*!
  @method decodeHeader: charset:
  @discussion This method is used to decode a header value
              encoded in base64 or quoted-printable. RFC 2047
	      describes how those headers should be encoded
	      (in particular, "2. Syntax of encoded-words").
              If <i>theCharset</i> is not nil, it is used to
	      decode the header. Otherwise, the charset used
	      in the header is used.
  @param theData The data to decode.
  @param theCharset The charset to force.
  @result The decoded header.
*/
+ (NSString *) decodeHeader: (NSData *) theData
                    charset: (NSString *) theCharset;

/*!
  @method encodeHeader: charset: encoding:
  @discussion This method is used to encode a header value
              in the format specified by RFC 2047 (in particular,
	      "2. Syntax of encoded-words").
  @param theText The text to encode.
  @param theCharset The charset to use. For example, "iso-8859-1".
  @param theEncoding The encoding to use. Valid values are
                     part of the PantomimeEncoding enum.
  @result The encoded data.
*/
+ (NSData *) encodeHeader: (NSString *) theText
                  charset: (NSString *) theCharset
                 encoding: (PantomimeEncoding) theEncoding;

+ (NSData *) encodeWordUsingBase64: (NSString *) theWord
                      prefixLength: (int) thePrefixLength;

+ (NSData *) encodeWordUsingQuotedPrintable: (NSString *) theWord
                               prefixLength: (int) thePrefixLength;

/*!
  @method globallyUniqueBoundary
  @discussion This method is used to generate a unique MIME boundary
              (or any kind of boundary).
  @result The boundary, as a NSData instance.
*/
+ (NSData *) globallyUniqueBoundary;

/*!
  @method globallyUniqueID
  @discussion This method is used to generate a unique ID that CWMessage (or CWPart)
              instances use as their unique ID. (Message-ID, Content-ID, etc.)
  @result The unique ID, as a NSData instance.
*/
+ (NSData *) globallyUniqueID;

/*!
  @method compositeMessageContentFromRawSource:
  @discussion This method is used to obtain a composite type (message)
              from <i>theData</i>.
  @param theData The bytes to use.
  @result A Message instance, nil on error.
*/
+ (CWMessage *) compositeMessageContentFromRawSource: (NSData *) theData;

/*!
  @method compositeMultipartContentFromRawSource:boundary:
  @discussion This method is used to obtain a composity type (multipart)
              from <i>theData</i>, using <i>theBoundary</i>.
  @param theData The bytes to use.
  @param theBoundary The boundary to use.
  @result A CWMIMEMultipart instance, nil on error.
*/
+ (CWMIMEMultipart *) compositeMultipartContentFromRawSource: (NSData *) theData
                                                    boundary: (NSData *) theBoundary;

/*!
  @method discreteContentFromRawSource: encoding: charset: part:
  @discussion This method is used to obtain discrete types such as
              text/, application/, image/, etc. It might return a NSString
	      or a NSData object (if the encoding is PantomimeEncodingBase64).
  @param theData The bytes to use.
  @param theEncoding The encoding to use. Valid values are
                     part of the PantomimeEncoding enum.
  @result A NSData instance.
*/
+ (id) discreteContentFromRawSource: (NSData *) theData
                           encoding: (PantomimeEncoding) theEncoding;

/*!
  @method setContentFromRawSource: inPart:
  @discussion This method is used to initialize a message, or a part
              of the message using <i>theData</i>. The CWPart's Content-Type
	      MUST be defined BEFORE calling this function otherwise
              the content will be considered as a pure string.
  @param theData The bytes to use.
  @param thePart The part to use, which can be a Part or a Message instance.
*/
+ (void) setContentFromRawSource: (NSData *) theData
                          inPart: (CWPart *) thePart;

/*!
  @method plainTextContentFromPart:
  @discussion This method is used to obtain a pure "text" part.
              For example, it can be used to strip any
	      HTML content from a part in order to get only
	      the text.
  @param thePart The Part instance from which to obtain the text.
  @result The pure "text".
*/
+ (NSData *) plainTextContentFromPart: (CWPart *) thePart;

@end

#endif // _Pantomime_H_CWMIMEUtility