34 std::auto_ptr<ProtocolMessage> pm ,
36 const GAuth::Secrets & client_secrets ,
const std::string & server ,
37 unsigned int connection_timeout ) :
39 m_client_resolver_info(server) ,
40 m_client_config(client_config) ,
41 m_client_secrets(client_secrets) ,
45 m_connection_timeout(connection_timeout) ,
55 m_pm->doneSignal().disconnect() ;
56 m_client.doneSignal().disconnect() ;
57 if( m_client.get() != NULL )
58 m_client->messageDoneSignal().disconnect() ;
63 return m_pm->doneSignal() ;
68 return m_done_signal ;
84 return m_pm->setFrom( from ) ;
89 return m_pm->addTo( to , to_status ) ;
94 m_pm->addReceived( line ) ;
99 return m_pm->addText( line ) ;
104 return m_pm->from() ;
108 const std::string & peer_socket_name ,
const std::string & peer_certificate )
110 m_done_signal.reset() ;
111 m_pm->process( auth_id , peer_socket_address , peer_socket_name , peer_certificate ) ;
116 G_DEBUG(
"ProtocolMessageForward::processDone: " << (success?1:0) <<
", " <<
id <<
", \"" << reason <<
"\"" ) ;
117 if( success &&
id != 0UL )
122 bool nothing_to_do = false ;
123 success = forward(
id , nothing_to_do , &reason ) ;
124 if( !success || nothing_to_do )
127 m_done_signal.emit( success ,
id , reason ) ;
133 m_done_signal.emit( success ,
id , reason ) ;
137 bool GSmtp::ProtocolMessageForward::forward(
unsigned long id ,
bool & nothing_to_do , std::string * reason_p )
141 nothing_to_do = false ;
142 *reason_p = std::string() ;
143 G_DEBUG(
"GSmtp::ProtocolMessageForward::forward: forwarding message " <<
id ) ;
145 std::auto_ptr<StoredMessage> message = m_store.get(
id ) ;
147 if( message->remoteRecipientCount() == 0U )
150 nothing_to_do = true ;
155 if( m_client.get() == NULL )
157 m_client.reset(
new Client(m_client_resolver_info,m_client_secrets,m_client_config) ) ;
158 m_client->messageDoneSignal().connect(
G::slot(*
this,&GSmtp::ProtocolMessageForward::messageDone) ) ;
160 m_client->sendMessage( message ) ;
164 catch( std::exception & e )
166 if( reason_p != NULL )
168 G_DEBUG(
"GSmtp::ProtocolMessageForward::forward: exception" ) ;
169 *reason_p = e.what() ;
175 void GSmtp::ProtocolMessageForward::messageDone( std::string reason )
177 G_DEBUG(
"GSmtp::ProtocolMessageForward::clientDone: \"" << reason <<
"\"" ) ;
178 const bool ok = reason.empty() ;
179 m_done_signal.emit( ok , m_id , reason ) ;
182 void GSmtp::ProtocolMessageForward::clientDone( std::string reason ,
bool )
184 G_DEBUG(
"GSmtp::ProtocolMessageForward::clientDone: \"" << reason <<
"\"" ) ;
185 const bool ok = reason.empty() ;
186 m_done_signal.emit( ok , m_id , reason ) ;
G::Signal3< bool, unsigned long, std::string > & storageDoneSignal()
Returns the signal which is used to signal that the storage is complete.
virtual bool addText(const std::string &)
Final override from GSmtp::ProtocolMessage.
void processDone(bool, unsigned long, std::string)
Called by derived classes that have intercepted the storageDoneSignal() when their own post-storage p...
virtual void clear()
Final override from GSmtp::ProtocolMessage.
virtual void addReceived(const std::string &)
Final override from GSmtp::ProtocolMessage.
Slot0 slot(T &object, void(T::*fn)())
Part of the slot/signal system.
virtual bool setFrom(const std::string &from_user)
Final override from GSmtp::ProtocolMessage.
A class which allows SMTP messages (envelope+content) to be stored and retrieved. ...
A simple interface to a store of secrets as used in authentication.
G::Signal2< std::string, bool > & doneSignal()
Returns a signal which indicates that client processing is complete and the client instance has delet...
ProtocolMessageForward(MessageStore &store, std::auto_ptr< ProtocolMessage > pm, const GSmtp::Client::Config &client_config, const GAuth::Secrets &client_secrets, const std::string &server_address, unsigned int connection_timeout)
Constructor.
A structure containing GSmtp::Client configuration parameters.
A structure returned by GSmtp::Verifier to describe the status of a rcpt-to recipient.
virtual G::Signal3< bool, unsigned long, std::string > & doneSignal()
Final override from GSmtp::ProtocolMessage.
virtual void process(const std::string &auth_id, const std::string &peer_socket_address, const std::string &peer_socket_name, const std::string &peer_certificate)
Final override from GSmtp::ProtocolMessage.
void connect(Slot2< P1, P2 > slot)
virtual std::string from() const
Final override from GSmtp::ProtocolMessage.
virtual bool addTo(const std::string &to_user, VerifierStatus to_status)
Final override from GSmtp::ProtocolMessage.
virtual void reset()
Final override from GSmtp::ProtocolMessage.
virtual ~ProtocolMessageForward()
Destructor.