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.

220 lines
5.6 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation **/
  4. /**********************************************************************/
  5. /*
  6. profsht.cpp
  7. Implementation of CProfileSheet -- property sheet to hold
  8. profile property pages
  9. FILE HISTORY:
  10. */
  11. // ProfSht.cpp : implementation file
  12. //
  13. #include "stdafx.h"
  14. #include "resource.h"
  15. #include "pgconst.h"
  16. #include "pgnetwk.h"
  17. #include "ProfSht.h"
  18. #include "rasprof.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CProfileSheetMerge
  26. IMPLEMENT_DYNAMIC(CProfileSheetMerge, CPropertySheet)
  27. CProfileSheetMerge::CProfileSheetMerge(CRASProfileMerge& profile, bool bSaveOnApply, UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
  28. :CPropertySheet(nIDCaption, pParentWnd, iSelectPage),
  29. m_pProfile(&profile),
  30. m_bSaveOnApply(bSaveOnApply),
  31. m_pgAuthentication(profile),
  32. m_pgAuthentication2k(profile),
  33. m_pgConstraints(&profile),
  34. m_pgEncryption(&profile),
  35. m_pgMultilink(&profile),
  36. m_pgNetworking(&profile),
  37. m_pgIASAdv(profile.m_spIProfile, profile.m_spIDictionary),
  38. m_dwTabFlags(0)
  39. {
  40. }
  41. CProfileSheetMerge::CProfileSheetMerge(CRASProfileMerge& profile, bool bSaveOnApply, LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
  42. :CPropertySheet(pszCaption, pParentWnd, iSelectPage),
  43. m_pProfile(&profile),
  44. m_bSaveOnApply(bSaveOnApply),
  45. m_pgAuthentication(profile),
  46. m_pgAuthentication2k(profile),
  47. m_pgConstraints(&profile),
  48. m_pgEncryption(&profile),
  49. m_pgMultilink(&profile),
  50. m_pgNetworking(&profile),
  51. m_pgIASAdv(profile.m_spIProfile, profile.m_spIDictionary),
  52. m_dwTabFlags(0)
  53. {
  54. }
  55. #ifdef __TEST_ADV_PAGE_API
  56. void* pVData;
  57. #endif
  58. void CProfileSheetMerge::PreparePages(DWORD dwTabFlags, void* pvData)
  59. {
  60. m_bApplied = FALSE;
  61. AddPage(&m_pgConstraints);
  62. m_pgConstraints.SetManager(this);
  63. AddPage(&m_pgNetworking);
  64. m_pgNetworking.SetManager(this);
  65. AddPage(&m_pgMultilink);
  66. m_pgMultilink.SetManager(this);
  67. // Check if this is a remote admin of a win2k machine
  68. m_dwTabFlags = dwTabFlags;
  69. if(dwTabFlags & RAS_IAS_PROFILEDLG_SHOW_WIN2K)
  70. {
  71. AddPage(&m_pgAuthentication2k);
  72. m_pgAuthentication2k.SetManager(this);
  73. }
  74. else
  75. {
  76. AddPage(&m_pgAuthentication);
  77. m_pgAuthentication.SetManager(this);
  78. }
  79. AddPage(&m_pgEncryption);
  80. m_pgEncryption.SetManager(this);
  81. // Advanced tab
  82. m_pgIASAdv.SetData(ALLOWEDINPROFILE, pvData);
  83. AddPage(&m_pgIASAdv);
  84. m_pgIASAdv.SetManager(this);
  85. #ifdef __TEST_ADV_PAGE_API
  86. pVData = pvData;
  87. #endif
  88. m_hrLastError = S_OK;
  89. }
  90. CProfileSheetMerge::~CProfileSheetMerge()
  91. {
  92. }
  93. BEGIN_MESSAGE_MAP(CProfileSheetMerge, CPropertySheet)
  94. //{{AFX_MSG_MAP(CProfileSheetMerge)
  95. ON_WM_HELPINFO()
  96. ON_WM_CREATE()
  97. //}}AFX_MSG_MAP
  98. END_MESSAGE_MAP()
  99. /////////////////////////////////////////////////////////////////////////////
  100. // CProfileSheetMerge message handlers
  101. BOOL CProfileSheetMerge::OnApply()
  102. {
  103. BOOL bSaved = TRUE;
  104. if(!CPageManager::OnApply()) return FALSE;
  105. // for each page this sheet manages, call the OnApply, and then call SetModify to False
  106. if (m_pgAuthentication.GetModified())
  107. m_pgAuthentication.OnApply();
  108. if (m_pgConstraints.GetModified())
  109. m_pgConstraints.OnApply();
  110. if (m_pgEncryption.GetModified())
  111. m_pgEncryption.OnApply();
  112. if (m_pgMultilink.GetModified())
  113. m_pgMultilink.OnApply();
  114. if (m_pgNetworking.GetModified())
  115. m_pgNetworking.OnApply();
  116. if (m_pgIASAdv.GetModified())
  117. m_pgIASAdv.OnApply();
  118. HRESULT hr = S_OK;
  119. if(m_bSaveOnApply)
  120. hr = m_pProfile->Save();
  121. if(FAILED(hr))
  122. {
  123. m_hrLastError = hr;
  124. ReportError(hr, IDS_ERR_SAVEPROFILE, NULL);
  125. bSaved = FALSE;
  126. }
  127. m_bApplied = TRUE;
  128. m_pgAuthentication.OnSaved(bSaved);
  129. m_pgConstraints.OnSaved(bSaved);
  130. m_pgEncryption.OnSaved(bSaved);
  131. m_pgMultilink.OnSaved(bSaved);
  132. m_pgNetworking.OnSaved(bSaved);
  133. m_pgIASAdv.OnSaved(bSaved);
  134. return bSaved;
  135. }
  136. const DWORD g_aHelpIDs___________[]=
  137. {
  138. ID_APPLY_NOW, 20000600,
  139. 0, 0
  140. };
  141. BOOL CProfileSheetMerge::OnHelpInfo(HELPINFO* pHelpInfo)
  142. {
  143. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  144. AfxGetApp()->m_pszHelpFilePath,
  145. HELP_WM_HELP,
  146. (DWORD_PTR)(LPVOID)g_aHelpIDs___________);
  147. return CPropertySheet::OnHelpInfo(pHelpInfo);
  148. }
  149. void CProfileSheetMerge::OnContextMenu(CWnd* pWnd, CPoint point)
  150. {
  151. ::WinHelp (pWnd->m_hWnd, AfxGetApp()->m_pszHelpFilePath,
  152. HELP_CONTEXTMENU, (DWORD_PTR)(LPVOID)g_aHelpIDs___________);
  153. }
  154. int CProfileSheetMerge::OnCreate(LPCREATESTRUCT lpCreateStruct)
  155. {
  156. ModifyStyleEx(0, WS_EX_CONTEXTHELP);
  157. if (CPropertySheet::OnCreate(lpCreateStruct) == -1)
  158. return -1;
  159. return 0;
  160. }
  161. BOOL CProfileSheetMerge::OnInitDialog()
  162. {
  163. BOOL bResult = CPropertySheet::OnInitDialog();
  164. if(CPageManager::GetReadOnly())
  165. GetDlgItem(IDOK)->EnableWindow(FALSE);
  166. #ifdef __TEST_ADV_PAGE_API
  167. HPROPSHEETPAGE hPage = IASCreateProfileAdvancedPage(m_pProfile->m_spIProfile, m_pProfile->m_spIDictionary, ALLOWEDINPROFILE, pVData);
  168. if(hPage)
  169. PropSheet_InsertPage(m_hWnd, NULL, hPage);
  170. #endif
  171. return bResult;
  172. }