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.

278 lines
7.2 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. Servpp.h
  7. Server properties implementation file
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "mmsapp.h"
  12. #include "spdutil.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. //
  20. // CMmSAProperties holder
  21. //
  22. /////////////////////////////////////////////////////////////////////////////
  23. CMmSAProperties::CMmSAProperties
  24. (
  25. ITFSNode * pNode,
  26. IComponentData * pComponentData,
  27. ITFSComponentData * pTFSCompData,
  28. CMmSA * pSA,
  29. ISpdInfo * pSpdInfo,
  30. LPCTSTR pszSheetName
  31. ) : CPropertyPageHolderBase(pNode, pComponentData, pszSheetName)
  32. {
  33. //ASSERT(pFolderNode == GetContainerNode());
  34. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  35. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  36. Assert(pTFSCompData != NULL);
  37. m_spTFSCompData.Set(pTFSCompData);
  38. m_spSpdInfo.Set(pSpdInfo);
  39. m_SA = *pSA;
  40. }
  41. CMmSAProperties::~CMmSAProperties()
  42. {
  43. RemovePageFromList((CPropertyPageBase*) &m_pageGeneral, FALSE);
  44. }
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CMmSAGenProp property page
  47. IMPLEMENT_DYNCREATE(CMmSAGenProp, CPropertyPageBase)
  48. CMmSAGenProp::CMmSAGenProp() : CPropertyPageBase(CMmSAGenProp::IDD)
  49. {
  50. //{{AFX_DATA_INIT(CMmSAGenProp)
  51. // NOTE: the ClassWizard will add member initialization here
  52. //}}AFX_DATA_INIT
  53. }
  54. CMmSAGenProp::~CMmSAGenProp()
  55. {
  56. }
  57. void CMmSAGenProp::DoDataExchange(CDataExchange* pDX)
  58. {
  59. CPropertyPageBase::DoDataExchange(pDX);
  60. //{{AFX_DATA_MAP(CMmSAGenProp)
  61. DDX_Control(pDX, IDC_MMSA_LIST_QM, m_listQmSAs);
  62. //}}AFX_DATA_MAP
  63. }
  64. BEGIN_MESSAGE_MAP(CMmSAGenProp, CPropertyPageBase)
  65. //{{AFX_MSG_MAP(CMmSAGenProp)
  66. //}}AFX_MSG_MAP
  67. END_MESSAGE_MAP()
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CMmSAGenProp message handlers
  70. BOOL CMmSAGenProp::OnInitDialog()
  71. {
  72. CPropertyPageBase::OnInitDialog();
  73. PopulateSAInfo();
  74. LoadQmSAs();
  75. SetDirty(FALSE);
  76. return TRUE; // return TRUE unless you set the focus to a control
  77. // EXCEPTION: OCX Property Pages should return FALSE
  78. }
  79. void CMmSAGenProp::PopulateSAInfo()
  80. {
  81. CString st;
  82. CMmSAProperties * pSAProp;
  83. CMmSA * pSA;
  84. CMmFilterInfo * pFltrInfo;
  85. pSAProp = (CMmSAProperties *) GetHolder();
  86. Assert(pSAProp);
  87. pSAProp->GetSAInfo(&pSA);
  88. AddressToString(pSA->m_MeAddr, &st);
  89. GetDlgItem(IDC_MMSA_ME)->SetWindowText(st);
  90. AddressToString(pSA->m_PeerAddr, &st);
  91. GetDlgItem(IDC_MMSA_PEER)->SetWindowText(st);
  92. MmAuthToString(pSA->m_Auth, &st);
  93. GetDlgItem(IDC_MMSA_AUTH)->SetWindowText(st);
  94. GetDlgItem(IDC_MMSA_IKE_POL)->SetWindowText(pSA->m_stPolicyName);
  95. DoiEspAlgorithmToString(pSA->m_SelectedOffer.m_EncryptionAlgorithm, &st);
  96. GetDlgItem(IDC_MMSA_CONF)->SetWindowText(st);
  97. DoiAuthAlgorithmToString(pSA->m_SelectedOffer.m_HashingAlgorithm, &st);
  98. GetDlgItem(IDC_MMSA_INTEG)->SetWindowText(st);
  99. DhGroupToString(pSA->m_SelectedOffer.m_dwDHGroup, &st);
  100. GetDlgItem(IDC_MMSA_DH_GRP)->SetWindowText(st);
  101. KeyLifetimeToString(pSA->m_SelectedOffer.m_Lifetime, &st);
  102. GetDlgItem(IDC_MMSA_KEYLIFE)->SetWindowText(st);
  103. }
  104. void CMmSAGenProp::LoadQmSAs()
  105. {
  106. int nWidth;
  107. CString st;
  108. st.LoadString(IDS_COL_QM_SA_SRC);
  109. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  110. m_listQmSAs.InsertColumn(0, st, LVCFMT_LEFT, nWidth);
  111. st.LoadString(IDS_COL_QM_SA_DEST);
  112. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  113. m_listQmSAs.InsertColumn(1, st, LVCFMT_LEFT, nWidth);
  114. st.LoadString(IDS_COL_QM_SA_SRC_PORT);
  115. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  116. m_listQmSAs.InsertColumn(2, st, LVCFMT_LEFT, nWidth);
  117. st.LoadString(IDS_COL_QM_SA_DES_PORT);
  118. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  119. m_listQmSAs.InsertColumn(3, st, LVCFMT_LEFT, nWidth);
  120. st.LoadString(IDS_COL_QM_SA_PROT);
  121. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  122. m_listQmSAs.InsertColumn(4, st, LVCFMT_LEFT, nWidth);
  123. st.LoadString(IDS_COL_QM_SA_POL);
  124. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  125. m_listQmSAs.InsertColumn(5, st, LVCFMT_LEFT, nWidth);
  126. st.LoadString(IDS_COL_QM_SA_AUTH);
  127. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  128. m_listQmSAs.InsertColumn(6, st, LVCFMT_LEFT, nWidth);
  129. st.LoadString(IDS_COL_QM_SA_CONF);
  130. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  131. m_listQmSAs.InsertColumn(7, st, LVCFMT_LEFT, nWidth);
  132. st.LoadString(IDS_COL_QM_SA_INTEGRITY);
  133. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  134. m_listQmSAs.InsertColumn(8, st, LVCFMT_LEFT, nWidth);
  135. st.LoadString(IDS_COL_QM_SA_MY_TNL);
  136. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  137. m_listQmSAs.InsertColumn(9, st, LVCFMT_LEFT, nWidth);
  138. st.LoadString(IDS_COL_QM_SA_PEER_TNL);
  139. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  140. m_listQmSAs.InsertColumn(10, st, LVCFMT_LEFT, nWidth);
  141. CMmSAProperties * pSAProp;
  142. CMmSA * pSA;
  143. pSAProp = (CMmSAProperties *) GetHolder();
  144. Assert(pSAProp);
  145. pSAProp->GetSAInfo(&pSA);
  146. SPISpdInfo spSpdInfo;
  147. pSAProp->GetSpdInfo(&spSpdInfo);
  148. CQmSAArray arrQmSAs;
  149. spSpdInfo->EnumQmSAsFromMmSA(*pSA, &arrQmSAs);
  150. int nRows = 0;
  151. for (int i = 0; i < arrQmSAs.GetSize(); i++)
  152. {
  153. nRows = m_listQmSAs.InsertItem(nRows, _T(""));
  154. if (-1 != nRows)
  155. {
  156. AddressToString(arrQmSAs[i]->m_QmDriverFilter.m_SrcAddr, &st);
  157. m_listQmSAs.SetItemText(nRows, 0, st);
  158. AddressToString(arrQmSAs[i]->m_QmDriverFilter.m_DesAddr, &st);
  159. m_listQmSAs.SetItemText(nRows, 1, st);
  160. PortToString(arrQmSAs[i]->m_QmDriverFilter.m_SrcPort, &st);
  161. m_listQmSAs.SetItemText(nRows, 2, st);
  162. PortToString(arrQmSAs[i]->m_QmDriverFilter.m_DesPort, &st);
  163. m_listQmSAs.SetItemText(nRows, 3, st);
  164. ProtocolToString(arrQmSAs[i]->m_QmDriverFilter.m_Protocol, &st);
  165. m_listQmSAs.SetItemText(nRows, 4, st);
  166. st = arrQmSAs[i]->m_stPolicyName;
  167. m_listQmSAs.SetItemText(nRows, 5, st);
  168. QmAlgorithmToString(QM_ALGO_AUTH, &arrQmSAs[i]->m_SelectedOffer, &st);
  169. m_listQmSAs.SetItemText(nRows, 6, st);
  170. QmAlgorithmToString(QM_ALGO_ESP_CONF, &arrQmSAs[i]->m_SelectedOffer, &st);
  171. m_listQmSAs.SetItemText(nRows, 7, st);
  172. QmAlgorithmToString(QM_ALGO_ESP_INTEG, &arrQmSAs[i]->m_SelectedOffer, &st);
  173. m_listQmSAs.SetItemText(nRows, 8, st);
  174. TnlEpToString(arrQmSAs[i]->m_QmDriverFilter.m_Type,
  175. arrQmSAs[i]->m_QmDriverFilter.m_MyTunnelEndpt,
  176. &st);
  177. m_listQmSAs.SetItemText(nRows, 9, st);
  178. TnlEpToString(arrQmSAs[i]->m_QmDriverFilter.m_Type,
  179. arrQmSAs[i]->m_QmDriverFilter.m_PeerTunnelEndpt,
  180. &st);
  181. m_listQmSAs.SetItemText(nRows, 10, st);
  182. }
  183. nRows++;
  184. }
  185. FreeItemsAndEmptyArray(arrQmSAs);
  186. }
  187. BOOL CMmSAGenProp::OnApply()
  188. {
  189. if (!IsDirty())
  190. return TRUE;
  191. UpdateData();
  192. //TODO
  193. //Do nothing at this time
  194. //CPropertyPageBase::OnApply();
  195. return TRUE;
  196. }
  197. BOOL CMmSAGenProp::OnPropertyChange(BOOL bScope, LONG_PTR *ChangeMask)
  198. {
  199. return FALSE;
  200. }