- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gspamprocessor.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 // gspamprocessor.cpp
19 //
20
21 #include "gdef.h"
22 #include "gsmtp.h"
23 #include "gspamprocessor.h"
24 #include "glog.h"
25
26 GSmtp::SpamProcessor::SpamProcessor( const std::string & server ,
27 unsigned int connection_timeout , unsigned int response_timeout ) :
28 m_resolver_info(server) ,
29 m_connection_timeout(connection_timeout) ,
30 m_response_timeout(response_timeout)
31 {
32 m_client.eventSignal().connect( G::slot(*this,&GSmtp::SpamProcessor::clientEvent) ) ;
33 }
34
35 GSmtp::SpamProcessor::~SpamProcessor()
36 {
37 m_client.eventSignal().disconnect() ;
38 }
39
40 void GSmtp::SpamProcessor::start( const std::string & path )
41 {
42 m_client.reset( new SpamClient(m_resolver_info,m_connection_timeout,m_response_timeout));
43
44 m_text.erase() ;
45 m_client->request( path ) ; // (no need to wait for connection)
46 }
47
48 void GSmtp::SpamProcessor::clientEvent( std::string s1 , std::string s2 )
49 {
50 G_DEBUG( "GSmtp::SpamProcessor::clientEvent: [" << s1 << "] [" << s2 << "]" ) ;
51 if( s1 == "spam" )
52 {
53 m_text = s2 ;
54 m_done_signal.emit( s2.empty() ) ;
55 }
56 }
57
58 bool GSmtp::SpamProcessor::cancelled() const
59 {
60 return false ;
61 }
62
63 bool GSmtp::SpamProcessor::repoll() const
64 {
65 return false ;
66 }
67
68 std::string GSmtp::SpamProcessor::text() const
69 {
70 return m_text ;
71 }
72
73 G::Signal1<bool> & GSmtp::SpamProcessor::doneSignal()
74 {
75 return m_done_signal ;
76 }
77
78 void GSmtp::SpamProcessor::abort()
79 {
80 m_text.erase() ;
81 if( m_client.get() != NULL && m_client->busy() )
82 m_client.reset() ;
83 }
84
gspamprocessor.h
glog.h
GSmtp::SpamProcessor::cancelled
virtual bool cancelled() const
Final override from GSmtp::Processor.
Definition: gspamprocessor.cpp:58
GSmtp::SpamProcessor::abort
virtual void abort()
Final override from GSmtp::Processor.
Definition: gspamprocessor.cpp:78
G::slot
Slot0 slot(T &object, void(T::*fn)())
Part of the slot/signal system.
Definition: gslot.h:156
GSmtp::SpamProcessor::start
virtual void start(const std::string &path)
Final override from GSmtp::Processor.
Definition: gspamprocessor.cpp:40
G::Signal1< bool >
GSmtp::SpamProcessor::doneSignal
virtual G::Signal1< bool > & doneSignal()
Final override from GSmtp::Processor.
Definition: gspamprocessor.cpp:73
GSmtp::SpamProcessor::~SpamProcessor
virtual ~SpamProcessor()
Destructor.
Definition: gspamprocessor.cpp:35
GSmtp::SpamClient
A client class that interacts with a remote process using a protocol somewhat similar to the spamassa...
Definition: gspamclient.h:47
G_DEBUG
#define G_DEBUG(expr)
Definition: glog.h:95
GSmtp::SpamProcessor::SpamProcessor
SpamProcessor(const std::string &, unsigned int connection_timeout, unsigned int response_timeout)
Constructor.
Definition: gspamprocessor.cpp:26
gsmtp.h
GSmtp::SpamProcessor::text
virtual std::string text() const
Final override from GSmtp::Processor.
Definition: gspamprocessor.cpp:68
GSmtp::SpamProcessor::repoll
virtual bool repoll() const
Final override from GSmtp::Processor.
Definition: gspamprocessor.cpp:63