Add AlarmManager.

This commit is contained in:
levlam 2024-08-15 18:26:01 +03:00
parent 210269a498
commit e6039ee308
6 changed files with 54 additions and 0 deletions

View File

@ -320,6 +320,7 @@ set(TD_MTPROTO_SOURCE
set(TDLIB_SOURCE_PART1 set(TDLIB_SOURCE_PART1
td/telegram/AccountManager.cpp td/telegram/AccountManager.cpp
td/telegram/AlarmManager.cpp
td/telegram/AnimationsManager.cpp td/telegram/AnimationsManager.cpp
td/telegram/Application.cpp td/telegram/Application.cpp
td/telegram/AttachMenuManager.cpp td/telegram/AttachMenuManager.cpp
@ -607,6 +608,7 @@ set(TDLIB_SOURCE_PART2
td/telegram/AccessRights.h td/telegram/AccessRights.h
td/telegram/AccountManager.h td/telegram/AccountManager.h
td/telegram/AffectedHistory.h td/telegram/AffectedHistory.h
td/telegram/AlarmManager.h
td/telegram/AnimationsManager.h td/telegram/AnimationsManager.h
td/telegram/Application.h td/telegram/Application.h
td/telegram/AttachMenuManager.h td/telegram/AttachMenuManager.h

View File

@ -296,6 +296,7 @@ function split_file($file, $chunks, $undo) {
$td_methods = array( $td_methods = array(
'AccentColorId' => 'AccentColorId', 'AccentColorId' => 'AccentColorId',
'account_manager[_(-](?![.]get[(][)])|AccountManager[^;>]' => 'AccountManager', 'account_manager[_(-](?![.]get[(][)])|AccountManager[^;>]' => 'AccountManager',
'alarm_manager[_(-](?![.]get[(][)])|AlarmManager' => 'AlarmManager',
'animations_manager[_(-](?![.]get[(][)])|AnimationsManager[^;>]' => 'AnimationsManager', 'animations_manager[_(-](?![.]get[(][)])|AnimationsManager[^;>]' => 'AnimationsManager',
'attach_menu_manager[_(-](?![.]get[(][)])|AttachMenuManager[^;>]' => 'AttachMenuManager', 'attach_menu_manager[_(-](?![.]get[(][)])|AttachMenuManager[^;>]' => 'AttachMenuManager',
'audios_manager[_(-](?![.]get[(][)])|AudiosManager' => 'AudiosManager', 'audios_manager[_(-](?![.]get[(][)])|AudiosManager' => 'AudiosManager',

View File

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

View File

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

View File

@ -7,6 +7,7 @@
#include "td/telegram/Td.h" #include "td/telegram/Td.h"
#include "td/telegram/AccountManager.h" #include "td/telegram/AccountManager.h"
#include "td/telegram/AlarmManager.h"
#include "td/telegram/AnimationsManager.h" #include "td/telegram/AnimationsManager.h"
#include "td/telegram/Application.h" #include "td/telegram/Application.h"
#include "td/telegram/AttachMenuManager.h" #include "td/telegram/AttachMenuManager.h"
@ -453,6 +454,8 @@ void Td::start_up() {
inc_request_actor_refcnt(); // guard inc_request_actor_refcnt(); // guard
inc_actor_refcnt(); // guard inc_actor_refcnt(); // guard
alarm_manager_ = create_actor<AlarmManager>("AlarmManager", create_reference());
alarm_timeout_.set_callback(on_alarm_timeout_callback); alarm_timeout_.set_callback(on_alarm_timeout_callback);
alarm_timeout_.set_callback_data(static_cast<void *>(this)); alarm_timeout_.set_callback_data(static_cast<void *>(this));
@ -670,6 +673,7 @@ void Td::clear() {
}; };
// close all pure actors // close all pure actors
reset_actor(ActorOwn<Actor>(std::move(alarm_manager_)));
reset_actor(ActorOwn<Actor>(std::move(call_manager_))); reset_actor(ActorOwn<Actor>(std::move(call_manager_)));
reset_actor(ActorOwn<Actor>(std::move(cashtag_search_hints_))); reset_actor(ActorOwn<Actor>(std::move(cashtag_search_hints_)));
reset_actor(ActorOwn<Actor>(std::move(config_manager_))); reset_actor(ActorOwn<Actor>(std::move(config_manager_)));

View File

@ -34,6 +34,7 @@
namespace td { namespace td {
class AccountManager; class AccountManager;
class AlarmManager;
class AnimationsManager; class AnimationsManager;
class AttachMenuManager; class AttachMenuManager;
class AudiosManager; class AudiosManager;
@ -272,6 +273,7 @@ class Td final : public Actor {
unique_ptr<WebPagesManager> web_pages_manager_; unique_ptr<WebPagesManager> web_pages_manager_;
ActorOwn<WebPagesManager> web_pages_manager_actor_; ActorOwn<WebPagesManager> web_pages_manager_actor_;
ActorOwn<AlarmManager> alarm_manager_;
ActorOwn<CallManager> call_manager_; ActorOwn<CallManager> call_manager_;
ActorOwn<HashtagHints> cashtag_search_hints_; ActorOwn<HashtagHints> cashtag_search_hints_;
ActorOwn<ConfigManager> config_manager_; ActorOwn<ConfigManager> config_manager_;