gpopserver.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_POP_SERVER_H
22 #define G_POP_SERVER_H
23 
24 #include "gdef.h"
25 #include "gpop.h"
26 #include "gmultiserver.h"
27 #include "gbufferedserverpeer.h"
28 #include "glinebuffer.h"
29 #include "gpopsecrets.h"
30 #include "gpopserverprotocol.h"
31 #include "gexception.h"
32 #include "gstrings.h"
33 #include <string>
34 #include <sstream>
35 #include <memory>
36 #include <list>
37 
39 namespace GPop
40 {
41  class Server ;
42  class ServerPeer ;
43 }
44 
51 {
52 public:
53  G_EXCEPTION( SendError , "network send error" ) ;
54 
56  std::auto_ptr<ServerProtocol::Text> ptext , ServerProtocol::Config ) ;
58 
59  virtual bool protocolSend( const std::string & line , size_t ) ;
61 
62 protected:
63  virtual void onDelete( const std::string & ) ;
65 
66  virtual bool onReceive( const std::string & ) ;
68 
69  virtual void onSecure( const std::string & ) ;
71 
72  virtual void onSendComplete() ;
74 
75  virtual bool securityEnabled() const ;
77 
78  virtual void securityStart() ;
80 
81 private:
82  ServerPeer( const ServerPeer & ) ;
83  void operator=( const ServerPeer & ) ;
84  void processLine( const std::string & line ) ;
85  static const std::string & crlf() ;
86 
87 private:
88  Server & m_server ;
89  std::auto_ptr<ServerProtocol::Text> m_ptext ; // order dependency
90  ServerProtocol m_protocol ; // order dependency -- last
91 } ;
92 
97 {
98 public:
99  G_EXCEPTION( Overflow , "too many interface addresses" ) ;
101  struct Config
102  {
104  unsigned int port ;
106  Config() ;
107  Config( bool , unsigned int , const G::Strings & interfaces ) ;
108  } ;
109 
110  Server( Store & store , const Secrets & , Config ) ;
112 
113  virtual ~Server() ;
115 
118 
119  void report() const ;
121 
122 private:
123  Server( const Server & ) ; // not implemented
124  void operator=( const Server & ) ; // not implemented
125  ServerProtocol::Text * newProtocolText( GNet::Address ) const ;
126 
127 private:
128  bool m_allow_remote ;
129  Store & m_store ;
130  const Secrets & m_secrets ;
131 } ;
132 
133 #endif
An abstract base class for the GNet::Server's connection to a remote client.
Definition: gserver.h:191
A simple interface to a store of secrets as used in authentication.
Definition: gpopsecrets.h:44
Implements the POP server-side protocol.
G::Strings interfaces
Definition: gpopserver.h:105
virtual bool onReceive(const std::string &)
Final override from GNet::BufferedServerPeer.
Definition: gpopserver.cpp:56
std::list< std::string > Strings
A std::list of std::strings.
Definition: gstrings.h:39
The Address class encapsulates an IP transport address.
Definition: gaddress.h:48
void report() const
Generates helpful diagnostics after construction.
Definition: gpopserver.cpp:111
virtual void onSendComplete()
Final override from GNet::BufferedServerPeer.
Definition: gpopserver.cpp:72
A structure containing GPop::Server configuration parameters.
Definition: gpopserver.h:101
An interface used by ServerProtocol to send protocol replies.
A message store.
Definition: gpopstore.h:46
An interface used by ServerProtocol to enable TLS.
virtual bool protocolSend(const std::string &line, size_t)
Final override from GPop::ServerProtocol::Sender.
Definition: gpopserver.cpp:67
virtual bool securityEnabled() const
Final override from GPop::ServerProtocol::Security.
Definition: gpopserver.cpp:77
A POP server class.
Definition: gpopserver.h:96
An interface used by ServerProtocol to provide response text strings.
virtual void securityStart()
Final override from GPop::ServerProtocol::Security.
Definition: gpopserver.cpp:85
virtual ~Server()
Destructor.
Definition: gpopserver.cpp:105
A structure containing configuration parameters for ServerProtocol. NOT USED.
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
Definition: gexception.h:93
GNet::ServerPeer * newPeer(GNet::Server::PeerInfo)
From MultiServer.
Definition: gpopserver.cpp:117
ServerPeer(GNet::Server::PeerInfo, Server &, Store &, const Secrets &, std::auto_ptr< ServerProtocol::Text > ptext, ServerProtocol::Config)
Constructor.
Definition: gpopserver.cpp:32
virtual void onSecure(const std::string &)
Final override from GNet::SocketProtocolSink.
Definition: gpopserver.cpp:90
unsigned int port
Definition: gpopserver.h:104
Represents a connection from a POP client.
Definition: gpopserver.h:50
A server that listens on more than one interface using a facade pattern to multiple Server instances...
Definition: gmultiserver.h:102
POP3 classes.
A ServerPeer that does line-buffering on input.
A structure used in GNet::Server::newPeer().
Definition: gserver.h:91
Server(Store &store, const Secrets &, Config)
Constructor. The 'secrets' reference is kept.
Definition: gpopserver.cpp:97
virtual void onDelete(const std::string &)
Final override from GNet::ServerPeer.
Definition: gpopserver.cpp:50