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"
|
2021-10-18 15:48:46 +00:00
|
|
|
#include "ui/widgets/sent_code_field.h"
|
2016-07-28 17:01:08 +00:00
|
|
|
|
2016-11-11 13:46:04 +00:00
|
|
|
namespace Ui {
|
2021-10-18 22:43:50 +00:00
|
|
|
|
2016-11-16 10:44:06 +00:00
|
|
|
class FlatLabel;
|
2016-11-11 13:46:04 +00:00
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
class ConfirmPhoneBox final : public Ui::BoxContent {
|
2016-07-28 17:01:08 +00:00
|
|
|
public:
|
2021-10-18 19:49:42 +00:00
|
|
|
ConfirmPhoneBox(
|
|
|
|
QWidget*,
|
2020-06-11 16:09:46 +00:00
|
|
|
const QString &phone,
|
2021-10-18 19:49:42 +00:00
|
|
|
int codeLength,
|
|
|
|
std::optional<int> timeout);
|
|
|
|
|
|
|
|
[[nodiscard]] rpl::producer<QString> checkRequests() const;
|
|
|
|
[[nodiscard]] rpl::producer<> resendRequests() const;
|
2016-07-28 17:01:08 +00:00
|
|
|
|
2021-10-18 19:49:42 +00:00
|
|
|
void callDone();
|
|
|
|
void showServerError(const QString &text);
|
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:
|
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();
|
|
|
|
|
2021-10-18 19:49:42 +00:00
|
|
|
QString getPhone() const;
|
2016-07-28 17:01:08 +00:00
|
|
|
void showError(const QString &error);
|
|
|
|
|
2016-07-29 10:05:00 +00:00
|
|
|
// _hash from the link for account.sendConfirmPhoneCode call.
|
|
|
|
// _phoneHash from auth.sentCode for account.confirmPhone call.
|
2021-10-18 19:49:42 +00:00
|
|
|
const QString _phone;
|
2016-07-28 17:01:08 +00:00
|
|
|
|
|
|
|
// If we receive the code length, we autosubmit _code field when enough symbols is typed.
|
2021-10-18 19:49:42 +00:00
|
|
|
const int _sentCodeLength = 0;
|
2016-07-28 17:01:08 +00:00
|
|
|
|
2021-10-18 19:49:42 +00:00
|
|
|
bool _isWaitingCheck = false;
|
2016-07-28 17:01:08 +00:00
|
|
|
|
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
|
|
|
|
2021-10-18 19:49:42 +00:00
|
|
|
rpl::event_stream<QString> _checkRequests;
|
|
|
|
rpl::event_stream<> _resendRequests;
|
|
|
|
|
2016-07-28 17:01:08 +00:00
|
|
|
};
|
2021-10-18 22:43:50 +00:00
|
|
|
|
|
|
|
} // namespace Ui
|