2015-03-02 12:34:16 +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.
|
2015-03-02 12:34:16 +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
|
2015-03-02 12:34:16 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/abstract_box.h"
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2016-11-11 13:46:04 +00:00
|
|
|
namespace Ui {
|
2016-11-15 11:56:49 +00:00
|
|
|
class InputField;
|
|
|
|
class PasswordInput;
|
2016-11-11 13:46:04 +00:00
|
|
|
class LinkButton;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class PasscodeBox : public BoxContent, public RPCSender {
|
2015-03-02 12:34:16 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-12-13 17:07:56 +00:00
|
|
|
PasscodeBox(QWidget*, bool turningOff);
|
|
|
|
PasscodeBox(QWidget*, const QByteArray &newSalt, const QByteArray &curSalt, bool hasRecovery, const QString &hint, bool turningOff = false);
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2016-07-28 17:01:08 +00:00
|
|
|
private slots:
|
2015-04-02 10:33:19 +00:00
|
|
|
void onSave(bool force = false);
|
2015-03-02 12:34:16 +00:00
|
|
|
void onBadOldPasscode();
|
|
|
|
void onOldChanged();
|
|
|
|
void onNewChanged();
|
2015-04-02 10:33:19 +00:00
|
|
|
void onEmailChanged();
|
|
|
|
void onRecoverByEmail();
|
|
|
|
void onRecoverExpired();
|
2015-10-12 21:02:10 +00:00
|
|
|
void onSubmit();
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
signals:
|
|
|
|
void reloadPassword();
|
|
|
|
|
|
|
|
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;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
private:
|
2016-12-13 17:07:56 +00:00
|
|
|
void closeReplacedBy();
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
void setPasswordDone(const MTPBool &result);
|
|
|
|
bool setPasswordFail(const RPCError &error);
|
|
|
|
|
|
|
|
void recoverStarted(const MTPauth_PasswordRecovery &result);
|
|
|
|
bool recoverStartFail(const RPCError &error);
|
|
|
|
|
|
|
|
void recover();
|
|
|
|
QString _pattern;
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
QPointer<BoxContent> _replacedBy;
|
2016-11-18 13:34:58 +00:00
|
|
|
bool _turningOff = false;
|
|
|
|
bool _cloudPwd = false;
|
|
|
|
mtpRequestId _setRequest = 0;
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
QByteArray _newSalt, _curSalt;
|
2016-11-18 13:34:58 +00:00
|
|
|
bool _hasRecovery = false;
|
|
|
|
bool _skipEmailWarning = false;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2016-11-18 13:34:58 +00:00
|
|
|
int _aboutHeight = 0;
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
Text _about, _hintText;
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::PasswordInput> _oldPasscode;
|
|
|
|
object_ptr<Ui::PasswordInput> _newPasscode;
|
|
|
|
object_ptr<Ui::PasswordInput> _reenterPasscode;
|
|
|
|
object_ptr<Ui::InputField> _passwordHint;
|
|
|
|
object_ptr<Ui::InputField> _recoverEmail;
|
|
|
|
object_ptr<Ui::LinkButton> _recover;
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
QString _oldError, _newError, _emailError;
|
2016-08-16 16:53:10 +00:00
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
};
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class RecoverBox : public BoxContent, public RPCSender {
|
2015-04-02 10:33:19 +00:00
|
|
|
Q_OBJECT
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
public:
|
2016-12-13 17:07:56 +00:00
|
|
|
RecoverBox(QWidget*, const QString &pattern);
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void onSubmit();
|
|
|
|
void onCodeChanged();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void reloadPassword();
|
|
|
|
void recoveryExpired();
|
|
|
|
|
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void prepare() override;
|
|
|
|
void setInnerFocus() override;
|
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void codeSubmitDone(bool recover, const MTPauth_Authorization &result);
|
|
|
|
bool codeSubmitFail(const RPCError &error);
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
mtpRequestId _submitRequest = 0;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
QString _pattern;
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::InputField> _recoverCode;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
QString _error;
|
2016-08-16 16:53:10 +00:00
|
|
|
|
2015-03-02 12:34:16 +00:00
|
|
|
};
|