00001 /* 00002 * Purpose: private wxWindows mail transport implementation 00003 * Author: Frank Buß 00004 * Created: 2002 00005 */ 00006 00007 #ifndef SMPT_H 00008 #define SMPT_H 00009 00010 #include <wx/wx.h> 00011 #include <wx/protocol/protocol.h> 00012 00013 #include "email.h" 00014 #include "cmdprot.h" 00015 00016 00023 class wxSMTPListener 00024 { 00025 public: 00030 virtual void OnSocketError(int errorCode) {}; 00031 00038 virtual void OnRecipientAdded(const wxString& address, int errorCode) {}; 00039 00047 virtual void OnDataSent(int errorCode) {}; 00048 }; 00049 00050 class MailState; 00051 00055 class wxSMTP : public wxCmdlineProtocol //, public wxEvtHandler 00056 { 00057 public: 00058 wxSMTP(wxSMTPListener* pListener = NULL); 00059 00060 ~wxSMTP(); 00061 00066 void Send(wxEmailMessage* pMessage); 00067 00068 void EvaluateLine(const wxString& line); 00069 void OnConnect(wxSocketEvent& event); 00070 00071 // MailStateContext interface 00072 00078 void ChangeState(const MailState& mailState); 00079 00085 void SendNextRecipient(); 00086 00090 void OnRecipientError(); 00091 00095 void OnRecipientSuccess(); 00096 00100 void OnDataSuccess(); 00101 00105 void SendFrom(); 00106 00110 void SendData(); 00111 00112 private: 00113 const MailState* m_pMailState; 00114 wxSMTPListener* m_pListener; 00115 wxEmailMessage* m_pMessage; 00116 00117 // current recipient and counts 00118 size_t m_count; 00119 wxString m_currentRecipient; 00120 00121 // all recipients 00122 wxArrayString m_recipients; 00123 }; 00124 00125 #endif