Add ConnectionStateManager.

This commit is contained in:
levlam 2024-08-01 14:40:12 +03:00
parent 05325437e8
commit 7ce682984c
6 changed files with 61 additions and 4 deletions

View File

@ -361,6 +361,7 @@ set(TDLIB_SOURCE_PART1
td/telegram/CommonDialogManager.cpp td/telegram/CommonDialogManager.cpp
td/telegram/ConfigManager.cpp td/telegram/ConfigManager.cpp
td/telegram/ConnectionState.cpp td/telegram/ConnectionState.cpp
td/telegram/ConnectionStateManager.cpp
td/telegram/Contact.cpp td/telegram/Contact.cpp
td/telegram/CountryInfoManager.cpp td/telegram/CountryInfoManager.cpp
td/telegram/DelayDispatcher.cpp td/telegram/DelayDispatcher.cpp
@ -650,6 +651,7 @@ set(TDLIB_SOURCE_PART2
td/telegram/CommonDialogManager.h td/telegram/CommonDialogManager.h
td/telegram/ConfigManager.h td/telegram/ConfigManager.h
td/telegram/ConnectionState.h td/telegram/ConnectionState.h
td/telegram/ConnectionStateManager.h
td/telegram/Contact.h td/telegram/Contact.h
td/telegram/CountryInfoManager.h td/telegram/CountryInfoManager.h
td/telegram/CustomEmojiId.h td/telegram/CustomEmojiId.h

View File

@ -329,6 +329,7 @@ function split_file($file, $chunks, $undo) {
'ChatId' => 'ChatId', 'ChatId' => 'ChatId',
'chat_manager[_(-](?![.]get[(][)])|ChatManager([^ ;.]| [^*])' => 'ChatManager', 'chat_manager[_(-](?![.]get[(][)])|ChatManager([^ ;.]| [^*])' => 'ChatManager',
'common_dialog_manager[_(-](?![.]get[(][)])|CommonDialogManager' => 'CommonDialogManager', 'common_dialog_manager[_(-](?![.]get[(][)])|CommonDialogManager' => 'CommonDialogManager',
'connection_state_manager[_(-](?![.]get[(][)])|ConnectionStateManager' => 'ConnectionStateManager',
'country_info_manager[_(-](?![.]get[(][)])|CountryInfoManager' => 'CountryInfoManager', 'country_info_manager[_(-](?![.]get[(][)])|CountryInfoManager' => 'CountryInfoManager',
'CustomEmojiId' => 'CustomEmojiId', 'CustomEmojiId' => 'CustomEmojiId',
'device_token_manager[_(-](?![.]get[(][)])|DeviceTokenManager' => 'DeviceTokenManager', 'device_token_manager[_(-](?![.]get[(][)])|DeviceTokenManager' => 'DeviceTokenManager',

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/ConnectionStateManager.h"
namespace td {
ConnectionStateManager::ConnectionStateManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
}
void ConnectionStateManager::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 ConnectionStateManager final : public Actor {
public:
ConnectionStateManager(Td *td, ActorShared<> parent);
private:
void tear_down() final;
Td *td_;
ActorShared<> parent_;
};
} // namespace td

View File

@ -40,6 +40,7 @@
#include "td/telegram/ChatManager.h" #include "td/telegram/ChatManager.h"
#include "td/telegram/CommonDialogManager.h" #include "td/telegram/CommonDialogManager.h"
#include "td/telegram/ConfigManager.h" #include "td/telegram/ConfigManager.h"
#include "td/telegram/ConnectionStateManager.h"
#include "td/telegram/CountryInfoManager.h" #include "td/telegram/CountryInfoManager.h"
#include "td/telegram/CustomEmojiId.h" #include "td/telegram/CustomEmojiId.h"
#include "td/telegram/DeviceTokenManager.h" #include "td/telegram/DeviceTokenManager.h"
@ -2685,8 +2686,9 @@ void Td::dec_actor_refcnt() {
reset_manager(business_manager_, "BusinessManager"); reset_manager(business_manager_, "BusinessManager");
reset_manager(callback_queries_manager_, "CallbackQueriesManager"); reset_manager(callback_queries_manager_, "CallbackQueriesManager");
reset_manager(channel_recommendation_manager_, "ChannelRecommendationManager"); reset_manager(channel_recommendation_manager_, "ChannelRecommendationManager");
reset_manager(common_dialog_manager_, "CommonDialogManager");
reset_manager(chat_manager_, "ChatManager"); reset_manager(chat_manager_, "ChatManager");
reset_manager(common_dialog_manager_, "CommonDialogManager");
reset_manager(connection_state_manager_, "ConnectionStateManager");
reset_manager(country_info_manager_, "CountryInfoManager"); reset_manager(country_info_manager_, "CountryInfoManager");
reset_manager(dialog_action_manager_, "DialogActionManager"); reset_manager(dialog_action_manager_, "DialogActionManager");
reset_manager(dialog_filter_manager_, "DialogFilterManager"); reset_manager(dialog_filter_manager_, "DialogFilterManager");
@ -2864,8 +2866,9 @@ void Td::clear() {
reset_actor(ActorOwn<Actor>(std::move(business_connection_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(business_connection_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(business_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(business_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(channel_recommendation_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(channel_recommendation_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(common_dialog_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(chat_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(chat_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(common_dialog_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(connection_state_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(country_info_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(country_info_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(dialog_action_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(dialog_action_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(dialog_filter_manager_actor_))); reset_actor(ActorOwn<Actor>(std::move(dialog_filter_manager_actor_)));
@ -3369,11 +3372,13 @@ void Td::init_managers() {
channel_recommendation_manager_ = make_unique<ChannelRecommendationManager>(this, create_reference()); channel_recommendation_manager_ = make_unique<ChannelRecommendationManager>(this, create_reference());
channel_recommendation_manager_actor_ = channel_recommendation_manager_actor_ =
register_actor("ChannelRecommendationManager", channel_recommendation_manager_.get()); register_actor("ChannelRecommendationManager", channel_recommendation_manager_.get());
common_dialog_manager_ = make_unique<CommonDialogManager>(this, create_reference());
common_dialog_manager_actor_ = register_actor("CommonDialogManager", common_dialog_manager_.get());
chat_manager_ = make_unique<ChatManager>(this, create_reference()); chat_manager_ = make_unique<ChatManager>(this, create_reference());
chat_manager_actor_ = register_actor("ChatManager", chat_manager_.get()); chat_manager_actor_ = register_actor("ChatManager", chat_manager_.get());
G()->set_chat_manager(chat_manager_actor_.get()); G()->set_chat_manager(chat_manager_actor_.get());
common_dialog_manager_ = make_unique<CommonDialogManager>(this, create_reference());
common_dialog_manager_actor_ = register_actor("CommonDialogManager", common_dialog_manager_.get());
connection_state_manager_ = make_unique<ConnectionStateManager>(this, create_reference());
connection_state_manager_actor_ = register_actor("ConnectionStateManager", connection_state_manager_.get());
country_info_manager_ = make_unique<CountryInfoManager>(this, create_reference()); country_info_manager_ = make_unique<CountryInfoManager>(this, create_reference());
country_info_manager_actor_ = register_actor("CountryInfoManager", country_info_manager_.get()); country_info_manager_actor_ = register_actor("CountryInfoManager", country_info_manager_.get());
dialog_action_manager_ = make_unique<DialogActionManager>(this, create_reference()); dialog_action_manager_ = make_unique<DialogActionManager>(this, create_reference());

View File

@ -51,6 +51,7 @@ class ChannelRecommendationManager;
class ChatManager; class ChatManager;
class CommonDialogManager; class CommonDialogManager;
class ConfigManager; class ConfigManager;
class ConnectionStateManager;
class CountryInfoManager; class CountryInfoManager;
class DeviceTokenManager; class DeviceTokenManager;
class DialogActionManager; class DialogActionManager;
@ -189,6 +190,8 @@ class Td final : public Actor {
ActorOwn<ChatManager> chat_manager_actor_; ActorOwn<ChatManager> chat_manager_actor_;
unique_ptr<CommonDialogManager> common_dialog_manager_; unique_ptr<CommonDialogManager> common_dialog_manager_;
ActorOwn<CommonDialogManager> common_dialog_manager_actor_; ActorOwn<CommonDialogManager> common_dialog_manager_actor_;
unique_ptr<ConnectionStateManager> connection_state_manager_;
ActorOwn<ConnectionStateManager> connection_state_manager_actor_;
unique_ptr<CountryInfoManager> country_info_manager_; unique_ptr<CountryInfoManager> country_info_manager_;
ActorOwn<CountryInfoManager> country_info_manager_actor_; ActorOwn<CountryInfoManager> country_info_manager_actor_;
unique_ptr<DialogActionManager> dialog_action_manager_; unique_ptr<DialogActionManager> dialog_action_manager_;