E-MailRelay
gnetworkfilter.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 gnetworkfilter.h
19///
20
21#ifndef G_NETWORK_FILTER_H
22#define G_NETWORK_FILTER_H
23
24#include "gdef.h"
25#include "gfilter.h"
26#include "gclientptr.h"
27#include "gfilestore.h"
28#include "grequestclient.h"
29#include "geventhandler.h"
30#include "goptional.h"
31#include <utility>
32
33namespace GFilters
34{
35 class NetworkFilter ;
36}
37
38//| \class GFilters::NetworkFilter
39/// A Filter class that passes the name of a message file to a
40/// remote network server. The response of ok/abandon/fail is
41/// delivered via the base class's doneSignal().
42///
44{
45public:
47 const Filter::Config & , const std::string & server_location ) ;
48 ///< Constructor.
49
50 ~NetworkFilter() override ;
51 ///< Destructor.
52
53private: // 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 void onException( GNet::ExceptionSource * , std::exception & , bool ) override ; // GNet::ExceptionHandler
65
66public:
67 NetworkFilter( const NetworkFilter & ) = delete ;
68 NetworkFilter( NetworkFilter && ) = delete ;
69 NetworkFilter & operator=( const NetworkFilter & ) = delete ;
70 NetworkFilter & operator=( NetworkFilter && ) = delete ;
71
72private:
73 void clientEvent( const std::string & , const std::string & , const std::string & ) ;
74 void sendResult( const std::string & ) ;
75 void onTimeout() ;
76 std::pair<std::string,int> responsePair() const ;
77
78private:
79 GNet::EventState m_es ;
80 GStore::FileStore & m_file_store ;
83 G::Slot::Signal<int> m_done_signal ;
84 GNet::Location m_location ;
85 unsigned int m_connection_timeout ;
86 unsigned int m_response_timeout ;
88 Result m_result {Result::fail} ;
89} ;
90
91#endif
A Filter class that passes the name of a message file to a remote network server.
NetworkFilter(GNet::EventState, GStore::FileStore &, Filter::Type, const Filter::Config &, const std::string &server_location)
Constructor.
~NetworkFilter() override
Destructor.
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
Definition: geventstate.h:131
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket/future event...
A mixin base class that identifies the source of an exception when delivered to GNet::ExceptionHandle...
A class that represents the remote target for out-going client connections.
Definition: glocation.h:70
A timer class template in which the timeout is delivered to the specified method.
Definition: gtimer.h:141
An interface for processing a message file through a filter.
Definition: gfilter.h:51
A concrete implementation of the MessageStore interface dealing in paired flat files.
Definition: gfilestore.h:56
A somewhat opaque identifer for a GStore::MessageStore message id.
Definition: gmessagestore.h:43
A class template like a simplified c++17 std::optional.
Definition: goptional.h:50
Message filter classes.
Definition: gcopyfilter.h:31