From e6039ee30896c4e772ae6ebedd2134c21ed7a967 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 15 Aug 2024 18:26:01 +0300 Subject: [PATCH] Add AlarmManager. --- CMakeLists.txt | 2 ++ SplitSource.php | 1 + td/telegram/AlarmManager.cpp | 18 ++++++++++++++++++ td/telegram/AlarmManager.h | 27 +++++++++++++++++++++++++++ td/telegram/Td.cpp | 4 ++++ td/telegram/Td.h | 2 ++ 6 files changed, 54 insertions(+) create mode 100644 td/telegram/AlarmManager.cpp create mode 100644 td/telegram/AlarmManager.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b58a33ae2..4331f712c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -320,6 +320,7 @@ set(TD_MTPROTO_SOURCE set(TDLIB_SOURCE_PART1 td/telegram/AccountManager.cpp + td/telegram/AlarmManager.cpp td/telegram/AnimationsManager.cpp td/telegram/Application.cpp td/telegram/AttachMenuManager.cpp @@ -607,6 +608,7 @@ set(TDLIB_SOURCE_PART2 td/telegram/AccessRights.h td/telegram/AccountManager.h td/telegram/AffectedHistory.h + td/telegram/AlarmManager.h td/telegram/AnimationsManager.h td/telegram/Application.h td/telegram/AttachMenuManager.h diff --git a/SplitSource.php b/SplitSource.php index 51e2160de..c1301b01c 100644 --- a/SplitSource.php +++ b/SplitSource.php @@ -296,6 +296,7 @@ function split_file($file, $chunks, $undo) { $td_methods = array( 'AccentColorId' => 'AccentColorId', 'account_manager[_(-](?![.]get[(][)])|AccountManager[^;>]' => 'AccountManager', + 'alarm_manager[_(-](?![.]get[(][)])|AlarmManager' => 'AlarmManager', 'animations_manager[_(-](?![.]get[(][)])|AnimationsManager[^;>]' => 'AnimationsManager', 'attach_menu_manager[_(-](?![.]get[(][)])|AttachMenuManager[^;>]' => 'AttachMenuManager', 'audios_manager[_(-](?![.]get[(][)])|AudiosManager' => 'AudiosManager', diff --git a/td/telegram/AlarmManager.cpp b/td/telegram/AlarmManager.cpp new file mode 100644 index 000000000..f0cccd898 --- /dev/null +++ b/td/telegram/AlarmManager.cpp @@ -0,0 +1,18 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024 +// +// 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/AlarmManager.h" + +namespace td { + +AlarmManager::AlarmManager(ActorShared<> parent) : parent_(std::move(parent)) { +} + +void AlarmManager::tear_down() { + parent_.reset(); +} + +} // namespace td diff --git a/td/telegram/AlarmManager.h b/td/telegram/AlarmManager.h new file mode 100644 index 000000000..b4e65cca3 --- /dev/null +++ b/td/telegram/AlarmManager.h @@ -0,0 +1,27 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024 +// +// 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 AlarmManager final : public Actor { + public: + explicit AlarmManager(ActorShared<> parent); + + private: + void tear_down() final; + + ActorShared<> parent_; +}; + +} // namespace td diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 7be4d8e09..419083c11 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7,6 +7,7 @@ #include "td/telegram/Td.h" #include "td/telegram/AccountManager.h" +#include "td/telegram/AlarmManager.h" #include "td/telegram/AnimationsManager.h" #include "td/telegram/Application.h" #include "td/telegram/AttachMenuManager.h" @@ -453,6 +454,8 @@ void Td::start_up() { inc_request_actor_refcnt(); // guard inc_actor_refcnt(); // guard + alarm_manager_ = create_actor("AlarmManager", create_reference()); + alarm_timeout_.set_callback(on_alarm_timeout_callback); alarm_timeout_.set_callback_data(static_cast(this)); @@ -670,6 +673,7 @@ void Td::clear() { }; // close all pure actors + reset_actor(ActorOwn(std::move(alarm_manager_))); reset_actor(ActorOwn(std::move(call_manager_))); reset_actor(ActorOwn(std::move(cashtag_search_hints_))); reset_actor(ActorOwn(std::move(config_manager_))); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 8034ea2f1..80da879af 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -34,6 +34,7 @@ namespace td { class AccountManager; +class AlarmManager; class AnimationsManager; class AttachMenuManager; class AudiosManager; @@ -272,6 +273,7 @@ class Td final : public Actor { unique_ptr web_pages_manager_; ActorOwn web_pages_manager_actor_; + ActorOwn alarm_manager_; ActorOwn call_manager_; ActorOwn cashtag_search_hints_; ActorOwn config_manager_;