Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

323 lines
7.7 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. UnInsCheck.cpp
  5. Abstract:
  6. Dialog to check for type of uninstall.
  7. Author:
  8. Rohde Wakefield [rohde] 09-Oct-1997
  9. Revision History:
  10. Carl Hagerstrom [carlh] 20-Aug-1998
  11. Changed the dialog for uninstalling Remote Storage. All local fixed
  12. volumes on the Remote Storage server are scanned for the existence
  13. of Remote Storage reparse points. If Remote Storage data exists, the
  14. user is told, on the Remote Storage Uninstall Check Wizard Page,
  15. which volumes contain this data. The user is given the choice of
  16. deleting only Remote Storage executables, deleting executables and
  17. Remote Storage data, or cancelling from "Add or Remove Optional
  18. Components".
  19. Mike Moore [mmoore] 20-Oct-1998
  20. Changed the property page to a dialog.
  21. --*/
  22. #include "stdafx.h"
  23. #include "UnInsChk.h"
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CUninstallCheck property page
  26. /*++
  27. Implements:
  28. CUninstallCheck Constructor
  29. Routine Description:
  30. Performs initialization.
  31. Arguments:
  32. pOptCom - points to optional component object
  33. --*/
  34. CUninstallCheck::CUninstallCheck(CRsOptCom* pOptCom) :
  35. CDialog(IDD), m_pOptCom(pOptCom)
  36. {
  37. m_dataLoss = FALSE;
  38. m_pUninst = (CRsUninstall*)m_pOptCom;
  39. //{{AFX_DATA_INIT(CUninstallCheck)
  40. // NOTE: the ClassWizard will add member initialization here
  41. //}}AFX_DATA_INIT
  42. }
  43. /*++
  44. Implements:
  45. CUninstallCheck Destructor
  46. --*/
  47. CUninstallCheck::~CUninstallCheck()
  48. {
  49. }
  50. /*++
  51. Implements:
  52. CUninstallCheck::DoDataExchange
  53. Routine Description:
  54. Calls CRsPropertyPage::DoDataExchange.
  55. Arguments:
  56. pDx - a pointer to a CDataExchange object
  57. --*/
  58. void CUninstallCheck::DoDataExchange(CDataExchange* pDX)
  59. {
  60. CDialog::DoDataExchange(pDX);
  61. //{{AFX_DATA_MAP(CUninstallCheck)
  62. // NOTE: the ClassWizard will add DDX and DDV calls here
  63. //}}AFX_DATA_MAP
  64. }
  65. BEGIN_MESSAGE_MAP(CUninstallCheck, CDialog)
  66. //BEGIN_MESSAGE_MAP(CUninstallCheck, CDialog)
  67. //{{AFX_MSG_MAP(CUninstallCheck)
  68. //}}AFX_MSG_MAP
  69. END_MESSAGE_MAP()
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CUninstallCheck message handlers
  72. /*++
  73. Implements:
  74. CUninstallCheck::OnInitDialog
  75. Routine Description:
  76. Call the CDialog::OnInitDialog, check the remove executables radio button,
  77. uncheck the remove everything button, and fill the list box with volumes.
  78. Return Value:
  79. TRUE if no exceptions are thrown.
  80. --*/
  81. BOOL CUninstallCheck::OnInitDialog()
  82. {
  83. BOOL bRet = CDialog::OnInitDialog();
  84. HRESULT hr = S_OK;
  85. WCHAR* volName = (WCHAR*)0;
  86. DWORD volCount = 0;
  87. CRsClnServer* pRsCln = m_pUninst->m_pRsCln;
  88. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  89. try
  90. {
  91. // Set the font to bold for Remove Options
  92. LOGFONT logfont;
  93. CFont * tempFont = GetFont( );
  94. tempFont->GetLogFont( &logfont );
  95. logfont.lfWeight = FW_BOLD;
  96. m_boldShellFont.CreateFontIndirect( &logfont );
  97. CStatic* pRemOpts = (CStatic*)GetDlgItem(IDC_STATIC_REM_OPTS);
  98. pRemOpts->SetFont( &m_boldShellFont );
  99. CListBox* pListBox = (CListBox*)GetDlgItem(IDC_DIRTY_VOLUMES);
  100. pListBox->ResetContent();
  101. CButton* pBtn;
  102. pBtn = (CButton*)GetDlgItem(IDC_REMOVE_EXECUTABLES);
  103. pBtn->SetCheck(1);
  104. pBtn = (CButton*)GetDlgItem(IDC_REMOVE_EVERYTHING);
  105. pBtn->SetCheck(0);
  106. RsOptAffirmDw(pRsCln->FirstDirtyVolume(&volName));
  107. while (volName)
  108. {
  109. pListBox->AddString(volName);
  110. RsOptAffirmDw(pRsCln->NextDirtyVolume(&volName));
  111. }
  112. }
  113. RsOptCatch(hr);
  114. if ( FALSE == bRet )
  115. {
  116. EndDialog( IDCANCEL );
  117. }
  118. return bRet;
  119. }
  120. /////////////////////////////////////////////////////////////////////////////
  121. // CUninstallCheck message handlers
  122. /*++
  123. Implements:
  124. CUninstallCheck::DoModal
  125. Routine Description:
  126. Determine whether the Uninstall Check dialog should be made active,
  127. and if so, what should be displayed on it.
  128. The local fixed disk volumes are scanned for Remote Storage data.
  129. During the scan, an hourglass cursor and a modeless dialog,
  130. explaining that the scan is in progress, appear. If there is Remote
  131. Storage data, the Uninstall Check dialog will show a list box containing the
  132. volumes with Remote Storage data, instructions, and a set of radio buttons
  133. with uninstall options.
  134. Return Value:
  135. S_OK if no exceptions are thrown and the user selected OK.
  136. RSOPTCOM_ID_CANCELLED if the user selected cancel.
  137. --*/
  138. INT_PTR CUninstallCheck::DoModal()
  139. {
  140. HRESULT hr = S_OK;
  141. WCHAR* volName = (WCHAR*)0;
  142. DWORD volCount = 0;
  143. CRsClnServer* pRsCln = m_pUninst->m_pRsCln;
  144. INT_PTR nRet = IDOK;
  145. try {
  146. //
  147. // Enclose wait cursor in its own block of applicable
  148. // code. We want it gone before we Go Modal
  149. //
  150. {
  151. CWaitCursor cursor;
  152. CDialog dialog(IDD_SCAN_WAIT);
  153. dialog.Create(IDD_SCAN_WAIT);
  154. Sleep(1000); // allow the user to see the dialog for at
  155. // least a second when the scan is very fast
  156. RsOptAffirmDw(pRsCln->ScanServer(&volCount));
  157. }
  158. if( volCount > 0 ) {
  159. m_dataLoss = TRUE;
  160. nRet = CDialog::DoModal();
  161. }
  162. } RsOptCatch( hr );
  163. return( nRet );
  164. }
  165. /*++
  166. Implements:
  167. CUninstallCheck::OnOk
  168. Routine Description:
  169. When the OK button is pushed, check the radio button. If the
  170. user wants everything removed, set a flag in the uninstall object
  171. to reflect this.
  172. When this flag is set, uninstall will remove all Remote Storage
  173. reparse points, all truncated files and the Remote Storage directory.
  174. A message box will give the user a final warning before removing data.
  175. Return Value:
  176. void
  177. --*/
  178. void CUninstallCheck::OnOK()
  179. {
  180. TRACEFN("CUninstallCheck::OnOK");
  181. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  182. HRESULT hr = S_OK;
  183. CButton* pBtn = (CButton*)GetDlgItem(IDC_REMOVE_EVERYTHING);
  184. if (m_dataLoss)
  185. {
  186. try
  187. {
  188. if (1 == pBtn->GetCheck())
  189. {
  190. if (IDCANCEL == AfxMessageBox(IDS_POSSIBLE_DATA_LOSS, MB_ICONSTOP | MB_OKCANCEL))
  191. {
  192. m_pUninst->m_removeRsData = FALSE;
  193. }
  194. else
  195. {
  196. m_pUninst->m_removeRsData = TRUE;
  197. CDialog::OnOK();
  198. }
  199. }
  200. else
  201. {
  202. m_pUninst->m_removeRsData = FALSE;
  203. CDialog::OnOK();
  204. }
  205. }
  206. RsOptCatch(hr);
  207. }
  208. }
  209. /*++
  210. Implements:
  211. CUninstallCheck::OnCancel
  212. Routine Description:
  213. When the Cancel button is pushed, the user has decided to unmanaged the
  214. volumes himself. So, from this point on the admin and engine pieces should not
  215. be removed if requested.
  216. Return Value:
  217. void
  218. --*/
  219. void CUninstallCheck::OnCancel()
  220. {
  221. m_pUninst->m_removeRsData = FALSE;
  222. CDialog::OnCancel();
  223. }