Add DialogFilterManager.

This commit is contained in:
levlam 2023-03-27 11:27:17 +03:00
parent 9a85e4df1c
commit 800258fa57
7 changed files with 70 additions and 0 deletions

View File

@ -322,6 +322,7 @@ set(TDLIB_SOURCE
td/telegram/DialogEventLog.cpp td/telegram/DialogEventLog.cpp
td/telegram/DialogFilter.cpp td/telegram/DialogFilter.cpp
td/telegram/DialogFilterInviteLink.cpp td/telegram/DialogFilterInviteLink.cpp
td/telegram/DialogFilterManager.cpp
td/telegram/DialogId.cpp td/telegram/DialogId.cpp
td/telegram/DialogInviteLink.cpp td/telegram/DialogInviteLink.cpp
td/telegram/DialogLocation.cpp td/telegram/DialogLocation.cpp
@ -561,6 +562,7 @@ set(TDLIB_SOURCE
td/telegram/DialogFilter.h td/telegram/DialogFilter.h
td/telegram/DialogFilterId.h td/telegram/DialogFilterId.h
td/telegram/DialogFilterInviteLink.h td/telegram/DialogFilterInviteLink.h
td/telegram/DialogFilterManager.h
td/telegram/DialogId.h td/telegram/DialogId.h
td/telegram/DialogInviteLink.h td/telegram/DialogInviteLink.h
td/telegram/DialogListId.h td/telegram/DialogListId.h

View File

@ -284,7 +284,9 @@ function split_file($file, $chunks, $undo) {
'background_manager[_(-][^.]|BackgroundManager' => "BackgroundManager", 'background_manager[_(-][^.]|BackgroundManager' => "BackgroundManager",
'contacts_manager[_(-][^.]|ContactsManager([^ ;.]| [^*])' => 'ContactsManager', 'contacts_manager[_(-][^.]|ContactsManager([^ ;.]| [^*])' => 'ContactsManager',
'country_info_manager[_(-][^.]|CountryInfoManager' => 'CountryInfoManager', 'country_info_manager[_(-][^.]|CountryInfoManager' => 'CountryInfoManager',
'dialog_filter_manager[_(-][^.]|DialogFilterManager' => "DialogFilterManager",
'documents_manager[_(-][^.]|DocumentsManager' => "DocumentsManager", 'documents_manager[_(-][^.]|DocumentsManager' => "DocumentsManager",
'download_manager[_(-][^.]|DownloadManager' => "DownloadManager",
'file_reference_manager[_(-][^.]|FileReferenceManager|file_references[)]' => 'FileReferenceManager', 'file_reference_manager[_(-][^.]|FileReferenceManager|file_references[)]' => 'FileReferenceManager',
'file_manager[_(-][^.]|FileManager([^ ;.]| [^*])|update_file[)]' => 'files/FileManager', 'file_manager[_(-][^.]|FileManager([^ ;.]| [^*])|update_file[)]' => 'files/FileManager',
'forum_topic_manager[_(-][^.]|ForumTopicManager' => 'ForumTopicManager', 'forum_topic_manager[_(-][^.]|ForumTopicManager' => 'ForumTopicManager',

View File

@ -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

View File

@ -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

View File

@ -39,6 +39,7 @@ class CallManager;
class ConfigManager; class ConfigManager;
class ConnectionCreator; class ConnectionCreator;
class ContactsManager; class ContactsManager;
class DialogFilterManager;
class DownloadManager; class DownloadManager;
class FileManager; class FileManager;
class FileReferenceManager; class FileReferenceManager;
@ -234,6 +235,13 @@ class Global final : public ActorContext {
contacts_manager_ = contacts_manager; contacts_manager_ = contacts_manager;
} }
ActorId<DialogFilterManager> dialog_filter_manager() const {
return dialog_filter_manager_;
}
void set_dialog_filter_manager(ActorId<DialogFilterManager> dialog_filter_manager) {
dialog_filter_manager_ = std::move(dialog_filter_manager);
}
ActorId<DownloadManager> download_manager() const { ActorId<DownloadManager> download_manager() const {
return download_manager_; return download_manager_;
} }
@ -497,6 +505,7 @@ class Global final : public ActorContext {
ActorId<CallManager> call_manager_; ActorId<CallManager> call_manager_;
ActorId<ConfigManager> config_manager_; ActorId<ConfigManager> config_manager_;
ActorId<ContactsManager> contacts_manager_; ActorId<ContactsManager> contacts_manager_;
ActorId<DialogFilterManager> dialog_filter_manager_;
ActorId<DownloadManager> download_manager_; ActorId<DownloadManager> download_manager_;
ActorId<FileManager> file_manager_; ActorId<FileManager> file_manager_;
ActorId<FileReferenceManager> file_reference_manager_; ActorId<FileReferenceManager> file_reference_manager_;

View File

@ -34,6 +34,7 @@
#include "td/telegram/DialogEventLog.h" #include "td/telegram/DialogEventLog.h"
#include "td/telegram/DialogFilter.h" #include "td/telegram/DialogFilter.h"
#include "td/telegram/DialogFilterId.h" #include "td/telegram/DialogFilterId.h"
#include "td/telegram/DialogFilterManager.h"
#include "td/telegram/DialogId.h" #include "td/telegram/DialogId.h"
#include "td/telegram/DialogListId.h" #include "td/telegram/DialogListId.h"
#include "td/telegram/DialogLocation.h" #include "td/telegram/DialogLocation.h"
@ -3187,6 +3188,8 @@ void Td::dec_actor_refcnt() {
LOG(DEBUG) << "ContactsManager was cleared" << timer; LOG(DEBUG) << "ContactsManager was cleared" << timer;
country_info_manager_.reset(); country_info_manager_.reset();
LOG(DEBUG) << "CountryInfoManager was cleared" << timer; LOG(DEBUG) << "CountryInfoManager was cleared" << timer;
dialog_filter_manager_.reset();
LOG(DEBUG) << "DialogFilterManager was cleared" << timer;
documents_manager_.reset(); documents_manager_.reset();
LOG(DEBUG) << "DocumentsManager was cleared" << timer; LOG(DEBUG) << "DocumentsManager was cleared" << timer;
download_manager_.reset(); download_manager_.reset();
@ -3385,6 +3388,8 @@ void Td::clear() {
LOG(DEBUG) << "ContactsManager actor was cleared" << timer; LOG(DEBUG) << "ContactsManager actor was cleared" << timer;
country_info_manager_actor_.reset(); country_info_manager_actor_.reset();
LOG(DEBUG) << "CountryInfoManager actor was cleared" << timer; LOG(DEBUG) << "CountryInfoManager actor was cleared" << timer;
dialog_filter_manager_actor_.reset();
LOG(DEBUG) << "DialogFilterManager actor was cleared" << timer;
download_manager_actor_.reset(); download_manager_actor_.reset();
LOG(DEBUG) << "DownloadManager actor was cleared" << timer; LOG(DEBUG) << "DownloadManager actor was cleared" << timer;
file_manager_actor_.reset(); file_manager_actor_.reset();
@ -3858,6 +3863,9 @@ void Td::init_managers() {
G()->set_contacts_manager(contacts_manager_actor_.get()); G()->set_contacts_manager(contacts_manager_actor_.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_filter_manager_ = make_unique<DialogFilterManager>(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<DownloadManagerCallback>(this, create_reference())); download_manager_ = DownloadManager::create(td::make_unique<DownloadManagerCallback>(this, create_reference()));
download_manager_actor_ = register_actor("DownloadManager", download_manager_.get()); download_manager_actor_ = register_actor("DownloadManager", download_manager_.get());
G()->set_download_manager(download_manager_actor_.get()); G()->set_download_manager(download_manager_actor_.get());

View File

@ -49,6 +49,7 @@ class ConfigManager;
class ContactsManager; class ContactsManager;
class CountryInfoManager; class CountryInfoManager;
class DeviceTokenManager; class DeviceTokenManager;
class DialogFilterManager;
class DocumentsManager; class DocumentsManager;
class DownloadManager; class DownloadManager;
class FileManager; class FileManager;
@ -158,6 +159,8 @@ class Td final : public Actor {
ActorOwn<ContactsManager> contacts_manager_actor_; ActorOwn<ContactsManager> contacts_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<DialogFilterManager> dialog_filter_manager_;
ActorOwn<DialogFilterManager> dialog_filter_manager_actor_;
unique_ptr<DownloadManager> download_manager_; unique_ptr<DownloadManager> download_manager_;
ActorOwn<DownloadManager> download_manager_actor_; ActorOwn<DownloadManager> download_manager_actor_;
unique_ptr<FileManager> file_manager_; unique_ptr<FileManager> file_manager_;