2019-12-04 12:15:58 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "storage/file_download.h"
|
2019-12-05 08:32:33 +00:00
|
|
|
#include "storage/download_manager_mtproto.h"
|
2019-12-04 12:15:58 +00:00
|
|
|
|
|
|
|
class mtpFileLoader final
|
|
|
|
: public FileLoader
|
2019-12-05 08:32:33 +00:00
|
|
|
, private Storage::DownloadMtprotoTask {
|
2019-12-04 12:15:58 +00:00
|
|
|
public:
|
|
|
|
mtpFileLoader(
|
2020-06-08 15:17:33 +00:00
|
|
|
not_null<Main::Session*> session,
|
2019-12-04 12:15:58 +00:00
|
|
|
const StorageFileLocation &location,
|
|
|
|
Data::FileOrigin origin,
|
|
|
|
LocationType type,
|
|
|
|
const QString &toFile,
|
2020-08-26 13:28:56 +00:00
|
|
|
int loadSize,
|
|
|
|
int fullSize,
|
2019-12-04 12:15:58 +00:00
|
|
|
LoadToCacheSetting toCache,
|
|
|
|
LoadFromCloudSetting fromCloud,
|
|
|
|
bool autoLoading,
|
|
|
|
uint8 cacheTag);
|
|
|
|
mtpFileLoader(
|
2020-06-08 15:17:33 +00:00
|
|
|
not_null<Main::Session*> session,
|
2019-12-04 12:15:58 +00:00
|
|
|
const WebFileLocation &location,
|
2020-08-26 13:28:56 +00:00
|
|
|
int loadSize,
|
|
|
|
int fullSize,
|
2019-12-04 12:15:58 +00:00
|
|
|
LoadFromCloudSetting fromCloud,
|
|
|
|
bool autoLoading,
|
|
|
|
uint8 cacheTag);
|
|
|
|
mtpFileLoader(
|
2020-06-08 15:17:33 +00:00
|
|
|
not_null<Main::Session*> session,
|
2019-12-04 12:15:58 +00:00
|
|
|
const GeoPointLocation &location,
|
2020-08-26 13:28:56 +00:00
|
|
|
int loadSize,
|
|
|
|
int fullSize,
|
2019-12-04 12:15:58 +00:00
|
|
|
LoadFromCloudSetting fromCloud,
|
|
|
|
bool autoLoading,
|
|
|
|
uint8 cacheTag);
|
2020-04-15 14:06:34 +00:00
|
|
|
~mtpFileLoader();
|
2019-12-04 12:15:58 +00:00
|
|
|
|
|
|
|
Data::FileOrigin fileOrigin() const override;
|
|
|
|
uint64 objId() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Storage::Cache::Key cacheKey() const override;
|
|
|
|
std::optional<MediaKey> fileLocationKey() const override;
|
|
|
|
void startLoading() override;
|
2020-08-26 13:28:56 +00:00
|
|
|
void startLoadingWithPartial(const QByteArray &data) override;
|
2019-12-05 08:32:33 +00:00
|
|
|
void cancelHook() override;
|
2019-12-04 12:15:58 +00:00
|
|
|
|
|
|
|
bool readyToRequest() const override;
|
2019-12-05 08:32:33 +00:00
|
|
|
int takeNextRequestOffset() override;
|
|
|
|
bool feedPart(int offset, const QByteArray &bytes) override;
|
|
|
|
void cancelOnFail() override;
|
|
|
|
bool setWebFileSizeHook(int size) override;
|
2019-12-04 12:15:58 +00:00
|
|
|
|
|
|
|
bool _lastComplete = false;
|
|
|
|
int32 _nextRequestOffset = 0;
|
|
|
|
|
|
|
|
};
|