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.

360 lines
8.4 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 "mmfltrpp.h"
  12. #include "mmauthpp.h"
  13. #include "spdutil.h"
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. /////////////////////////////////////////////////////////////////////////////
  20. //
  21. // CMmFilterProperties holder
  22. //
  23. /////////////////////////////////////////////////////////////////////////////
  24. CMmFilterProperties::CMmFilterProperties
  25. (
  26. ITFSNode * pNode,
  27. IComponentData * pComponentData,
  28. ITFSComponentData * pTFSCompData,
  29. CMmFilterInfo * pFilterInfo,
  30. ISpdInfo * pSpdInfo,
  31. LPCTSTR pszSheetName
  32. ) : CPropertyPageHolderBase(pNode, pComponentData, pszSheetName)
  33. {
  34. //ASSERT(pFolderNode == GetContainerNode());
  35. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  36. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  37. AddPageToList((CPropertyPageBase*) &m_pageAuth);
  38. Assert(pTFSCompData != NULL);
  39. m_spTFSCompData.Set(pTFSCompData);
  40. m_spSpdInfo.Set(pSpdInfo);
  41. m_FltrInfo = *pFilterInfo;
  42. //$REVIEW there is very remote possibility that this routin will fail:
  43. m_spSpdInfo->GetMmAuthMethodsInfoByGuid(m_FltrInfo.m_guidAuthID, &m_AuthMethods);
  44. m_pageAuth.InitData(&m_AuthMethods);
  45. }
  46. CMmFilterProperties::~CMmFilterProperties()
  47. {
  48. RemovePageFromList((CPropertyPageBase*) &m_pageGeneral, FALSE);
  49. RemovePageFromList((CPropertyPageBase*) &m_pageAuth, FALSE);
  50. }
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CMmFilterGenProp property page
  53. IMPLEMENT_DYNCREATE(CMmFilterGenProp, CPropertyPageBase)
  54. CMmFilterGenProp::CMmFilterGenProp() : CPropertyPageBase(CMmFilterGenProp::IDD)
  55. {
  56. //{{AFX_DATA_INIT(CMmFilterGenProp)
  57. // NOTE: the ClassWizard will add member initialization here
  58. //}}AFX_DATA_INIT
  59. }
  60. CMmFilterGenProp::~CMmFilterGenProp()
  61. {
  62. }
  63. void CMmFilterGenProp::DoDataExchange(CDataExchange* pDX)
  64. {
  65. CPropertyPageBase::DoDataExchange(pDX);
  66. //{{AFX_DATA_MAP(CMmFilterGenProp)
  67. DDX_Control(pDX, IDC_MM_LIST_SPECIFIC, m_listSpecificFilters);
  68. //}}AFX_DATA_MAP
  69. }
  70. BEGIN_MESSAGE_MAP(CMmFilterGenProp, CPropertyPageBase)
  71. //{{AFX_MSG_MAP(CMmFilterGenProp)
  72. //}}AFX_MSG_MAP
  73. END_MESSAGE_MAP()
  74. /////////////////////////////////////////////////////////////////////////////
  75. // CMmFilterGenProp message handlers
  76. BOOL CMmFilterGenProp::OnInitDialog()
  77. {
  78. CPropertyPageBase::OnInitDialog();
  79. PopulateFilterInfo();
  80. LoadSpecificFilters();
  81. SetDirty(FALSE);
  82. return TRUE; // return TRUE unless you set the focus to a control
  83. // EXCEPTION: OCX Property Pages should return FALSE
  84. }
  85. void CMmFilterGenProp::PopulateFilterInfo()
  86. {
  87. CString st;
  88. CString stMask;
  89. CMmFilterProperties * pFltrProp;
  90. CMmFilterInfo * pFltrInfo;
  91. pFltrProp = (CMmFilterProperties *) GetHolder();
  92. Assert(pFltrProp);
  93. pFltrProp->GetFilterInfo(&pFltrInfo);
  94. int iIdAddr = IDC_MM_FLTR_SRC_ADDR;
  95. BOOL fUseEditForAddr = FALSE;
  96. BOOL fHideMask = FALSE;
  97. BOOL fDnsAddr = FALSE;
  98. switch (pFltrInfo->m_SrcAddr.AddrType)
  99. {
  100. case IP_ADDR_UNIQUE:
  101. if (IP_ADDRESS_ME == pFltrInfo->m_SrcAddr.uIpAddr)
  102. {
  103. st.LoadString(IDS_ADDR_ME);
  104. fHideMask = TRUE;
  105. }
  106. else
  107. {
  108. AddressToString(pFltrInfo->m_SrcAddr, &st, &fDnsAddr);
  109. if (fDnsAddr)
  110. {
  111. fUseEditForAddr = TRUE;
  112. fHideMask = TRUE;
  113. }
  114. else
  115. {
  116. stMask = c_szSingleAddressMask;
  117. IpToString(pFltrInfo->m_SrcAddr.uIpAddr, &st);
  118. }
  119. }
  120. break;
  121. case IP_ADDR_SUBNET:
  122. if (SUBNET_ADDRESS_ANY == pFltrInfo->m_SrcAddr.uSubNetMask)
  123. {
  124. st.LoadString(IDS_ADDR_ANY);
  125. fHideMask = TRUE;
  126. }
  127. else
  128. {
  129. IpToString(pFltrInfo->m_SrcAddr.uIpAddr, &st);
  130. IpToString(pFltrInfo->m_SrcAddr.uSubNetMask, &stMask);
  131. }
  132. break;
  133. }
  134. if (fHideMask)
  135. {
  136. GetDlgItem(IDC_MM_FLTR_SRC_MASK)->ShowWindow(SW_HIDE);
  137. GetDlgItem(IDC_MM_STATIC_SRC_MASK)->ShowWindow(SW_HIDE);
  138. }
  139. else
  140. {
  141. GetDlgItem(IDC_MM_FLTR_SRC_MASK)->SetWindowText(stMask);
  142. }
  143. if (fUseEditForAddr)
  144. {
  145. iIdAddr = IDC_MM_FLTR_SRC_ADDR_EDIT;
  146. GetDlgItem(IDC_MM_FLTR_SRC_ADDR)->ShowWindow(SW_HIDE);
  147. }
  148. else
  149. {
  150. iIdAddr = IDC_MM_FLTR_SRC_ADDR;
  151. GetDlgItem(IDC_MM_FLTR_SRC_ADDR_EDIT)->ShowWindow(SW_HIDE);
  152. }
  153. GetDlgItem(iIdAddr)->SetWindowText(st);
  154. //now populate the destination info
  155. iIdAddr = IDC_MM_FLTR_DEST_ADDR;
  156. fUseEditForAddr = FALSE;
  157. fHideMask = FALSE;
  158. fDnsAddr = FALSE;
  159. st = _T("");
  160. stMask= _T("");
  161. switch (pFltrInfo->m_DesAddr.AddrType)
  162. {
  163. case IP_ADDR_UNIQUE:
  164. if (IP_ADDRESS_ME == pFltrInfo->m_DesAddr.uIpAddr)
  165. {
  166. st.LoadString(IDS_ADDR_ME);
  167. fHideMask = TRUE;
  168. }
  169. else
  170. {
  171. AddressToString(pFltrInfo->m_DesAddr, &st, &fDnsAddr);
  172. if (fDnsAddr)
  173. {
  174. fUseEditForAddr = TRUE;
  175. fHideMask = TRUE;
  176. }
  177. else
  178. {
  179. stMask = c_szSingleAddressMask;
  180. IpToString(pFltrInfo->m_DesAddr.uIpAddr, &st);
  181. }
  182. }
  183. break;
  184. case IP_ADDR_SUBNET:
  185. if (SUBNET_ADDRESS_ANY == pFltrInfo->m_DesAddr.uSubNetMask)
  186. {
  187. st.LoadString(IDS_ADDR_ANY);
  188. fHideMask = TRUE;
  189. }
  190. else
  191. {
  192. IpToString(pFltrInfo->m_DesAddr.uIpAddr, &st);
  193. IpToString(pFltrInfo->m_DesAddr.uSubNetMask, &stMask);
  194. }
  195. break;
  196. }
  197. if (fHideMask)
  198. {
  199. GetDlgItem(IDC_MM_FLTR_DEST_MASK)->ShowWindow(SW_HIDE);
  200. GetDlgItem(IDC_MM_STATIC_DEST_MASK)->ShowWindow(SW_HIDE);
  201. }
  202. else
  203. {
  204. GetDlgItem(IDC_MM_FLTR_DEST_MASK)->SetWindowText(stMask);
  205. }
  206. if (fUseEditForAddr)
  207. {
  208. iIdAddr = IDC_MM_FLTR_DEST_ADDR_EDIT;
  209. GetDlgItem(IDC_MM_FLTR_DEST_ADDR)->ShowWindow(SW_HIDE);
  210. }
  211. else
  212. {
  213. iIdAddr = IDC_MM_FLTR_DEST_ADDR;
  214. GetDlgItem(IDC_MM_FLTR_DEST_ADDR_EDIT)->ShowWindow(SW_HIDE);
  215. }
  216. GetDlgItem(iIdAddr)->SetWindowText(st);
  217. //we are done with the destination address now
  218. InterfaceTypeToString(pFltrInfo->m_InterfaceType, &st);
  219. GetDlgItem(IDC_MM_FLTR_IF_TYPE)->SetWindowText(st);
  220. BoolToString(pFltrInfo->m_bCreateMirror, &st);
  221. GetDlgItem(IDC_MM_FLTR_MIRROR)->SetWindowText(st);
  222. SPISpdInfo spSpdInfo;
  223. pFltrProp->GetSpdInfo(&spSpdInfo);
  224. spSpdInfo->GetMmPolicyNameByGuid(pFltrInfo->m_guidPolicyID, &st);
  225. GetDlgItem(IDC_MM_FLTR_POLICY)->SetWindowText(st);
  226. }
  227. void CMmFilterGenProp::LoadSpecificFilters()
  228. {
  229. CMmFilterProperties * pFltrProp;
  230. CMmFilterInfo * pFltrInfo;
  231. CMmFilterInfoArray arraySpFilters;
  232. int nWidth;
  233. int nRows;
  234. CString st;
  235. pFltrProp = (CMmFilterProperties *) GetHolder();
  236. SPISpdInfo spSpdInfo;
  237. pFltrProp->GetSpdInfo(&spSpdInfo);
  238. pFltrProp->GetFilterInfo(&pFltrInfo);
  239. spSpdInfo->EnumMmSpecificFilters(
  240. &pFltrInfo->m_guidFltr,
  241. &arraySpFilters
  242. );
  243. nWidth = m_listSpecificFilters.GetStringWidth(_T("555.555.555.555 - "));
  244. st.LoadString(IDS_FILTER_PP_COL_SRC);
  245. m_listSpecificFilters.InsertColumn(0, st, LVCFMT_LEFT, nWidth);
  246. nWidth = m_listSpecificFilters.GetStringWidth(_T("555.555.555.555 - "));
  247. st.LoadString(IDS_FILTER_PP_COL_DEST);
  248. m_listSpecificFilters.InsertColumn(1, st, LVCFMT_LEFT, nWidth);
  249. st.LoadString(IDS_FLTR_DIR_OUT);
  250. nWidth = m_listSpecificFilters.GetStringWidth((LPCTSTR)st) + 20;
  251. st.LoadString(IDS_FILTER_PP_COL_DIRECTION);
  252. m_listSpecificFilters.InsertColumn(2, st, LVCFMT_LEFT, nWidth);
  253. st.LoadString(IDS_FILTER_PP_COL_WEIGHT);
  254. nWidth = m_listSpecificFilters.GetStringWidth((LPCTSTR)st) + 20;
  255. m_listSpecificFilters.InsertColumn(3, st, LVCFMT_LEFT, nWidth);
  256. nRows = 0;
  257. for (int i = 0; i < arraySpFilters.GetSize(); i++)
  258. {
  259. nRows = m_listSpecificFilters.InsertItem(nRows, _T(""));
  260. if (-1 != nRows)
  261. {
  262. AddressToString(arraySpFilters[i]->m_SrcAddr, &st);
  263. m_listSpecificFilters.SetItemText(nRows, 0, st);
  264. AddressToString(arraySpFilters[i]->m_DesAddr, &st);
  265. m_listSpecificFilters.SetItemText(nRows, 1, st);
  266. DirectionToString(arraySpFilters[i]->m_dwDirection, &st);
  267. m_listSpecificFilters.SetItemText(nRows, 2, st);
  268. st.Format(_T("%d"), arraySpFilters[i]->m_dwWeight);
  269. m_listSpecificFilters.SetItemText(nRows, 3, st);
  270. m_listSpecificFilters.SetItemData(nRows, i);
  271. }
  272. nRows++;
  273. }
  274. ::FreeItemsAndEmptyArray(arraySpFilters);
  275. }
  276. BOOL CMmFilterGenProp::OnApply()
  277. {
  278. if (!IsDirty())
  279. return TRUE;
  280. UpdateData();
  281. //TODO
  282. //Do nothing at this time
  283. //CPropertyPageBase::OnApply();
  284. return TRUE;
  285. }
  286. BOOL CMmFilterGenProp::OnPropertyChange(BOOL bScope, LONG_PTR *ChangeMask)
  287. {
  288. return FALSE;
  289. }