#ifndef __WBEM_LOGFILE_CONSUMER__H_ #define __WBEM_LOGFILE_CONSUMER__H_ #include #include #include #include "txttempl.h" #include class CLogFileConsumer : public CUnk { protected: class XProvider : public CImpl { public: XProvider(CLogFileConsumer* pObj) : CImpl(pObj){} HRESULT STDMETHODCALLTYPE FindConsumer( IWbemClassObject* pLogicalConsumer, IWbemUnboundObjectSink** ppConsumer); } m_XProvider; friend XProvider; class XInit : public CImpl { public: XInit(CLogFileConsumer* pObj) : CImpl(pObj){} HRESULT STDMETHODCALLTYPE Initialize( LPWSTR, LONG, LPWSTR, LPWSTR, IWbemServices*, IWbemContext*, IWbemProviderInitSink*); } m_XInit; friend XInit; public: CLogFileConsumer(CLifeControl* pControl = NULL, IUnknown* pOuter = NULL) : CUnk(pControl, pOuter), m_XProvider(this), m_XInit(this) {} ~CLogFileConsumer(){} void* GetInterface(REFIID riid); }; class CLogFileSink : public CUnk { protected: class XSink : public CImpl { public: XSink(CLogFileSink* pObj) : CImpl(pObj){} HRESULT STDMETHODCALLTYPE IndicateToConsumer( IWbemClassObject* pLogicalConsumer, long lNumObjects, IWbemClassObject** apObjects); } m_XSink; friend XSink; protected: CTextTemplate m_Template; WString m_wsFile; // determines whether file is too large, archives old if needed // probably returns INVALID_HANDLE_VALUE on error HRESULT GetFileHandle(HANDLE& handle); // don't access this directly. use GetFileHandle HANDLE m_hFile; ErrorObj* m_pErrorObj; bool m_bUnicode; // do the file be unicode? UINT64 m_maxFileSize; bool IsFileTooBig(UINT64 maxFileSize, HANDLE hFile); bool IsFileTooBig(UINT64 maxFileSize, WString& fileName); HRESULT ArchiveFile(WString& fileName); bool GetNumericExtension(WCHAR* pName, int& foundNumber); void OpenThisFile(WString fname, bool openExisting, bool allowDelete); void CloseCurrentFile(); public: CLogFileSink(CLifeControl* pControl = NULL) : CUnk(pControl), m_XSink(this),m_pErrorObj(NULL), m_hFile(INVALID_HANDLE_VALUE), m_maxFileSize(0), m_bUnicode(false) {} HRESULT Initialize(IWbemClassObject* pLogicalConsumer); ~CLogFileSink(); void* GetInterface(REFIID riid); }; #endif