2018-06-02 14:29:21 +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 "base/variant.h"
|
2021-03-12 12:48:00 +00:00
|
|
|
#include "mtproto/mtproto_response.h"
|
2019-11-18 09:28:14 +00:00
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
#include <QtCore/QPointer>
|
2019-11-18 09:28:14 +00:00
|
|
|
#include <crl/crl_object_on_queue.h>
|
2018-06-02 14:29:21 +00:00
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
namespace MTP {
|
|
|
|
class Instance;
|
|
|
|
} // namespace MTP
|
|
|
|
|
2018-06-02 14:29:21 +00:00
|
|
|
namespace Export {
|
|
|
|
|
2019-02-17 11:06:37 +00:00
|
|
|
class ControllerObject;
|
2018-06-02 14:29:21 +00:00
|
|
|
struct Settings;
|
2018-06-24 02:06:11 +00:00
|
|
|
struct Environment;
|
2018-06-02 14:29:21 +00:00
|
|
|
|
|
|
|
struct PasswordCheckState {
|
|
|
|
QString hint;
|
|
|
|
QString unconfirmedPattern;
|
|
|
|
bool requesting = true;
|
|
|
|
bool hasPassword = false;
|
|
|
|
bool checked = false;
|
2018-07-23 13:11:56 +00:00
|
|
|
MTPInputPeer singlePeer = MTP_inputPeerEmpty();
|
2018-06-02 14:29:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ProcessingState {
|
|
|
|
enum class Step {
|
2018-06-18 21:52:13 +00:00
|
|
|
Initializing,
|
|
|
|
DialogsList,
|
2018-06-02 14:29:21 +00:00
|
|
|
PersonalInfo,
|
2018-06-09 11:51:22 +00:00
|
|
|
Userpics,
|
2018-06-02 14:29:21 +00:00
|
|
|
Contacts,
|
|
|
|
Sessions,
|
2018-06-24 00:33:47 +00:00
|
|
|
OtherData,
|
2018-06-12 18:09:21 +00:00
|
|
|
Dialogs,
|
2018-06-02 14:29:21 +00:00
|
|
|
};
|
2018-06-19 18:31:30 +00:00
|
|
|
enum class FileType {
|
|
|
|
None,
|
2018-06-02 14:29:21 +00:00
|
|
|
Photo,
|
|
|
|
Video,
|
2018-06-18 21:52:13 +00:00
|
|
|
VoiceMessage,
|
|
|
|
VideoMessage,
|
|
|
|
Sticker,
|
|
|
|
GIF,
|
2018-06-02 14:29:21 +00:00
|
|
|
File,
|
|
|
|
};
|
2018-06-28 17:12:13 +00:00
|
|
|
enum class EntityType {
|
|
|
|
Chat,
|
|
|
|
SavedMessages,
|
2020-09-11 15:33:26 +00:00
|
|
|
RepliesMessages,
|
2018-06-28 17:12:13 +00:00
|
|
|
Other,
|
|
|
|
};
|
2018-06-02 14:29:21 +00:00
|
|
|
|
2018-06-18 21:52:13 +00:00
|
|
|
Step step = Step::Initializing;
|
|
|
|
|
2018-06-19 18:31:30 +00:00
|
|
|
int substepsPassed = 0;
|
|
|
|
int substepsNow = 0;
|
|
|
|
int substepsTotal = 0;
|
2018-06-02 14:29:21 +00:00
|
|
|
|
2018-06-28 17:12:13 +00:00
|
|
|
EntityType entityType = EntityType::Other;
|
2018-06-19 18:31:30 +00:00
|
|
|
QString entityName;
|
2018-06-02 14:29:21 +00:00
|
|
|
int entityIndex = 0;
|
2018-06-20 18:21:36 +00:00
|
|
|
int entityCount = 0;
|
2018-06-02 14:29:21 +00:00
|
|
|
|
|
|
|
int itemIndex = 0;
|
|
|
|
int itemCount = 0;
|
|
|
|
|
2021-03-22 12:32:40 +00:00
|
|
|
uint64 bytesRandomId = 0;
|
2018-06-19 18:31:30 +00:00
|
|
|
FileType bytesType = FileType::None;
|
|
|
|
QString bytesName;
|
2018-06-02 14:29:21 +00:00
|
|
|
int bytesLoaded = 0;
|
|
|
|
int bytesCount = 0;
|
|
|
|
};
|
|
|
|
|
2018-06-19 10:42:21 +00:00
|
|
|
struct ApiErrorState {
|
2021-03-12 12:48:00 +00:00
|
|
|
MTP::Error data;
|
2018-06-19 10:42:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct OutputErrorState {
|
|
|
|
QString path;
|
2018-06-02 14:29:21 +00:00
|
|
|
};
|
|
|
|
|
2018-06-21 00:54:59 +00:00
|
|
|
struct CancelledState {
|
|
|
|
};
|
|
|
|
|
2018-06-02 14:29:21 +00:00
|
|
|
struct FinishedState {
|
|
|
|
QString path;
|
2018-06-20 15:54:13 +00:00
|
|
|
int filesCount = 0;
|
|
|
|
int64 bytesCount = 0;
|
2018-06-02 14:29:21 +00:00
|
|
|
};
|
|
|
|
|
2020-08-31 09:04:17 +00:00
|
|
|
using State = std::variant<
|
|
|
|
v::null_t,
|
2018-06-02 14:29:21 +00:00
|
|
|
PasswordCheckState,
|
|
|
|
ProcessingState,
|
2018-06-19 10:42:21 +00:00
|
|
|
ApiErrorState,
|
|
|
|
OutputErrorState,
|
2018-06-21 00:54:59 +00:00
|
|
|
CancelledState,
|
2018-06-02 14:29:21 +00:00
|
|
|
FinishedState>;
|
|
|
|
|
2018-06-18 21:52:13 +00:00
|
|
|
//struct PasswordUpdate {
|
|
|
|
// enum class Type {
|
|
|
|
// CheckSucceed,
|
|
|
|
// WrongPassword,
|
|
|
|
// FloodLimit,
|
|
|
|
// RecoverUnavailable,
|
|
|
|
// };
|
|
|
|
// Type type = Type::WrongPassword;
|
|
|
|
//
|
|
|
|
//};
|
2018-06-02 14:29:21 +00:00
|
|
|
|
2019-02-17 11:06:37 +00:00
|
|
|
class Controller {
|
2018-06-02 14:29:21 +00:00
|
|
|
public:
|
2020-06-11 16:09:46 +00:00
|
|
|
Controller(
|
|
|
|
QPointer<MTP::Instance> mtproto,
|
|
|
|
const MTPInputPeer &peer);
|
2018-06-02 14:29:21 +00:00
|
|
|
|
|
|
|
rpl::producer<State> state() const;
|
|
|
|
|
|
|
|
// Password step.
|
2018-06-18 21:52:13 +00:00
|
|
|
//void submitPassword(const QString &password);
|
|
|
|
//void requestPasswordRecover();
|
|
|
|
//rpl::producer<PasswordUpdate> passwordUpdate() const;
|
|
|
|
//void reloadPasswordState();
|
|
|
|
//void cancelUnconfirmedPassword();
|
2018-06-02 14:29:21 +00:00
|
|
|
|
|
|
|
// Processing step.
|
2018-06-24 02:06:11 +00:00
|
|
|
void startExport(
|
|
|
|
const Settings &settings,
|
|
|
|
const Environment &environment);
|
2021-03-22 12:32:40 +00:00
|
|
|
void skipFile(uint64 randomId);
|
2018-06-21 00:54:59 +00:00
|
|
|
void cancelExportFast();
|
2018-06-02 14:29:21 +00:00
|
|
|
|
|
|
|
rpl::lifetime &lifetime();
|
|
|
|
|
2019-02-17 11:06:37 +00:00
|
|
|
~Controller();
|
2018-06-02 14:29:21 +00:00
|
|
|
|
|
|
|
private:
|
2019-02-17 11:06:37 +00:00
|
|
|
using Implementation = ControllerObject;
|
|
|
|
crl::object_on_queue<Implementation> _wrapped;
|
2018-06-02 14:29:21 +00:00
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Export
|