2019-02-16 17:01:47 +01:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2019-02-16 17:01:47 +01:00
|
|
|
//
|
|
|
|
// 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"
|
2019-05-14 16:26:13 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
2021-10-20 09:46:01 +02:00
|
|
|
#include "td/telegram/telegram_api.h"
|
2019-02-16 17:01:47 +01:00
|
|
|
|
|
|
|
#include "td/actor/actor.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2019-02-17 14:52:34 +01:00
|
|
|
#include "td/utils/Status.h"
|
2019-02-16 17:01:47 +01:00
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2024-04-13 18:10:52 +02:00
|
|
|
class Td;
|
|
|
|
|
|
|
|
class PhoneNumberManager final : public Actor {
|
2019-02-16 17:01:47 +01:00
|
|
|
public:
|
2024-04-13 18:10:52 +02:00
|
|
|
PhoneNumberManager(Td *td, ActorShared<> parent);
|
|
|
|
|
2024-04-13 19:25:05 +02:00
|
|
|
void set_phone_number(string phone_number, td_api::object_ptr<td_api::phoneNumberAuthenticationSettings> settings,
|
|
|
|
td_api::object_ptr<td_api::PhoneNumberCodeType> type,
|
2024-04-13 18:10:52 +02:00
|
|
|
Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise);
|
2019-05-03 04:44:59 +02:00
|
|
|
|
2024-04-13 18:10:52 +02:00
|
|
|
void resend_authentication_code(Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise);
|
2019-02-16 17:01:47 +01:00
|
|
|
|
2024-04-13 18:10:52 +02:00
|
|
|
void check_code(string code, Promise<Unit> &&promise);
|
2019-02-16 17:01:47 +01:00
|
|
|
|
2024-04-13 18:10:52 +02:00
|
|
|
private:
|
2024-04-13 19:25:05 +02:00
|
|
|
enum class Type : int32 { ChangePhone, VerifyPhone, ConfirmPhone };
|
2019-02-16 17:01:47 +01:00
|
|
|
enum class State : int32 { Ok, WaitCode } state_ = State::Ok;
|
2021-10-20 09:46:01 +02:00
|
|
|
|
2024-04-13 18:10:52 +02:00
|
|
|
void tear_down() final;
|
2019-02-16 17:01:47 +01:00
|
|
|
|
2024-04-13 18:10:52 +02:00
|
|
|
void inc_generation();
|
2021-10-20 09:46:01 +02:00
|
|
|
|
2024-04-13 18:10:52 +02:00
|
|
|
void send_new_send_code_query(const telegram_api::Function &send_code,
|
|
|
|
Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise);
|
2019-02-16 17:01:47 +01:00
|
|
|
|
2024-04-13 18:10:52 +02:00
|
|
|
void on_send_code_result(Result<telegram_api::object_ptr<telegram_api::auth_sentCode>> r_sent_code, int64 generation,
|
|
|
|
Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise);
|
2021-10-20 09:46:01 +02:00
|
|
|
|
2024-04-13 18:10:52 +02:00
|
|
|
void on_check_code_result(Result<Unit> result, int64 generation, Promise<Unit> &&promise);
|
2021-10-20 09:46:01 +02:00
|
|
|
|
2024-04-13 18:10:52 +02:00
|
|
|
Td *td_;
|
|
|
|
ActorShared<> parent_;
|
2021-10-20 09:46:01 +02:00
|
|
|
|
2024-04-13 18:10:52 +02:00
|
|
|
Type type_;
|
|
|
|
SendCodeHelper send_code_helper_;
|
|
|
|
int64 generation_ = 0;
|
2019-02-16 17:01:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|