- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gprocessorfactory_exec_enabled.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2013 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 // gprocessorfactory_exec_enabled.cpp
19 //
20
21 #include "gdef.h"
22 #include "gsmtp.h"
23 #include "gstr.h"
24 #include "gprocessorfactory.h"
25 #include "gexception.h"
26 #include "gfactoryparser.h"
27 #include "gnullprocessor.h"
28 #include "gnetworkprocessor.h"
29 #include "gexecutableprocessor.h"
30 #include "gspamprocessor.h"
31
32 std::string GSmtp::ProcessorFactory::check( const std::string & address )
33 {
34 return FactoryParser::check( address , "spam" ) ;
35 }
36
37 GSmtp::Processor * GSmtp::ProcessorFactory::newProcessor( const std::string & address , unsigned int timeout )
38 {
39 Pair p = FactoryParser::parse( address , "spam" ) ;
40 if( p.first.empty() )
41 {
42 return new NullProcessor ;
43 }
44 else if( p.first == "spam" )
45 {
46 return new SpamProcessor( p.second , timeout , timeout ) ;
47 }
48 else if( p.first == "net" )
49 {
50 return new NetworkProcessor( p.second , timeout , timeout ) ;
51 }
52 else if( p.first == "exit" )
53 {
54 return new NullProcessor( G::Str::toUInt(p.second) ) ;
55 }
56 else
57 {
58 return new ExecutableProcessor( G::Executable(p.second) ) ;
59 }
60 }
61
GSmtp::NullProcessor
A Processor class that does nothing.
Definition: gnullprocessor.h:38
GSmtp::NetworkProcessor
A Processor class that passes the name of a message file to a remote process over the network...
Definition: gnetworkprocessor.h:40
gspamprocessor.h
GSmtp::ProcessorFactory::newProcessor
static Processor * newProcessor(const std::string &address, unsigned int timeout)
Returns a Processor on the heap.
Definition: gprocessorfactory_exec_enabled.cpp:37
GSmtp::Processor
An interface for processing message files.
Definition: gprocessor.h:51
gnetworkprocessor.h
G::Str::toUInt
static unsigned int toUInt(const std::string &s, bool limited=false)
Converts string 's' to an unsigned int.
Definition: gstr.cpp:346
G::Executable
A structure representing an external program, holding a path and a set of arguments.
Definition: gexecutable.h:43
GSmtp::SpamProcessor
A Processor class that passes the body of a message file to a remote process over the network and sto...
Definition: gspamprocessor.h:43
gfactoryparser.h
gexecutableprocessor.h
gstr.h
GSmtp::FactoryParser::parse
static std::pair< std::string, std::string > parse(const std::string &address, const std::string &)
Parses an identifier.
Definition: gfactoryparser.cpp:29
GSmtp::FactoryParser::check
static std::string check(const std::string &address, const std::string &)
Parses and checks an identifier.
Definition: gfactoryparser.cpp:59
gexception.h
gprocessorfactory.h
GSmtp::ExecutableProcessor
A Processor class that processes message files using an external preprocessor program.
Definition: gexecutableprocessor.h:39
GSmtp::ProcessorFactory::check
static std::string check(const std::string &address)
Checks an address.
Definition: gprocessorfactory_exec_enabled.cpp:32
gsmtp.h
gnullprocessor.h