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.

205 lines
4.9 KiB

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