2018-06-11 18:35:27 +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/concurrent_sender.h"
|
|
|
|
|
|
|
|
namespace Export {
|
|
|
|
namespace Data {
|
|
|
|
struct File;
|
|
|
|
struct FileLocation;
|
|
|
|
struct PersonalInfo;
|
|
|
|
struct UserpicsInfo;
|
|
|
|
struct UserpicsSlice;
|
|
|
|
struct ContactsList;
|
2018-06-11 18:57:56 +00:00
|
|
|
struct SessionsList;
|
2018-06-12 18:09:21 +00:00
|
|
|
struct DialogsInfo;
|
2018-06-13 13:12:36 +00:00
|
|
|
struct DialogInfo;
|
|
|
|
struct MessagesSlice;
|
2018-06-11 18:35:27 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2018-06-13 13:12:36 +00:00
|
|
|
struct Settings;
|
|
|
|
|
2018-06-11 18:35:27 +00:00
|
|
|
class ApiWrap {
|
|
|
|
public:
|
|
|
|
ApiWrap(Fn<void(FnMut<void()>)> runner);
|
|
|
|
|
|
|
|
rpl::producer<RPCError> errors() const;
|
|
|
|
|
2018-06-13 13:12:36 +00:00
|
|
|
void startExport(const Settings &settings);
|
|
|
|
|
2018-06-11 18:35:27 +00:00
|
|
|
void requestPersonalInfo(FnMut<void(Data::PersonalInfo&&)> done);
|
|
|
|
|
|
|
|
void requestUserpics(
|
|
|
|
FnMut<void(Data::UserpicsInfo&&)> start,
|
|
|
|
Fn<void(Data::UserpicsSlice&&)> slice,
|
|
|
|
FnMut<void()> finish);
|
|
|
|
|
|
|
|
void requestContacts(FnMut<void(Data::ContactsList&&)> done);
|
|
|
|
|
2018-06-11 18:57:56 +00:00
|
|
|
void requestSessions(FnMut<void(Data::SessionsList&&)> done);
|
|
|
|
|
2018-06-13 13:12:36 +00:00
|
|
|
void requestDialogs(
|
|
|
|
FnMut<void(const Data::DialogsInfo&)> start,
|
|
|
|
Fn<void(const Data::DialogInfo&)> startOne,
|
|
|
|
Fn<void(Data::MessagesSlice&&)> sliceOne,
|
|
|
|
Fn<void()> finishOne,
|
|
|
|
FnMut<void()> finish);
|
2018-06-12 18:09:21 +00:00
|
|
|
|
2018-06-11 18:35:27 +00:00
|
|
|
~ApiWrap();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void handleUserpicsSlice(const MTPphotos_Photos &result);
|
|
|
|
void loadUserpicsFiles(Data::UserpicsSlice &&slice);
|
|
|
|
void loadNextUserpic();
|
|
|
|
void loadUserpicDone(const QString &relativePath);
|
|
|
|
void finishUserpics();
|
|
|
|
|
2018-06-12 18:09:21 +00:00
|
|
|
void requestDialogsSlice();
|
2018-06-13 13:12:36 +00:00
|
|
|
void appendDialogsSlice(Data::DialogsInfo &&info);
|
|
|
|
void finishDialogsList();
|
2018-06-13 17:10:12 +00:00
|
|
|
void fillDialogsPaths();
|
2018-06-13 13:12:36 +00:00
|
|
|
|
|
|
|
void requestNextDialog();
|
|
|
|
void requestMessagesSlice();
|
|
|
|
void loadMessagesFiles(Data::MessagesSlice &&slice);
|
|
|
|
void loadNextMessageFile();
|
|
|
|
void loadMessageFileDone(const QString &relativePath);
|
|
|
|
void finishMessages();
|
|
|
|
void finishDialogs();
|
2018-06-12 18:09:21 +00:00
|
|
|
|
2018-06-11 18:35:27 +00:00
|
|
|
void loadFile(const Data::File &file, FnMut<void(QString)> done);
|
|
|
|
void loadFilePart();
|
|
|
|
void filePartDone(int offset, const MTPupload_File &result);
|
|
|
|
|
|
|
|
template <typename Request>
|
|
|
|
[[nodiscard]] auto mainRequest(Request &&request);
|
|
|
|
|
|
|
|
[[nodiscard]] auto fileRequest(
|
|
|
|
const Data::FileLocation &location,
|
|
|
|
int offset);
|
|
|
|
|
|
|
|
void error(RPCError &&error);
|
|
|
|
void error(const QString &text);
|
|
|
|
|
|
|
|
MTP::ConcurrentSender _mtp;
|
2018-06-13 13:12:36 +00:00
|
|
|
|
|
|
|
std::unique_ptr<Settings> _settings;
|
2018-06-11 18:35:27 +00:00
|
|
|
MTPInputUser _user = MTP_inputUserSelf();
|
|
|
|
|
|
|
|
struct UserpicsProcess;
|
|
|
|
std::unique_ptr<UserpicsProcess> _userpicsProcess;
|
|
|
|
|
|
|
|
struct FileProcess;
|
|
|
|
std::unique_ptr<FileProcess> _fileProcess;
|
|
|
|
|
2018-06-12 18:09:21 +00:00
|
|
|
struct DialogsProcess;
|
|
|
|
std::unique_ptr<DialogsProcess> _dialogsProcess;
|
|
|
|
|
2018-06-11 18:35:27 +00:00
|
|
|
rpl::event_stream<RPCError> _errors;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Export
|