text body::getActualEpilogText(const generationContext& ctx) const { const string& epilogText = m_epilogText.empty() ? (isRootPart() ? ctx.getEpilogText() : NULL_STRING ) : m_epilogText; if (epilogText.empty()) return text(); else return text(epilogText, vmime::charset("us-ascii")); }
void body::generateImpl(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type /* curLinePos */, string::size_type* newLinePos) const { // MIME-Multipart if (getPartCount() != 0) { string boundary; if (m_header.acquire() == NULL) { boundary = generateRandomBoundaryString(); } else { try { ref <const contentTypeField> ctf = m_header.acquire()->findField(fields::CONTENT_TYPE) .dynamicCast <const contentTypeField>(); boundary = ctf->getBoundary(); } catch (exceptions::no_such_field&) { // Warning: no content-type and no boundary string specified! boundary = generateRandomBoundaryString(); } catch (exceptions::no_such_parameter&) { // Warning: no boundary string specified! boundary = generateRandomBoundaryString(); } } const string& prologText = m_prologText.empty() ? (isRootPart() ? options::getInstance()->multipart.getPrologText() : NULL_STRING ) : m_prologText; const string& epilogText = m_epilogText.empty() ? (isRootPart() ? options::getInstance()->multipart.getEpilogText() : NULL_STRING ) : m_epilogText; if (!prologText.empty()) { text prolog(prologText, vmime::charset("us-ascii")); prolog.encodeAndFold(os, maxLineLength, 0, NULL, text::FORCE_NO_ENCODING | text::NO_NEW_LINE_SEQUENCE); os << CRLF; } os << "--" << boundary; for (int p = 0 ; p < getPartCount() ; ++p) { os << CRLF; getPartAt(p)->generate(os, maxLineLength, 0); os << CRLF << "--" << boundary; } os << "--" << CRLF; if (!epilogText.empty()) { text epilog(epilogText, vmime::charset("us-ascii")); epilog.encodeAndFold(os, maxLineLength, 0, NULL, text::FORCE_NO_ENCODING | text::NO_NEW_LINE_SEQUENCE); os << CRLF; } if (newLinePos) *newLinePos = 0; } // Simple body else { // Generate the contents m_contents->generate(os, getEncoding(), maxLineLength); } }