Add store/parse_background.
This commit is contained in:
parent
61c3a2bcf5
commit
66170213fc
@ -20,7 +20,6 @@
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
@ -412,6 +411,34 @@ void BackgroundManager::tear_down() {
|
||||
parent_.reset();
|
||||
}
|
||||
|
||||
void BackgroundManager::store_background(BackgroundId background_id, LogEventStorerCalcLength &storer) {
|
||||
const auto *background = get_background(background_id);
|
||||
CHECK(background != nullptr);
|
||||
store(*background, storer);
|
||||
}
|
||||
|
||||
void BackgroundManager::store_background(BackgroundId background_id, LogEventStorerUnsafe &storer) {
|
||||
const auto *background = get_background(background_id);
|
||||
CHECK(background != nullptr);
|
||||
store(*background, storer);
|
||||
}
|
||||
|
||||
void BackgroundManager::parse_background(BackgroundId &background_id, LogEventParser &parser) {
|
||||
Background background;
|
||||
parse(background, parser);
|
||||
CHECK(background.has_new_local_id);
|
||||
if (background.file_id.is_valid() != background.type.has_file() || !background.id.is_valid()) {
|
||||
parser.set_error(PSTRING() << "Failed to load " << background.id);
|
||||
background_id = BackgroundId();
|
||||
return;
|
||||
}
|
||||
if (background.id.is_local() && !background.type.has_file() && background.id.get() > max_local_background_id_.get()) {
|
||||
set_max_local_background_id(background.id);
|
||||
}
|
||||
background_id = background.id;
|
||||
add_background(background, false);
|
||||
}
|
||||
|
||||
void BackgroundManager::get_backgrounds(bool for_dark_theme,
|
||||
Promise<td_api::object_ptr<td_api::backgrounds>> &&promise) {
|
||||
pending_get_backgrounds_queries_.emplace_back(for_dark_theme, std::move(promise));
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "td/telegram/BackgroundType.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/files/FileSourceId.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
@ -65,6 +66,12 @@ class BackgroundManager final : public Actor {
|
||||
|
||||
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
||||
|
||||
void store_background(BackgroundId background_id, LogEventStorerCalcLength &storer);
|
||||
|
||||
void store_background(BackgroundId background_id, LogEventStorerUnsafe &storer);
|
||||
|
||||
void parse_background(BackgroundId &background_id, LogEventParser &parser);
|
||||
|
||||
private:
|
||||
struct Background {
|
||||
BackgroundId id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user