E-MailRelay

gnullfilter.cpp
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 gnullfilter.cpp
19///
20
21#include "gdef.h"
22#include "gnullfilter.h"
23#include "gassert.h"
24#include "gstr.h"
25
26#ifndef G_LIB_SMALL
27 GFilters::NullFilter::NullFilter( GNet::EventState es , GStore::FileStore & ,
28 Filter::Type filter_type , const Filter::Config & ) :
29 m_id("exit") ,
30 m_exit(0,filter_type) ,
31 m_quiet(true) ,
32 m_timeout(0) ,
33 m_timer(*this,&NullFilter::onTimeout,es)
34{
35}
36#endif
37
38 GFilters::NullFilter::NullFilter( GNet::EventState es , GStore::FileStore & ,
39 Filter::Type filter_type , const Filter::Config & ,
40 unsigned int exit_code ) :
41 m_id("exit:"+G::Str::fromUInt(exit_code)) ,
42 m_exit(static_cast<int>(exit_code),filter_type) ,
43 m_quiet(exit_code==0U) ,
44 m_timeout(0) ,
45 m_timer(*this,&NullFilter::onTimeout,es)
46{
47}
48
49 GFilters::NullFilter::NullFilter( GNet::EventState es , GStore::FileStore & ,
50 Filter::Type filter_type , const Filter::Config & , G::TimeInterval sleep_time ) :
51 m_id("sleep") ,
52 m_exit(0,filter_type) ,
53 m_quiet(false) ,
54 m_timeout(sleep_time) ,
55 m_timer(*this,&NullFilter::onTimeout,es)
56{
57 G_ASSERT( m_exit.ok() ) ;
58}
59
60std::string GFilters::NullFilter::id() const
61{
62 return m_id ;
63}
64
65 bool GFilters::NullFilter::quiet() const
66{
67 return m_quiet ;
68}
69
70 bool GFilters::NullFilter::special() const
71{
72 return m_exit.special ;
73}
74
75GSmtp::Filter::Result GFilters::NullFilter::result() const
76{
77 return m_exit.result ;
78}
79
80std::string GFilters::NullFilter::response() const
81{
82 return ( m_exit.ok() || m_exit.abandon() ) ? std::string() : std::string("rejected") ;
83}
84
85 int GFilters::NullFilter::responseCode() const
86{
87 return 0 ;
88}
89
90std::string GFilters::NullFilter::reason() const
91{
92 return ( m_exit.ok() || m_exit.abandon() ) ? std::string() : m_id ;
93}
94
95 G::Slot::Signal<int> & GFilters::NullFilter::doneSignal() noexcept
96{
97 return m_done_signal ;
98}
99
100 void GFilters::NullFilter::cancel()
101{
102}
103
104 void GFilters::NullFilter::start( const GStore::MessageId & )
105{
106 m_timer.startTimer( m_timeout ) ;
107}
108
109 void GFilters::NullFilter::onTimeout()
110{
111 m_done_signal.emit( static_cast<int>(m_exit.result) ) ;
112}
113
GFilters::NullFilter
A Filter class that does nothing.
Definition: gnullfilter.h:39
GFilters::NullFilter::NullFilter
NullFilter(GNet::EventState, GStore::FileStore &, Filter::Type, const Filter::Config &)
Constructor for a do-nothing filter.
Definition: gnullfilter.cpp:27
GNet::EventState
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
Definition: geventstate.h:131
GStore::FileStore
A concrete implementation of the MessageStore interface dealing in paired flat files.
Definition: gfilestore.h:56
GStore::MessageId
A somewhat opaque identifer for a GStore::MessageStore message id.
Definition: gmessagestore.h:43
G::TimeInterval
An interval between two G::SystemTime values or two G::TimerTime values.
Definition: gdatetime.h:305
gassert.h
gnullfilter.h
gstr.h
G
Low-level classes.
Definition: garg.h:36
std
STL namespace.
G::Slot::Signal< int >