E-MailRelay

Classes | Public Types | Public Member Functions | List of all members
GSmtp::ProtocolMessage Class Referenceabstract

An interface used by the ServerProtocol class to assemble and process an incoming message. More...

`#include <gprotocolmessage.h>`

Inheritance diagram for GSmtp::ProtocolMessage:
[legend]

## Classes
struct | FromInfo
| Extra information from the SMTP MAIL-FROM command passed to GSmtp::ProtocolMessage::setFrom(). More...
struct | ProcessedInfo
| Parameters for GSmtp::ProtocolMessage::processedSignal() More...
struct | ToInfo
| Extra information passed to GSmtp::ProtocolMessage::addTo(). More...

## Public Types
using | ProcessedSignal = G::Slot::Signal< const ProcessedInfo & >
using | AddressStyle = GStore::MessageStore::AddressStyle

## Public Member Functions
virtual | ~ProtocolMessage ()=default
| Destructor.
virtual ProcessedSignal & | processedSignal ()=0
| Returns a signal which is raised once process() has completed.
virtual void | reset ()=0
| Clears the message state, terminates any asynchronous message processing and resets the object as if just constructed. More...
virtual void | clear ()=0
| Clears the message state and terminates any asynchronous message processing.
virtual GStore::MessageId | setFrom (const std::string &from_user, const FromInfo &)=0
| Sets the message envelope 'from' address etc. More...
virtual bool | addTo (const ToInfo &to)=0
| Adds an envelope 'to'. More...
virtual void | addReceived (const std::string &)=0
| Adds a 'received' line to the start of the content. More...
virtual GStore::NewMessage::Status | addContent (const char *, std::size_t)=0
| Adds content. More...
void | addContentLine (const std::string &)
| A convenience function that calls addContent() taking a string parameter and adding CR-LF. More...
virtual std::size_t | contentSize () const =0
| Returns the current content size. More...
virtual std::string | from () const =0
| Returns the setFrom() user string.
virtual FromInfo | fromInfo () const =0
| Returns the setFrom() extra info.
virtual std::string | bodyType () const =0
| Returns the setFrom() body type, fromInfo().body.
virtual void | process (const std::string &session_auth_id, const std::string &peer_socket_address, const std::string &peer_certificate)=0
| Starts asynchronous processing of the message. More...

## Detailed Description

An interface used by the ServerProtocol class to assemble and process an incoming message.

It implements the three 'buffers' mentioned in RFC-2821 (esp. section 4.1.1).

This interface serves to decouple the protocol class from the downstream message processing – hence the name. Derived classes implement different types of downstream processing. For store-and-forward behaviour the ProtocolMessageStore class uses GSmtp::MessageStore to store messages; for proxying behaviour the ProtocolMessageForward class uses GSmtp::Client to do immediate forwarding.

The interface is used by the protocol class in the following sequence:

- clear()
- setFrom()
- addTo() [1..n]
- addReceived() [0..n]
- addContent() [0..n]
- process() -> processedSignal() [async]

The process() method is asynchronous, but note that the completion signal may be emitted before the initiating call returns.

Definition at line 64 of file gprotocolmessage.h.

## Member Typedef Documentation

## ◆ AddressStyle

using GSmtp::ProtocolMessage::AddressStyle = GStore::MessageStore::AddressStyle

Definition at line 76 of file gprotocolmessage.h.

## ◆ ProcessedSignal

using GSmtp::ProtocolMessage::ProcessedSignal = G::Slot::Signal<const ProcessedInfo&>

Definition at line 75 of file gprotocolmessage.h.

## Member Function Documentation

## ◆ addContent()

virtual GStore::NewMessage::Status GSmtp::ProtocolMessage::addContent | ( | const char * | ,
|  | std::size_t |
| ) |  |
| pure virtual

Adds content.

The text should normally end in CR-LF. Returns an error enum, but error processing can be deferred until a final addContent(0) or until process().

Precondition: at least one successful addTo() call

## ◆ addContentLine()

void GSmtp::ProtocolMessage::addContentLine | ( | const std::string & | line | ) |

A convenience function that calls addContent() taking a string parameter and adding CR-LF.

Definition at line 26 of file gprotocolmessage.cpp.

## ◆ addReceived()

virtual void GSmtp::ProtocolMessage::addReceived | ( | const std::string & |  | ) |
| pure virtual

Adds a 'received' line to the start of the content.

Precondition: at least one successful addTo() call

## ◆ addTo()

virtual bool GSmtp::ProtocolMessage::addTo | ( | const ToInfo & | to | ) |
| pure virtual

Adds an envelope 'to'.

See also GSmtp::Verifier::verify(). Returns false if an invalid user.

Precondition: setFrom() called since clear() or process().

## ◆ contentSize()

virtual std::size_t GSmtp::ProtocolMessage::contentSize | ( |  | ) | const
| pure virtual

Returns the current content size.

Returns the maximum std::size_t value on overflow.

## ◆ process()

virtual void GSmtp::ProtocolMessage::process | ( | const std::string & | session_auth_id,
|  | const std::string & | peer_socket_address,
|  | const std::string & | peer_certificate
| ) |  |
| pure virtual

Starts asynchronous processing of the message.

Once processing is complete the message state is cleared and the processedSignal() is raised. All errors are also signalled via the processedSignal(). The processedSignal() may be emitted before process() returns.

The session-auth-id parameter is used to propagate authentication information from the SMTP AUTH command into individual messages. It is the empty string for unauthenticated clients. See also GAuth::SaslServer::id().

## ◆ reset()

virtual void GSmtp::ProtocolMessage::reset | ( |  | ) |
| pure virtual

Clears the message state, terminates any asynchronous message processing and resets the object as if just constructed.

(In practice this is clear() plus the disconnection of any forwarding client).

## ◆ setFrom()

virtual GStore::MessageId GSmtp::ProtocolMessage::setFrom | ( | const std::string & | from_user,
|  | const FromInfo & |
| ) |  |
| pure virtual

Sets the message envelope 'from' address etc.

Returns a unique message id.

The documentation for this class was generated from the following files:

- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gsmtp/gprotocolmessage.h
- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gsmtp/gprotocolmessage.cpp