1
0

cacheDownloader.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef NULLSOFT_WINAMP_CACHE_DOWNLOADER_HEADER
  2. #define NULLSOFT_WINAMP_CACHE_DOWNLOADER_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. #include "../Components/wac_downloadManager/wac_downloadManager_api.h"
  8. class CacheCallback;
  9. class CacheRecord;
  10. class CacheDownloader : public ifc_downloadManagerCallback
  11. {
  12. public:
  13. typedef enum
  14. {
  15. stateReady = 0,
  16. stateInitializing = 1,
  17. stateConnecting = 2,
  18. stateReceiving = 3,
  19. stateCompleted = 4,
  20. stateAborting = 5,
  21. } States;
  22. protected:
  23. CacheDownloader(CacheRecord *record, BOOL fEnableCompression);
  24. ~CacheDownloader();
  25. public:
  26. static HRESULT CreateInstance(CacheRecord *record, LPCWSTR pszAddress, BOOL fEnableCompression, CacheDownloader **instance);
  27. public:
  28. /* Dispatchable */
  29. size_t AddRef();
  30. size_t Release();
  31. int QueryInterface(GUID interface_guid, void **object);
  32. HRESULT Abort();
  33. UINT GetState();
  34. HRESULT SetOwner(CacheRecord *record);
  35. protected:
  36. HRESULT Start(LPCWSTR pszAddress);
  37. HRESULT DownloadCompleted(INT errorCode);
  38. /* ifc_downloadManagerCallback */
  39. void OnFinish(DownloadToken token);
  40. void OnTick(DownloadToken token);
  41. void OnError(DownloadToken token, int errorCode);
  42. void OnCancel(DownloadToken token);
  43. void OnConnect(DownloadToken token);
  44. void OnInit(DownloadToken token);
  45. protected:
  46. RECVS_DISPATCH;
  47. protected:
  48. ULONG ref;
  49. api_downloadManager *manager;
  50. DownloadToken cookie;
  51. CacheRecord *owner; // owner not ref counted
  52. UINT state;
  53. BOOL enableCompression;
  54. CRITICAL_SECTION lock;
  55. };
  56. #endif //NULLSOFT_WINAMP_CACHE_DOWNLOADER_HEADER