2015-03-02 15:34:16 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2015-03-02 15:34:16 +03:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2015-03-02 15:34:16 +03:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 17:38:10 +03:00
|
|
|
#include "boxes/abstract_box.h"
|
2018-04-17 19:19:24 +04:00
|
|
|
#include "mtproto/sender.h"
|
2015-03-02 15:34:16 +03:00
|
|
|
|
2016-11-11 16:46:04 +03:00
|
|
|
namespace Ui {
|
2016-11-15 14:56:49 +03:00
|
|
|
class InputField;
|
|
|
|
class PasswordInput;
|
2016-11-11 16:46:04 +03:00
|
|
|
class LinkButton;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2018-04-17 19:19:24 +04:00
|
|
|
class PasscodeBox : public BoxContent, private MTP::Sender {
|
2015-03-02 15:34:16 +03:00
|
|
|
public:
|
2016-12-13 20:07:56 +03:00
|
|
|
PasscodeBox(QWidget*, bool turningOff);
|
2018-04-17 19:19:24 +04:00
|
|
|
PasscodeBox(
|
|
|
|
QWidget*,
|
|
|
|
const QByteArray &newSalt,
|
|
|
|
const QByteArray &curSalt,
|
|
|
|
bool hasRecovery,
|
2018-04-20 20:42:51 +04:00
|
|
|
bool notEmptyPassport,
|
2018-04-17 19:19:24 +04:00
|
|
|
const QString &hint,
|
|
|
|
const QByteArray &newSecureSecretSalt,
|
|
|
|
bool turningOff = false);
|
2015-03-02 15:34:16 +03:00
|
|
|
|
2018-07-10 19:41:11 +03:00
|
|
|
rpl::producer<QByteArray> newPasswordSet() const;
|
|
|
|
rpl::producer<> passwordReloadNeeded() const;
|
2015-04-02 13:33:19 +03:00
|
|
|
|
|
|
|
protected:
|
2016-12-13 20:07:56 +03:00
|
|
|
void prepare() override;
|
|
|
|
void setInnerFocus() override;
|
|
|
|
|
2016-07-28 20:01:08 +03:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2015-04-02 13:33:19 +03:00
|
|
|
|
|
|
|
private:
|
2018-05-31 15:20:28 +03:00
|
|
|
void submit();
|
2016-12-13 20:07:56 +03:00
|
|
|
void closeReplacedBy();
|
2018-05-31 15:20:28 +03:00
|
|
|
void oldChanged();
|
|
|
|
void newChanged();
|
|
|
|
void emailChanged();
|
|
|
|
void save(bool force = false);
|
|
|
|
void badOldPasscode();
|
|
|
|
void recoverByEmail();
|
|
|
|
void recoverExpired();
|
2015-04-02 13:33:19 +03:00
|
|
|
|
2018-07-10 19:41:11 +03:00
|
|
|
void setPasswordDone(const QByteArray &newPasswordBytes);
|
2015-04-02 13:33:19 +03:00
|
|
|
bool setPasswordFail(const RPCError &error);
|
2018-07-10 19:41:11 +03:00
|
|
|
bool setPasswordFail(
|
|
|
|
const QByteArray &newPasswordBytes,
|
|
|
|
const RPCError &error);
|
2015-04-02 13:33:19 +03:00
|
|
|
|
|
|
|
void recoverStarted(const MTPauth_PasswordRecovery &result);
|
|
|
|
bool recoverStartFail(const RPCError &error);
|
|
|
|
|
|
|
|
void recover();
|
2018-04-17 19:19:24 +04:00
|
|
|
void clearCloudPassword(const QString &oldPassword);
|
|
|
|
void setNewCloudPassword(const QString &newPassword);
|
|
|
|
void changeCloudPassword(
|
|
|
|
const QString &oldPassword,
|
|
|
|
const QString &newPassword);
|
|
|
|
void sendChangeCloudPassword(
|
|
|
|
const QByteArray &oldPasswordHash,
|
|
|
|
const QString &newPassword,
|
|
|
|
const QByteArray &secureSecret);
|
|
|
|
void suggestSecretReset(
|
|
|
|
const QByteArray &oldPasswordHash,
|
|
|
|
const QString &newPassword);
|
|
|
|
void resetSecretAndChangePassword(
|
|
|
|
const QByteArray &oldPasswordHash,
|
|
|
|
const QString &newPassword);
|
2018-04-20 20:42:51 +04:00
|
|
|
void sendClearCloudPassword(const QString &oldPassword);
|
2018-04-17 19:19:24 +04:00
|
|
|
|
2015-04-02 13:33:19 +03:00
|
|
|
QString _pattern;
|
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
QPointer<BoxContent> _replacedBy;
|
2016-11-18 16:34:58 +03:00
|
|
|
bool _turningOff = false;
|
|
|
|
bool _cloudPwd = false;
|
|
|
|
mtpRequestId _setRequest = 0;
|
2015-03-02 15:34:16 +03:00
|
|
|
|
2018-04-17 19:19:24 +04:00
|
|
|
QByteArray _newSalt, _curSalt, _newSecureSecretSalt;
|
2016-11-18 16:34:58 +03:00
|
|
|
bool _hasRecovery = false;
|
2018-04-20 20:42:51 +04:00
|
|
|
bool _notEmptyPassport = false;
|
2016-11-18 16:34:58 +03:00
|
|
|
bool _skipEmailWarning = false;
|
2015-04-02 13:33:19 +03:00
|
|
|
|
2016-11-18 16:34:58 +03:00
|
|
|
int _aboutHeight = 0;
|
2015-03-02 15:34:16 +03:00
|
|
|
|
2015-04-02 13:33:19 +03:00
|
|
|
Text _about, _hintText;
|
2015-03-02 15:34:16 +03:00
|
|
|
|
2016-12-13 20:07:56 +03: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 15:34:16 +03:00
|
|
|
|
2015-04-02 13:33:19 +03:00
|
|
|
QString _oldError, _newError, _emailError;
|
2016-08-16 19:53:10 +03:00
|
|
|
|
2018-07-10 19:41:11 +03:00
|
|
|
rpl::event_stream<QByteArray> _newPasswordSet;
|
|
|
|
rpl::event_stream<> _passwordReloadNeeded;
|
|
|
|
|
2015-04-02 13:33:19 +03:00
|
|
|
};
|
2015-03-02 15:34:16 +03:00
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
class RecoverBox : public BoxContent, public RPCSender {
|
2015-04-02 13:33:19 +03:00
|
|
|
public:
|
2018-04-20 20:42:51 +04:00
|
|
|
RecoverBox(QWidget*, const QString &pattern, bool notEmptyPassport);
|
2015-04-02 13:33:19 +03:00
|
|
|
|
2018-07-10 19:41:11 +03:00
|
|
|
rpl::producer<> passwordCleared() const;
|
|
|
|
rpl::producer<> recoveryExpired() const;
|
|
|
|
|
|
|
|
//void reloadPassword();
|
|
|
|
//void recoveryExpired();
|
2015-04-02 13:33:19 +03:00
|
|
|
|
|
|
|
protected:
|
2016-12-13 20:07:56 +03:00
|
|
|
void prepare() override;
|
|
|
|
void setInnerFocus() override;
|
|
|
|
|
2016-08-16 19:53:10 +03:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2015-04-02 13:33:19 +03:00
|
|
|
|
|
|
|
private:
|
2018-05-31 15:20:28 +03:00
|
|
|
void submit();
|
|
|
|
void codeChanged();
|
2015-04-02 13:33:19 +03:00
|
|
|
void codeSubmitDone(bool recover, const MTPauth_Authorization &result);
|
|
|
|
bool codeSubmitFail(const RPCError &error);
|
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
mtpRequestId _submitRequest = 0;
|
2015-04-02 13:33:19 +03:00
|
|
|
|
|
|
|
QString _pattern;
|
2018-04-20 20:42:51 +04:00
|
|
|
bool _notEmptyPassport = false;
|
2015-04-02 13:33:19 +03:00
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
object_ptr<Ui::InputField> _recoverCode;
|
2015-04-02 13:33:19 +03:00
|
|
|
|
|
|
|
QString _error;
|
2016-08-16 19:53:10 +03:00
|
|
|
|
2018-07-10 19:41:11 +03:00
|
|
|
rpl::event_stream<> _passwordCleared;
|
|
|
|
rpl::event_stream<> _recoveryExpired;
|
|
|
|
|
2015-03-02 15:34:16 +03:00
|
|
|
};
|