-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathexport_controller.h
145 lines (117 loc) · 2.54 KB
/
export_controller.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
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"
#include "mtproto/mtproto_response.h"
#include <QtCore/QPointer>
#include <crl/crl_object_on_queue.h>
namespace MTP {
class Instance;
} // namespace MTP
namespace Export {
class ControllerObject;
struct Settings;
struct Environment;
struct PasswordCheckState {
QString hint;
QString unconfirmedPattern;
bool requesting = true;
bool hasPassword = false;
bool checked = false;
MTPInputPeer singlePeer = MTP_inputPeerEmpty();
};
struct ProcessingState {
enum class Step {
Initializing,
DialogsList,
PersonalInfo,
Userpics,
Stories,
Contacts,
Sessions,
OtherData,
Dialogs,
};
enum class EntityType {
Chat,
SavedMessages,
RepliesMessages,
VerifyCodes,
Other,
};
Step step = Step::Initializing;
int substepsPassed = 0;
int substepsNow = 0;
int substepsTotal = 0;
EntityType entityType = EntityType::Other;
QString entityName;
int entityIndex = 0;
int entityCount = 0;
int itemIndex = 0;
int itemCount = 0;
uint64 bytesRandomId = 0;
QString bytesName;
int64 bytesLoaded = 0;
int64 bytesCount = 0;
};
struct ApiErrorState {
MTP::Error data;
};
struct OutputErrorState {
QString path;
};
struct CancelledState {
};
struct FinishedState {
QString path;
int filesCount = 0;
int64 bytesCount = 0;
};
using State = std::variant<
v::null_t,
PasswordCheckState,
ProcessingState,
ApiErrorState,
OutputErrorState,
CancelledState,
FinishedState>;
//struct PasswordUpdate {
// enum class Type {
// CheckSucceed,
// WrongPassword,
// FloodLimit,
// RecoverUnavailable,
// };
// Type type = Type::WrongPassword;
//
//};
class Controller {
public:
Controller(
QPointer<MTP::Instance> mtproto,
const MTPInputPeer &peer);
rpl::producer<State> state() const;
// Password step.
//void submitPassword(const QString &password);
//void requestPasswordRecover();
//rpl::producer<PasswordUpdate> passwordUpdate() const;
//void reloadPasswordState();
//void cancelUnconfirmedPassword();
// Processing step.
void startExport(
const Settings &settings,
const Environment &environment);
void skipFile(uint64 randomId);
void cancelExportFast();
rpl::lifetime &lifetime();
~Controller();
private:
using Implementation = ControllerObject;
crl::object_on_queue<Implementation> _wrapped;
rpl::lifetime _lifetime;
};
} // namespace Export