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.

2283 lines
68 KiB

  1. /*++
  2. Copyright (c) 1994-2000 Microsoft Corporation
  3. Module Name :
  4. websvcext.cpp
  5. Abstract:
  6. IIS RestrictionList
  7. Author:
  8. Aaron Lee (aaronl)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. 03/19/2002 aaronl Initial creation
  13. --*/
  14. #include "stdafx.h"
  15. #include "common.h"
  16. #include "inetprop.h"
  17. #include "InetMgrApp.h"
  18. #include "iisobj.h"
  19. #include "util.h"
  20. #include "shts.h"
  21. #include "websvcext_sheet.h"
  22. #ifdef _DEBUG
  23. #undef THIS_FILE
  24. static char BASED_CODE THIS_FILE[] = __FILE__;
  25. #endif
  26. #define new DEBUG_NEW
  27. extern CInetmgrApp theApp;
  28. extern int g_IISMMCInstanceCount;
  29. #if defined(_DEBUG) || DBG
  30. extern CDebug_IISObject g_Debug_IISObject;
  31. CDebug_RestrictList g_Debug_RestrictList;
  32. #endif
  33. #define HIDD_WEBSVCEXT_PROHIBIT_ALL 0x101
  34. #define HIDD_WEBSVCEXT_UNKNOWN_ISAPI 0x102
  35. #define HIDD_WEBSVCEXT_UNKNOWN_CGI 0x103
  36. #define WEBSVCEXT_RESULTS_COL_WIDTH_0 20 // icon
  37. #define WEBSVCEXT_RESULTS_COL_WIDTH_1 180 // description
  38. #define WEBSVCEXT_RESULTS_COL_WIDTH_2 70 // status
  39. #define BAD_CHARS_FOR_HTML_PANE _T("&")
  40. #define WEBSVCEXT_HELP_PATH _T("::/htm/ca_enabledynamiccontent.htm")
  41. CWebServiceExtensionContainer * g_pCurrentlyDisplayedContainer = NULL;
  42. // ==========================================
  43. CWebServiceExtensionContainer::CWebServiceExtensionContainer(
  44. CIISMachine * pOwner,
  45. CIISService * pService
  46. )
  47. : CIISMBNode(pOwner, SZ_MBN_WEB),
  48. m_pWebService(pService),
  49. m_pResultData(NULL),
  50. m_dwResultDataCachedSignature(0)
  51. {
  52. VERIFY(m_bstrDisplayName.LoadString(IDS_WEBSVCEXT_CONTAINER));
  53. m_strLastResultSelectionID = _T("");
  54. m_iResultPaneCount = 0;
  55. #if defined(_DEBUG) || DBG
  56. g_Debug_RestrictList.Init();
  57. #endif
  58. }
  59. CWebServiceExtensionContainer::~CWebServiceExtensionContainer()
  60. {
  61. m_strLastResultSelectionID = _T("");
  62. m_iResultPaneCount = 0;
  63. // Erase all of the extensions that are under us...
  64. if (!m_WebSvcExtensionList.IsEmpty())
  65. {
  66. CWebServiceExtension * pItem = NULL;
  67. POSITION pos = m_WebSvcExtensionList.GetHeadPosition();
  68. while (pos)
  69. {
  70. pItem = m_WebSvcExtensionList.GetNext(pos);
  71. if (pItem)
  72. {
  73. delete pItem;pItem = NULL;
  74. }
  75. }
  76. m_WebSvcExtensionList.RemoveAll();
  77. }
  78. #if defined(_DEBUG) || DBG
  79. // see if we leaked anything
  80. g_Debug_RestrictList.Dump(TRUE);
  81. #endif
  82. }
  83. HRESULT
  84. CWebServiceExtensionContainer::GetContextHelp(CString& strHtmlPage)
  85. {
  86. strHtmlPage = WEBSVCEXT_HELP_PATH;
  87. return S_OK;
  88. }
  89. /* virtual */
  90. void
  91. CWebServiceExtensionContainer::InitializeChildHeaders(LPHEADERCTRL lpHeader)
  92. {
  93. CWebServiceExtension::InitializeHeaders(lpHeader);
  94. }
  95. /* virtual */
  96. HRESULT CWebServiceExtensionContainer::ForceReportMode(IResultData * pResult) const
  97. {
  98. LONG lViewMode = 0;
  99. if (SUCCEEDED(pResult->GetViewMode(&lViewMode)))
  100. {
  101. if (MMCLV_VIEWSTYLE_REPORT != lViewMode)
  102. {
  103. // whoops, bad mode.
  104. // user can only see icon with no description.
  105. // set it to a better one.
  106. pResult->SetViewMode(MMCLV_VIEWSTYLE_REPORT);
  107. }
  108. }
  109. return S_OK;
  110. }
  111. /* virtual */
  112. HRESULT
  113. CWebServiceExtensionContainer::GetResultViewType(
  114. LPOLESTR * lplpViewType,
  115. long * lpViewOptions
  116. )
  117. {
  118. *lplpViewType = NULL;
  119. *lpViewOptions = MMC_VIEW_OPTIONS_NOLISTVIEWS;
  120. // S_FALSE to use default view type, S_OK indicates the
  121. // view type is returned in *ppViewType
  122. return S_OK;
  123. }
  124. HRESULT
  125. CWebServiceExtensionContainer::SelectResultPaneSelectionID(IResultData * pResultData,CString strSelectionID)
  126. {
  127. HRESULT hr;
  128. CIISObject * pItem = NULL;
  129. CWebServiceExtension * pItemFromMMC = NULL;
  130. if (!pResultData)
  131. {
  132. return E_POINTER;
  133. }
  134. if (strSelectionID.IsEmpty())
  135. {
  136. return S_OK;
  137. }
  138. //
  139. // loop thru all the result items and clean then out.
  140. //
  141. RESULTDATAITEM rdi;
  142. ZeroMemory(&rdi, sizeof(rdi));
  143. rdi.mask = RDI_PARAM | RDI_STATE;
  144. rdi.nIndex = -1; // -1 to start at first item
  145. do
  146. {
  147. rdi.lParam = 0;
  148. hr = pResultData->GetNextItem(&rdi);
  149. if (hr != S_OK){break;}
  150. //
  151. // The cookie is really the IISObject, which is what we stuff
  152. // in the lparam.
  153. //
  154. pItem = (CIISObject *)rdi.lParam;
  155. ASSERT_PTR(pItem);
  156. if (IsEqualGUID(* (GUID *) pItem->GetNodeType(),cWebServiceExtension))
  157. {
  158. pItemFromMMC = (CWebServiceExtension *)rdi.lParam;
  159. // Get the ID
  160. if (pItemFromMMC->QueryContainer() == this)
  161. {
  162. if (0 == strSelectionID.CompareNoCase(pItemFromMMC->m_RestrictionUIEntry.strGroupID))
  163. {
  164. pItemFromMMC->UpdateResultItem(pResultData,TRUE);
  165. }
  166. }
  167. }
  168. } while (SUCCEEDED(hr) && -1 != rdi.nIndex);
  169. return S_OK;
  170. }
  171. HRESULT
  172. CWebServiceExtensionContainer::QueryResultPaneSelectionID(IResultData * pResultData,CString &strLastResultSelectionID)
  173. {
  174. HRESULT hr;
  175. CIISObject * pItem = NULL;
  176. CWebServiceExtension * pItemFromMMC = NULL;
  177. if (!pResultData)
  178. {
  179. return E_POINTER;
  180. }
  181. //
  182. // loop thru all the result items and clean then out.
  183. //
  184. RESULTDATAITEM rdi;
  185. ZeroMemory(&rdi, sizeof(rdi));
  186. rdi.mask = RDI_PARAM | RDI_STATE;
  187. rdi.nIndex = -1; // -1 to start at first item
  188. rdi.nState = LVIS_SELECTED | LVIS_FOCUSED; // only interested in selected items
  189. do
  190. {
  191. rdi.lParam = 0;
  192. hr = pResultData->GetNextItem(&rdi);
  193. if (hr != S_OK){break;}
  194. //
  195. // The cookie is really the IISObject, which is what we stuff
  196. // in the lparam.
  197. //
  198. pItem = (CIISObject *)rdi.lParam;
  199. ASSERT_PTR(pItem);
  200. if (IsEqualGUID(* (GUID *) pItem->GetNodeType(),cWebServiceExtension))
  201. {
  202. pItemFromMMC = (CWebServiceExtension *)rdi.lParam;
  203. // Get the ID
  204. // and return that back.
  205. if (pItemFromMMC->QueryContainer() == this)
  206. {
  207. strLastResultSelectionID = pItemFromMMC->m_RestrictionUIEntry.strGroupID;
  208. }
  209. }
  210. } while (SUCCEEDED(hr) && -1 != rdi.nIndex);
  211. return S_OK;
  212. }
  213. /* virtual */
  214. HRESULT
  215. CWebServiceExtensionContainer::EnumerateResultPane(BOOL fExpand, IHeaderCtrl * lpHeader, IResultData * lpResultData, BOOL fForRefresh)
  216. {
  217. if (lpResultData)
  218. {
  219. m_pResultData = lpResultData;
  220. DWORD * pdwOneDword = (DWORD*) lpResultData;
  221. m_dwResultDataCachedSignature = *pdwOneDword;
  222. }
  223. m_iResultPaneCount = 0;
  224. BOOL bUseCached = FALSE;
  225. CError err = CIISObject::EnumerateResultPane(fExpand, lpHeader, lpResultData, fForRefresh);
  226. if (err.Succeeded())
  227. {
  228. if (m_WebSvcExtensionList.IsEmpty())
  229. {
  230. #if defined(_DEBUG) || DBG
  231. // see if we leaked anything
  232. g_Debug_RestrictList.Dump(TRUE);
  233. #endif
  234. err = EnumerateWebServiceExtensions(&m_WebSvcExtensionList);
  235. }
  236. else
  237. {
  238. bUseCached = TRUE;
  239. }
  240. if (err.Succeeded())
  241. {
  242. if (fExpand)
  243. {
  244. if (bUseCached)
  245. {
  246. TRACEEOL(_T("Read from Cache..."));
  247. }
  248. else
  249. {
  250. TRACEEOL(_T("Read from Metabase (not cache)..."));
  251. }
  252. CWebServiceExtension * pItem = NULL;
  253. POSITION pos = m_WebSvcExtensionList.GetHeadPosition();
  254. int iSelectItem = TRUE;
  255. BOOL bSomethingWasSelected = FALSE;
  256. void ** ppParam = NULL;
  257. while (pos)
  258. {
  259. pItem = m_WebSvcExtensionList.GetNext(pos);
  260. ppParam = (void **) pItem;
  261. if (IsValidAddress( (const void*) *ppParam,sizeof(void*),FALSE))
  262. {
  263. // Select the 1st item in the list...
  264. if (!bSomethingWasSelected)
  265. {
  266. if (!m_strLastResultSelectionID.IsEmpty())
  267. {
  268. if (0 == pItem->m_RestrictionUIEntry.strGroupID.CompareNoCase(m_strLastResultSelectionID))
  269. {
  270. iSelectItem = TRUE;
  271. bSomethingWasSelected = TRUE;
  272. }
  273. }
  274. }
  275. if (bUseCached)
  276. {
  277. // then don't addref, since we already did it once...
  278. err = pItem->AddToResultPaneSorted(lpResultData,iSelectItem,FALSE);
  279. }
  280. else
  281. {
  282. err = pItem->AddToResultPaneSorted(lpResultData,iSelectItem,TRUE);
  283. }
  284. }
  285. m_iResultPaneCount++;
  286. // make sure no other entires are selected.
  287. iSelectItem = FALSE;
  288. }
  289. if (lpResultData)
  290. {
  291. lpResultData->ModifyViewStyle(MMC_SHOWSELALWAYS, (MMC_RESULT_VIEW_STYLE)0);
  292. }
  293. // if we used the stuff from the Cache,
  294. // then reload from metabase. since we'll only have
  295. // really one entry in this list....(Whatever entry that the user had a property page open on)
  296. if (bUseCached)
  297. {
  298. this->RefreshData();
  299. }
  300. g_pCurrentlyDisplayedContainer = this;
  301. }
  302. else
  303. {
  304. // user clicked away from this container node...
  305. // Save whatever the user had selected...
  306. QueryResultPaneSelectionID(lpResultData,m_strLastResultSelectionID);
  307. if (lpResultData)
  308. {
  309. // Clean everything and cache stuff that's not cleaned.
  310. // Cache any entries that were not cleaned.
  311. err = CacheResult(lpResultData);
  312. }
  313. // User is not selected on this one anymore
  314. g_pCurrentlyDisplayedContainer = NULL;
  315. }
  316. }
  317. DisplayError(err);
  318. return err;
  319. }
  320. return err;
  321. }
  322. HRESULT
  323. CWebServiceExtensionContainer::EnumerateWebServiceExtensions(CExtensionList * pList)
  324. {
  325. ASSERT(pList != NULL);
  326. CError err;
  327. err = CheckForMetabaseAccess(METADATA_PERMISSION_READ,this,TRUE,METABASE_PATH_FOR_RESTRICT_LIST);
  328. if (err.Succeeded())
  329. {
  330. CRestrictionUIList MyMetabaseRestrictionUIList;
  331. err = LoadMasterUIWithoutOldEntry(QueryInterface(),&MyMetabaseRestrictionUIList,NULL);
  332. if (err.Succeeded())
  333. {
  334. POSITION pos = NULL;
  335. CString TheKey;
  336. // Loop thru the ui list and display those...
  337. CRestrictionUIEntry * pOneEntry = NULL;
  338. for(pos = MyMetabaseRestrictionUIList.GetStartPosition();pos != NULL;)
  339. {
  340. MyMetabaseRestrictionUIList.GetNextAssoc(pos, TheKey, (CRestrictionUIEntry *&) pOneEntry);
  341. if (pOneEntry)
  342. {
  343. CWebServiceExtension * pItem = NULL;
  344. // creating this CWebServiceExtension makes a copy
  345. // of the data in pOneEntry. so after we're done
  346. // make sure to delete the MyMetabaseRestrictionUIList list
  347. // and all it's objects...
  348. if (NULL == (pItem = new CWebServiceExtension(m_pOwner, pOneEntry, m_pWebService)))
  349. {
  350. err = ERROR_NOT_ENOUGH_MEMORY;
  351. break;
  352. }
  353. pList->AddTail(pItem);
  354. }
  355. }
  356. // delete the list and delete all it's objects too.
  357. CleanRestrictionUIList(&MyMetabaseRestrictionUIList);
  358. }
  359. }
  360. return err;
  361. }
  362. /* virtual */
  363. HRESULT
  364. CWebServiceExtensionContainer::AddMenuItems(
  365. IN LPCONTEXTMENUCALLBACK lpContextMenuCallback,
  366. IN OUT long * pInsertionAllowed,
  367. IN DATA_OBJECT_TYPES type
  368. )
  369. {
  370. ASSERT_READ_PTR(lpContextMenuCallback);
  371. //
  372. // Add base menu items
  373. //
  374. HRESULT hr = CIISObject::AddMenuItems(
  375. lpContextMenuCallback,
  376. pInsertionAllowed,
  377. type
  378. );
  379. if (SUCCEEDED(hr))
  380. {
  381. ASSERT(pInsertionAllowed != NULL);
  382. if (IsAdministrator())
  383. {
  384. if ((*pInsertionAllowed & CCM_INSERTIONALLOWED_NEW) != 0)
  385. {
  386. AddMenuSeparator(lpContextMenuCallback);
  387. AddMenuItemByCommand(lpContextMenuCallback, IDM_WEBEXT_CONTAINER_ADD1);
  388. AddMenuItemByCommand(lpContextMenuCallback, IDM_WEBEXT_CONTAINER_ADD2);
  389. AddMenuSeparator(lpContextMenuCallback);
  390. AddMenuItemByCommand(lpContextMenuCallback, IDM_WEBEXT_CONTAINER_PROHIBIT_ALL);
  391. }
  392. }
  393. }
  394. return hr;
  395. }
  396. /* virtual */
  397. LPOLESTR
  398. CWebServiceExtensionContainer::GetResultPaneColInfo(int nCol)
  399. {
  400. if (nCol == 0)
  401. {
  402. return QueryDisplayName();
  403. }
  404. return OLESTR("");
  405. }
  406. HRESULT
  407. CWebServiceExtensionContainer::Command(
  408. long lCommandID,
  409. CSnapInObjectRootBase * pObj,
  410. DATA_OBJECT_TYPES type
  411. )
  412. {
  413. HRESULT hr = S_OK;
  414. IConsole * pConsole = (IConsole *)GetConsole();
  415. switch (lCommandID)
  416. {
  417. case IDM_WEBEXT_CONTAINER_ADD1:
  418. {
  419. AFX_MANAGE_STATE(::AfxGetStaticModuleState());
  420. CError err = CheckForMetabaseAccess(METADATA_PERMISSION_READ,this,TRUE,METABASE_PATH_FOR_RESTRICT_LIST);
  421. if (err.Succeeded())
  422. {
  423. CRestrictionUIEntry * pNewEntry = NULL;
  424. // ensure the dialog gets themed
  425. CThemeContextActivator activator(theApp.GetFusionInitHandle());
  426. if (TRUE == StartAddNewDialog(GetMainWindow(pConsole),QueryInterface(),IsLocal(),&pNewEntry))
  427. {
  428. // Update the UI
  429. if (pNewEntry)
  430. {
  431. InsertNewExtension(pNewEntry);
  432. // InsertNewExtension will call RefreshData()
  433. // so we don't have to do it out here...
  434. // refresh after insertion...
  435. //if (SUCCEEDED(RefreshData())){RefreshDisplay();}
  436. }
  437. }
  438. }
  439. }
  440. break;
  441. case IDM_WEBEXT_CONTAINER_ADD2:
  442. {
  443. AFX_MANAGE_STATE(::AfxGetStaticModuleState());
  444. CError err = CheckForMetabaseAccess(METADATA_PERMISSION_READ,this,TRUE,METABASE_PATH_FOR_RESTRICT_LIST);
  445. if (err.Succeeded())
  446. {
  447. // ensure the dialog gets themed
  448. CThemeContextActivator activator(theApp.GetFusionInitHandle());
  449. if (TRUE == StartAddNewByAppDialog(GetMainWindow(pConsole),QueryInterface(),IsLocal()))
  450. {
  451. // refresh all of the UI..
  452. if (SUCCEEDED(RefreshData()))
  453. {
  454. RefreshDisplay();
  455. }
  456. }
  457. }
  458. }
  459. break;
  460. case IDM_WEBEXT_CONTAINER_PROHIBIT_ALL:
  461. {
  462. CError err = CheckForMetabaseAccess(METADATA_PERMISSION_READ,this,TRUE,METABASE_PATH_FOR_RESTRICT_LIST);
  463. if (err.Succeeded())
  464. {
  465. CComBSTR strMsg;
  466. strMsg.LoadString(IDS_PROHIBIT_ALL_EXTENSIONS_MSG);
  467. UINT iHelpID = HIDD_WEBSVCEXT_PROHIBIT_ALL;
  468. if (IDYES == DoHelpMessageBox(NULL,strMsg,MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2 | MB_HELP, iHelpID))
  469. {
  470. hr = ChangeStateOfEntry(QueryInterface(),WEBSVCEXT_STATUS_PROHIBITED,NULL);
  471. if (SUCCEEDED(hr) || hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
  472. {
  473. if (SUCCEEDED(hr = RefreshData()))
  474. {
  475. RefreshDisplay();
  476. }
  477. }
  478. }
  479. }
  480. }
  481. break;
  482. //
  483. // Pass on to base class
  484. //
  485. default:
  486. hr = CIISMBNode::Command(lCommandID, pObj, type);
  487. }
  488. return hr;
  489. }
  490. HRESULT
  491. CWebServiceExtensionContainer::CacheResult(IResultData * pResultData)
  492. {
  493. HRESULT hr;
  494. CIISObject * pItem = NULL;
  495. CWebServiceExtension * pItemFromMMC = NULL;
  496. CExtensionList MyDeleteList;
  497. if (!pResultData)
  498. {
  499. return E_POINTER;
  500. }
  501. m_WebSvcExtensionList.RemoveAll();
  502. m_iResultPaneCount=0;
  503. // Loop thru all the result items and add it to our
  504. // List of extensions....
  505. RESULTDATAITEM rdi;
  506. ZeroMemory(&rdi, sizeof(rdi));
  507. rdi.mask = RDI_PARAM | RDI_STATE;
  508. rdi.nIndex = -1; // -1 to start at first item
  509. do
  510. {
  511. rdi.lParam = 0;
  512. hr = pResultData->GetNextItem(&rdi);
  513. if (hr != S_OK){break;}
  514. //
  515. // The cookie is really the IISObject, which is what we stuff
  516. // in the lparam.
  517. //
  518. pItem = (CIISObject *)rdi.lParam;
  519. ASSERT_PTR(pItem);
  520. if (pItem)
  521. {
  522. if (IsEqualGUID(* (GUID *) pItem->GetNodeType(),cWebServiceExtension))
  523. {
  524. pItemFromMMC = (CWebServiceExtension *)rdi.lParam;
  525. // Check if it points to this container!
  526. if (pItemFromMMC->QueryContainer() == this)
  527. {
  528. // add it to our "cache" list if it has a property window open
  529. m_WebSvcExtensionList.AddTail(pItemFromMMC);
  530. m_iResultPaneCount++;
  531. }
  532. }
  533. }
  534. } while (SUCCEEDED(hr) && -1 != rdi.nIndex);
  535. // loop thru the list of objects
  536. // that we need to delete
  537. if (!MyDeleteList.IsEmpty())
  538. {
  539. POSITION pos = MyDeleteList.GetHeadPosition();
  540. while (pos)
  541. {
  542. pItemFromMMC = MyDeleteList.GetNext(pos);
  543. if (pItemFromMMC)
  544. {
  545. // remove it from the UI
  546. if (FAILED(pItemFromMMC->FindMyResultItem(pResultData,TRUE)))
  547. {
  548. pResultData->DeleteItem(pItemFromMMC->QueryResultItem(), 0);
  549. }
  550. // clean data
  551. CleanRestrictionUIEntry(&pItemFromMMC->m_RestrictionUIEntry);
  552. // mark it for deletion.
  553. pItemFromMMC->m_fFlaggedForDeletion = TRUE;
  554. // delete the object
  555. // Don't delete the result item if another window has it open!
  556. // (if there are other console's open
  557. // then they are also displaying these result objects
  558. // don't delete these objects if there are other consoles open...)
  559. if (g_IISMMCInstanceCount <= 1)
  560. {
  561. pItemFromMMC->Release();
  562. }
  563. }
  564. }
  565. }
  566. return S_OK;
  567. }
  568. /*virtual*/
  569. HRESULT
  570. CWebServiceExtensionContainer::CleanResult(IResultData * pResultData)
  571. {
  572. HRESULT hr;
  573. CIISObject * pItem = NULL;
  574. CWebServiceExtension * pItemFromMMC = NULL;
  575. CExtensionList MyDeleteList;
  576. if (!pResultData)
  577. {
  578. return E_POINTER;
  579. }
  580. // only cleanresults if
  581. // there is only 1 instance of the console
  582. //if (g_IISMMCInstanceCount > 1){return S_OK;}
  583. // Clean our Cached list of objects...
  584. m_WebSvcExtensionList.RemoveAll();
  585. m_iResultPaneCount=0;
  586. //
  587. // loop thru all the result items and clean them out.
  588. //
  589. RESULTDATAITEM rdi;
  590. ZeroMemory(&rdi, sizeof(rdi));
  591. rdi.mask = RDI_PARAM | RDI_STATE;
  592. rdi.nIndex = -1; // -1 to start at first item
  593. do
  594. {
  595. rdi.lParam = 0;
  596. hr = pResultData->GetNextItem(&rdi);
  597. if (hr != S_OK){break;}
  598. //
  599. // The cookie is really the IISObject, which is what we stuff
  600. // in the lparam.
  601. //
  602. pItem = (CIISObject *)rdi.lParam;
  603. ASSERT_PTR(pItem);
  604. if (IsEqualGUID(* (GUID *) pItem->GetNodeType(),cWebServiceExtension))
  605. {
  606. pItemFromMMC = (CWebServiceExtension *)rdi.lParam;
  607. // delete the object by adding it to the delete list
  608. // so that we can delete them later
  609. //
  610. // we can't delete items from the result pane while we enum thru the result pane
  611. // things will be messed up in the result pane list....
  612. // and you will end up only deleteing half of what you wanted to delete!
  613. // Only delete an item if there is no property page open on it!
  614. if (pItemFromMMC->QueryContainer() == this)
  615. {
  616. if (pItemFromMMC->IsMyPropertySheetOpen())
  617. {
  618. // add it to our "cache" list if it has a property window open
  619. m_WebSvcExtensionList.AddTail(pItemFromMMC);
  620. m_iResultPaneCount++;
  621. }
  622. else
  623. {
  624. MyDeleteList.AddTail(pItemFromMMC);
  625. }
  626. }
  627. }
  628. } while (SUCCEEDED(hr) && -1 != rdi.nIndex);
  629. // loop thru the list of objects
  630. // that we need to delete
  631. POSITION pos = MyDeleteList.GetHeadPosition();
  632. while (pos)
  633. {
  634. pItemFromMMC = MyDeleteList.GetNext(pos);
  635. if (pItemFromMMC)
  636. {
  637. // remove it from the UI
  638. if (FAILED(pItemFromMMC->FindMyResultItem(pResultData,TRUE)))
  639. {
  640. pResultData->DeleteItem(pItemFromMMC->QueryResultItem(), 0);
  641. }
  642. // clean data
  643. CleanRestrictionUIEntry(&pItemFromMMC->m_RestrictionUIEntry);
  644. // mark it for deletion.
  645. pItemFromMMC->m_fFlaggedForDeletion = TRUE;
  646. // delete the object
  647. // Don't delete the result item if another window has it open!
  648. // (if there are other console's open
  649. // then they are also displaying these result objects
  650. // don't delete these objects if there are other consoles open...)
  651. if (g_IISMMCInstanceCount <= 1)
  652. {
  653. pItemFromMMC->Release();
  654. }
  655. }
  656. }
  657. // don't do this since we could be cleaning out
  658. // other result items which we don't own
  659. //pResultData->DeleteAllRsltItems();
  660. return S_OK;
  661. }
  662. HRESULT
  663. CWebServiceExtensionContainer::InsertNewExtension(CRestrictionUIEntry * pNewEntry)
  664. {
  665. CError err;
  666. IConsole * pConsole = (IConsole *)GetConsole();
  667. CString strNewEntryID;
  668. if (-1 == pNewEntry->strGroupID.Find(EMPTY_GROUPID_KEY))
  669. {
  670. m_strLastResultSelectionID = EMPTY_GROUPID_KEY + pNewEntry->strGroupID;
  671. strNewEntryID = EMPTY_GROUPID_KEY + pNewEntry->strGroupID;
  672. }
  673. else
  674. {
  675. m_strLastResultSelectionID = pNewEntry->strGroupID;
  676. strNewEntryID = pNewEntry->strGroupID;
  677. }
  678. if (!IsExpanded() || NULL == g_pCurrentlyDisplayedContainer)
  679. {
  680. // make sure we are select first.
  681. if (NULL != QueryScopeItem())
  682. {
  683. pConsole->SelectScopeItem(QueryScopeItem());
  684. }
  685. // the above code will read the newly created item from the metabase
  686. // we just need to find it now, and highlight it
  687. SelectResultPaneSelectionID(m_pResultData,strNewEntryID);
  688. if (SUCCEEDED(RefreshData())){RefreshDisplay();}
  689. }
  690. else
  691. {
  692. // insertion code can only be used
  693. // for the currently selected container
  694. // warning: you might be able to add remote computer items
  695. // into the local result view, if you don't check this
  696. if (this == g_pCurrentlyDisplayedContainer)
  697. {
  698. if (SUCCEEDED(RefreshData())){RefreshDisplay();}
  699. // Select the new entry...
  700. SelectResultPaneSelectionID(m_pResultData,strNewEntryID);
  701. // don't do all of this code below...
  702. // since it will add a new entry to the results pane...
  703. // however if we refresh, it could have a possibility to have duplicates...
  704. /*
  705. // Insert and select this new entry
  706. CWebServiceExtension * pItem = new CWebServiceExtension(m_pOwner, this, pNewEntry, m_pWebService);
  707. if (pItem != NULL)
  708. {
  709. // don't call RefreshData, uless you want 2 of these new entries in the list...
  710. //err = pItem->RefreshData();
  711. if (err.Succeeded())
  712. {
  713. // Get the pointer to ResultData from when we did the Enum
  714. err = pItem->AddToResultPaneSorted(m_pResultData,TRUE);
  715. }
  716. }
  717. else
  718. {
  719. err = ERROR_NOT_ENOUGH_MEMORY;
  720. }
  721. */
  722. }
  723. }
  724. return err;
  725. }
  726. /*virtual*/
  727. HRESULT
  728. CWebServiceExtensionContainer::RefreshData()
  729. {
  730. CError err;
  731. IResultData *pResultData = NULL;
  732. pResultData = m_pResultData;
  733. if (!pResultData)
  734. {
  735. return S_OK;
  736. }
  737. // Check validity of the IResultData Pointer!
  738. if (m_dwResultDataCachedSignature)
  739. {
  740. DWORD * pdwOneDword = (DWORD*) pResultData;
  741. if (pdwOneDword)
  742. {
  743. if (m_dwResultDataCachedSignature != *pdwOneDword)
  744. {
  745. TRACEEOLID("Bad Signature:" << m_dwResultDataCachedSignature << " != " << *pdwOneDword);
  746. // This is an invalid signature!
  747. return S_OK;
  748. }
  749. }
  750. }
  751. err = CheckForMetabaseAccess(METADATA_PERMISSION_READ,this,TRUE,METABASE_PATH_FOR_RESTRICT_LIST);
  752. if (err.Succeeded())
  753. {
  754. HRESULT hr = E_FAIL;
  755. POSITION pos = NULL;
  756. CIISObject * pItem = NULL;
  757. CWebServiceExtension * pItemFromMMC = NULL;
  758. CRestrictionUIList MyMetabaseRestrictionUIList;
  759. CRestrictionUIList MyPrunedList;
  760. CExtensionList MyDeleteList;
  761. BOOL bProceed = FALSE;
  762. BOOL bAddToRunningList = FALSE;
  763. // Sync the stuff in our results list
  764. // with the items that are in the metabase
  765. // ----------------------------------------------------------
  766. // 1st pass -- loop thru all the stuff in our list
  767. // and make sure they have all the most
  768. // updated info. removing same entry from metabase list.
  769. // if entry is in UI but not in metabase, then
  770. // remove the metabase entry.
  771. // 2nd pass -- loop thru the left over metabase list entries.
  772. // these are metabase items which are not in the UI.
  773. // ----------------------------------------------------------
  774. // Get the stuff from the metabase
  775. err = LoadMasterUIWithoutOldEntry(QueryInterface(),&MyMetabaseRestrictionUIList,NULL);
  776. if (err.Failed())
  777. {
  778. goto CWebServiceExtensionContainer_RefreshData_Exit;
  779. }
  780. // ==============================
  781. // 1st pass
  782. // Loop through the result list
  783. // ==============================
  784. bProceed = FALSE;
  785. RESULTDATAITEM rdi;
  786. ZeroMemory(&rdi, sizeof(rdi));
  787. rdi.mask = RDI_PARAM | RDI_STATE;
  788. rdi.nIndex = -1; // -1 to start at first item
  789. //rdi.nState = LVIS_SELECTED; // only interested in selected items
  790. do
  791. {
  792. bAddToRunningList = FALSE;
  793. rdi.lParam = 0;
  794. // this could AV right here if pResultData is invalid
  795. hr = pResultData->GetNextItem(&rdi);
  796. if (hr != S_OK)
  797. {
  798. break;
  799. }
  800. //
  801. // The cookie is really the IISObject, which is what we stuff
  802. // in the lparam.
  803. //
  804. pItem = (CIISObject *)rdi.lParam;
  805. ASSERT_PTR(pItem);
  806. if (IsEqualGUID(* (GUID *) pItem->GetNodeType(),cWebServiceExtension))
  807. {
  808. pItemFromMMC = (CWebServiceExtension *)rdi.lParam;
  809. // check if it's for this container!
  810. if (pItemFromMMC->QueryContainer() == this)
  811. {
  812. // check if our item is in the metabase list
  813. // if it is then update it, if not then delete it
  814. int iRet = UpdateItemFromItemInList(&pItemFromMMC->m_RestrictionUIEntry,&MyMetabaseRestrictionUIList);
  815. if (0 == iRet)
  816. {
  817. // no change
  818. bAddToRunningList = TRUE;
  819. }
  820. else if (2 == iRet)
  821. {
  822. // This means that the item was not in the list
  823. // so let's delete it, or mark it for deletion
  824. // seem like we can't delete this item from within this loop
  825. // so let's add it to a list of items to be deleted
  826. MyDeleteList.AddTail(pItemFromMMC);
  827. bAddToRunningList = FALSE;
  828. }
  829. else
  830. {
  831. // the item was updated...
  832. // so let's delete it from the Metabase List
  833. DeleteItemFromList(&pItemFromMMC->m_RestrictionUIEntry,&MyMetabaseRestrictionUIList);
  834. bAddToRunningList = TRUE;
  835. }
  836. bProceed = TRUE;
  837. }
  838. }
  839. if (bAddToRunningList)
  840. {
  841. // add this RestrictionUI item to our running
  842. // list of UI items that are in the UI
  843. AddRestrictUIEntryToRestrictUIList(&MyPrunedList,&pItemFromMMC->m_RestrictionUIEntry);
  844. // update the result panes icon,description,status...
  845. pItemFromMMC->UpdateResultItem(pResultData,FALSE);
  846. }
  847. //
  848. // Advance to next child of same parent
  849. //
  850. } while (SUCCEEDED(hr) && -1 != rdi.nIndex);
  851. // ==============================
  852. // 2nd pass
  853. // Loop through the metabase list
  854. // ==============================
  855. if (bProceed)
  856. {
  857. CRestrictionUIEntry * pOneEntry = NULL;
  858. CString strKey;
  859. CString strKey2;
  860. for(pos = MyMetabaseRestrictionUIList.GetStartPosition();pos != NULL;)
  861. {
  862. MyMetabaseRestrictionUIList.GetNextAssoc(pos, strKey2, (CRestrictionUIEntry *&) pOneEntry);
  863. if (pOneEntry)
  864. {
  865. // see if this entry exists in the UI list
  866. CRestrictionUIEntry * pItemExists = NULL;
  867. // THE KEY IS ALWAYS UPPERASE -- REMEMBER THIS!!!!!!!
  868. strKey=pOneEntry->strGroupID;strKey.MakeUpper();
  869. MyPrunedList.Lookup(strKey,pItemExists);
  870. if (!pItemExists)
  871. {
  872. // we expected that it would not be in the UI list
  873. // so let's create a new entry and add it.
  874. CWebServiceExtension * pNewExtension = NULL;
  875. if (NULL == (pNewExtension = new CWebServiceExtension(m_pOwner, pOneEntry, m_pWebService)))
  876. {
  877. err = ERROR_NOT_ENOUGH_MEMORY;
  878. break;
  879. }
  880. else
  881. {
  882. //add to results pane
  883. err = pNewExtension->AddToResultPaneSorted(pResultData,TRUE);
  884. }
  885. }
  886. }
  887. }
  888. // this one just points to entries that are still existing
  889. // so just erase this list
  890. MyPrunedList.RemoveAll();
  891. }
  892. // this one needs to be erased -- the list and all of it's data items...
  893. CleanRestrictionUIList(&MyMetabaseRestrictionUIList);
  894. // Loop thru the saved list of mmc entries
  895. // we are supposed to delete, and remove them
  896. pItemFromMMC = NULL;
  897. pos = MyDeleteList.GetHeadPosition();
  898. BOOL bDeletedSomethingThatWasSelected = FALSE;
  899. while (pos)
  900. {
  901. pItemFromMMC = MyDeleteList.GetNext(pos);
  902. if (pItemFromMMC)
  903. {
  904. // check if this item is currently selected!
  905. ZeroMemory(&rdi, sizeof(rdi));
  906. rdi.mask = RDI_STATE;
  907. rdi.itemID = pItemFromMMC->QueryResultItem();
  908. if (SUCCEEDED(pResultData->GetItem(&rdi)))
  909. {
  910. if (rdi.nState & LVIS_SELECTED)
  911. {
  912. bDeletedSomethingThatWasSelected = TRUE;
  913. }
  914. }
  915. // mark it as going to be deleted
  916. pItemFromMMC->m_fFlaggedForDeletion = TRUE;
  917. // remove from results pane!
  918. if (FAILED(pItemFromMMC->FindMyResultItem(pResultData,TRUE)))
  919. {
  920. pResultData->DeleteItem(pItemFromMMC->QueryResultItem(), 0);
  921. }
  922. }
  923. }
  924. if (bDeletedSomethingThatWasSelected)
  925. {
  926. // select something else (i guess we'll select the 1st item)
  927. pResultData->ModifyItemState(0,0,LVIS_SELECTED | LVIS_FOCUSED,0);
  928. }
  929. }
  930. CWebServiceExtensionContainer_RefreshData_Exit:
  931. return err;
  932. }
  933. ////////////////////////////////////////////////////////////////////////////////
  934. // CWebServiceExtension implementation
  935. //
  936. // Result View definition
  937. //
  938. /* static */
  939. int
  940. CWebServiceExtension::_rgnLabels[COL_TOTAL] =
  941. {
  942. IDS_RESULT_SERVICE_ICON,
  943. IDS_RESULT_SERVICE_WEBSVCEXT,
  944. IDS_RESULT_STATUS
  945. };
  946. /* static */
  947. int
  948. CWebServiceExtension::_rgnWidths[COL_TOTAL] =
  949. {
  950. WEBSVCEXT_RESULTS_COL_WIDTH_0,
  951. WEBSVCEXT_RESULTS_COL_WIDTH_1,
  952. WEBSVCEXT_RESULTS_COL_WIDTH_2
  953. };
  954. /* static */ CComBSTR CWebServiceExtension::_bstrStatusAllowed;
  955. /* static */ CComBSTR CWebServiceExtension::_bstrStatusProhibited;
  956. /* static */ CComBSTR CWebServiceExtension::_bstrStatusCustom;
  957. /* static */ CComBSTR CWebServiceExtension::_bstrStatusInUse;
  958. /* static */ CComBSTR CWebServiceExtension::_bstrStatusNotInUse;
  959. /* static */ CString CWebServiceExtension::_bstrMenuAllowOn;
  960. /* static */ CString CWebServiceExtension::_bstrMenuAllowOff;
  961. /* static */ CString CWebServiceExtension::_bstrMenuProhibitOn;
  962. /* static */ CString CWebServiceExtension::_bstrMenuProhibitOff;
  963. /* static */ CString CWebServiceExtension::_bstrMenuPropertiesOn;
  964. /* static */ CString CWebServiceExtension::_bstrMenuPropertiesOff;
  965. /* static */ CString CWebServiceExtension::_bstrMenuTasks;
  966. /* static */ CString CWebServiceExtension::_bstrMenuTask1;
  967. /* static */ CString CWebServiceExtension::_bstrMenuTask2;
  968. /* static */ CString CWebServiceExtension::_bstrMenuTask3;
  969. /* static */ CString CWebServiceExtension::_bstrMenuTask4;
  970. /* static */ CString CWebServiceExtension::_bstrMenuIconBullet;
  971. /* static */ CString CWebServiceExtension::_bstrMenuIconHelp;
  972. /* static */ BOOL CWebServiceExtension::_fStaticsLoaded = FALSE;
  973. /* static */ BOOL CWebServiceExtension::_fStaticsLoaded2 = FALSE;
  974. CWebServiceExtension::CWebServiceExtension(
  975. CIISMachine * pOwner,
  976. CRestrictionUIEntry * pRestrictionUIEntry,
  977. CIISService * pService
  978. )
  979. : CIISMBNode(pOwner, SZ_MBN_WEB),
  980. m_pWebService(pService)
  981. {
  982. m_hwnd = 0;
  983. m_fFlaggedForDeletion = FALSE;
  984. RestrictionUIEntryCopy(&m_RestrictionUIEntry,pRestrictionUIEntry);
  985. }
  986. CWebServiceExtension::~CWebServiceExtension()
  987. {
  988. // Delete all objects associated with this object..
  989. CleanRestrictionUIEntry(&m_RestrictionUIEntry);
  990. }
  991. HRESULT
  992. CWebServiceExtension::GetContextHelp(CString& strHtmlPage)
  993. {
  994. strHtmlPage = WEBSVCEXT_HELP_PATH;
  995. return S_OK;
  996. }
  997. /* static */
  998. void
  999. CWebServiceExtension::InitializeHeaders(LPHEADERCTRL lpHeader)
  1000. {
  1001. CIISObject::BuildResultView(lpHeader, COL_TOTAL, _rgnLabels, _rgnWidths);
  1002. if (!_fStaticsLoaded)
  1003. {
  1004. _fStaticsLoaded =
  1005. _bstrStatusAllowed.LoadString(IDS_ALLOWED) &&
  1006. _bstrStatusProhibited.LoadString(IDS_PROHIBITED) &&
  1007. _bstrStatusCustom.LoadString(IDS_CUSTOM) &&
  1008. _bstrStatusInUse.LoadString(IDS_INUSE) &&
  1009. _bstrStatusNotInUse.LoadString(IDS_NOTINUSE);
  1010. }
  1011. }
  1012. /* virtual */
  1013. void
  1014. CWebServiceExtension::InitializeChildHeaders(LPHEADERCTRL lpHeader)
  1015. {
  1016. CIISObject::BuildResultView(lpHeader, COL_TOTAL, _rgnLabels, _rgnWidths);
  1017. }
  1018. /* virtual */
  1019. HRESULT
  1020. CWebServiceExtension::GetResultViewType(
  1021. LPOLESTR * lplpViewType,
  1022. long * lpViewOptions
  1023. )
  1024. {
  1025. *lplpViewType = NULL;
  1026. *lpViewOptions = MMC_VIEW_OPTIONS_NOLISTVIEWS;
  1027. // S_FALSE to use default view type, S_OK indicates the
  1028. // view type is returned in *ppViewType
  1029. return S_OK;
  1030. }
  1031. /* virtual */
  1032. HRESULT
  1033. CWebServiceExtension::BuildMetaPath(CComBSTR & bstrPath) const
  1034. {
  1035. HRESULT hr = S_OK;
  1036. ASSERT(m_pWebService != NULL);
  1037. hr = m_pWebService->BuildMetaPath(bstrPath);
  1038. return hr;
  1039. }
  1040. /*virtual*/
  1041. BOOL CWebServiceExtension::IsConfigurable() const
  1042. {
  1043. // is not configurable if it's one of the "special ones...
  1044. if (WEBSVCEXT_TYPE_ALL_UNKNOWN_ISAPI == m_RestrictionUIEntry.iType || WEBSVCEXT_TYPE_ALL_UNKNOWN_CGI == m_RestrictionUIEntry.iType)
  1045. {
  1046. return FALSE;
  1047. }
  1048. else
  1049. {
  1050. // WEBSVCEXT_TYPE_REGULAR
  1051. // WEBSVCEXT_TYPE_FILENAME_EXTENSIONS_FILTER
  1052. return TRUE;
  1053. }
  1054. }
  1055. /*virtual*/
  1056. BOOL
  1057. CWebServiceExtension::IsDeletable() const
  1058. {
  1059. BOOL bRet = FALSE;
  1060. // if there is a property dialog
  1061. // open on this item, then don't let them
  1062. // delete the item.
  1063. // Don't hide the option to delete
  1064. // this confuses users and
  1065. // also it won't always be hidden.
  1066. // kind of wacky, so just show it always
  1067. // and pop an error if they try to delete it.
  1068. //if (IsMyPropertySheetOpen()){return FALSE;}
  1069. // loop thru the list to see if anyone of the entries
  1070. // is not deleteable -- if it's not deletable...
  1071. // then the whole thing is not deletable
  1072. CString TheKey;
  1073. POSITION pos = NULL;
  1074. CRestrictionEntry * pOneEntry = NULL;
  1075. for(pos = m_RestrictionUIEntry.strlstRestrictionEntries.GetStartPosition();pos != NULL;)
  1076. {
  1077. m_RestrictionUIEntry.strlstRestrictionEntries.GetNextAssoc(pos, TheKey, (CRestrictionEntry *&) pOneEntry);
  1078. if (pOneEntry)
  1079. {
  1080. if (WEBSVCEXT_TYPE_REGULAR == pOneEntry->iType)
  1081. {
  1082. if (0 != pOneEntry->iDeletable)
  1083. {
  1084. bRet = TRUE;
  1085. goto CWebServiceExtension_IsDeletable_Exit;
  1086. }
  1087. }
  1088. }
  1089. }
  1090. CWebServiceExtension_IsDeletable_Exit:
  1091. return bRet;
  1092. }
  1093. /* virtual */
  1094. LPOLESTR
  1095. CWebServiceExtension::GetResultPaneColInfo(
  1096. IN int nCol
  1097. )
  1098. {
  1099. switch(nCol)
  1100. {
  1101. case COL_ICON:
  1102. return _T("");
  1103. case COL_WEBSVCEXT:
  1104. return QueryDisplayName();
  1105. case COL_STATUS:
  1106. {
  1107. switch(GetState())
  1108. {
  1109. case WEBSVCEXT_STATUS_ALLOWED:
  1110. return _bstrStatusAllowed;
  1111. case WEBSVCEXT_STATUS_PROHIBITED:
  1112. return _bstrStatusProhibited;
  1113. case WEBSVCEXT_STATUS_CUSTOM:
  1114. return _bstrStatusCustom;
  1115. case WEBSVCEXT_STATUS_INUSE:
  1116. return _bstrStatusInUse;
  1117. case WEBSVCEXT_STATUS_NOTINUSE:
  1118. return _bstrStatusNotInUse;
  1119. default:
  1120. return OLESTR("");
  1121. }
  1122. }
  1123. }
  1124. ASSERT_MSG("Bad column number");
  1125. return OLESTR("");
  1126. }
  1127. /* virtual */
  1128. LPOLESTR
  1129. CWebServiceExtension::QueryDisplayName()
  1130. {
  1131. if (m_RestrictionUIEntry.strGroupDescription.IsEmpty())
  1132. {
  1133. // no need to call refresh for this.
  1134. //RefreshData();
  1135. m_RestrictionUIEntry.strGroupDescription = QueryNodeName();
  1136. }
  1137. return (LPTSTR)(LPCTSTR)m_RestrictionUIEntry.strGroupDescription;
  1138. }
  1139. /* virtual */
  1140. int
  1141. CWebServiceExtension::QueryImage() const
  1142. {
  1143. // Check if it's one of our "special ones"
  1144. switch(GetState())
  1145. {
  1146. case WEBSVCEXT_STATUS_ALLOWED:
  1147. if (WEBSVCEXT_TYPE_REGULAR != m_RestrictionUIEntry.iType)
  1148. {
  1149. // should be an icon that is emphasized for
  1150. // the "allowed" mode -- since that is dangerous
  1151. return iWebSvcFilterPlus;
  1152. }
  1153. else
  1154. {
  1155. return iWebSvcGearPlus;
  1156. }
  1157. case WEBSVCEXT_STATUS_PROHIBITED:
  1158. if (WEBSVCEXT_TYPE_REGULAR != m_RestrictionUIEntry.iType)
  1159. {
  1160. return iWebSvcFilter;
  1161. }
  1162. else
  1163. {
  1164. return iWebSvcGear;
  1165. }
  1166. case WEBSVCEXT_STATUS_CUSTOM:
  1167. if (WEBSVCEXT_TYPE_REGULAR != m_RestrictionUIEntry.iType)
  1168. {
  1169. return iWebSvcFilterPlus;
  1170. }
  1171. else
  1172. {
  1173. return iWebSvcGearPlus;
  1174. }
  1175. case WEBSVCEXT_STATUS_INUSE:
  1176. return iWebSvcGear;
  1177. case WEBSVCEXT_STATUS_NOTINUSE:
  1178. return iWebSvcGear;
  1179. default:
  1180. return iWebSvcGear;
  1181. }
  1182. return iWebSvcGear;
  1183. }
  1184. int
  1185. CWebServiceExtension::QueryImageForPropertyPage() const
  1186. {
  1187. switch(GetState())
  1188. {
  1189. case WEBSVCEXT_STATUS_ALLOWED:
  1190. case WEBSVCEXT_STATUS_PROHIBITED:
  1191. case WEBSVCEXT_STATUS_CUSTOM:
  1192. if (WEBSVCEXT_TYPE_REGULAR != m_RestrictionUIEntry.iType)
  1193. {
  1194. return iWebSvcFilter;
  1195. }
  1196. else
  1197. {
  1198. return iWebSvcGear;
  1199. }
  1200. case WEBSVCEXT_STATUS_INUSE:
  1201. case WEBSVCEXT_STATUS_NOTINUSE:
  1202. return iWebSvcGear;
  1203. default:
  1204. return iWebSvcGear;
  1205. }
  1206. return iApplication;
  1207. }
  1208. /* virtual */
  1209. HRESULT
  1210. CWebServiceExtension::RefreshData()
  1211. {
  1212. // the user clicked on the refresh menu bar or something
  1213. // so let's make sure the item gets reselected
  1214. return RefreshData(TRUE);
  1215. }
  1216. HRESULT
  1217. CWebServiceExtension::RefreshData(BOOL bReselect)
  1218. {
  1219. // since refreshing just one of these items
  1220. // means that we must read the metabase value
  1221. // which contains all of the items, we might as
  1222. // well update them all.
  1223. //
  1224. // just call the RefreshData for our container...
  1225. IConsole * pConsole = (IConsole *)GetConsole();
  1226. CWebServiceExtensionContainer * pContainer = m_pOwner->QueryWebSvcExtContainer();
  1227. if (pContainer)
  1228. {
  1229. if (bReselect)
  1230. {
  1231. if (SUCCEEDED(CheckForMetabaseAccess(METADATA_PERMISSION_READ,this,TRUE,METABASE_PATH_FOR_RESTRICT_LIST)))
  1232. {
  1233. // If we are selected, then
  1234. // make sure we are select first.
  1235. // this so that we get the StandardVerbs!
  1236. if (pContainer == g_pCurrentlyDisplayedContainer)
  1237. {
  1238. if (NULL != QueryScopeItem())
  1239. {
  1240. pConsole->SelectScopeItem(QueryScopeItem());
  1241. }
  1242. }
  1243. }
  1244. }
  1245. return pContainer->RefreshData();
  1246. }
  1247. else
  1248. {
  1249. return S_OK;
  1250. }
  1251. }
  1252. /* virtual */
  1253. int
  1254. CWebServiceExtension::CompareResultPaneItem(
  1255. CIISObject * pObject,
  1256. int nCol
  1257. )
  1258. /*++
  1259. Routine Description:
  1260. Compare two CIISObjects on sort item criteria
  1261. Arguments:
  1262. CIISObject * pObject : Object to compare against
  1263. int nCol : Column number to sort on
  1264. Return Value:
  1265. 0 if the two objects are identical
  1266. <0 if this object is less than pObject
  1267. >0 if this object is greater than pObject
  1268. --*/
  1269. {
  1270. ASSERT_READ_PTR(pObject);
  1271. //
  1272. // First criteria is object type
  1273. //
  1274. int n1 = QuerySortWeight();
  1275. int n2 = pObject->QuerySortWeight();
  1276. if (n1 != n2)
  1277. {
  1278. return n1 - n2;
  1279. }
  1280. //
  1281. // Both are CWebServiceExtension objects
  1282. //
  1283. CWebServiceExtension * pMyObject = (CWebServiceExtension *)pObject;
  1284. int MyType = 0;
  1285. int YourType = 0;
  1286. switch(nCol)
  1287. {
  1288. case COL_ICON:
  1289. // Sort on the type of icon.
  1290. MyType = m_RestrictionUIEntry.iType;;
  1291. YourType = pMyObject->m_RestrictionUIEntry.iType;
  1292. // 1st sort criteria -- type
  1293. if (MyType == YourType)
  1294. {
  1295. // secondary sort criteria -- name
  1296. //return ::lstrcmpi(GetResultPaneColInfo(COL_WEBSVCEXT), pObject->GetResultPaneColInfo(COL_WEBSVCEXT));
  1297. // this should be faster, GetResultPaneColInfo just calls this anyways.
  1298. return ::lstrcmpi(QueryDisplayName(), pObject->QueryDisplayName());
  1299. }
  1300. // 1st sort criteria -- type
  1301. if (MyType == WEBSVCEXT_TYPE_ALL_UNKNOWN_ISAPI || MyType == WEBSVCEXT_TYPE_ALL_UNKNOWN_CGI)
  1302. {
  1303. return -1;
  1304. }
  1305. else
  1306. {
  1307. // WEBSVCEXT_TYPE_FILENAME_EXTENSIONS_FILTER
  1308. // WEBSVCEXT_TYPE_REGULAR
  1309. return 1;
  1310. }
  1311. break;
  1312. case COL_WEBSVCEXT:
  1313. case COL_STATUS:
  1314. default:
  1315. //
  1316. // Lexical sort
  1317. //
  1318. return ::lstrcmpi(
  1319. GetResultPaneColInfo(nCol),
  1320. pObject->GetResultPaneColInfo(nCol)
  1321. );
  1322. }
  1323. }
  1324. /* virtual */
  1325. HRESULT
  1326. CWebServiceExtension::CreatePropertyPages(
  1327. LPPROPERTYSHEETCALLBACK lpProvider,
  1328. LONG_PTR handle,
  1329. IUnknown * pUnk,
  1330. DATA_OBJECT_TYPES type
  1331. )
  1332. {
  1333. AFX_MANAGE_STATE(::AfxGetStaticModuleState());
  1334. CError err;
  1335. IConsole * pConsole = (IConsole *)GetConsole();
  1336. if (S_FALSE == (HRESULT)(err = CIISMBNode::CreatePropertyPages(lpProvider, handle, pUnk, type)))
  1337. {
  1338. return S_OK;
  1339. }
  1340. if (ERROR_ALREADY_EXISTS == err.Win32Error())
  1341. {
  1342. return S_FALSE;
  1343. }
  1344. err = CheckForMetabaseAccess(METADATA_PERMISSION_READ,this,TRUE,METABASE_PATH_FOR_RESTRICT_LIST);
  1345. if (err.Succeeded())
  1346. {
  1347. //
  1348. // If there's already a property sheet open on this item
  1349. // then make it the foreground window and bail.
  1350. HWND MyPropWindow = IsMyPropertySheetOpen();
  1351. if (MyPropWindow && (MyPropWindow != (HWND) 1))
  1352. {
  1353. if (SetForegroundWindow(MyPropWindow))
  1354. {
  1355. if (handle)
  1356. {
  1357. MMCFreeNotifyHandle(handle);
  1358. handle = 0;
  1359. }
  1360. return S_FALSE;
  1361. }
  1362. else
  1363. {
  1364. // wasn't able to bring this property sheet to
  1365. // the foreground, the propertysheet must not
  1366. // exist anymore. let's just clean the hwnd
  1367. // so that the user will be able to open propertysheet
  1368. SetMyPropertySheetOpen(0);
  1369. }
  1370. }
  1371. // if the entry doesn't have any files
  1372. // then don't let them open it.
  1373. if (!m_RestrictionUIEntry.strlstRestrictionEntries.IsEmpty())
  1374. {
  1375. // we need to refresh ourself from the metabase
  1376. // before grabbing this data.
  1377. // need to get the most up to date info...
  1378. RefreshData(FALSE);
  1379. if (TRUE == m_fFlaggedForDeletion)
  1380. {
  1381. // this item was marked for deletion during the RefreshData
  1382. // so don't display it's property page.
  1383. // instead popup an error.
  1384. err = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
  1385. }
  1386. else
  1387. {
  1388. // Create a copy of the particular entry we want to modify....
  1389. CRestrictionUIEntry * pCopyOfRestrictionUIEntry = RestrictionUIEntryMakeCopy(&m_RestrictionUIEntry);
  1390. if (pCopyOfRestrictionUIEntry)
  1391. {
  1392. CWebServiceExtensionSheet * pSheet = new CWebServiceExtensionSheet(
  1393. QueryAuthInfo(),
  1394. METABASE_PATH_FOR_RESTRICT_LIST,
  1395. GetMainWindow(pConsole),
  1396. (LPARAM) this,
  1397. (LPARAM) GetParentNode(),
  1398. (LPARAM) pCopyOfRestrictionUIEntry
  1399. );
  1400. if (pSheet != NULL)
  1401. {
  1402. // cache handle for user in MMCPropertyChangeNotify
  1403. m_ppHandle = handle;
  1404. pSheet->SetModeless();
  1405. err = AddMMCPage(lpProvider, new CWebServiceExtensionGeneral(pSheet,QueryImageForPropertyPage(),pCopyOfRestrictionUIEntry));
  1406. err = AddMMCPage(lpProvider, new CWebServiceExtensionRequiredFiles(pSheet,QueryAuthInfo(),pCopyOfRestrictionUIEntry));
  1407. // send a notify to MMC to
  1408. // let it refresh the HTML GetProperty buttons
  1409. // don't do this, since it will send the property page to the background!
  1410. //MMCPropertyChangeNotify(handle, (LPARAM) this);
  1411. }
  1412. }
  1413. }
  1414. }
  1415. err.MessageBoxOnFailure();
  1416. }
  1417. else
  1418. {
  1419. return S_FALSE;
  1420. }
  1421. return err;
  1422. }
  1423. /* virtual */
  1424. HRESULT
  1425. CWebServiceExtension::AddMenuItems(
  1426. IN LPCONTEXTMENUCALLBACK lpContextMenuCallback,
  1427. IN OUT long * pInsertionAllowed,
  1428. IN DATA_OBJECT_TYPES type
  1429. )
  1430. {
  1431. ASSERT_READ_PTR(lpContextMenuCallback);
  1432. //
  1433. // Add base menu items
  1434. //
  1435. HRESULT hr = CIISObject::AddMenuItems(
  1436. lpContextMenuCallback,
  1437. pInsertionAllowed,
  1438. type
  1439. );
  1440. ASSERT(pInsertionAllowed != NULL);
  1441. if ((*pInsertionAllowed & CCM_INSERTIONALLOWED_TOP) != 0)
  1442. {
  1443. AddMenuSeparator(lpContextMenuCallback);
  1444. /*
  1445. // if there is a property dialog
  1446. // open on this item, then don't let them
  1447. // Do stuff with it.
  1448. if (IsMyPropertySheetOpen())
  1449. {
  1450. AddMenuItemByCommand(lpContextMenuCallback, IDM_WEBEXT_ALLOW, MF_GRAYED);
  1451. AddMenuItemByCommand(lpContextMenuCallback, IDM_WEBEXT_PROHIBIT, MF_GRAYED);
  1452. }
  1453. else
  1454. */
  1455. {
  1456. INT iState = GetState();
  1457. if (WEBSVCEXT_STATUS_ALLOWED == iState || WEBSVCEXT_STATUS_PROHIBITED == iState || WEBSVCEXT_STATUS_CUSTOM == iState)
  1458. {
  1459. AddMenuItemByCommand(lpContextMenuCallback, IDM_WEBEXT_ALLOW, iState != WEBSVCEXT_STATUS_ALLOWED ? 0 : MF_GRAYED);
  1460. AddMenuItemByCommand(lpContextMenuCallback, IDM_WEBEXT_PROHIBIT, iState != WEBSVCEXT_STATUS_PROHIBITED ? 0 : MF_GRAYED);
  1461. }
  1462. }
  1463. }
  1464. return hr;
  1465. }
  1466. /* virtual */
  1467. HRESULT
  1468. CWebServiceExtension::Command(
  1469. IN long lCommandID,
  1470. IN CSnapInObjectRootBase * pObj,
  1471. IN DATA_OBJECT_TYPES type
  1472. )
  1473. {
  1474. HRESULT hr = S_OK;
  1475. CString name;
  1476. INT iCommand = 9999;
  1477. switch (lCommandID)
  1478. {
  1479. case IDM_WEBEXT_ALLOW:
  1480. iCommand = WEBSVCEXT_STATUS_ALLOWED;
  1481. break;
  1482. case IDM_WEBEXT_PROHIBIT:
  1483. iCommand = WEBSVCEXT_STATUS_PROHIBITED;
  1484. break;
  1485. //
  1486. // Pass on to base class
  1487. //
  1488. default:
  1489. hr = CIISMBNode::Command(lCommandID, pObj, type);
  1490. }
  1491. if (iCommand != 9999)
  1492. {
  1493. hr = ChangeState(iCommand);
  1494. }
  1495. return hr;
  1496. }
  1497. /*virtual*/
  1498. HRESULT
  1499. CWebServiceExtension::DeleteNode(IResultData * pResult)
  1500. {
  1501. CError err;
  1502. // check if they have the property sheet open on it.
  1503. if (IsMyPropertySheetOpen())
  1504. {
  1505. ::AfxMessageBox(IDS_CLOSE_PROPERTY_SHEET_WEBSVCEXT);
  1506. return S_OK;
  1507. }
  1508. // Check if it's even deletable...
  1509. if (!IsDeletable())
  1510. {
  1511. ::AfxMessageBox(IDS_ITEM_NOT_REMOVABLE);
  1512. }
  1513. else
  1514. {
  1515. if (!NoYesMessageBox(IDS_CONFIRM_DELETE))
  1516. {
  1517. return err;
  1518. }
  1519. err == RemoveRestrictionUIEntry(QueryInterface(),&m_RestrictionUIEntry);
  1520. if (err.Succeeded())
  1521. {
  1522. // remove result item
  1523. if (FAILED(err = FindMyResultItem(pResult,TRUE)))
  1524. {
  1525. err = pResult->DeleteItem(m_hResultItem, 0);
  1526. }
  1527. if (err.Succeeded())
  1528. {
  1529. RefreshData(FALSE);
  1530. }
  1531. }
  1532. err.MessageBoxOnFailure();
  1533. }
  1534. return err;
  1535. }
  1536. /* virtual */
  1537. HRESULT
  1538. CWebServiceExtension::OnDblClick(IComponentData * pcd, IComponent * pc)
  1539. {
  1540. CComQIPtr<IPropertySheetProvider, &IID_IPropertySheetProvider> spProvider(GetConsole());
  1541. IDataObject * pdo = NULL;
  1542. GetDataObject(&pdo, CCT_RESULT);
  1543. CError err = spProvider->FindPropertySheet(reinterpret_cast<MMC_COOKIE>(this), 0, pdo);
  1544. if (err != S_OK)
  1545. {
  1546. err = spProvider->CreatePropertySheet(_T(""), TRUE, (MMC_COOKIE)this, pdo, MMC_PSO_HASHELP);
  1547. if (err.Succeeded())
  1548. {
  1549. err = spProvider->AddPrimaryPages(
  1550. pc,
  1551. TRUE, // we may want to get property change notifications
  1552. NULL, // according to docs
  1553. FALSE // for result item only
  1554. );
  1555. if (err.Succeeded())
  1556. {
  1557. err = spProvider->AddExtensionPages();
  1558. }
  1559. }
  1560. if (err.Succeeded())
  1561. {
  1562. HWND hWnd = NULL;
  1563. VERIFY(SUCCEEDED(GetConsole()->GetMainWindow(&hWnd)));
  1564. VERIFY(SUCCEEDED(spProvider->Show((LONG_PTR)hWnd, 0)));
  1565. }
  1566. else
  1567. {
  1568. spProvider->Show(-1, 0);
  1569. }
  1570. }
  1571. return err;
  1572. }
  1573. //
  1574. // Procedure removes all characters in the second string from the first one.
  1575. //
  1576. INT RemoveChars(LPTSTR pszStr,LPTSTR pszRemoved)
  1577. {
  1578. BOOL bRemovedSomething = FALSE;
  1579. INT iCharsRemovedCount = 0;
  1580. INT iOrgStringLength = _tcslen(pszStr);
  1581. INT cbRemoved = _tcslen(pszRemoved);
  1582. INT iSrc, iDest;
  1583. for (iSrc = iDest = 0; pszStr[iSrc]; iSrc++, iDest++)
  1584. {
  1585. // Check if this char is the in the list of stuf
  1586. // we are supposed to remove.
  1587. // if it is then just set iSrc to iSrc +1
  1588. #ifdef UNICODE
  1589. while (wmemchr(pszRemoved, pszStr[iSrc], cbRemoved))
  1590. #else
  1591. while (memchr(pszRemoved, pszStr[iSrc], cbRemoved))
  1592. #endif
  1593. {
  1594. iCharsRemovedCount++;
  1595. iSrc++;
  1596. }
  1597. // copy the character to itself
  1598. pszStr[iDest] = pszStr[iSrc];
  1599. }
  1600. // Cut off the left over strings
  1601. // which we didn't erase. but need to.
  1602. if (iCharsRemovedCount >= 0){pszStr[iOrgStringLength - iCharsRemovedCount]= '\0';}
  1603. return iDest - 1;
  1604. }
  1605. /* virtual */
  1606. HRESULT
  1607. CWebServiceExtension::GetProperty(
  1608. LPDATAOBJECT pDataObject,
  1609. BSTR szPropertyName,
  1610. BSTR* pbstrProperty)
  1611. {
  1612. CString strProperty;
  1613. if (!_wcsicmp(L"CCF_HTML_DETAILS",szPropertyName))
  1614. {
  1615. if (!_fStaticsLoaded2)
  1616. {
  1617. CComBSTR strTempFormat;
  1618. CComBSTR strTempString1,strTempString2,strTempString3;
  1619. CString csTempPath1;
  1620. CString csTempPath2;
  1621. // point this to a hard coded file, if the file exists...
  1622. if (_MAX_PATH >= GetSystemDirectory(csTempPath1.GetBuffer(_MAX_PATH), _MAX_PATH))
  1623. {
  1624. csTempPath1.ReleaseBuffer( );
  1625. csTempPath2 = csTempPath1;
  1626. csTempPath1 += _T("\\oobe\\images\\btn2.gif");
  1627. csTempPath2 += _T("\\oobe\\images\\qmark.gif");
  1628. strTempFormat.LoadString(IDS_MENU_WEBEXT_ICON_FORMAT);
  1629. DWORD dwAttr = GetFileAttributes(csTempPath1);
  1630. _bstrMenuIconBullet = _T("<BR>");
  1631. if (!(dwAttr == 0xffffffff || (dwAttr & FILE_ATTRIBUTE_DIRECTORY)))
  1632. {
  1633. // point to the hard coded file
  1634. _bstrMenuIconBullet.Format(strTempFormat,csTempPath1);
  1635. }
  1636. dwAttr = GetFileAttributes(csTempPath2);
  1637. _bstrMenuIconHelp = _T("<BR>");
  1638. if (!(dwAttr == 0xffffffff || (dwAttr & FILE_ATTRIBUTE_DIRECTORY)))
  1639. {
  1640. // point to the hard coded file
  1641. _bstrMenuIconHelp.Format(strTempFormat,csTempPath2);
  1642. }
  1643. }
  1644. //
  1645. // NOTE ON RemoveChars()
  1646. // This was used to erase the & from a string like "&Allow"
  1647. // Because Javascript can't handle that, so it had to be stripped.
  1648. // this worked for english type languages but broke for languages
  1649. // like Japanese because in order to show a hotkey they would
  1650. // use "SomeHiraganaCharacters (&A)". and the "(" isn't able
  1651. // to be handled by Javascript either, so it broke.
  1652. // instead of just fixing RemoveChars() to remove ( and ) as well
  1653. // we just created new strings, that way localizers don't get confused
  1654. // when the string the created shows up in the UI as
  1655. // "SomeHiraganaCharacters" rather than "SomeHiraganaCharacters (A)"
  1656. //
  1657. strTempString1.LoadString(IDS_MENU_WEBEXT_ALLOW_JAVA_SAFE);
  1658. //RemoveChars(strTempString1, BAD_CHARS_FOR_HTML_PANE);
  1659. strTempString2.LoadString(IDS_MENU_WEBEXT_ALLOW_FORMAT);
  1660. _bstrMenuAllowOn.Format(strTempString2,strTempString1,_T("IDS_MENU_WEBEXT_ALLOW"));
  1661. strTempString2.LoadString(IDS_MENU_WEBEXT_ALLOW_DISABLED_FORMAT);
  1662. _bstrMenuAllowOff.Format(strTempString2,strTempString1);
  1663. strTempString1.LoadString(IDS_MENU_WEBEXT_PROHIBIT_JAVA_SAFE);
  1664. //RemoveChars(strTempString1, BAD_CHARS_FOR_HTML_PANE);
  1665. strTempString2.LoadString(IDS_MENU_WEBEXT_PROHIBIT_FORMAT);
  1666. _bstrMenuProhibitOn.Format(strTempString2,strTempString1,_T("IDS_MENU_WEBEXT_PROHIBIT"));
  1667. strTempString2.LoadString(IDS_MENU_WEBEXT_PROHIBIT_DISABLED_FORMAT);
  1668. _bstrMenuProhibitOff.Format(strTempString2,strTempString1);
  1669. strTempString1.LoadString(IDS_MENU_PROPERTIES_JAVA_SAFE);
  1670. //RemoveChars(strTempString1, BAD_CHARS_FOR_HTML_PANE);
  1671. strTempString2.LoadString(IDS_MENU_WEBEXT_PROPERTIES_FORMAT);
  1672. _bstrMenuPropertiesOn.Format(strTempString2,strTempString1,strTempString1);
  1673. strTempString2.LoadString(IDS_MENU_WEBEXT_PROPERTIES_DISABLED_FORMAT);
  1674. _bstrMenuPropertiesOff.Format(strTempString2,strTempString1,strTempString1);
  1675. strTempString1.LoadString(IDS_MENU_WEBEXT_CONTAINER_ADD1_JAVA_SAFE);
  1676. //RemoveChars(strTempString1, BAD_CHARS_FOR_HTML_PANE);
  1677. strTempString2.LoadString(IDS_MENU_WEBEXT_ADD1_FORMAT);
  1678. _bstrMenuTask1.Format(strTempString2,_T("IDS_MENU_WEBEXT_CONTAINER_ADD1"),strTempString1);
  1679. strTempString1.LoadString(IDS_MENU_WEBEXT_CONTAINER_ADD2_JAVA_SAFE);
  1680. //RemoveChars(strTempString1, BAD_CHARS_FOR_HTML_PANE);
  1681. strTempString2.LoadString(IDS_MENU_WEBEXT_ADD2_FORMAT);
  1682. _bstrMenuTask2.Format(strTempString2,_T("IDS_MENU_WEBEXT_CONTAINER_ADD2"),strTempString1);
  1683. strTempString1.LoadString(IDS_MENU_WEBEXT_CONTAINER_PROHIBIT_ALL_JAVA_SAFE);
  1684. //RemoveChars(strTempString1, BAD_CHARS_FOR_HTML_PANE);
  1685. strTempString2.LoadString(IDS_MENU_WEBEXT_PROHIBIT_ALL_FORMAT);
  1686. _bstrMenuTask3.Format(strTempString2,_T("IDS_MENU_WEBEXT_CONTAINER_PROHIBIT_ALL"),strTempString1);
  1687. strTempString1.LoadString(IDS_MENU_WEBEXT_CONTAINER_HELP);
  1688. strTempString3.LoadString(IDS_MENU_WEBEXT_CONTAINER_HELP_JAVA_SAFE);
  1689. //RemoveChars(strTempString1, BAD_CHARS_FOR_HTML_PANE);
  1690. strTempString2.LoadString(IDS_MENU_WEBEXT_HELP_FORMAT);
  1691. _bstrMenuTask4.Format(strTempString2,strTempString3,strTempString1);
  1692. strTempString2.LoadString(IDS_MENU_WEBEXT_TASKS);
  1693. //RemoveChars(strTempString2, BAD_CHARS_FOR_HTML_PANE);
  1694. _bstrMenuTasks = strTempString2;
  1695. _fStaticsLoaded2 = TRUE;
  1696. }
  1697. /*
  1698. // commented out: if we disable this, then there is no notification to
  1699. // re-enable it if the user hit cancel, thus the buttons will stay "grayed"...
  1700. // if there is a property dialog
  1701. // open on this item, then don't
  1702. // let them access these buttons...
  1703. if (IsMyPropertySheetOpen())
  1704. {
  1705. strProperty += _bstrMenuAllowOff;
  1706. strProperty += _bstrMenuProhibitOff;
  1707. }
  1708. else
  1709. */
  1710. {
  1711. // [Allowed] Button
  1712. // [Prohibited] Button
  1713. switch(GetState())
  1714. {
  1715. case WEBSVCEXT_STATUS_ALLOWED:
  1716. strProperty += _bstrMenuAllowOff;
  1717. strProperty += _bstrMenuProhibitOn;
  1718. break;
  1719. case WEBSVCEXT_STATUS_PROHIBITED:
  1720. strProperty += _bstrMenuAllowOn;
  1721. strProperty += _bstrMenuProhibitOff;
  1722. break;
  1723. case WEBSVCEXT_STATUS_CUSTOM:
  1724. strProperty += _bstrMenuAllowOn;
  1725. strProperty += _bstrMenuProhibitOn;
  1726. break;
  1727. default:
  1728. break;
  1729. }
  1730. }
  1731. // [Properties] Button
  1732. if (IsConfigurable())
  1733. {
  1734. strProperty += _bstrMenuPropertiesOn;
  1735. }
  1736. else
  1737. {
  1738. strProperty += _bstrMenuPropertiesOff;
  1739. }
  1740. // Tasks
  1741. // -------------------------
  1742. strProperty += _bstrMenuTasks;
  1743. // Task 1
  1744. strProperty += _bstrMenuIconBullet;
  1745. strProperty += _bstrMenuTask1;
  1746. // Task 2
  1747. strProperty += _bstrMenuIconBullet;
  1748. strProperty += _bstrMenuTask2;
  1749. // Task 3
  1750. strProperty += _bstrMenuIconBullet;
  1751. strProperty += _bstrMenuTask3;
  1752. // Help
  1753. strProperty += _bstrMenuIconHelp;
  1754. strProperty += _bstrMenuTask4;
  1755. }
  1756. else if (!_wcsicmp(L"CCF_DESCRIPTION",szPropertyName))
  1757. {
  1758. // Display data in Description field...
  1759. }
  1760. else
  1761. {
  1762. return S_FALSE; // unknown strPropertyName
  1763. }
  1764. *pbstrProperty = ::SysAllocString(strProperty);
  1765. return S_OK;
  1766. }
  1767. HRESULT
  1768. CWebServiceExtension::UpdateResultItem(IResultData *pResultData,BOOL bSelect)
  1769. {
  1770. HRESULT hr = S_OK;
  1771. if (!pResultData)
  1772. {
  1773. return E_POINTER;
  1774. }
  1775. RESULTDATAITEM ri;
  1776. ::ZeroMemory(&ri, sizeof(ri));
  1777. ri.itemID = this->QueryResultItem();
  1778. ri.mask = RDI_STR | RDI_IMAGE;
  1779. if (bSelect)
  1780. {
  1781. ri.mask = ri.mask | RDI_STATE;
  1782. ri.nState = LVIS_SELECTED | LVIS_FOCUSED;
  1783. }
  1784. ri.str = MMC_CALLBACK;
  1785. ri.nImage = this->QueryImage();
  1786. hr = pResultData->SetItem(&ri);
  1787. pResultData->UpdateItem(ri.itemID);
  1788. return hr;
  1789. }
  1790. HRESULT
  1791. CWebServiceExtension::FindMyResultItem(IResultData *pResultData,BOOL bDeleteIfFound)
  1792. {
  1793. HRESULT hr,hr0 = S_FALSE;
  1794. LPARAM lParam = (LPARAM) this;
  1795. HRESULTITEM hresultItem = NULL;
  1796. int i = 0;
  1797. hr0 = hr = pResultData->FindItemByLParam(lParam,&hresultItem);
  1798. while (S_OK == hr)
  1799. {
  1800. if (i++ >= 10)
  1801. {
  1802. break;
  1803. }
  1804. if (bDeleteIfFound)
  1805. {
  1806. hr = pResultData->DeleteItem(hresultItem,0);
  1807. }
  1808. hr = pResultData->FindItemByLParam(lParam,&hresultItem);
  1809. }
  1810. return hr0;
  1811. }
  1812. HRESULT
  1813. CWebServiceExtension::AddToResultPane(IResultData *pResultData, BOOL bSelect,BOOL bPleaseAddRef)
  1814. {
  1815. HRESULT hr = S_OK;
  1816. HRESULTITEM hresultItem = NULL;
  1817. if (!pResultData)
  1818. {
  1819. return E_POINTER;
  1820. }
  1821. RESULTDATAITEM ri;
  1822. ::ZeroMemory(&ri, sizeof(ri));
  1823. ri.mask = RDI_STR | RDI_IMAGE | RDI_PARAM;
  1824. if (bSelect)
  1825. {
  1826. ri.mask = ri.mask | RDI_STATE;
  1827. ri.nState = LVIS_SELECTED | LVIS_FOCUSED;
  1828. }
  1829. ri.str = MMC_CALLBACK;
  1830. ri.nImage = this->QueryImage();
  1831. ri.lParam = (LPARAM) this;
  1832. // check if we're already in the list
  1833. if (S_OK == pResultData->FindItemByLParam((LPARAM) this,&hresultItem))
  1834. {
  1835. // this needs to be set before calling UpdateResultItem...
  1836. ri.itemID = hresultItem;
  1837. this->SetResultItem(ri.itemID);
  1838. this->SetScopeItem(this->QueryContainer()->QueryScopeItem());
  1839. hr = pResultData->SetItem(&ri);
  1840. if (bSelect)
  1841. {
  1842. //pResultData->UpdateItem(ri.itemID);
  1843. }
  1844. return S_OK;
  1845. }
  1846. //if (this->QueryContainer()->IsExpanded())
  1847. {
  1848. // a very important step here.
  1849. // if we don't have this AddRef, we will Access violate..
  1850. if (bPleaseAddRef)
  1851. {
  1852. this->AddRef();
  1853. }
  1854. hr = pResultData->InsertItem(&ri);
  1855. if (SUCCEEDED(hr))
  1856. {
  1857. this->SetScopeItem(this->QueryContainer()->QueryScopeItem());
  1858. this->SetResultItem(ri.itemID);
  1859. }
  1860. else
  1861. {
  1862. if (bPleaseAddRef)
  1863. {
  1864. this->Release();
  1865. }
  1866. }
  1867. }
  1868. return hr;
  1869. }
  1870. HRESULT
  1871. CWebServiceExtension::AddToResultPaneSorted(IResultData *pResultData,BOOL bSelect,BOOL bPleaseAddRef)
  1872. {
  1873. HRESULT hr = S_OK;
  1874. if (!pResultData)
  1875. {
  1876. return E_POINTER;
  1877. }
  1878. hr = AddToResultPane(pResultData,bSelect,bPleaseAddRef);
  1879. // sort on Column0,Ascending,nodata
  1880. pResultData->Sort(0,0,0);
  1881. return hr;
  1882. }
  1883. INT
  1884. CWebServiceExtension::GetState() const
  1885. {
  1886. INT iDisplayedState = GetRestrictUIState((CRestrictionUIEntry *) &m_RestrictionUIEntry);
  1887. return iDisplayedState;
  1888. }
  1889. HRESULT
  1890. CWebServiceExtension::ChangeState(INT iDesiredState)
  1891. {
  1892. AFX_MANAGE_STATE(::AfxGetStaticModuleState());
  1893. CError err;
  1894. CWaitCursor wait;
  1895. BOOL bProceed = TRUE;
  1896. BOOL bShowedPopup = FALSE;
  1897. IConsole * pConsole = (IConsole *)GetConsole();
  1898. // don't allow them to change the state if
  1899. // it's property sheet is already open...
  1900. // check if they have the property sheet open on it.
  1901. if (IsMyPropertySheetOpen())
  1902. {
  1903. ::AfxMessageBox(IDS_CLOSE_PROPERTY_SHEET_WEBSVCEXT2);
  1904. return S_OK;
  1905. }
  1906. err = CheckForMetabaseAccess(METADATA_PERMISSION_READ,this,TRUE,METABASE_PATH_FOR_RESTRICT_LIST);
  1907. if (err.Succeeded())
  1908. {
  1909. // if it's the special entries
  1910. // check if they are sure if they want to do this...
  1911. if (WEBSVCEXT_TYPE_ALL_UNKNOWN_ISAPI == m_RestrictionUIEntry.iType || WEBSVCEXT_TYPE_ALL_UNKNOWN_CGI == m_RestrictionUIEntry.iType)
  1912. {
  1913. // check if they're tryinging to allow it.
  1914. if (WEBSVCEXT_STATUS_ALLOWED == iDesiredState)
  1915. {
  1916. CString strMsg;
  1917. CString strMsgFormat;
  1918. bProceed = FALSE;
  1919. UINT iHelpID = 0;
  1920. if (WEBSVCEXT_TYPE_ALL_UNKNOWN_ISAPI == m_RestrictionUIEntry.iType)
  1921. {
  1922. iHelpID = HIDD_WEBSVCEXT_UNKNOWN_ISAPI;
  1923. strMsgFormat.LoadString(IDS_ALLOW_UNSAFE_ISAPI_MSG);
  1924. }
  1925. else
  1926. {
  1927. iHelpID = HIDD_WEBSVCEXT_UNKNOWN_CGI;
  1928. strMsgFormat.LoadString(IDS_ALLOW_UNSAFE_CGI_MSG);
  1929. }
  1930. strMsg.Format(strMsgFormat,m_RestrictionUIEntry.strGroupDescription,m_RestrictionUIEntry.strGroupDescription);
  1931. // ensure the dialog gets themed
  1932. CThemeContextActivator activator(theApp.GetFusionInitHandle());
  1933. if (IDYES == DoHelpMessageBox(NULL,strMsg,MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2 | MB_HELP, iHelpID))
  1934. {
  1935. bProceed = TRUE;
  1936. bShowedPopup = TRUE;
  1937. }
  1938. }
  1939. }
  1940. else
  1941. {
  1942. // check if it's a normal entry
  1943. // and if other applications have dependencies upon it
  1944. // if there are dependencies, then ask if they're sure
  1945. // they want to disable it?
  1946. if (WEBSVCEXT_TYPE_REGULAR == m_RestrictionUIEntry.iType)
  1947. {
  1948. // Check if they want to disable it
  1949. if (WEBSVCEXT_STATUS_PROHIBITED == iDesiredState)
  1950. {
  1951. // Check if this item has apps that
  1952. // are dependent upon it.
  1953. CStringListEx strlstDependApps;
  1954. if (TRUE == ReturnDependentAppsList(QueryInterface(),m_RestrictionUIEntry.strGroupID,&strlstDependApps,FALSE))
  1955. {
  1956. bProceed = FALSE;
  1957. // ensure the dialog gets themed
  1958. CThemeContextActivator activator(theApp.GetFusionInitHandle());
  1959. // check if they really want to do this.
  1960. CDepedentAppsDlg dlg(&strlstDependApps,m_RestrictionUIEntry.strGroupDescription,GetMainWindow(pConsole));
  1961. if (dlg.DoModal() == IDOK)
  1962. {
  1963. bProceed = TRUE;
  1964. bShowedPopup = TRUE;
  1965. }
  1966. }
  1967. }
  1968. }
  1969. }
  1970. if (bProceed)
  1971. {
  1972. if (&m_RestrictionUIEntry)
  1973. {
  1974. err = ChangeStateOfEntry(QueryInterface(),iDesiredState,&m_RestrictionUIEntry);
  1975. if (err.Succeeded() || err.Win32Error() == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
  1976. {
  1977. // just in case they are trying to set the allow/prohibit
  1978. // for an item which has already been removed from the metabase
  1979. if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == err.Win32Error())
  1980. {
  1981. err.MessageBoxOnFailure();
  1982. }
  1983. err = RefreshData(FALSE);
  1984. if (err.Succeeded())
  1985. {
  1986. RefreshDisplay();
  1987. if (bShowedPopup)
  1988. {
  1989. // if we wanted to make the container node
  1990. // redisplay everything... we would uncomment this line.
  1991. // seems like we have to do this after displaying confirmation msg.
  1992. // dunno why.
  1993. CWebServiceExtensionContainer * pContainer = m_pOwner->QueryWebSvcExtContainer();
  1994. if (pContainer)
  1995. {
  1996. err = pContainer->RefreshDisplay(FALSE);
  1997. }
  1998. }
  1999. }
  2000. }
  2001. err.MessageBoxOnFailure();
  2002. }
  2003. }
  2004. }
  2005. else
  2006. {
  2007. return S_FALSE;
  2008. }
  2009. return err;
  2010. }