1
0

DownloadStatus.h 988 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef NULLSOFT_DOWNLOADSTATUSH
  2. #define NULLSOFT_DOWNLOADSTATUSH
  3. #include "../nu/AutoLock.h"
  4. #include <map>
  5. class DownloadStatus
  6. {
  7. public:
  8. class Status
  9. {
  10. public:
  11. Status();
  12. ~Status();
  13. const Status &operator =(const Status &copy);
  14. Status(size_t _downloaded, size_t _maxSize, const wchar_t *channel, const wchar_t *item, const wchar_t *path);
  15. size_t downloaded, maxSize;
  16. int killswitch;
  17. wchar_t *channel;
  18. wchar_t *item;
  19. wchar_t *path;
  20. private:
  21. void Init();
  22. void Reset();
  23. };
  24. void AddDownloadThread(DownloadToken token, const wchar_t *channel, const wchar_t *item, const wchar_t *path);
  25. void DownloadThreadDone(DownloadToken token);
  26. bool UpdateStatus(DownloadToken token, size_t downloaded, size_t maxSize);
  27. bool CurrentlyDownloading();
  28. void GetStatusString(wchar_t *status, size_t len);
  29. typedef std::map<DownloadToken, Status> Downloads;
  30. Downloads downloads;
  31. Nullsoft::Utility::LockGuard statusLock;
  32. };
  33. extern DownloadStatus downloadStatus;
  34. #endif