summaryrefslogtreecommitdiff
path: root/NSCmpts/NightSecError.h
blob: 164c5fb961a557a4d964c0b9c71f60530bf76355 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// 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_)