[Up] [Next]

GSMimeDocument

Authors

Richard Frith-Macdonald

Version: $Revision$

Date: $Date$

GSMimeDocument

GSMimeDocument

Declared in: Foundation/GSMime.h

Inherits from: NSObject

Conforms to: NSObject


This class is intended to provide a wrapper for MIME messages permitting easy access to the contents of a message and providing a basis for parsing an unparsing messages that have arrived via email or as a web document.

The class keeps track of all the document headers, and provides methods for modifying the headers that apply to a document and for looking at the header structures, by providing an info dictionary containing the various parts of a header.

The common dictionary keys used for elements provided for all headers are -

RawHeader
This is the unmodified text of the header
BaseName
This is the header name.
BaseValue
This is the text after the header name and colon.
Name
This is a lowercase representation of the header name.
Value
This is the value of the header (normally lower case). It may only be a small subset of the information in the header with other information being split into separate fields depending on the type of header.

Instance Variables

Methods


Class Methods

mimeDocument

+ (GSMimeDocument*) mimeDocument;
Create an empty MIME document.

Instances Methods

addHeader:

- (BOOL) addHeader: (NSDictionary*)headerInfo;

This method may be called to add a header to the document. The header must be a mutable dictionary object that contains at least the fields that are standard for all headers.


allHeaders

- (NSArray) allHeaders;

This method returns an array containing NSDictionary objects representing the headers associated with the document.

The order of the headers in the array is the order of the headers in the document.


content

- (id) content;
This returns the content data of the document in the appropriate format for the type of data -
text
an NSString object
binary
an NSData object
multipart
an NSArray object containing GSMimeDocument objects

deleteHeader:

- (void) deleteHeader: (NSString*)rawHeader;
This method removes all occurrances of headers whose raw data exactly matches the supplied string.

deleteHeaderNamed:

- (void) deleteHeaderNamed: (NSString*)aName;
This method removes all occurrances of headers whose name matches the supplied string.

headerNamed:

- (NSDictionary*) headerNamed: (NSString*)aName;
This method returns the info dictionary for the first header whose name equals the supplied argument.

headersNamed:

- (NSArray*) headersNamed: (NSString*)aName;
This method returns an array of info dictionaries for all headers whose names equal the supplied argument.

setContent:

- (BOOL) setContent: (id)newContent;
Sets a new value for the content of the document.

setHeader:

- (BOOL) setHeader: (NSDictionary*)headerInfo;
This method may be called to set a header in the document. Any other headers with the same name will be removed from the document.