diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e26b7d2b..68bc4fd34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -331,6 +331,7 @@ set(TDLIB_SOURCE td/telegram/files/PartsManager.cpp td/telegram/files/ResourceManager.cpp td/telegram/Game.cpp + td/telegram/GameManager.cpp td/telegram/Global.cpp td/telegram/GroupCallManager.cpp td/telegram/GroupCallParticipant.cpp @@ -519,6 +520,7 @@ set(TDLIB_SOURCE td/telegram/FolderId.h td/telegram/FullMessageId.h td/telegram/Game.h + td/telegram/GameManager.h td/telegram/Global.h td/telegram/GroupCallId.h td/telegram/GroupCallManager.h diff --git a/SplitSource.php b/SplitSource.php index c8d860e4a..9784bd30b 100644 --- a/SplitSource.php +++ b/SplitSource.php @@ -286,6 +286,7 @@ function split_file($file, $chunks, $undo) { 'file_reference_manager[_(-][^.]|FileReferenceManager|file_references[)]' => 'FileReferenceManager', 'file_manager[_(-][^.]|FileManager([^ ;.]| [^*])|update_file[)]' => 'files/FileManager', 'G[(][)]|Global[^A-Za-z]' => 'Global', + 'game_manager[_(-][^.]|GameManager' => 'GameManager', 'group_call_manager[_(-][^.]|GroupCallManager' => 'GroupCallManager', 'HashtagHints' => 'HashtagHints', 'inline_queries_manager[_(-][^.]|InlineQueriesManager' => 'InlineQueriesManager', diff --git a/td/telegram/GameManager.cpp b/td/telegram/GameManager.cpp new file mode 100644 index 000000000..7a1da3866 --- /dev/null +++ b/td/telegram/GameManager.cpp @@ -0,0 +1,20 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021 +// +// 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/GameManager.h" + +namespace td { + +GameManager::GameManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) { +} + +GameManager::~GameManager() = default; + +void GameManager::tear_down() { + parent_.reset(); +} + +} // namespace td diff --git a/td/telegram/GameManager.h b/td/telegram/GameManager.h new file mode 100644 index 000000000..7b2bb7f4d --- /dev/null +++ b/td/telegram/GameManager.h @@ -0,0 +1,31 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021 +// +// 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" + +namespace td { + +class Td; + +class GameManager final : public Actor { + public: + GameManager(Td *td, ActorShared<> parent); + GameManager(const GameManager &) = delete; + GameManager &operator=(const GameManager &) = delete; + GameManager(GameManager &&) = delete; + GameManager &operator=(GameManager &&) = delete; + ~GameManager() final; + + private: + void tear_down() final; + + Td *td_; + ActorShared<> parent_; +}; + +} // namespace td diff --git a/td/telegram/Global.h b/td/telegram/Global.h index b40bb6552..18540a79e 100644 --- a/td/telegram/Global.h +++ b/td/telegram/Global.h @@ -38,6 +38,7 @@ class ConnectionCreator; class ContactsManager; class FileManager; class FileReferenceManager; +class GameManager; class GroupCallManager; class LanguagePackManager; class LinkManager; @@ -218,6 +219,13 @@ class Global final : public ActorContext { file_reference_manager_ = std::move(file_reference_manager); } + ActorId game_manager() const { + return game_manager_; + } + void set_game_manager(ActorId game_manager) { + game_manager_ = game_manager; + } + ActorId group_call_manager() const { return group_call_manager_; } @@ -409,6 +417,7 @@ class Global final : public ActorContext { ActorId contacts_manager_; ActorId file_manager_; ActorId file_reference_manager_; + ActorId game_manager_; ActorId group_call_manager_; ActorId language_pack_manager_; ActorId link_manager_; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 89deeaed2..b3e2d76fa 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -43,6 +43,7 @@ #include "td/telegram/files/FileType.h" #include "td/telegram/FolderId.h" #include "td/telegram/FullMessageId.h" +#include "td/telegram/GameManager.h" #include "td/telegram/Global.h" #include "td/telegram/GroupCallId.h" #include "td/telegram/GroupCallManager.h" @@ -3652,6 +3653,8 @@ void Td::dec_actor_refcnt() { LOG(DEBUG) << "FileManager was cleared" << timer; file_reference_manager_.reset(); LOG(DEBUG) << "FileReferenceManager was cleared" << timer; + game_manager_.reset(); + LOG(DEBUG) << "GameManager was cleared" << timer; group_call_manager_.reset(); LOG(DEBUG) << "GroupCallManager was cleared" << timer; inline_queries_manager_.reset(); @@ -3842,6 +3845,8 @@ void Td::clear() { LOG(DEBUG) << "FileManager actor was cleared" << timer; file_reference_manager_actor_.reset(); LOG(DEBUG) << "FileReferenceManager actor was cleared" << timer; + game_manager_actor_.reset(); + LOG(DEBUG) << "GameManager actor was cleared" << timer; group_call_manager_actor_.reset(); LOG(DEBUG) << "GroupCallManager actor was cleared" << timer; inline_queries_manager_actor_.reset(); @@ -4291,6 +4296,9 @@ void Td::init_managers() { G()->set_contacts_manager(contacts_manager_actor_.get()); country_info_manager_ = make_unique(this, create_reference()); country_info_manager_actor_ = register_actor("CountryInfoManager", country_info_manager_.get()); + game_manager_ = make_unique(this, create_reference()); + game_manager_actor_ = register_actor("GameManager", game_manager_.get()); + G()->set_game_manager(game_manager_actor_.get()); group_call_manager_ = make_unique(this, create_reference()); group_call_manager_actor_ = register_actor("GroupCallManager", group_call_manager_.get()); G()->set_group_call_manager(group_call_manager_actor_.get()); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index cce4b641b..e1d8e482d 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -51,6 +51,7 @@ class DeviceTokenManager; class DocumentsManager; class FileManager; class FileReferenceManager; +class GameManager; class GroupCallManager; class InlineQueriesManager; class HashtagHints; @@ -158,6 +159,8 @@ class Td final : public NetQueryCallback { ActorOwn file_manager_actor_; unique_ptr file_reference_manager_; ActorOwn file_reference_manager_actor_; + unique_ptr game_manager_; + ActorOwn game_manager_actor_; unique_ptr group_call_manager_; ActorOwn group_call_manager_actor_; unique_ptr inline_queries_manager_;