- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
50 class GPop::ServerPeer : public GNet::BufferedServerPeer , private GPop::ServerProtocol::Sender , private GPop::ServerProtocol::Security
51 {
52 public:
53 G_EXCEPTION( SendError , "network send error" ) ;
54
55 ServerPeer( GNet::Server::PeerInfo , Server & , Store & , const Secrets & ,
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
96 class GPop::Server : public GNet::MultiServer
97 {
98 public:
99 G_EXCEPTION( Overflow , "too many interface addresses" ) ;
101 struct Config
102 {
103 bool allow_remote ;
104 unsigned int port ;
105 G::Strings interfaces ;
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
116 GNet::ServerPeer * newPeer( GNet::Server::PeerInfo ) ;
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
GNet::ServerPeer
An abstract base class for the GNet::Server's connection to a remote client.
Definition: gserver.h:191
GPop::Secrets
A simple interface to a store of secrets as used in authentication.
Definition: gpopsecrets.h:44
gstrings.h
GPop::Server::Config::allow_remote
bool allow_remote
Definition: gpopserver.h:103
GPop::ServerProtocol
Implements the POP server-side protocol.
Definition: gpopserverprotocol.h:50
GPop::Server::Config::interfaces
G::Strings interfaces
Definition: gpopserver.h:105
GPop::ServerPeer::onReceive
virtual bool onReceive(const std::string &)
Final override from GNet::BufferedServerPeer.
Definition: gpopserver.cpp:56
G::Strings
std::list< std::string > Strings
A std::list of std::strings.
Definition: gstrings.h:39
GNet::Address
The Address class encapsulates an IP transport address.
Definition: gaddress.h:48
GPop::Server::report
void report() const
Generates helpful diagnostics after construction.
Definition: gpopserver.cpp:111
GPop::ServerPeer::onSendComplete
virtual void onSendComplete()
Final override from GNet::BufferedServerPeer.
Definition: gpopserver.cpp:72
GPop::Server::Config
A structure containing GPop::Server configuration parameters.
Definition: gpopserver.h:101
gmultiserver.h
GPop::ServerProtocol::Sender
An interface used by ServerProtocol to send protocol replies.
Definition: gpopserverprotocol.h:55
GPop::Store
A message store.
Definition: gpopstore.h:46
GPop::ServerProtocol::Security
An interface used by ServerProtocol to enable TLS.
Definition: gpopserverprotocol.h:78
glinebuffer.h
GPop::ServerPeer::protocolSend
virtual bool protocolSend(const std::string &line, size_t)
Final override from GPop::ServerProtocol::Sender.
Definition: gpopserver.cpp:67
GPop::ServerPeer::securityEnabled
virtual bool securityEnabled() const
Final override from GPop::ServerProtocol::Security.
Definition: gpopserver.cpp:77
GPop::Server::Config::Config
Config()
Definition: gpopserver.cpp:146
GPop::Server
A POP server class.
Definition: gpopserver.h:96
gbufferedserverpeer.h
GPop::ServerProtocol::Text
An interface used by ServerProtocol to provide response text strings.
Definition: gpopserverprotocol.h:62
gpopsecrets.h
gpopserverprotocol.h
GPop::ServerPeer::securityStart
virtual void securityStart()
Final override from GPop::ServerProtocol::Security.
Definition: gpopserver.cpp:85
GPop::Server::~Server
virtual ~Server()
Destructor.
Definition: gpopserver.cpp:105
gpop.h
GPop::ServerProtocol::Config
A structure containing configuration parameters for ServerProtocol. NOT USED.
Definition: gpopserverprotocol.h:72
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
GPop::Server::newPeer
GNet::ServerPeer * newPeer(GNet::Server::PeerInfo)
From MultiServer.
Definition: gpopserver.cpp:117
GPop::ServerPeer::ServerPeer
ServerPeer(GNet::Server::PeerInfo, Server &, Store &, const Secrets &, std::auto_ptr< ServerProtocol::Text > ptext, ServerProtocol::Config)
Constructor.
Definition: gpopserver.cpp:32
GPop::ServerPeer::onSecure
virtual void onSecure(const std::string &)
Final override from GNet::SocketProtocolSink.
Definition: gpopserver.cpp:90
GPop::Server::Config::port
unsigned int port
Definition: gpopserver.h:104
GPop::ServerPeer
Represents a connection from a POP client.
Definition: gpopserver.h:50
GNet::MultiServer
A server that listens on more than one interface using a facade pattern to multiple Server instances...
Definition: gmultiserver.h:102
GPop
POP3 classes.
GNet::BufferedServerPeer
A ServerPeer that does line-buffering on input.
Definition: gbufferedserverpeer.h:41
GNet::Server::PeerInfo
A structure used in GNet::Server::newPeer().
Definition: gserver.h:91
GPop::Server::Server
Server(Store &store, const Secrets &, Config)
Constructor. The 'secrets' reference is kept.
Definition: gpopserver.cpp:97
GPop::ServerPeer::onDelete
virtual void onDelete(const std::string &)
Final override from GNet::ServerPeer.
Definition: gpopserver.cpp:50