E-MailRelay

gspamfilter.h
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 gspamfilter.h
19///
20
21#ifndef G_SPAM_FILTER_H
22#define G_SPAM_FILTER_H
23
24#include "gdef.h"
25#include "gfilter.h"
26#include "gfilestore.h"
27#include "gclientptr.h"
28#include "gspamclient.h"
29
30 namespace GFilters
31{
32 class SpamFilter ;
33}
34
35//| \class GFilters::SpamFilter
36/// A Filter class that passes the body of a message file to a remote
37/// process over the network and optionally stores the response back
38/// into the file. It parses the response's "Spam:" header to determine
39/// the overall pass/fail result, or it can optionally always pass.
40///
41 class GFilters::SpamFilter : public GSmtp::Filter
42{
43 public:
44 SpamFilter( GNet::EventState , GStore::FileStore & ,
45 Filter::Type , const Filter::Config & ,
46 const std::string & server_location ,
47 bool read_only , bool always_pass ) ;
48 ///< Constructor.
49
50 ~SpamFilter() override ;
51 ///< Destructor.
52
53 private: // overrides
54 std::string id() const override ; // GSmtp::Filter
55 bool quiet() const override ; // GSmtp::Filter
56 G::Slot::Signal<int> & doneSignal() noexcept override ; // GSmtp::Filter
57 void start( const GStore::MessageId & ) override ; // GSmtp::Filter
58 void cancel() override ; // GSmtp::Filter
59 Result result() const override ; // GSmtp::Filter
60 std::string response() const override ; // GSmtp::Filter
61 int responseCode() const override ; // GSmtp::Filter
62 std::string reason() const override ; // GSmtp::Filter
63 bool special() const override ; // GSmtp::Filter
64
65 public:
66 SpamFilter( const SpamFilter & ) = delete ;
67 SpamFilter( SpamFilter && ) = delete ;
68 SpamFilter & operator=( const SpamFilter & ) = delete ;
69 SpamFilter & operator=( SpamFilter && ) = delete ;
70
71 private:
72 void clientEvent( const std::string & , const std::string & , const std::string & ) ;
73 void clientDeleted( const std::string & ) ;
74 void done() ;
75 void onDoneTimeout() ;
76
77 private:
78 GNet::EventState m_es ;
79 GNet::Timer<SpamFilter> m_done_timer ;
80 G::Slot::Signal<int> m_done_signal ;
81 GStore::FileStore & m_file_store ;
82 GNet::Location m_location ;
83 bool m_read_only ;
84 bool m_always_pass ;
85 unsigned int m_connection_timeout ;
86 unsigned int m_response_timeout ;
87 GNet::ClientPtr<GSmtp::SpamClient> m_client_ptr ;
88 std::string m_text ;
89 Result m_result {Result::fail} ;
90} ;
91
92#endif
GFilters::SpamFilter
A Filter class that passes the body of a message file to a remote process over the network and option...
Definition: gspamfilter.h:42
GFilters::SpamFilter::SpamFilter
SpamFilter(GNet::EventState, GStore::FileStore &, Filter::Type, const Filter::Config &, const std::string &server_location, bool read_only, bool always_pass)
Constructor.
Definition: gspamfilter.cpp:26
GFilters::SpamFilter::~SpamFilter
~SpamFilter() override
Destructor.
Definition: gspamfilter.cpp:43
GNet::ClientPtr< GSmtp::SpamClient >
GNet::EventState
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
Definition: geventstate.h:131
GNet::Location
A class that represents the remote target for out-going client connections.
Definition: glocation.h:70
GNet::Timer
A timer class template in which the timeout is delivered to the specified method.
Definition: gtimer.h:141
GSmtp::Filter
An interface for processing a message file through a filter.
Definition: gfilter.h:51
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
gclientptr.h
gfilestore.h
gfilter.h
gspamclient.h
GFilters
Message filter classes.
Definition: gcopyfilter.h:31
G::Slot::Signal< int >