file_download_mtproto.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "storage/file_download.h"
  9. #include "storage/download_manager_mtproto.h"
  10. class mtpFileLoader final
  11. : public FileLoader
  12. , private Storage::DownloadMtprotoTask {
  13. public:
  14. mtpFileLoader(
  15. not_null<Main::Session*> session,
  16. const StorageFileLocation &location,
  17. Data::FileOrigin origin,
  18. LocationType type,
  19. const QString &toFile,
  20. int64 loadSize,
  21. int64 fullSize,
  22. LoadToCacheSetting toCache,
  23. LoadFromCloudSetting fromCloud,
  24. bool autoLoading,
  25. uint8 cacheTag);
  26. mtpFileLoader(
  27. not_null<Main::Session*> session,
  28. const WebFileLocation &location,
  29. int64 loadSize,
  30. int64 fullSize,
  31. LoadFromCloudSetting fromCloud,
  32. bool autoLoading,
  33. uint8 cacheTag);
  34. mtpFileLoader(
  35. not_null<Main::Session*> session,
  36. const GeoPointLocation &location,
  37. int64 loadSize,
  38. int64 fullSize,
  39. LoadFromCloudSetting fromCloud,
  40. bool autoLoading,
  41. uint8 cacheTag);
  42. mtpFileLoader(
  43. not_null<Main::Session*> session,
  44. const AudioAlbumThumbLocation &location,
  45. int64 loadSize,
  46. int64 fullSize,
  47. LoadFromCloudSetting fromCloud,
  48. bool autoLoading,
  49. uint8 cacheTag);
  50. ~mtpFileLoader();
  51. Data::FileOrigin fileOrigin() const override;
  52. uint64 objId() const override;
  53. private:
  54. Storage::Cache::Key cacheKey() const override;
  55. std::optional<MediaKey> fileLocationKey() const override;
  56. void startLoading() override;
  57. void startLoadingWithPartial(const QByteArray &data) override;
  58. void cancelHook() override;
  59. bool readyToRequest() const override;
  60. int64 takeNextRequestOffset() override;
  61. bool feedPart(int64 offset, const QByteArray &bytes) override;
  62. void cancelOnFail() override;
  63. bool setWebFileSizeHook(int64 size) override;
  64. bool _lastComplete = false;
  65. int64 _nextRequestOffset = 0;
  66. };