2014-05-30 08:53:19 +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.
|
2014-05-30 08:53:19 +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
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-11-26 11:10:44 +00:00
|
|
|
#include "intro/intro_step.h"
|
2019-11-27 09:45:23 +00:00
|
|
|
#include "intro/intro_widget.h"
|
2016-11-15 11:56:49 +00:00
|
|
|
#include "ui/widgets/input_fields.h"
|
2019-11-27 08:33:18 +00:00
|
|
|
#include "base/timer.h"
|
2016-11-11 13:46:04 +00:00
|
|
|
|
2016-11-04 19:50:35 +00:00
|
|
|
namespace Ui {
|
|
|
|
class RoundButton;
|
2016-11-11 13:46:04 +00:00
|
|
|
class LinkButton;
|
2016-11-24 19:28:23 +00:00
|
|
|
class FlatLabel;
|
2016-11-04 19:50:35 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
namespace Intro {
|
2019-11-26 11:10:44 +00:00
|
|
|
namespace details {
|
|
|
|
|
|
|
|
enum class CallStatus;
|
2016-11-24 19:28:23 +00:00
|
|
|
|
|
|
|
class CodeInput final : public Ui::MaskedInputField {
|
2014-05-30 08:53:19 +00:00
|
|
|
public:
|
2019-06-18 14:07:45 +00:00
|
|
|
CodeInput(
|
|
|
|
QWidget *parent,
|
|
|
|
const style::InputField &st,
|
|
|
|
rpl::producer<QString> placeholder);
|
2016-11-24 19:28:23 +00:00
|
|
|
|
|
|
|
void setDigitsCountMax(int digitsCount);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
protected:
|
2016-11-24 19:28:23 +00:00
|
|
|
void correctValue(const QString &was, int wasCursor, QString &now, int &nowCursor) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int _digitsCountMax = 5;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-11-27 08:33:18 +00:00
|
|
|
class CodeWidget final : public Step {
|
2014-05-30 08:53:19 +00:00
|
|
|
public:
|
2019-07-24 08:46:23 +00:00
|
|
|
CodeWidget(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Main::Account*> account,
|
2019-11-26 11:10:44 +00:00
|
|
|
not_null<Data*> data);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-03-21 18:41:39 +00:00
|
|
|
bool hasBack() const override {
|
2014-11-26 16:45:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-11-24 19:28:23 +00:00
|
|
|
void setInnerFocus() override;
|
2016-03-14 16:59:18 +00:00
|
|
|
void activate() override;
|
|
|
|
void finished() override;
|
|
|
|
void cancelled() override;
|
2016-11-24 19:28:23 +00:00
|
|
|
void submit() override;
|
2022-12-28 18:41:38 +00:00
|
|
|
rpl::producer<QString> nextButtonText() const override;
|
|
|
|
const style::RoundButton *nextButtonStyle() const override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-08-31 14:27:20 +00:00
|
|
|
void updateDescText();
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
private:
|
2019-11-27 08:33:18 +00:00
|
|
|
void noTelegramCode();
|
|
|
|
void codeChanged();
|
|
|
|
void sendCall();
|
|
|
|
void checkRequest();
|
|
|
|
|
2019-11-26 14:27:09 +00:00
|
|
|
int errorTop() const override;
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
void updateCallText();
|
2017-05-30 13:54:05 +00:00
|
|
|
void refreshLang();
|
|
|
|
void updateControlsGeometry();
|
2016-11-24 19:28:23 +00:00
|
|
|
|
|
|
|
void codeSubmitDone(const MTPauth_Authorization &result);
|
2021-03-12 12:48:00 +00:00
|
|
|
void codeSubmitFail(const MTP::Error &error);
|
2016-11-24 19:28:23 +00:00
|
|
|
|
2019-06-18 16:53:27 +00:00
|
|
|
void showCodeError(rpl::producer<QString> text);
|
2016-03-15 19:38:30 +00:00
|
|
|
void callDone(const MTPauth_SentCode &v);
|
2015-04-02 10:33:19 +00:00
|
|
|
void gotPassword(const MTPaccount_Password &result);
|
|
|
|
|
2016-11-04 19:50:35 +00:00
|
|
|
void noTelegramCodeDone(const MTPauth_SentCode &result);
|
2021-03-12 12:48:00 +00:00
|
|
|
void noTelegramCodeFail(const MTP::Error &result);
|
2016-11-04 19:50:35 +00:00
|
|
|
|
2022-12-28 18:41:38 +00:00
|
|
|
void submitCode();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void stopCheck();
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::LinkButton> _noTelegramCode;
|
2016-11-24 19:28:23 +00:00
|
|
|
mtpRequestId _noTelegramCodeRequestId = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<CodeInput> _code;
|
2016-11-04 19:50:35 +00:00
|
|
|
QString _sentCode;
|
|
|
|
mtpRequestId _sentRequest = 0;
|
2016-11-24 19:28:23 +00:00
|
|
|
|
2019-11-27 08:33:18 +00:00
|
|
|
base::Timer _callTimer;
|
2019-11-26 11:10:44 +00:00
|
|
|
CallStatus _callStatus = CallStatus();
|
2016-11-24 19:28:23 +00:00
|
|
|
int _callTimeout;
|
|
|
|
mtpRequestId _callRequestId = 0;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::FlatLabel> _callLabel;
|
2015-08-31 14:27:20 +00:00
|
|
|
|
2019-11-27 08:33:18 +00:00
|
|
|
base::Timer _checkRequestTimer;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
};
|
2016-11-24 19:28:23 +00:00
|
|
|
|
2019-11-26 11:10:44 +00:00
|
|
|
} // namespace details
|
2016-11-24 19:28:23 +00:00
|
|
|
} // namespace Intro
|