PTLib
Version 2.14.3
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
mime.h
Go to the documentation of this file.
1
/*
2
* mime.h
3
*
4
* Multipurpose Internet Mail Extensions support classes.
5
*
6
* Portable Windows Library
7
*
8
* Copyright (c) 1993-2002 Equivalence Pty. Ltd.
9
*
10
* The contents of this file are subject to the Mozilla Public License
11
* Version 1.0 (the "License"); you may not use this file except in
12
* compliance with the License. You may obtain a copy of the License at
13
* http://www.mozilla.org/MPL/
14
*
15
* Software distributed under the License is distributed on an "AS IS"
16
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17
* the License for the specific language governing rights and limitations
18
* under the License.
19
*
20
* The Original Code is Portable Windows Library.
21
*
22
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23
*
24
* Contributor(s): ______________________________________.
25
*
26
* $Revision: 26840 $
27
* $Author: rjongbloed $
28
* $Date: 2012-01-08 18:22:58 +1100 (Sun, 08 Jan 2012) $
29
*/
30
31
#ifndef PTLIB_PMIME_H
32
#define PTLIB_PMIME_H
33
34
#ifdef P_USE_PRAGMA
35
#pragma interface
36
#endif
37
38
#include <
ptclib/cypher.h
>
39
40
41
class
PMultiPartList
;
42
class
PInternetProtocol
;
43
44
46
// PMIMEInfo
47
52
class
PMIMEInfo
:
public
PStringOptions
53
{
54
public
:
55
PMIMEInfo
() { }
56
58
PMIMEInfo
(
59
istream &strm
60
);
61
PMIMEInfo
(
62
PInternetProtocol
& socket
63
);
64
PMIMEInfo
(
65
const
PStringToString
& dict
66
);
67
PMIMEInfo
(
68
const
PString
& str
69
);
70
71
72
// Overrides from class PObject
76
virtual
void
PrintOn
(
77
ostream &strm
78
)
const
;
79
83
virtual
void
ReadFrom
(
84
istream &strm
85
);
86
87
88
// New functions for class.
94
PBoolean
Read
(
95
PInternetProtocol
& socket
96
);
97
103
PBoolean
Write
(
104
PInternetProtocol
& socket
105
)
const
;
106
109
PString
AsString
()
const
;
110
119
bool
AddMIME
(
120
const
PString
& line
121
);
122
bool
AddMIME
(
123
const
PString
& fieldName,
124
const
PString
& fieldValue
125
) {
return
InternalAddMIME
(fieldName, fieldValue); }
126
bool
AddMIME
(
127
const
PMIMEInfo
& mime
128
);
129
130
virtual
bool
InternalAddMIME
(
131
const
PString
& fieldName,
132
const
PString
& fieldValue
133
);
134
164
bool
GetComplex
(
165
const
char
* key,
166
PStringToString
& info
167
)
const
{
return
ParseComplex
(
GetString
(key), info); }
168
bool
GetComplex
(
169
const
PString
& key,
170
PStringToString
& info
171
)
const
{
return
ParseComplex
(
GetString
(key), info); }
172
bool
GetComplex
(
173
const
PCaselessString
& key,
174
PStringToString
& info
175
)
const
{
return
ParseComplex
(
GetString
(key), info); }
176
bool
GetComplex
(
177
const
PCaselessString
& (*key)(),
178
PStringToString
& info
179
)
const
{
return
ParseComplex
(
GetString
(key), info); }
180
182
static
bool
ParseComplex
(
183
const
PString
& str,
184
PStringToString
& info
185
);
186
189
bool
DecodeMultiPartList
(
190
PMultiPartList
& parts,
191
const
PString
& body,
192
const
PCaselessString
& key
193
)
const
;
194
197
bool
DecodeMultiPartList
(
198
PMultiPartList
& parts,
199
const
PString
& body,
200
const
PCaselessString
& (*key)() =
ContentTypeTag
201
)
const
{
return
DecodeMultiPartList
(parts, body, key()); }
202
203
204
static
const
PCaselessString
&
ContentTypeTag
();
205
static
const
PCaselessString
&
ContentDispositionTag
();
206
static
const
PCaselessString
&
ContentTransferEncodingTag
();
207
static
const
PCaselessString
&
ContentDescriptionTag
();
208
static
const
PCaselessString
&
ContentIdTag
();
209
210
static
const
PCaselessString
&
TextPlain
();
211
212
250
static
void
SetAssociation
(
251
const
PStringToString
& allTypes,
252
PBoolean
merge =
true
253
);
254
static
void
SetAssociation
(
255
const
PString
& fileType,
256
const
PString
& contentType
257
) { GetContentTypes().
SetAt
(fileType, contentType); }
258
266
static
PString
GetContentType
(
267
const
PString
& fileType
268
);
269
272
virtual
ostream &
PrintContents
(
273
ostream & strm
274
)
const
;
275
276
private
:
277
static
PStringToString
& GetContentTypes();
278
};
279
280
282
// PMultiPartInfo
283
286
class
PMultiPartInfo
:
public
PObject
287
{
288
PCLASSINFO(
PMultiPartInfo
,
PObject
);
289
public
:
290
PMIMEInfo
m_mime
;
291
PString
m_textBody
;
292
PBYTEArray
m_binaryBody
;
293
};
294
295
class
PMultiPartList
:
public
PList
<PMultiPartInfo>
296
{
297
PCLASSINFO(
PMultiPartList
,
PList<PMultiPartInfo>
);
298
public
:
299
PMultiPartList
() { }
300
301
bool
Decode
(
302
const
PString
& body,
303
const
PStringToString
& contentInfo
304
);
305
};
306
307
308
#endif // PTLIB_PMIME_H
309
310
311
// End Of File ///////////////////////////////////////////////////////////////
include
ptclib
mime.h
Generated on Fri Oct 10 2014 21:15:13 for PTLib by
1.8.3.1