Implements the client-side SMTP protocol. More...
#include <gclientprotocol.h>
Classes | |
struct | Config |
A structure containing GSmtp::ClientProtocol configuration parameters. More... | |
class | Sender |
An interface used by ClientProtocol to send protocol messages. More... | |
Public Types | |
typedef ClientProtocolReply | Reply |
Public Member Functions | |
ClientProtocol (Sender &sender, const GAuth::Secrets &secrets, Config config) | |
Constructor. More... | |
G::Signal2< std::string, int > & | doneSignal () |
Returns a signal that is raised once the protocol has finished with a given message. More... | |
G::Signal0 & | preprocessorSignal () |
Returns a signal that is raised when the protocol needs to do message preprocessing. More... | |
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. More... | |
void | sendDone () |
To be called when a blocked connection becomes unblocked. More... | |
void | preprocessorDone (bool ok, const std::string &reason) |
To be called when the Preprocessor 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 server. More... | |
Protected Member Functions | |
virtual void | onTimeout () |
Final override from GNet::AbstractTimer. More... | |
virtual void | onTimeoutException (std::exception &) |
Final override from GNet::AbstractTimer. More... | |
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 160 of file gclientprotocol.h.
Definition at line 163 of file gclientprotocol.h.
GSmtp::ClientProtocol::ClientProtocol | ( | Sender & | sender, |
const GAuth::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.
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 146 of file gclientprotocol.cpp.
References G_LOG, and G::Str::printable().
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 on success or a non-empty reason string. The second parameter is a reason code, typically the SMTP error value (but see preprocessorDone()).
Definition at line 611 of file gclientprotocol.cpp.
Referenced by GSmtp::Client::Client().
|
protectedvirtual |
Final override from GNet::AbstractTimer.
Implements GNet::AbstractTimer.
Definition at line 471 of file gclientprotocol.cpp.
References G_WARNING.
|
protectedvirtual |
Final override from GNet::AbstractTimer.
Implements GNet::AbstractTimer.
Definition at line 492 of file gclientprotocol.cpp.
void GSmtp::ClientProtocol::preprocessorDone | ( | bool | ok, |
const std::string & | reason | ||
) |
To be called when the Preprocessor interface has done its thing.
If not ok with an empty reason then the current message is just abandoned, resulting in a done signal with an empty reason string and a reason code of 1.
Definition at line 81 of file gclientprotocol.cpp.
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 616 of file gclientprotocol.cpp.
Referenced by GSmtp::Client::Client().
void GSmtp::ClientProtocol::secure | ( | ) |
To be called when the secure socket protocol has been successfully established.
Definition at line 100 of file gclientprotocol.cpp.
void GSmtp::ClientProtocol::sendDone | ( | ) |
To be called when a blocked connection becomes unblocked.
See ClientProtocol::Sender::protocolSend().
Definition at line 106 of file gclientprotocol.cpp.
References G_LOG.
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 60 of file gclientprotocol.cpp.
References G_DEBUG.