1
0

storageDwnld.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef NULLSOFT_WINAMP_OMSTORAGE_DOWNLOADER_HEADER
  2. #define NULLSOFT_WINAMP_OMSTORAGE_DOWNLOADER_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include "./ifc_omstorageasync.h"
  7. #include "../Components/wac_downloadManager/wac_downloadManager_api.h"
  8. #include <bfc/multipatch.h>
  9. class ifc_omservicehost;
  10. #define MPIID_OMSTORAGEASYNC 10
  11. #define MPIID_DOWNLOADCALLBACK 20
  12. class OmStorageDwnld : public MultiPatch<MPIID_OMSTORAGEASYNC, ifc_omstorageasync>,
  13. public MultiPatch<MPIID_DOWNLOADCALLBACK, ifc_downloadManagerCallback>
  14. {
  15. public:
  16. typedef enum
  17. {
  18. flagEnableCompression = 0x00000001,
  19. flagUserAbort = 0x00010000,
  20. flagCompletedSynchronously = 0x00020000,
  21. } Flags;
  22. protected:
  23. OmStorageDwnld(api_downloadManager *downloadManager, BOOL enableCompression);
  24. ~OmStorageDwnld();
  25. public:
  26. static HRESULT CreateInstance(api_downloadManager *downloadManager, BOOL enableCompression, OmStorageDwnld **instance);
  27. public:
  28. /* Dispatchable */
  29. size_t AddRef();
  30. size_t Release();
  31. int QueryInterface(GUID interface_guid, void **object);
  32. /* ifc_omstorageasync */
  33. HRESULT GetState(UINT *state);
  34. HRESULT GetWaitHandle(HANDLE *handle);
  35. HRESULT GetData(void **data);
  36. /* ifc_downloadManagerCallback */
  37. void OnFinish(DownloadToken token);
  38. void OnTick(DownloadToken token);
  39. void OnError(DownloadToken token, int errorCode);
  40. void OnCancel(DownloadToken token);
  41. void OnConnect(DownloadToken token);
  42. void OnInit(DownloadToken token);
  43. HRESULT GetResultCode();
  44. HRESULT GetBuffer(void **buffer, size_t *bufferSize);
  45. HRESULT SetData(void *data);
  46. HRESULT SetCallback(AsyncCallback callback);
  47. HRESULT GetCallback(AsyncCallback *callback);
  48. HRESULT RequestAbort(BOOL fDrop);
  49. HRESULT SetServiceHost(ifc_omservicehost *host);
  50. HRESULT GetServiceHost(ifc_omservicehost **host);
  51. protected:
  52. void DownloadCompleted(INT errorCode);
  53. size_t ref;
  54. AsyncCallback userCallback;
  55. void *userData;
  56. HANDLE completed;
  57. UINT flags;
  58. UINT opState;
  59. INT resultCode;
  60. CRITICAL_SECTION lock;
  61. DownloadToken cookie;
  62. api_downloadManager *manager;
  63. ifc_omservicehost *serviceHost;
  64. RECVS_MULTIPATCH;
  65. };
  66. #endif //NULLSOFT_WINAMP_OMSTORAGE_DOWNLOADER_HEADER