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"
|
2020-10-13 16:43:18 +00:00
|
|
|
#include "core/file_location.h"
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2023-01-10 18:56:20 +00:00
|
|
|
enum class ChatRestriction;
|
2019-07-24 11:45:24 +00:00
|
|
|
class mtpFileLoader;
|
|
|
|
|
2018-10-25 09:24:45 +00:00
|
|
|
namespace Images {
|
|
|
|
class Source;
|
|
|
|
} // namespace Images
|
|
|
|
|
2024-04-15 07:18:57 +00:00
|
|
|
namespace Core {
|
|
|
|
enum class NameType : uchar;
|
|
|
|
} // namespace Core
|
|
|
|
|
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;
|
2022-07-08 17:04:31 +00:00
|
|
|
enum class StickersType : uchar;
|
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;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-01-19 14:45:51 +00:00
|
|
|
enum class StickerType : uchar {
|
|
|
|
Webp,
|
|
|
|
Tgs,
|
|
|
|
Webm,
|
|
|
|
};
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
struct StickerData : public DocumentAdditionalData {
|
2022-01-19 14:45:51 +00:00
|
|
|
[[nodiscard]] Data::FileOrigin setOrigin() const;
|
|
|
|
[[nodiscard]] bool isStatic() const;
|
|
|
|
[[nodiscard]] bool isLottie() const;
|
|
|
|
[[nodiscard]] bool isAnimated() const;
|
|
|
|
[[nodiscard]] bool isWebm() const;
|
2018-07-13 21:25:47 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
QString alt;
|
2021-07-08 16:42:57 +00:00
|
|
|
StickerSetIdentifier set;
|
2022-01-19 14:45:51 +00:00
|
|
|
StickerType type = StickerType::Webp;
|
2022-07-08 17:04:31 +00:00
|
|
|
Data::StickersType setType = Data::StickersType();
|
2017-09-26 11:49:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SongData : public DocumentAdditionalData {
|
|
|
|
QString title, performer;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VoiceData : public DocumentAdditionalData {
|
|
|
|
~VoiceData();
|
|
|
|
|
|
|
|
VoiceWaveform waveform;
|
|
|
|
char wavemax = 0;
|
|
|
|
};
|
|
|
|
|
2022-10-23 19:02:19 +00:00
|
|
|
using RoundData = VoiceData;
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
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;
|
2022-07-08 15:00:30 +00:00
|
|
|
void resetCancelled();
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] float64 progress() const;
|
2022-05-10 14:22:28 +00:00
|
|
|
[[nodiscard]] int64 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
|
|
|
|
2023-01-10 18:56:20 +00:00
|
|
|
[[nodiscard]] ChatRestriction requiredSendRight() const;
|
|
|
|
|
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
|
|
|
|
2021-12-03 10:59:08 +00:00
|
|
|
[[nodiscard]] const Core::FileLocation &location(
|
|
|
|
bool check = false) const;
|
2020-10-13 16:43:18 +00:00
|
|
|
void setLocation(const Core::FileLocation &loc);
|
2017-09-26 11:49:16 +00:00
|
|
|
|
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
|
|
|
|
2022-03-29 14:14:11 +00:00
|
|
|
void forceToCache(bool force);
|
2019-01-16 12:25:29 +00:00
|
|
|
[[nodiscard]] bool saveToCache() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2021-12-03 10:59:08 +00:00
|
|
|
[[nodiscard]] Image *getReplyPreview(
|
|
|
|
Data::FileOrigin origin,
|
2022-12-30 09:37:34 +00:00
|
|
|
not_null<PeerData*> context,
|
|
|
|
bool spoiler);
|
2021-12-03 10:59:08 +00:00
|
|
|
[[nodiscard]] Image *getReplyPreview(not_null<HistoryItem*> item);
|
2022-12-30 09:37:34 +00:00
|
|
|
[[nodiscard]] bool replyPreviewLoaded(bool spoiler) const;
|
2019-01-25 14:37:28 +00:00
|
|
|
|
|
|
|
[[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;
|
2022-10-23 19:02:19 +00:00
|
|
|
[[nodiscard]] RoundData *round();
|
|
|
|
[[nodiscard]] const RoundData *round() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
|
2022-06-10 08:03:47 +00:00
|
|
|
void forceIsStreamedAnimation();
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool isVoiceMessage() const;
|
|
|
|
[[nodiscard]] bool isVideoMessage() const;
|
|
|
|
[[nodiscard]] bool isSong() const;
|
2021-01-09 19:52:55 +00:00
|
|
|
[[nodiscard]] bool isSongWithCover() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool isAudioFile() const;
|
|
|
|
[[nodiscard]] bool isVideoFile() const;
|
2023-07-19 08:30:34 +00:00
|
|
|
[[nodiscard]] bool isSilentVideo() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool isAnimation() const;
|
|
|
|
[[nodiscard]] bool isGifv() const;
|
|
|
|
[[nodiscard]] bool isTheme() const;
|
|
|
|
[[nodiscard]] bool isSharedMediaMusic() const;
|
2023-06-05 12:50:43 +00:00
|
|
|
[[nodiscard]] crl::time duration() const;
|
|
|
|
[[nodiscard]] bool hasDuration() 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;
|
2021-08-11 16:56:12 +00:00
|
|
|
[[nodiscard]] bool isPatternWallPaperPNG() const;
|
|
|
|
[[nodiscard]] bool isPatternWallPaperSVG() const;
|
2022-04-21 11:06:50 +00:00
|
|
|
[[nodiscard]] bool isPremiumSticker() const;
|
2022-07-08 17:04:31 +00:00
|
|
|
[[nodiscard]] bool isPremiumEmoji() const;
|
2022-12-15 15:10:51 +00:00
|
|
|
[[nodiscard]] bool emojiUsesTextColor() 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(
|
2021-07-02 10:13:48 +00:00
|
|
|
const InlineImageLocation &inlineThumbnail,
|
2020-05-22 11:15:09 +00:00
|
|
|
const ImageWithLocation &thumbnail,
|
2022-04-21 11:06:50 +00:00
|
|
|
const ImageWithLocation &videoThumbnail,
|
|
|
|
bool isPremiumSticker);
|
2019-01-25 14:37:28 +00:00
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
[[nodiscard]] QByteArray inlineThumbnailBytes() const {
|
|
|
|
return _inlineThumbnailBytes;
|
|
|
|
}
|
2021-07-02 10:13:48 +00:00
|
|
|
[[nodiscard]] bool inlineThumbnailIsPath() const {
|
|
|
|
return (_flags & Flag::InlineThumbnailIsPath);
|
|
|
|
}
|
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
|
|
|
|
2023-06-16 12:44:32 +00:00
|
|
|
void setStoryMedia(bool value);
|
|
|
|
[[nodiscard]] bool storyMedia() const;
|
|
|
|
|
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;
|
2024-04-15 07:18:57 +00:00
|
|
|
[[nodiscard]] Core::NameType nameType() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] QString mimeString() const;
|
2022-11-26 21:20:17 +00:00
|
|
|
[[nodiscard]] bool hasMimeType(const QString &mime) const;
|
2018-01-27 09:21:57 +00:00
|
|
|
void setMimeString(const QString &mime);
|
|
|
|
|
2020-10-30 01:07:04 +00:00
|
|
|
[[nodiscard]] bool hasAttachedStickers() const;
|
|
|
|
|
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
|
|
|
|
2021-11-05 18:32:26 +00:00
|
|
|
[[nodiscard]] bool canBeStreamed(HistoryItem *item) 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;
|
2023-06-26 16:22:56 +00:00
|
|
|
[[nodiscard]] int videoPreloadPrefix() const;
|
|
|
|
[[nodiscard]] StorageFileLocation videoPreloadLocation() const;
|
2019-03-04 11:28:52 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
DocumentId id = 0;
|
2022-05-10 14:22:28 +00:00
|
|
|
int64 size = 0;
|
2017-09-26 11:49:16 +00:00
|
|
|
QSize dimensions;
|
|
|
|
int32 date = 0;
|
2022-05-10 14:22:28 +00:00
|
|
|
DocumentType type = FileDocument;
|
2017-09-26 11:49:16 +00:00
|
|
|
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:
|
2022-03-29 14:14:11 +00:00
|
|
|
enum class Flag : ushort {
|
2023-06-16 12:44:32 +00:00
|
|
|
StreamingMaybeYes = 0x0001,
|
|
|
|
StreamingMaybeNo = 0x0002,
|
|
|
|
StreamingPlaybackFailed = 0x0004,
|
|
|
|
ImageType = 0x0008,
|
|
|
|
DownloadCancelled = 0x0010,
|
|
|
|
LoadedInMediaCache = 0x0020,
|
|
|
|
HasAttachedStickers = 0x0040,
|
|
|
|
InlineThumbnailIsPath = 0x0080,
|
|
|
|
ForceToCache = 0x0100,
|
|
|
|
PremiumSticker = 0x0200,
|
|
|
|
PossibleCoverThumbnail = 0x0400,
|
|
|
|
UseTextColor = 0x0800,
|
|
|
|
StoryDocument = 0x1000,
|
2023-06-29 10:48:14 +00:00
|
|
|
SilentVideo = 0x2000,
|
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();
|
2021-10-11 17:46:29 +00:00
|
|
|
void setFileName(const QString &remoteFileName);
|
2024-04-16 08:49:10 +00:00
|
|
|
bool enforceNameType(Core::NameType nameType);
|
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
|
|
|
|
2022-08-01 12:14:37 +00:00
|
|
|
void refreshPossibleCoverThumbnail();
|
|
|
|
|
2020-04-15 14:06:34 +00:00
|
|
|
const not_null<Data::Session*> _owner;
|
|
|
|
|
2023-06-26 16:22:56 +00:00
|
|
|
int _videoPreloadPrefix = 0;
|
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;
|
2023-06-05 12:50:43 +00:00
|
|
|
crl::time _duration = -1;
|
2018-10-25 08:12:56 +00:00
|
|
|
|
2020-10-13 16:43:18 +00:00
|
|
|
Core::FileLocation _location;
|
2017-09-26 11:49:16 +00:00
|
|
|
std::unique_ptr<DocumentAdditionalData> _additional;
|
2019-04-30 12:53:44 +00:00
|
|
|
mutable Flags _flags = kStreamingSupportedUnknown;
|
2020-03-27 11:40:50 +00:00
|
|
|
GoodThumbnailState _goodThumbnailState = GoodThumbnailState();
|
2024-04-15 07:18:57 +00:00
|
|
|
Core::NameType _nameType = Core::NameType();
|
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);
|
|
|
|
|
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());
|