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.

161 lines
3.4 KiB

  1. #include <urlmon.h>
  2. #include "cdlbsc.hpp"
  3. #include "resource.h"
  4. CodeDownloadBSC::CodeDownloadBSC( HWND hwnd, HWND hdlg, LPITEMIDLIST pidlUpdate )
  5. {
  6. _cRef = 1;
  7. _pIBinding = NULL;
  8. _hwnd = hwnd;
  9. _pidlUpdate = pidlUpdate;
  10. _hdlg = hdlg;
  11. }
  12. CodeDownloadBSC::~CodeDownloadBSC()
  13. {
  14. if ( _pidlUpdate )
  15. ILFree( _pidlUpdate );
  16. }
  17. HRESULT CodeDownloadBSC::Abort()
  18. {
  19. return _pIBinding->Abort();
  20. }
  21. /*
  22. *
  23. * IUnknown Methods
  24. *
  25. */
  26. STDMETHODIMP CodeDownloadBSC::QueryInterface(REFIID riid, void **ppv)
  27. {
  28. HRESULT hr = E_NOINTERFACE;
  29. *ppv = NULL;
  30. if (riid == IID_IUnknown || riid == IID_IBindStatusCallback)
  31. {
  32. *ppv = (IBindStatusCallback *)this;
  33. }
  34. else if ( riid == IID_IWindowForBindingUI )
  35. {
  36. *ppv = (IWindowForBindingUI *)this;
  37. }
  38. if (*ppv != NULL)
  39. {
  40. ((IUnknown *)*ppv)->AddRef();
  41. hr = S_OK;
  42. }
  43. return hr;
  44. }
  45. STDMETHODIMP_(ULONG) CodeDownloadBSC::AddRef()
  46. {
  47. return ++_cRef;
  48. }
  49. STDMETHODIMP_(ULONG) CodeDownloadBSC::Release()
  50. {
  51. if (--_cRef)
  52. {
  53. return _cRef;
  54. }
  55. delete this;
  56. return 0;
  57. }
  58. /*
  59. *
  60. * IBindStatusCallback Methods
  61. *
  62. */
  63. STDMETHODIMP CodeDownloadBSC::OnStartBinding(DWORD grfBSCOption, IBinding *pib)
  64. {
  65. if (_pIBinding != NULL)
  66. {
  67. _pIBinding->Release();
  68. }
  69. _pIBinding = pib;
  70. if (_pIBinding != NULL)
  71. {
  72. _pIBinding->AddRef();
  73. }
  74. return S_OK;
  75. }
  76. STDMETHODIMP CodeDownloadBSC::OnStopBinding(HRESULT hresult, LPCWSTR szError)
  77. {
  78. if ( _hdlg != NULL )
  79. PostMessage(_hdlg, WM_COMMAND, DOWNLOAD_COMPLETE,
  80. SUCCEEDED(hresult) ? TRUE : FALSE);
  81. if ( SUCCEEDED(hresult) && _pidlUpdate )
  82. {
  83. SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_IDLIST, _pidlUpdate, NULL);
  84. SHChangeNotifyHandleEvents();
  85. }
  86. return S_OK;
  87. }
  88. STDMETHODIMP CodeDownloadBSC::OnObjectAvailable(REFIID riid, IUnknown *punk)
  89. {
  90. if ( _hdlg != NULL )
  91. PostMessage(_hdlg, WM_COMMAND, DOWNLOAD_COMPLETE, TRUE );
  92. return S_OK;
  93. }
  94. STDMETHODIMP CodeDownloadBSC::GetPriority(LONG *pnPriority)
  95. {
  96. return S_OK;
  97. }
  98. STDMETHODIMP CodeDownloadBSC::OnLowResource(DWORD dwReserved)
  99. {
  100. return S_OK;
  101. }
  102. STDMETHODIMP CodeDownloadBSC::OnProgress(ULONG ulProgress, ULONG ulProgressMax,
  103. ULONG ulStatusCode,
  104. LPCWSTR szStatusText)
  105. {
  106. if ( _hdlg != NULL )
  107. {
  108. // convert progress to a percentage - 0->100
  109. LPARAM lprog;
  110. if ( ulStatusCode == BINDSTATUS_ENDDOWNLOADDATA )
  111. lprog = 100;
  112. else
  113. lprog = (ulProgressMax != 0)? (ulProgress * 100) / ulProgressMax : 0;
  114. PostMessage(_hdlg, WM_COMMAND, DOWNLOAD_PROGRESS, lprog );
  115. }
  116. return S_OK;
  117. }
  118. STDMETHODIMP CodeDownloadBSC::GetBindInfo(DWORD *pgrfBINDF, BINDINFO *pbindInfo)
  119. {
  120. // *pgrfBINDF |= BINDF_SILENTOPERATION;
  121. return S_OK;
  122. }
  123. STDMETHODIMP CodeDownloadBSC::OnDataAvailable(DWORD grfBSCF, DWORD dwSize,
  124. FORMATETC *pformatetc,
  125. STGMEDIUM *pstgmed)
  126. {
  127. return S_OK;
  128. }
  129. STDMETHODIMP CodeDownloadBSC::GetWindow( REFGUID rguidReason, HWND __RPC_FAR *phwnd )
  130. {
  131. *phwnd = _hwnd;
  132. return S_OK;
  133. }