Source code of Windows XP (NT5)
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.

87 lines
3.6 KiB

  1. #ifndef DOWNLOAD_H
  2. #define DOWNLOAD_H
  3. #include <iuprogress.h>
  4. #define DOWNLOAD_STATUS_OK 0
  5. #define DOWNLOAD_STATUS_ITEMCOMPLETE 1
  6. #define DOWNLOAD_STATUS_ERROR 2
  7. #define DOWNLOAD_STATUS_ABORTED 3
  8. #define DOWNLOAD_STATUS_OPERATIONCOMPLETE 4
  9. #define DOWNLOAD_STATUS_ITEMSTART 5
  10. //---------------------------------------------------------------------------
  11. //
  12. // type definition for the parameters needed by callback function
  13. //
  14. class COperationMgr;
  15. typedef struct _DOWNLOAD_CALLBACK_DATA
  16. {
  17. BSTR bstrOperationUuid;
  18. HWND hEventFiringWnd;
  19. IProgressListener* pProgressListener;
  20. float flProgressPercentage; // Minimum Percentage Increment for Progress 0 == all progress
  21. float flLastPercentage; // percentage value of the last progress callback
  22. LONG lTotalDownloadSize; // estimated total download size
  23. LONG lCurrentItemSize; // estimated current item size
  24. LONG lTotalDownloaded; // total bytes downloaded so far
  25. COperationMgr* pOperationMgr;
  26. } DCB_DATA, *P_DCB_DATA;
  27. //---------------------------------------------------------------------------
  28. //
  29. // type definition for the callback function
  30. //
  31. typedef BOOL (WINAPI * PFNDownloadCallback)(
  32. VOID* pCallbackData,
  33. DWORD dwStatus,
  34. DWORD dwBytesTotal,
  35. DWORD dwBlockSizeDownloaded, // Bytes Downloaded Since Last Callback.
  36. BSTR bstrXmlData, // XML in bstr, used by itemstart/complete, otherwise NULL
  37. LONG *lCommandRequest // return what callback function want to do:
  38. // PAUSE (1) or CANCEL (3)
  39. );
  40. //---------------------------------------------------------------------------
  41. //
  42. // DownloadFile
  43. // Implements the core downloader for IU. This is a single purpose downloader that is very generic,
  44. // It does not attempt to decompress or checktrust anything it downloads.
  45. //
  46. // Progress Information is given for each block downloaded through the supplied callback function.
  47. // Specifying a callback is optional. All callbacks are 'synchronous' and if not immediately
  48. // returned will block all downloads in this object.
  49. #define WUDF_DONTALLOWPROXY 0x00000001
  50. #define WUDF_CHECKREQSTATUSONLY 0x00000002
  51. #define WUDF_APPENDCACHEBREAKER 0x00000004
  52. #define WUDF_DODOWNLOADRETRY 0x00000008
  53. #define WUDF_SKIPCABVALIDATION 0x00000010
  54. #define WUDF_SKIPAUTOPROXYCACHE 0x00000020
  55. #define WUDF_PERSISTTRANSPORTDLL 0x00000040
  56. #define WUDF_ALLOWWININETONLY 0x40000000
  57. #define WUDF_ALLOWWINHTTPONLY 0x80000000
  58. #define WUDF_TRANSPORTMASK (WUDF_ALLOWWINHTTPONLY | WUDF_ALLOWWININETONLY)
  59. HRESULT DownloadFile(
  60. LPCTSTR pszServerUrl, // full http url
  61. LPCTSTR pszLocalPath, // local directory to download file to
  62. LPCTSTR pszLocalFileName, // optional local file name to rename the downloaded file to
  63. PDWORD pdwDownloadedBytes, // bytes downloaded for this file
  64. HANDLE *hQuitEvents, // optional events causing this function to abort
  65. UINT nQuitEventCount, // number of quit events, must be 0 if array is NULL
  66. PFNDownloadCallback fpnCallback, // optional call back function
  67. VOID* pCallbackData, // parameter for call back function to use
  68. DWORD dwFlags = 0
  69. );
  70. #include "dllite.h"
  71. #endif