E-MailRelay
gsimplefilterbase.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 gsimplefilterbase.h
19///
20
21#ifndef G_SIMPLE_FILTER_BASE_H
22#define G_SIMPLE_FILTER_BASE_H
23
24#include "gdef.h"
25#include "gfilter.h"
26#include "gfilestore.h"
27#include "genvelope.h"
28#include "geventstate.h"
29#include "gslot.h"
30#include "gtimer.h"
31#include "gstringview.h"
32
33namespace GFilters
34{
35 class SimpleFilterBase ;
36}
37
38//| \class GFilters::SimpleFilterBase
39/// A GSmtp::Filter base class for filters that run synchronously.
40/// Concrete classes should implement run().
41///
43{
44public:
45 SimpleFilterBase( GNet::EventState , Filter::Type , std::string_view id ) ;
46 ///< Constructor.
47
48 virtual Result run( const GStore::MessageId & , bool & special_out ,
49 GStore::FileStore::State ) = 0 ;
50 ///< Runs the filter synchronously and returns the result.
51
52 std::string prefix() const ;
53 ///< Returns a logging prefix derived from Filter::Type and filter id.
54
55private: // overrides
56 bool quiet() const final ;
57 void start( const GStore::MessageId & ) final ;
58 std::string id() const final ;
59 G::Slot::Signal<int> & doneSignal() noexcept final ;
60 void cancel() final ;
61 Result result() const final ;
62 std::string response() const final ;
63 int responseCode() const final ;
64 std::string reason() const final ;
65 bool special() const final ;
66
67private:
68 void onTimeout() ;
69
70private:
71 Filter::Type m_filter_type ;
72 std::string m_id ;
73 GNet::Timer<SimpleFilterBase> m_timer ;
74 G::Slot::Signal<int> m_done_signal ;
75 Result m_result {Result::fail} ;
76 bool m_special {false} ;
77} ;
78
79#endif
A GSmtp::Filter base class for filters that run synchronously.
SimpleFilterBase(GNet::EventState, Filter::Type, std::string_view id)
Constructor.
virtual Result run(const GStore::MessageId &, bool &special_out, GStore::FileStore::State)=0
Runs the filter synchronously and returns the result.
std::string prefix() const
Returns a logging prefix derived from Filter::Type and filter id.
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
Definition: geventstate.h:131
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
Network classes.
Definition: gdef.h:1243
Message store classes.
Definition: genvelope.cpp:30
Low-level classes.
Definition: garg.h:36
STL namespace.