2021-08-02 19:06:33 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "mtproto/sender.h"
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
struct CloudPasswordState;
|
|
|
|
} // namespace Core
|
|
|
|
|
|
|
|
class ApiWrap;
|
|
|
|
|
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
|
|
|
namespace Api {
|
|
|
|
|
|
|
|
class CloudPassword final {
|
|
|
|
public:
|
2022-05-06 21:17:41 +00:00
|
|
|
struct SetOk {
|
|
|
|
int unconfirmedEmailLengthCode = 0;
|
|
|
|
};
|
|
|
|
|
2021-08-15 10:11:48 +00:00
|
|
|
using ResetRetryDate = int;
|
2021-08-02 19:06:33 +00:00
|
|
|
explicit CloudPassword(not_null<ApiWrap*> api);
|
|
|
|
|
|
|
|
void reload();
|
|
|
|
void clearUnconfirmedPassword();
|
|
|
|
rpl::producer<Core::CloudPasswordState> state() const;
|
|
|
|
std::optional<Core::CloudPasswordState> stateCurrent() const;
|
|
|
|
|
2021-08-15 10:11:48 +00:00
|
|
|
rpl::producer<ResetRetryDate, QString> resetPassword();
|
|
|
|
rpl::producer<rpl::no_value, QString> cancelResetPassword();
|
|
|
|
|
2022-05-06 21:17:41 +00:00
|
|
|
rpl::producer<SetOk, QString> set(
|
|
|
|
const QString &oldPassword,
|
|
|
|
const QString &newPassword,
|
|
|
|
const QString &hint,
|
|
|
|
bool hasRecoveryEmail,
|
|
|
|
const QString &recoveryEmail);
|
2022-05-07 00:56:15 +00:00
|
|
|
rpl::producer<rpl::no_value, QString> check(const QString &password);
|
2022-05-06 21:17:41 +00:00
|
|
|
|
2022-05-07 02:03:41 +00:00
|
|
|
rpl::producer<rpl::no_value, QString> confirmEmail(const QString &code);
|
|
|
|
rpl::producer<rpl::no_value, QString> resendEmailCode();
|
2022-05-08 20:03:11 +00:00
|
|
|
rpl::producer<SetOk, QString> setEmail(
|
|
|
|
const QString &oldPassword,
|
|
|
|
const QString &recoveryEmail);
|
2022-05-07 02:03:41 +00:00
|
|
|
|
2022-05-08 21:33:17 +00:00
|
|
|
rpl::producer<rpl::no_value, QString> recoverPassword(
|
|
|
|
const QString &code,
|
|
|
|
const QString &newPassword,
|
|
|
|
const QString &newHint);
|
|
|
|
rpl::producer<QString, QString> requestPasswordRecovery();
|
|
|
|
rpl::producer<rpl::no_value, QString> checkRecoveryEmailAddressCode(
|
|
|
|
const QString &code);
|
|
|
|
|
2021-08-02 19:06:33 +00:00
|
|
|
private:
|
2022-05-06 21:17:41 +00:00
|
|
|
void apply(Core::CloudPasswordState state);
|
|
|
|
|
2021-08-02 19:06:33 +00:00
|
|
|
MTP::Sender _api;
|
|
|
|
mtpRequestId _requestId = 0;
|
|
|
|
std::unique_ptr<Core::CloudPasswordState> _state;
|
|
|
|
rpl::event_stream<Core::CloudPasswordState> _stateChanges;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Api
|