summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/td/telegram/ThemeSettings.hpp
blob: 7b91b859c72970aa458815fbb010610aa2cc3aae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
//
// 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)
//
#pragma once

#include "td/telegram/ThemeSettings.h"

#include "td/telegram/BackgroundInfo.hpp"

#include "td/utils/tl_helpers.h"

namespace td {

template <class StorerT>
void ThemeSettings::store(StorerT &storer) const {
  bool has_message_accent_color = message_accent_color_ != accent_color_;
  bool has_background = background_info_.is_valid();
  BEGIN_STORE_FLAGS();
  STORE_FLAG(animate_message_colors_);
  STORE_FLAG(has_message_accent_color);
  STORE_FLAG(has_background);
  END_STORE_FLAGS();
  td::store(accent_color_, storer);
  if (has_message_accent_color) {
    td::store(message_accent_color_, storer);
  }
  if (has_background) {
    td::store(background_info_, storer);
  }
  td::store(base_theme_, storer);
  td::store(message_colors_, storer);
}

template <class ParserT>
void ThemeSettings::parse(ParserT &parser) {
  bool has_message_accent_color;
  bool has_background;
  BEGIN_PARSE_FLAGS();
  PARSE_FLAG(animate_message_colors_);
  PARSE_FLAG(has_message_accent_color);
  PARSE_FLAG(has_background);
  END_PARSE_FLAGS();
  td::parse(accent_color_, parser);
  if (has_message_accent_color) {
    td::parse(message_accent_color_, parser);
  } else {
    message_accent_color_ = accent_color_;
  }
  if (has_background) {
    td::parse(background_info_, parser);
  }
  td::parse(base_theme_, parser);
  td::parse(message_colors_, parser);
}

}  // namespace td