tdesktop/Telegram/SourceFiles/boxes/confirm_phone_box.h

91 lines
2.0 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
2017-04-06 14:38:10 +00:00
#include "boxes/abstract_box.h"
#include "base/timer.h"
#include "ui/widgets/input_fields.h"
2021-10-18 15:48:46 +00:00
#include "ui/widgets/sent_code_field.h"
#include "mtproto/sender.h"
namespace Ui {
class InputField;
class FlatLabel;
} // namespace Ui
namespace Main {
class Session;
} // namespace Main
class ConfirmPhoneBox final : public Ui::BoxContent {
public:
static void Start(
not_null<Main::Session*> session,
const QString &phone,
const QString &hash);
[[nodiscard]] Main::Session &session() const {
return *_session;
}
protected:
void prepare() override;
void setInnerFocus() override;
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
private:
ConfirmPhoneBox(
QWidget*,
not_null<Main::Session*> session,
const QString &phone,
const QString &hash);
friend class object_ptr<ConfirmPhoneBox>;
void sendCode();
void sendCall();
void checkPhoneAndHash();
void sendCodeDone(const MTPauth_SentCode &result);
2021-03-12 12:48:00 +00:00
void sendCodeFail(const MTP::Error &error);
void callDone(const MTPauth_SentCode &result);
void confirmDone(const MTPBool &result);
2021-03-12 12:48:00 +00:00
void confirmFail(const MTP::Error &error);
QString getPhone() const {
return _phone;
}
void launch();
void showError(const QString &error);
const not_null<Main::Session*> _session;
MTP::Sender _api;
mtpRequestId _sendCodeRequestId = 0;
// _hash from the link for account.sendConfirmPhoneCode call.
// _phoneHash from auth.sentCode for account.confirmPhone call.
QString _phone, _hash;
QString _phoneHash;
// If we receive the code length, we autosubmit _code field when enough symbols is typed.
int _sentCodeLength = 0;
mtpRequestId _checkCodeRequestId = 0;
object_ptr<Ui::FlatLabel> _about = { nullptr };
2021-10-18 15:48:46 +00:00
object_ptr<Ui::SentCodeField> _code = { nullptr };
QString _error;
2021-10-18 15:48:46 +00:00
Ui::SentCodeCall _call;
};