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.

1704 lines
44 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: cldhndlr.cxx
  7. //
  8. // Contents: Performs download of class object and its handler concurrently
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 06-27-97 EricV (Eric VandenBerg) Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include <eapp.h>
  18. PerfDbgTag(tagClassInstallFilter, "Urlmon", "Log ClassInstallFilter", DEB_TRANS)
  19. DbgTag(tagClassInstallFilterErr, "Urlmon", "Log ClassInstallFilter Errors", DEB_TRANS|DEB_ERROR)
  20. //+---------------------------------------------------------------------------
  21. //
  22. // Method: CClassInstallFilterSink::CClassInstallFilterSink
  23. //
  24. // Synopsis:
  25. //
  26. // Arguments: [CClassInstallFilter] --
  27. //
  28. // Returns:
  29. //
  30. // History: 06-27-97 EricV (Eric VandenBerg) Created
  31. //
  32. // Notes:
  33. //
  34. //----------------------------------------------------------------------------
  35. CClassInstallFilterSink::CClassInstallFilterSink(CClassInstallFilter *pInstallFilter)
  36. {
  37. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilterSink::CClassInstallFilterSink\n");
  38. TransAssert(pInstallFilter);
  39. _pInstallFilter = pInstallFilter;
  40. _dwRef = 1;
  41. _bDone = FALSE;
  42. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilterSink::CClassInstallFilterSink (end)\n");
  43. }
  44. //+---------------------------------------------------------------------------
  45. //
  46. // Method: CClassInstallFilterSink::~CClassInstallFilterSink
  47. //
  48. // Synopsis:
  49. //
  50. // Arguments:
  51. //
  52. // Returns:
  53. //
  54. // History: 06-27-97 EricV (Eric VandenBerg) Created
  55. //
  56. // Notes:
  57. //
  58. //----------------------------------------------------------------------------
  59. CClassInstallFilterSink::~CClassInstallFilterSink()
  60. {
  61. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilterSink::~CClassInstallFilterSink\n");
  62. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilterSink::~CClassInstallFilterSink (end)\n");
  63. }
  64. //+---------------------------------------------------------------------------
  65. //
  66. // Method: CClassInstallFilterSink::QueryInterface
  67. //
  68. // Synopsis:
  69. //
  70. // Arguments: [riid] --
  71. // [ppvObj] --
  72. //
  73. // Returns:
  74. //
  75. // History: 06-27-97 EricV (Eric VandenBerg) Created
  76. //
  77. // Notes:
  78. //
  79. //----------------------------------------------------------------------------
  80. HRESULT CClassInstallFilterSink::QueryInterface(REFIID iid, void **ppvObj)
  81. {
  82. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilterSink::QueryInterface\n");
  83. HRESULT hr = E_FAIL;
  84. if (!ppvObj)
  85. {
  86. hr = E_INVALIDARG;
  87. }
  88. else
  89. {
  90. *ppvObj = NULL;
  91. if ((iid == IID_IOInetProtocolSink)
  92. || (iid == IID_IUnknown))
  93. {
  94. *ppvObj = (IOInetProtocolSink *) this;
  95. AddRef();
  96. hr = S_OK;
  97. }
  98. else if (iid == IID_IServiceProvider)
  99. {
  100. *ppvObj = (IServiceProvider *) this;
  101. AddRef();
  102. hr = S_OK;
  103. }
  104. else
  105. {
  106. hr = E_NOINTERFACE;
  107. }
  108. }
  109. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilterSink::QueryInterface (hr:%lx)\n", hr);
  110. return hr;
  111. }
  112. //+---------------------------------------------------------------------------
  113. //
  114. // Method: CClassInstallFilterSink::AddRef
  115. //
  116. // Synopsis:
  117. //
  118. // Arguments: [riid] --
  119. // [ppvObj] --
  120. //
  121. // Returns:
  122. //
  123. // History: 06-27-97 EricV (Eric VandenBerg) Created
  124. //
  125. // Notes:
  126. //
  127. //----------------------------------------------------------------------------
  128. ULONG CClassInstallFilterSink::AddRef(void)
  129. {
  130. PerfDbgLog(tagClassInstallFilter, this, "-CClassInstallFilterSink::AddRef\n");
  131. {
  132. _dwRef++;
  133. }
  134. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilterSink::AddRef (_dwRef=%ld)\n", _dwRef);
  135. return _dwRef;
  136. }
  137. //+---------------------------------------------------------------------------
  138. //
  139. // Method: CClassInstallFilterSink::Release
  140. //
  141. // Synopsis:
  142. //
  143. // Arguments: [riid] --
  144. // [ppvObj] --
  145. //
  146. // Returns:
  147. //
  148. // History: 06-27-97 EricV (Eric VandenBerg) Created
  149. //
  150. // Notes:
  151. //
  152. //----------------------------------------------------------------------------
  153. ULONG CClassInstallFilterSink::Release(void)
  154. {
  155. PerfDbgLog(tagClassInstallFilter, this, "-CClassInstallFilterSink::Release\n");
  156. {
  157. _dwRef--;
  158. if (!_dwRef)
  159. {
  160. delete this;
  161. return 0;
  162. }
  163. }
  164. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilterSink::Release (_dwRef:%ld)\n", _dwRef);
  165. return _dwRef;
  166. }
  167. //+---------------------------------------------------------------------------
  168. //
  169. // Method: CClassInstallFilterSink::Switch
  170. //
  171. // Synopsis:
  172. //
  173. // Arguments: [riid] --
  174. // [ppvObj] --
  175. //
  176. // Returns:
  177. //
  178. // History: 06-27-97 EricV (Eric VandenBerg) Created
  179. //
  180. // Notes:
  181. //
  182. //----------------------------------------------------------------------------
  183. HRESULT CClassInstallFilterSink::Switch(PROTOCOLDATA *pStateInfo)
  184. {
  185. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilterSink::Switch\n");
  186. HRESULT hr = NOERROR;
  187. TransAssert(pStateInfo);
  188. if (_bDone)
  189. {
  190. hr = E_FAIL;
  191. }
  192. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::Switch (hr:%lx)\n", hr);
  193. return hr;
  194. }
  195. //+---------------------------------------------------------------------------
  196. //
  197. // Method: CClassInstallFilterSink::ReportProgress
  198. //
  199. // Synopsis:
  200. //
  201. // Arguments:
  202. //
  203. // Returns:
  204. //
  205. // History: 06-27-97 EricV (Eric VandenBerg) Created
  206. //
  207. // Notes:
  208. //
  209. //----------------------------------------------------------------------------
  210. HRESULT CClassInstallFilterSink::ReportProgress(ULONG ulStatusCode, LPCWSTR szStatusText)
  211. {
  212. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilterSink::ReportProgress\n");
  213. HRESULT hr = NOERROR;
  214. ULONG ulNewStatus = 0;
  215. if (ulStatusCode == BINDSTATUS_BEGINDOWNLOADDATA)
  216. {
  217. ulNewStatus = BINDSTATUS_BEGINDOWNLOADCOMPONENTS;
  218. }
  219. else if (ulStatusCode == BINDSTATUS_DOWNLOADINGDATA)
  220. {
  221. ulNewStatus = BINDSTATUS_INSTALLINGCOMPONENTS;
  222. }
  223. else if (ulStatusCode == BINDSTATUS_ENDDOWNLOADCOMPONENTS)
  224. {
  225. ulNewStatus = BINDSTATUS_ENDDOWNLOADCOMPONENTS;
  226. }
  227. // report progress on this
  228. if (ulNewStatus && _pInstallFilter)
  229. {
  230. _pInstallFilter->ReportProgress(ulNewStatus, szStatusText);
  231. }
  232. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::ReportProgress (hr:%lx)\n", hr);
  233. return hr;
  234. }
  235. //+---------------------------------------------------------------------------
  236. //
  237. // Method: CClassInstallFilterSink::ReportData
  238. //
  239. // Synopsis:
  240. //
  241. // Arguments:
  242. //
  243. // Returns:
  244. //
  245. // History: 06-27-97 EricV (Eric VandenBerg) Created
  246. //
  247. // Notes:
  248. //
  249. //----------------------------------------------------------------------------
  250. HRESULT CClassInstallFilterSink::ReportData(DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax)
  251. {
  252. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilterSink::ReportData\n");
  253. HRESULT hr = NOERROR;
  254. if (_bDone)
  255. {
  256. hr = E_FAIL;
  257. }
  258. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::ReportData (hr:%lx)\n", hr);
  259. return hr;
  260. }
  261. //+---------------------------------------------------------------------------
  262. //
  263. // Method: CClassInstallFilterSink::ReportResult
  264. //
  265. // Synopsis:
  266. //
  267. // Arguments:
  268. //
  269. // Returns:
  270. //
  271. // History: 06-27-97 EricV (Eric VandenBerg) Created
  272. //
  273. // Notes:
  274. //
  275. //----------------------------------------------------------------------------
  276. HRESULT CClassInstallFilterSink::ReportResult(HRESULT hrResult, DWORD dwError, LPCWSTR wzResult)
  277. {
  278. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilterSink::ReportResult\n");
  279. HRESULT hr = NOERROR;
  280. if (_bDone)
  281. {
  282. hr = E_FAIL;
  283. }
  284. else
  285. {
  286. _bDone = TRUE;
  287. hr = _pInstallFilter->InstallerReportResult(hrResult, dwError, wzResult);
  288. }
  289. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::ReportResult (hr:%lx)\n", hr);
  290. return hr;
  291. }
  292. //+---------------------------------------------------------------------------
  293. //
  294. // Method: CClassInstallFilterSink::QueryService
  295. //
  296. // Synopsis:
  297. //
  298. // Arguments: [rsid] --
  299. // [riid] --
  300. // [ppvObj] --
  301. //
  302. // Returns:
  303. //
  304. // History: 06-27-97 EricV (Eric VandenBerg) Created
  305. //
  306. // Notes:
  307. //
  308. //----------------------------------------------------------------------------
  309. STDMETHODIMP CClassInstallFilterSink::QueryService(REFGUID rsid, REFIID riid, void ** ppvObj)
  310. {
  311. PerfDbgLog(tagClassInstallFilter, this, "-CClassInstallFilterSink::QueryService\n");
  312. HRESULT hr = NOERROR;
  313. if (!_pInstallFilter)
  314. {
  315. hr = E_NOINTERFACE;
  316. }
  317. else
  318. {
  319. hr = _pInstallFilter->QueryService(rsid,riid,ppvObj);
  320. }
  321. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilterSink::QueryService (hr:%xd)\n", hr);
  322. return hr;
  323. }
  324. //+---------------------------------------------------------------------------
  325. //
  326. // Method: CClassInstallFilter::CClassInstallFilter
  327. //
  328. // Synopsis:
  329. //
  330. // Arguments:
  331. //
  332. // Returns:
  333. //
  334. // History: 06-27-97 EricV (Eric VandenBerg) Created
  335. //
  336. // Notes:
  337. //
  338. //----------------------------------------------------------------------------
  339. CClassInstallFilter::CClassInstallFilter()
  340. {
  341. PerfDbgLog(tagClassInstallFilter, this, "-CClassInstallFilter::CClassInstallFilter\n");
  342. DllAddRef();
  343. _pwzCDLURL = 0;
  344. _pwzClsId = 0;
  345. _pwzMime = 0;
  346. _pInstallSink = 0;
  347. _bAddRef = FALSE;
  348. _grfBSCF = 0;
  349. _ulProgress = 0;
  350. _ulProgressMax = 0;
  351. _hrResult = 0;
  352. _dwError = 0;
  353. _wzResult = NULL;
  354. _fReportResult = FALSE;
  355. _pwzDocBase[0] = L'\0';
  356. _pSecMgr = NULL;
  357. _CRefs = 1;
  358. SetInstallState(installingNone);
  359. PerfDbgLog(tagClassInstallFilter, this, "-CClassInstallFilter::CClassInstallFilter (end)\n");
  360. }
  361. //+---------------------------------------------------------------------------
  362. //
  363. // Method: CClassInstallFilter::~CClassInstallFilter
  364. //
  365. // Synopsis:
  366. //
  367. // Arguments:
  368. //
  369. // Returns:
  370. //
  371. // History: 06-27-97 EricV (Eric VandenBerg) Created
  372. //
  373. // Notes:
  374. //
  375. //----------------------------------------------------------------------------
  376. CClassInstallFilter::~CClassInstallFilter()
  377. {
  378. PerfDbgLog(tagClassInstallFilter, this, "-CClassInstallFilter::~CClassInstallFilter\n");
  379. DllRelease();
  380. TransAssert((GetInstallState() == installingNone)
  381. || (GetInstallState() == installingDone));
  382. if (_wzResult)
  383. {
  384. delete [] _wzResult;
  385. }
  386. if (_pwzCDLURL)
  387. {
  388. delete [] _pwzCDLURL;
  389. }
  390. if (_pwzClsId)
  391. {
  392. delete [] _pwzClsId;
  393. }
  394. if (_pwzMime)
  395. {
  396. delete [] _pwzMime;
  397. }
  398. if (_pInstallSink)
  399. {
  400. _pInstallSink->Release();
  401. }
  402. if (_pCDLnetProtocol)
  403. {
  404. _pCDLnetProtocol->Release();
  405. _pCDLnetProtocol = NULL;
  406. }
  407. if (_pSecMgr) {
  408. _pSecMgr->Release();
  409. }
  410. PerfDbgLog(tagClassInstallFilter, this, "-CClassInstallFilter::~CClassInstallFilter (end)\n");
  411. }
  412. //+---------------------------------------------------------------------------
  413. //
  414. // Method: CClassInstallFilter::QueryInterface
  415. //
  416. // Synopsis:
  417. //
  418. // Arguments:
  419. //
  420. // Returns:
  421. //
  422. // History: 06-27-97 EricV (Eric VandenBerg) Created
  423. //
  424. // Notes:
  425. //
  426. //----------------------------------------------------------------------------
  427. STDMETHODIMP CClassInstallFilter::QueryInterface(REFIID riid, void **ppvObj)
  428. {
  429. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::QueryInterface\n");
  430. VDATEPTROUT(ppvObj, void *);
  431. VDATETHIS(this);
  432. HRESULT hr = NOERROR;
  433. *ppvObj = NULL;
  434. {
  435. if ( (riid == IID_IUnknown)
  436. || (riid == IID_IOInetProtocol))
  437. {
  438. *ppvObj = (IOInetProtocol *) this;
  439. AddRef();
  440. }
  441. else if (riid == IID_IOInetProtocolSink)
  442. {
  443. *ppvObj = (IOInetProtocolSink *) this;
  444. AddRef();
  445. }
  446. else if (riid == IID_IServiceProvider)
  447. {
  448. *ppvObj = (IServiceProvider *) this;
  449. AddRef();
  450. }
  451. else
  452. {
  453. hr = E_NOINTERFACE;
  454. }
  455. }
  456. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::QueryInterface (hr:%lx)\n", hr);
  457. return hr;
  458. }
  459. //+---------------------------------------------------------------------------
  460. //
  461. // Function: CClassInstallFilter::AddRef
  462. //
  463. // Synopsis:
  464. //
  465. // Arguments:
  466. //
  467. // Returns:
  468. //
  469. // History: 06-27-97 EricV (Eric VandenBerg) Created
  470. //
  471. // Notes:
  472. //
  473. //----------------------------------------------------------------------------
  474. STDMETHODIMP_(ULONG) CClassInstallFilter::AddRef(void)
  475. {
  476. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::AddRef\n");
  477. LONG lRet;
  478. {
  479. lRet = ++_CRefs;
  480. }
  481. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::AddRef (cRefs:%ld)\n", lRet);
  482. return lRet;
  483. }
  484. //+---------------------------------------------------------------------------
  485. //
  486. // Function: CClassInstallFilter::Release
  487. //
  488. // Synopsis:
  489. //
  490. // Arguments:
  491. //
  492. // Returns:
  493. //
  494. // History: 06-27-97 EricV (Eric VandenBerg) Created
  495. //
  496. // Notes:
  497. //
  498. //----------------------------------------------------------------------------
  499. STDMETHODIMP_(ULONG) CClassInstallFilter::Release(void)
  500. {
  501. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::Release\n");
  502. LONG lRet;
  503. {
  504. lRet = --_CRefs;
  505. if (_CRefs == 0)
  506. {
  507. delete this;
  508. }
  509. }
  510. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::Release (cRefs:%ld)\n", lRet);
  511. return lRet;
  512. }
  513. //+---------------------------------------------------------------------------
  514. //
  515. // Method: CInstallBindInfo::CInstallBindInfo
  516. //
  517. // Synopsis:
  518. //
  519. // Arguments:
  520. //
  521. // Returns:
  522. //
  523. // History: 06-27-97 EricV (Eric VandenBerg) Created
  524. //
  525. // Notes:
  526. //
  527. //----------------------------------------------------------------------------
  528. CInstallBindInfo::CInstallBindInfo()
  529. {
  530. PerfDbgLog(tagClassInstallFilter, this, "-CInstallBindInfo::CClassInstallFilter\n");
  531. _CRefs = 1;
  532. PerfDbgLog(tagClassInstallFilter, this, "-CInstallBindInfo::ClassInstallFilter (end)\n");
  533. }
  534. //+---------------------------------------------------------------------------
  535. //
  536. // Method: CInstallBindInfo::~CInstallBindInfo
  537. //
  538. // Synopsis:
  539. //
  540. // Arguments:
  541. //
  542. // Returns:
  543. //
  544. // History: 06-27-97 EricV (Eric VandenBerg) Created
  545. //
  546. // Notes:
  547. //
  548. //----------------------------------------------------------------------------
  549. CInstallBindInfo::~CInstallBindInfo()
  550. {
  551. PerfDbgLog(tagClassInstallFilter, this, "-CInstallBindInfo::~CInstallBindInfo\n");
  552. PerfDbgLog(tagClassInstallFilter, this, "-CInstallBindInfo::~CInstallBindInfo (end)\n");
  553. }
  554. //+---------------------------------------------------------------------------
  555. //
  556. // Method: CInstallBindInfo::QueryInterface
  557. //
  558. // Synopsis:
  559. //
  560. // Arguments:
  561. //
  562. // Returns:
  563. //
  564. // History: 06-27-97 EricV (Eric VandenBerg) Created
  565. //
  566. // Notes:
  567. //
  568. //----------------------------------------------------------------------------
  569. STDMETHODIMP CInstallBindInfo::QueryInterface(REFIID riid, void **ppvObj)
  570. {
  571. PerfDbgLog(tagClassInstallFilter, this, "+CInstallBindInfo::QueryInterface\n");
  572. VDATEPTROUT(ppvObj, void *);
  573. VDATETHIS(this);
  574. HRESULT hr = NOERROR;
  575. *ppvObj = NULL;
  576. {
  577. if ( (riid == IID_IUnknown)
  578. || (riid == IID_IOInetBindInfo))
  579. {
  580. *ppvObj = (IOInetBindInfo *) this;
  581. AddRef();
  582. }
  583. else
  584. {
  585. hr = E_NOINTERFACE;
  586. }
  587. }
  588. PerfDbgLog1(tagClassInstallFilter, this, "-CInstallBindInfo::QueryInterface (hr:%lx)\n", hr);
  589. return hr;
  590. }
  591. //+---------------------------------------------------------------------------
  592. //
  593. // Function: CInstallBindInfo::AddRef
  594. //
  595. // Synopsis:
  596. //
  597. // Arguments:
  598. //
  599. // Returns:
  600. //
  601. // History: 06-27-97 EricV (Eric VandenBerg) Created
  602. //
  603. // Notes:
  604. //
  605. //----------------------------------------------------------------------------
  606. STDMETHODIMP_(ULONG) CInstallBindInfo::AddRef(void)
  607. {
  608. PerfDbgLog(tagClassInstallFilter, this, "+CInstallBindInfo::AddRef\n");
  609. LONG lRet;
  610. {
  611. lRet = ++_CRefs;
  612. }
  613. PerfDbgLog1(tagClassInstallFilter, this, "-CInstallBindInfo::AddRef (cRefs:%ld)\n", lRet);
  614. return lRet;
  615. }
  616. //+---------------------------------------------------------------------------
  617. //
  618. // Function: CInstallBindInfo::Release
  619. //
  620. // Synopsis:
  621. //
  622. // Arguments:
  623. //
  624. // Returns:
  625. //
  626. // History: 06-27-97 EricV (Eric VandenBerg) Created
  627. //
  628. // Notes:
  629. //
  630. //----------------------------------------------------------------------------
  631. STDMETHODIMP_(ULONG) CInstallBindInfo::Release(void)
  632. {
  633. PerfDbgLog(tagClassInstallFilter, this, "+CInstallBindInfo::Release\n");
  634. LONG lRet;
  635. {
  636. lRet = --_CRefs;
  637. if (_CRefs == 0)
  638. {
  639. delete this;
  640. }
  641. }
  642. PerfDbgLog1(tagClassInstallFilter, this, "-CInstallBindInfo::Release (cRefs:%ld)\n", lRet);
  643. return lRet;
  644. }
  645. //+---------------------------------------------------------------------------
  646. //
  647. // Method: CInstallBindInfo::GetBindInfo
  648. //
  649. // Synopsis:
  650. //
  651. // Arguments: [grfBINDF] --
  652. // [pbindinfo] --
  653. //
  654. // Returns:
  655. //
  656. // History: 06-27-97 EricV (Eric VandenBerg) Created
  657. //
  658. // Notes:
  659. //
  660. //----------------------------------------------------------------------------
  661. STDMETHODIMP CInstallBindInfo::GetBindInfo(
  662. DWORD *grfBINDF, BINDINFO * pbindinfo)
  663. {
  664. PerfDbgLog(tagClassInstallFilter, this, "+CInstallBindInfo::GetBindInfo\n");
  665. HRESULT hr = NOERROR;
  666. TransAssert(pbindinfo);
  667. if (!grfBINDF || !pbindinfo || !pbindinfo->cbSize)
  668. {
  669. hr = E_INVALIDARG;
  670. }
  671. else
  672. {
  673. DWORD cbSize = pbindinfo->cbSize;
  674. memset(pbindinfo, 0, cbSize);
  675. pbindinfo->cbSize = cbSize;
  676. }
  677. PerfDbgLog1(tagClassInstallFilter, this, "+CInstallBindInfo::GetBindInfo (hr:%lx)\n",hr);
  678. return hr;
  679. }
  680. //+---------------------------------------------------------------------------
  681. //
  682. // Method: CInstallBindInfo::GetBindString
  683. //
  684. // Synopsis:
  685. //
  686. // Arguments: [ulStringType] --
  687. // [ppwzStr] --
  688. // [cEl] --
  689. // [pcElFetched] --
  690. //
  691. // Returns:
  692. //
  693. // History: 06-27-97 EricV (Eric VandenBerg) Created
  694. //
  695. // Notes:
  696. //
  697. //----------------------------------------------------------------------------
  698. STDMETHODIMP CInstallBindInfo::GetBindString(
  699. ULONG ulStringType, LPOLESTR *ppwzStr, ULONG cEl, ULONG *pcElFetched)
  700. {
  701. PerfDbgLog(tagClassInstallFilter, this, "+CInstallBindInfo::GetBindString\n");
  702. HRESULT hr = NOERROR;
  703. TransAssert(ppwzStr);
  704. TransAssert(pcElFetched);
  705. if (ppwzStr && pcElFetched)
  706. {
  707. *ppwzStr = NULL;
  708. *pcElFetched = 0;
  709. }
  710. hr = S_FALSE;
  711. PerfDbgLog1(tagClassInstallFilter, this, "+CInstallBindInfo::GetBindString (hr:%lx)\n",hr);
  712. return hr;
  713. }
  714. //+---------------------------------------------------------------------------
  715. //
  716. // Method: CClassInstallFilter::Start
  717. //
  718. // Synopsis:
  719. //
  720. // Arguments: [pwzUrl] --
  721. // [pTrans] --
  722. // [pOIBindInfo] --
  723. // [grfSTI] --
  724. // [dwReserved] --
  725. //
  726. // Returns:
  727. //
  728. // History: 06-27-97 EricV (Eric VandenBerg) Created
  729. //
  730. // Notes:
  731. //
  732. //----------------------------------------------------------------------------
  733. STDMETHODIMP CClassInstallFilter::Start(LPCWSTR pwzUrl,
  734. IOInetProtocolSink *pOInetProtSnk,
  735. IOInetBindInfo *pOIBindInfo,
  736. DWORD grfSTI,
  737. DWORD_PTR dwReserved)
  738. {
  739. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::Start\n");
  740. HRESULT hr = NOERROR;
  741. IOInetSession *pOInetSession = NULL;
  742. PROTOCOLFILTERDATA *pFilterData = (PROTOCOLFILTERDATA *)dwReserved;
  743. static LPCWSTR pwzCDLFormatCDL = L"cdl:";
  744. static LPCWSTR pwzCDLFormatCodebase = L"codebase=";
  745. static LPCWSTR pwzCDLFormatClsId = L"clsid=";
  746. static LPCWSTR pwzCDLFormatMime = L"mimetype=";
  747. static LPCWSTR pwzCDLFormatVerMS = L";verMS=";
  748. static LPCWSTR pwzCDLFormatVerLS = L";verLS=";
  749. static LPCWSTR pwzCDLFormatSeparator = L";";
  750. IOInetBindInfo *pBindInfo = NULL;
  751. LPWSTR pwzTmp = NULL;
  752. LPWSTR pwzVerInfo = NULL, pwzVerMS = NULL, pwzVerLS = NULL;
  753. DWORD dwSize;
  754. WCHAR chType = L'\0';
  755. TransAssert((pOIBindInfo && pOInetProtSnk && pwzUrl));
  756. TransAssert(!_pCDLnetProtocol);
  757. //BUGBUG:
  758. // we engage in some trickery to get the URL & class ID. The URL string
  759. // passed to us is actually "Class Install Handler", but after the NULL
  760. // terminator we expect the docbase the show up. After this, the real URL
  761. // info to occur. This is because the pwzURL
  762. // is used by LoadHandler to find us in the registry and then calls us with it.
  763. // Get the docbase
  764. while (*pwzUrl)
  765. {
  766. pwzUrl++;
  767. }
  768. pwzUrl++;
  769. lstrcpyW(_pwzDocBase, pwzUrl);
  770. // Now get the cdl:// codebase
  771. while (*pwzUrl)
  772. {
  773. pwzUrl++;
  774. }
  775. pwzUrl++;
  776. if (pOInetProtSnk && pwzUrl && *pwzUrl)
  777. {
  778. TransAssert(pwzUrl);
  779. //
  780. // expect url: codebase?<type>[clsid|mimetype]?<verMS>,<verLS>
  781. // example: http://msw/officehandler.cab?CABCD1234-...?1,2
  782. //
  783. delete [] _pwzUrl;
  784. pwzTmp = _pwzUrl = OLESTRDuplicate((LPCWSTR)pwzUrl);
  785. while (*pwzTmp && *pwzTmp != L'?')
  786. {
  787. pwzTmp++;
  788. }
  789. if (*pwzTmp)
  790. {
  791. *pwzTmp = L'\0';
  792. pwzTmp++;
  793. delete [] _pwzClsId;
  794. // extract version info.
  795. pwzVerInfo = pwzTmp;
  796. while (*pwzVerInfo && *pwzVerInfo != L'?')
  797. {
  798. pwzVerInfo++;
  799. }
  800. if (*pwzVerInfo == L'?')
  801. {
  802. pwzVerMS = pwzVerInfo + 1;
  803. pwzVerLS = pwzVerMS;
  804. while (*pwzVerLS && *pwzVerLS != L',')
  805. {
  806. pwzVerLS++;
  807. }
  808. if (*pwzVerLS == L',')
  809. {
  810. *pwzVerLS = L'\0';
  811. pwzVerLS++;
  812. }
  813. *pwzVerInfo = '\0';
  814. }
  815. else
  816. {
  817. pwzVerInfo = NULL;
  818. }
  819. if (*pwzTmp == L'{')
  820. {
  821. // handle CLSID string
  822. _pwzClsId = OLESTRDuplicate((LPCWSTR)pwzTmp);
  823. _pwzMime = NULL;
  824. }
  825. else
  826. {
  827. _pwzMime = OLESTRDuplicate((LPCWSTR)pwzTmp);
  828. _pwzClsId = NULL;
  829. }
  830. // compose cdl:// string
  831. dwSize = lstrlenW(pwzCDLFormatCDL)
  832. + (_pwzUrl ? lstrlenW(pwzCDLFormatCodebase)
  833. + lstrlenW(_pwzUrl)
  834. + lstrlenW(pwzCDLFormatSeparator) : 0)
  835. + (_pwzClsId ? lstrlenW(pwzCDLFormatClsId)
  836. + lstrlenW(_pwzClsId) : 0)
  837. + (_pwzMime ? lstrlenW(pwzCDLFormatMime)
  838. + lstrlenW(_pwzMime) : 0)
  839. + (pwzVerMS ? lstrlenW(pwzCDLFormatVerMS)
  840. + lstrlenW(pwzVerMS) : 0)
  841. + (pwzVerLS ? lstrlenW(pwzCDLFormatVerLS)
  842. + lstrlenW(pwzVerLS) : 0)
  843. + 3;
  844. delete [] _pwzCDLURL;
  845. _pwzCDLURL = new WCHAR[dwSize];
  846. if (_pwzCDLURL)
  847. {
  848. StrCpyW(_pwzCDLURL, pwzCDLFormatCDL);
  849. // codebase is optional, but one of clsid or mimetype must exist.
  850. if (_pwzUrl)
  851. {
  852. StrCatW(_pwzCDLURL, pwzCDLFormatCodebase);
  853. StrCatW(_pwzCDLURL, _pwzUrl);
  854. StrCatW(_pwzCDLURL, pwzCDLFormatSeparator);
  855. }
  856. if (_pwzClsId)
  857. {
  858. StrCatW(_pwzCDLURL, pwzCDLFormatClsId);
  859. StrCatW(_pwzCDLURL, _pwzClsId);
  860. }
  861. else if (_pwzMime)
  862. {
  863. StrCatW(_pwzCDLURL, pwzCDLFormatMime);
  864. StrCatW(_pwzCDLURL, _pwzMime);
  865. }
  866. else
  867. {
  868. hr = E_UNEXPECTED;
  869. }
  870. if (pwzVerMS)
  871. {
  872. StrCatW(_pwzCDLURL, pwzCDLFormatVerMS);
  873. StrCatW(_pwzCDLURL, pwzVerMS);
  874. }
  875. if (pwzVerLS)
  876. {
  877. StrCatW(_pwzCDLURL, pwzCDLFormatVerLS);
  878. StrCatW(_pwzCDLURL, pwzVerLS);
  879. }
  880. }
  881. else
  882. {
  883. hr = E_OUTOFMEMORY;
  884. }
  885. }
  886. else
  887. {
  888. hr = E_INVALIDARG;
  889. }
  890. if (SUCCEEDED(hr) && _pwzCDLURL && pFilterData && pFilterData->pProtocol)
  891. {
  892. _pProt = pFilterData->pProtocol;
  893. _pProt->AddRef();
  894. _pProtSnk = pOInetProtSnk;
  895. _pProtSnk->AddRef();
  896. // Pass our IInternetProtocolSink out
  897. pFilterData->pProtocolSink = (IOInetProtocolSink *)this;
  898. hr = CoInternetGetSession(0, &pOInetSession, 0);
  899. if (SUCCEEDED(hr))
  900. {
  901. hr = pOInetSession->CreateBinding(NULL, _pwzCDLURL, NULL, NULL,
  902. (IOInetProtocol **)&_pCDLnetProtocol,
  903. OIBDG_APARTMENTTHREADED);
  904. pOInetSession->Release();
  905. if (SUCCEEDED(hr) && _pCDLnetProtocol)
  906. {
  907. _pInstallSink = new CClassInstallFilterSink(this);
  908. if (_pInstallSink)
  909. {
  910. //hr = _CBindInfo.QueryInterface(IID_IOInetBindInfo, (void **)&pBindInfo);
  911. pBindInfo = new CInstallBindInfo();
  912. if (!pBindInfo) {
  913. hr = E_OUTOFMEMORY;
  914. }
  915. if (SUCCEEDED(hr) && pBindInfo)
  916. {
  917. hr = _pCDLnetProtocol->Start(_pwzCDLURL,
  918. (IOInetProtocolSink *)_pInstallSink,
  919. (IOInetBindInfo *)pBindInfo,
  920. PI_FORCE_ASYNC | PI_APARTMENTTHREADED, 0);
  921. // We add reference ourself so that if we are terminated before
  922. // the cdl:// download we don't get deleted.
  923. pBindInfo->Release();
  924. pBindInfo = NULL;
  925. if (hr == E_PENDING) {
  926. AddRef();
  927. _bAddRef = TRUE;
  928. SetInstallState(installingHandler);
  929. }
  930. }
  931. }
  932. else
  933. {
  934. hr = E_OUTOFMEMORY;
  935. }
  936. }
  937. }
  938. }
  939. else
  940. {
  941. hr = E_INVALIDARG;
  942. }
  943. }
  944. else
  945. {
  946. hr = E_FAIL;
  947. }
  948. // BUGBUG: when do we release if E_PENDING?
  949. if (hr != E_PENDING)
  950. {
  951. SetInstallState(installingDone);
  952. if (_pCDLnetProtocol)
  953. {
  954. _pCDLnetProtocol->Release();
  955. _pCDLnetProtocol = NULL;
  956. }
  957. }
  958. PerfDbgLog1(tagClassInstallFilter, this, "+CClassInstallFilter::Start (hr:%lx)\n",hr);
  959. return hr;
  960. }
  961. //+---------------------------------------------------------------------------
  962. //
  963. // Method: CClassInstallFilter::Continue
  964. //
  965. // Synopsis:
  966. //
  967. // Arguments: [pStateInfoIn] --
  968. //
  969. // Returns:
  970. //
  971. // History: 06-27-97 EricV (Eric VandenBerg) Created
  972. //
  973. // Notes:
  974. //
  975. //----------------------------------------------------------------------------
  976. STDMETHODIMP CClassInstallFilter::Continue(PROTOCOLDATA *pStateInfoIn)
  977. {
  978. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::Continue\n");
  979. HRESULT hr = NOERROR;
  980. if (_pProt)
  981. {
  982. hr = _pProt->Continue(pStateInfoIn);
  983. }
  984. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::Continue (hr:%lx)\n",hr);
  985. return hr;
  986. }
  987. //+---------------------------------------------------------------------------
  988. //
  989. // Method: CClassInstallFilter::Abort
  990. //
  991. // Synopsis:
  992. //
  993. // Arguments: [hrReason] --
  994. // [dwOptions] --
  995. //
  996. // Returns:
  997. //
  998. // History: 06-27-97 EricV (Eric VandenBerg) Created
  999. //
  1000. // Notes:
  1001. //
  1002. //----------------------------------------------------------------------------
  1003. STDMETHODIMP CClassInstallFilter::Abort(HRESULT hrReason, DWORD dwOptions)
  1004. {
  1005. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::Abort\n");
  1006. HRESULT hr = NOERROR;
  1007. if (_pCDLnetProtocol)
  1008. {
  1009. hr = _pCDLnetProtocol->Abort(hrReason, dwOptions);
  1010. }
  1011. if (_pProt)
  1012. {
  1013. hr = _pProt->Abort(hrReason, dwOptions);
  1014. }
  1015. // Release sink
  1016. if (_pProtSnk)
  1017. {
  1018. _pProtSnk->Release();
  1019. _pProtSnk = NULL;
  1020. }
  1021. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::Abort (hr:%lx)\n", hr);
  1022. return hr;
  1023. }
  1024. //+---------------------------------------------------------------------------
  1025. //
  1026. // Method: CClassInstallFilter::Terminate
  1027. //
  1028. // Synopsis:
  1029. //
  1030. // Arguments: [dwOptions] --
  1031. //
  1032. // Returns:
  1033. //
  1034. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1035. //
  1036. // Notes:
  1037. //
  1038. //----------------------------------------------------------------------------
  1039. STDMETHODIMP CClassInstallFilter::Terminate(DWORD dwOptions)
  1040. {
  1041. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::Terminate\n");
  1042. HRESULT hr = NOERROR;
  1043. TransAssert((_pProt));
  1044. if (_pCDLnetProtocol)
  1045. {
  1046. hr = _pCDLnetProtocol->Terminate(dwOptions);
  1047. }
  1048. if (_pProt)
  1049. {
  1050. hr = _pProt->Terminate(dwOptions);
  1051. }
  1052. // Release sink
  1053. if (_pProtSnk)
  1054. {
  1055. _pProtSnk->Release();
  1056. _pProtSnk = NULL;
  1057. }
  1058. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::Terminate (hr:%lx)\n", hr);
  1059. return hr;
  1060. }
  1061. //+---------------------------------------------------------------------------
  1062. //
  1063. // Method: CClassInstallFilter::Suspend
  1064. //
  1065. // Synopsis:
  1066. //
  1067. // Arguments: (none)
  1068. //
  1069. // Returns:
  1070. //
  1071. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1072. //
  1073. // Notes:
  1074. //
  1075. //----------------------------------------------------------------------------
  1076. STDMETHODIMP CClassInstallFilter::Suspend()
  1077. {
  1078. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::Suspend\n");
  1079. HRESULT hr = NOERROR;
  1080. if (_pProt)
  1081. {
  1082. hr = _pProt->Suspend();
  1083. }
  1084. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::Suspend (hr:%lx)\n", hr);
  1085. return hr;
  1086. }
  1087. //+---------------------------------------------------------------------------
  1088. //
  1089. // Method: CClassInstallFilter::Resume
  1090. //
  1091. // Synopsis:
  1092. //
  1093. // Arguments: (none)
  1094. //
  1095. // Returns:
  1096. //
  1097. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1098. //
  1099. // Notes:
  1100. //
  1101. //----------------------------------------------------------------------------
  1102. STDMETHODIMP CClassInstallFilter::Resume()
  1103. {
  1104. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::Resume\n");
  1105. HRESULT hr = NOERROR;
  1106. if (_pProt)
  1107. {
  1108. hr = _pProt->Resume();
  1109. }
  1110. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::Resume (hr:%lx)\n", hr);
  1111. return hr;
  1112. }
  1113. //+---------------------------------------------------------------------------
  1114. //
  1115. // Method: CClassInstallFilter::Read
  1116. //
  1117. // Synopsis:
  1118. //
  1119. // Arguments: (none)
  1120. //
  1121. // Returns:
  1122. //
  1123. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1124. //
  1125. // Notes:
  1126. //
  1127. //----------------------------------------------------------------------------
  1128. STDMETHODIMP CClassInstallFilter::Read(void *pv,ULONG cb,ULONG *pcbRead)
  1129. {
  1130. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::Read\n");
  1131. HRESULT hr = NOERROR;
  1132. if (_pProt)
  1133. {
  1134. hr = _pProt->Read(pv,cb,pcbRead);
  1135. }
  1136. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::Read (hr:%lx)\n", hr);
  1137. return hr;
  1138. }
  1139. //+---------------------------------------------------------------------------
  1140. //
  1141. // Method: CClassInstallFilter::Seek
  1142. //
  1143. // Synopsis:
  1144. //
  1145. // Arguments: (none)
  1146. //
  1147. // Returns:
  1148. //
  1149. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1150. //
  1151. // Notes:
  1152. //
  1153. //----------------------------------------------------------------------------
  1154. STDMETHODIMP CClassInstallFilter::Seek(LARGE_INTEGER dlibMove,DWORD dwOrigin,
  1155. ULARGE_INTEGER *plibNewPosition)
  1156. {
  1157. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::Seek\n");
  1158. HRESULT hr = NOERROR;
  1159. if (_pProt)
  1160. {
  1161. hr = _pProt->Seek(dlibMove, dwOrigin, plibNewPosition);
  1162. }
  1163. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::Seek (hr:%lx)\n", hr);
  1164. return hr;
  1165. }
  1166. //+---------------------------------------------------------------------------
  1167. //
  1168. // Method: CClassInstallFilter::LockRequest
  1169. //
  1170. // Synopsis:
  1171. //
  1172. // Arguments: [dwOptions] --
  1173. //
  1174. // Returns:
  1175. //
  1176. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1177. //
  1178. // Notes:
  1179. //
  1180. //----------------------------------------------------------------------------
  1181. STDMETHODIMP CClassInstallFilter::LockRequest(DWORD dwOptions)
  1182. {
  1183. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::LockRequest\n");
  1184. HRESULT hr = NOERROR;
  1185. if (_pProt)
  1186. {
  1187. hr = _pProt->LockRequest(dwOptions);
  1188. }
  1189. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::LockRequest (hr:%lx)\n",hr);
  1190. return hr;
  1191. }
  1192. //+---------------------------------------------------------------------------
  1193. //
  1194. // Method: CClassInstallFilter::UnlockRequest
  1195. //
  1196. // Synopsis:
  1197. //
  1198. // Arguments: (none)
  1199. //
  1200. // Returns:
  1201. //
  1202. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1203. //
  1204. // Notes:
  1205. //
  1206. //----------------------------------------------------------------------------
  1207. STDMETHODIMP CClassInstallFilter::UnlockRequest()
  1208. {
  1209. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::UnlockRequest\n");
  1210. HRESULT hr = NOERROR;
  1211. if (_pProt)
  1212. {
  1213. hr = _pProt->UnlockRequest();
  1214. }
  1215. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::UnlockRequest (hr:%lx)\n", hr);
  1216. return hr;
  1217. }
  1218. //+---------------------------------------------------------------------------
  1219. //
  1220. // Method: CClassInstallFilter::Switch
  1221. //
  1222. // Synopsis:
  1223. //
  1224. // Arguments: [pStateInfo] --
  1225. //
  1226. // Returns:
  1227. //
  1228. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1229. //
  1230. // Notes:
  1231. //
  1232. //----------------------------------------------------------------------------
  1233. STDMETHODIMP CClassInstallFilter::Switch(PROTOCOLDATA *pStateInfo)
  1234. {
  1235. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::Switch\n");
  1236. HRESULT hr = NOERROR;
  1237. if (_pProtSnk)
  1238. {
  1239. hr = _pProtSnk->Switch(pStateInfo);
  1240. }
  1241. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::Switch (hr:%lx)\n", hr);
  1242. return hr;
  1243. }
  1244. //+---------------------------------------------------------------------------
  1245. //
  1246. // Method: CClassInstallFilter::ReportProgress
  1247. //
  1248. // Synopsis:
  1249. //
  1250. // Arguments: [NotMsg] --
  1251. // [szStatusText] --
  1252. //
  1253. // Returns:
  1254. //
  1255. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1256. //
  1257. // Notes:
  1258. //
  1259. //----------------------------------------------------------------------------
  1260. STDMETHODIMP CClassInstallFilter::ReportProgress(ULONG NotMsg, LPCWSTR pwzStatusText)
  1261. {
  1262. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::ReportProgress\n");
  1263. HRESULT hr = NOERROR;
  1264. if (_pProtSnk)
  1265. {
  1266. hr = _pProtSnk->ReportProgress(NotMsg, pwzStatusText);
  1267. }
  1268. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::ReportProgress (hr:%lx)\n", hr);
  1269. return hr;
  1270. }
  1271. //+---------------------------------------------------------------------------
  1272. //
  1273. // Method: CClassInstallFilter::ReportData
  1274. //
  1275. // Synopsis:
  1276. //
  1277. // Arguments: [grfBSCF] --
  1278. // [ULONG] --
  1279. // [ulProgressMax] --
  1280. //
  1281. // Returns:
  1282. //
  1283. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1284. //
  1285. // Notes:
  1286. //
  1287. //----------------------------------------------------------------------------
  1288. STDMETHODIMP CClassInstallFilter::ReportData(DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax)
  1289. {
  1290. PerfDbgLog3(tagClassInstallFilter, this, "+CClassInstallFilter::ReportData(grfBSCF:%lx, ulProgress:%ld, ulProgressMax:%ld)\n",
  1291. grfBSCF, ulProgress, ulProgressMax);
  1292. HRESULT hr = NOERROR;
  1293. _grfBSCF = grfBSCF;
  1294. _ulProgress = ulProgress;
  1295. _ulProgressMax = ulProgressMax;
  1296. if (_pProtSnk)
  1297. {
  1298. hr = _pProtSnk->ReportData( grfBSCF, ulProgress, ulProgressMax);
  1299. }
  1300. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::ReportData (hr:%lx)\n", hr);
  1301. return hr;
  1302. }
  1303. //+---------------------------------------------------------------------------
  1304. //
  1305. // Method: CClassInstallFilter::ReportResult
  1306. //
  1307. // Synopsis:
  1308. //
  1309. // Arguments: [DWORD] --
  1310. // [dwError] --
  1311. // [wzResult] --
  1312. //
  1313. // Returns:
  1314. //
  1315. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1316. //
  1317. // Notes:
  1318. //
  1319. //----------------------------------------------------------------------------
  1320. STDMETHODIMP CClassInstallFilter::ReportResult(HRESULT hrResult, DWORD dwError, LPCWSTR wzResult)
  1321. {
  1322. PerfDbgLog(tagClassInstallFilter, this, "+CClassInstallFilter::ReportResult\n");
  1323. HRESULT hr = NOERROR;
  1324. // record any failure, unless overwriting previous failure
  1325. if (FAILED(hrResult) && SUCCEEDED(_hrResult) ) {
  1326. _hrResult = hrResult;
  1327. _dwError = dwError;
  1328. _wzResult = NULL;
  1329. if (_wzResult)
  1330. {
  1331. _wzResult = new WCHAR[lstrlenW(wzResult)+1];
  1332. StrCpyW(_wzResult, wzResult);
  1333. }
  1334. }
  1335. if (GetInstallState() != installingDone)
  1336. {
  1337. // data (docfile) completed download
  1338. _fReportResult = TRUE;
  1339. }
  1340. else if (_fReportResult)
  1341. {
  1342. // all complete
  1343. if (_pProtSnk)
  1344. {
  1345. // always report recorded results
  1346. hr = _pProtSnk->ReportResult(_hrResult, _dwError, _wzResult);
  1347. }
  1348. } else {
  1349. // data (docfile) completed download
  1350. _fReportResult = TRUE;
  1351. }
  1352. PerfDbgLog1(tagClassInstallFilter, this, "-CClassInstallFilter::ReportResult (hr:%lx)\n", hr);
  1353. return hr;
  1354. }
  1355. //+---------------------------------------------------------------------------
  1356. //
  1357. // Method: CClassInstallFilter::CClassInstallFilter
  1358. //
  1359. // Synopsis:
  1360. //
  1361. // Arguments: [DWORD] --
  1362. // [dwError] --
  1363. // [wzResult] --
  1364. //
  1365. // Returns:
  1366. //
  1367. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1368. //
  1369. // Notes:
  1370. //
  1371. //----------------------------------------------------------------------------
  1372. HRESULT CClassInstallFilter::InstallerReportResult(HRESULT hrResult, DWORD dwError, LPCWSTR wzResult)
  1373. {
  1374. HRESULT hr = NOERROR;
  1375. SetInstallState(installingDone);
  1376. if (_pProtSnk)
  1377. {
  1378. // tell sink to stop waiting on handler to install
  1379. _pProtSnk->ReportProgress(BINDSTATUS_ENDDOWNLOADCOMPONENTS,NULL);
  1380. // repeat last report data to kick start binding operation
  1381. _pProtSnk->ReportData(_grfBSCF, _ulProgress, _ulProgressMax);
  1382. }
  1383. ReportResult(hrResult, dwError, wzResult);
  1384. if (_bAddRef)
  1385. {
  1386. _bAddRef = FALSE;
  1387. Release();
  1388. }
  1389. return hr;
  1390. }
  1391. //+---------------------------------------------------------------------------
  1392. //
  1393. // Method: CClassInstallFilter::QueryService
  1394. //
  1395. // Synopsis:
  1396. //
  1397. // Arguments: [rsid] --
  1398. // [riid] --
  1399. // [ppvObj] --
  1400. //
  1401. // Returns:
  1402. //
  1403. // History: 06-27-97 EricV (Eric VandenBerg) Created
  1404. //
  1405. // Notes:
  1406. //
  1407. //----------------------------------------------------------------------------
  1408. STDMETHODIMP CClassInstallFilter::QueryService(REFGUID rsid, REFIID riid, void ** ppvObj)
  1409. {
  1410. HRESULT hr = NOERROR;
  1411. IServiceProvider *pIServiceProvider = NULL;
  1412. EProtAssert(ppvObj);
  1413. if (!ppvObj)
  1414. return E_INVALIDARG;
  1415. *ppvObj = 0;
  1416. if (IsEqualGUID(rsid, IID_IInternetHostSecurityManager) &&
  1417. IsEqualGUID(riid, IID_IInternetHostSecurityManager)) {
  1418. if (_pSecMgr == NULL) {
  1419. hr = CoInternetCreateSecurityManager(NULL, &_pSecMgr, NULL);
  1420. }
  1421. if (_pSecMgr) {
  1422. *ppvObj = (IInternetHostSecurityManager *)this;
  1423. AddRef();
  1424. }
  1425. else {
  1426. hr = E_NOINTERFACE;
  1427. }
  1428. }
  1429. else {
  1430. hr = _pProtSnk->QueryInterface(IID_IServiceProvider,
  1431. (LPVOID *)&pIServiceProvider);
  1432. if (SUCCEEDED(hr))
  1433. {
  1434. hr = pIServiceProvider->QueryService(rsid, riid, (LPVOID *)ppvObj);
  1435. pIServiceProvider->Release();
  1436. }
  1437. }
  1438. return hr;
  1439. }
  1440. // IInternetHostSecurityManager
  1441. STDMETHODIMP CClassInstallFilter::GetSecurityId(BYTE *pbSecurityId, DWORD *pcbSecurityId,
  1442. DWORD_PTR dwReserved)
  1443. {
  1444. HRESULT hr = E_FAIL;
  1445. if (_pSecMgr) {
  1446. hr = _pSecMgr->GetSecurityId(_pwzDocBase, pbSecurityId,
  1447. pcbSecurityId, dwReserved);
  1448. }
  1449. return hr;
  1450. }
  1451. STDMETHODIMP CClassInstallFilter::ProcessUrlAction(DWORD dwAction, BYTE *pPolicy, DWORD cbPolicy,
  1452. BYTE *pContext, DWORD cbContext, DWORD dwFlags,
  1453. DWORD dwReserved)
  1454. {
  1455. HRESULT hr = E_FAIL;
  1456. if (_pSecMgr) {
  1457. hr = _pSecMgr->ProcessUrlAction(_pwzDocBase, dwAction, pPolicy,
  1458. cbPolicy, pContext, cbContext,
  1459. dwFlags, dwReserved);
  1460. }
  1461. return hr;
  1462. }
  1463. STDMETHODIMP CClassInstallFilter::QueryCustomPolicy(REFGUID guidKey, BYTE **ppPolicy,
  1464. DWORD *pcbPolicy, BYTE *pContext,
  1465. DWORD cbContext, DWORD dwReserved)
  1466. {
  1467. HRESULT hr = E_FAIL;
  1468. if (_pSecMgr) {
  1469. hr = _pSecMgr->QueryCustomPolicy(_pwzDocBase, guidKey, ppPolicy,
  1470. pcbPolicy, pContext, cbContext,
  1471. dwReserved);
  1472. }
  1473. return hr;
  1474. }