Platform SDK: SMTP Server Events

Sink.h

[This is preliminary documentation and subject to change.]

// Sink.h : Declaration of the CSink

#ifndef __SINK_H_
#define __SINK_H_

#include "resource.h"       // main symbols
#include <mailmsg.h>
#include <smtpevent.h>
#include <seo.h>
#define SMTPINITGUID
#include <smtpguid.h>
#include <atlbase.h>
#include <atlimpl.cpp>

#define FILEPATH_DEFAULT "c:\\mailarchive"

extern FIO_CONTEXT            fcntxtFile;
extern OVERLAPPED            overLapped;
extern CComAutoCriticalSection   g_csCritSec;

/////////////////////////////////////////////////////////////////////////////
// CSink
class ATL_NO_VTABLE CSink : 
   public CComObjectRootEx<CComMultiThreadModel>,
   public CComCoClass<CSink, &CLSID_Sink>,
   public IMailTransportSubmission,
    public IEventIsCacheable,
    public IPersistPropertyBag,
   public IDispatchImpl<ISink, &IID_ISink, &LIBID_ARCHIVERLib>
{
public:
   CSink() : g_fHaveLogFileName(FALSE)
   {
      g_szLogFilePath = new char[sizeof(FILEPATH_DEFAULT)+1];
      strcpy(g_szLogFilePath,FILEPATH_DEFAULT);
   }
   ~CSink()
   {
      if(g_szLogFilePath) {
         delete [] g_szLogFilePath;
         g_szLogFilePath = NULL;
      }
   }


DECLARE_REGISTRY_RESOURCEID(IDR_SINK)
DECLARE_NOT_AGGREGATABLE(CSink)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CSink)
   COM_INTERFACE_ENTRY(ISink)
    COM_INTERFACE_ENTRY(IMailTransportSubmission)
    COM_INTERFACE_ENTRY(IEventIsCacheable)
    COM_INTERFACE_ENTRY(IPersistPropertyBag)
   COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

// ISink
public:
   STDMETHOD(UnRegisterSink)(/*[in]*/ long lInstance, /*[in]*/ BSTR BindingGUID);
   STDMETHOD(RegisterSink)(/*[in]*/ long lInstance, /*[in]*/ BSTR DisplayName, BSTR BindingGUID, BSTR ResponseText, VARIANT_BOOL fEnabled, BSTR* OutBindingGUID);

   /*
   ** IMailTransportSubmission
   */
   
   STDMETHOD(OnMessageSubmission)(
         IMailMsgProperties     *pIMailMsg,
         IMailTransportNotify   *pINotify,
         PVOID                   pvNotifyContext);

    /*
    ** IEventIsCacheable
    */
    STDMETHOD(IsCacheable)(void){ return S_OK;} 

    /*
    ** IPersistPropertyBag : IPersist
    */
    STDMETHOD(GetClassID)(CLSID *pClassID);
    STDMETHOD(InitNew)(void);
    STDMETHOD(Load)(IPropertyBag* pBag,IErrorLog *pErrorLog);
    STDMETHOD(Save)( 
            IPropertyBag *pPropBag,
            BOOL fClearDirty,
            BOOL fSaveAllProperties);
private:
   BOOL  g_fHaveLogFileName;
   LPSTR g_szLogFilePath;
};

#endif //__SINK_H_