libzypp  17.38.7
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>
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 
59  public:
60  BasicReportHelper(const BasicReportHelper &) = default;
62  BasicReportHelper &operator=(const 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 
79  public:
81 
82  DigestReportHelper(ContextRef r)
83  : BasicReportHelper(std::move(r)) {}
84 
85  DigestReportHelper(const 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:
96  };
97 
99  public:
101 
102  KeyRingReportHelper(ContextRef r)
103  : BasicReportHelper(std::move(r)) {}
104 
105  KeyRingReportHelper(const KeyRingReportHelper &) = default;
109 
110  // -- Key Ring reports -- //
111 
112  bool askUserToAcceptUnsignedFile( const std::string &file, const zypp::KeyContext &keycontext = {} );
113 
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:
128 
129  };
130 
132  public:
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;
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
bool askUserToAcceptWrongDigest(const zypp::Pathname &file, const std::string &requested, const std::string &found)
Definition: reporthelper.cc:48
bool error(std::string msg_r, UserData userData_r=UserData())
send error text
JobReportHelper(ContextRef r)
Definition: reporthelper.h:135
bool askUserToAcceptUnknownKey(const std::string &file, const std::string &id, const zypp::KeyContext &keycontext={})
bool askUserToAcceptUnsignedFile(const std::string &file, const zypp::KeyContext &keycontext={})
Definition: reporthelper.cc:61
KeyRingReportHelper & operator=(const KeyRingReportHelper &)=default
bool askUserToAcceptVerificationFailed(const std::string &file, const zypp::PublicKey &key, const zypp::KeyContext &keycontext={})
Class representing one GPG Public Keys data.
Definition: PublicKey.h:200
KeyRingReportHelper(ContextRef r)
Definition: reporthelper.h:102
void reportAutoImportKey(const std::list< zypp::PublicKeyData > &keyDataList_r, const zypp::PublicKeyData &keySigning_r, const zypp::KeyContext &keyContext_r)
ZYPP_FWD_DECL_REFS(Context)
detail::ReportHolder< zypp::DigestReport, Context::isAsync > _report
Definition: reporthelper.h:95
bool important(std::string msg_r, UserData userData_r=UserData())
send important message text
Definition: ansi.h:854
bool askUserToAccepUnknownDigest(const zypp::Pathname &file, const std::string &name)
Definition: reporthelper.cc:35
detail::ReportHolder< zypp::KeyRingReport, Context::isAsync > _report
Definition: reporthelper.h:127
BasicReportHelper(const BasicReportHelper &)=default
BasicReportHelper & operator=(const BasicReportHelper &)=default
void infoVerify(const std::string &file_r, const zypp::PublicKeyData &keyData_r, const zypp::KeyContext &keycontext={})
KeyTrust
User reply options for the askUserToTrustKey callback.
Definition: KeyRing.h:53
zypp::callback::UserData UserData
Definition: userrequest.h:18
zypp::KeyRingReport::KeyTrust askUserToAcceptKey(const zypp::PublicKey &key, const zypp::KeyContext &keycontext={})
Definition: reporthelper.cc:85
bool data(std::string msg_r, UserData userData_r=UserData())
send data message
bool askUserToAcceptPackageKey(const zypp::PublicKey &key_r, const zypp::KeyContext &keycontext_r={})
std::shared_ptr< zypp::callback::SendReport< Report > > _d
Definition: reporthelper.h:54
DigestReportHelper(ContextRef r)
Definition: reporthelper.h:82
bool info(std::string msg_r, UserData userData_r=UserData())
send message text
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Definition: PublicKey.h:374
bool debug(std::string msg_r, UserData userData_r=UserData())
send debug message text
JobReportHelper & operator=(const JobReportHelper &)=default
Typesafe passing of user data via callbacks.
Definition: UserData.h:39
const ContextRef & zyppContext()
Definition: reporthelper.h:65
static constexpr bool async()
Definition: reporthelper.h:69
bool askUserToAcceptNoDigest(const zypp::Pathname &file)
Definition: reporthelper.cc:23
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
DigestReportHelper & operator=(const DigestReportHelper &)=default
bool warning(std::string msg_r, UserData userData_r=UserData())
send warning text