tdesktop/Telegram/SourceFiles/export/export_controller.h

144 lines
2.5 KiB
C
Raw Normal View History

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"
2019-11-18 09:28:14 +00:00
#include "mtproto/mtproto_rpc_sender.h"
#include <crl/crl_object_on_queue.h>
2018-06-02 14:29:21 +00:00
namespace Export {
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,
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,
};
enum class EntityType {
Chat,
SavedMessages,
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
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;
int entityCount = 0;
2018-06-02 14:29:21 +00:00
int itemIndex = 0;
int itemCount = 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;
};
struct ApiErrorState {
RPCError data;
};
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;
int filesCount = 0;
int64 bytesCount = 0;
2018-06-02 14:29:21 +00:00
};
using State = base::optional_variant<
PasswordCheckState,
ProcessingState,
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
class Controller {
2018-06-02 14:29:21 +00:00
public:
explicit Controller(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);
2018-06-21 00:54:59 +00:00
void cancelExportFast();
2018-06-02 14:29:21 +00:00
rpl::lifetime &lifetime();
~Controller();
2018-06-02 14:29:21 +00:00
private:
using Implementation = ControllerObject;
crl::object_on_queue<Implementation> _wrapped;
2018-06-02 14:29:21 +00:00
rpl::lifetime _lifetime;
};
} // namespace Export