From 800258fa573d7e77bb8bfb74eec571bb139afd8c Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 27 Mar 2023 11:27:17 +0300 Subject: [PATCH] Add DialogFilterManager. --- CMakeLists.txt | 2 ++ SplitSource.php | 2 ++ td/telegram/DialogFilterManager.cpp | 18 ++++++++++++++++++ td/telegram/DialogFilterManager.h | 28 ++++++++++++++++++++++++++++ td/telegram/Global.h | 9 +++++++++ td/telegram/Td.cpp | 8 ++++++++ td/telegram/Td.h | 3 +++ 7 files changed, 70 insertions(+) create mode 100644 td/telegram/DialogFilterManager.cpp create mode 100644 td/telegram/DialogFilterManager.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e4ea88c6c..8ab2f6352 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,6 +322,7 @@ set(TDLIB_SOURCE td/telegram/DialogEventLog.cpp td/telegram/DialogFilter.cpp td/telegram/DialogFilterInviteLink.cpp + td/telegram/DialogFilterManager.cpp td/telegram/DialogId.cpp td/telegram/DialogInviteLink.cpp td/telegram/DialogLocation.cpp @@ -561,6 +562,7 @@ set(TDLIB_SOURCE td/telegram/DialogFilter.h td/telegram/DialogFilterId.h td/telegram/DialogFilterInviteLink.h + td/telegram/DialogFilterManager.h td/telegram/DialogId.h td/telegram/DialogInviteLink.h td/telegram/DialogListId.h diff --git a/SplitSource.php b/SplitSource.php index c7263b139..a8065471d 100644 --- a/SplitSource.php +++ b/SplitSource.php @@ -284,7 +284,9 @@ function split_file($file, $chunks, $undo) { 'background_manager[_(-][^.]|BackgroundManager' => "BackgroundManager", 'contacts_manager[_(-][^.]|ContactsManager([^ ;.]| [^*])' => 'ContactsManager', 'country_info_manager[_(-][^.]|CountryInfoManager' => 'CountryInfoManager', + 'dialog_filter_manager[_(-][^.]|DialogFilterManager' => "DialogFilterManager", 'documents_manager[_(-][^.]|DocumentsManager' => "DocumentsManager", + 'download_manager[_(-][^.]|DownloadManager' => "DownloadManager", 'file_reference_manager[_(-][^.]|FileReferenceManager|file_references[)]' => 'FileReferenceManager', 'file_manager[_(-][^.]|FileManager([^ ;.]| [^*])|update_file[)]' => 'files/FileManager', 'forum_topic_manager[_(-][^.]|ForumTopicManager' => 'ForumTopicManager', diff --git a/td/telegram/DialogFilterManager.cpp b/td/telegram/DialogFilterManager.cpp new file mode 100644 index 000000000..42d4b5e1c --- /dev/null +++ b/td/telegram/DialogFilterManager.cpp @@ -0,0 +1,18 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 +// +// 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/DialogFilterManager.h" + +namespace td { + +DialogFilterManager::DialogFilterManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) { +} + +void DialogFilterManager::tear_down() { + parent_.reset(); +} + +} // namespace td diff --git a/td/telegram/DialogFilterManager.h b/td/telegram/DialogFilterManager.h new file mode 100644 index 000000000..00ac26cf3 --- /dev/null +++ b/td/telegram/DialogFilterManager.h @@ -0,0 +1,28 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 +// +// 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 DialogFilterManager final : public Actor { + public: + DialogFilterManager(Td *td, ActorShared<> parent); + + private: + void tear_down() final; + + Td *td_; + ActorShared<> parent_; +}; + +} // namespace td diff --git a/td/telegram/Global.h b/td/telegram/Global.h index 296e43c75..794dcb9e0 100644 --- a/td/telegram/Global.h +++ b/td/telegram/Global.h @@ -39,6 +39,7 @@ class CallManager; class ConfigManager; class ConnectionCreator; class ContactsManager; +class DialogFilterManager; class DownloadManager; class FileManager; class FileReferenceManager; @@ -234,6 +235,13 @@ class Global final : public ActorContext { contacts_manager_ = contacts_manager; } + ActorId dialog_filter_manager() const { + return dialog_filter_manager_; + } + void set_dialog_filter_manager(ActorId dialog_filter_manager) { + dialog_filter_manager_ = std::move(dialog_filter_manager); + } + ActorId download_manager() const { return download_manager_; } @@ -497,6 +505,7 @@ class Global final : public ActorContext { ActorId call_manager_; ActorId config_manager_; ActorId contacts_manager_; + ActorId dialog_filter_manager_; ActorId download_manager_; ActorId file_manager_; ActorId file_reference_manager_; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 9d63b3018..b69288824 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -34,6 +34,7 @@ #include "td/telegram/DialogEventLog.h" #include "td/telegram/DialogFilter.h" #include "td/telegram/DialogFilterId.h" +#include "td/telegram/DialogFilterManager.h" #include "td/telegram/DialogId.h" #include "td/telegram/DialogListId.h" #include "td/telegram/DialogLocation.h" @@ -3187,6 +3188,8 @@ void Td::dec_actor_refcnt() { LOG(DEBUG) << "ContactsManager was cleared" << timer; country_info_manager_.reset(); LOG(DEBUG) << "CountryInfoManager was cleared" << timer; + dialog_filter_manager_.reset(); + LOG(DEBUG) << "DialogFilterManager was cleared" << timer; documents_manager_.reset(); LOG(DEBUG) << "DocumentsManager was cleared" << timer; download_manager_.reset(); @@ -3385,6 +3388,8 @@ void Td::clear() { LOG(DEBUG) << "ContactsManager actor was cleared" << timer; country_info_manager_actor_.reset(); LOG(DEBUG) << "CountryInfoManager actor was cleared" << timer; + dialog_filter_manager_actor_.reset(); + LOG(DEBUG) << "DialogFilterManager actor was cleared" << timer; download_manager_actor_.reset(); LOG(DEBUG) << "DownloadManager actor was cleared" << timer; file_manager_actor_.reset(); @@ -3858,6 +3863,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()); + dialog_filter_manager_ = make_unique(this, create_reference()); + dialog_filter_manager_actor_ = register_actor("DialogFilterManager", dialog_filter_manager_.get()); + G()->set_download_manager(download_manager_actor_.get()); download_manager_ = DownloadManager::create(td::make_unique(this, create_reference())); download_manager_actor_ = register_actor("DownloadManager", download_manager_.get()); G()->set_download_manager(download_manager_actor_.get()); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index f86b15674..25e345a1c 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -49,6 +49,7 @@ class ConfigManager; class ContactsManager; class CountryInfoManager; class DeviceTokenManager; +class DialogFilterManager; class DocumentsManager; class DownloadManager; class FileManager; @@ -158,6 +159,8 @@ class Td final : public Actor { ActorOwn contacts_manager_actor_; unique_ptr country_info_manager_; ActorOwn country_info_manager_actor_; + unique_ptr dialog_filter_manager_; + ActorOwn dialog_filter_manager_actor_; unique_ptr download_manager_; ActorOwn download_manager_actor_; unique_ptr file_manager_;