- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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