E-MailRelay
gnullfilter.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2018 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 // gnullfilter.cpp
19 //
20 
21 #include "gdef.h"
22 #include "gsmtp.h"
23 #include "gnullfilter.h"
24 #include "gstr.h"
25 
27  m_exit(0,server_side) ,
28  m_id("none") ,
29  m_timer(*this,&NullFilter::onTimeout,eh)
30 {
31 }
32 
33 GSmtp::NullFilter::NullFilter( GNet::ExceptionHandler & eh , bool server_side , unsigned int exit_code ) :
34  m_exit(exit_code,server_side) ,
35  m_id("exit:"+G::Str::fromUInt(exit_code)) ,
36  m_timer(*this,&NullFilter::onTimeout,eh)
37 {
38 }
39 
41 {
42 }
43 
44 std::string GSmtp::NullFilter::id() const
45 {
46  return m_id ;
47 }
48 
50 {
51  return true ;
52 }
53 
55 {
56  return m_exit.special ;
57 }
58 
59 std::string GSmtp::NullFilter::response() const
60 {
61  return ( m_exit.ok() || m_exit.abandon() ) ? std::string() : std::string("rejected") ;
62 }
63 
64 std::string GSmtp::NullFilter::reason() const
65 {
66  return ( m_exit.ok() || m_exit.abandon() ) ? std::string() : m_id ;
67 }
68 
70 {
71  return m_done_signal ;
72 }
73 
75 {
76 }
77 
78 void GSmtp::NullFilter::start( const std::string & )
79 {
80  m_timer.startTimer( 0U ) ;
81 }
82 
83 void GSmtp::NullFilter::onTimeout()
84 {
85  m_done_signal.emit( m_exit.result ) ;
86 }
87 
89 {
90  return m_exit.abandon() ;
91 }
92 
93 /// \file gnullfilter.cpp
virtual void cancel() override
Override from from GSmtp::Filter.
Definition: gnullfilter.cpp:74
virtual bool simple() const override
Override from from GSmtp::Filter.
Definition: gnullfilter.cpp:49
virtual bool special() const override
Override from from GSmtp::Filter.
Definition: gnullfilter.cpp:54
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket events...
virtual void start(const std::string &path) override
Override from from GSmtp::Filter.
Definition: gnullfilter.cpp:78
NullFilter(GNet::ExceptionHandler &, bool server_side)
Constructor.
Definition: gnullfilter.cpp:26
virtual G::Slot::Signal1< int > & doneSignal() override
Override from from GSmtp::Filter.
Definition: gnullfilter.cpp:69
Low-level classes.
Definition: garg.h:29
virtual ~NullFilter()
Destructor.
Definition: gnullfilter.cpp:40
A Filter class that does nothing.
Definition: gnullfilter.h:37
virtual std::string reason() const override
Override from from GSmtp::Filter.
Definition: gnullfilter.cpp:64
virtual bool abandoned() const override
Override from from GSmtp::Filter.
Definition: gnullfilter.cpp:88
virtual std::string response() const override
Override from from GSmtp::Filter.
Definition: gnullfilter.cpp:59
virtual std::string id() const override
Override from from GSmtp::Filter.
Definition: gnullfilter.cpp:44