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