tdlight/td/telegram/PhoneNumberManager.h

59 lines
1.8 KiB
C
Raw Normal View History

//
2024-01-01 01:07:21 +01:00
// 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"
2021-10-20 09:46:01 +02:00
#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);
void set_phone_number(string phone_number, td_api::object_ptr<td_api::phoneNumberAuthenticationSettings> settings,
td_api::object_ptr<td_api::PhoneNumberCodeType> type,
Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise);
void resend_authentication_code(Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise);
void check_code(string code, Promise<Unit> &&promise);
private:
enum class Type : int32 { ChangePhone, VerifyPhone, ConfirmPhone };
enum class State : int32 { Ok, WaitCode } state_ = State::Ok;
2021-10-20 09:46:01 +02:00
void tear_down() final;
void inc_generation();
2021-10-20 09:46:01 +02:00
void send_new_send_code_query(const telegram_api::Function &send_code,
Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise);
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
void on_check_code_result(Result<Unit> result, int64 generation, Promise<Unit> &&promise);
2021-10-20 09:46:01 +02:00
Td *td_;
ActorShared<> parent_;
2021-10-20 09:46:01 +02:00
Type type_;
SendCodeHelper send_code_helper_;
int64 generation_ = 0;
};
} // namespace td