E-MailRelay
Classes | Public Member Functions | List of all members
GSmtp::ClientProtocol Class Reference

Implements the client-side SMTP protocol. More...

#include <gsmtpclientprotocol.h>

+ Inheritance diagram for GSmtp::ClientProtocol:
+ Collaboration diagram for GSmtp::ClientProtocol:

Classes

struct  Config
 A structure containing GSmtp::ClientProtocol configuration parameters. More...
 
struct  DoneInfo
 Parameters for GSmtp::ClientProtocol::doneSignal() More...
 
class  Sender
 An interface used by ClientProtocol to send protocol messages. More...
 

Public Member Functions

 ClientProtocol (GNet::EventState, Sender &sender, const GAuth::SaslClientSecrets &secrets, const std::string &sasl_client_config, const Config &config, bool in_secure_tunnel)
 Constructor. More...
 
G::Slot::Signal< const DoneInfo & > & doneSignal () noexcept
 Returns a signal that is raised once the protocol has finished with a given message. More...
 
G::Slot::SignalfilterSignal () noexcept
 Returns a signal that is raised when the protocol needs to do message filtering. More...
 
void reconfigure (const std::string &ehlo)
 Updates a configuration parameter after construction. More...
 
void start (std::weak_ptr< GStore::StoredMessage >)
 Starts transmission of the given message. More...
 
void finish ()
 Called after the last message has been sent. More...
 
void sendComplete ()
 To be called when a blocked connection becomes unblocked. More...
 
void filterDone (Filter::Result result, const std::string &response, const std::string &reason)
 To be called when the Filter interface has done its thing. More...
 
void secure ()
 To be called when the secure socket protocol has been successfully established. More...
 
bool apply (const std::string &rx)
 Called on receipt of a line of text from the remote server. More...
 
 ClientProtocol (const ClientProtocol &)=delete
 
 ClientProtocol (ClientProtocol &&)=delete
 
ClientProtocoloperator= (const ClientProtocol &)=delete
 
ClientProtocoloperator= (ClientProtocol &&)=delete
 

Detailed Description

Implements the client-side SMTP protocol.

Definition at line 49 of file gsmtpclientprotocol.h.

Constructor & Destructor Documentation

◆ ClientProtocol()

GSmtp::ClientProtocol::ClientProtocol ( GNet::EventState  es,
Sender sender,
const GAuth::SaslClientSecrets secrets,
const std::string &  sasl_client_config,
const Config config,
bool  in_secure_tunnel 
)

Constructor.

The Sender interface is used to send protocol messages to the peer. The references are kept.

Definition at line 64 of file gsmtpclientprotocol.cpp.

Member Function Documentation

◆ apply()

bool GSmtp::ClientProtocol::apply ( const std::string &  rx)

Called on receipt of a line of text from the remote server.

Returns true if the protocol is done and the doneSignal() has been emitted.

Definition at line 139 of file gsmtpclientprotocol.cpp.

◆ doneSignal()

G::Slot::Signal< const GSmtp::ClientProtocol::DoneInfo & > & GSmtp::ClientProtocol::doneSignal ( )
noexcept

Returns a signal that is raised once the protocol has finished with a given message.

If 'must_accept_all_recipients' is false and the message was successfully sent to only some of the recipients then this is signalled as an error with a non-empty reject list.

Definition at line 129 of file gsmtpclientprotocol.cpp.

◆ filterDone()

void GSmtp::ClientProtocol::filterDone ( Filter::Result  result,
const std::string &  response,
const std::string &  reason 
)

To be called when the Filter interface has done its thing.

If the result is Result::ok then the message processing continues; otherwise the message processing fails with a doneSignal() code of -1 for Result::abandon or -2 for Result::fail.

Definition at line 567 of file gsmtpclientprotocol.cpp.

◆ filterSignal()

G::Slot::Signal & GSmtp::ClientProtocol::filterSignal ( )
noexcept

Returns a signal that is raised when the protocol needs to do message filtering.

The signal callee must call filterDone() when the filter has finished.

Definition at line 134 of file gsmtpclientprotocol.cpp.

◆ finish()

void GSmtp::ClientProtocol::finish ( )

Called after the last message has been sent.

Sends a quit command and shuts down the socket.

Definition at line 101 of file gsmtpclientprotocol.cpp.

◆ reconfigure()

void GSmtp::ClientProtocol::reconfigure ( const std::string &  ehlo)

Updates a configuration parameter after construction.

Definition at line 79 of file gsmtpclientprotocol.cpp.

◆ secure()

void GSmtp::ClientProtocol::secure ( )

To be called when the secure socket protocol has been successfully established.

Definition at line 108 of file gsmtpclientprotocol.cpp.

◆ sendComplete()

void GSmtp::ClientProtocol::sendComplete ( )

To be called when a blocked connection becomes unblocked.

See ClientProtocol::Sender::protocolSend().

Definition at line 113 of file gsmtpclientprotocol.cpp.

◆ start()

void GSmtp::ClientProtocol::start ( std::weak_ptr< GStore::StoredMessage message_in)

Starts transmission of the given message.

The doneSignal() is used to indicate that the message has been processed and the shared object should remain valid until then.

Precondition: GStore::StoredMessage::toCount() != 0

Definition at line 85 of file gsmtpclientprotocol.cpp.


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