E-MailRelay

gnullfilter.cpp
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2021 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 "gstr.h"
24
25 GSmtp::NullFilter::NullFilter( GNet::ExceptionSink es , bool server_side ) :
26 m_exit(0,server_side) ,
27 m_id("none") ,
28 m_timer(*this,&NullFilter::onTimeout,es)
29{
30}
31
32 GSmtp::NullFilter::NullFilter( GNet::ExceptionSink es , bool server_side , unsigned int exit_code ) :
33 m_exit(static_cast<int>(exit_code),server_side) ,
34 m_id("exit:"+G::Str::fromUInt(exit_code)) ,
35 m_timer(*this,&NullFilter::onTimeout,es)
36{
37}
38
39std::string GSmtp::NullFilter::id() const
40{
41 return m_id ;
42}
43
44 bool GSmtp::NullFilter::simple() const
45{
46 return true ;
47}
48
49 bool GSmtp::NullFilter::special() const
50{
51 return m_exit.special ;
52}
53
54std::string GSmtp::NullFilter::response() const
55{
56 return ( m_exit.ok() || m_exit.abandon() ) ? std::string() : std::string("rejected") ;
57}
58
59std::string GSmtp::NullFilter::reason() const
60{
61 return ( m_exit.ok() || m_exit.abandon() ) ? std::string() : m_id ;
62}
63
64 G::Slot::Signal<int> & GSmtp::NullFilter::doneSignal()
65{
66 return m_done_signal ;
67}
68
69 void GSmtp::NullFilter::cancel()
70{
71}
72
73 void GSmtp::NullFilter::start( const MessageId & )
74{
75 m_timer.startTimer( 0U ) ;
76}
77
78 void GSmtp::NullFilter::onTimeout()
79{
80 m_done_signal.emit( static_cast<int>(m_exit.result) ) ;
81}
82
83 bool GSmtp::NullFilter::abandoned() const
84{
85 return m_exit.abandon() ;
86}
87
GNet::ExceptionSink
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
Definition: gexceptionsink.h:100
GSmtp::NullFilter
A Filter class that does nothing.
Definition: gnullfilter.h:37
GSmtp::NullFilter::NullFilter
NullFilter(GNet::ExceptionSink, bool server_side)
Constructor.
Definition: gnullfilter.cpp:25
gnullfilter.h
gstr.h
G
Low-level classes.
Definition: galign.h:28
G::Slot::Signal< int >