From d946ab92673de0492b4c9e8880fc0f7165350813 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 25 May 2021 02:24:30 +0300 Subject: [PATCH] Add empty LinkManager. --- CMakeLists.txt | 2 ++ SplitSource.php | 1 + td/telegram/LinkManager.cpp | 22 ++++++++++++++++++++++ td/telegram/LinkManager.h | 34 ++++++++++++++++++++++++++++++++++ td/telegram/Td.cpp | 7 +++++++ td/telegram/Td.h | 3 +++ td/telegram/misc.h | 2 +- 7 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 td/telegram/LinkManager.cpp create mode 100644 td/telegram/LinkManager.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c783f0cd..dccd12c66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -331,6 +331,7 @@ set(TDLIB_SOURCE td/telegram/InputMessageText.cpp td/telegram/JsonValue.cpp td/telegram/LanguagePackManager.cpp + td/telegram/LinkManager.cpp td/telegram/Location.cpp td/telegram/logevent/LogEventHelper.cpp td/telegram/Logging.cpp @@ -512,6 +513,7 @@ set(TDLIB_SOURCE td/telegram/InputMessageText.h td/telegram/JsonValue.h td/telegram/LanguagePackManager.h + td/telegram/LinkManager.h td/telegram/Location.h td/telegram/logevent/LogEvent.h td/telegram/logevent/LogEventHelper.h diff --git a/SplitSource.php b/SplitSource.php index 2b65aaa6f..6a2f24f22 100644 --- a/SplitSource.php +++ b/SplitSource.php @@ -290,6 +290,7 @@ function split_file($file, $chunks, $undo) { 'HashtagHints' => 'HashtagHints', 'inline_queries_manager[_(-][^.]|InlineQueriesManager' => 'InlineQueriesManager', 'language_pack_manager[_(-][^.]|LanguagePackManager' => 'LanguagePackManager', + 'link_manager[_(-][^.]|LinkManager' => 'LinkManager', 'LogeventIdWithGeneration|add_log_event|delete_log_event|get_erase_log_event_promise|parse_time|store_time' => 'logevent/LogEventHelper', 'MessageCopyOptions' => 'MessageCopyOptions', 'messages_manager[_(-][^.]|MessagesManager' => 'MessagesManager', diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp new file mode 100644 index 000000000..026cf1151 --- /dev/null +++ b/td/telegram/LinkManager.cpp @@ -0,0 +1,22 @@ +// +// 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/LinkManager.h" + +#include "td/telegram/Td.h" + +namespace td { + +LinkManager::LinkManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) { +} + +LinkManager::~LinkManager() = default; + +void LinkManager::tear_down() { + parent_.reset(); +} + +} // namespace td diff --git a/td/telegram/LinkManager.h b/td/telegram/LinkManager.h new file mode 100644 index 000000000..d9dced6b0 --- /dev/null +++ b/td/telegram/LinkManager.h @@ -0,0 +1,34 @@ +// +// 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" + +#include "td/utils/common.h" + +namespace td { + +class Td; + +class LinkManager : public Actor { + public: + LinkManager(Td *td, ActorShared<> parent); + + LinkManager(const LinkManager &) = delete; + LinkManager &operator=(const LinkManager &) = delete; + LinkManager(LinkManager &&) = delete; + LinkManager &operator=(LinkManager &&) = delete; + ~LinkManager() override; + + private: + void tear_down() override; + + Td *td_; + ActorShared<> parent_; +}; + +} // namespace td diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 0c2cc44ba..84d7ad7d1 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -49,6 +49,7 @@ #include "td/telegram/InlineQueriesManager.h" #include "td/telegram/JsonValue.h" #include "td/telegram/LanguagePackManager.h" +#include "td/telegram/LinkManager.h" #include "td/telegram/Location.h" #include "td/telegram/Logging.h" #include "td/telegram/MessageCopyOptions.h" @@ -3816,6 +3817,8 @@ void Td::dec_actor_refcnt() { LOG(DEBUG) << "GroupCallManager was cleared" << timer; inline_queries_manager_.reset(); LOG(DEBUG) << "InlineQueriesManager was cleared" << timer; + link_manager_.reset(); + LOG(DEBUG) << "LinkManager was cleared" << timer; messages_manager_.reset(); LOG(DEBUG) << "MessagesManager was cleared" << timer; notification_manager_.reset(); @@ -4002,6 +4005,8 @@ void Td::clear() { LOG(DEBUG) << "GroupCallManager actor was cleared" << timer; inline_queries_manager_actor_.reset(); LOG(DEBUG) << "InlineQueriesManager actor was cleared" << timer; + link_manager_actor_.reset(); + LOG(DEBUG) << "LinkManager actor was cleared" << timer; messages_manager_actor_.reset(); // TODO: Stop silent LOG(DEBUG) << "MessagesManager actor was cleared" << timer; notification_manager_actor_.reset(); @@ -4438,6 +4443,8 @@ void Td::init_managers() { G()->set_group_call_manager(group_call_manager_actor_.get()); inline_queries_manager_ = make_unique(this, create_reference()); inline_queries_manager_actor_ = register_actor("InlineQueriesManager", inline_queries_manager_.get()); + link_manager_ = make_unique(this, create_reference()); + link_manager_actor_ = register_actor("LinkManager", link_manager_.get()); messages_manager_ = make_unique(this, create_reference()); messages_manager_actor_ = register_actor("MessagesManager", messages_manager_.get()); G()->set_messages_manager(messages_manager_actor_.get()); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 196a16526..3aaa4e380 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -55,6 +55,7 @@ class GroupCallManager; class InlineQueriesManager; class HashtagHints; class LanguagePackManager; +class LinkManager; class MessagesManager; class NetStatsManager; class NotificationManager; @@ -164,6 +165,8 @@ class Td final : public NetQueryCallback { ActorOwn group_call_manager_actor_; unique_ptr inline_queries_manager_; ActorOwn inline_queries_manager_actor_; + unique_ptr link_manager_; + ActorOwn link_manager_actor_; unique_ptr messages_manager_; ActorOwn messages_manager_actor_; unique_ptr notification_manager_; diff --git a/td/telegram/misc.h b/td/telegram/misc.h index a2e993c4c..9c16e6cc0 100644 --- a/td/telegram/misc.h +++ b/td/telegram/misc.h @@ -36,7 +36,7 @@ int32 get_vector_hash(const vector &numbers) TD_WARN_UNUSED_RESULT; // returns emoji corresponding to the specified number string get_emoji_fingerprint(uint64 num); -// checks whether url is a valid tg, ton or HTTP(S) URL and returns its in a canonical form +// checks whether url is a valid tg, ton or HTTP(S) URL and returns it in a canonical form Result check_url(Slice url); // removes all emoji modifiers