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 
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 ;
105 } ;
106 
107 #endif
SMTP and message-store classes.
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.
virtual void onDeleteImp(const std::string &, bool)
Final override from GNet::Client.
A class that holds a host/service name pair and optionally the results of a name-to-address lookup...
Definition: gresolverinfo.h:48
virtual void onConnect()
Final override from GNet::SimpleClient.
virtual ~RequestClient()
Destructor.
virtual void onDelete(const std::string &, bool)
Final override from GNet::HeapClient.
virtual void onSendComplete()
Final override from GNet::BufferedClient.
virtual void onSecure(const std::string &)
Final override from GNet::SocketProtocolSink.
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
Definition: gexception.h:93
virtual bool onReceive(const std::string &)
Final override from GNet::Client.
void request(const std::string &)
Issues a request.
bool busy() const
Returns true after request() and before the subsequent event signal.
A timer class template in which the timeout is delivered to the specified method. ...
Definition: gtimer.h:103
A HeapClient class that adds slot/signal signalling, connection/response timeouts, and input line buffering.
Definition: gclient.h:51
A client class that interacts with a remote process with a stateless line-based request/response prot...