2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-03-14 16:59:18 +00:00
|
|
|
#include "intro/introwidget.h"
|
2016-11-15 11:56:49 +00:00
|
|
|
#include "ui/widgets/input_fields.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 {
|
|
|
|
|
|
|
|
class CodeInput final : public Ui::MaskedInputField {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-05-30 15:21:05 +00:00
|
|
|
CodeInput(QWidget *parent, const style::InputField &st, base::lambda<QString()> placeholderFactory);
|
2016-11-24 19:28:23 +00:00
|
|
|
|
|
|
|
void setDigitsCountMax(int digitsCount);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void codeEntered();
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
class CodeWidget : public Widget::Step {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-11-24 19:28:23 +00:00
|
|
|
CodeWidget(QWidget *parent, Widget::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;
|
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;
|
|
|
|
|
|
|
|
private slots:
|
2015-08-31 14:27:20 +00:00
|
|
|
void onNoTelegramCode();
|
2014-05-30 08:53:19 +00:00
|
|
|
void onInputChange();
|
|
|
|
void onSendCall();
|
|
|
|
void onCheckRequest();
|
|
|
|
|
|
|
|
private:
|
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);
|
|
|
|
bool codeSubmitFail(const RPCError &error);
|
|
|
|
|
2017-05-30 13:54:05 +00:00
|
|
|
void showCodeError(base::lambda<QString()> textFactory);
|
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);
|
|
|
|
bool noTelegramCodeFail(const RPCError &result);
|
|
|
|
|
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
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<QTimer> _callTimer;
|
2016-11-24 19:28:23 +00:00
|
|
|
Widget::Data::CallStatus _callStatus;
|
|
|
|
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
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<QTimer> _checkRequest;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
};
|
2016-11-24 19:28:23 +00:00
|
|
|
|
|
|
|
} // namespace Intro
|