Debian Codegraph @

Framework/Pantomime/CWMIMEUtility.h

raw symbols SCIP
1 /*
2 ** CWMIMEUtility.h
3 **
4 ** Copyright (c) 2001-2004 Ludovic Marcotte
5 ** Copyright (C) 2018 Riccardo Mottola
6 **
7 ** Author: Ludovic Marcotte <[email protected]>
8 ** Riccardo Mottola <[email protected]>
9 **
10 ** This library is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU Lesser General Public
12 ** License as published by the Free Software Foundation; either
13 ** version 2.1 of the License, or (at your option) any later version.
14 **
15 ** This library is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** Lesser General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24 #ifndef _Pantomime_H_CWMIMEUtility
25 #define _Pantomime_H_CWMIMEUtility
26
27 #import <Foundation/NSArray.h>
28 #import <Foundation/NSData.h>
29 #import <Foundation/NSObject.h>
30 #import <Foundation/NSString.h>
31
32 #include <Pantomime/CWConstants.h>
33
34 @class CWMessage;
35 @class CWMIMEMultipart;
36 @class CWPart;
37
38
39 /*!
40 @class CWMIMEUtility
41 @abstract MIME utility class.
42 @discussion This class provides static methods to deal with the MIME standard.
43 Normally, you should not invoke any of those methods directly.
44 */
45 @interface CWMIMEUtility: NSObject
46
47
48 /*!
49 @method decodeHeader: charset:
50 @discussion This method is used to decode a header value
51 encoded in base64 or quoted-printable. RFC 2047
52 describes how those headers should be encoded
53 (in particular, "2. Syntax of encoded-words").
54 If <i>theCharset</i> is not nil, it is used to
55 decode the header. Otherwise, the charset used
56 in the header is used.
57 @param theData The data to decode.
58 @param theCharset The charset to force.
59 @result The decoded header.
60 */
61 + (NSString *) decodeHeader: (NSData *) theData
62 charset: (NSString *) theCharset;
63
64 /*!
65 @method encodeHeader: charset: encoding:
66 @discussion This method is used to encode a header value
67 in the format specified by RFC 2047 (in particular,
68 "2. Syntax of encoded-words").
69 @param theText The text to encode.
70 @param theCharset The charset to use. For example, "iso-8859-1".
71 @param theEncoding The encoding to use. Valid values are
72 part of the PantomimeEncoding enum.
73 @result The encoded data.
74 */
75 + (NSData *) encodeHeader: (NSString *) theText
76 charset: (NSString *) theCharset
77 encoding: (PantomimeEncoding) theEncoding;
78
79 + (NSData *) encodeWordUsingBase64: (NSString *) theWord
80 prefixLength: (int) thePrefixLength;
81
82 + (NSData *) encodeWordUsingQuotedPrintable: (NSString *) theWord
83 prefixLength: (NSUInteger) thePrefixLength;
84
85 /*!
86 @method globallyUniqueBoundary
87 @discussion This method is used to generate a unique MIME boundary
88 (or any kind of boundary).
89 @result The boundary, as a NSData instance.
90 */
91 + (NSData *) globallyUniqueBoundary;
92
93 /*!
94 @method globallyUniqueID
95 @discussion This method is used to generate a unique ID that CWMessage (or CWPart)
96 instances use as their unique ID. (Message-ID, Content-ID, etc.)
97 @result The unique ID, as a NSData instance.
98 */
99 + (NSData *) globallyUniqueID;
100
101 /*!
102 @method compositeMessageContentFromRawSource:
103 @discussion This method is used to obtain a composite type (message)
104 from <i>theData</i>.
105 @param theData The bytes to use.
106 @result A Message instance, nil on error.
107 */
108 + (CWMessage *) compositeMessageContentFromRawSource: (NSData *) theData;
109
110 /*!
111 @method compositeMultipartContentFromRawSource:boundary:
112 @discussion This method is used to obtain a composity type (multipart)
113 from <i>theData</i>, using <i>theBoundary</i>.
114 @param theData The bytes to use.
115 @param theBoundary The boundary to use.
116 @result A CWMIMEMultipart instance, nil on error.
117 */
118 + (CWMIMEMultipart *) compositeMultipartContentFromRawSource: (NSData *) theData
119 boundary: (NSData *) theBoundary;
120
121 /*!
122 @method discreteContentFromRawSource: encoding: charset: part:
123 @discussion This method is used to obtain discrete types such as
124 text/, application/, image/, etc. It might return a NSString
125 or a NSData object (if the encoding is PantomimeEncodingBase64).
126 @param theData The bytes to use.
127 @param theEncoding The encoding to use. Valid values are
128 part of the PantomimeEncoding enum.
129 @result A NSData instance.
130 */
131 + (id) discreteContentFromRawSource: (NSData *) theData
132 encoding: (PantomimeEncoding) theEncoding;
133
134 /*!
135 @method setContentFromRawSource: inPart:
136 @discussion This method is used to initialize a message, or a part
137 of the message using <i>theData</i>. The CWPart's Content-Type
138 MUST be defined BEFORE calling this function otherwise
139 the content will be considered as a pure string.
140 @param theData The bytes to use.
141 @param thePart The part to use, which can be a Part or a Message instance.
142 */
143 + (void) setContentFromRawSource: (NSData *) theData
144 inPart: (CWPart *) thePart;
145
146 /*!
147 @method plainTextContentFromPart:
148 @discussion This method is used to obtain a pure "text" part.
149 For example, it can be used to strip any
150 HTML content from a part in order to get only
151 the text.
152 @param thePart The Part instance from which to obtain the text.
153 @result The pure "text".
154 */
155 + (NSData *) plainTextContentFromPart: (CWPart *) thePart;
156
157 @end
158
159 #endif // _Pantomime_H_CWMIMEUtility