tdlight/td/telegram/PhoneNumberManager.h

77 lines
2.2 KiB
C
Raw Normal View History

//
2021-01-01 13:57:46 +01:00
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
//
// 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/net/NetActor.h"
#include "td/telegram/net/NetQuery.h"
#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 PhoneNumberManager final : public NetActor {
public:
enum class Type : int32 { ChangePhone, VerifyPhone, ConfirmPhone };
PhoneNumberManager(Type type, ActorShared<> parent);
void get_state(uint64 query_id);
using Settings = td_api::object_ptr<td_api::phoneNumberAuthenticationSettings>;
void set_phone_number(uint64 query_id, string phone_number, Settings settings);
void set_phone_number_and_hash(uint64 query_id, string hash, string phone_number, Settings settings);
void resend_authentication_code(uint64 query_id);
void check_code(uint64 query_id, string code);
private:
Type type_;
enum class State : int32 { Ok, WaitCode } state_ = State::Ok;
enum class NetQueryType : int32 { None, SendCode, CheckCode };
ActorShared<> parent_;
uint64 query_id_ = 0;
uint64 net_query_id_ = 0;
NetQueryType net_query_type_;
SendCodeHelper send_code_helper_;
void on_new_query(uint64 query_id);
2021-10-20 09:46:01 +02:00
void on_query_ok();
void on_query_error(Status status);
2021-10-20 09:46:01 +02:00
2021-10-19 17:11:16 +02:00
static void on_query_error(uint64 id, Status status);
2021-10-20 09:46:01 +02:00
void start_net_query(NetQueryType net_query_type, NetQueryPtr net_query);
2021-10-29 14:38:39 +02:00
void send_new_send_code_query(uint64 query_id, const telegram_api::Function &send_code);
2021-10-29 14:38:39 +02:00
void send_new_check_code_query(const telegram_api::Function &check_code);
2021-10-20 09:46:01 +02:00
void process_check_code_result(Result<tl_object_ptr<telegram_api::User>> &&result);
void process_check_code_result(Result<bool> &&result);
2021-07-03 22:51:36 +02:00
void on_result(NetQueryPtr result) final;
2021-10-20 09:46:01 +02:00
void on_send_code_result(NetQueryPtr &result);
void on_check_code_result(NetQueryPtr &result);
2021-07-03 22:51:36 +02:00
void tear_down() final;
};
} // namespace td