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