tdesktop/Telegram/SourceFiles/export/export_controller.h

156 lines
2.7 KiB
C
Raw Normal View History

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