E-MailRelay
gfilterchain.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 gfilterchain.h
19///
20
21#ifndef G_FILTER_CHAIN_H
22#define G_FILTER_CHAIN_H
23
24#include "gdef.h"
25#include "gfilter.h"
26#include "gfilterfactory.h"
27#include "gtimer.h"
28#include "gslot.h"
29#include "geventstate.h"
30#include <memory>
31#include <vector>
32
33namespace GFilters
34{
35 class FilterChain ;
36}
37
38//| \class GFilters::FilterChain
39/// A Filter class that runs a sequence of sub-filters. The sub-filters are run
40/// in sequence only as long as they return success.
41///
43{
44public:
46 const Filter::Config & , const GSmtp::FilterFactoryBase::Spec & spec ) ;
47 ///< Constructor.
48
49 ~FilterChain() override ;
50 ///< Destructor.
51
52public:
53 FilterChain( const FilterChain & ) = delete ;
54 FilterChain( FilterChain && ) = delete ;
55 FilterChain & operator=( const FilterChain & ) = delete ;
56 FilterChain & operator=( FilterChain && ) = delete ;
57
58private: // overrides
59 std::string id() const override ; // GSmtp::Filter
60 bool quiet() const override ; // GSmtp::Filter
61 G::Slot::Signal<int> & doneSignal() noexcept override ; // GSmtp::Filter
62 void start( const GStore::MessageId & ) override ; // GSmtp::Filter
63 void cancel() override ; // GSmtp::Filter
64 Result result() const override ; // GSmtp::Filter
65 std::string response() const override ; // GSmtp::Filter
66 int responseCode() const override ; // GSmtp::Filter
67 std::string reason() const override ; // GSmtp::Filter
68 bool special() const override ; // GSmtp::Filter
69
70private:
71 void add( GNet::EventState , GSmtp::FilterFactoryBase & , Filter::Type ,
72 const Filter::Config & , const GSmtp::FilterFactoryBase::Spec & ) ;
73 void onFilterDone( int ) ;
74
75private:
76 G::Slot::Signal<int> m_done_signal ;
77 std::string m_filter_id ;
78 std::vector<std::unique_ptr<GSmtp::Filter>> m_filters ;
79 std::size_t m_filter_index {0U} ;
80 GSmtp::Filter * m_filter {nullptr} ;
81 bool m_running {false} ;
82 GStore::MessageId m_message_id ;
83} ;
84
85#endif
A Filter class that runs a sequence of sub-filters.
Definition: gfilterchain.h:43
FilterChain(GNet::EventState, GSmtp::FilterFactoryBase &, Filter::Type, const Filter::Config &, const GSmtp::FilterFactoryBase::Spec &spec)
Constructor.
~FilterChain() override
Destructor.
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
Definition: geventstate.h:131
A factory interface for making GSmtp::Filter message processors.
An interface for processing a message file through a filter.
Definition: gfilter.h:51
A somewhat opaque identifer for a GStore::MessageStore message id.
Definition: gmessagestore.h:43
Message filter classes.
Definition: gcopyfilter.h:31
Filter specification tuple for GSmtp::FilterFactoryBase::newFilter().