-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTBContentType.m
executable file
·71 lines (58 loc) · 1.92 KB
/
TBContentType.m
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
/* TBContentType.m created by todd on Mon 12-Jun-2000 */
#import "TBContentType.h"
#import "TBContentId.h"
@implementation TBContentType
-(NSString *)majorType { return _majorType; }
-(NSString *)minorType { return _minorType; }
+ (id)contentTypeWithType:(NSString *)mimeType
// returns an autoreleased TBContentType object with the given mimeType
{
return [[[TBContentType alloc] initWithString:mimeType] autorelease];
}
+ (id)contentTypeWithType:(NSString *)mimeType startCID:(TBContentId *)start
// returns an autoreleased TBContentType object with the given mimeType
// and start content id.
{
TBContentType *ct = [[[TBContentType alloc] initWithString:mimeType] autorelease];
[ct setStart:start];
return ct;
}
-(id)initWithString:(NSString *)str
{
NSArray *pair;
[super initWithString: str];
pair = [_primaryValue componentsSeparatedByString: @"/"];
if ([pair count] !=2) {
[NSException raise:@"TBMimeException" format:@"TBContentType: The mimetype \"%@\" is not formatted correctly.",str];
}
_majorType = [[pair objectAtIndex: 0] retain];
_minorType = [[pair objectAtIndex: 1] retain];
return self;
}
-(void)dealloc
{
[_majorType release];
[_minorType release];
[super dealloc];
}
-(NSString *)charset { return [_additionalValues objectForKey: @"charset"]; }
-(void)setCharset:(NSString *)chars
{
[_additionalValues setObject: chars forKey: @"charset"];
}
-(NSString *)boundary { return [_additionalValues objectForKey: @"boundary"]; }
-(void)setBoundary:(NSString *)bnd
{
[_additionalValues setObject: bnd forKey: @"boundary"];
}
-(TBContentId *)start
{
return [TBContentId headerWithString:[_additionalValues objectForKey: @"start"]];
}
-(void)setStart:(TBContentId *)start
// sets the start content part value, used in multipart messages to point to
// the logical first body part.
{
[_additionalValues setObject:[start idString] forKey: @"start"];
}
@end