]> err.no Git - sope/blob - sope-mime/NGMime/NGPart.m
bumped framework versions
[sope] / sope-mime / NGMime / NGPart.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21
22 #include "NGPart.h"
23 #include "NGMimeType.h"
24 #include "common.h"
25 #include <NGMime/NGMimePartParser.h>
26
27 @implementation NSData(DataPart)
28
29 /* NGPart */
30
31 - (NSEnumerator *)valuesOfHeaderFieldWithName:(NSString *)_name {
32   id value = nil;
33
34   static NGMimeHeaderNames *Fields = NULL;
35
36   if (!Fields)
37     Fields = (NGMimeHeaderNames *)[NGMimePartParser headerFieldNames];
38   
39   if ([_name isEqualToString:Fields->contentLength])
40     value = [NSNumber numberWithUnsignedInt:[self length]];
41   else if ([_name isEqualToString:Fields->contentType])
42     value = [self contentType];
43   else if ([_name isEqualToString:@"content-id"])
44     value = [self contentId];
45   else if ([_name isEqualToString:@"content-m5"])
46     value = [self contentMd5];
47   else if ([_name isEqualToString:@"content-language"])
48     value = [self contentLanguage];
49
50   if (value)
51     return [[NSArray arrayWithObject:value] objectEnumerator];
52   
53   return nil;
54 }
55 - (NSEnumerator *)headerFieldNames {
56   return nil;
57 }
58
59 - (void)setBody:(id)_body {
60   [self doesNotRecognizeSelector:_cmd];
61 }
62 - (id)body {
63   return self;
64 }
65
66 /* NGMimePart */
67
68 - (NGMimeType *)contentType {
69   static NGMimeType *defType = nil;
70   if (defType == nil)
71     defType = [[NGMimeType mimeType:@"application/octet-stream"] retain];
72   return defType;
73 }
74 - (NSString *)contentId {
75   return nil;
76 }
77
78 - (NSArray *)contentLanguage {
79   return nil;
80 }
81 - (NSString *)contentMd5 {
82   return nil;
83 }
84 - (NSString *)encoding {
85   return nil;
86 }
87
88 @end /* NSData(DataPart) */
89
90 @implementation NSMutableData(DataPart)
91
92 - (void)setBody:(id)_body {
93   [self setData:_body];
94 }
95
96 @end /* NSMutableData(DataPart) */
97
98 void __link_NGPart(void) {
99   __link_NGPart();
100 }