Platform SDK: SMTP Server Events |
[This is preliminary documentation and subject to change.]
The ISMTPStoreDriver::Init method is called by the SMTP service to initialize each instance of a store driver.
HRESULT Init( [in] DWORD dwInstance, [in,unique] IUnknown *pBinding, [in] IUnknown *pServer, [in] DWORD dwReason, [out] IUnknown **ppStoreDriver );
Value | Description |
---|---|
E_NOTIMPL | Error. This method is not implemented. |
ERROR_ALREADY_INITIALIZED | Error. The store driver is already initialized (FACILITY_WIN32). |
ERROR_SHUTDOWN_IN_PROGRESS | Error. The store driver object is shutting down (FACILITY_WIN32). |
Through this call a store driver object receives initialization information from the SMTP virtual service. This information includes the instance number of the server, a pointer to the binding information for the store driver event binding, a reference to an object exposing the ISMTPServer interface, and a flag indicating the reason for the call. By examining the parameters, the store driver can determine if another instance of this store driver class is available, and whether the binding options are similar enough that that previous instance is still valid. If so, then the store driver can return a pointer to the previous instance, causing the virtual server to make all further calls on that previous instance. Caching instances of store drivers, however, is not required.
During the Init method, store drivers normally read configuration information used to persist message content and property streams. For example, the default SMTP (NTFS) store driver uses the ISMTPServer interface to read metabase properties identifying the Queue and Drop directory locations for the particular virtual server instance. Messages delivered locally are copied to the Drop directory location, and undelivered messages are temporarily stored in the Queue directory.
The Init function is called each time a new store driver is created. For performance reasons, it is best to expose an implementation of the IEventIsCacheable::IsCacheable method that returns S_OK, indicating to the event dispatcher that the object can be cached for subsequent use. The SMTP dispatcher makes repeated calls to the store driver object to allocate backing store for messages (IMailMsgStoreDriver::AllocMessage), close content handles (IMailMsgStoreDriver::CloseContentHandle), and delete backing store files (IMailMsgStoreDriver::Delete). If the object is not cached, each new instance will be re-initialized for each of the above calls.
ISMTPStoreDriver::PrepareForShutdown, ISMTPStoreDriver::Shutdown