E-MailRelay
gspamfilter.h
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 /// \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 "gsmtp.h"
26 #include "gfilter.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:
45  bool server_side , const std::string & server_location ,
46  bool read_only , bool always_pass ,
47  unsigned int connection_timeout , unsigned int response_timeout ) ;
48  ///< Constructor.
49 
50  virtual ~SpamFilter() ;
51  ///< Destructor.
52 
53  virtual std::string id() const override ;
54  ///< Override from from GSmtp::Filter.
55 
56  virtual bool simple() const override ;
57  ///< Override from from GSmtp::Filter.
58 
59  virtual G::Slot::Signal1<int> & doneSignal() override ;
60  ///< Override from from GSmtp::Filter.
61 
62  virtual void start( const std::string & path ) override ;
63  ///< Override from from GSmtp::Filter.
64 
65  virtual void cancel() override ;
66  ///< Override from from GSmtp::Filter.
67 
68  virtual bool abandoned() const override ;
69  ///< Override from from GSmtp::Filter.
70 
71  virtual std::string response() const override ;
72  ///< Override from from GSmtp::Filter.
73 
74  virtual std::string reason() const override ;
75  ///< Override from from GSmtp::Filter.
76 
77  virtual bool special() const override ;
78  ///< Override from from GSmtp::Filter.
79 
80 private:
81  SpamFilter( const SpamFilter & ) ; // not implemented
82  void operator=( const SpamFilter & ) ; // not implemented
83  void clientEvent( std::string , std::string ) ;
84  void emit( bool ) ;
85 
86 private:
87  G::Slot::Signal1<int> m_done_signal ;
88  GNet::ExceptionHandler & m_exception_handler ;
89  bool m_server_side ;
90  GNet::Location m_location ;
91  bool m_read_only ;
92  bool m_always_pass ;
93  unsigned int m_connection_timeout ;
94  unsigned int m_response_timeout ;
96  std::string m_text ;
97 } ;
98 
99 #endif
SMTP and message-store classes.
Definition: gadminserver.h:39
virtual ~SpamFilter()
Destructor.
Definition: gspamfilter.cpp:41
virtual void start(const std::string &path) override
Override from from GSmtp::Filter.
Definition: gspamfilter.cpp:56
virtual std::string response() const override
Override from from GSmtp::Filter.
Definition: gspamfilter.cpp:97
virtual std::string reason() const override
Override from from GSmtp::Filter.
virtual bool abandoned() const override
Override from from GSmtp::Filter.
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket events...
A class that holds a host/service name pair and the preferred address family (if any), and also the results of a name-to-address lookup, ie.
Definition: glocation.h:50
An interface for processing a message file through a filter.
Definition: gfilter.h:48
virtual bool special() const override
Override from from GSmtp::Filter.
Definition: gspamfilter.cpp:92
virtual bool simple() const override
Override from from GSmtp::Filter.
Definition: gspamfilter.cpp:51
A Filter class that passes the body of a message file to a remote process over the network and option...
Definition: gspamfilter.h:41
A smart pointer class for GNet::HeapClient that keeps track of when the contained instance deletes it...
Definition: gclientptr.h:33
SpamFilter(GNet::ExceptionHandler &, bool server_side, const std::string &server_location, bool read_only, bool always_pass, unsigned int connection_timeout, unsigned int response_timeout)
Constructor.
Definition: gspamfilter.cpp:27
virtual G::Slot::Signal1< int > & doneSignal() override
Override from from GSmtp::Filter.
virtual void cancel() override
Override from from GSmtp::Filter.
virtual std::string id() const override
Override from from GSmtp::Filter.
Definition: gspamfilter.cpp:46