E-MailRelay

gexecutablefilter.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 gexecutablefilter.h
19///
20
21#ifndef G_SMTP_EXECUTABLE_FILTER_H
22#define G_SMTP_EXECUTABLE_FILTER_H
23
24#include "gdef.h"
25#include "gpath.h"
26#include "gfilter.h"
27#include "gfilestore.h"
28#include "geventhandler.h"
29#include "gfutureevent.h"
30#include "gtimer.h"
31#include "gtask.h"
32#include <utility>
33
34 namespace GSmtp
35{
36 class ExecutableFilter ;
37}
38
39//| \class GSmtp::ExecutableFilter
40/// A Filter class that runs an external helper program.
41///
42 class GSmtp::ExecutableFilter : public Filter, private GNet::TaskCallback
43{
44 public:
45 ExecutableFilter( GNet::ExceptionSink , FileStore & , bool server_side ,
46 const std::string & path , unsigned int timeout ) ;
47 ///< Constructor.
48
49 ~ExecutableFilter() 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 void onTaskDone( int , const std::string & ) override ; // Override from GNet::TaskCallback.
63
64 public:
65 ExecutableFilter( const ExecutableFilter & ) = delete ;
66 ExecutableFilter( ExecutableFilter && ) = delete ;
67 void operator=( const ExecutableFilter & ) = delete ;
68 void operator=( ExecutableFilter && ) = delete ;
69
70 private:
71 std::pair<std::string,std::string> parseOutput( std::string , const std::string & ) const ;
72 void onTimeout() ;
73
74 private:
75 FileStore & m_file_store ;
76 G::Slot::Signal<int> m_done_signal ;
77 bool m_server_side ;
78 std::string m_prefix ;
79 Exit m_exit ;
80 G::Path m_path ;
81 unsigned int m_timeout ;
82 GNet::Timer<ExecutableFilter> m_timer ;
83 std::string m_response ;
84 std::string m_reason ;
85 GNet::Task m_task ;
86} ;
87
88#endif
GNet::ExceptionSink
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
Definition: gexceptionsink.h:100
GNet::TaskCallback
An abstract interface for callbacks from GNet::Task.
Definition: gtask.h:113
GNet::Task
A class for running an exectuable in a separate process with an asychronous completion callback.
Definition: gtask.h:45
GNet::Timer
A timer class template in which the timeout is delivered to the specified method.
Definition: gtimer.h:129
GSmtp::ExecutableFilter
A Filter class that runs an external helper program.
Definition: gexecutablefilter.h:43
GSmtp::ExecutableFilter::ExecutableFilter
ExecutableFilter(GNet::ExceptionSink, FileStore &, bool server_side, const std::string &path, unsigned int timeout)
Constructor.
Definition: gexecutablefilter.cpp:32
GSmtp::ExecutableFilter::~ExecutableFilter
~ExecutableFilter() override
Destructor.
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
G::Path
A Path object represents a file system path.
Definition: gpath.h:72
geventhandler.h
gfilestore.h
gfilter.h
gfutureevent.h
gpath.h
gtask.h
gtimer.h
GSmtp
SMTP and message-store classes.
Definition: gadminserver.h:39
GSmtp::Filter::Exit
Interprets an executable filter's exit code.
Definition: gfilter.h:102
G::Slot::Signal< int >