From 57e0b917b80f25a7e9c0e68ab570551889d2ed72 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 10 May 2019 18:55:55 +0300 Subject: [PATCH] Add updateSelectedBackground. GitOrigin-RevId: 78ca327ff6da27da19fc6a05e2354af969b42bfb --- td/generate/scheme/td_api.tl | 3 +++ td/generate/scheme/td_api.tlo | Bin 154112 -> 154216 bytes td/telegram/BackgroundManager.cpp | 25 +++++++++++++++++++++++-- td/telegram/BackgroundManager.h | 4 ++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 5572374b..1bd57b99 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2671,6 +2671,9 @@ updateFavoriteStickers sticker_ids:vector = Update; //@description The list of saved animations was updated @animation_ids The new list of file identifiers of saved animations updateSavedAnimations animation_ids:vector = Update; +//@description The selected background has changed @background The new selected background; may be null +updateSelectedBackground background:background = Update; + //@description Some language pack strings have been updated @localization_target Localization target to which the language pack belongs @language_pack_id Identifier of the updated language pack @strings List of changed language pack strings updateLanguagePackStrings localization_target:string language_pack_id:string strings:vector = Update; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index aece15aeb5fb53264222599bd88d6062f3ebec98..edafa4149931b2b850b024d1916900f131c44067 100644 GIT binary patch delta 1780 zcmZ8iT}V@581_Ah&9E3DG-$-2NsA_|8f0O#azv%U=npRjP1;Im)X+_rO*`dWQ7o!Gx;f39Vgu!m20*P}W;e{7@S76X~-tRrFcJ=Z+&-=VT-}jx##rm~k zeZkqZ{rRt^vvrq4{;qJK=JeZ>O^3I@$Ki-=E@FeWj@k;#7sAkr(PkK|TEygb2SS|@ z5RvOQTtaL$0`~e!>eu%>J0$+1589b}-GF4M4{R9a``{%;?ta2T{SZZLyhBtlbM!Sa6A5!1{Y#vAK!p5&GQ4LcABs)G)fISXm?STCqBIOb z?2MDx7pK`);?%6xM#~5p1V_MHb=?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_-J4Nd*q{3D@M5|3u9>;gAYtv-G&e6R%Ldk#f@Zm6?;aaU!#UZT)w7)!z`xnXRg!bA z62GKj;%hLoHy@!+&d*oLi;etiShvPcU6vFpDvE1-ak=d^$h void store(StorerT &storer) const { + bool has_file_id = file_id_.is_valid(); BEGIN_STORE_FLAGS(); STORE_FLAG(is_creator_); STORE_FLAG(is_default_); STORE_FLAG(is_dark_); + STORE_FLAG(has_file_id); END_STORE_FLAGS(); td::store(background_id_, storer); td::store(access_hash_, storer); td::store(name_, storer); - storer.context()->td().get_actor_unsafe()->documents_manager_->store_document(file_id_, storer); + if (has_file_id) { + storer.context()->td().get_actor_unsafe()->documents_manager_->store_document(file_id_, storer); + } td::store(type_, storer); td::store(set_type_, storer); } template void parse(ParserT &parser) { + bool has_file_id; BEGIN_PARSE_FLAGS(); PARSE_FLAG(is_creator_); PARSE_FLAG(is_default_); PARSE_FLAG(is_dark_); + PARSE_FLAG(has_file_id); END_PARSE_FLAGS(); td::parse(background_id_, parser); td::parse(access_hash_, parser); td::parse(name_, parser); - file_id_ = parser.context()->td().get_actor_unsafe()->documents_manager_->parse_document(parser); + if (has_file_id) { + file_id_ = parser.context()->td().get_actor_unsafe()->documents_manager_->parse_document(parser); + } else { + file_id_ = FileId(); + } td::parse(type_, parser); td::parse(set_type_, parser); } @@ -266,6 +276,8 @@ void BackgroundManager::start_up() { file_id_to_background_id_.emplace(background->file_id, background->id); } } + + send_update_selected_background(); } void BackgroundManager::tear_down() { @@ -371,6 +383,14 @@ BackgroundId BackgroundManager::search_background(const string &name, Promise BackgroundManager::get_update_selected_background() const { + return td_api::make_object(get_background_object(set_background_id_)); +} + +void BackgroundManager::send_update_selected_background() const { + send_closure(G()->td(), &Td::send_update, get_update_selected_background()); +} + Result BackgroundManager::prepare_input_file(const tl_object_ptr &input_file) { auto r_file_id = td_->file_manager_->get_input_file_id(FileType::Background, input_file, {}, false, false); if (r_file_id.is_error()) { @@ -506,6 +526,7 @@ void BackgroundManager::set_background_id(BackgroundId background_id, const Back set_background_type_ = type; save_background_id(); + send_update_selected_background(); } void BackgroundManager::upload_background_file(FileId file_id, const BackgroundType &type, Promise &&promise) { diff --git a/td/telegram/BackgroundManager.h b/td/telegram/BackgroundManager.h index ef4c307d..d3e81547 100644 --- a/td/telegram/BackgroundManager.h +++ b/td/telegram/BackgroundManager.h @@ -87,6 +87,10 @@ class BackgroundManager : public Actor { telegram_api::object_ptr &&input_wallpaper, Promise &&promise) const; + td_api::object_ptr get_update_selected_background() const; + + void send_update_selected_background() const; + BackgroundId add_solid_background(int32 color); Background *add_background(BackgroundId background_id);