From d63ef82e5df79e475941a10908b67268ccf31ad9 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 1 Aug 2024 13:57:39 +0300 Subject: [PATCH] Add PromoDataManager. --- CMakeLists.txt | 2 ++ SplitSource.php | 1 + td/telegram/Global.h | 9 +++++++++ td/telegram/PromoDataManager.cpp | 18 ++++++++++++++++++ td/telegram/PromoDataManager.h | 28 ++++++++++++++++++++++++++++ td/telegram/Td.cpp | 6 ++++++ td/telegram/Td.h | 11 +++++++---- 7 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 td/telegram/PromoDataManager.cpp create mode 100644 td/telegram/PromoDataManager.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f159efe0e..9074b4f4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -519,6 +519,7 @@ set(TDLIB_SOURCE_PART2 td/telegram/Premium.cpp td/telegram/PremiumGiftOption.cpp td/telegram/PrivacyManager.cpp + td/telegram/PromoDataManager.cpp td/telegram/QueryCombiner.cpp td/telegram/QueryMerger.cpp td/telegram/QuickReplyManager.cpp @@ -848,6 +849,7 @@ set(TDLIB_SOURCE_PART2 td/telegram/Premium.h td/telegram/PremiumGiftOption.h td/telegram/PrivacyManager.h + td/telegram/PromoDataManager.h td/telegram/PtsManager.h td/telegram/PublicDialogType.h td/telegram/QueryCombiner.h diff --git a/SplitSource.php b/SplitSource.php index 4d607b6c0..a0f0a3471 100644 --- a/SplitSource.php +++ b/SplitSource.php @@ -392,6 +392,7 @@ function split_file($file, $chunks, $undo) { 'PhotoSizeSource' => 'PhotoSizeSource', 'poll_manager[_(-](?![.]get[(][)])|PollManager' => 'PollManager', 'privacy_manager[_(-](?![.]get[(][)])|PrivacyManager' => 'PrivacyManager', + 'promo_data_manager[_(-](?![.]get[(][)])|PromoDataManager' => 'PromoDataManager', 'PublicDialogType|get_public_dialog_type' => 'PublicDialogType', 'quick_reply_manager[_(-](?![.]get[(][)])|QuickReplyManager' => 'QuickReplyManager', 'ReactionListType|[a-z_]*_reaction_list_type' => 'ReactionListType', diff --git a/td/telegram/Global.h b/td/telegram/Global.h index cd6cd9c22..754957cea 100644 --- a/td/telegram/Global.h +++ b/td/telegram/Global.h @@ -66,6 +66,7 @@ class NotificationSettingsManager; class OptionManager; class PasswordManager; class PeopleNearbyManager; +class PromoDataManager; class QuickReplyManager; class ReactionManager; class SavedMessagesManager; @@ -425,6 +426,13 @@ class Global final : public ActorContext { people_nearby_manager_ = people_nearby_manager; } + ActorId promo_data_manager() const { + return promo_data_manager_; + } + void set_promo_data_manager(ActorId promo_data_manager) { + promo_data_manager_ = promo_data_manager; + } + ActorId quick_reply_manager() const { return quick_reply_manager_; } @@ -691,6 +699,7 @@ class Global final : public ActorContext { ActorId notification_settings_manager_; ActorId password_manager_; ActorId people_nearby_manager_; + ActorId promo_data_manager_; ActorId quick_reply_manager_; ActorId reaction_manager_; ActorId saved_messages_manager_; diff --git a/td/telegram/PromoDataManager.cpp b/td/telegram/PromoDataManager.cpp new file mode 100644 index 000000000..765f80b03 --- /dev/null +++ b/td/telegram/PromoDataManager.cpp @@ -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/PromoDataManager.h" + +namespace td { + +PromoDataManager::PromoDataManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) { +} + +void PromoDataManager::tear_down() { + parent_.reset(); +} + +} // namespace td diff --git a/td/telegram/PromoDataManager.h b/td/telegram/PromoDataManager.h new file mode 100644 index 000000000..09e6baace --- /dev/null +++ b/td/telegram/PromoDataManager.h @@ -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 PromoDataManager final : public Actor { + public: + PromoDataManager(Td *td, ActorShared<> parent); + + private: + void tear_down() final; + + Td *td_; + ActorShared<> parent_; +}; + +} // namespace td diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 837eaf7bb..8129d6b47 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -123,6 +123,7 @@ #include "td/telegram/PollManager.h" #include "td/telegram/Premium.h" #include "td/telegram/PrivacyManager.h" +#include "td/telegram/PromoDataManager.h" #include "td/telegram/PublicDialogType.h" #include "td/telegram/QuickReplyManager.h" #include "td/telegram/ReactionManager.h" @@ -2808,6 +2809,7 @@ void Td::dec_actor_refcnt() { reset_manager(phone_number_manager_, "PhoneNumberManager"); reset_manager(poll_manager_, "PollManager"); reset_manager(privacy_manager_, "PrivacyManager"); + reset_manager(promo_data_manager_, "PromoDataManager"); reset_manager(quick_reply_manager_, "QuickReplyManager"); reset_manager(reaction_manager_, "ReactionManager"); reset_manager(saved_messages_manager_, "SavedMessagesManager"); @@ -2986,6 +2988,7 @@ void Td::clear() { reset_actor(ActorOwn(std::move(phone_number_manager_actor_))); reset_actor(ActorOwn(std::move(poll_manager_actor_))); reset_actor(ActorOwn(std::move(privacy_manager_actor_))); + reset_actor(ActorOwn(std::move(promo_data_manager_actor_))); reset_actor(ActorOwn(std::move(quick_reply_manager_actor_))); reset_actor(ActorOwn(std::move(reaction_manager_actor_))); reset_actor(ActorOwn(std::move(saved_messages_manager_actor_))); @@ -3530,6 +3533,9 @@ void Td::init_managers() { poll_manager_actor_ = register_actor("PollManager", poll_manager_.get()); privacy_manager_ = make_unique(this, create_reference()); privacy_manager_actor_ = register_actor("PrivacyManager", privacy_manager_.get()); + promo_data_manager_ = make_unique(this, create_reference()); + promo_data_manager_actor_ = register_actor("PromoDataManager", promo_data_manager_.get()); + G()->set_promo_data_manager(promo_data_manager_actor_.get()); quick_reply_manager_ = make_unique(this, create_reference()); quick_reply_manager_actor_ = register_actor("QuickReplyManager", quick_reply_manager_.get()); G()->set_quick_reply_manager(quick_reply_manager_actor_.get()); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 555de3ec6..47d6e6ef9 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -81,6 +81,7 @@ class PeopleNearbyManager; class PhoneNumberManager; class PollManager; class PrivacyManager; +class PromoDataManager; class QuickReplyManager; class ReactionManager; class SavedMessagesManager; @@ -228,14 +229,16 @@ class Td final : public Actor { ActorOwn notification_manager_actor_; unique_ptr notification_settings_manager_; ActorOwn notification_settings_manager_actor_; - unique_ptr poll_manager_; - ActorOwn poll_manager_actor_; - unique_ptr privacy_manager_; - ActorOwn privacy_manager_actor_; unique_ptr people_nearby_manager_; ActorOwn people_nearby_manager_actor_; unique_ptr phone_number_manager_; ActorOwn phone_number_manager_actor_; + unique_ptr poll_manager_; + ActorOwn poll_manager_actor_; + unique_ptr privacy_manager_; + ActorOwn privacy_manager_actor_; + unique_ptr promo_data_manager_; + ActorOwn promo_data_manager_actor_; unique_ptr quick_reply_manager_; ActorOwn quick_reply_manager_actor_; unique_ptr reaction_manager_;