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.

109 lines
3.4 KiB

  1. // CSimpleDriver.h : Declaration of the CSimpleDriver
  2. #ifndef __CSIMPLEDRIVER_H_
  3. #define __CSIMPLEDRIVER_H_
  4. #include "resource.h" // main symbols
  5. #include <mailmsg.h>
  6. #include <seo.h>
  7. #include "AdjustTokenPrivileges.h"
  8. #include <eventlogger.h>
  9. extern "C"
  10. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/);
  11. class CEventLogger; // forward declaration
  12. class CPOP3DropDir; // forward declaration
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CStoreDriverCriticalSection
  15. class CStoreDriverCriticalSection
  16. {
  17. public:
  18. CStoreDriverCriticalSection()
  19. {
  20. InitializeCriticalSection(&s_csStoreDriver); // returns void
  21. }
  22. virtual ~CStoreDriverCriticalSection()
  23. {
  24. DeleteCriticalSection(&s_csStoreDriver); // returns void
  25. }
  26. // Attributes
  27. public:
  28. CRITICAL_SECTION s_csStoreDriver;
  29. };
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CSimpleDriver
  32. class ATL_NO_VTABLE CSimpleDriver :
  33. public ISMTPStoreDriver,
  34. public IEventIsCacheable,
  35. public CComObjectRootEx<CComMultiThreadModelNoCS>,
  36. public CComCoClass<CSimpleDriver, &CLSID_CPOP3SMTPStoreDriver>
  37. {
  38. friend CPOP3DropDir;
  39. public:
  40. CSimpleDriver();
  41. virtual ~CSimpleDriver();
  42. DECLARE_REGISTRY_RESOURCEID(IDR_CSIMPLEDRIVER)
  43. HRESULT FinalConstruct() {
  44. return S_OK;
  45. }
  46. HRESULT InternalAddRef() {
  47. return CComObjectRootEx<CComMultiThreadModelNoCS>::InternalAddRef();
  48. }
  49. HRESULT InternalRelease() {
  50. return CComObjectRootEx<CComMultiThreadModelNoCS>::InternalRelease();
  51. }
  52. public:
  53. //
  54. // ISMTPStoreDriver
  55. //
  56. HRESULT STDMETHODCALLTYPE Init( DWORD dwInstance, IUnknown *pBinding, IUnknown *pServer, DWORD dwReason, IUnknown **ppStoreDriver );
  57. HRESULT STDMETHODCALLTYPE PrepareForShutdown( DWORD dwReason );
  58. HRESULT STDMETHODCALLTYPE Shutdown( DWORD dwReason );
  59. HRESULT STDMETHODCALLTYPE LocalDelivery( IMailMsgProperties *pMsg, DWORD dwRecipCount, DWORD *pdwRecipIndexes, IMailMsgNotify *pNotify );
  60. HRESULT STDMETHODCALLTYPE EnumerateAndSubmitMessages( IMailMsgNotify *pNotify );
  61. // do the actual work for a local delivery
  62. HRESULT DoLocalDelivery( IMailMsgProperties *pMsg, DWORD dwRecipCount, DWORD *pdwRecipIndexes );
  63. //
  64. // IEventIsCacheable
  65. //
  66. // This lets SEO know that they can hold onto our object when
  67. // it is not actively in use
  68. //
  69. HRESULT STDMETHODCALLTYPE IsCacheable() { return S_OK; }
  70. BEGIN_COM_MAP(CSimpleDriver)
  71. COM_INTERFACE_ENTRY(ISMTPStoreDriver)
  72. COM_INTERFACE_ENTRY(IEventIsCacheable)
  73. END_COM_MAP()
  74. // Implementation
  75. public:
  76. void LogEvent( LOGTYPE Type, DWORD dwEventID ) { m_EventLoggerX.LogEvent( Type, dwEventID );}
  77. void LogEvent( LOGTYPE Type, DWORD dwEventID, DWORD dwError ) { m_EventLoggerX.LogEvent( Type, dwEventID, 0, NULL, 0, sizeof( dwError ), &dwError );}
  78. //Attributes
  79. protected:
  80. char m_szComputerName[MAX_PATH];
  81. BOOL m_fInit;
  82. long m_lPrepareForShutdown;
  83. CEventLogger m_EventLoggerX;
  84. CAdjustTokenPrivileges m_AdjustTokenPrivilegesX;
  85. static DWORD s_dwCounter; // Used to create unique mail file names
  86. static CSimpleDriver *s_pStoreDriver;
  87. };
  88. #endif //__CSIMPLEDRIVER_H_