2
Copyright (C) 2000-2005 SKYRIX Software AG
4
This file is part of SOPE.
6
SOPE is free software; you can redistribute it and/or modify it under
7
the terms of the GNU Lesser General Public License as published by the
8
Free Software Foundation; either version 2, or (at your option) any
11
SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14
License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with SOPE; see the file COPYING. If not, write to the
18
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22
#ifndef __NGMimeGenerator_NGMimePartGenerator_H__
23
#define __NGMimeGenerator_NGMimePartGenerator_H__
25
#import <Foundation/NSObject.h>
26
#import <NGMime/NGPart.h>
27
#import <NGMime/NGMimeGeneratorProtocols.h>
29
@class NSMutableData, NSData, NSString, NSEnumerator;
30
@class NGHashMap, NGMutableHashMap;
31
@class NGMimeType, NGMimePartGenerator;
33
@interface NGMimePartGenerator : NSObject <NGMimePartGenerator>
36
NSMutableData *result; // result
37
id<NGMimePart> part; // for generating
38
id delegate; // not retained to prevent retain cycles
42
void (*appendBytes)(id,SEL,const void*,unsigned int); /* cached method
45
BOOL generatorGenerateDataForHeaderField:1;
46
BOOL generatorGeneratorForBodyOfPart:1;
47
BOOL generatorGenerateDataForBodyOfPart:1;
51
+ (id)mimePartGenerator;
53
/* generating mime from MimeMessage */
54
- (NSData *)generateMimeFromPart:(id<NGMimePart>)_part;
57
/* generate mime from part and store it in the returned filename */
58
- (NSString *)generateMimeFromPartToFile:(id<NGMimePart>)_part;
60
/* build data with current mime-header and the _additionalHeaders;
61
_additionalHeaders come from generateBodyData (boundary, encoding, ...) */
62
- (NSData *)generateHeaderData:(NGHashMap *)_additionalHeaders;
64
/* build the body; use -generatorForBodyOfPart */
65
- (NSData *)generateBodyData:(NGMutableHashMap *)_additionalHeaders;
67
/* call generateHeaderData and generateBodyData; manage additionalHeaders */
70
/* set result and other stuff */
71
- (BOOL)prepareForGenerationOfPart:(id<NGMimePart>)_part;
73
/* setting the delegate */
74
- (void)setDelegate:(id)_delegate;
77
/* ----- hooks for subclasses ----- */
80
Generate a prefix and/or a suffix for a part. Can be used to write
81
HTTP response lines before the part.
83
- (BOOL)generatePrefix;
84
- (void)generateSuffix;
86
/* if no content-type is set */
87
- (NGMimeType *)defaultContentTypeForPart:(id<NGMimePart>)_part;
89
/* returns header field generator for the specified field */
90
- (id<NGMimeHeaderFieldGenerator>)generatorForHeaderField:(NSString *)_name;
92
/* build data for the specified header; employ -generatorForHeaderField */
94
- (NSData *)generateDataForHeaderField:(NSString *)_headerField
97
/* build data with the specified header; */
99
- (BOOL)isMultiValueCommaHeaderField:(NSString *)_headerField;
100
- (BOOL)appendHeaderField:(NSString *)_field values:(NSEnumerator *)_values
101
toData:(NSMutableData *)_data;
103
/* looking for a NGMimeBodyGenerator in dependece to the content-type */
104
- (id<NGMimeBodyGenerator>)generatorForBodyOfPart:(id<NGMimePart>)_part;
106
/* ----- end hooks for subclasses ----- */
109
- (id<NGMimePart>)part;
113
@interface NSObject(NGMimePartGenerator)
116
The delegete has the opportunity to generate data for specified
117
header-field with the given enumerator. The classes of the values depends
118
on the _headerField name, normaly they are NSStrings
120
- (NSData *)mimePartGenerator:(id<NGMimePartGenerator>)_gen
121
generateDataForHeaderField:(NSString *)_headerField
122
value:(NSEnumerator *)_value;
125
The delegate can choose, which generator should be used, to generate
126
the specified NGMimePart.
128
- (id<NGMimeBodyGenerator>)mimePartGenerator:(id<NGMimePartGenerator>)_gen
129
generatorForBodyOfPart:(id<NGMimePart>)_part;
132
The delegate has the opportunity to generate the whole body-part. Additional
133
headers like boundary can be set in _additionalHeaders.
135
- (NSData *)mimePartGenerator:(id<NGMimePartGenerator>)_gen
136
generateDataForBodyOfPart:(id<NGMimePart>)_part
137
additionalHeaders:(NGMutableHashMap *)_additionalHeaders;
140
The delegate can set prefix and suffix for a multipart.
142
- (NSString *)multipartBodyGenerator:(id<NGMimeBodyGenerator>)_bodyGen
143
prefixForPart:(id<NGMimePart>)_part;
145
- (NSString *)multipartBodyGenerator:(id<NGMimeBodyGenerator>)_bodyGen
146
suffixForPart:(id<NGMimePart>)_part;
149
The delegate can select which NGMimeBodyGenerator should de used
150
for generate the given part.
152
- (id<NGMimePartGenerator>)multipartBodyGenerator:(id<NGMimeBodyGenerator>)
153
generatorForPart:(id<NGMimePart>)_part;
156
- (void)setUseMimeData:(BOOL)_b;
160
#endif // __NGMimeGenerator_NGMimePartGenerator_H__