libzypp 17.38.15

reporthelper.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_NG_REPORTHELPER_INCLUDED
13#define ZYPP_NG_REPORTHELPER_INCLUDED
14
15#include <zypp-core/ng/async/task.h>
16#include <zypp-common/PublicKey.h>
17#include <zypp/KeyContext.h>
18#include <zypp/KeyRing.h>
19#include <zypp/Digest.h>
20#include <zypp-core/base/Gettext.h>
21#include <zypp-core/ng/base/zyppglobal.h>
22#include <zypp-core/ng/ui/userrequest.h>
23#include <zypp/ng/context.h>
24
25#include <zypp/ZYppCallbacks.h>
26
27 namespace zyppng {
28
29 ZYPP_FWD_DECL_REFS (Context);
30
31 namespace detail {
32 template <typename Report, bool syncAsync >
33 class ReportHolder;
34
35 template <typename Report>
36 class ReportHolder<Report, true>
37 {};
38
39 template <typename Report>
40 class ReportHolder<Report, false>
41 {
42 public:
43 ReportHolder() : _d( std::make_shared<zypp::callback::SendReport<Report>>() ){}
44
45 ReportHolder(const ReportHolder &) = default;
46 ReportHolder(ReportHolder &&) = default;
47 ReportHolder &operator=(const ReportHolder &) = default;
48 ReportHolder &operator=(ReportHolder &&) = default;
49
50 auto &operator->() {
51 return *_d;
52 }
53
54 std::shared_ptr<zypp::callback::SendReport<Report>> _d;
55 };
56 }
57
58 class BasicReportHelper {
59 public:
60 BasicReportHelper(const BasicReportHelper &) = default;
61 BasicReportHelper(BasicReportHelper &&) = default;
62 BasicReportHelper &operator=(const BasicReportHelper &) = default;
63 BasicReportHelper &operator=(BasicReportHelper &&) = default;
64
65 const ContextRef &zyppContext() {
66 return _ctx;
67 }
68
69 static constexpr bool async () {
70 return ZYPP_IS_ASYNC;
71 }
72
73 protected:
74 BasicReportHelper( ContextRef &&ctx );
75 ContextRef _ctx;
76 };
77
78 class DigestReportHelper : public BasicReportHelper {
79 public:
80 using BasicReportHelper::async;
81
82 DigestReportHelper(ContextRef r)
83 : BasicReportHelper(std::move(r)) {}
84
85 DigestReportHelper(const DigestReportHelper &) = default;
86 DigestReportHelper(DigestReportHelper &&) = default;
87 DigestReportHelper &operator=(const DigestReportHelper &) = default;
88 DigestReportHelper &operator=(DigestReportHelper &&) = default;
89
90 bool askUserToAcceptNoDigest ( const zypp::Pathname &file );
91 bool askUserToAccepUnknownDigest ( const zypp::Pathname &file, const std::string &name );
92 bool askUserToAcceptWrongDigest ( const zypp::Pathname &file, const std::string &requested, const std::string &found );
93
94 private:
95 detail::ReportHolder<zypp::DigestReport, Context::isAsync> _report;
96 };
97
98 class KeyRingReportHelper : public BasicReportHelper {
99 public:
100 using BasicReportHelper::async;
101
102 KeyRingReportHelper(ContextRef r)
103 : BasicReportHelper(std::move(r)) {}
104
105 KeyRingReportHelper(const KeyRingReportHelper &) = default;
106 KeyRingReportHelper(KeyRingReportHelper &&) = default;
107 KeyRingReportHelper &operator=(const KeyRingReportHelper &) = default;
108 KeyRingReportHelper &operator=(KeyRingReportHelper &&) = default;
109
110 // -- Key Ring reports -- //
111
112 bool askUserToAcceptUnsignedFile( const std::string &file, const zypp::KeyContext &keycontext = {} );
113
114 zypp::KeyRingReport::KeyTrust askUserToAcceptKey( const zypp::PublicKey &key, const zypp::KeyContext &keycontext = {} );
115
116 bool askUserToAcceptPackageKey( const zypp::PublicKey &key_r, const zypp::KeyContext &keycontext_r = {} );
117
118 void infoVerify( const std::string & file_r, const zypp::PublicKeyData & keyData_r, const zypp::KeyContext &keycontext = {} );
119
120 void reportAutoImportKey( const std::list<zypp::PublicKeyData> & keyDataList_r, const zypp::PublicKeyData & keySigning_r, const zypp::KeyContext &keyContext_r );
121
122 bool askUserToAcceptVerificationFailed( const std::string &file, const zypp::PublicKey &key, const zypp::KeyContext &keycontext = {} );
123
124 bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id, const zypp::KeyContext &keycontext = {} );
125
126 private:
127 detail::ReportHolder<zypp::KeyRingReport, Context::isAsync> _report;
128
129 };
130
131 class JobReportHelper : public BasicReportHelper {
132 public:
133 using BasicReportHelper::async;
134
135 JobReportHelper(ContextRef r)
136 : BasicReportHelper(std::move(r)) {}
137
138 JobReportHelper(const JobReportHelper &) = default;
139 JobReportHelper(JobReportHelper &&) = default;
140 JobReportHelper &operator=(const JobReportHelper &) = default;
141 JobReportHelper &operator=(JobReportHelper &&) = default;
142
144 bool debug( std::string msg_r, UserData userData_r = UserData() );
145
147 bool info( std::string msg_r, UserData userData_r = UserData() );
148
150 bool warning( std::string msg_r, UserData userData_r = UserData() );
151
153 bool error( std::string msg_r, UserData userData_r = UserData() );
154
156 bool important( std::string msg_r, UserData userData_r = UserData() );
157
159 bool data( std::string msg_r, UserData userData_r = UserData() );
160
161 };
162}
163
164
165#endif //ZYPP_NG_REPORTHELPER_INCLUDED
Gettext.h
KeyContext.h
KeyRing.h
PublicKey.h
ZYppCallbacks.h
zypp::PublicKey
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Definition PublicKey.h:378
zypp::callback::UserData::UserData
UserData()
Default ctor.
Definition UserData.h:55
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zyppng::BasicReportHelper::operator=
BasicReportHelper & operator=(const BasicReportHelper &)=default
zyppng::BasicReportHelper::zyppContext
const ContextRef & zyppContext()
Definition reporthelper.h:65
zyppng::BasicReportHelper::BasicReportHelper
BasicReportHelper(const BasicReportHelper &)=default
zyppng::BasicReportHelper::async
static constexpr bool async()
Definition reporthelper.h:69
zyppng::BasicReportHelper::BasicReportHelper
BasicReportHelper(BasicReportHelper &&)=default
zyppng::BasicReportHelper::_ctx
ContextRef _ctx
Definition reporthelper.h:75
zyppng::BasicReportHelper::operator=
BasicReportHelper & operator=(BasicReportHelper &&)=default
zyppng::Context
Definition context.h:27
zyppng::DigestReportHelper::askUserToAcceptNoDigest
bool askUserToAcceptNoDigest(const zypp::Pathname &file)
Definition reporthelper.cc:23
zyppng::DigestReportHelper::operator=
DigestReportHelper & operator=(const DigestReportHelper &)=default
zyppng::DigestReportHelper::DigestReportHelper
DigestReportHelper(DigestReportHelper &&)=default
zyppng::DigestReportHelper::DigestReportHelper
DigestReportHelper(const DigestReportHelper &)=default
zyppng::DigestReportHelper::_report
detail::ReportHolder< zypp::DigestReport, Context::isAsync > _report
Definition reporthelper.h:95
zyppng::DigestReportHelper::DigestReportHelper
DigestReportHelper(ContextRef r)
Definition reporthelper.h:82
zyppng::DigestReportHelper::askUserToAccepUnknownDigest
bool askUserToAccepUnknownDigest(const zypp::Pathname &file, const std::string &name)
Definition reporthelper.cc:35
zyppng::DigestReportHelper::operator=
DigestReportHelper & operator=(DigestReportHelper &&)=default
zyppng::DigestReportHelper::askUserToAcceptWrongDigest
bool askUserToAcceptWrongDigest(const zypp::Pathname &file, const std::string &requested, const std::string &found)
Definition reporthelper.cc:48
zyppng::JobReportHelper::debug
bool debug(std::string msg_r, UserData userData_r=UserData())
send debug message text
Definition reporthelper.cc:183
zyppng::JobReportHelper::operator=
JobReportHelper & operator=(const JobReportHelper &)=default
zyppng::JobReportHelper::important
bool important(std::string msg_r, UserData userData_r=UserData())
send important message text
Definition reporthelper.cc:227
zyppng::JobReportHelper::data
bool data(std::string msg_r, UserData userData_r=UserData())
send data message
Definition reporthelper.cc:238
zyppng::JobReportHelper::JobReportHelper
JobReportHelper(ContextRef r)
Definition reporthelper.h:135
zyppng::JobReportHelper::info
bool info(std::string msg_r, UserData userData_r=UserData())
send message text
Definition reporthelper.cc:194
zyppng::JobReportHelper::JobReportHelper
JobReportHelper(JobReportHelper &&)=default
zyppng::JobReportHelper::JobReportHelper
JobReportHelper(const JobReportHelper &)=default
zyppng::JobReportHelper::error
bool error(std::string msg_r, UserData userData_r=UserData())
send error text
Definition reporthelper.cc:216
zyppng::JobReportHelper::operator=
JobReportHelper & operator=(JobReportHelper &&)=default
zyppng::JobReportHelper::warning
bool warning(std::string msg_r, UserData userData_r=UserData())
send warning text
Definition reporthelper.cc:205
zyppng::KeyRingReportHelper::operator=
KeyRingReportHelper & operator=(KeyRingReportHelper &&)=default
zyppng::KeyRingReportHelper::askUserToAcceptUnsignedFile
bool askUserToAcceptUnsignedFile(const std::string &file, const zypp::KeyContext &keycontext={})
Definition reporthelper.cc:61
zyppng::KeyRingReportHelper::_report
detail::ReportHolder< zypp::KeyRingReport, Context::isAsync > _report
Definition reporthelper.h:127
zyppng::KeyRingReportHelper::KeyRingReportHelper
KeyRingReportHelper(ContextRef r)
Definition reporthelper.h:102
zyppng::KeyRingReportHelper::KeyRingReportHelper
KeyRingReportHelper(const KeyRingReportHelper &)=default
zyppng::KeyRingReportHelper::KeyRingReportHelper
KeyRingReportHelper(KeyRingReportHelper &&)=default
zyppng::KeyRingReportHelper::askUserToAcceptPackageKey
bool askUserToAcceptPackageKey(const zypp::PublicKey &key_r, const zypp::KeyContext &keycontext_r={})
Definition reporthelper.cc:101
zyppng::KeyRingReportHelper::askUserToAcceptUnknownKey
bool askUserToAcceptUnknownKey(const std::string &file, const std::string &id, const zypp::KeyContext &keycontext={})
Definition reporthelper.cc:159
zyppng::KeyRingReportHelper::askUserToAcceptVerificationFailed
bool askUserToAcceptVerificationFailed(const std::string &file, const zypp::PublicKey &key, const zypp::KeyContext &keycontext={})
Definition reporthelper.cc:137
zyppng::KeyRingReportHelper::reportAutoImportKey
void reportAutoImportKey(const std::list< zypp::PublicKeyData > &keyDataList_r, const zypp::PublicKeyData &keySigning_r, const zypp::KeyContext &keyContext_r)
Definition reporthelper.cc:124
zyppng::KeyRingReportHelper::infoVerify
void infoVerify(const std::string &file_r, const zypp::PublicKeyData &keyData_r, const zypp::KeyContext &keycontext={})
Definition reporthelper.cc:112
zyppng::KeyRingReportHelper::operator=
KeyRingReportHelper & operator=(const KeyRingReportHelper &)=default
zyppng::KeyRingReportHelper::askUserToAcceptKey
zypp::KeyRingReport::KeyTrust askUserToAcceptKey(const zypp::PublicKey &key, const zypp::KeyContext &keycontext={})
Definition reporthelper.cc:85
zyppng::detail::ReportHolder< Report, false >::ReportHolder
ReportHolder(const ReportHolder &)=default
zyppng::detail::ReportHolder< Report, false >::operator->
auto & operator->()
Definition reporthelper.h:50
zyppng::detail::ReportHolder< Report, false >::operator=
ReportHolder & operator=(ReportHolder &&)=default
zyppng::detail::ReportHolder< Report, false >::ReportHolder
ReportHolder()
Definition reporthelper.h:43
zyppng::detail::ReportHolder< Report, false >::operator=
ReportHolder & operator=(const ReportHolder &)=default
zyppng::detail::ReportHolder< Report, false >::_d
std::shared_ptr< zypp::callback::SendReport< Report > > _d
Definition reporthelper.h:54
zyppng::detail::ReportHolder< Report, false >::ReportHolder
ReportHolder(ReportHolder &&)=default
zyppng::detail::ReportHolder
Definition reporthelper.h:33
context.h
std
Definition ansi.h:855
zypp::callback
Callbacks light.
Definition Callback.h:146
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zyppng::detail
Definition reporthelper.h:31
zyppng
Definition MediaNetworkRequestExecutor.h:16
zyppng::ZYPP_FWD_DECL_REFS
ZYPP_FWD_DECL_REFS(Context)
zyppng::UserData
zypp::callback::UserData UserData
Definition userrequest.h:18
zypp::KeyContext
Definition KeyContext.h:9
zypp::KeyRingReport::KeyTrust
KeyTrust
User reply options for the askUserToTrustKey callback.
Definition KeyRing.h:54
userrequest.h
Digest.h
zyppglobal.h