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
34namespace GSmtp
35{
36 class ExecutableFilter ;
37}
38
39//| \class GSmtp::ExecutableFilter
40/// A Filter class that runs an external helper program.
41///
43{
44public:
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
52private: // 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
64public:
65 ExecutableFilter( const ExecutableFilter & ) = delete ;
66 ExecutableFilter( ExecutableFilter && ) = delete ;
67 void operator=( const ExecutableFilter & ) = delete ;
68 void operator=( ExecutableFilter && ) = delete ;
69
70private:
71 std::pair<std::string,std::string> parseOutput( std::string , const std::string & ) const ;
72 void onTimeout() ;
73
74private:
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 ;
83 std::string m_response ;
84 std::string m_reason ;
85 GNet::Task m_task ;
86} ;
87
88#endif
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
An abstract interface for callbacks from GNet::Task.
Definition: gtask.h:113
A class for running an exectuable in a separate process with an asychronous completion callback.
Definition: gtask.h:45
A timer class template in which the timeout is delivered to the specified method.
Definition: gtimer.h:129
A Filter class that runs an external helper program.
ExecutableFilter(GNet::ExceptionSink, FileStore &, bool server_side, const std::string &path, unsigned int timeout)
Constructor.
~ExecutableFilter() override
Destructor.
A concrete implementation of the MessageStore interface dealing in paired flat files.
Definition: gfilestore.h:58
An interface for processing a message file through a filter.
Definition: gfilter.h:49
A somewhat opaque identifer for a MessageStore message.
Definition: gmessagestore.h:43
A Path object represents a file system path.
Definition: gpath.h:72
SMTP and message-store classes.
Definition: gadminserver.h:39
Interprets an executable filter's exit code.
Definition: gfilter.h:102