Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

SMTPClient.h

00001 /*
00002  * SMTPClient
00003  *
00004  * Copyright (C) 2002 Konstantin Klyagin <konst@konst.org.ua>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef SMTPCLIENT_H
00023 #define SMTPCLIENT_H
00024 
00025 #include <libicq2000/SocketClient.h>
00026 #include <libicq2000/buffer.h>
00027 
00028 namespace ICQ2000 {
00029 
00030   class SMTPClient : public SocketClient {
00031    private:
00032     enum State { NOT_CONNECTED,
00033                  WAITING_FOR_CONNECT,
00034                  WAITING_FOR_INVITATION,
00035                  WAITING_FOR_HELO_ACK,
00036                  WAITING_FOR_MAIL_ACK,
00037                  WAITING_FOR_RCPT_ACK,
00038                  WAITING_FOR_DATA_ACK,
00039                  WAITING_FOR_TEXT_ACK,
00040                  DISCONNECTING };
00041 
00042     State m_state;
00043 
00044     list<MessageEvent*> m_msgqueue;
00045     Buffer m_recv;
00046     string m_server_name;
00047     unsigned short m_server_port;
00048     time_t m_last_operation, m_timeout;
00049 
00050     void expired_cb(MessageEvent *ev);
00051     void flush_queue();
00052     void check_timeout();
00053 
00054     string getContactEmail(ContactRef cont) const;
00055 
00056     void Init();
00057     void Parse();
00058     void Send(Buffer &b);
00059 
00060     Translator *m_translator;
00061     ContactRef m_self_contact;
00062 
00063     void SayHello();
00064     void SayFrom();
00065     void SayTo();
00066     void SayData();
00067     void SayQuit();
00068 
00069     void SendText();
00070 
00071     void Disconnect();
00072 
00073    public:
00074     SMTPClient(ContactRef self, const string& server_name, unsigned short server_port,
00075                Translator* translator);
00076 
00077     ~SMTPClient();
00078 
00079     void Connect();
00080     void FinishNonBlockingConnect();
00081     void Recv();
00082 
00083     void clearoutMessagesPoll();
00084 
00085     void setServerHost(const string& host);
00086     string getServerHost() const;
00087 
00088     void setServerPort(unsigned short port);
00089     unsigned short getServerPort() const;
00090 
00091     void setTimeout(time_t t);
00092     time_t getTimeout() const;
00093 
00094     void SendEvent(MessageEvent* ev);
00095   };
00096 
00097   class SMTPException : public exception {
00098    private:
00099     string m_errortext;
00100     
00101    public:
00102     SMTPException();
00103     SMTPException(const string& text);
00104     ~SMTPException() throw() { }
00105 
00106     const char* what() const throw();
00107   };
00108 
00109 };
00110 
00111 #endif

Generated on Fri Apr 26 23:48:14 2002 for libicq2000 by doxygen1.2.15