E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gprotocolmessageforward.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2018 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 ///
18 /// \file gprotocolmessageforward.h
19 ///
20
21 #ifndef G_SMTP_PROTOCOL_MESSAGE_FORWARD_H
22 #define G_SMTP_PROTOCOL_MESSAGE_FORWARD_H
23
24 #include "gdef.h"
25 #include "gsmtp.h"
26 #include "glocation.h"
27 #include "gclientptr.h"
28 #include "gprotocolmessage.h"
29 #include "gprotocolmessagestore.h"
30 #include "gsecrets.h"
31 #include "gsmtpclient.h"
32 #include "gmessagestore.h"
33 #include "gnewmessage.h"
34 #include "gverifierstatus.h"
35 #include <string>
36 #include <memory>
37
38 namespace GSmtp
39 {
40 class ProtocolMessageForward ;
41 }
42
43 /// \class GSmtp::ProtocolMessageForward
44 /// A concrete implementation of the ProtocolMessage interface that stores
45 /// incoming messages in the message store and then immediately forwards
46 /// them on to the downstream server.
47 ///
48 /// The implementation delegates to an instance of the ProtocolMessageStore
49 /// class (ie. its sibling class) to do the storage, and to an instance
50 /// of the GSmtp::Client class to do the forwarding.
51 ///
52 /// \see GSmtp::ProtocolMessageStore
53 ///
54 class GSmtp::ProtocolMessageForward : public ProtocolMessage
55 {
56 public:
57 ProtocolMessageForward( MessageStore & store ,
58 unique_ptr<ProtocolMessage> pm ,
59 const GSmtp::Client::Config & client_config ,
60 const GAuth::Secrets & client_secrets ,
61 const std::string & remote_server_address ) ;
62 ///< Constructor. The 'store' and 'client-secrets' references
63 ///< are kept.
64
65 virtual ~ProtocolMessageForward() ;
66 ///< Destructor.
67
68 virtual G::Slot::Signal4<bool,unsigned long,std::string,std::string> & doneSignal() override ;
69 ///< Override from GSmtp::ProtocolMessage.
70
71 virtual void reset() override ;
72 ///< Override from GSmtp::ProtocolMessage.
73
74 virtual void clear() override ;
75 ///< Override from GSmtp::ProtocolMessage.
76
77 virtual bool setFrom( const std::string & from_user , const std::string & ) override ;
78 ///< Override from GSmtp::ProtocolMessage.
79
80 virtual bool addTo( const std::string & to_user , VerifierStatus to_status ) override ;
81 ///< Override from GSmtp::ProtocolMessage.
82
83 virtual void addReceived( const std::string & ) override ;
84 ///< Override from GSmtp::ProtocolMessage.
85
86 virtual bool addText( const char * , size_t ) override ;
87 ///< Override from GSmtp::ProtocolMessage.
88
89 virtual std::string from() const override ;
90 ///< Override from GSmtp::ProtocolMessage.
91
92 virtual void process( const std::string & auth_id, const std::string & peer_socket_address ,
93 const std::string & peer_certificate ) override ;
94 ///< Override from GSmtp::ProtocolMessage.
95
96 protected:
97 G::Slot::Signal4<bool,unsigned long,std::string,std::string> & storageDoneSignal() ;
98 ///< Returns the signal which is used to signal that the storage
99 ///< is complete. Derived classes can use this to
100 ///< intercept the storage-done signal emit()ed by
101 ///< the ProtocolMessageStore object.
102
103 void processDone( bool , unsigned long , std::string , std::string ) ;
104 ///< Called by derived classes that have intercepted
105 ///< the storageDoneSignal() when their own post-storage
106 ///< processing is complete.
107
108 private:
109 void operator=( const ProtocolMessageForward & ) ; // not implemented
110 void clientDone( std::string ) ; // GNet::Client::doneSignal()
111 void messageDone( std::string ) ; // GSmtp::Client::messageDoneSignal()
112 std::string forward( unsigned long , bool & ) ;
113
114 private:
115 MessageStore & m_store ;
116 GNet::Location m_client_location ;
117 Client::Config m_client_config ;
118 const GAuth::Secrets & m_client_secrets ;
119 unique_ptr<ProtocolMessage> m_pm ;
120 GNet::ClientPtr<GSmtp::Client> m_client ;
121 unsigned long m_id ;
122 G::Slot::Signal4<bool,unsigned long,std::string,std::string> m_done_signal ;
123 } ;
124
125 #endif
gprotocolmessagestore.h
GSmtp::ProtocolMessageForward::ProtocolMessageForward
ProtocolMessageForward(MessageStore &store, unique_ptr< ProtocolMessage > pm, const GSmtp::Client::Config &client_config, const GAuth::Secrets &client_secrets, const std::string &remote_server_address)
Constructor.
Definition: gprotocolmessageforward.cpp:32
GSmtp
SMTP and message-store classes.
Definition: gadminserver.h:39
GSmtp::ProtocolMessageForward
A concrete implementation of the ProtocolMessage interface that stores incoming messages in the messa...
Definition: gprotocolmessageforward.h:54
G::Slot::Signal4< bool, unsigned long, std::string, std::string >
GSmtp::ProtocolMessageForward::storageDoneSignal
G::Slot::Signal4< bool, unsigned long, std::string, std::string > & storageDoneSignal()
Returns the signal which is used to signal that the storage is complete.
Definition: gprotocolmessageforward.cpp:57
gverifierstatus.h
gprotocolmessage.h
glocation.h
GSmtp::ProtocolMessageForward::processDone
void processDone(bool, unsigned long, std::string, std::string)
Called by derived classes that have intercepted the storageDoneSignal() when their own post-storage p...
Definition: gprotocolmessageforward.cpp:110
GNet::Location
A class that holds a host/service name pair and the preferred address family (if any), and also the results of a name-to-address lookup, ie.
Definition: glocation.h:50
GSmtp::ProtocolMessageForward::addTo
virtual bool addTo(const std::string &to_user, VerifierStatus to_status) override
Override from GSmtp::ProtocolMessage.
Definition: gprotocolmessageforward.cpp:83
gsecrets.h
GSmtp::MessageStore
A class which allows SMTP messages to be stored and retrieved.
Definition: gmessagestore.h:43
GAuth::Secrets
A simple interface for a store of secrets used in authentication.
Definition: gsecrets.h:40
GSmtp::ProtocolMessageForward::from
virtual std::string from() const override
Override from GSmtp::ProtocolMessage.
Definition: gprotocolmessageforward.cpp:98
gclientptr.h
GSmtp::ProtocolMessageForward::process
virtual void process(const std::string &auth_id, const std::string &peer_socket_address, const std::string &peer_certificate) override
Override from GSmtp::ProtocolMessage.
Definition: gprotocolmessageforward.cpp:103
gmessagestore.h
GSmtp::ProtocolMessageForward::setFrom
virtual bool setFrom(const std::string &from_user, const std::string &) override
Override from GSmtp::ProtocolMessage.
Definition: gprotocolmessageforward.cpp:78
GSmtp::Client::Config
A structure containing GSmtp::Client configuration parameters.
Definition: gsmtpclient.h:55
GSmtp::VerifierStatus
A structure returned by GSmtp::Verifier to describe the status of a 'rcpt-to' recipient.
Definition: gverifierstatus.h:51
GSmtp::ProtocolMessage
An interface used by the ServerProtocol class to assemble and process an incoming message...
Definition: gprotocolmessage.h:63
GSmtp::ProtocolMessageForward::reset
virtual void reset() override
Override from GSmtp::ProtocolMessage.
Definition: gprotocolmessageforward.cpp:67
GNet::ClientPtr
A smart pointer class for GNet::HeapClient that keeps track of when the contained instance deletes it...
Definition: gclientptr.h:33
gsmtp.h
GSmtp::ProtocolMessageForward::addText
virtual bool addText(const char *, size_t) override
Override from GSmtp::ProtocolMessage.
Definition: gprotocolmessageforward.cpp:93
gsmtpclient.h
GSmtp::ProtocolMessageForward::addReceived
virtual void addReceived(const std::string &) override
Override from GSmtp::ProtocolMessage.
Definition: gprotocolmessageforward.cpp:88
GSmtp::ProtocolMessageForward::doneSignal
virtual G::Slot::Signal4< bool, unsigned long, std::string, std::string > & doneSignal() override
Override from GSmtp::ProtocolMessage.
Definition: gprotocolmessageforward.cpp:62
gnewmessage.h
GSmtp::ProtocolMessageForward::clear
virtual void clear() override
Override from GSmtp::ProtocolMessage.
Definition: gprotocolmessageforward.cpp:73
GSmtp::ProtocolMessageForward::~ProtocolMessageForward
virtual ~ProtocolMessageForward()
Destructor.
Definition: gprotocolmessageforward.cpp:49