forked from rpm-software-management/dnf5
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallbacks.hpp
107 lines (77 loc) · 3.28 KB
/
callbacks.hpp
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
/*
Copyright Contributors to the libdnf project.
This file is part of libdnf: https://github.com/rpm-software-management/libdnf/
Libdnf is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
Libdnf is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with libdnf. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef DNF5DAEMON_CLIENT_CALLBACKS_HPP
#define DNF5DAEMON_CLIENT_CALLBACKS_HPP
#include <libdnf5-cli/progressbar/download_progress_bar.hpp>
#include <libdnf5-cli/progressbar/multi_progress_bar.hpp>
#include <sdbus-c++/sdbus-c++.h>
#include <string>
namespace dnfdaemon::client {
class Context;
class DbusCallback {
public:
explicit DbusCallback(Context & context) : context(context) {};
virtual ~DbusCallback() = default;
protected:
Context & context;
bool signature_valid(sdbus::Signal & signal);
};
class DownloadCB final : public DbusCallback {
public:
explicit DownloadCB(Context & context);
virtual ~DownloadCB() = default;
void add_new_download(sdbus::Signal & signal);
void progress(sdbus::Signal & signal);
void end(sdbus::Signal & signal);
void mirror_failure(sdbus::Signal & signal);
void key_import(sdbus::Signal & signal);
void reset_progress_bar();
void set_number_widget_visible(bool value);
void set_show_total_bar_limit(std::size_t limit);
private:
libdnf5::cli::progressbar::DownloadProgressBar * find_progress_bar(const std::string & download_id);
void print();
bool printed{false};
bool number_widget_visible{false};
std::size_t show_total_bar_limit{static_cast<std::size_t>(-1)};
std::unique_ptr<libdnf5::cli::progressbar::MultiProgressBar> multi_progress_bar;
// map {download_id: progressbar}
std::unordered_map<std::string, libdnf5::cli::progressbar::DownloadProgressBar *> progress_bars;
};
class TransactionCB final : public DbusCallback {
public:
explicit TransactionCB(Context & context);
virtual ~TransactionCB() = default;
void verify_start(sdbus::Signal & signal);
void verify_end(sdbus::Signal & signal);
void verify_progress(sdbus::Signal & signal);
void transaction_start(sdbus::Signal & signal);
void transaction_end(sdbus::Signal & signal);
void transaction_progress(sdbus::Signal & signal);
void action_start(sdbus::Signal & signal);
void action_end(sdbus::Signal & signal);
void action_progress(sdbus::Signal & signal);
void script_start(sdbus::Signal & signal);
void script_stop(sdbus::Signal & signal);
void script_error(sdbus::Signal & signal);
void unpack_error(sdbus::Signal & signal);
void finished(sdbus::Signal & signal);
private:
libdnf5::cli::progressbar::MultiProgressBar multi_progress_bar;
libdnf5::cli::progressbar::DownloadProgressBar * active_progress_bar{nullptr};
void new_progress_bar(uint64_t total, const std::string & description);
};
} // namespace dnfdaemon::client
#endif