1
/***************************************************************************
2
copyright : (C) 2002-2005 by Stefano Barbato
3
email : stefano@codesink.org
5
$Id: message.cxx,v 1.2 2005/02/23 10:26:14 tat Exp $
6
***************************************************************************/
8
/***************************************************************************
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
15
***************************************************************************/
18
#include <mimetic/message.h>
19
#include <mimetic/contenttype.h>
20
#include <mimetic/utils.h>
26
Attachment::Attachment(const std::string& fqn)
28
set(fqn, ContentType("application","octect-stream"),Base64::Encoder());
31
Attachment::Attachment(const std::string& fqn, const ContentType& ct)
33
set(fqn, ct, Base64::Encoder());
37
TextEntity::TextEntity()
39
header().contentType("text/unknown");
42
TextEntity::TextEntity(const string& text)
44
m_header.contentType("text/unknown");
48
TextEntity::TextEntity(const string& text, const string& charset)
50
ContentType ct("text", "unknown");
51
ct.paramList().push_back(ContentType::Param("charset", charset));
52
m_header.contentType(ct);
56
TextPlain::TextPlain(const string& text)
59
m_header.contentType("text/plain");
62
TextPlain::TextPlain(const string& text, const string& charset)
63
: TextEntity(text,charset)
65
m_header.contentType("text/plain");
69
TextEnriched::TextEnriched(const string& text)
72
m_header.contentType("text/enriched");
74
TextEnriched::TextEnriched(const string& text, const string& charset)
75
: TextEntity(text,charset)
77
m_header.contentType("text/enriched");
81
MultipartEntity::MultipartEntity()
83
ContentType::Boundary boundary;
84
ContentType ct("multipart", "unknown");
85
ct.paramList().push_back(ContentType::Param("boundary", boundary));
86
m_header.contentType(ct);
89
MultipartMixed::MultipartMixed()
91
ContentType::Boundary boundary;
92
ContentType ct("multipart", "mixed");
93
ct.paramList().push_back(ContentType::Param("boundary", boundary));
94
m_header.contentType(ct);
97
MultipartParallel::MultipartParallel()
99
ContentType::Boundary boundary;
100
ContentType ct("multipart", "parallel");
101
ct.paramList().push_back(ContentType::Param("boundary", boundary));
102
m_header.contentType(ct);
105
MultipartAlternative::MultipartAlternative()
107
ContentType::Boundary boundary;
108
ContentType ct("multipart", "alternative");
109
ct.paramList().push_back(ContentType::Param("boundary", boundary));
110
m_header.contentType(ct);
113
MultipartDigest::MultipartDigest()
115
ContentType::Boundary boundary;
116
ContentType ct("multipart", "digest");
117
ct.paramList().push_back(ContentType::Param("boundary", boundary));
118
m_header.contentType(ct);
121
ApplicationOctStream::ApplicationOctStream()
123
m_header.contentType("application/octet-stream");
126
MessageRfc822::MessageRfc822(const MimeEntity& me)
129
m_header.contentType("message/rfc822");
132
ostream& MessageRfc822::write(ostream& os,const char* eol) const
134
MimeEntity::write(os);
138
string ApplicationOctStream::type() const
140
return m_header.contentType().param("type");
143
void ApplicationOctStream::type(const string& type)
145
ContentType ct = m_header.contentType();
146
ct.param("type",type);
147
m_header.contentType(ct);
150
uint ApplicationOctStream::padding() const
152
return utils::str2int(m_header.contentType().param("padding"));
155
void ApplicationOctStream::padding(unsigned int n)
157
ContentType ct = m_header.contentType();
158
ct.param("padding", utils::int2str(n));
159
m_header.contentType(ct);