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.

112 lines
3.0 KiB

  1. #include <wininet.h>
  2. #include <urlmon.h>
  3. #ifndef _DOWNLOAD
  4. #define _DOWNLOAD
  5. class CDownloader
  6. : public IBindStatusCallback,
  7. public IAuthenticate,
  8. public IHttpNegotiate
  9. {
  10. public:
  11. CDownloader();
  12. ~CDownloader();
  13. HRESULT DoDownload(LPCSTR pszUrl, LPCSTR szFilename);
  14. HRESULT Abort();
  15. STDMETHOD(QueryInterface)(REFIID riid, void **ppvObjOut);
  16. STDMETHOD_(ULONG, AddRef)();
  17. STDMETHOD_(ULONG, Release)();
  18. STDMETHOD(OnStartBinding)(
  19. /* [in] */ DWORD grfBSCOption,
  20. /* [in] */ IBinding *pib);
  21. STDMETHOD(GetPriority)(
  22. /* [out] */ LONG *pnPriority);
  23. STDMETHOD(OnLowResource)(
  24. /* [in] */ DWORD reserved);
  25. STDMETHOD(OnProgress)(
  26. /* [in] */ ULONG ulProgress,
  27. /* [in] */ ULONG ulProgressMax,
  28. /* [in] */ ULONG ulStatusCode,
  29. /* [in] */ LPCWSTR szStatusText);
  30. STDMETHOD(OnStopBinding)(
  31. /* [in] */ HRESULT hresult,
  32. /* [in] */ LPCWSTR szError);
  33. STDMETHOD(GetBindInfo)(
  34. /* [out] */ DWORD *grfBINDINFOF,
  35. /* [unique][out][in] */ BINDINFO *pbindinfo);
  36. STDMETHOD(OnDataAvailable)(
  37. /* [in] */ DWORD grfBSCF,
  38. /* [in] */ DWORD dwSize,
  39. /* [in] */ FORMATETC *pformatetc,
  40. /* [in] */ STGMEDIUM *pstgmed);
  41. STDMETHOD(OnObjectAvailable)(
  42. /* [in] */ REFIID riid,
  43. /* [iid_is][in] */ IUnknown *punk);
  44. // IAuthenticate methods
  45. STDMETHOD(Authenticate)(HWND *phwnd,
  46. LPWSTR *pszUserName, LPWSTR *pszPassword);
  47. //IHttpNegotiate methods
  48. STDMETHODIMP BeginningTransaction(LPCWSTR szURL, LPCWSTR szHeaders, DWORD dwReserved,
  49. LPWSTR * pszAdditionalHeaders);
  50. STDMETHODIMP OnResponse(DWORD dwResponseCode, LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders,
  51. LPWSTR * pszAdditionalResquestHeaders);
  52. protected:
  53. IBinding *_pBnd;
  54. DWORD _cRef;
  55. IStream *_pStm;
  56. BOOL _fTimeout;
  57. BOOL _fTimeoutValid;
  58. HANDLE _hFile;
  59. HANDLE _hDL;
  60. HRESULT _hDLResult;
  61. UINT _uTickCount;
  62. };
  63. HRESULT GetAMoniker( LPOLESTR url, IMoniker ** ppmkr );
  64. typedef struct _SITEINFO SITEINFO;
  65. struct _SITEINFO
  66. {
  67. LPTSTR lpszUrl;
  68. LPTSTR lpszSiteName;
  69. SITEINFO* pNextSite;
  70. };
  71. class CSiteMgr
  72. {
  73. SITEINFO* m_pSites;
  74. SITEINFO* m_pCurrentSite;
  75. char m_szLang[10];
  76. HRESULT ParseSitesFile(LPTSTR);
  77. BOOL ParseAndAllocateDownloadSite(LPTSTR);
  78. public:
  79. CSiteMgr();
  80. ~CSiteMgr();
  81. BOOL GetNextSite(LPTSTR* lpszUrl, LPTSTR* lpszName);
  82. HRESULT Initialize(LPCTSTR);
  83. };
  84. #endif