32 m_processor(processor)
34 m_processor->doneSignal().connect(
G::slot(*
this,&ProtocolMessageStore::preprocessorDone) ) ;
39 m_processor->doneSignal().disconnect() ;
44 G_DEBUG(
"GSmtp::ProtocolMessageStore::reset" ) ;
50 G_DEBUG(
"GSmtp::ProtocolMessageStore::clear" ) ;
53 m_processor->abort() ;
58 G_DEBUG(
"GSmtp::ProtocolMessageStore::setFrom: " << from ) ;
60 if( from.length() == 0U )
61 G_WARNING(
"GSmtp::ProtocolMessageStore: empty MAIL-FROM return path" ) ;
66 std::auto_ptr<NewMessage> new_message( m_store.newMessage(from) ) ;
67 m_msg <<= new_message.release() ;
75 G_DEBUG(
"GSmtp::ProtocolMessageStore::addTo: " << to ) ;
78 if( to.length() > 0U && m_msg.get() != NULL )
82 G_WARNING(
"GSmtp::ProtocolMessage: rejecting recipient \"" << to <<
"\": "
83 << to_status.
reason <<
": " << to_status.
help );
100 G_DEBUG(
"GSmtp::ProtocolMessageStore::addReceived" ) ;
101 addText( received_line ) ;
107 if( m_msg.get() == NULL )
109 return m_msg->addText( line ) ;
114 return m_msg.get() ? m_from : std::string() ;
118 const std::string & peer_socket_name ,
const std::string & peer_certificate )
122 G_DEBUG(
"ProtocolMessageStore::process: \"" << auth_id <<
"\", \"" << peer_socket_address <<
"\"" ) ;
124 if( m_msg.get() == NULL )
128 std::string message_location = m_msg->prepare( auth_id , peer_socket_address , peer_socket_name , peer_certificate ) ;
131 m_processor->start( message_location ) ;
133 catch( std::exception & e )
135 G_DEBUG(
"GSmtp::ProtocolMessage::process: exception: " << e.what() ) ;
137 m_done_signal.emit(
false , 0UL , e.what() ) ;
141 void GSmtp::ProtocolMessageStore::preprocessorDone(
bool ok )
145 G_DEBUG(
"ProtocolMessageStore::preprocessorDone: " << (ok?1:0) ) ;
147 if( m_msg.get() == NULL )
150 unsigned long id = 0UL ;
157 else if( m_processor->cancelled() )
159 try { m_msg->commit() ; }
catch( std::exception & ) {}
163 reason = m_processor->text() ;
164 reason = reason.empty() ?
"error" : reason ;
165 G_LOG_S(
"GSmtp::ProtocolMessageStore::preprocessorDone: error storing message: " << reason ) ;
167 if( m_processor->repoll() )
172 G_DEBUG(
"ProtocolMessageStore::preprocessorDone: emiting done signal" ) ;
173 m_done_signal.emit( reason.empty() , id , reason ) ;
175 catch( std::exception & e )
177 G_DEBUG(
"GSmtp::ProtocolMessage::preprocessorDone: exception: " << e.what() ) ;
179 m_done_signal.emit(
false , 0UL , e.what() ) ;
185 return m_done_signal ;
virtual void addReceived(const std::string &)
Final override from GSmtp::ProtocolMessage.
virtual void clear()
Final override from GSmtp::ProtocolMessage.
virtual bool addText(const std::string &)
Final override from GSmtp::ProtocolMessage.
Slot0 slot(T &object, void(T::*fn)())
Part of the slot/signal system.
virtual std::string from() const
Final override from GSmtp::ProtocolMessage.
virtual bool setFrom(const std::string &from_user)
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.
ProtocolMessageStore(MessageStore &store, std::auto_ptr< Processor >)
Constructor.
A class which allows SMTP messages (envelope+content) to be stored and retrieved. ...
virtual void reset()
Final override from GSmtp::ProtocolMessage.
virtual ~ProtocolMessageStore()
Destructor.
virtual G::Signal3< bool, unsigned long, std::string > & doneSignal()
Final override from GSmtp::ProtocolMessage.
A structure returned by GSmtp::Verifier to describe the status of a rcpt-to recipient.
A general-purpose exception class derived from std::exception and containing a std::string.
virtual bool addTo(const std::string &to_user, VerifierStatus to_status)
Final override from GSmtp::ProtocolMessage.