Add AccountManager.

This commit is contained in:
levlam 2023-09-08 16:19:30 +03:00
parent 66793cf2f5
commit 162b5cc636
7 changed files with 78 additions and 0 deletions

View File

@ -286,6 +286,7 @@ set(TDLIB_SOURCE
td/mtproto/utils.cpp
td/telegram/Account.cpp
td/telegram/AccountManager.cpp
td/telegram/AnimationsManager.cpp
td/telegram/Application.cpp
td/telegram/AttachMenuManager.cpp
@ -536,6 +537,7 @@ set(TDLIB_SOURCE
td/telegram/AccessRights.h
td/telegram/Account.h
td/telegram/AccountManager.h
td/telegram/AffectedHistory.h
td/telegram/AnimationsManager.h
td/telegram/Application.h

View File

@ -276,6 +276,7 @@ function split_file($file, $chunks, $undo) {
if (!preg_match('/Td::~?Td/', $new_content)) { // destructor Td::~Td needs to see definitions of all forward-declared classes
$td_methods = array(
'account_manager[_(-][^.]|AccountManager[^;>]' => "AccountManager",
'animations_manager[_(-][^.]|AnimationsManager[^;>]' => "AnimationsManager",
'attach_menu_manager[_(-][^.]|AttachMenuManager[^;>]' => "AttachMenuManager",
'audios_manager[_(-][^.]|AudiosManager' => "AudiosManager",

View File

@ -0,0 +1,21 @@
//
// 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/AccountManager.h"
namespace td {
AccountManager::AccountManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
}
void AccountManager::tear_down() {
parent_.reset();
}
void AccountManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
}
} // namespace td

View File

@ -0,0 +1,32 @@
//
// 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/telegram/td_api.h"
#include "td/actor/actor.h"
#include "td/utils/common.h"
namespace td {
class Td;
class AccountManager final : public Actor {
public:
AccountManager(Td *td, ActorShared<> parent);
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
private:
void tear_down() final;
Td *td_;
ActorShared<> parent_;
};
} // namespace td

View File

@ -30,6 +30,7 @@
namespace td {
class AccountManager;
class AnimationsManager;
class AttachMenuManager;
class AuthManager;
@ -184,6 +185,13 @@ class Global final : public ActorContext {
return td_;
}
ActorId<AccountManager> account_manager() const {
return account_manager_;
}
void set_account_manager(ActorId<AccountManager> account_manager) {
account_manager_ = account_manager;
}
ActorId<AnimationsManager> animations_manager() const {
return animations_manager_;
}
@ -517,6 +525,7 @@ class Global final : public ActorContext {
unique_ptr<TdDb> td_db_;
ActorId<Td> td_;
ActorId<AccountManager> account_manager_;
ActorId<AnimationsManager> animations_manager_;
ActorId<AttachMenuManager> attach_menu_manager_;
ActorId<AuthManager> auth_manager_;

View File

@ -7,6 +7,7 @@
#include "td/telegram/Td.h"
#include "td/telegram/Account.h"
#include "td/telegram/AccountManager.h"
#include "td/telegram/AnimationsManager.h"
#include "td/telegram/Application.h"
#include "td/telegram/AttachMenuManager.h"
@ -3228,6 +3229,8 @@ void Td::dec_actor_refcnt() {
} else if (close_flag_ == 3) {
LOG(INFO) << "All actors were closed";
Timer timer;
account_manager_.reset();
LOG(DEBUG) << "AccountManager was cleared" << timer;
animations_manager_.reset();
LOG(DEBUG) << "AnimationsManager was cleared" << timer;
attach_menu_manager_.reset();
@ -3438,6 +3441,8 @@ void Td::clear() {
LOG(DEBUG) << "TempAuthKeyWatchdog was cleared" << timer;
// clear actors which are unique pointers
account_manager_actor_.reset();
LOG(DEBUG) << "AccountManager actor was cleared" << timer;
animations_manager_actor_.reset();
LOG(DEBUG) << "AnimationsManager actor was cleared" << timer;
attach_menu_manager_actor_.reset();
@ -3914,6 +3919,9 @@ void Td::init_managers() {
documents_manager_ = make_unique<DocumentsManager>(this);
videos_manager_ = make_unique<VideosManager>(this);
account_manager_ = make_unique<AccountManager>(this, create_reference());
account_manager_actor_ = register_actor("AccountManager", account_manager_.get());
G()->set_account_manager(account_manager_actor_.get());
animations_manager_ = make_unique<AnimationsManager>(this, create_reference());
animations_manager_actor_ = register_actor("AnimationsManager", animations_manager_.get());
G()->set_animations_manager(animations_manager_actor_.get());
@ -4360,6 +4368,8 @@ void Td::on_request(uint64 id, const td_api::getCurrentState &request) {
autosave_manager_->get_current_state(updates);
account_manager_->get_current_state(updates);
// TODO updateFileGenerationStart generation_id:int64 original_path:string destination_path:string conversion:string = Update;
// TODO updateCall call:call = Update;
// TODO updateGroupCall call:groupCall = Update;

View File

@ -37,6 +37,7 @@
namespace td {
class AccountManager;
class AnimationsManager;
class AttachMenuManager;
class AudiosManager;
@ -148,6 +149,8 @@ class Td final : public Actor {
unique_ptr<OptionManager> option_manager_;
unique_ptr<VideosManager> videos_manager_;
unique_ptr<AccountManager> account_manager_;
ActorOwn<AccountManager> account_manager_actor_;
unique_ptr<AnimationsManager> animations_manager_;
ActorOwn<AnimationsManager> animations_manager_actor_;
unique_ptr<AttachMenuManager> attach_menu_manager_;