2018-03-18 08:51:14 +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"
|
2018-04-09 17:56:07 +00:00
|
|
|
#include "boxes/confirm_phone_box.h"
|
2018-03-25 11:37:57 +00:00
|
|
|
#include "base/weak_ptr.h"
|
2018-08-03 21:48:00 +00:00
|
|
|
#include "core/core_cloud_password.h"
|
2018-03-18 08:51:14 +00:00
|
|
|
|
2018-07-13 21:25:47 +00:00
|
|
|
class mtpFileLoader;
|
2018-03-21 04:35:32 +00:00
|
|
|
|
2018-03-25 11:37:57 +00:00
|
|
|
namespace Storage {
|
2018-03-28 20:40:42 +00:00
|
|
|
struct UploadSecureDone;
|
|
|
|
struct UploadSecureProgress;
|
2018-03-25 11:37:57 +00:00
|
|
|
} // namespace Storage
|
|
|
|
|
2018-03-18 08:51:14 +00:00
|
|
|
namespace Window {
|
2019-06-06 10:21:40 +00:00
|
|
|
class SessionController;
|
2018-03-18 08:51:14 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
|
|
|
namespace Passport {
|
|
|
|
|
2018-08-20 12:40:41 +00:00
|
|
|
struct Config {
|
|
|
|
int32 hash = 0;
|
|
|
|
std::map<QString, QString> languagesByCountryCode;
|
|
|
|
};
|
|
|
|
Config &ConfigInstance();
|
|
|
|
Config ParseConfig(const MTPhelp_PassportConfig &data);
|
|
|
|
|
2018-07-10 16:41:11 +00:00
|
|
|
struct SavedCredentials {
|
|
|
|
bytes::vector hashForAuth;
|
|
|
|
bytes::vector hashForSecret;
|
|
|
|
uint64 secretId = 0;
|
|
|
|
};
|
|
|
|
|
2018-08-17 11:01:23 +00:00
|
|
|
QString NonceNameByScope(const QString &scope);
|
|
|
|
|
2018-03-29 19:49:31 +00:00
|
|
|
class ViewController;
|
|
|
|
|
2018-03-18 08:51:14 +00:00
|
|
|
struct FormRequest {
|
|
|
|
FormRequest(
|
|
|
|
UserId botId,
|
2018-03-27 13:00:13 +00:00
|
|
|
const QString &scope,
|
2018-03-18 08:51:14 +00:00
|
|
|
const QString &callbackUrl,
|
2018-04-12 15:45:04 +00:00
|
|
|
const QString &publicKey,
|
2018-08-17 11:01:23 +00:00
|
|
|
const QString &nonce,
|
2018-04-17 17:54:52 +00:00
|
|
|
const QString &errors);
|
2018-03-18 08:51:14 +00:00
|
|
|
|
|
|
|
UserId botId;
|
2018-03-27 13:00:13 +00:00
|
|
|
QString scope;
|
2018-03-18 08:51:14 +00:00
|
|
|
QString callbackUrl;
|
|
|
|
QString publicKey;
|
2018-08-17 11:01:23 +00:00
|
|
|
QString nonce;
|
2018-04-17 17:54:52 +00:00
|
|
|
QString errors;
|
2018-03-18 08:51:14 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-03-29 19:49:31 +00:00
|
|
|
struct UploadScanData {
|
|
|
|
FullMsgId fullId;
|
|
|
|
uint64 fileId = 0;
|
|
|
|
int partsCount = 0;
|
|
|
|
QByteArray md5checksum;
|
|
|
|
bytes::vector hash;
|
|
|
|
bytes::vector bytes;
|
|
|
|
|
|
|
|
int offset = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class UploadScanDataPointer {
|
|
|
|
public:
|
|
|
|
UploadScanDataPointer(std::unique_ptr<UploadScanData> &&value);
|
|
|
|
UploadScanDataPointer(UploadScanDataPointer &&other);
|
|
|
|
UploadScanDataPointer &operator=(UploadScanDataPointer &&other);
|
|
|
|
~UploadScanDataPointer();
|
|
|
|
|
|
|
|
UploadScanData *get() const;
|
|
|
|
operator UploadScanData*() const;
|
|
|
|
explicit operator bool() const;
|
|
|
|
UploadScanData *operator->() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<UploadScanData> _value;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-04-03 18:24:31 +00:00
|
|
|
struct Value;
|
|
|
|
|
2018-08-14 15:27:47 +00:00
|
|
|
enum class FileType {
|
|
|
|
Scan,
|
|
|
|
Translation,
|
|
|
|
FrontSide,
|
|
|
|
ReverseSide,
|
|
|
|
Selfie,
|
|
|
|
};
|
|
|
|
|
2018-03-29 19:49:31 +00:00
|
|
|
struct File {
|
|
|
|
uint64 id = 0;
|
|
|
|
uint64 accessHash = 0;
|
|
|
|
int32 size = 0;
|
|
|
|
int32 dcId = 0;
|
|
|
|
TimeId date = 0;
|
|
|
|
bytes::vector hash;
|
|
|
|
bytes::vector secret;
|
|
|
|
bytes::vector encryptedSecret;
|
|
|
|
|
|
|
|
int downloadOffset = 0;
|
|
|
|
QImage image;
|
2018-04-15 15:06:53 +00:00
|
|
|
QString error;
|
2018-03-29 19:49:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct EditFile {
|
|
|
|
EditFile(
|
2018-04-03 18:24:31 +00:00
|
|
|
not_null<const Value*> value,
|
2018-08-14 15:27:47 +00:00
|
|
|
FileType type,
|
2018-03-29 19:49:31 +00:00
|
|
|
const File &fields,
|
|
|
|
std::unique_ptr<UploadScanData> &&uploadData);
|
|
|
|
|
2018-04-03 18:24:31 +00:00
|
|
|
not_null<const Value*> value;
|
2018-08-14 15:27:47 +00:00
|
|
|
FileType type;
|
2018-03-29 19:49:31 +00:00
|
|
|
File fields;
|
|
|
|
UploadScanDataPointer uploadData;
|
|
|
|
std::shared_ptr<bool> guard;
|
|
|
|
bool deleted = false;
|
|
|
|
};
|
|
|
|
|
2018-04-15 15:06:53 +00:00
|
|
|
struct ValueField {
|
|
|
|
QString text;
|
|
|
|
QString error;
|
|
|
|
};
|
|
|
|
|
2018-03-31 01:45:40 +00:00
|
|
|
struct ValueMap {
|
2018-04-15 15:06:53 +00:00
|
|
|
std::map<QString, ValueField> fields;
|
2018-03-31 01:45:40 +00:00
|
|
|
};
|
|
|
|
|
2018-03-29 19:49:31 +00:00
|
|
|
struct ValueData {
|
|
|
|
QByteArray original;
|
2018-04-06 18:47:29 +00:00
|
|
|
bytes::vector secret;
|
2018-03-31 01:45:40 +00:00
|
|
|
ValueMap parsed;
|
2018-03-29 19:49:31 +00:00
|
|
|
bytes::vector hash;
|
|
|
|
bytes::vector encryptedSecret;
|
2018-04-06 18:47:29 +00:00
|
|
|
ValueMap parsedInEdit;
|
|
|
|
bytes::vector hashInEdit;
|
|
|
|
bytes::vector encryptedSecretInEdit;
|
2018-03-29 19:49:31 +00:00
|
|
|
};
|
|
|
|
|
2018-04-09 17:56:07 +00:00
|
|
|
struct Verification {
|
|
|
|
mtpRequestId requestId = 0;
|
|
|
|
QString phoneCodeHash;
|
|
|
|
int codeLength = 0;
|
|
|
|
std::unique_ptr<SentCodeCall> call;
|
|
|
|
|
|
|
|
QString error;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-05-11 22:55:56 +00:00
|
|
|
struct Form;
|
|
|
|
|
2018-03-29 19:49:31 +00:00
|
|
|
struct Value {
|
|
|
|
enum class Type {
|
2018-04-03 18:24:31 +00:00
|
|
|
PersonalDetails,
|
|
|
|
Passport,
|
|
|
|
DriverLicense,
|
|
|
|
IdentityCard,
|
2018-05-11 22:55:56 +00:00
|
|
|
InternalPassport,
|
2018-03-29 19:49:31 +00:00
|
|
|
Address,
|
2018-04-03 18:24:31 +00:00
|
|
|
UtilityBill,
|
|
|
|
BankStatement,
|
|
|
|
RentalAgreement,
|
2018-05-11 22:55:56 +00:00
|
|
|
PassportRegistration,
|
|
|
|
TemporaryRegistration,
|
2018-03-29 19:49:31 +00:00
|
|
|
Phone,
|
|
|
|
Email,
|
|
|
|
};
|
|
|
|
|
2018-08-14 11:37:03 +00:00
|
|
|
|
2018-03-29 19:49:31 +00:00
|
|
|
explicit Value(Type type);
|
|
|
|
Value(Value &&other) = default;
|
|
|
|
|
2018-08-14 11:37:03 +00:00
|
|
|
// Some data is not parsed from server-provided values.
|
|
|
|
// It should be preserved through re-parsing (for example when saving).
|
|
|
|
// So we hide "operator=(Value&&)" in private and instead provide this.
|
|
|
|
void fillDataFrom(Value &&other);
|
2018-08-14 15:27:47 +00:00
|
|
|
bool requiresSpecialScan(FileType type) const;
|
|
|
|
bool requiresScan(FileType type) const;
|
2018-08-12 19:48:43 +00:00
|
|
|
bool scansAreFilled() const;
|
2018-08-14 15:27:47 +00:00
|
|
|
void saveInEdit();
|
|
|
|
void clearEditData();
|
|
|
|
bool uploadingScan() const;
|
|
|
|
bool saving() const;
|
|
|
|
|
2018-08-17 14:59:07 +00:00
|
|
|
static constexpr auto kNothingFilled = 0x100;
|
|
|
|
static constexpr auto kNoTranslationFilled = 0x10;
|
|
|
|
static constexpr auto kNoSelfieFilled = 0x001;
|
|
|
|
int whatNotFilled() const;
|
|
|
|
|
2018-08-14 15:27:47 +00:00
|
|
|
std::vector<File> &files(FileType type);
|
|
|
|
const std::vector<File> &files(FileType type) const;
|
|
|
|
QString &fileMissingError(FileType type);
|
|
|
|
const QString &fileMissingError(FileType type) const;
|
|
|
|
std::vector<EditFile> &filesInEdit(FileType type);
|
|
|
|
const std::vector<EditFile> &filesInEdit(FileType type) const;
|
2018-09-21 16:28:46 +00:00
|
|
|
EditFile &fileInEdit(FileType type, std::optional<int> fileIndex);
|
2018-08-14 15:27:47 +00:00
|
|
|
const EditFile &fileInEdit(
|
|
|
|
FileType type,
|
2018-09-21 16:28:46 +00:00
|
|
|
std::optional<int> fileIndex) const;
|
2018-08-14 15:27:47 +00:00
|
|
|
|
|
|
|
std::vector<EditFile> takeAllFilesInEdit();
|
2018-05-11 22:55:56 +00:00
|
|
|
|
2018-03-29 19:49:31 +00:00
|
|
|
Type type;
|
|
|
|
ValueData data;
|
2018-08-14 15:27:47 +00:00
|
|
|
std::map<FileType, File> specialScans;
|
2018-08-12 19:48:43 +00:00
|
|
|
QString error;
|
2018-08-14 15:27:47 +00:00
|
|
|
std::map<FileType, EditFile> specialScansInEdit;
|
2018-04-09 17:56:07 +00:00
|
|
|
Verification verification;
|
2018-04-12 15:45:04 +00:00
|
|
|
bytes::vector submitHash;
|
2018-04-09 17:56:07 +00:00
|
|
|
|
2018-08-12 19:48:43 +00:00
|
|
|
bool selfieRequired = false;
|
|
|
|
bool translationRequired = false;
|
|
|
|
bool nativeNames = false;
|
2018-04-09 17:56:07 +00:00
|
|
|
int editScreens = 0;
|
2018-08-14 11:37:03 +00:00
|
|
|
|
2018-04-06 18:47:29 +00:00
|
|
|
mtpRequestId saveRequestId = 0;
|
|
|
|
|
2018-08-14 11:37:03 +00:00
|
|
|
private:
|
|
|
|
Value &operator=(Value &&other) = default;
|
|
|
|
|
2018-08-14 15:27:47 +00:00
|
|
|
std::vector<File> _scans;
|
|
|
|
std::vector<File> _translations;
|
|
|
|
std::vector<EditFile> _scansInEdit;
|
|
|
|
std::vector<EditFile> _translationsInEdit;
|
|
|
|
QString _scanMissingError;
|
|
|
|
QString _translationMissingError;
|
|
|
|
|
2018-03-29 19:49:31 +00:00
|
|
|
};
|
|
|
|
|
2018-08-14 12:51:12 +00:00
|
|
|
bool ValueChanged(not_null<const Value*> value, const ValueMap &data);
|
|
|
|
|
2018-08-12 19:48:43 +00:00
|
|
|
struct RequestedValue {
|
|
|
|
explicit RequestedValue(Value::Type type);
|
|
|
|
|
|
|
|
Value::Type type;
|
|
|
|
bool selfieRequired = false;
|
|
|
|
bool translationRequired = false;
|
|
|
|
bool nativeNames = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RequestedRow {
|
|
|
|
std::vector<RequestedValue> values;
|
|
|
|
};
|
|
|
|
|
2018-03-29 19:49:31 +00:00
|
|
|
struct Form {
|
2018-08-12 19:48:43 +00:00
|
|
|
using Request = std::vector<std::vector<Value::Type>>;
|
|
|
|
|
2018-04-03 18:24:31 +00:00
|
|
|
std::map<Value::Type, Value> values;
|
2018-08-12 19:48:43 +00:00
|
|
|
Request request;
|
2018-04-03 18:24:31 +00:00
|
|
|
QString privacyPolicyUrl;
|
2018-04-17 19:42:53 +00:00
|
|
|
QVector<MTPSecureValueError> pendingErrors;
|
2018-03-29 19:49:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PasswordSettings {
|
2018-08-10 19:19:46 +00:00
|
|
|
Core::CloudPasswordCheckRequest request;
|
2018-08-03 21:48:00 +00:00
|
|
|
Core::CloudPasswordAlgo newAlgo;
|
|
|
|
Core::SecureSecretAlgo newSecureAlgo;
|
2018-03-29 19:49:31 +00:00
|
|
|
QString hint;
|
|
|
|
QString unconfirmedPattern;
|
|
|
|
QString confirmedEmail;
|
|
|
|
bool hasRecovery = false;
|
2018-04-20 16:42:51 +00:00
|
|
|
bool notEmptyPassport = false;
|
2018-08-03 21:48:00 +00:00
|
|
|
bool unknownAlgo = false;
|
2018-04-17 11:26:11 +00:00
|
|
|
|
|
|
|
bool operator==(const PasswordSettings &other) const {
|
2018-08-10 19:19:46 +00:00
|
|
|
return (request == other.request)
|
|
|
|
// newAlgo and newSecureAlgo are always different, because they have
|
|
|
|
// different random parts added on the client to the server salts.
|
|
|
|
// && (newAlgo == other.newAlgo)
|
|
|
|
// && (newSecureAlgo == other.newSecureAlgo)
|
|
|
|
&& ((!newAlgo && !other.newAlgo) || (newAlgo && other.newAlgo))
|
|
|
|
&& ((!newSecureAlgo && !other.newSecureAlgo)
|
|
|
|
|| (newSecureAlgo && other.newSecureAlgo))
|
2018-04-17 11:26:11 +00:00
|
|
|
&& (hint == other.hint)
|
|
|
|
&& (unconfirmedPattern == other.unconfirmedPattern)
|
|
|
|
&& (confirmedEmail == other.confirmedEmail)
|
2018-08-03 21:48:00 +00:00
|
|
|
&& (hasRecovery == other.hasRecovery)
|
|
|
|
&& (unknownAlgo == other.unknownAlgo);
|
2018-04-17 11:26:11 +00:00
|
|
|
}
|
|
|
|
bool operator!=(const PasswordSettings &other) const {
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
2018-03-29 19:49:31 +00:00
|
|
|
};
|
2018-03-21 04:35:32 +00:00
|
|
|
|
2018-03-25 11:37:57 +00:00
|
|
|
struct FileKey {
|
|
|
|
uint64 id = 0;
|
|
|
|
int32 dcId = 0;
|
|
|
|
|
|
|
|
inline bool operator==(const FileKey &other) const {
|
|
|
|
return (id == other.id) && (dcId == other.dcId);
|
|
|
|
}
|
|
|
|
inline bool operator!=(const FileKey &other) const {
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
inline bool operator<(const FileKey &other) const {
|
|
|
|
return (id < other.id) || ((id == other.id) && (dcId < other.dcId));
|
|
|
|
}
|
|
|
|
inline bool operator>(const FileKey &other) const {
|
|
|
|
return (other < *this);
|
|
|
|
}
|
|
|
|
inline bool operator<=(const FileKey &other) const {
|
|
|
|
return !(other < *this);
|
|
|
|
}
|
|
|
|
inline bool operator>=(const FileKey &other) const {
|
|
|
|
return !(*this < other);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-11-27 08:02:56 +00:00
|
|
|
class FormController : public base::has_weak_ptr {
|
2018-03-18 08:51:14 +00:00
|
|
|
public:
|
|
|
|
FormController(
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
2018-03-18 08:51:14 +00:00
|
|
|
const FormRequest &request);
|
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
not_null<Window::SessionController*> window() const {
|
|
|
|
return _controller;
|
|
|
|
}
|
|
|
|
|
2018-03-18 08:51:14 +00:00
|
|
|
void show();
|
2018-03-29 19:49:31 +00:00
|
|
|
UserData *bot() const;
|
2018-04-03 18:24:31 +00:00
|
|
|
QString privacyPolicyUrl() const;
|
2018-04-15 15:06:53 +00:00
|
|
|
std::vector<not_null<const Value*>> submitGetErrors();
|
2018-07-10 16:41:11 +00:00
|
|
|
void submitPassword(const QByteArray &password);
|
2018-04-18 08:42:15 +00:00
|
|
|
void recoverPassword();
|
2018-03-19 16:22:27 +00:00
|
|
|
rpl::producer<QString> passwordError() const;
|
2018-04-16 17:02:40 +00:00
|
|
|
const PasswordSettings &passwordSettings() const;
|
|
|
|
void reloadPassword();
|
2018-07-10 16:41:11 +00:00
|
|
|
void reloadAndSubmitPassword(const QByteArray &password);
|
2018-04-16 17:02:40 +00:00
|
|
|
void cancelPassword();
|
2018-03-19 16:22:27 +00:00
|
|
|
|
2018-08-14 15:27:47 +00:00
|
|
|
bool canAddScan(not_null<const Value*> value, FileType type) const;
|
|
|
|
void uploadScan(
|
2018-05-11 22:55:56 +00:00
|
|
|
not_null<const Value*> value,
|
2018-08-14 15:27:47 +00:00
|
|
|
FileType type,
|
2018-05-11 22:55:56 +00:00
|
|
|
QByteArray &&content);
|
2018-08-14 15:27:47 +00:00
|
|
|
void deleteScan(
|
2018-05-11 22:55:56 +00:00
|
|
|
not_null<const Value*> value,
|
2018-08-14 15:27:47 +00:00
|
|
|
FileType type,
|
2018-09-21 16:28:46 +00:00
|
|
|
std::optional<int> fileIndex);
|
2018-08-14 15:27:47 +00:00
|
|
|
void restoreScan(
|
2018-05-11 22:55:56 +00:00
|
|
|
not_null<const Value*> value,
|
2018-08-14 15:27:47 +00:00
|
|
|
FileType type,
|
2018-09-21 16:28:46 +00:00
|
|
|
std::optional<int> fileIndex);
|
2018-03-25 11:37:57 +00:00
|
|
|
|
2018-03-19 16:22:27 +00:00
|
|
|
rpl::producer<> secretReadyEvents() const;
|
|
|
|
|
|
|
|
QString defaultEmail() const;
|
|
|
|
QString defaultPhoneNumber() const;
|
|
|
|
|
2018-03-29 19:49:31 +00:00
|
|
|
rpl::producer<not_null<const EditFile*>> scanUpdated() const;
|
2018-04-09 17:56:07 +00:00
|
|
|
rpl::producer<not_null<const Value*>> valueSaveFinished() const;
|
2018-04-06 18:47:29 +00:00
|
|
|
rpl::producer<not_null<const Value*>> verificationNeeded() const;
|
2018-04-09 17:56:07 +00:00
|
|
|
rpl::producer<not_null<const Value*>> verificationUpdate() const;
|
|
|
|
void verify(not_null<const Value*> value, const QString &code);
|
2018-03-29 19:49:31 +00:00
|
|
|
|
2018-04-03 18:24:31 +00:00
|
|
|
const Form &form() const;
|
|
|
|
void startValueEdit(not_null<const Value*> value);
|
|
|
|
void cancelValueEdit(not_null<const Value*> value);
|
2018-04-09 17:56:07 +00:00
|
|
|
void cancelValueVerification(not_null<const Value*> value);
|
2018-04-03 18:24:31 +00:00
|
|
|
void saveValueEdit(not_null<const Value*> value, ValueMap &&data);
|
2018-04-13 16:43:17 +00:00
|
|
|
void deleteValueEdit(not_null<const Value*> value);
|
2018-03-21 04:35:32 +00:00
|
|
|
|
2018-03-31 01:45:40 +00:00
|
|
|
void cancel();
|
2018-04-15 16:22:13 +00:00
|
|
|
void cancelSure();
|
2018-03-31 01:45:40 +00:00
|
|
|
|
|
|
|
rpl::lifetime &lifetime();
|
2018-03-19 16:22:27 +00:00
|
|
|
|
2018-03-25 11:37:57 +00:00
|
|
|
~FormController();
|
|
|
|
|
2018-03-18 08:51:14 +00:00
|
|
|
private:
|
2018-08-10 19:19:46 +00:00
|
|
|
using PasswordCheckCallback = Fn<void(
|
|
|
|
const Core::CloudPasswordResult &check)>;
|
|
|
|
|
2018-04-12 15:45:04 +00:00
|
|
|
struct FinalData {
|
|
|
|
QVector<MTPSecureValueHash> hashes;
|
|
|
|
QByteArray credentials;
|
2018-04-15 15:06:53 +00:00
|
|
|
std::vector<not_null<const Value*>> errors;
|
2018-04-12 15:45:04 +00:00
|
|
|
};
|
2018-08-14 15:27:47 +00:00
|
|
|
|
|
|
|
template <typename Condition>
|
|
|
|
EditFile *findEditFileByCondition(Condition &&condition);
|
2018-03-25 11:37:57 +00:00
|
|
|
EditFile *findEditFile(const FullMsgId &fullId);
|
2018-03-28 20:40:42 +00:00
|
|
|
EditFile *findEditFile(const FileKey &key);
|
2018-03-29 14:44:34 +00:00
|
|
|
std::pair<Value*, File*> findFile(const FileKey &key);
|
2018-04-03 18:24:31 +00:00
|
|
|
not_null<Value*> findValue(not_null<const Value*> value);
|
2018-03-18 08:51:14 +00:00
|
|
|
|
|
|
|
void requestForm();
|
|
|
|
void requestPassword();
|
2018-08-20 12:40:41 +00:00
|
|
|
void requestConfig();
|
2018-03-18 08:51:14 +00:00
|
|
|
|
|
|
|
void formDone(const MTPaccount_AuthorizationForm &result);
|
2018-04-15 15:06:53 +00:00
|
|
|
void formFail(const QString &error);
|
2018-08-12 19:48:43 +00:00
|
|
|
bool parseForm(const MTPaccount_AuthorizationForm &result);
|
2018-03-18 08:51:14 +00:00
|
|
|
void showForm();
|
2018-04-12 15:45:04 +00:00
|
|
|
Value parseValue(
|
|
|
|
const MTPSecureValue &value,
|
|
|
|
const std::vector<EditFile> &editData = {}) const;
|
2018-03-28 20:40:42 +00:00
|
|
|
std::vector<File> parseFiles(
|
|
|
|
const QVector<MTPSecureFile> &data,
|
2018-04-12 15:45:04 +00:00
|
|
|
const std::vector<EditFile> &editData) const;
|
2018-09-21 16:28:46 +00:00
|
|
|
std::optional<File> parseFile(
|
2018-04-10 19:00:52 +00:00
|
|
|
const MTPSecureFile &data,
|
2018-04-12 15:45:04 +00:00
|
|
|
const std::vector<EditFile> &editData) const;
|
2018-03-29 14:44:34 +00:00
|
|
|
void fillDownloadedFile(
|
|
|
|
File &destination,
|
|
|
|
const std::vector<EditFile> &source) const;
|
2018-08-17 11:11:09 +00:00
|
|
|
bool handleAppUpdateError(const QString &error);
|
2018-03-18 08:51:14 +00:00
|
|
|
|
2018-08-10 19:19:46 +00:00
|
|
|
void submitPassword(
|
|
|
|
const Core::CloudPasswordResult &check,
|
|
|
|
const QByteArray &password,
|
|
|
|
bool submitSaved);
|
|
|
|
void checkPasswordHash(
|
|
|
|
mtpRequestId &guard,
|
|
|
|
bytes::vector hash,
|
|
|
|
PasswordCheckCallback callback);
|
|
|
|
bool handleSrpIdInvalid(mtpRequestId &guard);
|
|
|
|
void requestPasswordData(mtpRequestId &guard);
|
|
|
|
void passwordChecked();
|
|
|
|
void passwordServerError();
|
2018-03-18 08:51:14 +00:00
|
|
|
void passwordDone(const MTPaccount_Password &result);
|
2018-04-17 11:26:11 +00:00
|
|
|
bool applyPassword(const MTPDaccount_password &settings);
|
|
|
|
bool applyPassword(PasswordSettings &&settings);
|
2018-03-27 13:00:13 +00:00
|
|
|
bytes::vector passwordHashForAuth(bytes::const_span password) const;
|
2018-07-10 16:41:11 +00:00
|
|
|
void checkSavedPasswordSettings(const SavedCredentials &credentials);
|
2018-08-10 19:19:46 +00:00
|
|
|
void checkSavedPasswordSettings(
|
|
|
|
const Core::CloudPasswordResult &check,
|
|
|
|
const SavedCredentials &credentials);
|
2018-03-27 13:00:13 +00:00
|
|
|
void validateSecureSecret(
|
|
|
|
bytes::const_span encryptedSecret,
|
2018-07-10 16:41:11 +00:00
|
|
|
bytes::const_span passwordHashForSecret,
|
|
|
|
bytes::const_span passwordBytes,
|
2018-04-13 18:14:14 +00:00
|
|
|
uint64 serverSecretId);
|
2018-03-29 14:44:34 +00:00
|
|
|
void decryptValues();
|
2018-08-14 11:37:03 +00:00
|
|
|
void decryptValue(Value &value) const;
|
|
|
|
bool validateValueSecrets(Value &value) const;
|
|
|
|
void resetValue(Value &value) const;
|
2018-04-17 17:54:52 +00:00
|
|
|
void fillErrors();
|
2018-08-20 12:40:41 +00:00
|
|
|
void fillNativeFromFallback();
|
2018-03-18 08:51:14 +00:00
|
|
|
|
2018-04-10 19:00:52 +00:00
|
|
|
void loadFile(File &file);
|
2018-03-28 20:40:42 +00:00
|
|
|
void fileLoadDone(FileKey key, const QByteArray &bytes);
|
|
|
|
void fileLoadProgress(FileKey key, int offset);
|
|
|
|
void fileLoadFail(FileKey key);
|
2018-03-27 13:00:13 +00:00
|
|
|
void generateSecret(bytes::const_span password);
|
2018-08-10 19:19:46 +00:00
|
|
|
void saveSecret(
|
|
|
|
const Core::CloudPasswordResult &check,
|
|
|
|
const SavedCredentials &saved,
|
|
|
|
const bytes::vector &secret);
|
2018-03-21 04:35:32 +00:00
|
|
|
|
2018-03-25 11:37:57 +00:00
|
|
|
void subscribeToUploader();
|
2018-04-10 19:00:52 +00:00
|
|
|
void encryptFile(
|
|
|
|
EditFile &file,
|
|
|
|
QByteArray &&content,
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void(UploadScanData &&result)> callback);
|
2018-04-10 19:00:52 +00:00
|
|
|
void prepareFile(
|
|
|
|
EditFile &file,
|
|
|
|
const QByteArray &content);
|
|
|
|
void uploadEncryptedFile(
|
|
|
|
EditFile &file,
|
2018-03-29 14:44:34 +00:00
|
|
|
UploadScanData &&data);
|
2018-03-28 20:40:42 +00:00
|
|
|
void scanUploadDone(const Storage::UploadSecureDone &data);
|
|
|
|
void scanUploadProgress(const Storage::UploadSecureProgress &data);
|
|
|
|
void scanUploadFail(const FullMsgId &fullId);
|
2018-04-10 19:00:52 +00:00
|
|
|
void scanDeleteRestore(
|
|
|
|
not_null<const Value*> value,
|
2018-08-14 15:27:47 +00:00
|
|
|
FileType type,
|
2018-09-21 16:28:46 +00:00
|
|
|
std::optional<int> fileIndex,
|
2018-04-10 19:00:52 +00:00
|
|
|
bool deleted);
|
2018-03-29 19:49:31 +00:00
|
|
|
|
2018-04-09 17:56:07 +00:00
|
|
|
QString getPhoneFromValue(not_null<const Value*> value) const;
|
|
|
|
QString getEmailFromValue(not_null<const Value*> value) const;
|
|
|
|
QString getPlainTextFromValue(not_null<const Value*> value) const;
|
|
|
|
void startPhoneVerification(not_null<Value*> value);
|
|
|
|
void startEmailVerification(not_null<Value*> value);
|
2018-04-15 15:06:53 +00:00
|
|
|
void valueSaveShowError(not_null<Value*> value, const RPCError &error);
|
|
|
|
void valueSaveFailed(not_null<Value*> value);
|
2018-04-09 17:56:07 +00:00
|
|
|
void requestPhoneCall(not_null<Value*> value);
|
|
|
|
void verificationError(
|
|
|
|
not_null<Value*> value,
|
|
|
|
const QString &text);
|
|
|
|
void valueEditFailed(not_null<Value*> value);
|
|
|
|
void clearValueEdit(not_null<Value*> value);
|
|
|
|
void clearValueVerification(not_null<Value*> value);
|
|
|
|
|
2018-03-29 19:49:31 +00:00
|
|
|
bool isEncryptedValue(Value::Type type) const;
|
2018-04-03 18:24:31 +00:00
|
|
|
void saveEncryptedValue(not_null<Value*> value);
|
|
|
|
void savePlainTextValue(not_null<Value*> value);
|
|
|
|
void sendSaveRequest(
|
|
|
|
not_null<Value*> value,
|
|
|
|
const MTPInputSecureValue &data);
|
2018-04-13 17:42:28 +00:00
|
|
|
FinalData prepareFinalData();
|
2018-03-25 11:37:57 +00:00
|
|
|
|
2018-04-15 16:22:13 +00:00
|
|
|
void suggestReset(bytes::vector password);
|
2018-08-10 19:19:46 +00:00
|
|
|
void resetSecret(
|
|
|
|
const Core::CloudPasswordResult &check,
|
|
|
|
const bytes::vector &password);
|
2018-04-15 15:06:53 +00:00
|
|
|
void suggestRestart();
|
|
|
|
void cancelAbort();
|
2018-04-17 11:26:11 +00:00
|
|
|
void shortPollEmailConfirmation();
|
2018-04-13 18:14:14 +00:00
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionController*> _controller;
|
2019-11-27 08:02:56 +00:00
|
|
|
MTP::Sender _api;
|
2018-03-18 08:51:14 +00:00
|
|
|
FormRequest _request;
|
|
|
|
UserData *_bot = nullptr;
|
|
|
|
|
2018-03-19 16:22:27 +00:00
|
|
|
mtpRequestId _formRequestId = 0;
|
|
|
|
mtpRequestId _passwordRequestId = 0;
|
|
|
|
mtpRequestId _passwordCheckRequestId = 0;
|
2018-08-20 12:40:41 +00:00
|
|
|
mtpRequestId _configRequestId = 0;
|
2018-03-19 16:22:27 +00:00
|
|
|
|
|
|
|
PasswordSettings _password;
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time _lastSrpIdInvalidTime = 0;
|
2018-08-10 19:19:46 +00:00
|
|
|
bytes::vector _passwordCheckHash;
|
|
|
|
PasswordCheckCallback _passwordCheckCallback;
|
2018-07-10 16:41:11 +00:00
|
|
|
QByteArray _savedPasswordValue;
|
2018-03-18 08:51:14 +00:00
|
|
|
Form _form;
|
2018-03-31 01:45:40 +00:00
|
|
|
bool _cancelled = false;
|
2018-04-18 08:42:15 +00:00
|
|
|
mtpRequestId _recoverRequestId = 0;
|
2020-04-10 11:17:10 +00:00
|
|
|
base::flat_map<FileKey, std::unique_ptr<mtpFileLoader>> _fileLoaders;
|
2018-03-29 19:49:31 +00:00
|
|
|
|
|
|
|
rpl::event_stream<not_null<const EditFile*>> _scanUpdated;
|
2018-04-09 17:56:07 +00:00
|
|
|
rpl::event_stream<not_null<const Value*>> _valueSaveFinished;
|
2018-04-06 18:47:29 +00:00
|
|
|
rpl::event_stream<not_null<const Value*>> _verificationNeeded;
|
2018-04-09 17:56:07 +00:00
|
|
|
rpl::event_stream<not_null<const Value*>> _verificationUpdate;
|
2018-03-18 08:51:14 +00:00
|
|
|
|
2018-03-27 12:16:00 +00:00
|
|
|
bytes::vector _secret;
|
2018-03-29 14:44:34 +00:00
|
|
|
uint64 _secretId = 0;
|
2018-06-04 15:35:11 +00:00
|
|
|
std::vector<Fn<void()>> _secretCallbacks;
|
2018-03-21 04:35:32 +00:00
|
|
|
mtpRequestId _saveSecretRequestId = 0;
|
2018-03-19 16:22:27 +00:00
|
|
|
rpl::event_stream<> _secretReady;
|
|
|
|
rpl::event_stream<QString> _passwordError;
|
2018-04-12 15:45:04 +00:00
|
|
|
mtpRequestId _submitRequestId = 0;
|
2018-04-13 18:14:14 +00:00
|
|
|
bool _submitSuccess = false;
|
2018-04-15 15:06:53 +00:00
|
|
|
bool _suggestingRestart = false;
|
|
|
|
QString _serviceErrorText;
|
2018-04-17 11:26:11 +00:00
|
|
|
base::Timer _shortPollTimer;
|
2018-03-19 16:22:27 +00:00
|
|
|
|
2018-03-25 11:37:57 +00:00
|
|
|
rpl::lifetime _uploaderSubscriptions;
|
2018-03-29 19:49:31 +00:00
|
|
|
rpl::lifetime _lifetime;
|
2018-03-25 11:37:57 +00:00
|
|
|
|
2018-03-31 01:45:40 +00:00
|
|
|
std::unique_ptr<ViewController> _view;
|
|
|
|
|
2018-03-18 08:51:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Passport
|