Source code of Windows XP (NT5)
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.

195 lines
4.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: aret.cpp
  7. //
  8. // Contents: implementation of CAttrRet
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "wsecmgr.h"
  13. #include "resource.h"
  14. #include "snapmgr.h"
  15. #include "attr.h"
  16. #include "ARet.h"
  17. #include "util.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CAttrRet dialog
  25. CAttrRet::CAttrRet(UINT nTemplateID)
  26. : CAttribute(nTemplateID ? nTemplateID : IDD)
  27. {
  28. //{{AFX_DATA_INIT(CAttrRet)
  29. m_strAttrName = _T("");
  30. m_strLastInspect = _T("");
  31. m_rabRetention = -1;
  32. //}}AFX_DATA_INIT
  33. m_StartIds = IDS_AS_NEEDED;
  34. m_pHelpIDs = (DWORD_PTR)a189HelpIDs;
  35. m_uTemplateResID = IDD;
  36. }
  37. void CAttrRet::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CAttribute::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CAttrRet)
  41. // DDX_Text(pDX, IDC_ATTRIBUTE_NAME, m_strAttrName);
  42. DDX_Text(pDX, IDC_LAST_INSPECT, m_strLastInspect);
  43. DDX_Radio(pDX, IDC_RETENTION, m_rabRetention);
  44. //}}AFX_DATA_MAP
  45. }
  46. BEGIN_MESSAGE_MAP(CAttrRet, CAttribute)
  47. //{{AFX_MSG_MAP(CAttrRet)
  48. ON_BN_CLICKED(IDC_RETENTION, OnRetention)
  49. ON_BN_CLICKED(IDC_RADIO2, OnRetention)
  50. ON_BN_CLICKED(IDC_RADIO3, OnRetention)
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CAttrRet message handlers
  55. BOOL CAttrRet::OnInitDialog()
  56. {
  57. CAttribute::OnInitDialog();
  58. AddUserControl(IDC_RETENTION);
  59. AddUserControl(IDC_RADIO2);
  60. AddUserControl(IDC_RADIO3);
  61. EnableUserControls(m_bConfigure);
  62. return TRUE; // return TRUE unless you set the focus to a control
  63. // EXCEPTION: OCX Property Pages should return FALSE
  64. }
  65. BOOL CAttrRet::OnApply()
  66. {
  67. if ( !m_bReadOnly )
  68. {
  69. LONG_PTR dw = 0;
  70. int status = 0;
  71. UpdateData(TRUE);
  72. if (!m_bConfigure)
  73. dw = (LONG_PTR)ULongToPtr(SCE_NO_VALUE);
  74. else
  75. {
  76. switch(m_rabRetention)
  77. {
  78. case RADIO_RETAIN_BY_DAYS:
  79. dw = SCE_RETAIN_BY_DAYS;
  80. break;
  81. case RADIO_RETAIN_AS_NEEDED:
  82. dw = SCE_RETAIN_AS_NEEDED;
  83. break;
  84. case RADIO_RETAIN_MANUALLY:
  85. dw = SCE_RETAIN_MANUALLY;
  86. break;
  87. }
  88. }
  89. CEditTemplate *pet = m_pSnapin->GetTemplate(GT_COMPUTER_TEMPLATE,AREA_SECURITY_POLICY);
  90. //
  91. // Check dependecies for this item.
  92. //
  93. if(DDWarn.CheckDependencies(
  94. (DWORD)dw
  95. ) == ERROR_MORE_DATA ){
  96. //
  97. // If it fails and the user presses cancel then we will exit and do nothing.
  98. //
  99. CThemeContextActivator activator;
  100. if( DDWarn.DoModal() != IDOK){
  101. return FALSE;
  102. }
  103. //
  104. // If the user presses autoset then we set the item and update the result panes.
  105. //
  106. for(int i = 0; i < DDWarn.GetFailedCount(); i++){
  107. PDEPENDENCYFAILED pItem = DDWarn.GetFailedInfo(i);
  108. if(pItem && pItem->pResult ){
  109. pItem->pResult->SetBase( pItem->dwSuggested );
  110. status = m_pSnapin->SetAnalysisInfo(pItem->pResult->GetID(),
  111. pItem->dwSuggested,
  112. pItem->pResult);
  113. pItem->pResult->SetStatus(status); //Raid #249167, 4/21/2001
  114. pItem->pResult->Update(m_pSnapin, FALSE);
  115. }
  116. }
  117. }
  118. m_pData->SetBase(dw);
  119. status = m_pSnapin->SetAnalysisInfo(m_pData->GetID(),dw, m_pData);
  120. m_pData->SetStatus(status);
  121. m_pData->Update(m_pSnapin, FALSE);
  122. }
  123. return CAttribute::OnApply();
  124. }
  125. void CAttrRet::Initialize(CResult * pData)
  126. {
  127. LONG_PTR dw = 0;
  128. CAttribute::Initialize(pData);
  129. DDWarn.InitializeDependencies(m_pSnapin,pData);
  130. m_StartIds = IDS_AS_NEEDED;
  131. //
  132. // Display the last inspected setting in its static box
  133. //
  134. pData->GetDisplayName( NULL, m_strLastInspect, 2 );
  135. // Set the template setting radio button appropriately
  136. // m_strAttrName = pData->GetAttrPretty();
  137. dw = pData->GetBase();
  138. if ((LONG_PTR)ULongToPtr(SCE_NO_VALUE) == dw) {
  139. m_bConfigure = FALSE;
  140. } else {
  141. m_bConfigure = TRUE;
  142. SetInitialValue((DWORD_PTR)dw);
  143. }
  144. }
  145. void CAttrRet::SetInitialValue(DWORD_PTR dw) {
  146. switch(dw) {
  147. case SCE_RETAIN_BY_DAYS:
  148. m_rabRetention = RADIO_RETAIN_BY_DAYS;
  149. break;
  150. case SCE_RETAIN_AS_NEEDED:
  151. m_rabRetention = RADIO_RETAIN_AS_NEEDED;
  152. break;
  153. case SCE_RETAIN_MANUALLY:
  154. m_rabRetention = RADIO_RETAIN_MANUALLY;
  155. break;
  156. }
  157. }
  158. void CAttrRet::OnRetention()
  159. {
  160. SetModified(TRUE);
  161. }