E-MailRelay

gprotocolmessageforward.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 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 "glocation.h"
26#include "gclientptr.h"
27#include "gprotocolmessage.h"
28#include "gprotocolmessagestore.h"
29#include "gsmtpforward.h"
30#include "gsaslclientsecrets.h"
31#include "gmessagestore.h"
32#include "gnewmessage.h"
33#include "gfilterfactorybase.h"
34#include "gverifierstatus.h"
35#include "gcall.h"
36#include <string>
37#include <memory>
38
39 namespace GSmtp
40{
41 class ProtocolMessageForward ;
42}
43
44//| \class GSmtp::ProtocolMessageForward
45/// A concrete implementation of the ProtocolMessage interface that stores
46/// incoming messages in the message store and then immediately forwards
47/// them on to the downstream server.
48///
49/// The implementation delegates to an instance of the ProtocolMessageStore
50/// class (ie. its sibling class) to do the storage, and to an instance
51/// of the GSmtp::Forward class to do the forwarding.
52///
53/// \see GSmtp::ProtocolMessageStore
54///
55 class GSmtp::ProtocolMessageForward : public ProtocolMessage
56{
57 public:
58 ProtocolMessageForward( GNet::EventState ,
59 GStore::MessageStore & store , FilterFactoryBase & ,
60 std::unique_ptr<ProtocolMessage> pm ,
61 const GSmtp::Client::Config & client_config ,
62 const GAuth::SaslClientSecrets & client_secrets ,
63 const std::string & forward_to , int forward_to_family ) ;
64 ///< Constructor.
65
66 ~ProtocolMessageForward() override ;
67 ///< Destructor.
68
69 private: // overrides
70 ProtocolMessage::ProcessedSignal & processedSignal() noexcept override ; // GSmtp::ProtocolMessage
71 void reset() override ; // GSmtp::ProtocolMessage
72 void clear() override ; // GSmtp::ProtocolMessage
73 GStore::MessageId setFrom( const std::string & from_user , const FromInfo & ) override ; // GSmtp::ProtocolMessage
74 bool addTo( const ToInfo & ) override ; // GSmtp::ProtocolMessage
75 void addReceived( const std::string & ) override ; // GSmtp::ProtocolMessage
76 GStore::NewMessage::Status addContent( const char * , std::size_t ) override ; // GSmtp::ProtocolMessage
77 std::size_t contentSize() const override ; // GSmtp::ProtocolMessage
78 std::string from() const override ; // GSmtp::ProtocolMessage
79 ProtocolMessage::FromInfo fromInfo() const override ; // GSmtp::ProtocolMessage
80 std::string bodyType() const override ; // GSmtp::ProtocolMessage
81 void process( const std::string & auth_id, const std::string & peer_socket_address ,
82 const std::string & peer_certificate ) override ; // GSmtp::ProtocolMessage
83
84 public:
85 ProtocolMessageForward( const ProtocolMessageForward & ) = delete ;
86 ProtocolMessageForward( ProtocolMessageForward && ) = delete ;
87 ProtocolMessageForward & operator=( const ProtocolMessageForward & ) = delete ;
88 ProtocolMessageForward & operator=( ProtocolMessageForward && ) = delete ;
89
90 private:
91 void clientDone( const std::string & ) ; // GNet::Client::doneSignal()
92 void messageDone( const Client::MessageDoneInfo & ) ; // GSmtp::Client::messageDoneSignal()
93 void protocolMessageProcessed( const ProtocolMessage::ProcessedInfo & ) ; // GSmtp::ProtocolMessage::processedSignal()
94 std::string forward( const GStore::MessageId & , bool & ) ;
95
96 private:
97 GNet::EventState m_es ;
98 GStore::MessageStore & m_store ;
99 FilterFactoryBase & m_ff ;
100 G::CallStack m_call_stack ;
101 GNet::Location m_client_location ;
102 Client::Config m_client_config ;
103 const GAuth::SaslClientSecrets & m_client_secrets ;
104 std::unique_ptr<ProtocolMessage> m_pm ;
105 GNet::ClientPtr<GSmtp::Forward> m_client_ptr ;
106 GStore::MessageId m_id ;
107 ProtocolMessage::ProcessedSignal m_processed_signal ;
108} ;
109
110#endif
GAuth::SaslClientSecrets
An interface used by GAuth::SaslClient to obtain a client id and its authentication secret.
Definition: gsaslclientsecrets.h:39
GNet::ClientPtr< GSmtp::Forward >
GNet::EventState
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
Definition: geventstate.h:131
GNet::Location
A class that represents the remote target for out-going client connections.
Definition: glocation.h:70
GSmtp::FilterFactoryBase
A factory interface for making GSmtp::Filter message processors.
Definition: gfilterfactorybase.h:43
GSmtp::ProtocolMessageForward
A concrete implementation of the ProtocolMessage interface that stores incoming messages in the messa...
Definition: gprotocolmessageforward.h:56
GSmtp::ProtocolMessageForward::ProtocolMessageForward
ProtocolMessageForward(GNet::EventState, GStore::MessageStore &store, FilterFactoryBase &, std::unique_ptr< ProtocolMessage > pm, const GSmtp::Client::Config &client_config, const GAuth::SaslClientSecrets &client_secrets, const std::string &forward_to, int forward_to_family)
Constructor.
Definition: gprotocolmessageforward.cpp:28
GSmtp::ProtocolMessageForward::~ProtocolMessageForward
~ProtocolMessageForward() override
Destructor.
Definition: gprotocolmessageforward.cpp:48
GSmtp::ProtocolMessage
An interface used by the ServerProtocol class to assemble and process an incoming message.
Definition: gprotocolmessage.h:65
GStore::MessageId
A somewhat opaque identifer for a GStore::MessageStore message id.
Definition: gmessagestore.h:43
GStore::MessageStore
A class which allows SMTP messages to be stored and retrieved.
Definition: gmessagestore.h:73
G::CallStack
A linked list of CallFrame pointers.
Definition: gcall.h:59
gcall.h
gclientptr.h
gfilterfactorybase.h
glocation.h
gmessagestore.h
gnewmessage.h
gprotocolmessage.h
gprotocolmessagestore.h
gsaslclientsecrets.h
gsmtpforward.h
gverifierstatus.h
GSmtp
SMTP classes.
Definition: gadminserver.h:42
GSmtp::Client::Config
A structure containing GSmtp::Client configuration parameters.
Definition: gsmtpclient.h:67
GSmtp::Client::MessageDoneInfo
Signal parameters for GNet::Client::messageDoneSignal()
Definition: gsmtpclient.h:87
GSmtp::ProtocolMessage::FromInfo
Extra information from the SMTP MAIL-FROM command passed to GSmtp::ProtocolMessage::setFrom().
Definition: gprotocolmessage.h:78
GSmtp::ProtocolMessage::ProcessedInfo
Parameters for GSmtp::ProtocolMessage::processedSignal()
Definition: gprotocolmessage.h:68
GSmtp::ProtocolMessage::ToInfo
Extra information passed to GSmtp::ProtocolMessage::addTo().
Definition: gprotocolmessage.h:85
G::Slot::Signal< const ProcessedInfo & >