libzypp: zypp/ng/reporthelper.h Source File

libzypp 17.36.6

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-common/PublicKey.h>
16#include <zypp/KeyContext.h>
17#include <zypp/KeyRing.h>
18#include <zypp/Digest.h>
19#include <zypp-core/base/Gettext.h>
20#include <zypp-core/zyppng/base/zyppglobal.h>
21#include <zypp-core/zyppng/ui/userrequest.h>
22#include <zypp/ng/context.h>
23#include <zypp/ng/workflows/contextfacade.h>
24
25#include <zypp/ZYppCallbacks.h>
26
27namespace zyppng {
28
29 ZYPP_FWD_DECL_REFS (Context);
30
31 namespace detail {
32 template <typename ContextRefType, typename Report>
33 class ReportHolder;
34
35 template <typename Report>
36 class ReportHolder<ContextRef, Report>
37 {};
38
39 template <typename Report>
40 class ReportHolder<SyncContextRef, Report>
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 template<typename ZyppContextRef>
59 class BasicReportHelper {
60 public:
61 BasicReportHelper(const BasicReportHelper &) = default;
62 BasicReportHelper(BasicReportHelper &&) = default;
63 BasicReportHelper &operator=(const BasicReportHelper &) = default;
64 BasicReportHelper &operator=(BasicReportHelper &&) = default;
65
66 const ZyppContextRef &zyppContext() {
67 return _ctx;
68 }
69
70 static constexpr bool async () {
71 return std::is_same<ZyppContextRef, ContextRef>();
72 }
73
74 protected:
75 BasicReportHelper( ZyppContextRef &&ctx );
76 ZyppContextRef _ctx;
77 };
78
79 template<typename ZyppContextRef>
80 class DigestReportHelper : public BasicReportHelper<ZyppContextRef> {
81 public:
82 using BasicReportHelper<ZyppContextRef>::async;
83
84 DigestReportHelper(ZyppContextRef r)
85 : BasicReportHelper<ZyppContextRef>(std::move(r)) {}
86
87 DigestReportHelper(const DigestReportHelper &) = default;
88 DigestReportHelper(DigestReportHelper &&) = default;
89 DigestReportHelper &operator=(const DigestReportHelper &) = default;
90 DigestReportHelper &operator=(DigestReportHelper &&) = default;
91
92 bool askUserToAcceptNoDigest ( const zypp::Pathname &file );
93 bool askUserToAccepUnknownDigest ( const zypp::Pathname &file, const std::string &name );
94 bool askUserToAcceptWrongDigest ( const zypp::Pathname &file, const std::string &requested, const std::string &found );
95
96 private:
97 detail::ReportHolder<ZyppContextRef, zypp::DigestReport> _report;
98 };
99
100 template<typename ZyppContextRef>
101 class KeyRingReportHelper : public BasicReportHelper<ZyppContextRef> {
102 public:
103 using BasicReportHelper<ZyppContextRef>::async;
104
105 KeyRingReportHelper(ZyppContextRef r)
106 : BasicReportHelper<ZyppContextRef>(std::move(r)) {}
107
108 KeyRingReportHelper(const KeyRingReportHelper &) = default;
109 KeyRingReportHelper(KeyRingReportHelper &&) = default;
110 KeyRingReportHelper &operator=(const KeyRingReportHelper &) = default;
111 KeyRingReportHelper &operator=(KeyRingReportHelper &&) = default;
112
113 // -- Key Ring reports -- //
114
115 bool askUserToAcceptUnsignedFile( const std::string &file, const zypp::KeyContext &keycontext = {} );
116
117 zypp::KeyRingReport::KeyTrust askUserToAcceptKey( const zypp::PublicKey &key, const zypp::KeyContext &keycontext = {} );
118
119 bool askUserToAcceptPackageKey( const zypp::PublicKey &key_r, const zypp::KeyContext &keycontext_r = {} );
120
121 void infoVerify( const std::string & file_r, const zypp::PublicKeyData & keyData_r, const zypp::KeyContext &keycontext = {} );
122
123 void reportAutoImportKey( const std::list<zypp::PublicKeyData> & keyDataList_r, const zypp::PublicKeyData & keySigning_r, const zypp::KeyContext &keyContext_r );
124
125 bool askUserToAcceptVerificationFailed( const std::string &file, const zypp::PublicKey &key, const zypp::KeyContext &keycontext = {} );
126
127 bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id, const zypp::KeyContext &keycontext = {} );
128
129 private:
130 detail::ReportHolder<ZyppContextRef, zypp::KeyRingReport> _report;
131
132 };
133
134 template<typename ZyppContextRef>
135 class JobReportHelper : public BasicReportHelper<ZyppContextRef> {
136 public:
137 using BasicReportHelper<ZyppContextRef>::async;
138
139 JobReportHelper(ZyppContextRef r)
140 : BasicReportHelper<ZyppContextRef>(std::move(r)) {}
141
142 JobReportHelper(const JobReportHelper &) = default;
143 JobReportHelper(JobReportHelper &&) = default;
144 JobReportHelper &operator=(const JobReportHelper &) = default;
145 JobReportHelper &operator=(JobReportHelper &&) = default;
146
148 bool debug( std::string msg_r, UserData userData_r = UserData() );
149
151 bool info( std::string msg_r, UserData userData_r = UserData() );
152
154 bool warning( std::string msg_r, UserData userData_r = UserData() );
155
157 bool error( std::string msg_r, UserData userData_r = UserData() );
158
160 bool important( std::string msg_r, UserData userData_r = UserData() );
161
163 bool data( std::string msg_r, UserData userData_r = UserData() );
164
165 };
166}
167
168
169#endif //ZYPP_NG_REPORTHELPER_INCLUDED
KeyContext.h
KeyRing.h
ZYppCallbacks.h
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zyppng::BasicReportHelper::BasicReportHelper
BasicReportHelper(const BasicReportHelper &)=default
zyppng::BasicReportHelper::BasicReportHelper
BasicReportHelper(BasicReportHelper &&)=default
zyppng::BasicReportHelper::_ctx
ZyppContextRef _ctx
Definition reporthelper.h:76
zyppng::BasicReportHelper::async
static constexpr bool async()
Definition reporthelper.h:70
zyppng::BasicReportHelper::zyppContext
const ZyppContextRef & zyppContext()
Definition reporthelper.h:66
zyppng::BasicReportHelper::operator=
BasicReportHelper & operator=(BasicReportHelper &&)=default
zyppng::BasicReportHelper::operator=
BasicReportHelper & operator=(const BasicReportHelper &)=default
zyppng::Context
Definition context.h:39
zyppng::DigestReportHelper::operator=
DigestReportHelper & operator=(const DigestReportHelper &)=default
zyppng::DigestReportHelper::askUserToAccepUnknownDigest
bool askUserToAccepUnknownDigest(const zypp::Pathname &file, const std::string &name)
Definition reporthelper.cc:36
zyppng::DigestReportHelper::DigestReportHelper
DigestReportHelper(ZyppContextRef r)
Definition reporthelper.h:84
zyppng::DigestReportHelper::_report
detail::ReportHolder< ZyppContextRef, zypp::DigestReport > _report
Definition reporthelper.h:97
zyppng::DigestReportHelper::DigestReportHelper
DigestReportHelper(DigestReportHelper &&)=default
zyppng::DigestReportHelper::DigestReportHelper
DigestReportHelper(const DigestReportHelper &)=default
zyppng::DigestReportHelper::askUserToAcceptWrongDigest
bool askUserToAcceptWrongDigest(const zypp::Pathname &file, const std::string &requested, const std::string &found)
Definition reporthelper.cc:49
zyppng::DigestReportHelper::askUserToAcceptNoDigest
bool askUserToAcceptNoDigest(const zypp::Pathname &file)
Definition reporthelper.cc:23
zyppng::DigestReportHelper::operator=
DigestReportHelper & operator=(DigestReportHelper &&)=default
zyppng::JobReportHelper::important
bool important(std::string msg_r, UserData userData_r=UserData())
send important message text
Definition reporthelper.cc:228
zyppng::JobReportHelper::operator=
JobReportHelper & operator=(const JobReportHelper &)=default
zyppng::JobReportHelper::JobReportHelper
JobReportHelper(ZyppContextRef r)
Definition reporthelper.h:139
zyppng::JobReportHelper::error
bool error(std::string msg_r, UserData userData_r=UserData())
send error text
Definition reporthelper.cc:217
zyppng::JobReportHelper::warning
bool warning(std::string msg_r, UserData userData_r=UserData())
send warning text
Definition reporthelper.cc:206
zyppng::JobReportHelper::JobReportHelper
JobReportHelper(JobReportHelper &&)=default
zyppng::JobReportHelper::operator=
JobReportHelper & operator=(JobReportHelper &&)=default
zyppng::JobReportHelper::debug
bool debug(std::string msg_r, UserData userData_r=UserData())
send debug message text
Definition reporthelper.cc:184
zyppng::JobReportHelper::data
bool data(std::string msg_r, UserData userData_r=UserData())
send data message
Definition reporthelper.cc:239
zyppng::JobReportHelper::info
bool info(std::string msg_r, UserData userData_r=UserData())
send message text
Definition reporthelper.cc:195
zyppng::JobReportHelper::JobReportHelper
JobReportHelper(const JobReportHelper &)=default
zyppng::KeyRingReportHelper::operator=
KeyRingReportHelper & operator=(const KeyRingReportHelper &)=default
zyppng::KeyRingReportHelper::askUserToAcceptPackageKey
bool askUserToAcceptPackageKey(const zypp::PublicKey &key_r, const zypp::KeyContext &keycontext_r={})
Definition reporthelper.cc:102
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:125
zyppng::KeyRingReportHelper::askUserToAcceptUnsignedFile
bool askUserToAcceptUnsignedFile(const std::string &file, const zypp::KeyContext &keycontext={})
Definition reporthelper.cc:62
zyppng::KeyRingReportHelper::operator=
KeyRingReportHelper & operator=(KeyRingReportHelper &&)=default
zyppng::KeyRingReportHelper::infoVerify
void infoVerify(const std::string &file_r, const zypp::PublicKeyData &keyData_r, const zypp::KeyContext &keycontext={})
Definition reporthelper.cc:113
zyppng::KeyRingReportHelper::KeyRingReportHelper
KeyRingReportHelper(KeyRingReportHelper &&)=default
zyppng::KeyRingReportHelper::_report
detail::ReportHolder< ZyppContextRef, zypp::KeyRingReport > _report
Definition reporthelper.h:130
zyppng::KeyRingReportHelper::askUserToAcceptVerificationFailed
bool askUserToAcceptVerificationFailed(const std::string &file, const zypp::PublicKey &key, const zypp::KeyContext &keycontext={})
Definition reporthelper.cc:138
zyppng::KeyRingReportHelper::KeyRingReportHelper
KeyRingReportHelper(const KeyRingReportHelper &)=default
zyppng::KeyRingReportHelper::askUserToAcceptKey
zypp::KeyRingReport::KeyTrust askUserToAcceptKey(const zypp::PublicKey &key, const zypp::KeyContext &keycontext={})
Definition reporthelper.cc:86
zyppng::KeyRingReportHelper::askUserToAcceptUnknownKey
bool askUserToAcceptUnknownKey(const std::string &file, const std::string &id, const zypp::KeyContext &keycontext={})
Definition reporthelper.cc:160
zyppng::KeyRingReportHelper::KeyRingReportHelper
KeyRingReportHelper(ZyppContextRef r)
Definition reporthelper.h:105
zyppng::detail::ReportHolder< SyncContextRef, Report >::operator=
ReportHolder & operator=(const ReportHolder &)=default
zyppng::detail::ReportHolder< SyncContextRef, Report >::ReportHolder
ReportHolder()
Definition reporthelper.h:43
zyppng::detail::ReportHolder< SyncContextRef, Report >::ReportHolder
ReportHolder(ReportHolder &&)=default
zyppng::detail::ReportHolder< SyncContextRef, Report >::operator->
auto & operator->()
Definition reporthelper.h:50
zyppng::detail::ReportHolder< SyncContextRef, Report >::_d
std::shared_ptr< zypp::callback::SendReport< Report > > _d
Definition reporthelper.h:54
zyppng::detail::ReportHolder< SyncContextRef, Report >::operator=
ReportHolder & operator=(ReportHolder &&)=default
zyppng::detail::ReportHolder< SyncContextRef, Report >::ReportHolder
ReportHolder(const ReportHolder &)=default
zyppng::detail::ReportHolder
Definition reporthelper.h:33
context.h
contextfacade.h
std
Definition Arch.h:364
zypp::callback
Callbacks light.
Definition Callback.h:146
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zyppng::detail
Definition reporthelper.h:31
zyppng
Definition MediaCurl2.h:22
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
Gettext.h
userrequest.h
Digest.h
zyppglobal.h
ZYPP_FWD_DECL_REFS
#define ZYPP_FWD_DECL_REFS(T)
Definition zyppglobal.h:119