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"
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
39namespace 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///
56{
57public:
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
69private: // 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
84public:
87 ProtocolMessageForward & operator=( const ProtocolMessageForward & ) = delete ;
88 ProtocolMessageForward & operator=( ProtocolMessageForward && ) = delete ;
89
90private:
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
96private:
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 ;
106 GStore::MessageId m_id ;
107 ProtocolMessage::ProcessedSignal m_processed_signal ;
108} ;
109
110#endif
An interface used by GAuth::SaslClient to obtain a client id and its authentication secret.
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
Definition: geventstate.h:131
A class that represents the remote target for out-going client connections.
Definition: glocation.h:70
A factory interface for making GSmtp::Filter message processors.
A concrete implementation of the ProtocolMessage interface that stores incoming messages in the messa...
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.
~ProtocolMessageForward() override
Destructor.
An interface used by the ServerProtocol class to assemble and process an incoming message.
A somewhat opaque identifer for a GStore::MessageStore message id.
Definition: gmessagestore.h:43
A class which allows SMTP messages to be stored and retrieved.
Definition: gmessagestore.h:73
A linked list of CallFrame pointers.
Definition: gcall.h:59
SMTP classes.
Definition: gadminserver.h:42
A structure containing GSmtp::Client configuration parameters.
Definition: gsmtpclient.h:67
Signal parameters for GNet::Client::messageDoneSignal()
Definition: gsmtpclient.h:87
Extra information from the SMTP MAIL-FROM command passed to GSmtp::ProtocolMessage::setFrom().
Parameters for GSmtp::ProtocolMessage::processedSignal()
Extra information passed to GSmtp::ProtocolMessage::addTo().