E-MailRelay
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
GSmtp::Filter Class Referenceabstract

An interface for processing a message file through a filter. More...

#include <gfilter.h>

+ Inheritance diagram for GSmtp::Filter:

Classes

struct  Config
 Configuration passed to filter constructors. More...
 
struct  Exit
 Interprets an executable filter's exit code. More...
 

Public Types

enum class  Result { ok = 0 , abandon = 1 , fail = 2 }
 
enum class  Type { server , client , routing }
 

Public Member Functions

virtual ~Filter ()=default
 Destructor.
 
virtual std::string id () const =0
 Returns the id passed to the derived-class constructor. More...
 
virtual bool quiet () const =0
 Returns true if there is no need for logging.
 
virtual void start (const GStore::MessageId &)=0
 Starts the filter for the given message. More...
 
virtual G::Slot::Signal< int > & doneSignal () noexcept=0
 Returns a signal which is raised once start() has completed or failed. More...
 
virtual void cancel ()=0
 Aborts any incomplete filtering.
 
virtual Result result () const =0
 Returns the filter result, after the doneSignal() has been emitted.
 
virtual std::string response () const =0
 Returns a non-empty SMTP response string iff the filter failed, or an empty response if successful or abandoned.
 
virtual int responseCode () const =0
 An override for the SMTP response code for when the filter has failed. More...
 
virtual std::string reason () const =0
 Returns a non-empty reason string iff the filter failed, or an empty reason if successful or abandoned.
 
virtual bool special () const =0
 Returns true if the filter indicated special handling is required.
 
std::string str (Type type) const
 Returns a diagnostic string for logging, including the filter result. More...
 

Static Public Member Functions

static std::string_view strtype (Type type) noexcept
 Returns a type string for logging: "filter", "client-filter" or "routing-filter". More...
 

Detailed Description

An interface for processing a message file through a filter.

The interface is asynchronous, using a slot/signal completion callback.

Filters return a tri-state value (ok, abandon, fail) and a 'special' flag which is interpreted as 're-scan' for server filters and 'stop-scanning' for client filters.

The abandon state is treated more like success on the server side but more like failure on the client side.

The fail state has an associated SMTP response string (eg. "rejected"), an override for the SMTP response code, and a more expansive reason string for logging.

Definition at line 50 of file gfilter.h.

Member Enumeration Documentation

◆ Result

enum class GSmtp::Filter::Result
strong

Definition at line 53 of file gfilter.h.

◆ Type

enum class GSmtp::Filter::Type
strong

Definition at line 59 of file gfilter.h.

Member Function Documentation

◆ doneSignal()

virtual G::Slot::Signal< int > & GSmtp::Filter::doneSignal ( )
pure virtualnoexcept

Returns a signal which is raised once start() has completed or failed.

The signal parameter is the integer value of result().

◆ id()

virtual std::string GSmtp::Filter::id ( ) const
pure virtual

Returns the id passed to the derived-class constructor.

Used in logging.

◆ responseCode()

virtual int GSmtp::Filter::responseCode ( ) const
pure virtual

An override for the SMTP response code for when the filter has failed.

Many implementations should just return zero.

◆ start()

virtual void GSmtp::Filter::start ( const GStore::MessageId )
pure virtual

Starts the filter for the given message.

Any previous, incomplete filtering is cancel()ed. Asynchronous completion is indicated by a doneSignal().

◆ str()

std::string GSmtp::Filter::str ( Filter::Type  type) const

Returns a diagnostic string for logging, including the filter result.

Definition at line 26 of file gfilter.cpp.

◆ strtype()

std::string_view GSmtp::Filter::strtype ( Filter::Type  type)
staticnoexcept

Returns a type string for logging: "filter", "client-filter" or "routing-filter".

Definition at line 49 of file gfilter.cpp.


The documentation for this class was generated from the following files: