21#ifndef G_SMTP_SPAM_CLIENT_H
22#define G_SMTP_SPAM_CLIENT_H
49 G_EXCEPTION( Error ,
tx(
"spam client error") )
52 bool read_only ,
unsigned int connection_timeout ,
unsigned int response_timeout ) ;
55 void request(
const std::string & file_path ) ;
71 static void username(
const std::string & ) ;
75 void onConnect()
override ;
76 bool onReceive(
const char * , std::size_t , std::size_t , std::size_t ,
char )
override ;
77 void onSendComplete()
override ;
78 void onSecure(
const std::string & ,
const std::string & ,
const std::string & )
override ;
79 void onDelete(
const std::string & )
override ;
95 explicit Request(
Client & ) ;
96 void send(
const std::string & path ,
const std::string &
username ) ;
99 std::ifstream m_stream ;
101 std::vector<char> m_buffer ;
105 explicit Response(
bool read_only ) ;
107 Response(
const Response & ) = delete ;
108 Response( Response && ) = delete ;
109 Response & operator=(
const Response & ) = delete ;
110 Response & operator=( Response && ) = delete ;
111 void add(
const std::string & ,
const std::string & ) ;
112 bool ok(
const std::string & )
const ;
113 bool complete()
const ;
114 std::string result()
const ;
117 std::string m_path_tmp ;
118 std::string m_path_final ;
119 std::ofstream m_stream ;
120 std::size_t m_content_length {0U} ;
121 std::size_t m_size {0U} ;
122 std::string m_result ;
127 bool m_busy {
false} ;
130 Response m_response ;
131 static std::string m_username ;
A class for making an outgoing connection to a remote server, with support for socket-level protocols...
bool send(const std::string &data)
Sends data to the peer and starts the response timer (if configured).
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
A class that represents the remote target for out-going client connections.
A timer class template in which the timeout is delivered to the specified method.
A class which acts as an SMTP client, sending messages to a remote SMTP server.
A client class that interacts with a remote process using a protocol somewhat similar to the spamassa...
SpamClient(GNet::EventState, const GNet::Location &host_and_service, bool read_only, unsigned int connection_timeout, unsigned int response_timeout)
Constructor.
static void username(const std::string &)
Sets the username used in the network protocol.
void request(const std::string &file_path)
Starts sending a request that comprises a few http-like header lines followed by the contents of the ...
bool busy() const
Returns true after request() and before the subsequent event signal.
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().