summaryrefslogtreecommitdiff
path: root/NSCmpts/Encrypt.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/Encrypt.cpp
Initial ImportHEADmaster
Diffstat (limited to 'NSCmpts/Encrypt.cpp')
-rw-r--r--NSCmpts/Encrypt.cpp144
1 files changed, 144 insertions, 0 deletions
diff --git a/NSCmpts/Encrypt.cpp b/NSCmpts/Encrypt.cpp
new file mode 100644
index 0000000..617dc69
--- /dev/null
+++ b/NSCmpts/Encrypt.cpp
@@ -0,0 +1,144 @@
+// Encrypt.cpp : Implementation of CEncrypt
+#include "stdafx.h"
+#include "NSCmpts.h"
+#include "Encrypt.h"
+#include "ProgressDlg.h"
+#include <appmisc.h>
+#include <commisc.h>
+
+/////////////////////////////////////////////////////////////////////////////
+// CEncrypt
+
+STDMETHODIMP CEncrypt::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;
+}
+
+STDMETHODIMP CEncrypt::DoShutdown(long hParent, long lMode)
+{
+ bool bPrompt = lMode & nsNoPrompt ? false : true;
+// bool bSilent = lMode & nsQuiet ? true : false;
+
+ // Put it out here so it'll stay in scope
+ m_bDisablePassword = m_Data.GetInt(NS_ENCRYPT_REG_DISABLE, false) ? true : false;
+
+ try
+ {
+ // Ask for Password here
+ if(m_xpyPass == NULL)
+ try_(m_xpyPass.CreateInstance(__uuidof(XpyEx)));
+
+ VARIANT_BOOL vbEnabled = m_xpyPass->Enabled[xpyMainPass];
+
+ if(!vbEnabled && bPrompt)
+ m_xpyPass->Prompt(hParent, xpyuiMainPassword);
+
+ vbEnabled = m_xpyPass->Enabled[xpyMainPass];
+
+ if(!vbEnabled)
+ return XPY_E_NO_PASSWORD;
+
+ }
+ catch(_com_error& e)
+ {
+ // These are big errors and means something's not
+ // set up properly. Make sure it gets user's attention
+ // can't just go into the log window
+
+ if(bPrompt)
+ {
+ string sMessage;
+ IErrorInfo* pError;
+ if(pError = e.ErrorInfo())
+ {
+ sMessage.format(IDS_ENCRYPT_ERR_XPY, e.Description());
+ pError->Release();
+ }
+ else
+ sMessage.format(IDS_ENCRYPT_ERR_XPY, e.ErrorMessage());
+
+ MessageBox((HWND)hParent, sMessage, _T("XPY Encryption Problem"), MB_OK | MB_ICONSTOP);
+ }
+
+ route_to_atl(e);
+ }
+
+ // Create the dialog
+ CActionProgressDlg dlgProgress(m_spUnkSite, IDD_PROGRESSENCRYPT);
+ dlgProgress.Create((HWND)hParent);
+ dlgProgress.PlayAmination(IDR_AVIENCRYPT);
+
+ CEncryptActions::EncryptPrepare* pAction = new CEncryptActions::EncryptPrepare;
+ HRESULT hr = pAction->Initialize(m_Data);
+
+ if(hr != S_OK)
+ return hr;
+
+ m_Engine.Add(pAction);
+
+ // Create the update_monitor
+ m_Engine.SetUpdates(dlgProgress, dlgProgress);
+
+ // start the backup
+ HANDLE hThread = m_Engine.StartThread();
+
+ WaitForAndIdle(1, &hThread, INFINITE);
+
+ hr = S_OK;
+ GetExitCodeThread(hThread, (LPDWORD)&hr);
+
+ dlgProgress.DestroyWindow();
+
+ return hr;
+
+}
+
+STDMETHODIMP CEncrypt::get_Info(NightSecInfo nsItem, VARIANT* pvVal)
+{
+ ::VariantClear(pvVal);
+
+ CComBSTR bsRetVal;
+
+ switch(nsItem)
+ {
+ case nsName:
+ pvVal->vt = VT_BSTR;
+ bsRetVal.LoadString(IDS_ENCRYPTNAME);
+ pvVal->bstrVal = bsRetVal;
+ return S_OK;
+ case nsHelpText:
+ pvVal->vt = VT_BSTR;
+ bsRetVal.LoadString(IDS_ENCRYPTDESC);
+ pvVal->bstrVal = bsRetVal;
+ return S_OK;
+ case nsCmdLine:
+ pvVal->vt = VT_BSTR;
+ bsRetVal.LoadString(IDS_ENCRYPTPARAM);
+ pvVal->bstrVal = bsRetVal;
+ return S_OK;
+ case nsForceShow:
+ 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 CEncrypt::SetData(IUnknown* pUnk)
+{
+ return m_Data.Initialize(pUnk);
+} \ No newline at end of file