- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

grequestclient.h
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 // ===
20
21 #ifndef G_REQUEST_CLIENT_H
22 #define G_REQUEST_CLIENT_H
23
24 #include "gdef.h"
25 #include "gnet.h"
26 #include "gsmtp.h"
27 #include "gclient.h"
28 #include "gtimer.h"
29 #include "gpath.h"
30 #include "gslot.h"
31 #include "gexception.h"
32
34 namespace GSmtp
35 {
36 class RequestClient ;
37 }
38
43 class GSmtp::RequestClient : public GNet::Client
44 {
45 public:
46 G_EXCEPTION( ProtocolError , "protocol error" ) ;
47
48 RequestClient( const std::string & key , const std::string & ok , const std::string & eol ,
49 const GNet::ResolverInfo & host_and_service , unsigned int connect_timeout , unsigned int response_timeout ) ;
54
55 void request( const std::string & ) ;
64
65 bool busy() const ;
68
69 protected:
70 virtual ~RequestClient() ;
72
73 virtual void onConnect() ;
75
76 virtual bool onReceive( const std::string & ) ;
78
79 virtual void onSendComplete() ;
81
82 virtual void onDelete( const std::string & , bool ) ;
84
85 virtual void onDeleteImp( const std::string & , bool ) ;
87
88 virtual void onSecure( const std::string & ) ;
90
91 private:
92 typedef GNet::Client Base ;
93 RequestClient( const RequestClient & ) ; // not implemented
94 void operator=( const RequestClient & ) ; // not implemented
95 void onTimeout() ;
96 std::string requestLine( const std::string & ) const ;
97 std::string result( std::string ) const ;
98
99 private:
100 std::string m_key ;
101 std::string m_ok ;
102 std::string m_eol ;
103 std::string m_request ;
104 GNet::Timer<RequestClient> m_timer ;
105 } ;
106
107 #endif
GSmtp
SMTP and message-store classes.
GSmtp::RequestClient::RequestClient
RequestClient(const std::string &key, const std::string &ok, const std::string &eol, const GNet::ResolverInfo &host_and_service, unsigned int connect_timeout, unsigned int response_timeout)
Constructor.
Definition: grequestclient.cpp:28
GSmtp::RequestClient::onDeleteImp
virtual void onDeleteImp(const std::string &, bool)
Final override from GNet::Client.
Definition: grequestclient.cpp:76
gclient.h
GNet::ResolverInfo
A class that holds a host/service name pair and optionally the results of a name-to-address lookup...
Definition: gresolverinfo.h:48
GSmtp::RequestClient::onConnect
virtual void onConnect()
Final override from GNet::SimpleClient.
Definition: grequestclient.cpp:45
gslot.h
GSmtp::RequestClient::~RequestClient
virtual ~RequestClient()
Destructor.
Definition: grequestclient.cpp:41
GSmtp::RequestClient::onDelete
virtual void onDelete(const std::string &, bool)
Final override from GNet::HeapClient.
Definition: grequestclient.cpp:72
GSmtp::RequestClient::onSendComplete
virtual void onSendComplete()
Final override from GNet::BufferedClient.
Definition: grequestclient.cpp:109
GSmtp::RequestClient::onSecure
virtual void onSecure(const std::string &)
Final override from GNet::SocketProtocolSink.
Definition: grequestclient.cpp:92
gtimer.h
gexception.h
G_EXCEPTION
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
Definition: gexception.h:93
GSmtp::RequestClient::onReceive
virtual bool onReceive(const std::string &)
Final override from GNet::Client.
Definition: grequestclient.cpp:96
gpath.h
GSmtp::RequestClient::request
void request(const std::string &)
Issues a request.
Definition: grequestclient.cpp:52
GSmtp::RequestClient::busy
bool busy() const
Returns true after request() and before the subsequent event signal.
Definition: grequestclient.cpp:67
gsmtp.h
GNet::Timer
A timer class template in which the timeout is delivered to the specified method. ...
Definition: gtimer.h:103
GNet::Client
A HeapClient class that adds slot/signal signalling, connection/response timeouts, and input line buffering.
Definition: gclient.h:51
GSmtp::RequestClient
A client class that interacts with a remote process with a stateless line-based request/response prot...
Definition: grequestclient.h:43