Add AutosaveManager.

This commit is contained in:
levlam 2023-02-03 10:41:31 +03:00
parent 5ed796cd57
commit 216b6e1acf
7 changed files with 71 additions and 0 deletions

View File

@ -289,6 +289,7 @@ set(TDLIB_SOURCE
td/telegram/AudiosManager.cpp
td/telegram/AuthManager.cpp
td/telegram/AutoDownloadSettings.cpp
td/telegram/AutosaveManager.cpp
td/telegram/BackgroundManager.cpp
td/telegram/BackgroundType.cpp
td/telegram/BotCommand.cpp
@ -513,6 +514,7 @@ set(TDLIB_SOURCE
td/telegram/AudiosManager.h
td/telegram/AuthManager.h
td/telegram/AutoDownloadSettings.h
td/telegram/AutosaveManager.h
td/telegram/BackgroundId.h
td/telegram/BackgroundManager.h
td/telegram/BackgroundType.h

View File

@ -280,6 +280,7 @@ function split_file($file, $chunks, $undo) {
'attach_menu_manager[_(-][^.]|AttachMenuManager[^;>]' => "AttachMenuManager",
'audios_manager[_(-][^.]|AudiosManager' => "AudiosManager",
'auth_manager[_(-][^.]|AuthManager' => 'AuthManager',
'autosave_manager[_(-][^.]|AutosaveManager' => 'AutosaveManager',
'background_manager[_(-][^.]|BackgroundManager' => "BackgroundManager",
'contacts_manager[_(-][^.]|ContactsManager([^ ;.]| [^*])' => 'ContactsManager',
'country_info_manager[_(-][^.]|CountryInfoManager' => 'CountryInfoManager',

View File

@ -0,0 +1,20 @@
//
// 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/AutosaveManager.h"
#include "td/telegram/Td.h"
namespace td {
AutosaveManager::AutosaveManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
}
void AutosaveManager::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 AutosaveManager final : public Actor {
public:
AutosaveManager(Td *td, ActorShared<> parent);
private:
void tear_down() final;
Td *td_;
ActorShared<> parent_;
};
} // namespace td

View File

@ -34,6 +34,7 @@ namespace td {
class AnimationsManager;
class AttachMenuManager;
class AuthManager;
class AutosaveManager;
class BackgroundManager;
class CallManager;
class ConfigManager;
@ -204,6 +205,13 @@ class Global final : public ActorContext {
auth_manager_ = auth_manager;
}
ActorId<AutosaveManager> autosave_manager() const {
return autosave_manager_;
}
void set_autosave_manager(ActorId<AutosaveManager> autosave_manager) {
autosave_manager_ = autosave_manager;
}
ActorId<BackgroundManager> background_manager() const {
return background_manager_;
}
@ -475,6 +483,7 @@ class Global final : public ActorContext {
ActorId<AnimationsManager> animations_manager_;
ActorId<AttachMenuManager> attach_menu_manager_;
ActorId<AuthManager> auth_manager_;
ActorId<AutosaveManager> autosave_manager_;
ActorId<BackgroundManager> background_manager_;
ActorId<CallManager> call_manager_;
ActorId<ConfigManager> config_manager_;

View File

@ -13,6 +13,7 @@
#include "td/telegram/AudiosManager.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/AutoDownloadSettings.h"
#include "td/telegram/AutosaveManager.h"
#include "td/telegram/BackgroundId.h"
#include "td/telegram/BackgroundManager.h"
#include "td/telegram/BackgroundType.h"
@ -3196,6 +3197,8 @@ void Td::dec_actor_refcnt() {
LOG(DEBUG) << "AudiosManager was cleared" << timer;
auth_manager_.reset();
LOG(DEBUG) << "AuthManager was cleared" << timer;
autosave_manager_.reset();
LOG(DEBUG) << "AutosaveManager was cleared" << timer;
background_manager_.reset();
LOG(DEBUG) << "BackgroundManager was cleared" << timer;
callback_queries_manager_.reset();
@ -3394,6 +3397,8 @@ void Td::clear() {
LOG(DEBUG) << "AttachMenuManager actor was cleared" << timer;
auth_manager_actor_.reset();
LOG(DEBUG) << "AuthManager actor was cleared" << timer;
autosave_manager_actor_.reset();
LOG(DEBUG) << "AutosaveManager actor was cleared" << timer;
background_manager_actor_.reset();
LOG(DEBUG) << "BackgroundManager actor was cleared" << timer;
contacts_manager_actor_.reset();
@ -3857,6 +3862,9 @@ void Td::init_managers() {
attach_menu_manager_ = make_unique<AttachMenuManager>(this, create_reference());
attach_menu_manager_actor_ = register_actor("AttachMenuManager", attach_menu_manager_.get());
G()->set_attach_menu_manager(attach_menu_manager_actor_.get());
autosave_manager_ = make_unique<AutosaveManager>(this, create_reference());
autosave_manager_actor_ = register_actor("AutosaveManager", autosave_manager_.get());
G()->set_autosave_manager(autosave_manager_actor_.get());
background_manager_ = make_unique<BackgroundManager>(this, create_reference());
background_manager_actor_ = register_actor("BackgroundManager", background_manager_.get());
G()->set_background_manager(background_manager_actor_.get());

View File

@ -42,6 +42,7 @@ class AnimationsManager;
class AttachMenuManager;
class AudiosManager;
class AuthManager;
class AutosaveManager;
class BackgroundManager;
class CallManager;
class CallbackQueriesManager;
@ -144,6 +145,8 @@ class Td final : public Actor {
ActorOwn<AttachMenuManager> attach_menu_manager_actor_;
unique_ptr<AuthManager> auth_manager_;
ActorOwn<AuthManager> auth_manager_actor_;
unique_ptr<AutosaveManager> autosave_manager_;
ActorOwn<AutosaveManager> autosave_manager_actor_;
unique_ptr<BackgroundManager> background_manager_;
ActorOwn<BackgroundManager> background_manager_actor_;
unique_ptr<ContactsManager> contacts_manager_;