mirror of
https://github.com/telegramdesktop/tdesktop
synced 2024-12-26 00:12:25 +00:00
Make crl::object_on_queue usages consistent.
This commit is contained in:
parent
7c1704e68b
commit
c9716f3c72
@ -754,7 +754,7 @@ void Session::startExport(const MTPInputPeer &singlePeer) {
|
|||||||
_exportPanel->activatePanel();
|
_exportPanel->activatePanel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_export = std::make_unique<Export::ControllerWrap>(singlePeer);
|
_export = std::make_unique<Export::Controller>(singlePeer);
|
||||||
_exportPanel = std::make_unique<Export::View::PanelController>(
|
_exportPanel = std::make_unique<Export::View::PanelController>(
|
||||||
_export.get());
|
_export.get());
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class Reader;
|
|||||||
} // namespace Media
|
} // namespace Media
|
||||||
|
|
||||||
namespace Export {
|
namespace Export {
|
||||||
class ControllerWrap;
|
class Controller;
|
||||||
namespace View {
|
namespace View {
|
||||||
class PanelController;
|
class PanelController;
|
||||||
} // namespace View
|
} // namespace View
|
||||||
@ -669,7 +669,7 @@ private:
|
|||||||
|
|
||||||
Storage::DatabasePointer _cache;
|
Storage::DatabasePointer _cache;
|
||||||
|
|
||||||
std::unique_ptr<Export::ControllerWrap> _export;
|
std::unique_ptr<Export::Controller> _export;
|
||||||
std::unique_ptr<Export::View::PanelController> _exportPanel;
|
std::unique_ptr<Export::View::PanelController> _exportPanel;
|
||||||
rpl::event_stream<Export::View::PanelController*> _exportViewChanges;
|
rpl::event_stream<Export::View::PanelController*> _exportViewChanges;
|
||||||
TimeId _exportAvailableAt = 0;
|
TimeId _exportAvailableAt = 0;
|
||||||
|
@ -31,10 +31,10 @@ Settings NormalizeSettings(const Settings &settings) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class Controller {
|
class ControllerObject {
|
||||||
public:
|
public:
|
||||||
Controller(
|
ControllerObject(
|
||||||
crl::weak_on_queue<Controller> weak,
|
crl::weak_on_queue<ControllerObject> weak,
|
||||||
const MTPInputPeer &peer);
|
const MTPInputPeer &peer);
|
||||||
|
|
||||||
rpl::producer<State> state() const;
|
rpl::producer<State> state() const;
|
||||||
@ -130,8 +130,8 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller::Controller(
|
ControllerObject::ControllerObject(
|
||||||
crl::weak_on_queue<Controller> weak,
|
crl::weak_on_queue<ControllerObject> weak,
|
||||||
const MTPInputPeer &peer)
|
const MTPInputPeer &peer)
|
||||||
: _api(weak.runner())
|
: _api(weak.runner())
|
||||||
, _state(PasswordCheckState{}) {
|
, _state(PasswordCheckState{}) {
|
||||||
@ -153,7 +153,7 @@ Controller::Controller(
|
|||||||
setState(std::move(state));
|
setState(std::move(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<State> Controller::state() const {
|
rpl::producer<State> ControllerObject::state() const {
|
||||||
return rpl::single(
|
return rpl::single(
|
||||||
_state
|
_state
|
||||||
) | rpl::then(
|
) | rpl::then(
|
||||||
@ -164,7 +164,7 @@ rpl::producer<State> Controller::state() const {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::setState(State &&state) {
|
void ControllerObject::setState(State &&state) {
|
||||||
if (_state.is<CancelledState>()) {
|
if (_state.is<CancelledState>()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -172,11 +172,11 @@ void Controller::setState(State &&state) {
|
|||||||
_stateChanges.fire_copy(_state);
|
_stateChanges.fire_copy(_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::ioError(const QString &path) {
|
void ControllerObject::ioError(const QString &path) {
|
||||||
setState(OutputErrorState{ path });
|
setState(OutputErrorState{ path });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Controller::ioCatchError(Output::Result result) {
|
bool ControllerObject::ioCatchError(Output::Result result) {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
ioError(result.path);
|
ioError(result.path);
|
||||||
return true;
|
return true;
|
||||||
@ -184,24 +184,24 @@ bool Controller::ioCatchError(Output::Result result) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void Controller::submitPassword(const QString &password) {
|
//void ControllerObject::submitPassword(const QString &password) {
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//void Controller::requestPasswordRecover() {
|
//void ControllerObject::requestPasswordRecover() {
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//rpl::producer<PasswordUpdate> Controller::passwordUpdate() const {
|
//rpl::producer<PasswordUpdate> ControllerObject::passwordUpdate() const {
|
||||||
// return rpl::never<PasswordUpdate>();
|
// return rpl::never<PasswordUpdate>();
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//void Controller::reloadPasswordState() {
|
//void ControllerObject::reloadPasswordState() {
|
||||||
// //_mtp.request(base::take(_passwordRequestId)).cancel();
|
// //_mtp.request(base::take(_passwordRequestId)).cancel();
|
||||||
// requestPasswordState();
|
// requestPasswordState();
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//void Controller::requestPasswordState() {
|
//void ControllerObject::requestPasswordState() {
|
||||||
// if (_passwordRequestId) {
|
// if (_passwordRequestId) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
@ -214,7 +214,7 @@ bool Controller::ioCatchError(Output::Result result) {
|
|||||||
// //}).send();
|
// //}).send();
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//void Controller::passwordStateDone(const MTPaccount_Password &result) {
|
//void ControllerObject::passwordStateDone(const MTPaccount_Password &result) {
|
||||||
// auto state = PasswordCheckState();
|
// auto state = PasswordCheckState();
|
||||||
// state.checked = false;
|
// state.checked = false;
|
||||||
// state.requesting = false;
|
// state.requesting = false;
|
||||||
@ -224,11 +224,11 @@ bool Controller::ioCatchError(Output::Result result) {
|
|||||||
// setState(std::move(state));
|
// setState(std::move(state));
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//void Controller::cancelUnconfirmedPassword() {
|
//void ControllerObject::cancelUnconfirmedPassword() {
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void Controller::startExport(
|
void ControllerObject::startExport(
|
||||||
const Settings &settings,
|
const Settings &settings,
|
||||||
const Environment &environment) {
|
const Environment &environment) {
|
||||||
if (!_settings.path.isEmpty()) {
|
if (!_settings.path.isEmpty()) {
|
||||||
@ -243,7 +243,7 @@ void Controller::startExport(
|
|||||||
exportNext();
|
exportNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::fillExportSteps() {
|
void ControllerObject::fillExportSteps() {
|
||||||
using Type = Settings::Type;
|
using Type = Settings::Type;
|
||||||
_steps.push_back(Step::Initializing);
|
_steps.push_back(Step::Initializing);
|
||||||
if (_settings.types & Type::AnyChatsMask) {
|
if (_settings.types & Type::AnyChatsMask) {
|
||||||
@ -269,7 +269,7 @@ void Controller::fillExportSteps() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::fillSubstepsInSteps(const ApiWrap::StartInfo &info) {
|
void ControllerObject::fillSubstepsInSteps(const ApiWrap::StartInfo &info) {
|
||||||
auto result = std::vector<int>();
|
auto result = std::vector<int>();
|
||||||
const auto push = [&](Step step, int count) {
|
const auto push = [&](Step step, int count) {
|
||||||
const auto index = static_cast<int>(step);
|
const auto index = static_cast<int>(step);
|
||||||
@ -304,12 +304,12 @@ void Controller::fillSubstepsInSteps(const ApiWrap::StartInfo &info) {
|
|||||||
_substepsTotal = ranges::accumulate(_substepsInStep, 0);
|
_substepsTotal = ranges::accumulate(_substepsInStep, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::cancelExportFast() {
|
void ControllerObject::cancelExportFast() {
|
||||||
_api.cancelExportFast();
|
_api.cancelExportFast();
|
||||||
setState(CancelledState());
|
setState(CancelledState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::exportNext() {
|
void ControllerObject::exportNext() {
|
||||||
if (++_stepIndex >= _steps.size()) {
|
if (++_stepIndex >= _steps.size()) {
|
||||||
if (ioCatchError(_writer->finish())) {
|
if (ioCatchError(_writer->finish())) {
|
||||||
return;
|
return;
|
||||||
@ -331,17 +331,17 @@ void Controller::exportNext() {
|
|||||||
case Step::OtherData: return exportOtherData();
|
case Step::OtherData: return exportOtherData();
|
||||||
case Step::Dialogs: return exportDialogs();
|
case Step::Dialogs: return exportDialogs();
|
||||||
}
|
}
|
||||||
Unexpected("Step in Controller::exportNext.");
|
Unexpected("Step in ControllerObject::exportNext.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::initialize() {
|
void ControllerObject::initialize() {
|
||||||
setState(stateInitializing());
|
setState(stateInitializing());
|
||||||
_api.startExport(_settings, &_stats, [=](ApiWrap::StartInfo info) {
|
_api.startExport(_settings, &_stats, [=](ApiWrap::StartInfo info) {
|
||||||
initialized(info);
|
initialized(info);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::initialized(const ApiWrap::StartInfo &info) {
|
void ControllerObject::initialized(const ApiWrap::StartInfo &info) {
|
||||||
if (ioCatchError(_writer->start(_settings, _environment, &_stats))) {
|
if (ioCatchError(_writer->start(_settings, _environment, &_stats))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ void Controller::initialized(const ApiWrap::StartInfo &info) {
|
|||||||
exportNext();
|
exportNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::collectDialogsList() {
|
void ControllerObject::collectDialogsList() {
|
||||||
setState(stateDialogsList(0));
|
setState(stateDialogsList(0));
|
||||||
_api.requestDialogsList([=](int count) {
|
_api.requestDialogsList([=](int count) {
|
||||||
setState(stateDialogsList(count));
|
setState(stateDialogsList(count));
|
||||||
@ -360,7 +360,7 @@ void Controller::collectDialogsList() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::exportPersonalInfo() {
|
void ControllerObject::exportPersonalInfo() {
|
||||||
setState(statePersonalInfo());
|
setState(statePersonalInfo());
|
||||||
_api.requestPersonalInfo([=](Data::PersonalInfo &&result) {
|
_api.requestPersonalInfo([=](Data::PersonalInfo &&result) {
|
||||||
if (ioCatchError(_writer->writePersonal(result))) {
|
if (ioCatchError(_writer->writePersonal(result))) {
|
||||||
@ -370,7 +370,7 @@ void Controller::exportPersonalInfo() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::exportUserpics() {
|
void ControllerObject::exportUserpics() {
|
||||||
_api.requestUserpics([=](Data::UserpicsInfo &&start) {
|
_api.requestUserpics([=](Data::UserpicsInfo &&start) {
|
||||||
if (ioCatchError(_writer->writeUserpicsStart(start))) {
|
if (ioCatchError(_writer->writeUserpicsStart(start))) {
|
||||||
return false;
|
return false;
|
||||||
@ -396,7 +396,7 @@ void Controller::exportUserpics() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::exportContacts() {
|
void ControllerObject::exportContacts() {
|
||||||
setState(stateContacts());
|
setState(stateContacts());
|
||||||
_api.requestContacts([=](Data::ContactsList &&result) {
|
_api.requestContacts([=](Data::ContactsList &&result) {
|
||||||
if (ioCatchError(_writer->writeContactsList(result))) {
|
if (ioCatchError(_writer->writeContactsList(result))) {
|
||||||
@ -406,7 +406,7 @@ void Controller::exportContacts() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::exportSessions() {
|
void ControllerObject::exportSessions() {
|
||||||
setState(stateSessions());
|
setState(stateSessions());
|
||||||
_api.requestSessions([=](Data::SessionsList &&result) {
|
_api.requestSessions([=](Data::SessionsList &&result) {
|
||||||
if (ioCatchError(_writer->writeSessionsList(result))) {
|
if (ioCatchError(_writer->writeSessionsList(result))) {
|
||||||
@ -416,7 +416,7 @@ void Controller::exportSessions() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::exportOtherData() {
|
void ControllerObject::exportOtherData() {
|
||||||
setState(stateOtherData());
|
setState(stateOtherData());
|
||||||
const auto relativePath = "lists/other_data.json";
|
const auto relativePath = "lists/other_data.json";
|
||||||
_api.requestOtherData(relativePath, [=](Data::File &&result) {
|
_api.requestOtherData(relativePath, [=](Data::File &&result) {
|
||||||
@ -427,7 +427,7 @@ void Controller::exportOtherData() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::exportDialogs() {
|
void ControllerObject::exportDialogs() {
|
||||||
if (ioCatchError(_writer->writeDialogsStart(_dialogsInfo))) {
|
if (ioCatchError(_writer->writeDialogsStart(_dialogsInfo))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -435,7 +435,7 @@ void Controller::exportDialogs() {
|
|||||||
exportNextDialog();
|
exportNextDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::exportNextDialog() {
|
void ControllerObject::exportNextDialog() {
|
||||||
const auto index = ++_dialogIndex;
|
const auto index = ++_dialogIndex;
|
||||||
const auto info = _dialogsInfo.item(index);
|
const auto info = _dialogsInfo.item(index);
|
||||||
if (info) {
|
if (info) {
|
||||||
@ -474,7 +474,7 @@ void Controller::exportNextDialog() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Callback>
|
template <typename Callback>
|
||||||
ProcessingState Controller::prepareState(
|
ProcessingState ControllerObject::prepareState(
|
||||||
Step step,
|
Step step,
|
||||||
Callback &&callback) const {
|
Callback &&callback) const {
|
||||||
if (step != _lastProcessingStep) {
|
if (step != _lastProcessingStep) {
|
||||||
@ -491,11 +491,11 @@ ProcessingState Controller::prepareState(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessingState Controller::stateInitializing() const {
|
ProcessingState ControllerObject::stateInitializing() const {
|
||||||
return ProcessingState();
|
return ProcessingState();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessingState Controller::stateDialogsList(int processed) const {
|
ProcessingState ControllerObject::stateDialogsList(int processed) const {
|
||||||
const auto step = Step::DialogsList;
|
const auto step = Step::DialogsList;
|
||||||
return prepareState(step, [&](ProcessingState &result) {
|
return prepareState(step, [&](ProcessingState &result) {
|
||||||
result.entityIndex = processed;
|
result.entityIndex = processed;
|
||||||
@ -504,11 +504,11 @@ ProcessingState Controller::stateDialogsList(int processed) const {
|
|||||||
substepsInStep(Step::Dialogs));
|
substepsInStep(Step::Dialogs));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ProcessingState Controller::statePersonalInfo() const {
|
ProcessingState ControllerObject::statePersonalInfo() const {
|
||||||
return prepareState(Step::PersonalInfo);
|
return prepareState(Step::PersonalInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessingState Controller::stateUserpics(
|
ProcessingState ControllerObject::stateUserpics(
|
||||||
const DownloadProgress &progress) const {
|
const DownloadProgress &progress) const {
|
||||||
return prepareState(Step::Userpics, [&](ProcessingState &result) {
|
return prepareState(Step::Userpics, [&](ProcessingState &result) {
|
||||||
result.entityIndex = _userpicsWritten + progress.itemIndex;
|
result.entityIndex = _userpicsWritten + progress.itemIndex;
|
||||||
@ -523,19 +523,19 @@ ProcessingState Controller::stateUserpics(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessingState Controller::stateContacts() const {
|
ProcessingState ControllerObject::stateContacts() const {
|
||||||
return prepareState(Step::Contacts);
|
return prepareState(Step::Contacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessingState Controller::stateSessions() const {
|
ProcessingState ControllerObject::stateSessions() const {
|
||||||
return prepareState(Step::Sessions);
|
return prepareState(Step::Sessions);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessingState Controller::stateOtherData() const {
|
ProcessingState ControllerObject::stateOtherData() const {
|
||||||
return prepareState(Step::OtherData);
|
return prepareState(Step::OtherData);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessingState Controller::stateDialogs(
|
ProcessingState ControllerObject::stateDialogs(
|
||||||
const DownloadProgress &progress) const {
|
const DownloadProgress &progress) const {
|
||||||
const auto step = Step::Dialogs;
|
const auto step = Step::Dialogs;
|
||||||
return prepareState(step, [&](ProcessingState &result) {
|
return prepareState(step, [&](ProcessingState &result) {
|
||||||
@ -547,7 +547,7 @@ ProcessingState Controller::stateDialogs(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::fillMessagesState(
|
void ControllerObject::fillMessagesState(
|
||||||
ProcessingState &result,
|
ProcessingState &result,
|
||||||
const Data::DialogsInfo &info,
|
const Data::DialogsInfo &info,
|
||||||
int index,
|
int index,
|
||||||
@ -572,81 +572,81 @@ void Controller::fillMessagesState(
|
|||||||
result.bytesCount = progress.total;
|
result.bytesCount = progress.total;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Controller::substepsInStep(Step step) const {
|
int ControllerObject::substepsInStep(Step step) const {
|
||||||
Expects(_substepsInStep.size() > static_cast<int>(step));
|
Expects(_substepsInStep.size() > static_cast<int>(step));
|
||||||
|
|
||||||
return _substepsInStep[static_cast<int>(step)];
|
return _substepsInStep[static_cast<int>(step)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::setFinishedState() {
|
void ControllerObject::setFinishedState() {
|
||||||
setState(FinishedState{
|
setState(FinishedState{
|
||||||
_writer->mainFilePath(),
|
_writer->mainFilePath(),
|
||||||
_stats.filesCount(),
|
_stats.filesCount(),
|
||||||
_stats.bytesCount() });
|
_stats.bytesCount() });
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerWrap::ControllerWrap(const MTPInputPeer &peer) : _wrapped(peer) {
|
Controller::Controller(const MTPInputPeer &peer) : _wrapped(peer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<State> ControllerWrap::state() const {
|
rpl::producer<State> Controller::state() const {
|
||||||
return _wrapped.producer_on_main([=](const Controller &controller) {
|
return _wrapped.producer_on_main([=](const Implementation &unwrapped) {
|
||||||
return controller.state();
|
return unwrapped.state();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//void ControllerWrap::submitPassword(const QString &password) {
|
//void Controller::submitPassword(const QString &password) {
|
||||||
// _wrapped.with([=](Controller &controller) {
|
// _wrapped.with([=](Implementation &unwrapped) {
|
||||||
// controller.submitPassword(password);
|
// unwrapped.submitPassword(password);
|
||||||
// });
|
// });
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//void ControllerWrap::requestPasswordRecover() {
|
//void Controller::requestPasswordRecover() {
|
||||||
// _wrapped.with([=](Controller &controller) {
|
// _wrapped.with([=](Implementation &unwrapped) {
|
||||||
// controller.requestPasswordRecover();
|
// unwrapped.requestPasswordRecover();
|
||||||
// });
|
// });
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//rpl::producer<PasswordUpdate> ControllerWrap::passwordUpdate() const {
|
//rpl::producer<PasswordUpdate> Controller::passwordUpdate() const {
|
||||||
// return _wrapped.producer_on_main([=](const Controller &controller) {
|
// return _wrapped.producer_on_main([=](const Implementation &unwrapped) {
|
||||||
// return controller.passwordUpdate();
|
// return unwrapped.passwordUpdate();
|
||||||
// });
|
// });
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//void ControllerWrap::reloadPasswordState() {
|
//void Controller::reloadPasswordState() {
|
||||||
// _wrapped.with([=](Controller &controller) {
|
// _wrapped.with([=](Implementation &unwrapped) {
|
||||||
// controller.reloadPasswordState();
|
// unwrapped.reloadPasswordState();
|
||||||
// });
|
// });
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//void ControllerWrap::cancelUnconfirmedPassword() {
|
//void Controller::cancelUnconfirmedPassword() {
|
||||||
// _wrapped.with([=](Controller &controller) {
|
// _wrapped.with([=](Implementation &unwrapped) {
|
||||||
// controller.cancelUnconfirmedPassword();
|
// unwrapped.cancelUnconfirmedPassword();
|
||||||
// });
|
// });
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void ControllerWrap::startExport(
|
void Controller::startExport(
|
||||||
const Settings &settings,
|
const Settings &settings,
|
||||||
const Environment &environment) {
|
const Environment &environment) {
|
||||||
LOG(("Export Info: Started export to '%1'.").arg(settings.path));
|
LOG(("Export Info: Started export to '%1'.").arg(settings.path));
|
||||||
|
|
||||||
_wrapped.with([=](Controller &controller) {
|
_wrapped.with([=](Implementation &unwrapped) {
|
||||||
controller.startExport(settings, environment);
|
unwrapped.startExport(settings, environment);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerWrap::cancelExportFast() {
|
void Controller::cancelExportFast() {
|
||||||
LOG(("Export Info: Cancelled export."));
|
LOG(("Export Info: Cancelled export."));
|
||||||
|
|
||||||
_wrapped.with([=](Controller &controller) {
|
_wrapped.with([=](Implementation &unwrapped) {
|
||||||
controller.cancelExportFast();
|
unwrapped.cancelExportFast();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::lifetime &ControllerWrap::lifetime() {
|
rpl::lifetime &Controller::lifetime() {
|
||||||
return _lifetime;
|
return _lifetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerWrap::~ControllerWrap() {
|
Controller::~Controller() {
|
||||||
LOG(("Export Info: Controller destroyed."));
|
LOG(("Export Info: Controller destroyed."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
|
|
||||||
namespace Export {
|
namespace Export {
|
||||||
|
|
||||||
class Controller;
|
class ControllerObject;
|
||||||
struct Settings;
|
struct Settings;
|
||||||
struct Environment;
|
struct Environment;
|
||||||
|
|
||||||
@ -109,9 +109,9 @@ using State = base::optional_variant<
|
|||||||
//
|
//
|
||||||
//};
|
//};
|
||||||
|
|
||||||
class ControllerWrap {
|
class Controller {
|
||||||
public:
|
public:
|
||||||
explicit ControllerWrap(const MTPInputPeer &peer);
|
explicit Controller(const MTPInputPeer &peer);
|
||||||
|
|
||||||
rpl::producer<State> state() const;
|
rpl::producer<State> state() const;
|
||||||
|
|
||||||
@ -130,10 +130,11 @@ public:
|
|||||||
|
|
||||||
rpl::lifetime &lifetime();
|
rpl::lifetime &lifetime();
|
||||||
|
|
||||||
~ControllerWrap();
|
~Controller();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
crl::object_on_queue<Controller> _wrapped;
|
using Implementation = ControllerObject;
|
||||||
|
crl::object_on_queue<Implementation> _wrapped;
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -124,7 +124,7 @@ void ResolveSettings(Settings &settings) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PanelController::PanelController(not_null<ControllerWrap*> process)
|
PanelController::PanelController(not_null<Controller*> process)
|
||||||
: _process(process)
|
: _process(process)
|
||||||
, _settings(std::make_unique<Settings>(Local::ReadExportSettings()))
|
, _settings(std::make_unique<Settings>(Local::ReadExportSettings()))
|
||||||
, _saveSettingsTimer([=] { saveSettings(); }) {
|
, _saveSettingsTimer([=] { saveSettings(); }) {
|
||||||
|
@ -34,7 +34,7 @@ class Panel;
|
|||||||
|
|
||||||
class PanelController {
|
class PanelController {
|
||||||
public:
|
public:
|
||||||
PanelController(not_null<ControllerWrap*> process);
|
PanelController(not_null<Controller*> process);
|
||||||
|
|
||||||
void activatePanel();
|
void activatePanel();
|
||||||
void stopWithConfirmation(FnMut<void()> callback = nullptr);
|
void stopWithConfirmation(FnMut<void()> callback = nullptr);
|
||||||
@ -65,7 +65,7 @@ private:
|
|||||||
|
|
||||||
void saveSettings() const;
|
void saveSettings() const;
|
||||||
|
|
||||||
not_null<ControllerWrap*> _process;
|
not_null<Controller*> _process;
|
||||||
std::unique_ptr<Settings> _settings;
|
std::unique_ptr<Settings> _settings;
|
||||||
base::Timer _saveSettingsTimer;
|
base::Timer _saveSettingsTimer;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user