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.

237 lines
6.4 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, **/
  4. /**********************************************************************/
  5. /*
  6. pgencryp.cpp
  7. Definition of CPgEncryption -- property page to edit
  8. profile attributes related to encryption
  9. FILE HISTORY:
  10. */
  11. #include "stdafx.h"
  12. #include "resource.h"
  13. #include "PgEncryp.h"
  14. #include "hlptable.h"
  15. #include "profsht.h"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CPgEncryptionMerge property page
  23. IMPLEMENT_DYNCREATE(CPgEncryptionMerge, CPropertyPage)
  24. #define NO_OLD_ET_VALUE
  25. CPgEncryptionMerge::CPgEncryptionMerge(CRASProfileMerge* profile)
  26. : CManagedPage(CPgEncryptionMerge::IDD),
  27. m_pProfile(profile)
  28. {
  29. //{{AFX_DATA_INIT(CPgEncryptionMerge)
  30. m_bBasic = FALSE;
  31. m_bNone = FALSE;
  32. m_bStrong = FALSE;
  33. m_bStrongest = FALSE;
  34. //}}AFX_DATA_INIT
  35. m_b128EnabledOnTheMachine = FALSE;
  36. // default case --- allow everything
  37. if (((m_pProfile->m_dwAttributeFlags & PABF_msRASAllowEncryption) == 0)
  38. && ((m_pProfile->m_dwAttributeFlags & PABF_msRASEncryptionType) == 0))
  39. {
  40. m_bBasic = TRUE;
  41. m_bNone = TRUE;
  42. m_bStrong = TRUE;
  43. m_bStrongest = TRUE;
  44. }
  45. else if (((m_pProfile->m_dwAttributeFlags & PABF_msRASAllowEncryption) != 0)
  46. && ((m_pProfile->m_dwAttributeFlags & PABF_msRASEncryptionType) != 0))
  47. {
  48. if (m_pProfile->m_dwEncryptionPolicy == RAS_EP_ALLOW)
  49. m_bNone = TRUE; // allow means None is OK
  50. m_bStrong = ((m_pProfile->m_dwEncryptionType & RAS_ET_STRONG ) != 0);
  51. m_bBasic = ((m_pProfile->m_dwEncryptionType & RAS_ET_BASIC ) != 0);
  52. m_bStrongest = ((m_pProfile->m_dwEncryptionType & RAS_ET_STRONGEST ) != 0);
  53. }
  54. SetHelpTable(g_aHelpIDs_IDD_ENCRYPTION_MERGE);
  55. }
  56. CPgEncryptionMerge::~CPgEncryptionMerge()
  57. {
  58. }
  59. void CPgEncryptionMerge::DoDataExchange(CDataExchange* pDX)
  60. {
  61. CPropertyPage::DoDataExchange(pDX);
  62. //{{AFX_DATA_MAP(CPgEncryptionMerge)
  63. DDX_Check(pDX, IDC_CHECK_ENC_BASIC, m_bBasic);
  64. DDX_Check(pDX, IDC_CHECK_ENC_NONE, m_bNone);
  65. DDX_Check(pDX, IDC_CHECK_ENC_STRONG, m_bStrong);
  66. DDX_Check(pDX, IDC_CHECK_ENC_STRONGEST, m_bStrongest);
  67. //}}AFX_DATA_MAP
  68. }
  69. BEGIN_MESSAGE_MAP(CPgEncryptionMerge, CPropertyPage)
  70. //{{AFX_MSG_MAP(CPgEncryptionMerge)
  71. ON_WM_HELPINFO()
  72. ON_WM_CONTEXTMENU()
  73. ON_BN_CLICKED(IDC_CHECK_ENC_BASIC, OnCheckEncBasic)
  74. ON_BN_CLICKED(IDC_CHECK_ENC_NONE, OnCheckEncNone)
  75. ON_BN_CLICKED(IDC_CHECK_ENC_STRONG, OnCheckEncStrong)
  76. ON_BN_CLICKED(IDC_CHECK_ENC_STRONGEST, OnCheckEncStrongest)
  77. //}}AFX_MSG_MAP
  78. END_MESSAGE_MAP()
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CPgEncryption message handlers
  81. BOOL CPgEncryptionMerge::OnKillActive()
  82. {
  83. UpdateData();
  84. // at least one should be
  85. if(!(m_bNone || m_bBasic || m_bStrong || m_bStrongest))
  86. {
  87. AfxMessageBox(IDS_DATAENTRY_ENCRYPTIONTYPE);
  88. return FALSE;
  89. }
  90. return CPropertyPage::OnKillActive();
  91. }
  92. BOOL CPgEncryptionMerge::OnApply()
  93. {
  94. if (!GetModified()) return TRUE;
  95. // default case -- allow anything, -- remove the attributes
  96. if (m_bNone && m_bBasic && m_bStrong && m_bStrongest)
  97. {
  98. // remove both attributes
  99. m_pProfile->m_dwAttributeFlags &= (~PABF_msRASAllowEncryption);
  100. m_pProfile->m_dwAttributeFlags &= (~PABF_msRASEncryptionType);
  101. }
  102. else
  103. {
  104. // policy
  105. if (m_bNone)
  106. m_pProfile->m_dwEncryptionPolicy = RAS_EP_ALLOW;
  107. else
  108. m_pProfile->m_dwEncryptionPolicy = RAS_EP_REQUIRE;
  109. // type
  110. m_pProfile->m_dwEncryptionType = 0;
  111. if (m_bBasic)
  112. m_pProfile->m_dwEncryptionType |= RAS_ET_BASIC;
  113. if (m_bStrong)
  114. m_pProfile->m_dwEncryptionType |= RAS_ET_STRONG;
  115. if (m_bStrongest)
  116. m_pProfile->m_dwEncryptionType |= RAS_ET_STRONGEST;
  117. // at least one must be selected
  118. if (m_pProfile->m_dwEncryptionType == 0 && m_pProfile->m_dwEncryptionPolicy == RAS_EP_REQUIRE)
  119. {
  120. AfxMessageBox(IDS_DATAENTRY_ENCRYPTIONTYPE);
  121. return FALSE;
  122. }
  123. // set the flags
  124. m_pProfile->m_dwAttributeFlags |= PABF_msRASAllowEncryption;
  125. m_pProfile->m_dwAttributeFlags |= PABF_msRASEncryptionType;
  126. }
  127. return CManagedPage::OnApply();
  128. }
  129. BOOL CPgEncryptionMerge::OnInitDialog()
  130. {
  131. // if 128 bit is enabled
  132. RAS_NDISWAN_DRIVER_INFO Info;
  133. // always true for IAS
  134. m_b128EnabledOnTheMachine = TRUE;
  135. CPropertyPage::OnInitDialog();
  136. CProfileSheetMerge* pSheet = dynamic_cast<CProfileSheetMerge*>(GetManager());
  137. if (pSheet && (pSheet->m_dwTabFlags & RAS_IAS_PROFILEDLG_SHOW_RASTABS))
  138. {
  139. // if 128 bit is enabled
  140. RAS_NDISWAN_DRIVER_INFO Info;
  141. ZeroMemory(&Info, sizeof(RAS_NDISWAN_DRIVER_INFO));
  142. m_pProfile->GetRasNdiswanDriverCaps(&Info);
  143. if (Info.DriverCaps & RAS_NDISWAN_128BIT_ENABLED)
  144. m_b128EnabledOnTheMachine = TRUE;
  145. else
  146. m_b128EnabledOnTheMachine = FALSE;
  147. if(m_b128EnabledOnTheMachine)
  148. GetDlgItem(IDC_CHECK_ENC_STRONGEST)->ShowWindow(SW_SHOW);
  149. else
  150. GetDlgItem(IDC_CHECK_ENC_STRONGEST)->ShowWindow(SW_HIDE);
  151. }
  152. return TRUE; // return TRUE unless you set the focus to a control
  153. // EXCEPTION: OCX Property Pages should return FALSE
  154. }
  155. BOOL CPgEncryptionMerge::OnHelpInfo(HELPINFO* pHelpInfo)
  156. {
  157. // TODO: Add your message handler code here and/or call default
  158. return CManagedPage::OnHelpInfo(pHelpInfo);
  159. }
  160. void CPgEncryptionMerge::OnContextMenu(CWnd* pWnd, CPoint point)
  161. {
  162. CManagedPage::OnContextMenu(pWnd, point);
  163. }
  164. BOOL CPgEncryptionMerge::OnSetActive()
  165. {
  166. return CPropertyPage::OnSetActive();
  167. }
  168. void CPgEncryptionMerge::OnCheckEncBasic()
  169. {
  170. // TODO: Add your control notification handler code here
  171. SetModified();
  172. }
  173. void CPgEncryptionMerge::OnCheckEncNone()
  174. {
  175. // TODO: Add your control notification handler code here
  176. SetModified();
  177. }
  178. void CPgEncryptionMerge::OnCheckEncStrong()
  179. {
  180. // TODO: Add your control notification handler code here
  181. SetModified();
  182. }
  183. void CPgEncryptionMerge::OnCheckEncStrongest()
  184. {
  185. // TODO: Add your control notification handler code here
  186. SetModified();
  187. }