E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gpopserver.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2018 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 /// \file gpopserver.h
19 ///
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
38 namespace GPop
39 {
40 class Server ;
41 class ServerPeer ;
42 }
43
44 /// \class GPop::ServerPeer
45 /// Represents a connection from a POP client. Instances are created
46 /// on the heap by Server (only).
47 /// \see GPop::Server
48 ///
49 class GPop::ServerPeer : public GNet::BufferedServerPeer , private ServerProtocol::Sender , private ServerProtocol::Security
50 {
51 public:
52 G_EXCEPTION( SendError , "network send error" ) ;
53
54 ServerPeer( GNet::Server::PeerInfo , Server & , Store & , const Secrets & ,
55 unique_ptr<ServerProtocol::Text> ptext , ServerProtocol::Config ) ;
56 ///< Constructor.
57
58 virtual bool protocolSend( const std::string & line , size_t ) override ;
59 ///< Final override from GPop::ServerProtocol::Sender.
60
61 protected:
62 virtual void onDelete( const std::string & ) override ;
63 ///< Final override from GNet::ServerPeer.
64
65 virtual bool onReceive( const char * , size_t , size_t ) override ;
66 ///< Final override from GNet::BufferedServerPeer.
67
68 virtual void onSecure( const std::string & ) override ;
69 ///< Final override from GNet::SocketProtocolSink.
70
71 virtual void onSendComplete() override ;
72 ///< Final override from GNet::BufferedServerPeer.
73
74 virtual bool securityEnabled() const override ;
75 ///< Final override from GPop::ServerProtocol::Security.
76
77 virtual void securityStart() override ;
78 ///< Final override from GPop::ServerProtocol::Security.
79
80 private:
81 ServerPeer( const ServerPeer & ) ;
82 void operator=( const ServerPeer & ) ;
83 void processLine( const std::string & line ) ;
84
85 private:
86 Server & m_server ;
87 unique_ptr<ServerProtocol::Text> m_ptext ; // order dependency
88 ServerProtocol m_protocol ; // order dependency -- last
89 } ;
90
91 /// \class GPop::Server
92 /// A POP server class.
93 ///
94 class GPop::Server : public GNet::MultiServer
95 {
96 public:
97 G_EXCEPTION( Overflow , "too many interface addresses" ) ;
98 struct Config /// A structure containing GPop::Server configuration parameters.
99 {
100 bool allow_remote ;
101 unsigned int port ;
102 G::StringArray addresses ;
103 Config() ;
104 Config( bool , unsigned int , const G::StringArray & addresses ) ;
105 } ;
106
107 Server( GNet::ExceptionHandler & , Store & store , const Secrets & , Config ) ;
108 ///< Constructor. The 'secrets' reference is kept.
109
110 virtual ~Server() ;
111 ///< Destructor.
112
113 void report() const ;
114 ///< Generates helpful diagnostics after construction.
115
116 private:
117 Server( const Server & ) ; // not implemented
118 void operator=( const Server & ) ; // not implemented
119 unique_ptr<ServerProtocol::Text> newProtocolText( GNet::Address ) const ;
120 virtual GNet::ServerPeer * newPeer( GNet::Server::PeerInfo , GNet::MultiServer::ServerInfo ) override ;
121
122 private:
123 bool m_allow_remote ;
124 Store & m_store ;
125 const Secrets & m_secrets ;
126 } ;
127
128 #endif
GNet::ServerPeer
An abstract base class for the GNet::Server's connection to a remote client.
Definition: gserver.h:173
GPop::Secrets
A simple interface to a store of secrets as used in authentication.
Definition: gpopsecrets.h:43
gstrings.h
GPop::ServerPeer::onSecure
virtual void onSecure(const std::string &) override
Final override from GNet::SocketProtocolSink.
Definition: gpopserver.cpp:82
GPop::ServerPeer::onSendComplete
virtual void onSendComplete() override
Final override from GNet::BufferedServerPeer.
Definition: gpopserver.cpp:65
GPop::ServerProtocol
Implements the POP server-side protocol.
Definition: gpopserverprotocol.h:48
GNet::Address
The GNet::Address class encapsulates a TCP/UDP transport address.
Definition: gaddress.h:54
G::StringArray
std::vector< std::string > StringArray
A std::vector of std::strings.
Definition: gstrings.h:33
GPop::Server::report
void report() const
Generates helpful diagnostics after construction.
Definition: gpop_disabled.cpp:89
GPop::ServerPeer::ServerPeer
ServerPeer(GNet::Server::PeerInfo, Server &, Store &, const Secrets &, unique_ptr< ServerProtocol::Text > ptext, ServerProtocol::Config)
Constructor.
Definition: gpopserver.cpp:31
GPop::Server::Config
A structure containing GPop::Server configuration parameters.
Definition: gpopserver.h:98
GPop::ServerPeer::onReceive
virtual bool onReceive(const char *, size_t, size_t) override
Final override from GNet::BufferedServerPeer.
Definition: gpopserver.cpp:49
gmultiserver.h
GPop::ServerProtocol::Sender
An interface used by ServerProtocol to send protocol replies.
Definition: gpopserverprotocol.h:52
GPop::Store
A message store.
Definition: gpopstore.h:45
GPop::ServerPeer::onDelete
virtual void onDelete(const std::string &) override
Final override from GNet::ServerPeer.
Definition: gpopserver.cpp:43
GPop::ServerProtocol::Security
An interface used by ServerProtocol to enable TLS.
Definition: gpopserverprotocol.h:72
GNet::ExceptionHandler
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket events...
Definition: gexceptionhandler.h:44
glinebuffer.h
GPop::Server
A POP server class.
Definition: gpopserver.h:94
gbufferedserverpeer.h
gpopsecrets.h
gpopserverprotocol.h
GNet::MultiServer::ServerInfo
A structure used in GNet::MultiServer::newPeer().
Definition: gmultiserver.h:100
GPop::Server::Server
Server(GNet::ExceptionHandler &, Store &store, const Secrets &, Config)
Constructor. The 'secrets' reference is kept.
Definition: gpopserver.cpp:89
GPop::Server::~Server
virtual ~Server()
Destructor.
Definition: gpop_disabled.cpp:85
gpop.h
GPop::ServerPeer::securityEnabled
virtual bool securityEnabled() const override
Final override from GPop::ServerProtocol::Security.
Definition: gpopserver.cpp:70
GPop::ServerProtocol::Config
A structure containing configuration parameters for ServerProtocol. NOT USED.
Definition: gpopserverprotocol.h:67
gexception.h
GPop::ServerPeer
Represents a connection from a POP client.
Definition: gpopserver.h:49
GPop::ServerPeer::protocolSend
virtual bool protocolSend(const std::string &line, size_t) override
Final override from GPop::ServerProtocol::Sender.
Definition: gpopserver.cpp:60
GNet::MultiServer
A server that listens on more than one interface using a facade pattern to multiple GNet::Server inst...
Definition: gmultiserver.h:94
GPop
POP3 classes.
Definition: gpopauth.h:28
GNet::BufferedServerPeer
A ServerPeer that does line-buffering on input.
Definition: gbufferedserverpeer.h:39
GNet::Server::PeerInfo
A structure used in GNet::Server::newPeer().
Definition: gserver.h:85
GPop::ServerPeer::securityStart
virtual void securityStart() override
Final override from GPop::ServerProtocol::Security.
Definition: gpopserver.cpp:77