summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/td/telegram/DocumentsManager.hpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-06-04 19:24:05 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-06-04 19:24:05 +0300
commitefc336e60cf1331bf5f3213d296981b87b8b2a6c (patch)
treeea59ea1a324f45f6e8a06cc0887b376bfba90ca9 /protocols/Telegram/tdlib/td/td/telegram/DocumentsManager.hpp
parent6e83622d2af1cec3c759f4cff6efe4df2fe3328c (diff)
fixes #3537 (Telegram: 32-разрядная версия падает в 64-разрядной Windows) + update to the fresh TDLIB
Diffstat (limited to 'protocols/Telegram/tdlib/td/td/telegram/DocumentsManager.hpp')
-rw-r--r--protocols/Telegram/tdlib/td/td/telegram/DocumentsManager.hpp59
1 files changed, 50 insertions, 9 deletions
diff --git a/protocols/Telegram/tdlib/td/td/telegram/DocumentsManager.hpp b/protocols/Telegram/tdlib/td/td/telegram/DocumentsManager.hpp
index c7b15700c1..494415cf77 100644
--- a/protocols/Telegram/tdlib/td/td/telegram/DocumentsManager.hpp
+++ b/protocols/Telegram/tdlib/td/td/telegram/DocumentsManager.hpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -20,22 +20,63 @@ template <class StorerT>
void DocumentsManager::store_document(FileId file_id, StorerT &storer) const {
const GeneralDocument *document = get_document(file_id);
CHECK(document != nullptr);
- store(document->file_name, storer);
- store(document->mime_type, storer);
- store(document->minithumbnail, storer);
- store(document->thumbnail, storer);
+ bool has_file_name = !document->file_name.empty();
+ bool has_mime_type = !document->mime_type.empty();
+ bool has_minithumbnail = !document->minithumbnail.empty();
+ bool has_thumbnail = document->thumbnail.file_id.is_valid();
+ BEGIN_STORE_FLAGS();
+ STORE_FLAG(has_file_name);
+ STORE_FLAG(has_mime_type);
+ STORE_FLAG(has_minithumbnail);
+ STORE_FLAG(has_thumbnail);
+ END_STORE_FLAGS();
+ if (has_file_name) {
+ store(document->file_name, storer);
+ }
+ if (has_mime_type) {
+ store(document->mime_type, storer);
+ }
+ if (has_minithumbnail) {
+ store(document->minithumbnail, storer);
+ }
+ if (has_thumbnail) {
+ store(document->thumbnail, storer);
+ }
store(file_id, storer);
}
template <class ParserT>
FileId DocumentsManager::parse_document(ParserT &parser) {
auto document = make_unique<GeneralDocument>();
- parse(document->file_name, parser);
- parse(document->mime_type, parser);
- if (parser.version() >= static_cast<int32>(Version::SupportMinithumbnails)) {
+ bool has_file_name;
+ bool has_mime_type;
+ bool has_minithumbnail;
+ bool has_thumbnail;
+ if (parser.version() >= static_cast<int32>(Version::AddDocumentFlags)) {
+ BEGIN_PARSE_FLAGS();
+ PARSE_FLAG(has_file_name);
+ PARSE_FLAG(has_mime_type);
+ PARSE_FLAG(has_minithumbnail);
+ PARSE_FLAG(has_thumbnail);
+ END_PARSE_FLAGS();
+ } else {
+ has_file_name = true;
+ has_mime_type = true;
+ has_minithumbnail = parser.version() >= static_cast<int32>(Version::SupportMinithumbnails);
+ has_thumbnail = true;
+ }
+ if (has_file_name) {
+ parse(document->file_name, parser);
+ }
+ if (has_mime_type) {
+ parse(document->mime_type, parser);
+ }
+ if (has_minithumbnail) {
parse(document->minithumbnail, parser);
}
- parse(document->thumbnail, parser);
+ if (has_thumbnail) {
+ parse(document->thumbnail, parser);
+ }
parse(document->file_id, parser);
if (parser.get_error() != nullptr || !document->file_id.is_valid()) {
return FileId();