Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
3.0 KiB

  1. // POP3DropDir.h: interface for the POP3DropDir class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #ifndef __POP3DROPDIR_H_
  5. #define __POP3DROPDIR_H_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include <mailbox.h>
  10. #include <mailmsg.h>
  11. #include <seo.h>
  12. #include <eventlogger.h>
  13. #define LODWORD(i64) (DWORD)(0xffffffff&(i64))
  14. #define HIDWORD(i64) (DWORD)(((unsigned __int64)(i64))>>32)
  15. #define PRIVATE_OPTIMAL_BUFFER_SIZE 64 * 1024 // From smtp\server\dropdir.h
  16. #define OPTIMAL_BUFFER_W_DOTSTUFFING_PAD PRIVATE_OPTIMAL_BUFFER_SIZE * 4/3 + 1 // worst case every \r\n. sequence would be expanded to \r\n..
  17. typedef struct _POP3DROPDIR_OVERLAPPED
  18. {
  19. FH_OVERLAPPED Overlapped;
  20. PVOID ThisPtr;
  21. } POP3DROPDIR_OVERLAPPED, *PPOP3DROPDIR_OVERLAPPED;
  22. class CPOP3DropDir
  23. {
  24. public:
  25. CPOP3DropDir( IMailMsgProperties *pIMailMsgProperties, DWORD dwRecipCount, DWORD *pdwRecipIndexes, IMailMsgNotify *pIMailMsgNotify );
  26. virtual ~CPOP3DropDir();
  27. private:
  28. CPOP3DropDir(){;} // Hide default constructor
  29. // Implementation
  30. public:
  31. HRESULT DoLocalDelivery();
  32. bool isAllRecipientsProcessed( ){ return (m_dwRecipCurrent < m_dwRecipCount ) ? false : true; }
  33. HRESULT NextRecipientCopyMailToDropDir(){ HRESULT hr; do{ hr = CopyMailToDropDir(); } while ( ERROR_INVALID_MESSAGEDEST == hr ); return hr; }
  34. HRESULT ReadFileCompletion( DWORD cbSize, DWORD dwErr, PFH_OVERLAPPED lpo );
  35. HRESULT SetHr( HRESULT hr ){ return m_hr = FAILED(hr) ? hr : m_hr; }
  36. HRESULT WriteFileCompletion( DWORD cbSize, DWORD dwErr, PFH_OVERLAPPED lpo );
  37. protected:
  38. HRESULT CopyMailToDropDir();
  39. HRESULT DotStuffBuffer( LPVOID *ppBuffer, LPDWORD pdwSize );
  40. HRESULT MailboxAndContextCleanup( bool bDeleteMailFile );
  41. HRESULT MarkRecipient( DWORD dwMark );
  42. HRESULT ReadFile( IN LPVOID pBuffer, IN DWORD cbSize );
  43. HRESULT WriteFile( IN LPVOID pBuffer, IN DWORD cbSize );
  44. // Attributes
  45. protected:
  46. HRESULT m_hr;
  47. unsigned __int64 m_i64ReadOffset;
  48. unsigned __int64 m_i64WriteOffset;
  49. DWORD m_dwRecipCount;
  50. DWORD m_dwRecipCurrent; // Recipient currently delivering for
  51. DWORD *m_pdwRecipIndexes;
  52. WCHAR m_sRecipEmailName[POP3_MAX_ADDRESS_LENGTH]; // Domain name length + mailbox name length + @ + NULL
  53. WCHAR m_sStoreFileName[64];
  54. char m_sBuffer[OPTIMAL_BUFFER_W_DOTSTUFFING_PAD];
  55. enum BufferWrapSequence{
  56. NA = 0,
  57. CR = 1,
  58. CRLF = 2
  59. };
  60. BufferWrapSequence m_enumBWS;
  61. PFIO_CONTEXT m_PFIOContextRead;
  62. PFIO_CONTEXT m_PFIOContextWrite;
  63. POP3DROPDIR_OVERLAPPED m_OverlappedRead;
  64. POP3DROPDIR_OVERLAPPED m_OverlappedWrite;
  65. CMailBox m_mailboxX;
  66. IMailMsgBind *m_pIMailMsgBind;
  67. IMailMsgProperties *m_pIMailMsgProperties;
  68. IMailMsgNotify *m_pIMailMsgNotify;
  69. IMailMsgRecipients *m_pIMailMsgRecipients;
  70. };
  71. #endif // __POP3DROPDIR_H_