Add TermsOfServiceManager.

This commit is contained in:
levlam 2024-08-01 11:13:11 +03:00
parent 78f6dccb00
commit 01755c8fea
6 changed files with 59 additions and 0 deletions

View File

@ -574,6 +574,7 @@ set(TDLIB_SOURCE_PART2
td/telegram/Td.cpp td/telegram/Td.cpp
td/telegram/TdDb.cpp td/telegram/TdDb.cpp
td/telegram/TermsOfService.cpp td/telegram/TermsOfService.cpp
td/telegram/TermsOfServiceManager.cpp
td/telegram/ThemeManager.cpp td/telegram/ThemeManager.cpp
td/telegram/ThemeSettings.cpp td/telegram/ThemeSettings.cpp
td/telegram/TimeZoneManager.cpp td/telegram/TimeZoneManager.cpp
@ -918,6 +919,7 @@ set(TDLIB_SOURCE_PART2
td/telegram/TdCallback.h td/telegram/TdCallback.h
td/telegram/TdDb.h td/telegram/TdDb.h
td/telegram/TermsOfService.h td/telegram/TermsOfService.h
td/telegram/TermsOfServiceManager.h
td/telegram/ThemeManager.h td/telegram/ThemeManager.h
td/telegram/ThemeSettings.h td/telegram/ThemeSettings.h
td/telegram/TimeZoneManager.h td/telegram/TimeZoneManager.h

View File

@ -422,6 +422,7 @@ function split_file($file, $chunks, $undo) {
'td_api' => 'td_api', 'td_api' => 'td_api',
'td_db[(][)]|TdDb[^A-Za-z]' => 'TdDb', 'td_db[(][)]|TdDb[^A-Za-z]' => 'TdDb',
'telegram_api' => 'telegram_api', 'telegram_api' => 'telegram_api',
'terms_of_service_manager[_(-](?![.]get[(][)])|TermsOfServiceManager' => 'TermsOfServiceManager',
'theme_manager[_(-](?![.]get[(][)])|ThemeManager' => 'ThemeManager', 'theme_manager[_(-](?![.]get[(][)])|ThemeManager' => 'ThemeManager',
'ThemeSettings' => 'ThemeSettings', 'ThemeSettings' => 'ThemeSettings',
'time_zone_manager[_(-](?![.]get[(][)])|TimeZoneManager' => 'TimeZoneManager', 'time_zone_manager[_(-](?![.]get[(][)])|TimeZoneManager' => 'TimeZoneManager',

View File

@ -157,6 +157,7 @@
#include "td/telegram/td_api.hpp" #include "td/telegram/td_api.hpp"
#include "td/telegram/TdDb.h" #include "td/telegram/TdDb.h"
#include "td/telegram/telegram_api.h" #include "td/telegram/telegram_api.h"
#include "td/telegram/TermsOfServiceManager.h"
#include "td/telegram/ThemeManager.h" #include "td/telegram/ThemeManager.h"
#include "td/telegram/TimeZoneManager.h" #include "td/telegram/TimeZoneManager.h"
#include "td/telegram/TopDialogCategory.h" #include "td/telegram/TopDialogCategory.h"
@ -2862,6 +2863,7 @@ void Td::dec_actor_refcnt() {
reset_manager(statistics_manager_, "StatisticsManager"); reset_manager(statistics_manager_, "StatisticsManager");
reset_manager(stickers_manager_, "StickersManager"); reset_manager(stickers_manager_, "StickersManager");
reset_manager(story_manager_, "StoryManager"); reset_manager(story_manager_, "StoryManager");
reset_manager(terms_of_service_manager_, "TermsOfServiceManager");
reset_manager(theme_manager_, "ThemeManager"); reset_manager(theme_manager_, "ThemeManager");
reset_manager(time_zone_manager_, "TimeZoneManager"); reset_manager(time_zone_manager_, "TimeZoneManager");
reset_manager(top_dialog_manager_, "TopDialogManager"); reset_manager(top_dialog_manager_, "TopDialogManager");
@ -3040,6 +3042,7 @@ void Td::clear() {
reset_actor(ActorOwn<Actor>(std::move(statistics_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(statistics_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(stickers_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(stickers_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(story_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(story_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(terms_of_service_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(theme_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(theme_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(time_zone_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(time_zone_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(top_dialog_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(top_dialog_manager_actor_)));
@ -3599,6 +3602,8 @@ void Td::init_managers() {
story_manager_ = make_unique<StoryManager>(this, create_reference()); story_manager_ = make_unique<StoryManager>(this, create_reference());
story_manager_actor_ = register_actor("StoryManager", story_manager_.get()); story_manager_actor_ = register_actor("StoryManager", story_manager_.get());
G()->set_story_manager(story_manager_actor_.get()); G()->set_story_manager(story_manager_actor_.get());
terms_of_service_manager_ = make_unique<TermsOfServiceManager>(this, create_reference());
terms_of_service_manager_actor_ = register_actor("TermsOfServiceManager", terms_of_service_manager_.get());
theme_manager_ = make_unique<ThemeManager>(this, create_reference()); theme_manager_ = make_unique<ThemeManager>(this, create_reference());
theme_manager_actor_ = register_actor("ThemeManager", theme_manager_.get()); theme_manager_actor_ = register_actor("ThemeManager", theme_manager_.get());
G()->set_theme_manager(theme_manager_actor_.get()); G()->set_theme_manager(theme_manager_actor_.get());
@ -4551,6 +4556,7 @@ void Td::on_request(uint64 id, td_api::getStorageStatisticsFast &request) {
}); });
send_closure(storage_manager_, &StorageManager::get_storage_stats_fast, std::move(query_promise)); send_closure(storage_manager_, &StorageManager::get_storage_stats_fast, std::move(query_promise));
} }
void Td::on_request(uint64 id, const td_api::getDatabaseStatistics &request) { void Td::on_request(uint64 id, const td_api::getDatabaseStatistics &request) {
CREATE_REQUEST_PROMISE(); CREATE_REQUEST_PROMISE();
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<DatabaseStats> result) mutable { auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<DatabaseStats> result) mutable {

View File

@ -94,6 +94,7 @@ class StatisticsManager;
class StickersManager; class StickersManager;
class StorageManager; class StorageManager;
class StoryManager; class StoryManager;
class TermsOfServiceManager;
class ThemeManager; class ThemeManager;
class TimeZoneManager; class TimeZoneManager;
class TopDialogManager; class TopDialogManager;
@ -254,6 +255,8 @@ class Td final : public Actor {
ActorOwn<StickersManager> stickers_manager_actor_; ActorOwn<StickersManager> stickers_manager_actor_;
unique_ptr<StoryManager> story_manager_; unique_ptr<StoryManager> story_manager_;
ActorOwn<StoryManager> story_manager_actor_; ActorOwn<StoryManager> story_manager_actor_;
unique_ptr<TermsOfServiceManager> terms_of_service_manager_;
ActorOwn<TermsOfServiceManager> terms_of_service_manager_actor_;
unique_ptr<ThemeManager> theme_manager_; unique_ptr<ThemeManager> theme_manager_;
ActorOwn<ThemeManager> theme_manager_actor_; ActorOwn<ThemeManager> theme_manager_actor_;
unique_ptr<TimeZoneManager> time_zone_manager_; unique_ptr<TimeZoneManager> time_zone_manager_;
@ -410,6 +413,7 @@ class Td final : public Actor {
vector<std::pair<uint64, td_api::object_ptr<td_api::Function>>> pending_preauthentication_requests_; vector<std::pair<uint64, td_api::object_ptr<td_api::Function>>> pending_preauthentication_requests_;
vector<std::pair<uint64, td_api::object_ptr<td_api::Function>>> pending_set_parameters_requests_; vector<std::pair<uint64, td_api::object_ptr<td_api::Function>>> pending_set_parameters_requests_;
vector<std::pair<uint64, td_api::object_ptr<td_api::Function>>> pending_init_requests_; vector<std::pair<uint64, td_api::object_ptr<td_api::Function>>> pending_init_requests_;
template <class T> template <class T>

View File

@ -0,0 +1,18 @@
//
// 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)
//
#include "td/telegram/TermsOfServiceManager.h"
namespace td {
TermsOfServiceManager::TermsOfServiceManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
}
void TermsOfServiceManager::tear_down() {
parent_.reset();
}
} // namespace td

View File

@ -0,0 +1,28 @@
//
// 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/actor/actor.h"
#include "td/utils/common.h"
namespace td {
class Td;
class TermsOfServiceManager final : public Actor {
public:
TermsOfServiceManager(Td *td, ActorShared<> parent);
private:
void tear_down() final;
Td *td_;
ActorShared<> parent_;
};
} // namespace td