7 #ifndef _MIMETIC_MESSAGE_H_
8 #define _MIMETIC_MESSAGE_H_
10 #include <sys/types.h>
11 #include <mimetic/libconfig.h>
12 #include <mimetic/mimeentity.h>
13 #include <mimetic/utils.h>
14 #include <mimetic/codec/codec.h>
37 TextEntity(
const std::string& text,
const std::string& charset);
52 TextPlain(
const std::string& text,
const std::string& charset);
64 TextEnriched(
const std::string& text,
const std::string& charset);
106 template<
typename Codec>
108 std::string type()
const;
109 void type(
const std::string&);
110 uint padding()
const;
111 void padding(
unsigned int);
112 bool operator()()
const {
return isValid(); }
113 bool isValid()
const {
return m_status; }
127 template<
typename Codec>
128 Attachment(
const std::string&,
const Codec& c );
129 template<
typename Codec>
131 bool operator()()
const {
return isValid(); }
132 bool isValid()
const {
return m_status; }
134 template<
typename Codec>
135 void set(
const std::string&,
const ContentType&,
const Codec& c);
147 template<
typename Codec>
148 ImageJpeg(
const std::string& fqn,
const Codec& c)
161 template<
typename Codec>
162 AudioBasic(
const std::string& fqn,
const Codec& c)
175 std::ostream& write(std::ostream&,
const char*)
const;
185 template<
typename Codec>
188 set(fqn,
ContentType(
"application",
"octet-stream"), codec);
191 template<
typename Codec>
194 set(fqn, ctype, codec);
197 template<
typename Codec>
198 void Attachment::set(
const std::string& fqn,
const ContentType& ctype,
const Codec& codec)
200 Header& h = header();
203 std::string filename = utils::extractFilename(m_fqn);
205 h.contentType(ctype);
206 h.contentType().paramList().push_back(ContentType::Param(
"name", filename));
209 h.contentTransferEncoding().mechanism(codec.name());
212 h.contentDisposition().type(
"attachment");
213 h.contentDisposition().paramList().push_back(ContentDisposition::Param(
"filename", filename));
215 m_status = body().
load(m_fqn, codec);
219 template<
typename Codec>
220 ApplicationOctStream::ApplicationOctStream(
const std::string& fqn,
const Codec& codec)
222 Header& h = header();
225 std::string filename = utils::extractFilename(m_fqn);
227 h.contentType(ContentType(
"application",
"octet-stream"));
228 h.contentType().paramList().push_back(ContentType::Param(
"name", filename));
231 h.contentTransferEncoding().mechanism(codec.name());
234 h.contentDisposition().type(
"attachment");
235 h.contentDisposition().paramList().push_back(ContentDisposition::Param(
"filename", filename));
237 m_status = body().
load(m_fqn, codec);
application/octet-stream entity class
Definition: message.h:103
text/enriched entity class
Definition: message.h:57
Codecs base class.
Definition: codec_base.h:23
Represent a MIME entity.
Definition: mimeentity.h:37
audio/basic attachment
Definition: message.h:155
multipart/alternative entity class
Definition: message.h:90
Attachment(const std::string &)
Content-Type field value.
Definition: contenttype.h:18
Base multipart/* class.
Definition: message.h:72
multipart/parallel entity class
Definition: message.h:84
Base64 encoder.
Definition: base64.h:36
image/jpeg attachment
Definition: message.h:141
Base class for text/* MIME entities.
Definition: message.h:25
Helper class to embed file attachments.
Definition: message.h:120
multipart/digest entity class
Definition: message.h:96
message/rfc822 entity type
Definition: message.h:171
bool load(const std::string &)
multipart/mixed entity class
Definition: message.h:78
text/plain entity class
Definition: message.h:45