| 1 | /* |
| 2 | ** CWParser.h |
| 3 | ** |
| 4 | ** Copyright (c) 2001-2006 Ludovic Marcotte |
| 5 | ** |
| 6 | ** Author: Ludovic Marcotte <[email protected]> |
| 7 | ** |
| 8 | ** This library is free software; you can redistribute it and/or |
| 9 | ** modify it under the terms of the GNU Lesser General Public |
| 10 | ** License as published by the Free Software Foundation; either |
| 11 | ** version 2.1 of the License, or (at your option) any later version. |
| 12 | ** |
| 13 | ** This library is distributed in the hope that it will be useful, |
| 14 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | ** Lesser General Public License for more details. |
| 17 | ** |
| 18 | ** You should have received a copy of the GNU General Public License |
| 19 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | |
| 22 | #ifndef _Pantomime_H_CWParser |
| 23 | #define _Pantomime_H_CWParser |
| 24 | |
| 25 | #import <Foundation/NSData.h> |
| 26 | #import <Foundation/NSObject.h> |
| 27 | |
| 28 | #include <Pantomime/CWConstants.h> |
| 29 | |
| 30 | @class CWPart; |
| 31 | @class CWMessage; |
| 32 | |
| 33 | /*! |
| 34 | @class CWParser |
| 35 | @abstract Utility class providing class methods to parse messages. |
| 36 | @discussion This class provide useful methods (all class methods) to |
| 37 | parse messages from their raw representation. |
| 38 | */ |
| 39 | @interface CWParser: NSObject |
| 40 | |
| 41 | /*! |
| 42 | @method parseContentDescription: inPart: |
| 43 | @discussion This method is used to parse a Content-Disposition header line. |
| 44 | @param theLine The line to parse. |
| 45 | @param thePart The part in which to store the parsed value, if any. |
| 46 | */ |
| 47 | + (void) parseContentDescription: (NSData *) theLine |
| 48 | inPart: (CWPart *) thePart; |
| 49 | |
| 50 | /*! |
| 51 | @method parseContentDisposition: inPart: |
| 52 | @discussion This method is used to parse a Content-Disposition header line. |
| 53 | It supports the following parameters: "filename" ; case-insensitive |
| 54 | @param theLine The line to parse. |
| 55 | @param thePart The part in which to store the parsed value, if any. |
| 56 | */ |
| 57 | + (void) parseContentDisposition: (NSData *) theLine |
| 58 | inPart: (CWPart *) thePart; |
| 59 | |
| 60 | /*! |
| 61 | @method parseContentID: inPart: |
| 62 | @discussion This method is used to parse a Content-ID header line. |
| 63 | @param theLine The line to parse. |
| 64 | @param thePart The part in which to store the parsed value, if any. |
| 65 | */ |
| 66 | + (void) parseContentID: (NSData *) theLine |
| 67 | inPart: (CWPart *) thePart; |
| 68 | |
| 69 | /*! |
| 70 | @method parseContentTransferEncoding: inPart: |
| 71 | @discussion This method is used to parse a Content-Transfer-Encoding header line. |
| 72 | It supports: "7bit" (or none) ; case-insensitive |
| 73 | "quoted-printable" |
| 74 | "base64" |
| 75 | "8bit" |
| 76 | "binary" |
| 77 | @param theLine The line to parse. |
| 78 | @param thePart The part in which to store the parsed value, if any. |
| 79 | */ |
| 80 | + (void) parseContentTransferEncoding: (NSData *) theLine |
| 81 | inPart: (CWPart *) thePart; |
| 82 | |
| 83 | /*! |
| 84 | @method parseContentType: inPart: |
| 85 | @discussion This method is used to parse a Content-Type header line. |
| 86 | This method parses correct lines like: |
| 87 | "Content-Type: text/plain", |
| 88 | "Content-Type: Text/plain;" |
| 89 | "Content-Type: text/plain; charset="iso-8859-1"", |
| 90 | "Content-Type: text", |
| 91 | "Content-Type: text/plain", and so on. |
| 92 | This method also parses (if it needs to) the following parameters: |
| 93 | "boundary" (if Content-Type is multipart/something), "charset" (if Content-Type is text/plain) |
| 94 | "name", "format" and so on. |
| 95 | @param theLine The line to parse. |
| 96 | @param thePart The part in which to store the parsed values, if any. |
| 97 | */ |
| 98 | + (void) parseContentType: (NSData *) theLine |
| 99 | inPart: (CWPart *) thePart; |
| 100 | |
| 101 | /*! |
| 102 | @method parseDate: inMessage: |
| 103 | @discussion This method is used to parse a Date header line. |
| 104 | @param theLine The line to parse. |
| 105 | @param theMessage The message in which to store the parsed value, if any. |
| 106 | */ |
| 107 | + (void) parseDate: (NSData *) theLine |
| 108 | inMessage: (CWMessage *) theMessage; |
| 109 | |
| 110 | /*! |
| 111 | @method parseDestination: forType: inMessage: |
| 112 | @discussion This method is used to parse the To: Cc: Bcc: headers value. |
| 113 | @param theLine The line to parse. |
| 114 | @param theType The type to parse (one of the values of the PantomimeRecipientType enum) |
| 115 | @param theMessage The message in which to store the parsed value, if any. |
| 116 | */ |
| 117 | + (NSData *) parseDestination: (NSData *) theLine |
| 118 | forType: (PantomimeRecipientType) theType |
| 119 | inMessage: (CWMessage *) theMessage |
| 120 | quick: (BOOL) theBOOL; |
| 121 | |
| 122 | /*! |
| 123 | @method parseFrom: inMessage: |
| 124 | @discussion This method is used to parse a From header line. |
| 125 | @param theLine The line to parse. |
| 126 | @param theMessage The message in which to store the parsed value, if any. |
| 127 | */ |
| 128 | + (NSData *) parseFrom: (NSData *) theLine |
| 129 | inMessage: (CWMessage *) theMessage |
| 130 | quick: (BOOL) theBOOL; |
| 131 | |
| 132 | /*! |
| 133 | @method parseInReplyTo: inMessage: |
| 134 | @discussion This method is used to parse a In-Reply-To header line. |
| 135 | @param theLine The line to parse. |
| 136 | @param theMessage The message in which to store the parsed value, if any. |
| 137 | */ |
| 138 | + (NSData *) parseInReplyTo: (NSData *) theLine |
| 139 | inMessage: (CWMessage *) theMessage |
| 140 | quick: (BOOL) theBOOL; |
| 141 | |
| 142 | /*! |
| 143 | @method parseMessageID: inMessage: |
| 144 | @discussion This method is used to parse a Message-ID header line. |
| 145 | @param theLine The line to parse. |
| 146 | @param theMessage The message in which to store the parsed value, if any. |
| 147 | */ |
| 148 | + (NSData *) parseMessageID: (NSData *) theLine |
| 149 | inMessage: (CWMessage *) theMessage |
| 150 | quick: (BOOL) theBOOL; |
| 151 | |
| 152 | /*! |
| 153 | @method parseMIMEVersion: inMessage: |
| 154 | @discussion This method is used to parse a MIME-Version header line. |
| 155 | @param theLine The line to parse. |
| 156 | @param theMessage The message in which to store the parsed value, if any. |
| 157 | */ |
| 158 | + (void) parseMIMEVersion: (NSData *) theLine |
| 159 | inMessage: (CWMessage *) theMessage; |
| 160 | |
| 161 | /*! |
| 162 | @method parseReferences: inMessage: |
| 163 | @discussion This method is used to parse a References header line. |
| 164 | @param theLine The line to parse. |
| 165 | @param theMessage The message in which to store the parsed value, if any. |
| 166 | */ |
| 167 | + (NSData *) parseReferences: (NSData *) theLine |
| 168 | inMessage: (CWMessage *) theMessage |
| 169 | quick: (BOOL) theBOOL; |
| 170 | |
| 171 | /*! |
| 172 | @method parseReply: inMessage: |
| 173 | @discussion This method is used to parse a Reply-To header line. |
| 174 | @param theLine The line to parse. |
| 175 | @param theMessage The message in which to store the parsed value, if any. |
| 176 | */ |
| 177 | + (void) parseReplyTo: (NSData *) theLine |
| 178 | inMessage: (CWMessage *) theMessage; |
| 179 | |
| 180 | /*! |
| 181 | @method parseResentFrom: inMessage: |
| 182 | @discussion This method is used to parse a Resent-From header line. |
| 183 | @param theLine The line to parse. |
| 184 | @param theMessage The message in which to store the parsed value, if any. |
| 185 | */ |
| 186 | + (void) parseResentFrom: (NSData *) theLine |
| 187 | inMessage: (CWMessage *) theMessage; |
| 188 | |
| 189 | /*! |
| 190 | @method parseStatus: inMessage: |
| 191 | @discussion This method is used to parse a Status header line. This |
| 192 | header is commonly added by some MUA:s like Pine. |
| 193 | @param theLine The line to parse. |
| 194 | @param theMessage The message in which to store the parsed value, if any. |
| 195 | */ |
| 196 | + (void) parseStatus: (NSData *) theLine |
| 197 | inMessage: (CWMessage *) theMessage; |
| 198 | |
| 199 | /*! |
| 200 | @method parseXStatus: inMessage: |
| 201 | @discussion This method is used to parse a X-Status header line. This |
| 202 | header is commonly added by some MUA:s like Pine. |
| 203 | @param theLine The line to parse. |
| 204 | @param theMessage The message in which to store the parsed value, if any. |
| 205 | */ |
| 206 | + (void) parseXStatus: (NSData *) theLine |
| 207 | inMessage: (CWMessage *) theMessage; |
| 208 | |
| 209 | /*! |
| 210 | @method parseSubject: inMessage: |
| 211 | @discussion This method is used to parse a Subject header line. |
| 212 | @param theLine The line to parse. |
| 213 | @param theMessage The message in which to store the parsed value, if any. |
| 214 | */ |
| 215 | + (NSData *) parseSubject: (NSData *) theLine |
| 216 | inMessage: (CWMessage *) theMessage |
| 217 | quick: (BOOL) theBOOL; |
| 218 | |
| 219 | /*! |
| 220 | @method parseUnknownHeader: inMessage: |
| 221 | @discussion This method is used to parse the headers that we don't "support natively". |
| 222 | @param theLine The line to parse. |
| 223 | @param theMessage The message in which to store the parsed value, if any. |
| 224 | */ |
| 225 | + (void) parseUnknownHeader: (NSData *) theLine |
| 226 | inMessage: (CWMessage *) theMessage; |
| 227 | |
| 228 | /*! |
| 229 | @method parseOrganization: inMessage: |
| 230 | @discussion This method is used to parse a Organization header line. |
| 231 | @param theLine The line to parse. |
| 232 | @param theMessage The message in which to store the parsed value, if any. |
| 233 | */ |
| 234 | + (void) parseOrganization: (NSData *) theLine |
| 235 | inMessage: (CWMessage *) theMessage; |
| 236 | |
| 237 | @end |
| 238 | |
| 239 | #endif // _Pantomime_H_CWParser |