"Fossies" - the Fresh Open Source Software Archive 
Member "tdesktop-2.6.1/Telegram/SourceFiles/export/export_manager.cpp" (24 Feb 2021, 2218 Bytes) of package /linux/misc/tdesktop-2.6.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "export_manager.cpp" see the
Fossies "Dox" file reference documentation.
1 /*
2 This file is part of Telegram Desktop,
3 the official desktop application for the Telegram messaging service.
4
5 For license and copyright information please follow this link:
6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
7 */
8 #include "export/export_manager.h"
9
10 #include "export/export_controller.h"
11 #include "export/view/export_view_panel_controller.h"
12 #include "data/data_peer.h"
13 #include "main/main_session.h"
14 #include "main/main_account.h"
15 #include "ui/layers/box_content.h"
16 #include "base/unixtime.h"
17
18 namespace Export {
19
20 Manager::Manager() = default;
21
22 Manager::~Manager() = default;
23
24 void Manager::start(not_null<PeerData*> peer) {
25 start(&peer->session(), peer->input);
26 }
27
28 void Manager::start(
29 not_null<Main::Session*> session,
30 const MTPInputPeer &singlePeer) {
31 if (_panel) {
32 _panel->activatePanel();
33 return;
34 }
35 _controller = std::make_unique<Controller>(
36 &session->mtp(),
37 singlePeer);
38 _panel = std::make_unique<View::PanelController>(
39 session,
40 _controller.get());
41 session->account().sessionChanges(
42 ) | rpl::filter([=](Main::Session *value) {
43 return (value != session);
44 }) | rpl::start_with_next([=] {
45 stop();
46 }, _panel->lifetime());
47
48 _viewChanges.fire(_panel.get());
49
50 _panel->stopRequests(
51 ) | rpl::start_with_next([=] {
52 LOG(("Export Info: Stop requested."));
53 stop();
54 }, _controller->lifetime());
55 }
56
57 rpl::producer<View::PanelController*> Manager::currentView(
58 ) const {
59 return _viewChanges.events_starting_with(_panel.get());
60 }
61
62 bool Manager::inProgress() const {
63 return _controller != nullptr;
64 }
65
66 bool Manager::inProgress(not_null<Main::Session*> session) const {
67 return _panel && (&_panel->session() == session);
68 }
69
70 void Manager::stopWithConfirmation(FnMut<void()> callback) {
71 if (!_panel) {
72 callback();
73 return;
74 }
75 auto closeAndCall = [=, callback = std::move(callback)]() mutable {
76 auto saved = std::move(callback);
77 LOG(("Export Info: Stop With Confirmation."));
78 stop();
79 if (saved) {
80 saved();
81 }
82 };
83 _panel->stopWithConfirmation(std::move(closeAndCall));
84 }
85
86 void Manager::stop() {
87 if (_panel) {
88 LOG(("Export Info: Destroying."));
89 _panel = nullptr;
90 _viewChanges.fire(nullptr);
91 }
92 _controller = nullptr;
93 }
94
95 } // namespace Export