// NightSecError.h: Definition of the CNightSecError class // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_NIGHTSECERROR_H__F6662FF3_94AB_11D3_BFC4_0020182B97FC__INCLUDED_) #define AFX_NIGHTSECERROR_H__F6662FF3_94AB_11D3_BFC4_0020182B97FC__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "resource.h" // main symbols #include "../common/Defines.h" #include "../common/interfaces.h" #include "ActionEngine.h" ///////////////////////////////////////////////////////////////////////////// // CXXXXErrorImpl: A COM object that gets added to INightSecErrorLog on // the host class CBaseErrorImpl : public INightSecError { public: CBaseErrorImpl() : m_lHelpContext(0) {}; // Set the error codes for this object void SetError(const string& sDesc, HRESULT hRes, LPCTSTR szHelpFile = _T(""), long lHelpContext = 0); void SetError(const string& sDesc, HRESULT hRes, long lHelpContext) { SetError(sDesc, hRes, NS_HELP_FILE, lHelpContext); } // INightSecError public: STDMETHOD(get_Err)(/*[out, retval]*/ HRESULT* phRet) { *phRet = m_hRes; return S_OK; } STDMETHOD(get_Description)(/*[out, retval]*/ BSTR* pbsRet) { *pbsRet = m_bsDescription.Copy(); return S_OK; } STDMETHOD(get_HelpFile)(/*[out, retval]*/ BSTR* pbsRet) { *pbsRet = m_bsHelpFile.Copy(); return S_OK; } STDMETHOD(get_HelpContext)(/*[out, retval]*/ long* plRet) { *plRet = m_lHelpContext; return S_OK; } protected: CComBSTR m_bsDescription; // Description of Error CComBSTR m_bsHelpFile; // Helpfile for Error long m_lHelpContext; // Location in Help File HRESULT m_hRes; // Original HRESULT }; //////////////////////////////////////////////////////////////// // This is a special case CBaseErrorImpl that wraps a // CAction class CActionErrorImpl : public CComObjectRoot, public CBaseErrorImpl, public INightSecErrorFix { // Construction public: CActionErrorImpl() { m_pAction = NULL; }; ~CActionErrorImpl() { m_pAction->release(); } // Attach to this action (addrefs) void Attach(CAction* pAction); // COM MAP BEGIN_COM_MAP(CActionErrorImpl) COM_INTERFACE_ENTRY(INightSecError) COM_INTERFACE_ENTRY(INightSecErrorFix) END_COM_MAP() DECLARE_NOT_AGGREGATABLE(CActionErrorImpl) // INightSecErrorFix public: STDMETHOD(Fix)(); STDMETHOD(get_Fixable)(/*[out, retval]*/ BOOL* pbRet); STDMETHOD(Retry)(); STDMETHOD(get_Retryable)(/*[out, retval]*/ BOOL* pbRet); protected: CAction* m_pAction; // Action that caused the error }; /////////////////////////////////////////////////////////// // Special Case CBaseErrorIpml that wraps a // ISecureShutdownWin Object class CNightSecErrorImpl : public CComObjectRoot, public CBaseErrorImpl, public INightSecErrorFix { // Construction public: CNightSecErrorImpl() { m_pShutdown = NULL; }; ~CNightSecErrorImpl() { if(m_pShutdown) m_pShutdown->Release(); } // Attach to object (addrefs) void Attach(ISecureShutdownWin* pShutdown); // COM MAP BEGIN_COM_MAP(CActionErrorImpl) COM_INTERFACE_ENTRY(INightSecError) COM_INTERFACE_ENTRY(INightSecErrorFix) END_COM_MAP() DECLARE_NOT_AGGREGATABLE(CActionErrorImpl) // INightSecErrorFix public: STDMETHOD(Fix)() { return E_FAIL; }; STDMETHOD(get_Fixable)(/*[out, retval]*/ BOOL* pbRet) { *pbRet = FALSE; return S_OK; }; STDMETHOD(Retry)(); STDMETHOD(get_Retryable)(/*[out, retval]*/ BOOL* pbRet) { *pbRet = TRUE; return S_OK; }; protected: ISecureShutdownWin* m_pShutdown; // Object that caused the error }; #endif // !defined(AFX_NIGHTSECERROR_H__F6662FF3_94AB_11D3_BFC4_0020182B97FC__INCLUDED_)