// // 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/telegram/SendCodeHelper.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" #include "td/actor/actor.h" #include "td/utils/common.h" #include "td/utils/Status.h" namespace td { class Td; class PhoneNumberManager final : public Actor { public: PhoneNumberManager(Td *td, ActorShared<> parent); enum class Type : int32 { ChangePhone, VerifyPhone, ConfirmPhone }; void set_phone_number(Type type, string phone_number, td_api::object_ptr settings, Promise> &&promise); void set_phone_number_and_hash(string hash, string phone_number, td_api::object_ptr settings, Promise> &&promise); void resend_authentication_code(Promise> &&promise); void check_code(string code, Promise &&promise); private: enum class State : int32 { Ok, WaitCode } state_ = State::Ok; void tear_down() final; void inc_generation(); void send_new_send_code_query(const telegram_api::Function &send_code, Promise> &&promise); void on_send_code_result(Result> r_sent_code, int64 generation, Promise> &&promise); void on_check_code_result(Result result, int64 generation, Promise &&promise); Td *td_; ActorShared<> parent_; Type type_; SendCodeHelper send_code_helper_; int64 generation_ = 0; }; } // namespace td