00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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