diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 36180d639..5c300e5a5 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -178,8 +178,10 @@ inputFileLocal path:string = InputFile; inputFileGenerated original_path:string conversion:string expected_size:int32 = InputFile; -//@description Photo description @type Thumbnail type (see https://core.telegram.org/constructor/photoSize) @photo Information about the photo file @width Photo width @height Photo height -photoSize type:string photo:file width:int32 height:int32 = PhotoSize; +//@description Describes an image in JPEG format @type Image type (see https://core.telegram.org/constructor/photoSize) +//@photo Information about the image file @width Image width @height Image height +//@progressive_sizes Sizes of progressive JPEG file prefixes, which can be used to preliminarily show the image +photoSize type:string photo:file width:int32 height:int32 progressive_sizes:vector = PhotoSize; //@description Thumbnail image of a very poor quality and low resolution @width Thumbnail width, usually doesn't exceed 40 @height Thumbnail height, usually doesn't exceed 40 @data The thumbnail in JPEG format minithumbnail width:int32 height:int32 data:bytes = Minithumbnail; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 0b46896a4..5864e0a4d 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index 16fd37374..6e4038bd5 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -864,7 +864,8 @@ tl_object_ptr copy(const td_api::minithumbnail &obj) { template <> tl_object_ptr copy(const td_api::photoSize &obj) { - return make_tl_object(obj.type_, copy(obj.photo_), obj.width_, obj.height_); + return make_tl_object(obj.type_, copy(obj.photo_), obj.width_, obj.height_, + vector(obj.progressive_sizes_)); } template <> diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 5ca47b190..ed3774ede 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -3355,17 +3355,17 @@ void unregister_message_content(Td *td, const MessageContent *content, FullMessa template static tl_object_ptr secret_to_telegram(FromT &from); -// fileLocationUnavailable#7c596b46 volume_id:long local_id:int secret:long = FileLocation; +// fileLocationUnavailable volume_id:long local_id:int secret:long = FileLocation; static auto secret_to_telegram(secret_api::fileLocationUnavailable &file_location) { return make_tl_object(file_location.volume_id_, file_location.local_id_); } -// fileLocation#53d69076 dc_id:int volume_id:long local_id:int secret:long = FileLocation; +// fileLocation dc_id:int volume_id:long local_id:int secret:long = FileLocation; static auto secret_to_telegram(secret_api::fileLocation &file_location) { return make_tl_object(file_location.volume_id_, file_location.local_id_); } -// photoSizeEmpty#e17e23c type:string = PhotoSize; +// photoSizeEmpty type:string = PhotoSize; static auto secret_to_telegram(secret_api::photoSizeEmpty &empty) { if (!clean_input_string(empty.type_)) { empty.type_.clear(); @@ -3373,7 +3373,7 @@ static auto secret_to_telegram(secret_api::photoSizeEmpty &empty) { return make_tl_object(empty.type_); } -// photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize; +// photoSize type:string location:FileLocation w:int h:int size:int = PhotoSize; static auto secret_to_telegram(secret_api::photoSize &photo_size) { if (!clean_input_string(photo_size.type_)) { photo_size.type_.clear(); @@ -3383,7 +3383,7 @@ static auto secret_to_telegram(secret_api::photoSize &photo_size) { photo_size.w_, photo_size.h_, photo_size.size_); } -// photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize; +// photoCachedSize type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize; static auto secret_to_telegram(secret_api::photoCachedSize &photo_size) { if (!clean_input_string(photo_size.type_)) { photo_size.type_.clear(); @@ -3393,17 +3393,17 @@ static auto secret_to_telegram(secret_api::photoCachedSize &photo_size) { photo_size.w_, photo_size.h_, photo_size.bytes_.clone()); } -// documentAttributeImageSize #6c37c15c w:int h:int = DocumentAttribute; +// documentAttributeImageSize w:int h:int = DocumentAttribute; static auto secret_to_telegram(secret_api::documentAttributeImageSize &image_size) { return make_tl_object(image_size.w_, image_size.h_); } -// documentAttributeAnimated #11b58939 = DocumentAttribute; +// documentAttributeAnimated = DocumentAttribute; static auto secret_to_telegram(secret_api::documentAttributeAnimated &animated) { return make_tl_object(); } -// documentAttributeSticker23 #fb0a5727 = DocumentAttribute; +// documentAttributeSticker23 = DocumentAttribute; static auto secret_to_telegram(secret_api::documentAttributeSticker23 &sticker) { return make_tl_object( 0, false /*ignored*/, "", make_tl_object(), nullptr); @@ -3420,7 +3420,7 @@ static auto secret_to_telegram(secret_api::inputStickerSetShortName &sticker_set return make_tl_object(sticker_set.short_name_); } -// documentAttributeSticker #3a556302 alt:string stickerset:InputStickerSet = DocumentAttribute; +// documentAttributeSticker alt:string stickerset:InputStickerSet = DocumentAttribute; static auto secret_to_telegram(secret_api::documentAttributeSticker &sticker) { if (!clean_input_string(sticker.alt_)) { sticker.alt_.clear(); @@ -3430,13 +3430,13 @@ static auto secret_to_telegram(secret_api::documentAttributeSticker &sticker) { nullptr); } -// documentAttributeVideo #5910cccb duration:int w:int h:int = DocumentAttribute; +// documentAttributeVideo duration:int w:int h:int = DocumentAttribute; static auto secret_to_telegram(secret_api::documentAttributeVideo &video) { return make_tl_object(0, false /*ignored*/, false /*ignored*/, video.duration_, video.w_, video.h_); } -// documentAttributeFilename #15590068 file_name:string = DocumentAttribute; +// documentAttributeFilename file_name:string = DocumentAttribute; static auto secret_to_telegram(secret_api::documentAttributeFilename &filename) { if (!clean_input_string(filename.file_name_)) { filename.file_name_.clear(); @@ -3444,7 +3444,7 @@ static auto secret_to_telegram(secret_api::documentAttributeFilename &filename) return make_tl_object(filename.file_name_); } -// documentAttributeVideo66#ef02ce6 flags:# round_message:flags.0?true duration:int w:int h:int = DocumentAttribute; +// documentAttributeVideo66 flags:# round_message:flags.0?true duration:int w:int h:int = DocumentAttribute; static auto secret_to_telegram(secret_api::documentAttributeVideo66 &video) { return make_tl_object( (video.flags_ & secret_api::documentAttributeVideo66::ROUND_MESSAGE_MASK) != 0 @@ -3479,16 +3479,16 @@ static auto telegram_documentAttributeAudio(bool is_voice_note, int duration, st std::move(performer), std::move(waveform)); } -// documentAttributeAudio23 #51448e5 duration:int = DocumentAttribute; +// documentAttributeAudio23 duration:int = DocumentAttribute; static auto secret_to_telegram(secret_api::documentAttributeAudio23 &audio) { return telegram_documentAttributeAudio(false, audio.duration_, "", "", Auto()); } -// documentAttributeAudio45 #ded218e0 duration:int title:string performer:string = DocumentAttribute; +// documentAttributeAudio45 duration:int title:string performer:string = DocumentAttribute; static auto secret_to_telegram(secret_api::documentAttributeAudio45 &audio) { return telegram_documentAttributeAudio(false, audio.duration_, audio.title_, audio.performer_, Auto()); } -// documentAttributeAudio#9852f9c6 flags:# voice:flags.10?true duration:int title:flags.0?string +// documentAttributeAudio flags:# voice:flags.10?true duration:int title:flags.0?string // performer:flags.1?string waveform:flags.2?bytes = DocumentAttribute; static auto secret_to_telegram(secret_api::documentAttributeAudio &audio) { return telegram_documentAttributeAudio((audio.flags_ & secret_api::documentAttributeAudio::VOICE_MASK) != 0, @@ -3506,7 +3506,7 @@ static auto secret_to_telegram(std::vector = DecryptedMessageMedia; static auto secret_to_telegram_document(secret_api::decryptedMessageMediaExternalDocument &from) { if (!clean_input_string(from.mime_type_)) { diff --git a/td/telegram/Photo.cpp b/td/telegram/Photo.cpp index b14b6023f..0a3c6cee8 100644 --- a/td/telegram/Photo.cpp +++ b/td/telegram/Photo.cpp @@ -408,6 +408,8 @@ Variant get_photo_size(FileManager *file_manager, PhotoSizeSo location = std::move(size->location_); res.dimensions = get_dimensions(size->w_, size->h_); res.size = size->sizes_.back(); + size->sizes_.pop_back(); + res.progressive_sizes = std::move(size->sizes_); break; } @@ -567,7 +569,8 @@ static tl_object_ptr get_photo_size_object(FileManager *file_ return td_api::make_object( photo_size->type ? std::string(1, static_cast(photo_size->type)) : std::string(), // TODO replace string type with integer type - file_manager->get_file_object(photo_size->file_id), photo_size->dimensions.width, photo_size->dimensions.height); + file_manager->get_file_object(photo_size->file_id), photo_size->dimensions.width, photo_size->dimensions.height, + vector(photo_size->progressive_sizes)); } static vector> get_photo_sizes_object(FileManager *file_manager, @@ -586,7 +589,8 @@ static vector> get_photo_sizes_object(File } bool operator==(const PhotoSize &lhs, const PhotoSize &rhs) { - return lhs.type == rhs.type && lhs.dimensions == rhs.dimensions && lhs.size == rhs.size && lhs.file_id == rhs.file_id; + return lhs.type == rhs.type && lhs.dimensions == rhs.dimensions && lhs.size == rhs.size && + lhs.file_id == rhs.file_id && lhs.progressive_sizes == rhs.progressive_sizes; } bool operator!=(const PhotoSize &lhs, const PhotoSize &rhs) { @@ -615,7 +619,8 @@ bool operator<(const PhotoSize &lhs, const PhotoSize &rhs) { StringBuilder &operator<<(StringBuilder &string_builder, const PhotoSize &photo_size) { return string_builder << "{type = " << photo_size.type << ", dimensions = " << photo_size.dimensions - << ", size = " << photo_size.size << ", file_id = " << photo_size.file_id << "}"; + << ", size = " << photo_size.size << ", file_id = " << photo_size.file_id + << ", progressive_sizes = " << photo_size.progressive_sizes << "}"; } static tl_object_ptr get_animated_chat_photo_object(FileManager *file_manager, @@ -949,6 +954,15 @@ tl_object_ptr convert_photo_to_profile_photo( } case telegram_api::photoStrippedSize::ID: break; + case telegram_api::photoSizeProgressive::ID: { + auto size = static_cast(size_ptr.get()); + if (size->type_ == "a") { + photo_small = copy_location(size->location_); + } else if (size->type_ == "c") { + photo_big = copy_location(size->location_); + } + break; + } default: UNREACHABLE(); break; diff --git a/td/telegram/Photo.h b/td/telegram/Photo.h index 46a18ce4b..43db9372a 100644 --- a/td/telegram/Photo.h +++ b/td/telegram/Photo.h @@ -48,6 +48,7 @@ struct PhotoSize { Dimensions dimensions; int32 size = 0; FileId file_id; + vector progressive_sizes; }; struct AnimationSize : public PhotoSize { diff --git a/td/telegram/Photo.hpp b/td/telegram/Photo.hpp index 0ffd0a086..911316040 100644 --- a/td/telegram/Photo.hpp +++ b/td/telegram/Photo.hpp @@ -75,6 +75,7 @@ void store(const PhotoSize &photo_size, StorerT &storer) { store(photo_size.dimensions, storer); store(photo_size.size, storer); store(photo_size.file_id, storer); + store(photo_size.progressive_sizes, storer); } template @@ -83,6 +84,11 @@ void parse(PhotoSize &photo_size, ParserT &parser) { parse(photo_size.dimensions, parser); parse(photo_size.size, parser); parse(photo_size.file_id, parser); + if (parser.version() >= static_cast(Version::AddPhotoProgressiveSizes)) { + parse(photo_size.progressive_sizes, parser); + } else { + photo_size.progressive_sizes.clear(); + } LOG(DEBUG) << "Parsed photo size " << photo_size; } diff --git a/td/telegram/Version.h b/td/telegram/Version.h index 9891f0e48..fd62e28a7 100644 --- a/td/telegram/Version.h +++ b/td/telegram/Version.h @@ -39,6 +39,7 @@ enum class Version : int32 { AddDiceEmoji, // 25 AddAnimationStickers, AddDialogPhotoHasAnimation, + AddPhotoProgressiveSizes, Next };