From 3f95d417d9e623ac0c74df8ef11d7a01846392dd Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 17 Sep 2003 19:07:23 +0000 Subject: Initial Import --- Shutdown/ShutdownApp.cpp | 128 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 Shutdown/ShutdownApp.cpp (limited to 'Shutdown/ShutdownApp.cpp') diff --git a/Shutdown/ShutdownApp.cpp b/Shutdown/ShutdownApp.cpp new file mode 100644 index 0000000..714fe55 --- /dev/null +++ b/Shutdown/ShutdownApp.cpp @@ -0,0 +1,128 @@ +// ShutdownApp.cpp: implementation of the CShutdownApp class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "ShutdownApp.h" + +#include + +#include "batchfilecmpt.h" +#include +#include "itemdlg.h" + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CShutdownApp::CShutdownApp() + : CNightSecApp(_T("Secure Shutdown"), _T("NightSecurity.SecureShutdown.{2ED9B360-F6EF-11d2-A5A1-0020182B97FC}")) +{ } + +CShutdownApp::~CShutdownApp() +{ } + +bool CShutdownApp::InitInstance() +{ + // If more than one instance bail out early + if(m_oneInstance.IsAlreadyLoaded()) + { + m_oneInstance.FindAndActivate(_T("#32770"), _T("Secure Shutdown")); + return false; + } + + if(!CNightSecApp::InitInstance()) + return false; + + // If the checklist hasn't been run all the way through yet + // then... + if(!m_settings.GetInt(IS_SETUP_KEY, 0)) + { + // Ask if they'd like to fill it out + if(::MessageBox(NULL, _T("You haven't filled out the Night Security checklist yet. Would you like to do that now?."), _T("Secure Shutdown"), MB_ICONQUESTION | MB_YESNO) == IDYES) + { + // Start the Checklist Program + if(ShellExecute(NULL, _T("open"), string(GetProgramFolder(_Module.m_hInst) + _T("Checklist.exe")), NULL, "", SW_SHOWNORMAL) <= (HINSTANCE)32) + ::MessageBox(NULL, _T("Couldn't start Night Security Checklist. Make sure it's installed properly."), _T("Secure Shutdown"), MB_ICONSTOP); + + return false; + } + + // Only ask'm once. If they answer 'no' then don't bother'm + // again + m_settings.WriteInt(IS_SETUP_KEY, 1); + + } + + g_site.SetSite(); + + // Do the actual shutdown + DoShutdown(NULL); + + // If any components changed data + g_aComponents.SaveComponentData(); + + g_site.ClearSite(); + + // Since the dialog has been closed, return FALSE so that we exit the + // application, rather than start the application's message pump. + return false; +} + +HRESULT CShutdownApp::DoShutdown(HWND hwndParent, long lOptions) +{ + // ... Add Entry for Batchfile Creation Components (host based) + // into array + g_aComponents.push_back(new CBatchFileCmpt); + + // Create Progress Dialog + g_site.m_dlgItems.Create(NULL); + + g_site.m_log.Init(g_site.m_dlgItems); + + // Now comes the real stuff + HRESULT hr = S_OK; + MSG msg; + + int nCurPos = 0; + + // Call Do Shutdown for All Windows Components + for(int nCnt = 0; nCnt < g_aComponents.size(); nCnt++) + { + // If it's a Windows Component + if(g_aComponents[nCnt]->GetType() == COMPONENT_WIN) + { + // If it's currently active + if(g_aComponents[nCnt]->IsEnabled()) + { + // Make Entry Active + g_site.m_dlgItems.SetCurrentItem(nCurPos); + + PEEK_ALL_MESSAGES(msg); + + // Call Shutdown + hr = g_aComponents[nCnt]->DoShutdown(lOptions, g_site.m_dlgItems); + + // Was Component Cancelled? + // All nicely behaved components return E_ABORT + // on cancel + if(hr == E_ABORT) + return E_ABORT; + + // Check it off + // (Check it with a false if failed) + g_site.m_dlgItems.CheckOffItem(nCurPos, SUCCEEDED(hr)); + + PEEK_ALL_MESSAGES(msg); + + // Is Dialog Cancelled? + if(g_site.m_dlgItems.IsCancelled()) + return E_ABORT; + + nCurPos++; + } + } + } + + return S_OK; +} \ No newline at end of file -- cgit v1.2.3