// // 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/Promise.h" #include "td/utils/Status.h" namespace td { class Td; class PhoneNumberManager final : public Actor { public: PhoneNumberManager(Td *td, ActorShared<> parent); void set_phone_number(string phone_number, td_api::object_ptr settings, td_api::object_ptr type, Promise> &&promise); void send_firebase_sms(const string &token, Promise &&promise); void report_missing_code(const string &mobile_network_code, Promise &&promise); void resend_authentication_code(td_api::object_ptr &&reason, Promise> &&promise); void check_code(string code, Promise &&promise); private: enum class Type : int32 { ChangePhone, VerifyPhone, ConfirmPhone }; 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