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.

121 lines
3.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 2000
  6. //
  7. // File: audownload.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #pragma once
  11. #include "aucatitem.h"
  12. #include "aucatalog.h"
  13. #include <bits.h>
  14. #include <initguid.h>
  15. class Catalog;
  16. #define NO_BG_JOBSTATE -1
  17. #define CATMSG_DOWNLOAD_COMPLETE 1
  18. #define CATMSG_TRANSIENT_ERROR 2 //This comes from drizzle, for example if internet connection is lost
  19. #define CATMSG_DOWNLOAD_IN_PROGRESS 3
  20. #define CATMSG_DOWNLOAD_CANCELED 4
  21. #define CATMSG_DOWNLOAD_ERROR 5
  22. #define DRIZZLE_NOTIFY_FLAGS BG_NOTIFY_JOB_TRANSFERRED | BG_NOTIFY_JOB_ERROR | BG_NOTIFY_JOB_MODIFICATION
  23. typedef void (*DWNLDCALLBACK)(DWORD dwCallbackMsg, IBackgroundCopyJob *pBGJob, IBackgroundCopyError *pBGErr = NULL);
  24. typedef enum tagDRIZZLEOPS {
  25. DRIZZLEOPS_CANCEL = 1,
  26. DRIZZLEOPS_PAUSE ,
  27. DRIZZLEOPS_RESUME
  28. } DRIZZLEOPS;
  29. typedef enum tagJOBFINISHREASON {
  30. JOB_UNSPECIFIED_REASON = -1,
  31. JOB_ERROR = 0
  32. } JOBFINISHREASON;
  33. ///////////////////////////////////////////////////////////////////////////
  34. // Wrapper class for drizzle download operation
  35. // also implements drizzle notification callbacks
  36. //////////////////////////////////////////////////////////////////////////
  37. class CAUDownloader : public IBackgroundCopyCallback
  38. {
  39. public:
  40. // IUnknown methods
  41. HRESULT STDMETHODCALLTYPE QueryInterface(
  42. /* [in] */ REFIID riid,
  43. /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
  44. ULONG STDMETHODCALLTYPE AddRef( void);
  45. ULONG STDMETHODCALLTYPE Release( void);
  46. // IBackgroundCopyCallback methods
  47. HRESULT STDMETHODCALLTYPE JobTransferred(
  48. /* [in] */ IBackgroundCopyJob *pJob);
  49. HRESULT STDMETHODCALLTYPE JobError(
  50. /* [in] */ IBackgroundCopyJob *pJob,
  51. /* [in] */ IBackgroundCopyError *pError);
  52. HRESULT STDMETHODCALLTYPE JobModification(
  53. /* [in] */ IBackgroundCopyJob*,
  54. /* [in] */ DWORD );
  55. CAUDownloader(DWNLDCALLBACK pfnCallback):
  56. m_DownloadId(GUID_NULL),
  57. m_dwJobState(NO_BG_JOBSTATE),
  58. m_DoDownloadStatus(pfnCallback),
  59. m_refs(0),
  60. m_FinishReason(JOB_UNSPECIFIED_REASON)
  61. {};
  62. ~CAUDownloader();
  63. HRESULT ContinueLastDownloadJob();
  64. //the following two could be combined into DownloadFiles() in V4
  65. HRESULT QueueDownloadFile(LPCTSTR pszServerUrl, // full http url
  66. LPCTSTR pszLocalFile // local file name
  67. );
  68. HRESULT StartDownload();
  69. HRESULT DrizzleOperation(DRIZZLEOPS);
  70. HRESULT getStatus(DWORD *percent, DWORD *pdwstatus);
  71. GUID getID()
  72. {
  73. return m_DownloadId;
  74. }
  75. void setID(const GUID & guid )
  76. {
  77. m_DownloadId = guid;
  78. }
  79. void Reset();
  80. JOBFINISHREASON m_FinishReason;
  81. private:
  82. HRESULT SetDrizzleNotifyInterface();
  83. HRESULT InitDownloadJob(const GUID & guidDownloadId);
  84. HRESULT ReconnectDownloadJob();
  85. HRESULT CreateDownloadJob(IBackgroundCopyJob ** ppjob);
  86. HRESULT FindDownloadJob(IBackgroundCopyJob ** ppjob);
  87. long m_refs;
  88. GUID m_DownloadId; // id what m_pjob points to.
  89. DWORD m_dwJobState; //Job State from drizzle, used in JobModification callback
  90. DWNLDCALLBACK m_DoDownloadStatus; //callback function to notify user of download state change
  91. // Friend functions (callbacks)
  92. friend void QueryFilesExistCallback(void*, long, LPCTSTR, LPCTSTR);
  93. };
  94. void DoDownloadStatus(DWORD dwDownloadMsg, IBackgroundCopyJob *pBGJob, IBackgroundCopyError *pBGErr);