GSmtp::ClientProtocol Class Reference

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

#include <gclientprotocol.h>

Inheritance diagram for GSmtp::ClientProtocol:

GNet::AbstractTimer

List of all members.

Public Types

typedef ClientProtocolReply Reply

Public Member Functions

 ClientProtocol (Sender &sender, const Secrets &secrets, Config config)
 Constructor.
G::Signal2< std::string, int > & doneSignal ()
 Returns a signal that is raised once the protocol has finished with a given message.
G::Signal0preprocessorSignal ()
 Returns a signal that is raised when the protocol needs to do message preprocessing.
void start (const std::string &from, const G::Strings &to, bool eight_bit, std::string authentication, std::string server_name, std::auto_ptr< std::istream > content)
 Starts transmission of the given message.
void sendDone ()
 To be called when a blocked connection becomes unblocked.
void preprocessorDone (const std::string &reason)
 To be called when the Preprocessor interface has done its thing.
void secure ()
 To be called when the secure socket protocol has been successfully established.
bool apply (const std::string &rx)
 Called on receipt of a line of text from the server.

Protected Member Functions

virtual void onTimeout ()
 Final override from GNet::AbstractTimer.
virtual void onTimeoutException (std::exception &)
 Final override from GNet::AbstractTimer.

Classes

struct  Config
 A structure containing GSmtp::ClientProtocol configuration parameters. More...
class  Sender
 An interface used by ClientProtocol to send protocol messages. More...


Detailed Description

Implements the client-side SMTP protocol.

Note that fatal, non-message-specific errors result in an exception being thrown, possibly out of an event-loop callback. In practice these will result in the connection being dropped immediately without failing the message.

Definition at line 159 of file gclientprotocol.h.


Member Typedef Documentation

Definition at line 162 of file gclientprotocol.h.


Constructor & Destructor Documentation

GSmtp::ClientProtocol::ClientProtocol ( Sender sender,
const Secrets secrets,
Config  config 
)

Constructor.

The 'sender' and 'secrets' references are kept.

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

The 'thishost_name' parameter is used in the SMTP EHLO request.

If the 'eight-bit-strict' flag is true then an eight-bit message being sent to a seven-bit server will be failed.

Definition at line 37 of file gclientprotocol.cpp.


Member Function Documentation

G::Signal2< std::string, int > & GSmtp::ClientProtocol::doneSignal (  ) 

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

The first signal parameter is the empty string, or a non-empty reason on error.

Definition at line 551 of file gclientprotocol.cpp.

Referenced by GSmtp::Client::Client(), and GSmtp::Client::~Client().

G::Signal0 & GSmtp::ClientProtocol::preprocessorSignal (  ) 

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

The callee must call preprocessorDone().

Definition at line 556 of file gclientprotocol.cpp.

Referenced by GSmtp::Client::Client(), and GSmtp::Client::~Client().

void GSmtp::ClientProtocol::start ( const std::string &  from,
const G::Strings to,
bool  eight_bit,
std::string  authentication,
std::string  server_name,
std::auto_ptr< std::istream >  content 
)

Starts transmission of the given message.

The doneSignal() is used to indicate that the message has been processed.

The 'server_name' parameter is passed to the SASL authentication code. It should be a fully-qualified domain name where possible.

Definition at line 58 of file gclientprotocol.cpp.

References G_DEBUG, and G::Signal2< P1, P2 >::reset().

void GSmtp::ClientProtocol::sendDone (  ) 

To be called when a blocked connection becomes unblocked.

See ClientProtocol::Sender::protocolSend().

Definition at line 91 of file gclientprotocol.cpp.

References G_LOG.

Referenced by GSmtp::Client::onSendComplete().

void GSmtp::ClientProtocol::preprocessorDone ( const std::string &  reason  ) 

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

The reason string should be empty on success.

Definition at line 78 of file gclientprotocol.cpp.

References GSmtp::ClientProtocolReply::error(), GSmtp::ClientProtocolReply::Internal_2xx, and GSmtp::ClientProtocolReply::ok().

void GSmtp::ClientProtocol::secure (  ) 

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

Definition at line 85 of file gclientprotocol.cpp.

References GSmtp::ClientProtocolReply::Internal_2yy, and GSmtp::ClientProtocolReply::ok().

Referenced by GSmtp::Client::onSecure().

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

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

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

Definition at line 131 of file gclientprotocol.cpp.

References G_LOG, and G::Str::printable().

Referenced by GSmtp::Client::onReceive().

void GSmtp::ClientProtocol::onTimeout (  )  [protected, virtual]

Final override from GNet::AbstractTimer.

Implements GNet::AbstractTimer.

Definition at line 429 of file gclientprotocol.cpp.

References G_WARNING.

void GSmtp::ClientProtocol::onTimeoutException ( std::exception &  e  )  [protected, virtual]

Final override from GNet::AbstractTimer.

Implements GNet::AbstractTimer.

Definition at line 450 of file gclientprotocol.cpp.


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

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5