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.

2231 lines
62 KiB

  1. /*++
  2. Copyright (c) 1994-2000 Microsoft Corporation
  3. Module Name :
  4. websvcext_sheet.cpp
  5. Abstract:
  6. Property Sheet and Pages
  7. Author:
  8. Aaron Lee (AaronL)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. 4/1/2002 aaronl Initial creation
  13. --*/
  14. #include "stdafx.h"
  15. #include "common.h"
  16. #include "strvalid.h"
  17. #include "inetprop.h"
  18. #include "InetMgrApp.h"
  19. #include "shts.h"
  20. #include "iisobj.h"
  21. #include "shlobjp.h"
  22. #include "websvcext_sheet.h"
  23. #ifdef _DEBUG
  24. #undef THIS_FILE
  25. static char BASED_CODE THIS_FILE[] = __FILE__;
  26. #endif
  27. #define new DEBUG_NEW
  28. extern CInetmgrApp theApp;
  29. static CComBSTR g_InvalidWebSvcExtCharsPath;
  30. static CComBSTR g_InvalidWebSvcExtCharsName;
  31. static BOOL g_fStaticsLoaded = FALSE;
  32. void LoadStatics(void)
  33. {
  34. if (!g_fStaticsLoaded)
  35. {
  36. g_InvalidWebSvcExtCharsName = _T(",");
  37. g_fStaticsLoaded = g_InvalidWebSvcExtCharsPath.LoadString(IDS_WEBSVCEXT_INVALID_CHARSET);
  38. }
  39. }
  40. IMPLEMENT_DYNAMIC(CWebServiceExtensionSheet, CInetPropertySheet)
  41. CWebServiceExtensionSheet::CWebServiceExtensionSheet(
  42. CComAuthInfo * pComAuthInfo,
  43. LPCTSTR lpszMetaPath,
  44. CWnd * pParentWnd,
  45. LPARAM lParam,
  46. LPARAM lParamParent,
  47. LPARAM lParam2,
  48. UINT iSelectPage
  49. )
  50. : CInetPropertySheet(pComAuthInfo, lpszMetaPath, pParentWnd, lParam, lParamParent, iSelectPage),
  51. m_pprops(NULL)
  52. {
  53. m_pWebServiceExtension = (CWebServiceExtension *) lParam;
  54. m_pRestrictionUIEntry = (CRestrictionUIEntry *) lParam2;
  55. }
  56. CWebServiceExtensionSheet::~CWebServiceExtensionSheet()
  57. {
  58. FreeConfigurationParameters();
  59. }
  60. HRESULT
  61. CWebServiceExtensionSheet::LoadConfigurationParameters()
  62. {
  63. //
  64. // Load base properties
  65. //
  66. CError err;
  67. if (m_pprops == NULL)
  68. {
  69. //
  70. // First call -- load values
  71. //
  72. m_pprops = new CWebServiceExtensionProps(m_pWebServiceExtension->QueryInterface(), QueryMetaPath(),m_pRestrictionUIEntry,m_pWebServiceExtension);
  73. if (!m_pprops)
  74. {
  75. TRACEEOL("LoadConfigurationParameters: OOM");
  76. err = ERROR_NOT_ENOUGH_MEMORY;
  77. return err;
  78. }
  79. err = m_pprops->LoadData();
  80. }
  81. return err;
  82. }
  83. void
  84. CWebServiceExtensionSheet::FreeConfigurationParameters()
  85. {
  86. CInetPropertySheet::FreeConfigurationParameters();
  87. if (m_pprops)
  88. {
  89. delete m_pprops;m_pprops=NULL;
  90. }
  91. }
  92. BEGIN_MESSAGE_MAP(CWebServiceExtensionSheet, CInetPropertySheet)
  93. //{{AFX_MSG_MAP(CWebServiceExtensionSheet)
  94. //}}AFX_MSG_MAP
  95. END_MESSAGE_MAP()
  96. //////////////////////////////////////////////////////////////////////////////
  97. IMPLEMENT_DYNCREATE(CWebServiceExtensionGeneral, CInetPropertyPage)
  98. CWebServiceExtensionGeneral::CWebServiceExtensionGeneral(CWebServiceExtensionSheet * pSheet,int iImageIndex, CRestrictionUIEntry * pRestrictionUIEntry)
  99. : CInetPropertyPage(CWebServiceExtensionGeneral::IDD, pSheet),m_hGeneralImage(NULL)
  100. {
  101. m_pRestrictionUIEntry = pRestrictionUIEntry;
  102. HBITMAP hImageStrip = (HBITMAP) LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_INETMGR32), IMAGE_BITMAP, 0, 0,
  103. LR_LOADTRANSPARENT
  104. | LR_LOADMAP3DCOLORS
  105. | LR_SHARED);
  106. if (hImageStrip)
  107. {
  108. if (0 != iImageIndex)
  109. {
  110. m_hGeneralImage = GetBitmapFromStrip(hImageStrip, iImageIndex, 32);
  111. }
  112. }
  113. if (hImageStrip != NULL)
  114. {
  115. FreeResource(hImageStrip);
  116. hImageStrip=NULL;
  117. }
  118. }
  119. CWebServiceExtensionGeneral::~CWebServiceExtensionGeneral()
  120. {
  121. if (m_hGeneralImage != NULL)
  122. {
  123. FreeResource(m_hGeneralImage);
  124. m_hGeneralImage = NULL;
  125. }
  126. }
  127. /* virtual */
  128. HRESULT
  129. CWebServiceExtensionGeneral::FetchLoadedValues()
  130. {
  131. CError err;
  132. BEGIN_META_INST_READ(CWebServiceExtensionSheet)
  133. FETCH_INST_DATA_FROM_SHEET(m_strExtensionName);
  134. FETCH_INST_DATA_FROM_SHEET(m_strExtensionUsedBy);
  135. FETCH_INST_DATA_FROM_SHEET(m_iExtensionUsedByCount);
  136. END_META_INST_READ(err)
  137. if (m_iExtensionUsedByCount > 15)
  138. {
  139. ::ShowScrollBar(CONTROL_HWND(IDC_EXTENSION_USEDBY), SB_VERT, TRUE);
  140. }
  141. return err;
  142. }
  143. /* virtual */
  144. HRESULT
  145. CWebServiceExtensionGeneral::SaveInfo()
  146. {
  147. ASSERT(IsDirty());
  148. CError err;
  149. try
  150. {
  151. CWebServiceExtensionSheet * pSheet = (CWebServiceExtensionSheet *)GetSheet();
  152. if (pSheet)
  153. {
  154. pSheet->GetInstanceProperties().m_strExtensionName = m_strExtensionName;
  155. pSheet->GetInstanceProperties().m_strExtensionUsedBy = m_strExtensionUsedBy;
  156. err = pSheet->GetInstanceProperties().WriteDirtyProps();
  157. }
  158. }
  159. catch(CMemoryException * e)
  160. {
  161. e->Delete();
  162. err = ERROR_NOT_ENOUGH_MEMORY;
  163. }
  164. return err;
  165. }
  166. void
  167. CWebServiceExtensionGeneral::DoDataExchange(CDataExchange * pDX)
  168. {
  169. CInetPropertyPage::DoDataExchange(pDX);
  170. //{{AFX_DATA_MAP(CWebServiceExtensionGeneral)
  171. DDX_Control(pDX, IDC_EXTENSION_NAME, m_ExtensionName);
  172. DDX_Control(pDX, IDC_EXTENSION_USEDBY, m_ExtensionUsedBy);
  173. //DDX_Text(pDX, IDC_EXTENSION_NAME, m_strExtensionName);
  174. //DDX_Text(pDX, IDC_EXTENSION_NAME, m_strExtensionUsedBy);
  175. //DDV_MinMaxChars(pDX, m_strExtensionName, 1, MAX_PATH);
  176. //}}AFX_DATA_MAP
  177. }
  178. BEGIN_MESSAGE_MAP(CWebServiceExtensionGeneral, CInetPropertyPage)
  179. //{{AFX_MSG_MAP(CWebServiceExtensionGeneral)
  180. ON_WM_COMPAREITEM()
  181. ON_WM_MEASUREITEM()
  182. ON_WM_DRAWITEM()
  183. ON_COMMAND(ID_HELP, OnHelp)
  184. ON_WM_HELPINFO()
  185. ON_EN_CHANGE(IDC_EXTENSION_NAME, OnItemChanged)
  186. ON_EN_CHANGE(IDC_EXTENSION_USEDBY, OnItemChanged)
  187. ON_WM_DESTROY()
  188. //}}AFX_MSG_MAP
  189. END_MESSAGE_MAP()
  190. BOOL
  191. CWebServiceExtensionGeneral::OnInitDialog()
  192. {
  193. CInetPropertyPage::OnInitDialog();
  194. CString strBeautifullName;
  195. CString strFormat;
  196. strFormat.LoadString(IDS_WEBSVCEXT_PROP_PRENAME);
  197. strBeautifullName.Format(strFormat,m_strExtensionName);
  198. m_ExtensionName.SetWindowText(strBeautifullName);
  199. m_ExtensionUsedBy.SetWindowText(m_strExtensionUsedBy);
  200. if (m_hGeneralImage)
  201. {
  202. ::SendDlgItemMessage(m_hWnd,IDC_FILE_ICON,STM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM) m_hGeneralImage);
  203. }
  204. strFormat.LoadString(IDS_WEBSVCEXT_PROP_CAPTION);
  205. strBeautifullName.Format(strFormat,m_strExtensionName);
  206. ::SetWindowText(::GetForegroundWindow(), strBeautifullName);
  207. SetControlsState();
  208. SetModified(FALSE);
  209. return TRUE;
  210. }
  211. BOOL
  212. CWebServiceExtensionGeneral::OnHelpInfo(HELPINFO * pHelpInfo)
  213. {
  214. OnHelp();
  215. return TRUE;
  216. }
  217. void
  218. CWebServiceExtensionGeneral::OnHelp()
  219. {
  220. WinHelpDebug(0x20000 + CWebServiceExtensionGeneral::IDD);
  221. ::WinHelp(m_hWnd, theApp.m_pszHelpFilePath, HELP_CONTEXT, 0x20000 + CWebServiceExtensionGeneral::IDD);
  222. }
  223. void
  224. CWebServiceExtensionGeneral::SetControlsState()
  225. {
  226. m_ExtensionName.SetReadOnly(TRUE);
  227. m_ExtensionUsedBy.SetReadOnly(TRUE);
  228. }
  229. void
  230. CWebServiceExtensionGeneral::OnItemChanged()
  231. {
  232. SetModified(TRUE);
  233. }
  234. void
  235. CWebServiceExtensionGeneral::OnDestroy()
  236. {
  237. CInetPropertyPage::OnDestroy();
  238. }
  239. BOOL
  240. CWebServiceExtensionGeneral::OnSetActive()
  241. {
  242. // dunno why this doesn't work.
  243. m_ExtensionName.SetSel(0,0);
  244. //m_ExtensionUsedBy.SetFocus();
  245. return CInetPropertyPage::OnSetActive();
  246. }
  247. //////////////////////////////////////////////////////////////////////
  248. IMPLEMENT_DYNCREATE(CWebServiceExtensionRequiredFiles, CInetPropertyPage)
  249. CWebServiceExtensionRequiredFiles::CWebServiceExtensionRequiredFiles(CWebServiceExtensionSheet * pSheet,CComAuthInfo * pComAuthInfo,CRestrictionUIEntry * pRestrictionUIEntry)
  250. : CInetPropertyPage(CWebServiceExtensionRequiredFiles::IDD, pSheet)
  251. {
  252. m_pComAuthInfo = pComAuthInfo;
  253. m_pInterface = pSheet->m_pWebServiceExtension->QueryInterface();
  254. m_pRestrictionUIEntry = pRestrictionUIEntry;
  255. m_MyRestrictionList.RemoveAll();
  256. RestrictionListCopy(&m_MyRestrictionList,&m_pRestrictionUIEntry->strlstRestrictionEntries);
  257. }
  258. CWebServiceExtensionRequiredFiles::~CWebServiceExtensionRequiredFiles()
  259. {
  260. // delete the list and all the newly items
  261. CleanRestrictionList(&m_MyRestrictionList);
  262. }
  263. /* virtual */
  264. HRESULT
  265. CWebServiceExtensionRequiredFiles::FetchLoadedValues()
  266. {
  267. CError err;
  268. BEGIN_META_INST_READ(CWebServiceExtensionSheet)
  269. //FETCH_INST_DATA_FROM_SHEET(m_strFileList);
  270. RestrictionListCopy(&m_MyRestrictionList,&pSheet->GetInstanceProperties().m_MyRestrictionList);
  271. END_META_INST_READ(err)
  272. return err;
  273. }
  274. /* virtual */
  275. HRESULT
  276. CWebServiceExtensionRequiredFiles::SaveInfo()
  277. {
  278. ASSERT(IsDirty());
  279. CError err;
  280. BEGIN_META_INST_WRITE(CWebServiceExtensionSheet)
  281. //STORE_INST_DATA_ON_SHEET(m_MyRestrictionList);
  282. RestrictionListCopy(&pSheet->GetInstanceProperties().m_MyRestrictionList,&m_MyRestrictionList);
  283. END_META_INST_WRITE(err)
  284. return err;
  285. }
  286. void
  287. CWebServiceExtensionRequiredFiles::DoDataExchange(CDataExchange * pDX)
  288. {
  289. CInetPropertyPage::DoDataExchange(pDX);
  290. //{{AFX_DATA_MAP(CWebServiceExtensionRequiredFiles)
  291. DDX_Control(pDX, IDC_BTN_ADD, m_bnt_Add);
  292. DDX_Control(pDX, IDC_BTN_REMOVE, m_bnt_Remove);
  293. DDX_Control(pDX, IDC_BTN_ENABLE, m_bnt_Enable);
  294. DDX_Control(pDX, IDC_BTN_DISABLE, m_bnt_Disable);
  295. //}}AFX_DATA_MAP
  296. //
  297. // Private DDX/DDV Routines
  298. //
  299. DDX_Control(pDX, IDC_LIST_FILES, m_list_Files);
  300. }
  301. BEGIN_MESSAGE_MAP(CWebServiceExtensionRequiredFiles, CInetPropertyPage)
  302. //{{AFX_MSG_MAP(CWebServiceExtensionRequiredFiles)
  303. ON_BN_CLICKED(IDC_BTN_ADD, OnDoButtonAdd)
  304. ON_BN_CLICKED(IDC_BTN_REMOVE, OnDoButtonRemove)
  305. ON_BN_CLICKED(IDC_BTN_ENABLE, OnDoButtonEnable)
  306. ON_BN_CLICKED(IDC_BTN_DISABLE, OnDoButtonDisable)
  307. ON_NOTIFY(NM_DBLCLK, IDC_LIST_FILES, OnDblclkListFiles)
  308. ON_NOTIFY(NM_CLICK, IDC_LIST_FILES, OnClickListFiles)
  309. ON_NOTIFY(LVN_KEYDOWN, IDC_LIST_FILES, OnKeydownListFiles)
  310. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_FILES, OnSelChangedListFiles)
  311. ON_NOTIFY(LVN_BEGINDRAG, IDC_LIST_FILES, OnSelChangedListFiles)
  312. ON_COMMAND(ID_HELP, OnHelp)
  313. ON_WM_HELPINFO()
  314. //}}AFX_MSG_MAP
  315. END_MESSAGE_MAP()
  316. #define COL_1 0
  317. #define COL_1_WID 256
  318. BOOL
  319. CWebServiceExtensionRequiredFiles::OnInitDialog()
  320. {
  321. CInetPropertyPage::OnInitDialog();
  322. CString strMyTitle;
  323. if (m_pRestrictionUIEntry)
  324. {
  325. CString strTruncatedName;
  326. CString strFormat;
  327. strFormat.LoadString(IDS_REQUIREDFILES_TITLE);
  328. if (m_pRestrictionUIEntry->strGroupDescription.GetLength() <= 40)
  329. {
  330. strTruncatedName = m_pRestrictionUIEntry->strGroupDescription;
  331. }
  332. else
  333. {
  334. strTruncatedName = m_pRestrictionUIEntry->strGroupDescription.Left(40);
  335. strTruncatedName = strTruncatedName + _T("...");
  336. }
  337. strMyTitle.Format(strFormat,strTruncatedName,strTruncatedName);
  338. }
  339. GetDlgItem(IDC_REQUIREDFILES_STATIC_TITLE)->SetWindowText(strMyTitle);
  340. m_list_Files.Initialize(2);
  341. FillListBox(NULL);
  342. SetControlState();
  343. SetModified(FALSE);
  344. return TRUE;
  345. }
  346. BOOL
  347. CWebServiceExtensionRequiredFiles::OnHelpInfo(HELPINFO * pHelpInfo)
  348. {
  349. OnHelp();
  350. return TRUE;
  351. }
  352. void
  353. CWebServiceExtensionRequiredFiles::OnHelp()
  354. {
  355. WinHelpDebug(0x20000 + CWebServiceExtensionRequiredFiles::IDD);
  356. ::WinHelp(m_hWnd, theApp.m_pszHelpFilePath, HELP_CONTEXT, 0x20000 + CWebServiceExtensionRequiredFiles::IDD);
  357. }
  358. void
  359. CWebServiceExtensionRequiredFiles::FillListBox(CRestrictionEntry * pSelection)
  360. {
  361. m_list_Files.SetRedraw(FALSE);
  362. m_list_Files.DeleteAllItems();
  363. int cItems = 0;
  364. POSITION pos;
  365. CString TheKey;
  366. CRestrictionEntry * pOneEntry = NULL;
  367. for(pos = m_MyRestrictionList.GetStartPosition();pos != NULL;)
  368. {
  369. m_MyRestrictionList.GetNextAssoc(pos, TheKey, (CRestrictionEntry *&) pOneEntry);
  370. if (pOneEntry)
  371. {
  372. m_list_Files.AddItem(pOneEntry);
  373. ++cItems;
  374. }
  375. }
  376. m_list_Files.SetRedraw(TRUE);
  377. if (pSelection)
  378. {
  379. LVFINDINFO fi;
  380. fi.flags = LVFI_PARAM;
  381. fi.lParam = (LPARAM)pSelection;
  382. fi.vkDirection = VK_DOWN;
  383. int i = m_list_Files.FindItem(&fi);
  384. if (i != -1)
  385. {
  386. m_list_Files.SelectItem(i);
  387. }
  388. }
  389. }
  390. void
  391. CWebServiceExtensionRequiredFiles::SetControlState()
  392. {
  393. int nCurSel = m_list_Files.GetSelectionMark();
  394. BOOL bAdd_able = TRUE;
  395. BOOL bRemove_able = FALSE;
  396. BOOL bEnable_able = FALSE;
  397. BOOL bDisable_able = FALSE;
  398. BOOL bNoEntries = TRUE;
  399. CString TheKey;
  400. POSITION pos;
  401. CRestrictionEntry * pOneEntry;
  402. if (-1 != nCurSel)
  403. {
  404. CRestrictionEntry * pOneEntry = m_list_Files.GetItem(nCurSel);
  405. if (pOneEntry)
  406. {
  407. // Check if the entry -- is "not deletable"
  408. if (0 == pOneEntry->iDeletable)
  409. {
  410. bAdd_able = FALSE;
  411. bRemove_able = FALSE;
  412. }
  413. else
  414. {
  415. bRemove_able = TRUE;
  416. }
  417. // check if it's currently prohibited...
  418. // then we should allow them to "allow"
  419. if (WEBSVCEXT_STATUS_PROHIBITED == pOneEntry->iStatus)
  420. {
  421. bEnable_able = TRUE;
  422. }
  423. // check if it's currently allowed...
  424. // then we should allow them to "prohibit"
  425. if (WEBSVCEXT_STATUS_ALLOWED == pOneEntry->iStatus)
  426. {
  427. bDisable_able = TRUE;
  428. }
  429. }
  430. }
  431. if (bAdd_able || bRemove_able)
  432. {
  433. // if we are on one of the "special" entries
  434. // then we cannot add or remove to the entry.
  435. if (WEBSVCEXT_TYPE_ALL_UNKNOWN_ISAPI == m_pRestrictionUIEntry->iType || WEBSVCEXT_TYPE_ALL_UNKNOWN_CGI == m_pRestrictionUIEntry->iType)
  436. {
  437. bAdd_able = FALSE;
  438. bRemove_able = FALSE;
  439. }
  440. // or if our entry is marked as not delet-able...
  441. // then the user cannot add or remove from this list...
  442. for(pos = m_MyRestrictionList.GetStartPosition();pos != NULL;)
  443. {
  444. m_MyRestrictionList.GetNextAssoc(pos, TheKey, (CRestrictionEntry *&) pOneEntry);
  445. if (pOneEntry)
  446. {
  447. bNoEntries = FALSE;
  448. if (0 == pOneEntry->iDeletable)
  449. {
  450. bAdd_able = FALSE;
  451. bRemove_able = FALSE;
  452. break;
  453. }
  454. }
  455. }
  456. }
  457. if (TRUE == bNoEntries)
  458. {
  459. for(pos = m_MyRestrictionList.GetStartPosition();pos != NULL;)
  460. {
  461. m_MyRestrictionList.GetNextAssoc(pos, TheKey, (CRestrictionEntry *&) pOneEntry);
  462. if (pOneEntry)
  463. {
  464. bNoEntries = FALSE;
  465. break;
  466. }
  467. }
  468. }
  469. m_bnt_Add.EnableWindow(bAdd_able);
  470. m_bnt_Remove.EnableWindow(bRemove_able);
  471. m_bnt_Enable.EnableWindow(bEnable_able);
  472. m_bnt_Disable.EnableWindow(bDisable_able);
  473. if (bNoEntries)
  474. {
  475. // disable the OK button
  476. SetModified(FALSE);
  477. ::EnableWindow(::GetDlgItem(::GetForegroundWindow(), IDOK), FALSE);
  478. }
  479. else
  480. {
  481. // enable the OK button
  482. ::EnableWindow(::GetDlgItem(::GetForegroundWindow(), IDOK), TRUE);
  483. }
  484. m_list_Files.EnableWindow(TRUE);
  485. }
  486. void
  487. CWebServiceExtensionRequiredFiles::OnClickListFiles(NMHDR * pNMHDR, LRESULT * pResult)
  488. {
  489. SetControlState();
  490. *pResult = 0;
  491. }
  492. void
  493. CWebServiceExtensionRequiredFiles::OnKeydownListFiles(NMHDR * pNMHDR, LRESULT* pResult)
  494. {
  495. LV_KEYDOWN * pLVKeyDow = (LV_KEYDOWN *)pNMHDR;
  496. SetControlState();
  497. switch (pLVKeyDow->wVKey)
  498. {
  499. case VK_INSERT:
  500. SendMessage(WM_COMMAND, IDC_BTN_ADD);
  501. break;
  502. case VK_DELETE:
  503. SendMessage(WM_COMMAND, IDC_BTN_REMOVE);
  504. break;
  505. case VK_SPACE:
  506. {
  507. if (GetDlgItem(IDC_BTN_ENABLE)->IsWindowEnabled())
  508. {
  509. OnDoButtonEnable();
  510. }
  511. else if (GetDlgItem(IDC_BTN_DISABLE)->IsWindowEnabled())
  512. {
  513. OnDoButtonDisable();
  514. }
  515. SetControlState();
  516. }
  517. break;
  518. default:
  519. // Continue default action
  520. *pResult = 0;
  521. break;
  522. }
  523. }
  524. void
  525. CWebServiceExtensionRequiredFiles::OnSelChangedListFiles(NMHDR* pNMHDR, LRESULT* pResult)
  526. {
  527. SetControlState();
  528. *pResult = 1;
  529. }
  530. void
  531. CWebServiceExtensionRequiredFiles::OnDblclkListFiles(NMHDR * pNMHDR, LRESULT * pResult)
  532. {
  533. if (GetDlgItem(IDC_BTN_ENABLE)->IsWindowEnabled())
  534. {
  535. OnDoButtonEnable();
  536. }
  537. else if (GetDlgItem(IDC_BTN_DISABLE)->IsWindowEnabled())
  538. {
  539. OnDoButtonDisable();
  540. }
  541. SetControlState();
  542. *pResult = 0;
  543. }
  544. void
  545. CWebServiceExtensionRequiredFiles::OnDoButtonAdd()
  546. {
  547. CFileDlg dlg(IsLocal(), m_pInterface, &m_MyRestrictionList, m_pRestrictionUIEntry ? m_pRestrictionUIEntry->strGroupID : _T(""), this);
  548. if (dlg.DoModal() == IDOK)
  549. {
  550. // Get the filename that they entered
  551. // and add it to our list.
  552. CString strReturnFileName;
  553. strReturnFileName = dlg.m_strFileName;
  554. {
  555. // Get the Status
  556. int iMyStatus = WEBSVCEXT_STATUS_PROHIBITED;
  557. {
  558. POSITION pos;
  559. CString TheKey;
  560. CRestrictionEntry * pOneEntry = NULL;
  561. for(pos = m_MyRestrictionList.GetStartPosition();pos != NULL;)
  562. {
  563. m_MyRestrictionList.GetNextAssoc(pos, TheKey, (CRestrictionEntry *&) pOneEntry);
  564. if (pOneEntry)
  565. {
  566. if (WEBSVCEXT_STATUS_ALLOWED == pOneEntry->iStatus)
  567. {
  568. iMyStatus = WEBSVCEXT_STATUS_ALLOWED;
  569. break;
  570. }
  571. }
  572. }
  573. }
  574. CRestrictionEntry * pNewEntry = CreateRestrictionEntry(
  575. strReturnFileName,
  576. iMyStatus,
  577. 1,
  578. m_pRestrictionUIEntry ? m_pRestrictionUIEntry->strGroupID : _T(""), // from parent data
  579. m_pRestrictionUIEntry ? m_pRestrictionUIEntry->strGroupDescription : _T(""), // from parent data
  580. WEBSVCEXT_TYPE_REGULAR);
  581. if (pNewEntry)
  582. {
  583. // THE KEY IS ALWAYS UPPERASE -- REMEMBER THIS!!!!!!!
  584. CString strKey;strKey=pNewEntry->strFileName;strKey.MakeUpper();
  585. m_MyRestrictionList.SetAt(strKey,pNewEntry);
  586. FillListBox(pNewEntry);
  587. }
  588. }
  589. }
  590. SetControlState();
  591. SetModified(TRUE);
  592. }
  593. void
  594. CWebServiceExtensionRequiredFiles::OnDoButtonRemove()
  595. {
  596. int nCurSel = m_list_Files.GetSelectionMark();
  597. if (-1 != nCurSel)
  598. {
  599. CString TheKey;
  600. CRestrictionEntry * pRestrictionEntry = m_list_Files.GetItem(nCurSel);
  601. if (pRestrictionEntry)
  602. {
  603. // 1st -- set to disabled...
  604. pRestrictionEntry->iStatus = WEBSVCEXT_STATUS_PROHIBITED;
  605. m_list_Files.SetListItem(nCurSel, pRestrictionEntry);
  606. // then remove the entry...
  607. {
  608. TheKey = pRestrictionEntry->strFileName;
  609. // THE KEY IS ALWAYS UPPERASE -- REMEMBER THIS!!!!!!!
  610. TheKey.MakeUpper();
  611. m_MyRestrictionList.RemoveKey(TheKey);
  612. }
  613. }
  614. FillListBox(NULL);
  615. int count = m_list_Files.GetItemCount();
  616. if (count > 0)
  617. {
  618. m_list_Files.SelectItem(nCurSel < count ? nCurSel : --nCurSel);
  619. GetDlgItem(IDC_BTN_REMOVE)->SetFocus();
  620. }
  621. else
  622. {
  623. m_list_Files.SelectItem(nCurSel, FALSE);
  624. GetDlgItem(IDC_LIST_FILES)->SetFocus();
  625. }
  626. SetModified(TRUE);
  627. SetControlState();
  628. }
  629. }
  630. void
  631. CWebServiceExtensionRequiredFiles::OnDoButtonEnable()
  632. {
  633. int nCurSel = m_list_Files.GetSelectionMark();
  634. if (-1 != nCurSel)
  635. {
  636. CRestrictionEntry * pRestrictionEntry = m_list_Files.GetItem(nCurSel);
  637. if (pRestrictionEntry)
  638. {
  639. if (WEBSVCEXT_STATUS_ALLOWED != pRestrictionEntry->iStatus)
  640. {
  641. pRestrictionEntry->iStatus = WEBSVCEXT_STATUS_ALLOWED;
  642. SetModified(TRUE);
  643. }
  644. m_list_Files.SetListItem(nCurSel, pRestrictionEntry);
  645. // make sure to select it.
  646. m_list_Files.SelectItem(nCurSel, TRUE);
  647. }
  648. SetControlState();
  649. }
  650. }
  651. void
  652. CWebServiceExtensionRequiredFiles::OnDoButtonDisable()
  653. {
  654. BOOL bProceed = TRUE;
  655. int nCurSel = m_list_Files.GetSelectionMark();
  656. if (-1 != nCurSel)
  657. {
  658. CRestrictionEntry * pRestrictionEntry = m_list_Files.GetItem(nCurSel);
  659. if (pRestrictionEntry)
  660. {
  661. if (WEBSVCEXT_TYPE_REGULAR == pRestrictionEntry->iType)
  662. {
  663. // Check if this item has apps that
  664. // are dependent upon it.
  665. CStringListEx strlstDependApps;
  666. if (TRUE == ReturnDependentAppsList(m_pInterface,pRestrictionEntry->strGroupID,&strlstDependApps,FALSE))
  667. {
  668. bProceed = FALSE;
  669. // check if they really want to do this.
  670. CDepedentAppsDlg dlg(&strlstDependApps,pRestrictionEntry->strGroupDescription,NULL);
  671. if (dlg.DoModal() == IDOK)
  672. {
  673. bProceed = TRUE;
  674. }
  675. }
  676. }
  677. if (bProceed)
  678. {
  679. if (WEBSVCEXT_STATUS_PROHIBITED != pRestrictionEntry->iStatus)
  680. {
  681. pRestrictionEntry->iStatus = WEBSVCEXT_STATUS_PROHIBITED;
  682. SetModified(TRUE);
  683. }
  684. m_list_Files.SetListItem(nCurSel, pRestrictionEntry);
  685. // make sure to select it.
  686. m_list_Files.SelectItem(nCurSel, TRUE);
  687. }
  688. }
  689. SetControlState();
  690. }
  691. }
  692. //
  693. // properties
  694. //
  695. CWebServiceExtensionProps::CWebServiceExtensionProps(
  696. CMetaInterface * pInterface,
  697. LPCTSTR meta_path,
  698. CRestrictionUIEntry * pRestrictionUIEntry,
  699. CWebServiceExtension * pWebServiceExtension
  700. )
  701. : CMetaProperties(pInterface, meta_path),
  702. m_pRestrictionUIEntry(pRestrictionUIEntry),
  703. m_pWebServiceExtension(pWebServiceExtension)
  704. {
  705. m_MyRestrictionList.RemoveAll();
  706. m_pInterface = pInterface;
  707. }
  708. CWebServiceExtensionProps::~CWebServiceExtensionProps()
  709. {
  710. CleanRestrictionList(&m_MyRestrictionList);
  711. }
  712. //
  713. // This is where the values get read from the metabase
  714. //
  715. void
  716. CWebServiceExtensionProps::ParseFields()
  717. {
  718. // Get the data out from our passed in format.
  719. CRestrictionUIEntry * pMyPointer = m_pRestrictionUIEntry;
  720. CString strAllEntries;
  721. CString strOurGroupID;
  722. strOurGroupID = pMyPointer->strGroupID;
  723. //
  724. // General property
  725. //
  726. m_strExtensionName = pMyPointer->strGroupDescription;
  727. m_strExtensionUsedBy = _T("");
  728. m_iExtensionUsedByCount = 0;
  729. // Load Applications which are using this GroupID!!!
  730. // fetch the list from the metabase and loop thru the list
  731. CStringListEx strlstDependApps;
  732. if (TRUE == ReturnDependentAppsList(m_pWebServiceExtension->QueryInterface(),strOurGroupID,&strlstDependApps,FALSE))
  733. {
  734. CString csOneEntry,csOneEntry2;
  735. POSITION pos,pos2 = NULL;
  736. int count = (int) strlstDependApps.GetCount();
  737. for (int i = 0; i < count-1; i++)
  738. {
  739. if( ( pos = strlstDependApps.FindIndex( i )) != NULL )
  740. {
  741. csOneEntry = strlstDependApps.GetAt(pos);
  742. for (int j = i; j < count; j++ )
  743. {
  744. if( ( pos2 = strlstDependApps.FindIndex( j )) != NULL )
  745. {
  746. csOneEntry2 = strlstDependApps.GetAt(pos2);
  747. if (0 < csOneEntry.Compare(csOneEntry2))
  748. {
  749. strlstDependApps.SetAt( pos, csOneEntry2 );
  750. strlstDependApps.SetAt( pos2, csOneEntry );
  751. csOneEntry = csOneEntry2;
  752. }
  753. }
  754. }
  755. }
  756. }
  757. m_iExtensionUsedByCount = count;
  758. }
  759. POSITION pos1 = strlstDependApps.GetHeadPosition();
  760. while (pos1)
  761. {
  762. strAllEntries = strAllEntries + strlstDependApps.GetNext(pos1);
  763. strAllEntries = strAllEntries + _T("\r\n");
  764. }
  765. if (strAllEntries.IsEmpty())
  766. {
  767. strAllEntries.LoadString(IDS_UNKNOWN);
  768. }
  769. m_strExtensionUsedBy = strAllEntries;
  770. //
  771. // Required Files propety
  772. //
  773. m_MyRestrictionList.RemoveAll();
  774. RestrictionListCopy(&m_MyRestrictionList,&pMyPointer->strlstRestrictionEntries);
  775. return;
  776. }
  777. HRESULT
  778. CWebServiceExtensionProps::UpdateMMC(DWORD dwUpdateFlag)
  779. {
  780. void ** ppParam = (void **) m_pWebServiceExtension;
  781. if (IsValidAddress( (const void*) *ppParam,sizeof(void*),FALSE))
  782. {
  783. CWebServiceExtension * lParam = (CWebServiceExtension *) m_pWebServiceExtension;
  784. if (lParam)
  785. {
  786. // Make sure to refresh the GetProperty stuff too..
  787. // this will be done in the destructor, so we don't have to do it here
  788. if (lParam)
  789. {
  790. // caution
  791. if (IsValidAddress( (const void*) lParam->m_ppHandle,sizeof(void*),FALSE))
  792. {
  793. if (lParam->QueryResultItem())
  794. {
  795. // RefreshData at the container level
  796. // will sync up everything.
  797. lParam->m_UpdateFlag = dwUpdateFlag; //PROP_CHANGE_DISPLAY_ONLY;
  798. MMCPropertyChangeNotify(lParam->m_ppHandle, (LPARAM) lParam);
  799. }
  800. else
  801. {
  802. TRACEEOLID("MMCPropertyChangeNotify:Looks like this is an orphaned property sheet, don't send notification...\r\n");
  803. }
  804. }
  805. }
  806. }
  807. }
  808. return S_OK;
  809. }
  810. //
  811. // This is where the values get written to the metabase
  812. //
  813. HRESULT
  814. CWebServiceExtensionProps::WriteDirtyProps()
  815. {
  816. CError err;
  817. CRestrictionUIList MasterRestrictionUIList;
  818. CRestrictionUIEntry NewUIEntry;
  819. CMetaInterface * pInterface = m_pInterface;
  820. // Get the data out from our passed in format.
  821. CRestrictionUIEntry * pMyPointer = m_pRestrictionUIEntry;
  822. if (!pMyPointer)
  823. {
  824. return E_POINTER;
  825. }
  826. NewUIEntry.iType = pMyPointer->iType;
  827. NewUIEntry.strGroupID = pMyPointer->strGroupID;
  828. NewUIEntry.strGroupDescription = m_strExtensionName;
  829. // if there is restrictionlist entries
  830. // then add it to the new entry we are going to write to the metabase.
  831. {
  832. POSITION pos;
  833. CString TheKey;
  834. CRestrictionEntry * pOneEntry = NULL;
  835. for(pos = m_MyRestrictionList.GetStartPosition();pos != NULL;)
  836. {
  837. m_MyRestrictionList.GetNextAssoc(pos, TheKey, (CRestrictionEntry *&) pOneEntry);
  838. if (pOneEntry)
  839. {
  840. // THE KEY IS ALWAYS UPPERASE -- REMEMBER THIS!!!!!!!
  841. TheKey.MakeUpper();
  842. NewUIEntry.strlstRestrictionEntries.SetAt(TheKey,pOneEntry);
  843. }
  844. }
  845. pMyPointer->strGroupDescription = m_strExtensionName;
  846. // Check if we still have the interface to the metabase...
  847. if (pInterface)
  848. {
  849. err = CheckForMetabaseAccess(METADATA_PERMISSION_READ,pInterface,METABASE_PATH_FOR_RESTRICT_LIST);
  850. if (err.Failed())
  851. {
  852. goto WriteDirtyProps_Exit;
  853. }
  854. }
  855. if (SUCCEEDED(LoadMasterUIWithoutOldEntry(pInterface,&MasterRestrictionUIList,pMyPointer)))
  856. {
  857. if (m_MyRestrictionList.IsEmpty())
  858. {
  859. // if there are no restrictionlist entries...
  860. // then we don't have an entry... remove it
  861. AddRestrictUIEntryToRestrictUIList(&MasterRestrictionUIList,NULL);
  862. }
  863. else
  864. {
  865. AddRestrictUIEntryToRestrictUIList(&MasterRestrictionUIList,&NewUIEntry);
  866. }
  867. // Merge our changes with the master list!!!!!
  868. // 1. read the master list.
  869. // 2. merge our changes into it.
  870. // 3. write out the master list.
  871. // 4. update the UI.
  872. CStringListEx strlstReturned;
  873. if (SUCCEEDED(PrepRestictionUIListForWrite(&MasterRestrictionUIList,&strlstReturned)))
  874. {
  875. // Write out the strlstReturned to the metabase.
  876. err = OpenForWriting(FALSE);
  877. if (err.Succeeded())
  878. {
  879. err = SetValue(MD_WEB_SVC_EXT_RESTRICTION_LIST, strlstReturned);
  880. Close();
  881. }
  882. if (err.Succeeded())
  883. {
  884. // update the UI with the changed value
  885. // 1. remove the UI's old value
  886. // 2. add in the new value to the UI
  887. //
  888. // get the list of extensions
  889. // update our entry or delete our entry...
  890. // copy new value into existing place.
  891. // this will clean out the existing place's objects...
  892. UpdateMMC(0);
  893. }
  894. }
  895. }
  896. }
  897. WriteDirtyProps_Exit:
  898. //m_Dirty = err.Succeeded();
  899. return err;
  900. }
  901. // -----------------------------------------------------------
  902. CFileDlg::CFileDlg(
  903. IN BOOL fLocal,
  904. IN CMetaInterface * pInterface,
  905. IN CRestrictionList * pMyRestrictionList,
  906. IN LPCTSTR strGroupID,
  907. IN CWnd * pParent OPTIONAL
  908. )
  909. : CDialog(CFileDlg::IDD, pParent),
  910. m_fLocal(fLocal)
  911. {
  912. //{{AFX_DATA_INIT(CFileDlg)
  913. m_strFileName = _T("");
  914. m_pInterface = pInterface;
  915. m_strGroupID = strGroupID;
  916. m_pRestrictionList = pMyRestrictionList;
  917. m_bValidateFlag = FALSE;
  918. //}}AFX_DATA_INIT
  919. }
  920. void
  921. CFileDlg::DoDataExchange(
  922. IN CDataExchange * pDX
  923. )
  924. {
  925. CDialog::DoDataExchange(pDX);
  926. //{{AFX_DATA_MAP(CFileDlg)
  927. DDX_Control(pDX, IDOK, m_button_Ok);
  928. DDX_Control(pDX, IDC_EDIT_FILENAME, m_edit_FileName);
  929. DDX_Control(pDX, IDC_BUTTON_BROWSE, m_button_Browse);
  930. //}}AFX_DATA_MAP
  931. DDX_Text(pDX, IDC_EDIT_FILENAME, m_strFileName);
  932. if (pDX->m_bSaveAndValidate)
  933. {
  934. DDV_MaxCharsBalloon(pDX, m_strFileName, 255);
  935. int iErrorMsg = 0;
  936. m_strFileName.TrimLeft();m_strFileName.TrimRight();
  937. CString csPathMunged;
  938. csPathMunged = m_strFileName;
  939. #ifdef SUPPORT_SLASH_SLASH_QUESTIONMARK_SLASH_TYPE_PATHS
  940. GetSpecialPathRealPath(0,m_strFileName,csPathMunged);
  941. #endif
  942. //DDV_FilePath(pDX, csPathMunged, m_fLocal);
  943. // if this is a path/filename without a .ext then remove any period from the end.
  944. // check if it ends with a period.
  945. if (csPathMunged.Right(1) == _T("."))
  946. {
  947. TCHAR szFilename_ext_only[_MAX_EXT];
  948. _tsplitpath(csPathMunged, NULL, NULL, NULL, szFilename_ext_only);
  949. if (szFilename_ext_only)
  950. {
  951. if (0 == _tcscmp(szFilename_ext_only,_T(".")))
  952. {
  953. csPathMunged.TrimRight(_T("."));
  954. }
  955. }
  956. }
  957. DWORD dwAllowedFlags = CHKPATH_ALLOW_UNC_PATH;
  958. DWORD dwCharsetFlags = CHKPATH_CHARSET_GENERAL;
  959. dwCharsetFlags |= CHKPATH_CHARSET_GENERAL_NO_COMMA;
  960. FILERESULT dwReturn = MyValidatePath(csPathMunged,m_fLocal,CHKPATH_WANT_FILE,dwAllowedFlags,dwCharsetFlags);
  961. if (FAILED(dwReturn))
  962. {
  963. iErrorMsg = IDS_WEBSVCEXT_INVALID_FILENAME_FORMAT;
  964. if (IS_FLAG_SET(dwReturn,CHKPATH_FAIL_INVALID_CHARSET))
  965. {
  966. iErrorMsg = IDS_WEBSVCEXT_INVALID_FILENAME_CHARS;
  967. }
  968. else
  969. {
  970. if (dwReturn == CHKPATH_FAIL_NOT_ALLOWED_DIR_NOT_EXIST)
  971. {
  972. iErrorMsg = IDS_ERR_PATH_NOT_FOUND;
  973. }
  974. }
  975. }
  976. else
  977. {
  978. // check for % character
  979. // there must be at least 2
  980. TCHAR * pChar = NULL;
  981. pChar = _tcschr(csPathMunged, _T('%'));
  982. if (pChar)
  983. {
  984. pChar++;
  985. pChar = _tcschr(pChar, _T('%'));
  986. if (pChar)
  987. {
  988. TRACEEOL("Path:Warn if percent character");
  989. iErrorMsg = IDS_WEBSVCEXT_INVALID_PERCENT_WARNING;
  990. }
  991. }
  992. }
  993. // Check for invalid characters
  994. if (0 != iErrorMsg)
  995. {
  996. if (IDS_WEBSVCEXT_INVALID_PERCENT_WARNING == iErrorMsg)
  997. {
  998. // For some reason, we need this
  999. // flag so that we don't show the message twice...
  1000. if (!m_bValidateFlag)
  1001. {
  1002. if (IDCANCEL == ::AfxMessageBox(IDS_WEBSVCEXT_INVALID_PERCENT_WARNING,MB_ICONINFORMATION | MB_OKCANCEL | MB_DEFBUTTON2))
  1003. {
  1004. m_bValidateFlag = FALSE;
  1005. pDX->Fail();
  1006. }
  1007. else
  1008. {
  1009. // ensure user doesn't see the 2nd msgbox
  1010. m_bValidateFlag = TRUE;
  1011. }
  1012. }
  1013. else
  1014. {
  1015. // flip it back on
  1016. m_bValidateFlag = FALSE;
  1017. }
  1018. }
  1019. else if (IDS_WEBSVCEXT_INVALID_FILENAME_CHARS == iErrorMsg)
  1020. {
  1021. // formulate the real error message
  1022. CString strMsg;
  1023. CString strTempList;
  1024. CComBSTR strTempFormat;
  1025. strTempFormat.LoadString(IDS_WEBSVCEXT_INVALID_FILENAME_CHARS);
  1026. LoadStatics();
  1027. strTempList = _T(":");
  1028. strTempList += g_InvalidWebSvcExtCharsPath;
  1029. strMsg.Format(strTempFormat,strTempList);
  1030. DDV_ShowBalloonAndFail(pDX, strMsg);
  1031. m_bValidateFlag = FALSE;
  1032. }
  1033. else
  1034. {
  1035. DDV_ShowBalloonAndFail(pDX, iErrorMsg);
  1036. m_bValidateFlag = FALSE;
  1037. }
  1038. }
  1039. }
  1040. }
  1041. //
  1042. // Message Map
  1043. //
  1044. BEGIN_MESSAGE_MAP(CFileDlg, CDialog)
  1045. //{{AFX_MSG_MAP(CFileDlg)
  1046. ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
  1047. ON_EN_CHANGE(IDC_EDIT_FILENAME, OnFilenameChanged)
  1048. //}}AFX_MSG_MAP
  1049. END_MESSAGE_MAP()
  1050. //
  1051. // Message Handlers
  1052. //
  1053. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1054. HRESULT AFXAPI
  1055. MyLimitInputPath(HWND hWnd)
  1056. {
  1057. CString strMsg;
  1058. CComBSTR strTempFormat;
  1059. strTempFormat.LoadString(IDS_WEBSVCEXT_INVALID_FILENAME_CHARS);
  1060. LoadStatics();
  1061. strMsg.Format(strTempFormat,g_InvalidWebSvcExtCharsPath);
  1062. LIMITINPUT li = {0};
  1063. li.cbSize = sizeof(li);
  1064. li.dwMask = LIM_FLAGS | LIM_FILTER | LIM_MESSAGE | LIM_HINST;
  1065. li.dwFlags = LIF_EXCLUDEFILTER | LIF_HIDETIPONVALID | LIF_PASTESKIP;
  1066. li.hinst = _Module.GetResourceInstance();
  1067. // don't ask me why, but when we use this
  1068. // it truncates it to like 80 chars.
  1069. // specifying an actual string allows more than 80
  1070. //li.pszMessage = MAKEINTRESOURCE(IDS_WEBSVCEXT_INVALID_FILENAME_CHARS);
  1071. li.pszMessage = (LPTSTR) (LPCTSTR) strMsg;
  1072. li.pszFilter = g_InvalidWebSvcExtCharsPath;
  1073. return SHLimitInputEditWithFlags(hWnd, &li);
  1074. }
  1075. HRESULT AFXAPI
  1076. MyLimitInputName(HWND hWnd)
  1077. {
  1078. CComBSTR strTempString;
  1079. strTempString.LoadString(IDS_WEBSVCEXT_INVALID_NAME_CHARS);
  1080. LoadStatics();
  1081. LIMITINPUT li = {0};
  1082. li.cbSize = sizeof(li);
  1083. li.dwMask = LIM_FLAGS | LIM_FILTER | LIM_MESSAGE | LIM_HINST;
  1084. li.dwFlags = LIF_EXCLUDEFILTER | LIF_HIDETIPONVALID | LIF_PASTESKIP;
  1085. li.hinst = _Module.GetResourceInstance();
  1086. // don't ask me why, but when we use this
  1087. // it truncates it to like 80 chars.
  1088. // specifying an actual string allows more than 80
  1089. //li.pszMessage = MAKEINTRESOURCE(IDS_WEBSVCEXT_INVALID_NAME_CHARS);
  1090. li.pszMessage = strTempString;
  1091. li.pszFilter = g_InvalidWebSvcExtCharsName;
  1092. return SHLimitInputEditWithFlags(hWnd, &li);
  1093. }
  1094. BOOL
  1095. CFileDlg::OnInitDialog()
  1096. {
  1097. CDialog::OnInitDialog();
  1098. //
  1099. // Available on local connections only
  1100. //
  1101. m_button_Browse.EnableWindow(m_fLocal);
  1102. MySetControlStates();
  1103. MyLimitInputPath(CONTROL_HWND(IDC_EDIT_FILENAME));
  1104. return TRUE;
  1105. }
  1106. void
  1107. CFileDlg::OnButtonBrowse()
  1108. {
  1109. ASSERT(m_fLocal);
  1110. CString strFileMask((LPCTSTR)IDS_ISAPI_CGI_MASK);
  1111. //
  1112. // CODEWORK: Derive a class from CFileDialog that allows
  1113. // the setting of the initial path
  1114. //
  1115. //CString strPath;
  1116. //m_edit_FileName.GetWindowText(strPath);
  1117. CFileDialog dlgBrowse(
  1118. TRUE,
  1119. NULL,
  1120. NULL,
  1121. OFN_HIDEREADONLY,
  1122. strFileMask,
  1123. this
  1124. );
  1125. // Disable hook to get Windows 2000 style dialog
  1126. dlgBrowse.m_ofn.Flags &= ~(OFN_ENABLEHOOK);
  1127. dlgBrowse.m_ofn.Flags |= OFN_DONTADDTORECENT|OFN_FILEMUSTEXIST;
  1128. INT_PTR rc = dlgBrowse.DoModal();
  1129. if (rc == IDOK)
  1130. {
  1131. m_edit_FileName.SetWindowText(dlgBrowse.GetPathName());
  1132. }
  1133. else if (rc == IDCANCEL)
  1134. {
  1135. DWORD err = CommDlgExtendedError();
  1136. }
  1137. OnItemChanged();
  1138. }
  1139. void
  1140. CFileDlg::MySetControlStates()
  1141. {
  1142. m_button_Ok.EnableWindow(m_edit_FileName.GetWindowTextLength() > 0);
  1143. }
  1144. void
  1145. CFileDlg::OnItemChanged()
  1146. {
  1147. MySetControlStates();
  1148. }
  1149. void
  1150. CFileDlg::OnFilenameChanged()
  1151. {
  1152. OnItemChanged();
  1153. }
  1154. BOOL
  1155. CFileDlg::FilePathEntryExists(
  1156. IN LPCTSTR lpName,
  1157. IN OUT CString * strUser
  1158. )
  1159. /*++
  1160. Routine Description:
  1161. Look for a given filename in the list
  1162. Arguments:
  1163. LPCTSTR lpName : filename name to look for
  1164. Return Value:
  1165. TRUE if the name already existed in the metabase
  1166. --*/
  1167. {
  1168. // Loop thru to ensure that this specified path\filename
  1169. // isn't already being used in the metabase by
  1170. // a different entry.
  1171. return IsFileUsedBySomeoneElse(m_pInterface, lpName, m_strGroupID,strUser);
  1172. }
  1173. void
  1174. CFileDlg::OnOK()
  1175. {
  1176. if (UpdateData(TRUE))
  1177. {
  1178. BOOL bInUseAlready = FALSE;
  1179. // Make sure the filname is unique
  1180. // within our own entry!
  1181. if (!m_strFileName.IsEmpty())
  1182. {
  1183. CString strUser;
  1184. CRestrictionEntry * pOneRestrictEntry = NULL;
  1185. pOneRestrictEntry = NULL;
  1186. if (m_pRestrictionList)
  1187. {
  1188. // THE KEY IS ALWAYS UPPERASE -- REMEMBER THIS!!!!!!!
  1189. CString strKey;strKey=m_strFileName;strKey.MakeUpper();
  1190. m_pRestrictionList->Lookup(strKey,(CRestrictionEntry *&) pOneRestrictEntry);
  1191. if (pOneRestrictEntry)
  1192. {
  1193. bInUseAlready = TRUE;
  1194. CComBSTR strMessage;
  1195. strMessage.LoadString(IDS_DUPLICATE_ENTRY);
  1196. EditShowBalloon(m_edit_FileName.m_hWnd, (CString) strMessage);
  1197. }
  1198. }
  1199. }
  1200. //
  1201. // Make sure the filename is unique
  1202. //
  1203. if (FALSE == bInUseAlready)
  1204. {
  1205. CString strUser;
  1206. if (FilePathEntryExists(m_strFileName,&strUser))
  1207. {
  1208. bInUseAlready = TRUE;
  1209. CString strMessage;
  1210. CComBSTR strFormat;
  1211. strFormat.LoadString(IDS_WEBSVCEXT_NOT_UNIQUE);
  1212. strMessage.Format(strFormat,strUser);
  1213. EditShowBalloon(m_edit_FileName.m_hWnd, strMessage);
  1214. }
  1215. }
  1216. // Everything okay
  1217. if (!bInUseAlready)
  1218. {
  1219. CDialog::OnOK();
  1220. }
  1221. }
  1222. //
  1223. // Don't dismiss the dialog
  1224. //
  1225. }
  1226. // -----------------------------------------------------------
  1227. CWebSvcExtAddNewDlg::CWebSvcExtAddNewDlg(
  1228. IN BOOL fLocal,
  1229. IN CMetaInterface * pInterface,
  1230. IN CWnd * pParent OPTIONAL
  1231. )
  1232. : CDialog(CWebSvcExtAddNewDlg::IDD, pParent),
  1233. m_fIsLocal(fLocal)
  1234. {
  1235. //{{AFX_DATA_INIT(CWebSvcExtAddNewDlg)
  1236. m_strGroupName = _T("");
  1237. m_fAllow = FALSE;
  1238. m_pInterface = pInterface;
  1239. m_MyRestrictionList.RemoveAll();
  1240. //}}AFX_DATA_INIT
  1241. }
  1242. CWebSvcExtAddNewDlg::~CWebSvcExtAddNewDlg()
  1243. {
  1244. CleanRestrictionList(&m_MyRestrictionList);
  1245. }
  1246. void
  1247. CWebSvcExtAddNewDlg::DoDataExchange(
  1248. IN CDataExchange * pDX
  1249. )
  1250. {
  1251. CDialog::DoDataExchange(pDX);
  1252. //{{AFX_DATA_MAP(CWebSvcExtAddNewDlg)
  1253. DDX_Control(pDX, IDC_EDIT_EXTENSION_NAME, m_edit_FileName);
  1254. DDX_Control(pDX, IDC_BTN_ADD, m_bnt_Add);
  1255. DDX_Control(pDX, IDC_BTN_REMOVE, m_bnt_Remove);
  1256. DDX_Control(pDX, IDC_CHECK_ALLOW, m_chk_Allow);
  1257. DDX_Control(pDX, IDOK, m_button_Ok);
  1258. DDX_Control(pDX, ID_HELP, m_button_Help);
  1259. //}}AFX_DATA_MAP
  1260. DDX_Text(pDX, IDC_EDIT_EXTENSION_NAME, m_strGroupName);
  1261. DDX_Control(pDX, IDC_LIST_FILES, m_list_Files);
  1262. if (pDX->m_bSaveAndValidate)
  1263. {
  1264. m_strGroupName.TrimLeft();
  1265. m_strGroupName.TrimRight();
  1266. DDV_MinMaxChars(pDX, m_strGroupName, 1, 256);
  1267. if (m_strGroupName.GetLength() > 256){DDV_ShowBalloonAndFail(pDX, IDS_ERR_INVALID_PATH /*IDS_BAD_URL_PATH*/ );}
  1268. }
  1269. //if (pDX->m_bSaveAndValidate){DDV_FilePath(pDX, m_strGroupName, m_fLocal);}
  1270. }
  1271. //
  1272. // Message Map
  1273. //
  1274. BEGIN_MESSAGE_MAP(CWebSvcExtAddNewDlg, CDialog)
  1275. //{{AFX_MSG_MAP(CWebSvcExtAddNewDlg)
  1276. ON_EN_CHANGE(IDC_EDIT_EXTENSION_NAME, OnFilenameChanged)
  1277. ON_BN_CLICKED(IDC_BTN_ADD, OnDoButtonAdd)
  1278. ON_BN_CLICKED(IDC_BTN_REMOVE, OnDoButtonRemove)
  1279. ON_BN_CLICKED(IDC_CHECK_ALLOW, OnDoCheckAllow)
  1280. ON_NOTIFY(NM_CLICK, IDC_LIST_FILES, OnClickListFiles)
  1281. ON_NOTIFY(LVN_KEYDOWN, IDC_LIST_FILES, OnKeydownListFiles)
  1282. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_FILES, OnSelChangedListFiles)
  1283. ON_NOTIFY(LVN_BEGINDRAG, IDC_LIST_FILES, OnSelChangedListFiles)
  1284. ON_COMMAND(ID_HELP, OnHelp)
  1285. ON_WM_HELPINFO()
  1286. //}}AFX_MSG_MAP
  1287. END_MESSAGE_MAP()
  1288. //
  1289. // Message Handlers
  1290. //
  1291. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1292. BOOL
  1293. CWebSvcExtAddNewDlg::OnInitDialog()
  1294. {
  1295. CDialog::OnInitDialog();
  1296. m_list_Files.Initialize(1);
  1297. m_fAllow = FALSE;
  1298. m_chk_Allow.SetCheck(m_fAllow);
  1299. MySetControlStates();
  1300. MyLimitInputName(CONTROL_HWND(IDC_EDIT_EXTENSION_NAME));
  1301. return TRUE;
  1302. }
  1303. BOOL
  1304. CWebSvcExtAddNewDlg::OnHelpInfo(HELPINFO * pHelpInfo)
  1305. {
  1306. OnHelp();
  1307. return TRUE;
  1308. }
  1309. void
  1310. CWebSvcExtAddNewDlg::OnHelp()
  1311. {
  1312. WinHelpDebug(0x20000 + CWebSvcExtAddNewDlg::IDD);
  1313. ::WinHelp(m_hWnd, theApp.m_pszHelpFilePath, HELP_CONTEXT, 0x20000 + CWebSvcExtAddNewDlg::IDD);
  1314. }
  1315. void
  1316. CWebSvcExtAddNewDlg::MySetControlStates()
  1317. {
  1318. m_edit_FileName.EnableWindow(TRUE);
  1319. m_bnt_Add.EnableWindow(TRUE);
  1320. m_list_Files.EnableWindow(TRUE);
  1321. // Enable Remove only if there is something selected...
  1322. int nCurSel = m_list_Files.GetSelectionMark();
  1323. if (-1 != nCurSel)
  1324. {
  1325. m_bnt_Remove.EnableWindow(TRUE);
  1326. }
  1327. else
  1328. {
  1329. m_bnt_Remove.EnableWindow(FALSE);
  1330. }
  1331. // Enable OK only if there is a filename
  1332. // and at least one entry in the list box
  1333. int nCount = m_list_Files.GetItemCount();
  1334. if (nCount > 0)
  1335. {
  1336. m_button_Ok.EnableWindow(m_edit_FileName.GetWindowTextLength() > 0);
  1337. }
  1338. else
  1339. {
  1340. m_button_Ok.EnableWindow(FALSE);
  1341. }
  1342. m_fAllow = m_chk_Allow.GetCheck();
  1343. }
  1344. void
  1345. CWebSvcExtAddNewDlg::OnItemChanged()
  1346. {
  1347. MySetControlStates();
  1348. }
  1349. void
  1350. CWebSvcExtAddNewDlg::OnFilenameChanged()
  1351. {
  1352. OnItemChanged();
  1353. }
  1354. BOOL
  1355. CWebSvcExtAddNewDlg::FilePathEntryExists(
  1356. IN LPCTSTR lpName
  1357. )
  1358. {
  1359. // Loop thru to ensure that this specified GroupID
  1360. // isn't already being used in the metabase by
  1361. // a different entry.
  1362. return IsGroupIDUsedBySomeoneElse(m_pInterface, lpName);
  1363. }
  1364. void
  1365. CWebSvcExtAddNewDlg::OnOK()
  1366. {
  1367. if (UpdateData(TRUE))
  1368. {
  1369. //
  1370. // Make sure the group name is unique
  1371. //
  1372. if (FilePathEntryExists(m_strGroupName))
  1373. {
  1374. EditShowBalloon(m_edit_FileName.m_hWnd, IDS_WEBSVCEXT_ID_NOT_UNIQUE);
  1375. return;
  1376. }
  1377. CDialog::OnOK();
  1378. }
  1379. }
  1380. void
  1381. CWebSvcExtAddNewDlg::OnDoCheckAllow()
  1382. {
  1383. m_fAllow = !m_fAllow;
  1384. OnItemChanged();
  1385. MySetControlStates();
  1386. }
  1387. void
  1388. CWebSvcExtAddNewDlg::OnDoButtonAdd()
  1389. {
  1390. int nCurSel = m_list_Files.GetSelectionMark();
  1391. CFileDlg dlg(m_fIsLocal, m_pInterface, &m_MyRestrictionList, _T(""), this);
  1392. if (dlg.DoModal() == IDOK)
  1393. {
  1394. // Get the filename that they entered
  1395. // and add it to our list.
  1396. CString strReturnFileName;
  1397. strReturnFileName = dlg.m_strFileName;
  1398. {
  1399. CRestrictionEntry * pNewEntry = CreateRestrictionEntry(
  1400. strReturnFileName,
  1401. WEBSVCEXT_STATUS_ALLOWED, // doesn't matter we won't use what gets set here..
  1402. 1, // doesn't matter we won't use what gets set here..
  1403. _T(""),
  1404. _T(""),
  1405. WEBSVCEXT_TYPE_REGULAR // doesn't matter we won't use what gets set here..
  1406. );
  1407. if (pNewEntry)
  1408. {
  1409. // THE KEY IS ALWAYS UPPERASE -- REMEMBER THIS!!!!!!!
  1410. CString strKey;strKey=pNewEntry->strFileName;strKey.MakeUpper();
  1411. m_MyRestrictionList.SetAt(strKey,pNewEntry);
  1412. FillListBox(pNewEntry);
  1413. }
  1414. }
  1415. }
  1416. MySetControlStates();
  1417. }
  1418. void
  1419. CWebSvcExtAddNewDlg::OnDoButtonRemove()
  1420. {
  1421. int nCurSel = m_list_Files.GetSelectionMark();
  1422. if (-1 != nCurSel)
  1423. {
  1424. CString TheKey;
  1425. CRestrictionEntry * pRestrictionEntry = m_list_Files.GetItem(nCurSel);
  1426. if (pRestrictionEntry)
  1427. {
  1428. // remove the entry...
  1429. {
  1430. TheKey = pRestrictionEntry->strFileName;
  1431. // THE KEY IS ALWAYS UPPERASE -- REMEMBER THIS!!!!!!!
  1432. TheKey.MakeUpper();
  1433. m_MyRestrictionList.RemoveKey(TheKey);
  1434. }
  1435. }
  1436. FillListBox(NULL);
  1437. int count = m_list_Files.GetItemCount();
  1438. if (count > 0)
  1439. {
  1440. m_list_Files.SelectItem(nCurSel < count ? nCurSel : --nCurSel);
  1441. GetDlgItem(IDC_BTN_REMOVE)->SetFocus();
  1442. }
  1443. else
  1444. {
  1445. m_list_Files.SelectItem(nCurSel, FALSE);
  1446. GetDlgItem(IDC_LIST_FILES)->SetFocus();
  1447. }
  1448. MySetControlStates();
  1449. }
  1450. }
  1451. void
  1452. CWebSvcExtAddNewDlg::OnClickListFiles(NMHDR * pNMHDR, LRESULT * pResult)
  1453. {
  1454. MySetControlStates();
  1455. *pResult = 0;
  1456. }
  1457. void
  1458. CWebSvcExtAddNewDlg::OnKeydownListFiles(NMHDR * pNMHDR, LRESULT* pResult)
  1459. {
  1460. LV_KEYDOWN * pLVKeyDow = (LV_KEYDOWN *)pNMHDR;
  1461. MySetControlStates();
  1462. switch (pLVKeyDow->wVKey)
  1463. {
  1464. case VK_INSERT:
  1465. SendMessage(WM_COMMAND, IDC_BTN_ADD);
  1466. break;
  1467. case VK_DELETE:
  1468. SendMessage(WM_COMMAND, IDC_BTN_REMOVE);
  1469. break;
  1470. default:
  1471. // Continue default action
  1472. *pResult = 0;
  1473. break;
  1474. }
  1475. }
  1476. void
  1477. CWebSvcExtAddNewDlg::OnSelChangedListFiles(NMHDR* pNMHDR, LRESULT* pResult)
  1478. {
  1479. MySetControlStates();
  1480. *pResult = 1;
  1481. }
  1482. void
  1483. CWebSvcExtAddNewDlg::FillListBox(CRestrictionEntry * pSelection)
  1484. {
  1485. m_list_Files.SetRedraw(FALSE);
  1486. m_list_Files.DeleteAllItems();
  1487. int cItems = 0;
  1488. POSITION pos;
  1489. CString TheKey;
  1490. CRestrictionEntry * pOneEntry = NULL;
  1491. for(pos = m_MyRestrictionList.GetStartPosition();pos != NULL;)
  1492. {
  1493. m_MyRestrictionList.GetNextAssoc(pos, TheKey, (CRestrictionEntry *&) pOneEntry);
  1494. if (pOneEntry)
  1495. {
  1496. m_list_Files.AddItem(pOneEntry);
  1497. ++cItems;
  1498. }
  1499. }
  1500. m_list_Files.SetRedraw(TRUE);
  1501. if (pSelection)
  1502. {
  1503. LVFINDINFO fi;
  1504. fi.flags = LVFI_PARAM;
  1505. fi.lParam = (LPARAM)pSelection;
  1506. fi.vkDirection = VK_DOWN;
  1507. int i = m_list_Files.FindItem(&fi);
  1508. if (i != -1)
  1509. {
  1510. m_list_Files.SelectItem(i);
  1511. }
  1512. }
  1513. }
  1514. // -----------------------------------------------------------
  1515. CWebSvcExtAddNewForAppDlg::CWebSvcExtAddNewForAppDlg(
  1516. IN BOOL fLocal,
  1517. IN CMetaInterface * pInterface,
  1518. IN CWnd * pParent OPTIONAL
  1519. )
  1520. : CDialog(CWebSvcExtAddNewForAppDlg::IDD, pParent),
  1521. m_fLocal(fLocal)
  1522. {
  1523. //{{AFX_DATA_INIT(CWebSvcExtAddNewForAppDlg)
  1524. m_pMySelectedApplication = NULL;
  1525. m_nComboSelection = -1;
  1526. m_pInterface = pInterface;
  1527. //}}AFX_DATA_INIT
  1528. }
  1529. void
  1530. CWebSvcExtAddNewForAppDlg::DoDataExchange(
  1531. IN CDataExchange * pDX
  1532. )
  1533. {
  1534. CDialog::DoDataExchange(pDX);
  1535. //{{AFX_DATA_MAP(CWebSvcExtAddNewForAppDlg)
  1536. DDX_Control(pDX, IDOK, m_button_Ok);
  1537. DDX_Control(pDX, ID_HELP, m_button_Help);
  1538. DDX_CBIndex(pDX, IDC_COMBO_APPLICATION, m_nComboSelection);
  1539. DDX_Control(pDX, IDC_COMBO_APPLICATION, m_combo_Applications);
  1540. DDX_Control(pDX, IDC_DEPENDENCIES_TXT, m_Dependencies);
  1541. //}}AFX_DATA_MAP
  1542. }
  1543. //
  1544. // Message Map
  1545. //
  1546. BEGIN_MESSAGE_MAP(CWebSvcExtAddNewForAppDlg, CDialog)
  1547. //{{AFX_MSG_MAP(CWebSvcExtAddNewForAppDlg)
  1548. ON_CBN_SELCHANGE(IDC_COMBO_APPLICATION, OnSelchangeComboApplications)
  1549. ON_COMMAND(ID_HELP, OnHelp)
  1550. ON_WM_HELPINFO()
  1551. //}}AFX_MSG_MAP
  1552. END_MESSAGE_MAP()
  1553. //
  1554. // Message Handlers
  1555. //
  1556. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1557. BOOL
  1558. CWebSvcExtAddNewForAppDlg::OnInitDialog()
  1559. {
  1560. CDialog::OnInitDialog();
  1561. m_combo_Applications.SetRedraw(FALSE);
  1562. m_combo_Applications.ResetContent();
  1563. // fetch the list from the
  1564. // metabase and loop thru the list
  1565. CApplicationDependList MyMasterList;
  1566. if (SUCCEEDED(LoadApplicationDependList(m_pInterface,&MyMasterList,TRUE)))
  1567. {
  1568. // loop thru the returned back list
  1569. int TheIndex;
  1570. POSITION pos;
  1571. CString TheKey;
  1572. CApplicationDependEntry * pOneEntry = NULL;
  1573. for(pos = MyMasterList.GetStartPosition();pos != NULL;)
  1574. {
  1575. MyMasterList.GetNextAssoc(pos, TheKey, (CApplicationDependEntry *&) pOneEntry);
  1576. if (pOneEntry)
  1577. {
  1578. TheIndex = m_combo_Applications.AddString(pOneEntry->strApplicationName);
  1579. if (TheIndex != CB_ERR)
  1580. {
  1581. m_combo_Applications.SetItemDataPtr(TheIndex, pOneEntry);
  1582. }
  1583. }
  1584. }
  1585. }
  1586. // Load Mapping for GroupID to friendlyName
  1587. LoadApplicationFriendlyNames(m_pInterface,&m_GroupIDtoGroupFriendList);
  1588. m_combo_Applications.EnableWindow(TRUE);
  1589. m_combo_Applications.SetRedraw(TRUE);
  1590. m_combo_Applications.SetCurSel(m_nComboSelection);
  1591. // Highlight the 1st selection...
  1592. if (-1 == m_nComboSelection)
  1593. {
  1594. m_nComboSelection = m_combo_Applications.GetCount();
  1595. if (m_nComboSelection >= 0)
  1596. {
  1597. m_combo_Applications.SetCurSel(0);
  1598. OnSelchangeComboApplications();
  1599. }
  1600. }
  1601. MySetControlStates();
  1602. return TRUE;
  1603. }
  1604. BOOL
  1605. CWebSvcExtAddNewForAppDlg::OnHelpInfo(HELPINFO * pHelpInfo)
  1606. {
  1607. OnHelp();
  1608. return TRUE;
  1609. }
  1610. void
  1611. CWebSvcExtAddNewForAppDlg::OnHelp()
  1612. {
  1613. WinHelpDebug(0x20000 + CWebSvcExtAddNewForAppDlg::IDD);
  1614. ::WinHelp(m_hWnd, theApp.m_pszHelpFilePath, HELP_CONTEXT, 0x20000 + CWebSvcExtAddNewForAppDlg::IDD);
  1615. }
  1616. void
  1617. CWebSvcExtAddNewForAppDlg::MySetControlStates()
  1618. {
  1619. m_Dependencies.SetReadOnly(TRUE);
  1620. int nSel = m_combo_Applications.GetCurSel();
  1621. if (-1 == nSel)
  1622. {
  1623. m_button_Ok.EnableWindow(FALSE);
  1624. }
  1625. else
  1626. {
  1627. m_button_Ok.EnableWindow(TRUE);
  1628. }
  1629. }
  1630. void
  1631. CWebSvcExtAddNewForAppDlg::OnSelchangeComboApplications()
  1632. {
  1633. int nSel = m_combo_Applications.GetCurSel();
  1634. if (m_nComboSelection == nSel)
  1635. {
  1636. //
  1637. // Selection didn't change
  1638. //
  1639. return;
  1640. }
  1641. m_nComboSelection = nSel;
  1642. int idx = m_combo_Applications.GetCurSel();
  1643. if (idx != -1)
  1644. {
  1645. m_Dependencies.SetWindowText(_T(""));
  1646. CApplicationDependEntry * pOneEntry = NULL;
  1647. CString strOneFriendly;
  1648. CString strOneGroupID;
  1649. CString strAllEntries;
  1650. pOneEntry = (CApplicationDependEntry *) m_combo_Applications.GetItemDataPtr(idx);
  1651. if (pOneEntry)
  1652. {
  1653. // dump out our info.
  1654. POSITION pos = pOneEntry->strlistGroupID.GetHeadPosition();
  1655. while (pos)
  1656. {
  1657. strOneGroupID = pOneEntry->strlistGroupID.GetNext(pos);
  1658. // replace ID with friendly string
  1659. strOneFriendly = _T("");
  1660. // THE KEY IS ALWAYS UPPERASE -- REMEMBER THIS!!!!!!!
  1661. CString strKey;strKey=strOneGroupID;strKey.MakeUpper();
  1662. m_GroupIDtoGroupFriendList.Lookup(strKey,strOneFriendly);
  1663. if (strOneFriendly.IsEmpty())
  1664. {
  1665. strAllEntries = strAllEntries + strOneGroupID;
  1666. }
  1667. else
  1668. {
  1669. strAllEntries = strAllEntries + strOneFriendly;
  1670. }
  1671. strAllEntries = strAllEntries + _T("\r\n");
  1672. }
  1673. }
  1674. m_Dependencies.SetWindowText(strAllEntries);
  1675. }
  1676. MySetControlStates();
  1677. }
  1678. void
  1679. CWebSvcExtAddNewForAppDlg::OnOK()
  1680. {
  1681. if (UpdateData(TRUE))
  1682. {
  1683. int idx = m_combo_Applications.GetCurSel();
  1684. if (idx != -1)
  1685. {
  1686. CApplicationDependEntry * pOneEntry = NULL;
  1687. pOneEntry = (CApplicationDependEntry *) m_combo_Applications.GetItemDataPtr(idx);
  1688. m_pMySelectedApplication = pOneEntry;
  1689. }
  1690. CDialog::OnOK();
  1691. }
  1692. }
  1693. BOOL StartAddNewDialog(CWnd * pParent,CMetaInterface * pInterface,BOOL bIsLocal,CRestrictionUIEntry **pReturnedNewEntry)
  1694. {
  1695. BOOL bRet = FALSE;
  1696. CError err;
  1697. CWebSvcExtAddNewDlg dlg(bIsLocal, pInterface, pParent);
  1698. *pReturnedNewEntry = NULL;
  1699. if (dlg.DoModal() == IDOK)
  1700. {
  1701. BOOL bPleaseUpdateMetabase = FALSE;
  1702. CRestrictionList MasterRestrictionList;
  1703. CString strReturnGroupName = dlg.m_strGroupName;
  1704. BOOL bReturnedAllowStatus = dlg.m_fAllow;
  1705. // get the data from the modal dialog
  1706. // and create a new entry...
  1707. // also, add the entry to the metabase
  1708. // and update the UI
  1709. // Create a new UI entry for the UI
  1710. // if all of this is successfull...
  1711. // update the UI
  1712. CRestrictionUIEntry * pNewUIEntry = new CRestrictionUIEntry;
  1713. if (pNewUIEntry)
  1714. {
  1715. pNewUIEntry->iType = WEBSVCEXT_TYPE_REGULAR;
  1716. // this has to have the EMPTY_GROUPID_KEY part!
  1717. pNewUIEntry->strGroupID = EMPTY_GROUPID_KEY + strReturnGroupName;
  1718. pNewUIEntry->strGroupDescription = strReturnGroupName;
  1719. }
  1720. if (SUCCEEDED(LoadMasterRestrictListWithoutOldEntry(pInterface,&MasterRestrictionList,NULL)))
  1721. {
  1722. // Loop thru the restrictionlist that the had.
  1723. CRestrictionEntry * pOneEntry = NULL;
  1724. CString TheKey;
  1725. POSITION pos;
  1726. for(pos = dlg.m_MyRestrictionList.GetStartPosition();pos != NULL;)
  1727. {
  1728. dlg.m_MyRestrictionList.GetNextAssoc(pos, TheKey, (CRestrictionEntry *&) pOneEntry);
  1729. if (pOneEntry)
  1730. {
  1731. CRestrictionEntry * pNewEntry = CreateRestrictionEntry(
  1732. pOneEntry->strFileName,
  1733. bReturnedAllowStatus ? WEBSVCEXT_STATUS_ALLOWED : WEBSVCEXT_STATUS_PROHIBITED,
  1734. 1,
  1735. // this has to have the EMPTY_GROUPID_KEY part!
  1736. EMPTY_GROUPID_KEY + strReturnGroupName,
  1737. strReturnGroupName,
  1738. WEBSVCEXT_TYPE_REGULAR); // user can only add regular type entries that are deletable.
  1739. if (pNewEntry)
  1740. {
  1741. // Add our new entry to the "master restrictlist"...
  1742. AddRestrictEntryToRestrictList(&MasterRestrictionList,pNewEntry);
  1743. // add it to our new UI entry
  1744. // THE KEY IS ALWAYS UPPERASE -- REMEMBER THIS!!!!!!!
  1745. CString strKey;strKey=pNewEntry->strFileName;strKey.MakeUpper();
  1746. pNewUIEntry->strlstRestrictionEntries.SetAt(strKey,pNewEntry);
  1747. bPleaseUpdateMetabase = TRUE;
  1748. }
  1749. }
  1750. }
  1751. if (bPleaseUpdateMetabase)
  1752. {
  1753. CStringListEx strlstReturned;
  1754. if (SUCCEEDED(PrepRestictionListForWrite(&MasterRestrictionList,&strlstReturned)))
  1755. {
  1756. // Write out the strlstReturned to the metabase.
  1757. if (SUCCEEDED(WriteSettingsRestrictionList(pInterface,&strlstReturned)))
  1758. {
  1759. bRet = TRUE;
  1760. }
  1761. }
  1762. }
  1763. }
  1764. if (pNewUIEntry)
  1765. {
  1766. if (bRet)
  1767. {
  1768. // if we have a new ui entry
  1769. // then pass it back
  1770. *pReturnedNewEntry = pNewUIEntry;
  1771. }
  1772. else
  1773. {
  1774. // clean this entry up
  1775. delete pNewUIEntry;
  1776. pNewUIEntry = NULL;
  1777. }
  1778. }
  1779. }
  1780. return bRet;
  1781. }
  1782. BOOL StartAddNewByAppDialog(CWnd * pParent,CMetaInterface * pInterface,BOOL bIsLocal)
  1783. {
  1784. BOOL bRet = FALSE;
  1785. CRestrictionList MasterRestrictionList;
  1786. CWebSvcExtAddNewForAppDlg dlg(bIsLocal, pInterface, pParent);
  1787. if (dlg.DoModal() != IDOK)
  1788. {
  1789. goto StartAddNewByAppDialog_Exit;
  1790. }
  1791. // Get the selected Application from the list
  1792. // that they selected.
  1793. if (NULL == dlg.m_pMySelectedApplication)
  1794. {
  1795. goto StartAddNewByAppDialog_Exit;
  1796. }
  1797. int iDesiredState = WEBSVCEXT_STATUS_ALLOWED;
  1798. BOOL bPleaseUpdateMetabase = FALSE;
  1799. CApplicationDependEntry * pOneEntry = dlg.m_pMySelectedApplication;
  1800. if (SUCCEEDED(LoadMasterRestrictListWithoutOldEntry(pInterface,&MasterRestrictionList,NULL)))
  1801. {
  1802. POSITION pos1,pos2;
  1803. CString strOneAppName;
  1804. CRestrictionEntry * pOneRestEntry = NULL;
  1805. CString TheKey;
  1806. // Loop thru the list of GROUPID's
  1807. // that they specified that they want to be enabled...
  1808. pos1 = pOneEntry->strlistGroupID.GetHeadPosition();
  1809. while (pos1)
  1810. {
  1811. strOneAppName = pOneEntry->strlistGroupID.GetNext(pos1);
  1812. // we have a GroupID,
  1813. // let's find all the entries with that entry
  1814. // and update them...
  1815. for(pos2 = MasterRestrictionList.GetStartPosition();pos2 != NULL;)
  1816. {
  1817. pOneRestEntry = NULL;
  1818. MasterRestrictionList.GetNextAssoc(pos2, TheKey, (CRestrictionEntry *&) pOneRestEntry);
  1819. if (pOneRestEntry)
  1820. {
  1821. // if the GroupID matches, then update it to desired state
  1822. if (0 == strOneAppName.Compare(pOneRestEntry->strGroupID))
  1823. {
  1824. if (WEBSVCEXT_TYPE_REGULAR == pOneRestEntry->iType)
  1825. {
  1826. if (pOneRestEntry->iStatus != iDesiredState)
  1827. {
  1828. bPleaseUpdateMetabase = TRUE;
  1829. pOneRestEntry->iStatus = iDesiredState;
  1830. }
  1831. }
  1832. }
  1833. }
  1834. }
  1835. }
  1836. //
  1837. // save the metabase info
  1838. //
  1839. if (bPleaseUpdateMetabase)
  1840. {
  1841. CStringListEx strlstReturned;
  1842. if (SUCCEEDED(PrepRestictionListForWrite(&MasterRestrictionList,&strlstReturned)))
  1843. {
  1844. // Write out the strlstReturned to the metabase.
  1845. if (SUCCEEDED(WriteSettingsRestrictionList(pInterface,&strlstReturned)))
  1846. {
  1847. bRet = TRUE;
  1848. }
  1849. }
  1850. }
  1851. //
  1852. // resync the UI with the changes.
  1853. //
  1854. }
  1855. StartAddNewByAppDialog_Exit:
  1856. return bRet;
  1857. }
  1858. CDepedentAppsDlg::CDepedentAppsDlg(
  1859. IN CStringListEx * pstrlstDependApps,
  1860. IN LPCTSTR strExtensionName,
  1861. IN CWnd * pParent OPTIONAL
  1862. )
  1863. : CDialog(CDepedentAppsDlg::IDD, pParent),m_pstrlstDependentAppList(NULL)
  1864. {
  1865. //{{AFX_DATA_INIT(CDepedentAppsDlg)
  1866. m_strExtensionName = strExtensionName;
  1867. //}}AFX_DATA_INIT
  1868. if (pstrlstDependApps){m_pstrlstDependentAppList = pstrlstDependApps;}
  1869. }
  1870. void
  1871. CDepedentAppsDlg::DoDataExchange(
  1872. IN CDataExchange * pDX
  1873. )
  1874. {
  1875. CDialog::DoDataExchange(pDX);
  1876. //{{AFX_DATA_MAP(CDepedentAppsDlg)
  1877. DDX_Control(pDX, ID_HELP, m_button_Help);
  1878. DDX_Control(pDX, IDC_DEPENDENT_APPS_LIST, m_dependent_apps_list);
  1879. //}}AFX_DATA_MAP
  1880. }
  1881. //
  1882. // Message Map
  1883. //
  1884. BEGIN_MESSAGE_MAP(CDepedentAppsDlg, CDialog)
  1885. //{{AFX_MSG_MAP(CDepedentAppsDlg)
  1886. ON_COMMAND(ID_HELP, OnHelp)
  1887. ON_WM_HELPINFO()
  1888. //}}AFX_MSG_MAP
  1889. END_MESSAGE_MAP()
  1890. //
  1891. // Message Handlers
  1892. //
  1893. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1894. BOOL
  1895. CDepedentAppsDlg::OnInitDialog()
  1896. {
  1897. CString strTempString;
  1898. CString strWarn1;
  1899. CString strWarn2;
  1900. CDialog::OnInitDialog();
  1901. strTempString.Empty();
  1902. // Display the stuff that was passed to us...
  1903. if (m_pstrlstDependentAppList)
  1904. {
  1905. m_dependent_apps_list.SetRedraw(FALSE);
  1906. m_dependent_apps_list.ResetContent();
  1907. CString strOneAppNameEntry;
  1908. POSITION pos = m_pstrlstDependentAppList->GetHeadPosition();
  1909. while (pos)
  1910. {
  1911. strOneAppNameEntry = m_pstrlstDependentAppList->GetNext(pos);
  1912. // add it to the new listbox
  1913. m_dependent_apps_list.AddString(strOneAppNameEntry);
  1914. }
  1915. // Set the Backcolor to read only color.
  1916. //m_dependent_apps_list.SetBack
  1917. m_dependent_apps_list.SetRedraw(TRUE);
  1918. }
  1919. // Formulate text for the static labels..
  1920. strTempString.LoadString(IDS_APP_DEPEND_WARN1);
  1921. strWarn1.Format(strTempString,m_strExtensionName);
  1922. GetDlgItem(IDC_EDIT_WARN1)->SetWindowText(strWarn1);
  1923. if (strWarn1.GetLength() > 200)
  1924. {
  1925. ::ShowScrollBar(CONTROL_HWND(IDC_EDIT_WARN1), SB_VERT, TRUE);
  1926. }
  1927. strTempString.LoadString(IDS_APP_DEPEND_WARN2);
  1928. strWarn2.Format(strTempString,m_strExtensionName);
  1929. GetDlgItem(IDC_EDIT_WARN2)->SetWindowText(strWarn2);
  1930. if (strWarn2.GetLength() > 200)
  1931. {
  1932. ::ShowScrollBar(CONTROL_HWND(IDC_EDIT_WARN2), SB_VERT, TRUE);
  1933. }
  1934. CenterWindow();
  1935. MessageBeep(MB_ICONEXCLAMATION);
  1936. // Default to NO
  1937. GetDlgItem(IDCANCEL)->SetFocus();
  1938. return FALSE;
  1939. }
  1940. BOOL
  1941. CDepedentAppsDlg::OnHelpInfo(HELPINFO * pHelpInfo)
  1942. {
  1943. OnHelp();
  1944. return TRUE;
  1945. }
  1946. void
  1947. CDepedentAppsDlg::OnHelp()
  1948. {
  1949. WinHelpDebug(0x20000 + CDepedentAppsDlg::IDD);
  1950. ::WinHelp(m_hWnd, theApp.m_pszHelpFilePath, HELP_CONTEXT, 0x20000 + CDepedentAppsDlg::IDD);
  1951. }
  1952. void
  1953. CDepedentAppsDlg::OnOK()
  1954. {
  1955. if (UpdateData(TRUE))
  1956. {
  1957. CDialog::OnOK();
  1958. }
  1959. }