diff options
author | Stef Walter <stef@thewalter.net> | 2003-09-17 19:07:23 +0000 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2003-09-17 19:07:23 +0000 |
commit | 3f95d417d9e623ac0c74df8ef11d7a01846392dd (patch) | |
tree | 45ec73f2dc07eafd7f41a6f62a8cdfbaa279469f /NSCmpts/Backup.cpp |
Diffstat (limited to 'NSCmpts/Backup.cpp')
-rw-r--r-- | NSCmpts/Backup.cpp | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/NSCmpts/Backup.cpp b/NSCmpts/Backup.cpp new file mode 100644 index 0000000..5f108bd --- /dev/null +++ b/NSCmpts/Backup.cpp @@ -0,0 +1,177 @@ +// Backup.cpp : Implementation of CBackup + +#include "stdafx.h" +#include "NSCmpts.h" +#include "Backup.h" +#include "ProgressDlg.h" +#include <appmisc.h> + +///////////////////////////////////////////////////////////////////////////// +// CBackup + +STDMETHODIMP CBackup::InterfaceSupportsErrorInfo(REFIID riid) +{ + static const IID* arr[] = + { + &IID_ISecureShutdownWin + }; + for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++) + { + if (InlineIsEqualGUID(*arr[i],riid)) + return S_OK; + } + return S_FALSE; +} + +ATL_PROPMAP_ENTRY* CBackup::GetPropertyMap() +{ + // Depending on the mode of the wizard + // return a different set of property papges + + // This is the Normal set without the advanced page + static ATL_PROPMAP_ENTRY pNormalPropMap[] = + { + PROP_PAGE(CLSID_BackupSourceProp) + PROP_PAGE(CLSID_BackupDestProp) + {NULL, 0, NULL, &IID_NULL, 0, 0, 0} + }; + + // All the property pages + static ATL_PROPMAP_ENTRY pAdvancedPropMap[] = + { + PROP_PAGE(CLSID_BackupSourceProp) + PROP_PAGE(CLSID_BackupDestProp) + PROP_PAGE(CLSID_BackupAdvancedProp) + {NULL, 0, NULL, &IID_NULL, 0, 0, 0} + }; + + // Try and see which mode the wizard is in + INightSecSiteInfoPtr pInfo = (IUnknown*)m_spUnkSite; + if(pInfo) + { + // Get the Info from the Site + CComVariant var; + pInfo->get_Info(nsAdvanced, &var); + + if(var.vt == VT_BOOL && var.bVal == TRUE) + return pAdvancedPropMap; + } + + return pNormalPropMap; +} + +/*static DWORD CALLBACK BackupProc(LPVOID lpParam) +{ + CActionEngine* pEngine = (CActionEngine*)lpParam; + return pEngine->Start(); +} +*/ + +STDMETHODIMP CBackup::DoShutdown(long hParent, long lMode) +{ + // Whether or not to show prompts + bool bPrompt = lMode & nsNoPrompt ? false : true; + + // We don't support this option yet + // bool bSilent = lMode & nsQuiet ? true : false; + + // Create the dialog + CActionProgressDlg dlgProgress(m_spUnkSite, IDD_PROGRESSBACKUP); + dlgProgress.Create((HWND)hParent); + dlgProgress.PlayAmination(IDR_AVIBACKUP); + + // Create the first Action + string sTemp = m_Data.GetString(NS_BACKUP_REG_ENGINE, _T("Archive")); + + HRESULT hr = S_OK; + + // Date based backup + if(sTemp == _T("Date")) + { + CBackupActions::DatePrepare* pAction = new CBackupActions::DatePrepare; + hr = pAction->Initialize(m_Data); + m_Engine.Add(pAction); + } + // Archive Based Backup + else + { + CBackupActions::ArchivePrepare* pAction = new CBackupActions::ArchivePrepare; + hr = pAction->Initialize(m_Data); + m_Engine.Add(pAction); + } + + if(FAILED(hr)) + { + if(bPrompt) + MessageBoxTimeout((HWND)hParent, _T("The backup options aren't set up correctly. \n\nRun Night Security Checklist to set the options."), _T("Night Security Backup"), MB_OK | MB_ICONWARNING, 15000, 5000); + + dlgProgress.DestroyWindow(); + return E_INVALIDARG; + } + + // Init the update_monitor + m_Engine.SetUpdates(dlgProgress, dlgProgress); + + // start the backup + HANDLE hThread = m_Engine.StartThread(); + + // Wait for the Thread + WaitForAndIdle(1, &hThread, INFINITE); + + // Get the HRESULT from the Thread + GetExitCodeThread(hThread, (LPDWORD)&hr); + + // Close Dialog + dlgProgress.DestroyWindow(); + + return hr; +} + +// Gets Miscellaneous Info about the Object +STDMETHODIMP CBackup::get_Info(NightSecInfo nsItem, VARIANT* pvVal) +{ + ::VariantClear(pvVal); + + CComBSTR bsRetVal; + + switch(nsItem) + { + case nsName: + pvVal->vt = VT_BSTR; + bsRetVal.LoadString(IDS_BACKUPNAME); + pvVal->bstrVal = bsRetVal; + return S_OK; + case nsHelpText: + pvVal->vt = VT_BSTR; + bsRetVal.LoadString(IDS_BACKUPDESC); + pvVal->bstrVal = bsRetVal; + return S_OK; + case nsCmdLine: + pvVal->vt = VT_BSTR; + bsRetVal.LoadString(IDS_BACKUPPARAM); + pvVal->bstrVal = bsRetVal; + return S_OK; + case nsForceShow: // We have to have our pages shown + pvVal->vt = VT_BOOL; + pvVal->bVal = TRUE; + return S_OK; + case nsCopyAble: + pvVal->vt = VT_BOOL; + pvVal->bVal = TRUE; + return S_OK; + } + + return S_FALSE; +} + +STDMETHODIMP CBackup::SetData(IUnknown* pUnk) +{ + return m_Data.Initialize(pUnk); +} + +/*UINT CBackup::LoadPaths() +{ + m_destPath = m_Data.GetString(NS_BACKUP_REG_DEST, _T("")); + return m_Data.GetStringSet(NS_BACKUP_REG_SOURCE, m_srcPaths); +} +*/ |