E-MailRelay

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:

## Public Types
using | DoneSignal = G::Slot::Signal< bool, const MessageId &, const std::string &, const std::string & >

## Public Member Functions
virtual | ~ProtocolMessage ()=default
| Destructor.
virtual DoneSignal & | doneSignal ()=0
| Returns a signal which is raised once process() has completed. More...
virtual void | reset ()=0
| Resets the object state as if just constructed. More...
virtual void | clear ()=0
| Clears the message state and terminates any asynchronous message processing. More...
virtual MessageId | setFrom (const std::string &from_user, const std::string &from_auth)=0
| Sets the message envelope 'from'. More...
virtual bool | addTo (VerifierStatus to_status)=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 bool | addText (const char *, std::size_t)=0
| Adds text. More...
bool | addTextLine (const std::string &)
| A convenience function that calls addText() taking a string parameter and adding CR-LF. More...
virtual std::string | from () const =0
| Returns the setFrom() string. More...
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]
- addText() [0..n]
- process() -> doneSignal() [async]

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

Definition at line 63 of file gprotocolmessage.h.

## Member Typedef Documentation

## ◆ DoneSignal

using GSmtp::ProtocolMessage::DoneSignal = G::Slot::Signal<bool,const MessageId&,const std::string&,const std::string&>

Definition at line 66 of file gprotocolmessage.h.

## Member Function Documentation

## ◆ 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

Implemented in GSmtp::ProtocolMessageStore.

## ◆ addText()

virtual bool GSmtp::ProtocolMessage::addText | ( | const char * | ,
|  | std::size_t |
| ) |  |
| pure virtual

Adds text.

The text should normally end in CR-LF. Returns false on error, typically because a size limit is reached.

Precondition: at least one successful addTo() call

Implemented in GSmtp::ProtocolMessageStore.

## ◆ addTextLine()

bool GSmtp::ProtocolMessage::addTextLine | ( | const std::string & | line | ) |

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

Definition at line 24 of file gprotocolmessage.cpp.

## ◆ addTo()

virtual bool GSmtp::ProtocolMessage::addTo | ( | VerifierStatus | to_status | ) |
| pure virtual

Adds an envelope 'to'.

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

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

Implemented in GSmtp::ProtocolMessageStore.

## ◆ clear()

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

Clears the message state and terminates any asynchronous message processing.

Implemented in GSmtp::ProtocolMessageStore.

## ◆ doneSignal()

virtual DoneSignal & GSmtp::ProtocolMessage::doneSignal | ( |  | ) |
| pure virtual

Returns a signal which is raised once process() has completed.

The signal parameters are 'success', 'id', 'short-response' and 'full-reason'. As a special case, if success is true and id is invalid then the message processing was either abandoned or it only had local-mailbox recipients.

Implemented in GSmtp::ProtocolMessageStore.

## ◆ from()

virtual std::string GSmtp::ProtocolMessage::from | ( |  | ) | const
| pure virtual

Returns the setFrom() string.

Implemented in GSmtp::ProtocolMessageStore.

## ◆ 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 doneSignal() is raised. The signal may be raised 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().

Implemented in GSmtp::ProtocolMessageStore.

## ◆ reset()

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

Resets the object state as if just constructed.

Implemented in GSmtp::ProtocolMessageStore.

## ◆ setFrom()

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

Sets the message envelope 'from'.

Implemented in GSmtp::ProtocolMessageStore.

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

- /usr/src/slapt-src-x86_64/network/emailrelay/emailrelay-2.3/src/gsmtp/gprotocolmessage.h
- /usr/src/slapt-src-x86_64/network/emailrelay/emailrelay-2.3/src/gsmtp/gprotocolmessage.cpp