aboutsummaryrefslogtreecommitdiffstats
path: root/src/htmlTextPart.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2010-05-23 16:18:00 +0000
committerVincent Richard <[email protected]>2010-05-23 16:18:00 +0000
commit2f8026dc5bb17e7fecf126070481e34a20485b67 (patch)
tree74625e9c08910c4db6ed19c341246aa1a922a494 /src/htmlTextPart.cpp
parentFileSystemFactory is now a ref. (diff)
downloadvmime-2f8026dc5bb17e7fecf126070481e34a20485b67.tar.gz
vmime-2f8026dc5bb17e7fecf126070481e34a20485b67.zip
Improved automatic encoding selection. Added helper functions on body for setting contents, type, charset and encoding.
Diffstat (limited to 'src/htmlTextPart.cpp')
-rw-r--r--src/htmlTextPart.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/htmlTextPart.cpp b/src/htmlTextPart.cpp
index 7713034f..c845b576 100644
--- a/src/htmlTextPart.cpp
+++ b/src/htmlTextPart.cpp
@@ -69,27 +69,20 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
ref <bodyPart> part = vmime::create <bodyPart>();
parent->getBody()->appendPart(part);
- // -- Set header fields
- part->getHeader()->ContentType()->setValue
- (mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN));
- part->getHeader()->ContentType().dynamicCast <contentTypeField>()->setCharset(m_charset);
- part->getHeader()->ContentTransferEncoding()->setValue(encoding(encodingTypes::QUOTED_PRINTABLE));
-
// -- Set contents
- part->getBody()->setContents(m_plainText);
+ part->getBody()->setContents(m_plainText,
+ mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN), m_charset,
+ encoding::decide(m_plainText, m_charset, encoding::USAGE_TEXT));
}
// HTML text
// -- Create a new part
ref <bodyPart> htmlPart = vmime::create <bodyPart>();
- // -- Set header fields
- htmlPart->getHeader()->ContentType()->setValue(mediaType(mediaTypes::TEXT, mediaTypes::TEXT_HTML));
- htmlPart->getHeader()->ContentType().dynamicCast <contentTypeField>()->setCharset(m_charset);
- htmlPart->getHeader()->ContentTransferEncoding()->setValue(encoding(encodingTypes::QUOTED_PRINTABLE));
-
// -- Set contents
- htmlPart->getBody()->setContents(m_text);
+ htmlPart->getBody()->setContents(m_text,
+ mediaType(mediaTypes::TEXT, mediaTypes::TEXT_HTML), m_charset,
+ encoding::decide(m_text, m_charset, encoding::USAGE_TEXT));
// Handle the case we have embedded objects
if (!m_objects.empty())