From 3c8f56fc663019614582735cf01bfe0f91a5d2d7 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 7 Feb 2019 18:28:49 +0300 Subject: [PATCH] Support pageBlockMap. GitOrigin-RevId: f2c4c6f6d84135d10fc1f53fb13290107827a89f --- td/generate/scheme/td_api.tl | 3 ++ td/generate/scheme/td_api.tlo | Bin 143528 -> 143748 bytes td/telegram/WebPagesManager.cpp | 70 +++++++++++++++++++++++++++++++- td/telegram/WebPagesManager.h | 1 + 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 64dc8f80..d2cd86f7 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -825,6 +825,9 @@ pageBlockDetails header:RichText page_blocks:vector is_open:Bool = Pa //@description Related articles @header Block header @articles List of related articles pageBlockRelatedArticles header:RichText articles:vector = PageBlock; +//@description A map @location Location of the map center @zoom Map zoom level @width Map width @height Map height @caption Block caption +pageBlockMap location:location zoom:int32 width:int32 height:int32 caption:pageBlockCaption = PageBlock; + //@description Describes an instant view page for a web page @page_blocks Content of the web page @is_rtl True, if the instant view must be shown from right to left //@is_full True, if the instant view contains the full page. A network request might be needed to get the full web page instant view diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index f34ab6666c3fb8396aaaa2c71d6a1ed643fd1646..1450fec9d5e5fc6ad016593430e063af9b422c9d 100644 GIT binary patch delta 745 zcmZ4SkfY@>#|9Zu!5Mo_?cfYZOiy*n$xqH^V33*okx_iJi>QboenV~M_@e`N9n<8--|CZ7{@Cb({15ZrRXMI0 z;R60Bo&s2k^i3=PO2Wd3b#me*?db(q851T8e3zMg;3o&z(#=c$+<}C^=9YgPQ@~=| KCro0LmT;8cb7&-4uAdDq2ku&ciAR-#?6(9_s_fTC8@1eR@yoc&~08_*A0jkF015`}{ zOk~Oj4Tw1hK7>FR5+9)^+kAxTD)^`(0dnEZV?sU*Kv3k&ro&;|b`b39H8ABDV9HrO zK@HIO76fIEk6^1(jk$#=d_fJhbmfQHzTA5cFg{Dj5@T*~4nPN_3LRp2HwPiC}r zpX~4p>d~BEP;X86bpT>l$Zx1QHNT+|cjY(Kc8)(faC4X@H~v &file_ids) const override { + append_page_block_caption_file_ids(caption, file_ids); + } + + tl_object_ptr get_page_block_object() const override { + return make_tl_object(location.get_location_object(), zoom, dimensions.width, + dimensions.height, get_page_block_caption_object(caption)); + } + + template + void store(T &storer) const { + using ::td::store; + store(location, storer); + store(zoom, storer); + store(dimensions, storer); + store(caption, storer); + } + + template + void parse(T &parser) { + using ::td::parse; + parse(location, parser); + parse(zoom, parser); + parse(dimensions, parser); + parse(caption, parser); + } +}; + template void WebPagesManager::PageBlock::call_impl(Type type, const PageBlock *ptr, F &&f) { switch (type) { @@ -1988,6 +2034,8 @@ void WebPagesManager::PageBlock::call_impl(Type type, const PageBlock *ptr, F && return f(static_cast(ptr)); case Type::RelatedArticles: return f(static_cast(ptr)); + case Type::Map: + return f(static_cast(ptr)); } UNREACHABLE(); } @@ -3340,6 +3388,26 @@ unique_ptr WebPagesManager::get_page_block( return td::make_unique(get_rich_text(std::move(page_block->title_), documents), std::move(articles)); } + case telegram_api::pageBlockMap::ID: { + auto page_block = move_tl_object_as(page_block_ptr); + Location location(std::move(page_block->geo_)); + auto zoom = page_block->zoom_; + Dimensions dimensions = get_dimensions(page_block->w_, page_block->h_); + if (location.empty()) { + LOG(ERROR) << "Receive invalid map location"; + break; + } + if (zoom <= 0 || zoom > 30) { + LOG(ERROR) << "Receive invalid map zoom " << zoom; + break; + } + if (dimensions.width == 0) { + LOG(ERROR) << "Receive invalid map dimensions " << page_block->w_ << " " << page_block->h_; + break; + } + return make_unique(std::move(location), zoom, dimensions, + get_page_block_caption(std::move(page_block->caption_), documents)); + } default: UNREACHABLE(); } diff --git a/td/telegram/WebPagesManager.h b/td/telegram/WebPagesManager.h index 35b02047..8d7884c8 100644 --- a/td/telegram/WebPagesManager.h +++ b/td/telegram/WebPagesManager.h @@ -132,6 +132,7 @@ class WebPagesManager : public Actor { class PageBlockTable; class PageBlockDetails; class PageBlockRelatedArticles; + class PageBlockMap; class WebPageInstantView;