E-MailRelay

gspamfilter.h
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 gspamfilter.h
19///
20
21#ifndef G_SMTP_SPAM_FILTER_H
22#define G_SMTP_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 GSmtp
31{
32 class SpamFilter ;
33}
34
35//| \class GSmtp::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 GSmtp::SpamFilter : public Filter
42{
43 public:
44 SpamFilter( GNet::ExceptionSink , FileStore & , const std::string & server_location ,
45 bool read_only , bool always_pass , unsigned int connection_timeout ,
46 unsigned int response_timeout ) ;
47 ///< Constructor.
48
49 ~SpamFilter() override ;
50 ///< Destructor.
51
52 private: // overrides
53 std::string id() const override ; // Override from from GSmtp::Filter.
54 bool simple() const override ; // Override from from GSmtp::Filter.
55 G::Slot::Signal<int> & doneSignal() override ; // Override from from GSmtp::Filter.
56 void start( const MessageId & ) override ; // Override from from GSmtp::Filter.
57 void cancel() override ; // Override from from GSmtp::Filter.
58 bool abandoned() const override ; // Override from from GSmtp::Filter.
59 std::string response() const override ; // Override from from GSmtp::Filter.
60 std::string reason() const override ; // Override from from GSmtp::Filter.
61 bool special() const override ; // Override from from GSmtp::Filter.
62
63 public:
64 SpamFilter( const SpamFilter & ) = delete ;
65 SpamFilter( SpamFilter && ) = delete ;
66 void operator=( const SpamFilter & ) = delete ;
67 void operator=( SpamFilter && ) = delete ;
68
69 private:
70 void clientEvent( const std::string & , const std::string & , const std::string & ) ;
71 void clientDeleted( const std::string & ) ;
72 void emit( bool ) ;
73
74 private:
75 G::Slot::Signal<int> m_done_signal ;
76 GNet::ExceptionSink m_es ;
77 FileStore & m_file_store ;
78 GNet::Location m_location ;
79 bool m_read_only ;
80 bool m_always_pass ;
81 unsigned int m_connection_timeout ;
82 unsigned int m_response_timeout ;
83 GNet::ClientPtr<SpamClient> m_client_ptr ;
84 std::string m_text ;
85} ;
86
87#endif
GNet::ClientPtr
A smart pointer class for GNet::Client.
Definition: gclientptr.h:135
GNet::ExceptionSink
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
Definition: gexceptionsink.h:100
GNet::Location
A class that represents the remote target for out-going client connections.
Definition: glocation.h:71
GSmtp::FileStore
A concrete implementation of the MessageStore interface dealing in paired flat files.
Definition: gfilestore.h:58
GSmtp::Filter
An interface for processing a message file through a filter.
Definition: gfilter.h:49
GSmtp::MessageId
A somewhat opaque identifer for a MessageStore message.
Definition: gmessagestore.h:43
GSmtp::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
GSmtp::SpamFilter::~SpamFilter
~SpamFilter() override
Destructor.
Definition: gspamfilter.cpp:41
GSmtp::SpamFilter::SpamFilter
SpamFilter(GNet::ExceptionSink, FileStore &, const std::string &server_location, bool read_only, bool always_pass, unsigned int connection_timeout, unsigned int response_timeout)
Constructor.
Definition: gspamfilter.cpp:26
gclientptr.h
gfilestore.h
gfilter.h
gspamclient.h
GSmtp
SMTP and message-store classes.
Definition: gadminserver.h:39
G::Slot::Signal< int >