summaryrefslogtreecommitdiff
path: root/NSCmpts/NightSecError.cpp
diff options
context:
space:
mode:
authorStef Walter <stef@thewalter.net>2003-09-17 19:07:23 +0000
committerStef Walter <stef@thewalter.net>2003-09-17 19:07:23 +0000
commit3f95d417d9e623ac0c74df8ef11d7a01846392dd (patch)
tree45ec73f2dc07eafd7f41a6f62a8cdfbaa279469f /NSCmpts/NightSecError.cpp
Initial ImportHEADmaster
Diffstat (limited to 'NSCmpts/NightSecError.cpp')
-rw-r--r--NSCmpts/NightSecError.cpp176
1 files changed, 176 insertions, 0 deletions
diff --git a/NSCmpts/NightSecError.cpp b/NSCmpts/NightSecError.cpp
new file mode 100644
index 0000000..252c19a
--- /dev/null
+++ b/NSCmpts/NightSecError.cpp
@@ -0,0 +1,176 @@
+// NightSecError.cpp : Implementation of CNSCmptsApp and DLL registration.
+
+#include "stdafx.h"
+#include "NSCmpts.h"
+#include "NightSecError.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// Set the current error to
+void CBaseErrorImpl::SetError(const string& sDesc, HRESULT hRes,
+ LPCTSTR szHelpFile /*= _T("")*/, long lHelpContext /*= 0*/)
+{
+ // Initialize Other Stuff
+ m_hRes = hRes;
+ m_bsDescription = sDesc;
+ m_bsHelpFile = szHelpFile;
+ m_lHelpContext = lHelpContext;
+}
+
+/*void CActionErrorImpl::SetError(CAction* pAction, const string& sDesc, HRESULT hRes,
+ LPCTSTR szHelpFile, long lHelpContext)
+{
+ // Attach to Action
+ m_pAction = pAction;
+ pAction->addref();
+
+ CBaseErrorImpl::SetError(sDesc, hRes, szHelpFile, lHelpContext);
+}
+*/
+
+void CActionErrorImpl::Attach(CAction* pAction)
+{
+ // Attach to Action
+ ASSERT(pAction);
+ m_pAction = pAction;
+ pAction->addref();
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Fix the error
+
+STDMETHODIMP CActionErrorImpl::Fix()
+{
+ // Sanity Checks
+ ASSERT(m_pAction);
+ ASSERT(m_pAction->IsFixable(m_hRes));
+
+ if(!m_pAction)
+ return E_UNEXPECTED;
+ if(!m_pAction->IsFixable(m_hRes))
+ return E_FAIL;
+
+ // Fix it
+ try
+ {
+ m_pAction->Fix(m_hRes);
+
+ // Clear error information
+ m_bsDescription = _T("Fixed Successfully");
+ m_hRes = S_OK;
+ m_lHelpContext = 0;
+ }
+ catch(CActionError& err)
+ {
+ // Set new error information
+ m_hRes = err.m_hRes;
+ m_bsDescription = err.m_sDesc;
+ m_lHelpContext = 0;
+ }
+
+ return m_hRes;
+}
+
+
+///////////////////////////////////////////////////////////////////
+// Check if fixable
+
+STDMETHODIMP CActionErrorImpl::get_Fixable(/*[out, retval]*/ BOOL* pbRet)
+{
+ ASSERT(m_pAction);
+
+ if(!m_pAction)
+ return E_UNEXPECTED;
+
+ *pbRet = m_pAction->IsFixable(m_hRes) ? TRUE : FALSE;
+
+ return S_OK;
+}
+
+////////////////////////////////////////////////////////////////////
+// Retry the action
+
+STDMETHODIMP CActionErrorImpl::Retry()
+{
+ // Sanity Checks
+
+ ASSERT(m_pAction);
+ ASSERT(m_pAction->IsRetryable());
+
+ if(!m_pAction)
+ return E_UNEXPECTED;
+ if(!m_pAction->IsRetryable())
+ return E_FAIL;
+
+ // Do it Again
+ try
+ {
+ m_pAction->Do(NULL, NULL);
+
+ // Clear error Information
+ m_hRes = S_OK;
+ m_bsDescription = _T("Completed Successfully");
+ m_lHelpContext = 0;
+ }
+ catch(CActionError& err)
+ {
+ // Set New Error Information
+ m_hRes = err.m_hRes;
+ m_bsDescription = err.m_sDesc;
+ m_lHelpContext = 0;
+ }
+
+ return m_hRes;
+
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Check if retryable
+
+STDMETHODIMP CActionErrorImpl::get_Retryable(/*[out, retval]*/ BOOL* pbRet)
+{
+ ASSERT(m_pAction);
+
+ if(!m_pAction)
+ return E_UNEXPECTED;
+
+ *pbRet = m_pAction->IsRetryable() ? TRUE : FALSE;
+
+ return S_OK;
+}
+
+void CNightSecErrorImpl::Attach(ISecureShutdownWin* pShutdown)
+{
+ // Attach to Secure Shutdown
+ ASSERT(pShutdown);
+ m_pShutdown = pShutdown;
+ m_pShutdown->AddRef();
+}
+
+
+////////////////////////////////////////////////////////////////////
+// Retry the action
+
+STDMETHODIMP CNightSecErrorImpl::Retry()
+{
+ // Sanity Checks
+ ASSERT(m_pShutdown);
+
+ if(!m_pShutdown)
+ return E_UNEXPECTED;
+
+
+ // Do it Again
+ HRESULT hr = m_pShutdown->DoShutdown(NULL, 0);
+
+ if(SUCCEEDED(hr))
+ {
+ // Clear error Information
+ m_hRes = S_OK;
+ m_bsDescription = _T("Completed Successfully");
+ m_lHelpContext = 0;
+ }
+ // Otherwise it should have filled us up with new error info
+
+ return m_hRes;
+}