SMTPServer.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2005-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 #ifndef _OASYS_SMTP_SERVER_H_
00018 #define _OASYS_SMTP_SERVER_H_
00019 
00020 #include "../io/FdIOClient.h"
00021 #include "../io/TCPServer.h"
00022 #include "SMTP.h"
00023 
00024 namespace oasys {
00025 
00026 class SMTPServer;
00027 class SMTPHandlerFactory;
00028 class SMTPHandlerThread;
00029 
00034 class SMTPServer : public oasys::TCPServerThread {
00035 public:
00036     SMTPServer(const SMTP::Config& config,
00037                SMTPHandlerFactory* handler_factory,
00038                Notifier*           session_done = NULL,
00039                int                 accept_timeout = -1);
00040 
00041 private:
00042     void accepted(int fd, in_addr_t addr, u_int16_t port);
00043     
00044     SMTP::Config        config_;
00045     SMTPHandlerFactory* handler_factory_;
00046     Notifier*           session_done_;
00047 };
00048 
00054 class SMTPHandlerFactory {
00055 public:
00056     virtual ~SMTPHandlerFactory() {}
00057     virtual SMTPHandler* new_handler() = 0;
00058 };
00059 
00063 class SMTPHandlerThread : public Thread {
00064 public:
00065     SMTPHandlerThread(SMTPHandler* handler,
00066                       int fd_in, int fd_out,
00067                       const SMTP::Config& config,
00068                       Notifier* session_done);
00069 
00070     virtual ~SMTPHandlerThread();
00071     void run();
00072 
00073 private:
00074     SMTPHandler*   handler_;
00075     FdIOClient     fdio_in_;
00076     FdIOClient     fdio_out_;
00077     BufferedInput  in_;
00078     BufferedOutput out_;
00079     SMTP           smtp_;
00080     Notifier*      session_done_;
00081 };
00082 
00083 } // namespace oasys
00084 
00085 #endif /* _OASYS_SMTP_SERVER_H_ */

Generated on Thu Jun 7 12:54:29 2007 for DTN Reference Implementation by  doxygen 1.5.1