28 std::ostringstream ss ;
31 if( r == Result::fail )
33 else if( r == Result::abandon )
34 ss <<
"ok(abandon) " ;
39 ss << ( type == Filter::Type::server ?
"+rescan " :
"+break " ) ;
41 ss <<
"response=[" <<
response() <<
"]" ;
44 ss <<
" reason=[" <<
reason() <<
"]" ;
51 return type == Type::server ?
"filter"_sv :
52 ( type == Type::client ?
"client-filter"_sv :
"routing-filter"_sv ) ;
55GSmtp::Filter::Exit::Exit(
int exit_code , Filter::Type type )
61 else if( exit_code >= 1 && exit_code < 100 )
63 result = Result::fail ;
65 else if( exit_code == 100 )
67 result = Result::abandon ;
69 else if( exit_code == 101 )
74 bool server_side = type == Filter::Type::server ;
77 const bool rescan = true ;
78 if( exit_code == 102 )
80 result = Result::abandon ; special = rescan ;
82 else if( exit_code == 103 )
84 result = Result::ok ; special = rescan ;
86 else if( exit_code == 104 )
88 result = Result::fail ; special = rescan ;
93 const bool stop_scanning = true ;
94 if( exit_code == 102 )
96 result = Result::ok ; special = stop_scanning ;
98 else if( exit_code == 103 )
100 result = Result::ok ;
102 else if( exit_code == 104 )
104 result = Result::abandon ; special = stop_scanning ;
106 else if( exit_code == 105 )
108 result = Result::fail ; special = stop_scanning ;
113bool GSmtp::Filter::Exit::ok()
const
115 return result == Result::ok ;
118bool GSmtp::Filter::Exit::abandon()
const
120 return result == Result::abandon ;
124bool GSmtp::Filter::Exit::fail()
const
126 return result == Result::fail ;
virtual Result result() const =0
Returns the filter result, after the doneSignal() has been emitted.
virtual bool special() const =0
Returns true if the filter indicated special handling is required.
virtual std::string response() const =0
Returns a non-empty SMTP response string iff the filter failed, or an empty response if successful or...
virtual std::string reason() const =0
Returns a non-empty reason string iff the filter failed, or an empty reason if successful or abandone...
std::string str(Type type) const
Returns a diagnostic string for logging, including the filter result.
static std::string_view strtype(Type type) noexcept
Returns a type string for logging: "filter", "client-filter" or "routing-filter".