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.

136 lines
3.9 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 <windows.h>
  12. //#include "aucatitem.h"
  13. //#include "aucatalog.h"
  14. //#include "catalog.h"
  15. #include <initguid.h>
  16. #include <bits.h>
  17. #include <cguid.h>
  18. #include <testiu.h>
  19. //class Catalog;
  20. #define NO_BG_JOBSTATE -1
  21. #define CATMSG_DOWNLOAD_COMPLETE 1
  22. #define CATMSG_TRANSIENT_ERROR 2 //This comes from drizzle, for example if internet connection is lost
  23. #define CATMSG_DOWNLOAD_IN_PROGRESS 3
  24. #define CATMSG_DOWNLOAD_CANCELED 4
  25. #define CATMSG_DOWNLOAD_ERROR 5
  26. #define DRIZZLE_NOTIFY_FLAGS BG_NOTIFY_JOB_TRANSFERRED | BG_NOTIFY_JOB_ERROR | BG_NOTIFY_JOB_MODIFICATION
  27. /*
  28. typedef struct tagPingDownloadStatusData {
  29. static const UINT DOWNLOAD_ERR_DESC_SIZE = 50;
  30. BOOL m_fDownloadOk;
  31. union {
  32. struct {
  33. UINT m_uPuidNum;
  34. PUID* m_pPuids;
  35. };
  36. struct {
  37. PUID m_errPuid;
  38. TCHAR m_tszErrDesc[DOWNLOAD_ERR_DESC_SIZE];
  39. };
  40. };
  41. BOOL Init(BOOL fDownloadOk, Catalog *pCat, IBackgroundCopyError *pBGErr=NULL);
  42. } PingDownloadStatusData;
  43. typedef struct tagQueryFilesForPuidCallbackData{
  44. BOOL fFound;
  45. LPCTSTR ptszRemoteFile;
  46. } QueryFilesForPuidCallbackData;
  47. typedef void (*DWNLDCALLBACK)(DWORD dwCallbackMsg, PingDownloadStatusData * ptDownloadStatusData = NULL);
  48. */
  49. typedef void (*DWNLDCALLBACK)(DWORD dwCallbackMsg, PVOID ptDownloadStatusData = NULL);
  50. typedef enum tagDRIZZLEOPS {
  51. DRIZZLEOPS_CANCEL = 1,
  52. DRIZZLEOPS_PAUSE ,
  53. DRIZZLEOPS_RESUME
  54. } DRIZZLEOPS;
  55. ///////////////////////////////////////////////////////////////////////////
  56. // Wrapper class for drizzle download operation
  57. // also implements drizzle notification callbacks
  58. //////////////////////////////////////////////////////////////////////////
  59. class CAUDownloader : public IBackgroundCopyCallback
  60. {
  61. public:
  62. // IUnknown methods
  63. HRESULT STDMETHODCALLTYPE QueryInterface(
  64. /* [in] */ REFIID riid,
  65. /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
  66. ULONG STDMETHODCALLTYPE AddRef( void);
  67. ULONG STDMETHODCALLTYPE Release( void);
  68. // IBackgroundCopyCallback methods
  69. HRESULT STDMETHODCALLTYPE JobTransferred(
  70. /* [in] */ IBackgroundCopyJob *pJob);
  71. HRESULT STDMETHODCALLTYPE JobError(
  72. /* [in] */ IBackgroundCopyJob *pJob,
  73. /* [in] */ IBackgroundCopyError *pError);
  74. HRESULT STDMETHODCALLTYPE JobModification(
  75. /* [in] */ IBackgroundCopyJob*,
  76. /* [in] */ DWORD );
  77. CAUDownloader(DWNLDCALLBACK pfnCallback):
  78. m_DownloadId(GUID_NULL),
  79. m_dwJobState(NO_BG_JOBSTATE),
  80. m_DoDownloadStatus(pfnCallback),
  81. m_refs(0)
  82. {};
  83. ~CAUDownloader();
  84. HRESULT ContinueLastDownloadJob(const GUID & guidDownloadId);
  85. //the following two could be combined into DownloadFiles() in V4
  86. HRESULT QueueDownloadFile(LPCTSTR pszServerUrl, // full http url
  87. LPCTSTR pszLocalFile // local file name
  88. );
  89. HRESULT StartDownload();
  90. HRESULT DrizzleOperation(DRIZZLEOPS);
  91. HRESULT getStatus(DWORD *percent, DWORD *pdwstatus);
  92. GUID getID()
  93. {
  94. return m_DownloadId;
  95. }
  96. private:
  97. HRESULT SetDrizzleNotifyInterface();
  98. HRESULT InitDownloadJob(const GUID & guidDownloadId);
  99. HRESULT ReconnectDownloadJob();
  100. HRESULT CreateDownloadJob(IBackgroundCopyJob ** ppjob);
  101. HRESULT FindDownloadJob(IBackgroundCopyJob ** ppjob);
  102. void Reset();
  103. long m_refs;
  104. GUID m_DownloadId; // id what m_pjob points to.
  105. DWORD m_dwJobState; //Job State from drizzle, used in JobModification callback
  106. DWNLDCALLBACK m_DoDownloadStatus; //callback function to notify user of download state change
  107. // Friend functions (callbacks)
  108. // friend void QueryFilesExistCallback(void*, long, LPCTSTR, LPCTSTR);
  109. };