Exemplo n.º 1
0
void component::parse	(const parsingContext& ctx,
												shared_ptr <utility::inputStream> inputStream,
												size_t position,
												size_t end,
												size_t* newPosition)
{
	m_parsedOffset = m_parsedLength = 0;

	shared_ptr <utility::seekableInputStream> seekableStream =
		dynamicCast <utility::seekableInputStream>(inputStream);

	if (seekableStream == NULL || end == 0)
	{
		// Read the whole stream into a buffer
		std::ostringstream oss;
		utility::outputStreamAdapter ossAdapter(oss);

		utility::bufferedStreamCopyRange(*inputStream, ossAdapter, position, end - position);

		const string &buffer = oss.str();
		parseImpl(ctx, buffer, 0, buffer.length(), NULL);
	}
	else
	{
		shared_ptr <utility::parserInputStreamAdapter> parser =
			make_shared <utility::parserInputStreamAdapter>(seekableStream);

		parseImpl(ctx, parser, position, end, newPosition);
	}
}
void component::parse
	(const parsingContext& ctx,
	 ref <utility::inputStream> inputStream, const utility::stream::size_type position,
	 const utility::stream::size_type end, utility::stream::size_type* newPosition)
{
	m_parsedOffset = m_parsedLength = 0;

	ref <utility::seekableInputStream> seekableStream =
		inputStream.dynamicCast <utility::seekableInputStream>();

	if (seekableStream == NULL || end == 0)
	{
		// Read the whole stream into a buffer
		std::ostringstream oss;
		utility::outputStreamAdapter ossAdapter(oss);

		utility::bufferedStreamCopyRange(*inputStream, ossAdapter, position, end - position);

		const string buffer = oss.str();
		parseImpl(ctx, buffer, 0, buffer.length(), NULL);
	}
	else
	{
		ref <utility::parserInputStreamAdapter> parser =
			vmime::create <utility::parserInputStreamAdapter>(seekableStream);

		parseImpl(ctx, parser, position, end, newPosition);
	}
}
Exemplo n.º 3
0
void transport::send
	(shared_ptr <vmime::message> msg, const mailbox& expeditor, const mailboxList& recipients,
	 utility::progressListener* progress, const mailbox& sender)
{
	// Generate the message, "stream" it and delegate the sending
	// to the generic send() function.
	std::ostringstream oss;
	utility::outputStreamAdapter ossAdapter(oss);

	msg->generate(ossAdapter);

	const string& str(oss.str());

	utility::inputStreamStringAdapter isAdapter(str);

	send(expeditor, recipients, isAdapter, str.length(), progress, sender);
}
Exemplo n.º 4
0
void transport::send(ref <vmime::message> msg, utility::progressListener* progress)
{
	// Extract expeditor
	mailbox expeditor;

	try
	{
		const mailbox& mbox = *msg->getHeader()->findField(fields::FROM)->
			getValue().dynamicCast <const mailbox>();

		expeditor = mbox;
	}
	catch (exceptions::no_such_field&)
	{
		throw exceptions::no_expeditor();
	}

	// Extract recipients
	mailboxList recipients;

	try
	{
		const addressList& to = *msg->getHeader()->findField(fields::TO)->
			getValue().dynamicCast <const addressList>();

		extractMailboxes(recipients, to);
	}
	catch (exceptions::no_such_field&) { }

	try
	{
		const addressList& cc = *msg->getHeader()->findField(fields::CC)->
			getValue().dynamicCast <const addressList>();

		extractMailboxes(recipients, cc);
	}
	catch (exceptions::no_such_field&) { }

	try
	{
		const addressList& bcc = *msg->getHeader()->findField(fields::BCC)->
			getValue().dynamicCast <const addressList>();

		extractMailboxes(recipients, bcc);
	}
	catch (exceptions::no_such_field&) { }

	// Remove BCC headers from the message we're about to send, as required by the RFC.
	// Some SMTP server automatically strip this header (Postfix, qmail), and others
	// have an option for this (Exim).
	try
	{
		ref <headerField> bcc = msg->getHeader()->findField(fields::BCC);
		msg->getHeader()->removeField(bcc);
	}
	catch (exceptions::no_such_field&) { }

	// Generate the message, "stream" it and delegate the sending
	// to the generic send() function.
	std::ostringstream oss;
	utility::outputStreamAdapter ossAdapter(oss);

	msg->generate(ossAdapter);

	const string& str(oss.str());

	utility::inputStreamStringAdapter isAdapter(str);

	send(expeditor, recipients, isAdapter, str.length(), progress);
}