~ubuntu-branches/ubuntu/karmic/gnustep-base/karmic

« back to all changes in this revision

Viewing changes to Headers/Additions/GNUstepBase/GSMime.h

  • Committer: Bazaar Package Importer
  • Author(s): Eric Heintzmann
  • Date: 2005-04-17 00:14:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050417001438-enf0y07c9tku85z1
Tags: 1.10.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** Interface for MIME parsing classes
 
2
 
 
3
   Copyright (C) 2000 Free Software Foundation, Inc.
 
4
 
 
5
   Written by:  Richard frith-Macdonald  <rfm@gnu.org>
 
6
 
 
7
   Date: October 2000
 
8
   
 
9
   This file is part of the GNUstep Base Library.
 
10
 
 
11
   This library is free software; you can redistribute it and/or
 
12
   modify it under the terms of the GNU Library General Public
 
13
   License as published by the Free Software Foundation; either
 
14
   version 2 of the License, or (at your option) any later version.
 
15
   
 
16
   This library is distributed in the hope that it will be useful,
 
17
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
   Library General Public License for more details.
 
20
 
 
21
   You should have received a copy of the GNU Library General Public
 
22
   License along with this library; if not, write to the Free
 
23
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
 
24
 
 
25
   AutogsdocSource: Additions/GSMime.m
 
26
*/
 
27
 
 
28
#ifndef __GSMIME_H__
 
29
#define __GSMIME_H__
 
30
 
 
31
#ifdef NeXT_Foundation_LIBRARY
 
32
#include <Foundation/Foundation.h>
 
33
#else
 
34
#include        <Foundation/NSObject.h>
 
35
#include        <Foundation/NSString.h>
 
36
#endif
 
37
 
 
38
@class  NSArray;
 
39
@class  NSMutableArray;
 
40
@class  NSData;
 
41
@class  NSMutableData;
 
42
@class  NSDictionary;
 
43
@class  NSMutableDictionary;
 
44
@class  NSScanner;
 
45
 
 
46
/*
 
47
 * A trivial class for mantaining state while decoding/encoding data.
 
48
 * Each encoding type requires its own subclass.
 
49
 */
 
50
@interface      GSMimeCodingContext : NSObject
 
51
{
 
52
  BOOL          atEnd;  /* Flag to say that data has ended.     */
 
53
}
 
54
- (BOOL) atEnd;
 
55
- (BOOL) decodeData: (const void*)sData
 
56
             length: (unsigned)length
 
57
           intoData: (NSMutableData*)dData;
 
58
- (void) setAtEnd: (BOOL)flag;
 
59
@end
 
60
 
 
61
@interface      GSMimeHeader : NSObject <NSCopying>
 
62
{
 
63
  NSString              *name;
 
64
  NSString              *value;
 
65
  NSMutableDictionary   *objects;
 
66
  NSMutableDictionary   *params;
 
67
}
 
68
+ (NSString*) makeQuoted: (NSString*)v always: (BOOL)flag;
 
69
+ (NSString*) makeToken: (NSString*)t;
 
70
- (id) copyWithZone: (NSZone*)z;
 
71
- (id) initWithName: (NSString*)n
 
72
              value: (NSString*)v;
 
73
- (id) initWithName: (NSString*)n
 
74
              value: (NSString*)v
 
75
         parameters: (NSDictionary*)p;
 
76
- (NSString*) name;
 
77
- (id) objectForKey: (NSString*)k;
 
78
- (NSDictionary*) objects;
 
79
- (NSString*) parameterForKey: (NSString*)k;
 
80
- (NSDictionary*) parameters;
 
81
- (NSMutableData*) rawMimeData;
 
82
- (void) setName: (NSString*)s;
 
83
- (void) setObject: (id)o  forKey: (NSString*)k;
 
84
- (void) setParameter: (NSString*)v forKey: (NSString*)k;
 
85
- (void) setParameters: (NSDictionary*)d;
 
86
- (void) setValue: (NSString*)s;
 
87
- (NSString*) text;
 
88
- (NSString*) value;
 
89
@end
 
90
 
 
91
 
 
92
@interface      GSMimeDocument : NSObject <NSCopying>
 
93
{
 
94
  NSMutableArray        *headers;
 
95
  id                    content;
 
96
}
 
97
 
 
98
+ (NSString*) charsetFromEncoding: (NSStringEncoding)enc;
 
99
+ (NSData*) decodeBase64: (NSData*)source;
 
100
+ (NSString*) decodeBase64String: (NSString*)source;
 
101
+ (GSMimeDocument*) documentWithContent: (id)newContent
 
102
                                   type: (NSString*)type
 
103
                                   name: (NSString*)name;
 
104
+ (NSData*) encodeBase64: (NSData*)source;
 
105
+ (NSString*) encodeBase64String: (NSString*)source;
 
106
+ (NSStringEncoding) encodingFromCharset: (NSString*)charset;
 
107
 
 
108
- (void) addContent: (id)newContent;
 
109
- (void) addHeader: (GSMimeHeader*)info;
 
110
- (GSMimeHeader*) addHeader: (NSString*)name
 
111
                      value: (NSString*)value
 
112
                 parameters: (NSDictionary*)parameters;
 
113
- (NSArray*) allHeaders;
 
114
- (id) content;
 
115
- (id) contentByID: (NSString*)key;
 
116
- (id) contentByLocation: (NSString*)key;
 
117
- (id) contentByName: (NSString*)key;
 
118
- (id) copyWithZone: (NSZone*)z;
 
119
- (NSString*) contentFile;
 
120
- (NSString*) contentID;
 
121
- (NSString*) contentLocation;
 
122
- (NSString*) contentName;
 
123
- (NSString*) contentSubtype;
 
124
- (NSString*) contentType;
 
125
- (NSArray*) contentsByName: (NSString*)key;
 
126
- (NSData*) convertToData;
 
127
- (NSString*) convertToText;
 
128
- (void) deleteContent: (GSMimeDocument*)aPart;
 
129
- (void) deleteHeader: (GSMimeHeader*)aHeader;
 
130
- (void) deleteHeaderNamed: (NSString*)name;
 
131
- (GSMimeHeader*) headerNamed: (NSString*)name;
 
132
- (NSArray*) headersNamed: (NSString*)name;
 
133
- (NSString*) makeBoundary;
 
134
- (GSMimeHeader*) makeContentID;
 
135
- (GSMimeHeader*) makeHeader: (NSString*)name
 
136
                       value: (NSString*)value
 
137
                  parameters: (NSDictionary*)parameters;
 
138
- (GSMimeHeader*) makeMessageID;
 
139
- (NSMutableData*) rawMimeData;
 
140
- (NSMutableData*) rawMimeData: (BOOL)isOuter;
 
141
- (void) setContent: (id)newContent;
 
142
- (void) setContent: (id)newContent
 
143
               type: (NSString*)type;
 
144
- (void) setContent: (id)newContent
 
145
               type: (NSString*)type
 
146
               name: (NSString*)name;
 
147
- (void) setContentType: (NSString*)newType;
 
148
- (void) setHeader: (GSMimeHeader*)info;
 
149
- (GSMimeHeader*) setHeader: (NSString*)name
 
150
                      value: (NSString*)value
 
151
                 parameters: (NSDictionary*)parameters;
 
152
 
 
153
@end
 
154
 
 
155
@interface      GSMimeParser : NSObject
 
156
{
 
157
  NSMutableData         *data;
 
158
  unsigned char         *bytes;
 
159
  unsigned              dataEnd;
 
160
  unsigned              sectionStart;
 
161
  unsigned              lineStart;
 
162
  unsigned              lineEnd;
 
163
  unsigned              input;
 
164
  unsigned              expect;
 
165
  unsigned              rawBodyLength;
 
166
  struct {
 
167
    unsigned int        inBody:1;
 
168
    unsigned int        isHttp:1;
 
169
    unsigned int        complete:1;
 
170
    unsigned int        hadErrors:1;
 
171
    unsigned int        buggyQuotes:1;
 
172
    unsigned int        wantEndOfLine:1;
 
173
  } flags;
 
174
  NSData                *boundary;
 
175
  GSMimeDocument        *document;
 
176
  GSMimeParser          *child;
 
177
  GSMimeCodingContext   *context;
 
178
  NSStringEncoding      _defaultEncoding;
 
179
}
 
180
 
 
181
+ (GSMimeDocument*) documentFromData: (NSData*)mimeData;
 
182
+ (GSMimeParser*) mimeParser;
 
183
 
 
184
- (GSMimeCodingContext*) contextFor: (GSMimeHeader*)info;
 
185
- (NSData*) data;
 
186
- (BOOL) decodeData: (NSData*)sData
 
187
          fromRange: (NSRange)aRange
 
188
           intoData: (NSMutableData*)dData
 
189
        withContext: (GSMimeCodingContext*)con;
 
190
- (void) expectNoHeaders;
 
191
- (BOOL) isComplete;
 
192
- (BOOL) isHttp;
 
193
- (BOOL) isInBody;
 
194
- (BOOL) isInHeaders;
 
195
- (GSMimeDocument*) mimeDocument;
 
196
- (BOOL) parse: (NSData*)d;
 
197
- (BOOL) parseHeader: (NSString*)aHeader;
 
198
- (BOOL) scanHeaderBody: (NSScanner*)scanner into: (GSMimeHeader*)info;
 
199
- (NSString*) scanName: (NSScanner*)scanner;
 
200
- (BOOL) scanPastSpace: (NSScanner*)scanner;
 
201
- (NSString*) scanSpecial: (NSScanner*)scanner;
 
202
- (NSString*) scanToken: (NSScanner*)scanner;
 
203
- (void) setBuggyQuotes: (BOOL)flag;
 
204
- (void) setDefaultCharset: (NSString*)aName;
 
205
- (void) setIsHttp;
 
206
@end
 
207
 
 
208
#endif