2017-09-26 11:49:16 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-09-26 11:49:16 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-04-30 12:53:44 +00:00
|
|
|
#include "base/flags.h"
|
2019-09-13 06:06:02 +00:00
|
|
|
#include "base/binary_guard.h"
|
2017-09-26 11:49:16 +00:00
|
|
|
#include "data/data_types.h"
|
2020-05-26 11:59:45 +00:00
|
|
|
#include "data/data_cloud_file.h"
|
2019-01-25 14:37:28 +00:00
|
|
|
#include "ui/image/image.h"
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
class mtpFileLoader;
|
|
|
|
|
2018-10-25 09:24:45 +00:00
|
|
|
namespace Images {
|
|
|
|
class Source;
|
|
|
|
} // namespace Images
|
|
|
|
|
2018-08-27 11:35:58 +00:00
|
|
|
namespace Storage {
|
|
|
|
namespace Cache {
|
|
|
|
struct Key;
|
|
|
|
} // namespace Cache
|
|
|
|
} // namespace Storage
|
|
|
|
|
2019-02-13 18:10:18 +00:00
|
|
|
namespace Media {
|
|
|
|
namespace Streaming {
|
|
|
|
class Loader;
|
|
|
|
} // namespace Streaming
|
|
|
|
} // namespace Media
|
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
namespace Data {
|
|
|
|
class Session;
|
2020-03-27 11:40:50 +00:00
|
|
|
class DocumentMedia;
|
2020-04-08 15:09:29 +00:00
|
|
|
class ReplyPreview;
|
2019-01-25 14:37:28 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
2018-01-27 09:21:57 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
inline uint64 mediaMix32To64(int32 a, int32 b) {
|
|
|
|
return (uint64(*reinterpret_cast<uint32*>(&a)) << 32)
|
|
|
|
| uint64(*reinterpret_cast<uint32*>(&b));
|
|
|
|
}
|
|
|
|
|
2018-07-13 21:25:47 +00:00
|
|
|
// version field removed from document.
|
|
|
|
inline MediaKey mediaKey(LocationType type, int32 dc, const uint64 &id) {
|
|
|
|
return MediaKey(mediaMix32To64(type, dc), id);
|
2017-09-26 11:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct DocumentAdditionalData {
|
|
|
|
virtual ~DocumentAdditionalData() = default;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StickerData : public DocumentAdditionalData {
|
2018-07-13 21:25:47 +00:00
|
|
|
Data::FileOrigin setOrigin() const;
|
|
|
|
|
2019-05-27 12:57:26 +00:00
|
|
|
bool animated = false;
|
2017-09-26 11:49:16 +00:00
|
|
|
QString alt;
|
|
|
|
MTPInputStickerSet set = MTP_inputStickerSetEmpty();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SongData : public DocumentAdditionalData {
|
|
|
|
int32 duration = 0;
|
|
|
|
QString title, performer;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VoiceData : public DocumentAdditionalData {
|
|
|
|
~VoiceData();
|
|
|
|
|
|
|
|
int duration = 0;
|
|
|
|
VoiceWaveform waveform;
|
|
|
|
char wavemax = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool fileIsImage(const QString &name, const QString &mime);
|
|
|
|
|
|
|
|
namespace Serialize {
|
|
|
|
class Document;
|
|
|
|
} // namespace Serialize;
|
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
class DocumentData final {
|
2017-09-26 11:49:16 +00:00
|
|
|
public:
|
2019-01-25 14:37:28 +00:00
|
|
|
DocumentData(not_null<Data::Session*> owner, DocumentId id);
|
2020-04-08 15:09:29 +00:00
|
|
|
~DocumentData();
|
2018-01-27 09:21:57 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] Data::Session &owner() const;
|
2019-07-24 11:45:24 +00:00
|
|
|
[[nodiscard]] Main::Session &session() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
void setattributes(
|
|
|
|
const QVector<MTPDocumentAttribute> &attributes);
|
|
|
|
|
|
|
|
void automaticLoadSettingsChanged();
|
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool loading() const;
|
|
|
|
[[nodiscard]] QString loadingFilePath() const;
|
|
|
|
[[nodiscard]] bool displayLoading() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
void save(
|
2018-07-13 21:25:47 +00:00
|
|
|
Data::FileOrigin origin,
|
2017-09-26 11:49:16 +00:00
|
|
|
const QString &toFile,
|
|
|
|
LoadFromCloudSetting fromCloud = LoadFromCloudOrLocal,
|
|
|
|
bool autoLoading = false);
|
|
|
|
void cancel();
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool cancelled() const;
|
|
|
|
[[nodiscard]] float64 progress() const;
|
2019-04-10 11:26:15 +00:00
|
|
|
[[nodiscard]] int loadOffset() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool uploading() const;
|
2019-05-31 16:45:03 +00:00
|
|
|
[[nodiscard]] bool loadedInMediaCache() const;
|
|
|
|
void setLoadedInMediaCache(bool loaded);
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2017-12-25 14:17:00 +00:00
|
|
|
void setWaitingForAlbum();
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool waitingForAlbum() const;
|
2017-12-25 14:17:00 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] const FileLocation &location(bool check = false) const;
|
2017-09-26 11:49:16 +00:00
|
|
|
void setLocation(const FileLocation &loc);
|
|
|
|
|
2020-04-09 13:02:01 +00:00
|
|
|
bool saveFromData();
|
|
|
|
bool saveFromDataSilent();
|
2020-04-09 14:02:09 +00:00
|
|
|
[[nodiscard]] QString filepath(bool check = false) const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-01-16 12:25:29 +00:00
|
|
|
[[nodiscard]] bool saveToCache() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] Image *getReplyPreview(Data::FileOrigin origin);
|
|
|
|
|
|
|
|
[[nodiscard]] StickerData *sticker() const;
|
|
|
|
[[nodiscard]] Data::FileOrigin stickerSetOrigin() const;
|
|
|
|
[[nodiscard]] Data::FileOrigin stickerOrGifOrigin() const;
|
|
|
|
[[nodiscard]] bool isStickerSetInstalled() const;
|
|
|
|
[[nodiscard]] SongData *song();
|
|
|
|
[[nodiscard]] const SongData *song() const;
|
|
|
|
[[nodiscard]] VoiceData *voice();
|
|
|
|
[[nodiscard]] const VoiceData *voice() const;
|
|
|
|
|
|
|
|
[[nodiscard]] bool isVoiceMessage() const;
|
|
|
|
[[nodiscard]] bool isVideoMessage() const;
|
|
|
|
[[nodiscard]] bool isSong() const;
|
|
|
|
[[nodiscard]] bool isAudioFile() const;
|
|
|
|
[[nodiscard]] bool isVideoFile() const;
|
|
|
|
[[nodiscard]] bool isAnimation() const;
|
|
|
|
[[nodiscard]] bool isGifv() const;
|
|
|
|
[[nodiscard]] bool isTheme() const;
|
|
|
|
[[nodiscard]] bool isSharedMediaMusic() const;
|
2019-03-06 08:21:42 +00:00
|
|
|
[[nodiscard]] TimeId getDuration() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool isImage() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
void recountIsImage();
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool supportsStreaming() const;
|
2019-03-05 13:56:27 +00:00
|
|
|
void setNotSupportsStreaming();
|
2019-09-06 11:33:51 +00:00
|
|
|
void setDataAndCache(const QByteArray &data);
|
2019-01-16 12:25:29 +00:00
|
|
|
bool checkWallPaperProperties();
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool isWallPaper() const;
|
2019-01-29 16:26:19 +00:00
|
|
|
[[nodiscard]] bool isPatternWallPaper() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
|
|
|
|
[[nodiscard]] bool hasThumbnail() const;
|
2020-04-15 14:06:34 +00:00
|
|
|
[[nodiscard]] bool thumbnailLoading() const;
|
|
|
|
[[nodiscard]] bool thumbnailFailed() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
void loadThumbnail(Data::FileOrigin origin);
|
2020-05-25 14:16:04 +00:00
|
|
|
[[nodiscard]] const ImageLocation &thumbnailLocation() const;
|
|
|
|
[[nodiscard]] int thumbnailByteSize() const;
|
2020-05-22 11:15:09 +00:00
|
|
|
|
|
|
|
[[nodiscard]] bool hasVideoThumbnail() const;
|
|
|
|
[[nodiscard]] bool videoThumbnailLoading() const;
|
|
|
|
[[nodiscard]] bool videoThumbnailFailed() const;
|
|
|
|
void loadVideoThumbnail(Data::FileOrigin origin);
|
2020-07-03 08:42:09 +00:00
|
|
|
[[nodiscard]] const ImageLocation &videoThumbnailLocation() const;
|
|
|
|
[[nodiscard]] int videoThumbnailByteSize() const;
|
2020-05-22 11:15:09 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
void updateThumbnails(
|
2020-04-08 15:09:29 +00:00
|
|
|
const QByteArray &inlineThumbnailBytes,
|
2020-05-22 11:15:09 +00:00
|
|
|
const ImageWithLocation &thumbnail,
|
|
|
|
const ImageWithLocation &videoThumbnail);
|
2019-01-25 14:37:28 +00:00
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
[[nodiscard]] QByteArray inlineThumbnailBytes() const {
|
|
|
|
return _inlineThumbnailBytes;
|
|
|
|
}
|
2020-05-30 18:37:03 +00:00
|
|
|
void clearInlineThumbnailBytes() {
|
|
|
|
_inlineThumbnailBytes = QByteArray();
|
|
|
|
}
|
2020-04-08 15:09:29 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] Storage::Cache::Key goodThumbnailCacheKey() const;
|
2020-03-27 11:40:50 +00:00
|
|
|
[[nodiscard]] bool goodThumbnailChecked() const;
|
|
|
|
[[nodiscard]] bool goodThumbnailGenerating() const;
|
|
|
|
[[nodiscard]] bool goodThumbnailNoData() const;
|
|
|
|
void setGoodThumbnailGenerating();
|
|
|
|
void setGoodThumbnailDataReady();
|
|
|
|
void setGoodThumbnailChecked(bool hasData);
|
|
|
|
|
|
|
|
[[nodiscard]] std::shared_ptr<Data::DocumentMedia> createMediaView();
|
2020-04-09 08:15:47 +00:00
|
|
|
[[nodiscard]] auto activeMediaView() const
|
|
|
|
-> std::shared_ptr<Data::DocumentMedia>;
|
2020-03-27 11:40:50 +00:00
|
|
|
void setGoodThumbnailPhoto(not_null<PhotoData*> photo);
|
|
|
|
[[nodiscard]] PhotoData *goodThumbnailPhoto() const;
|
2018-10-25 08:12:56 +00:00
|
|
|
|
2020-05-20 12:28:18 +00:00
|
|
|
[[nodiscard]] Storage::Cache::Key bigFileBaseCacheKey() const;
|
2019-06-26 10:01:04 +00:00
|
|
|
|
2018-07-13 16:49:46 +00:00
|
|
|
void setRemoteLocation(
|
|
|
|
int32 dc,
|
|
|
|
uint64 access,
|
|
|
|
const QByteArray &fileReference);
|
2017-09-26 11:49:16 +00:00
|
|
|
void setContentUrl(const QString &url);
|
2018-03-04 20:04:13 +00:00
|
|
|
void setWebLocation(const WebFileLocation &location);
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool hasRemoteLocation() const;
|
|
|
|
[[nodiscard]] bool hasWebLocation() const;
|
|
|
|
[[nodiscard]] bool isNull() const;
|
|
|
|
[[nodiscard]] MTPInputDocument mtpInput() const;
|
|
|
|
[[nodiscard]] QByteArray fileReference() const;
|
2018-07-16 17:31:07 +00:00
|
|
|
void refreshFileReference(const QByteArray &value);
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
// When we have some client-side generated document
|
|
|
|
// (for example for displaying an external inline bot result)
|
|
|
|
// and it has downloaded data, we can collect that data from it
|
|
|
|
// to (this) received from the server "same" document.
|
2019-01-25 14:37:28 +00:00
|
|
|
void collectLocalData(not_null<DocumentData*> local);
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] QString filename() const;
|
|
|
|
[[nodiscard]] QString mimeString() const;
|
|
|
|
[[nodiscard]] bool hasMimeType(QLatin1String mime) const;
|
2018-01-27 09:21:57 +00:00
|
|
|
void setMimeString(const QString &mime);
|
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] MediaKey mediaKey() const;
|
|
|
|
[[nodiscard]] Storage::Cache::Key cacheKey() const;
|
|
|
|
[[nodiscard]] uint8 cacheTag() const;
|
2018-01-27 09:21:57 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] static QString ComposeNameString(
|
2018-01-27 09:21:57 +00:00
|
|
|
const QString &filename,
|
|
|
|
const QString &songTitle,
|
|
|
|
const QString &songPerformer);
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] QString composeNameString() const;
|
2017-11-05 11:00:48 +00:00
|
|
|
|
2019-02-27 11:36:19 +00:00
|
|
|
[[nodiscard]] bool canBeStreamed() const;
|
2019-04-12 09:25:00 +00:00
|
|
|
[[nodiscard]] auto createStreamingLoader(
|
|
|
|
Data::FileOrigin origin,
|
|
|
|
bool forceRemoteLoader) const
|
|
|
|
-> std::unique_ptr<Media::Streaming::Loader>;
|
2020-04-10 13:18:51 +00:00
|
|
|
[[nodiscard]] bool useStreamingLoader() const;
|
2019-02-13 18:10:18 +00:00
|
|
|
|
2019-03-04 11:28:52 +00:00
|
|
|
void setInappPlaybackFailed();
|
|
|
|
[[nodiscard]] bool inappPlaybackFailed() const;
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
DocumentId id = 0;
|
|
|
|
DocumentType type = FileDocument;
|
|
|
|
QSize dimensions;
|
|
|
|
int32 date = 0;
|
|
|
|
int32 size = 0;
|
|
|
|
|
|
|
|
FileStatus status = FileReady;
|
2017-12-25 14:17:00 +00:00
|
|
|
|
|
|
|
std::unique_ptr<Data::UploadState> uploadingData;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
private:
|
2019-04-30 12:53:44 +00:00
|
|
|
enum class Flag : uchar {
|
|
|
|
StreamingMaybeYes = 0x01,
|
|
|
|
StreamingMaybeNo = 0x02,
|
|
|
|
StreamingPlaybackFailed = 0x04,
|
|
|
|
ImageType = 0x08,
|
|
|
|
DownloadCancelled = 0x10,
|
|
|
|
LoadedInMediaCache = 0x20,
|
2019-03-05 13:56:27 +00:00
|
|
|
};
|
2019-04-30 12:53:44 +00:00
|
|
|
using Flags = base::flags<Flag>;
|
|
|
|
friend constexpr bool is_flag_type(Flag) { return true; };
|
|
|
|
|
2020-03-27 11:40:50 +00:00
|
|
|
enum class GoodThumbnailFlag : uchar {
|
|
|
|
Checked = 0x01,
|
|
|
|
Generating = 0x02,
|
|
|
|
NoData = 0x03,
|
|
|
|
Mask = 0x03,
|
|
|
|
|
|
|
|
DataReady = 0x04,
|
|
|
|
};
|
|
|
|
using GoodThumbnailState = base::flags<GoodThumbnailFlag>;
|
|
|
|
friend constexpr bool is_flag_type(GoodThumbnailFlag) { return true; };
|
|
|
|
|
2019-04-30 12:53:44 +00:00
|
|
|
static constexpr Flags kStreamingSupportedMask = Flags()
|
|
|
|
| Flag::StreamingMaybeYes
|
|
|
|
| Flag::StreamingMaybeNo;
|
|
|
|
static constexpr Flags kStreamingSupportedUnknown = Flags()
|
|
|
|
| Flag::StreamingMaybeYes
|
|
|
|
| Flag::StreamingMaybeNo;
|
|
|
|
static constexpr Flags kStreamingSupportedMaybeYes = Flags()
|
|
|
|
| Flag::StreamingMaybeYes;
|
|
|
|
static constexpr Flags kStreamingSupportedMaybeNo = Flags()
|
|
|
|
| Flag::StreamingMaybeNo;
|
|
|
|
static constexpr Flags kStreamingSupportedNo = Flags();
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
friend class Serialize::Document;
|
|
|
|
|
2020-03-27 11:40:50 +00:00
|
|
|
[[nodiscard]] LocationType locationType() const;
|
2019-05-10 08:38:23 +00:00
|
|
|
void validateLottieSticker();
|
2019-03-05 13:56:27 +00:00
|
|
|
void setMaybeSupportsStreaming(bool supports);
|
2019-05-31 16:45:03 +00:00
|
|
|
void setLoadedInMediaCacheLocation();
|
2018-01-27 09:21:57 +00:00
|
|
|
|
2020-04-10 11:17:10 +00:00
|
|
|
void finishLoad();
|
|
|
|
void handleLoaderUpdates();
|
2020-04-15 14:06:34 +00:00
|
|
|
void destroyLoader();
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2020-04-09 13:02:01 +00:00
|
|
|
bool saveFromDataChecked();
|
2019-01-25 14:37:28 +00:00
|
|
|
|
2020-04-15 14:06:34 +00:00
|
|
|
const not_null<Data::Session*> _owner;
|
|
|
|
|
2018-07-13 21:25:47 +00:00
|
|
|
// Two types of location: from MTProto by dc+access or from web by url
|
2017-09-26 11:49:16 +00:00
|
|
|
int32 _dc = 0;
|
|
|
|
uint64 _access = 0;
|
2018-07-13 16:49:46 +00:00
|
|
|
QByteArray _fileReference;
|
2017-09-26 11:49:16 +00:00
|
|
|
QString _url;
|
2017-11-05 11:00:48 +00:00
|
|
|
QString _filename;
|
|
|
|
QString _mimeString;
|
2018-03-04 20:04:13 +00:00
|
|
|
WebFileLocation _urlLocation;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
QByteArray _inlineThumbnailBytes;
|
2020-05-26 11:59:45 +00:00
|
|
|
Data::CloudFile _thumbnail;
|
|
|
|
Data::CloudFile _videoThumbnail;
|
2020-04-08 15:09:29 +00:00
|
|
|
std::unique_ptr<Data::ReplyPreview> _replyPreview;
|
2020-03-27 11:40:50 +00:00
|
|
|
std::weak_ptr<Data::DocumentMedia> _media;
|
|
|
|
PhotoData *_goodThumbnailPhoto = nullptr;
|
2018-10-25 08:12:56 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
FileLocation _location;
|
|
|
|
std::unique_ptr<DocumentAdditionalData> _additional;
|
|
|
|
int32 _duration = -1;
|
2019-04-30 12:53:44 +00:00
|
|
|
mutable Flags _flags = kStreamingSupportedUnknown;
|
2020-03-27 11:40:50 +00:00
|
|
|
GoodThumbnailState _goodThumbnailState = GoodThumbnailState();
|
2020-04-15 14:06:34 +00:00
|
|
|
std::unique_ptr<FileLoader> _loader;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
VoiceWaveform documentWaveformDecode(const QByteArray &encoded5bit);
|
|
|
|
QByteArray documentWaveformEncode5bit(const VoiceWaveform &waveform);
|
|
|
|
|
2017-12-18 13:13:41 +00:00
|
|
|
class DocumentClickHandler : public FileClickHandler {
|
2017-09-26 11:49:16 +00:00
|
|
|
public:
|
2017-12-15 16:25:47 +00:00
|
|
|
DocumentClickHandler(
|
|
|
|
not_null<DocumentData*> document,
|
2020-05-04 13:38:49 +00:00
|
|
|
FullMsgId context = FullMsgId());
|
|
|
|
|
|
|
|
[[nodiscard]] not_null<DocumentData*> document() const {
|
2017-09-26 11:49:16 +00:00
|
|
|
return _document;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-05-04 13:38:49 +00:00
|
|
|
const not_null<DocumentData*> _document;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class DocumentSaveClickHandler : public DocumentClickHandler {
|
|
|
|
public:
|
2019-03-11 14:35:11 +00:00
|
|
|
enum class Mode {
|
|
|
|
ToCacheOrFile,
|
|
|
|
ToFile,
|
|
|
|
ToNewFile,
|
|
|
|
};
|
2017-09-26 11:49:16 +00:00
|
|
|
using DocumentClickHandler::DocumentClickHandler;
|
2018-07-13 21:25:47 +00:00
|
|
|
static void Save(
|
|
|
|
Data::FileOrigin origin,
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<DocumentData*> document,
|
2019-03-11 14:35:11 +00:00
|
|
|
Mode mode = Mode::ToCacheOrFile);
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class DocumentOpenClickHandler : public DocumentClickHandler {
|
|
|
|
public:
|
|
|
|
using DocumentClickHandler::DocumentClickHandler;
|
2018-07-13 21:25:47 +00:00
|
|
|
static void Open(
|
|
|
|
Data::FileOrigin origin,
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<DocumentData*> document,
|
2019-03-11 14:35:11 +00:00
|
|
|
HistoryItem *context);
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class DocumentCancelClickHandler : public DocumentClickHandler {
|
|
|
|
public:
|
|
|
|
using DocumentClickHandler::DocumentClickHandler;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-03-13 09:35:47 +00:00
|
|
|
class DocumentOpenWithClickHandler : public DocumentClickHandler {
|
|
|
|
public:
|
|
|
|
using DocumentClickHandler::DocumentClickHandler;
|
|
|
|
static void Open(
|
|
|
|
Data::FileOrigin origin,
|
|
|
|
not_null<DocumentData*> document);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
class VoiceSeekClickHandler : public DocumentOpenClickHandler {
|
|
|
|
public:
|
|
|
|
using DocumentOpenClickHandler::DocumentOpenClickHandler;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override {
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-01-29 16:26:19 +00:00
|
|
|
class DocumentWrappedClickHandler : public DocumentClickHandler {
|
|
|
|
public:
|
|
|
|
DocumentWrappedClickHandler(
|
|
|
|
ClickHandlerPtr wrapped,
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
FullMsgId context = FullMsgId())
|
|
|
|
: DocumentClickHandler(document, context)
|
|
|
|
, _wrapped(wrapped) {
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override {
|
|
|
|
_wrapped->onClick({ Qt::LeftButton });
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ClickHandlerPtr _wrapped;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-03-06 16:04:47 +00:00
|
|
|
QString FileNameForSave(
|
2020-06-08 15:17:33 +00:00
|
|
|
not_null<Main::Session*> session,
|
2017-09-26 11:49:16 +00:00
|
|
|
const QString &title,
|
|
|
|
const QString &filter,
|
|
|
|
const QString &prefix,
|
|
|
|
QString name,
|
|
|
|
bool savingAs,
|
|
|
|
const QDir &dir = QDir());
|
2018-12-05 08:07:17 +00:00
|
|
|
|
2020-04-10 14:19:43 +00:00
|
|
|
QString DocumentFileNameForSave(
|
|
|
|
not_null<const DocumentData*> data,
|
|
|
|
bool forceSavingAs = false,
|
|
|
|
const QString &already = QString(),
|
|
|
|
const QDir &dir = QDir());
|
|
|
|
|
2018-12-05 08:07:17 +00:00
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
QString FileExtension(const QString &filepath);
|
|
|
|
bool IsValidMediaFile(const QString &filepath);
|
|
|
|
bool IsExecutableName(const QString &filepath);
|
2019-01-17 08:18:23 +00:00
|
|
|
base::binary_guard ReadImageAsync(
|
2020-04-10 13:18:51 +00:00
|
|
|
not_null<Data::DocumentMedia*> media,
|
2019-02-04 15:53:00 +00:00
|
|
|
FnMut<QImage(QImage)> postprocess,
|
2019-01-17 08:18:23 +00:00
|
|
|
FnMut<void(QImage&&)> done);
|
2018-12-05 08:07:17 +00:00
|
|
|
|
|
|
|
} // namespace Data
|