libzypp  14.42.0
ZYppCallbacks.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_ZYPPCALLBACKS_H
13 #define ZYPP_ZYPPCALLBACKS_H
14 
15 #include "zypp/base/EnumClass.h"
16 #include "zypp/Callback.h"
17 #include "zypp/UserData.h"
18 #include "zypp/Resolvable.h"
19 #include "zypp/RepoInfo.h"
20 #include "zypp/Pathname.h"
21 #include "zypp/Package.h"
22 #include "zypp/Patch.h"
23 #include "zypp/Url.h"
24 #include "zypp/ProgressData.h"
26 
28 namespace zypp
29 {
30 
32  namespace sat
33  {
34  class Queue;
35  class FileConflicts;
36  } // namespace sat
38 
40  {
41  virtual void start( const ProgressData &/*task*/ )
42  {}
43 
44  virtual bool progress( const ProgressData &/*task*/ )
45  { return true; }
46 
47 // virtual Action problem(
48 // Repo /*source*/
49 // , Error /*error*/
50 // , const std::string &/*description*/ )
51 // { return ABORT; }
52 
53  virtual void finish( const ProgressData &/*task*/ )
54  {}
55 
56  };
57 
59  {
60 
63  : _fnc(fnc)
64  , _report(report)
65  , _first(true)
66  {
67  }
68 
69  bool operator()( const ProgressData &progress )
70  {
71  if ( _first )
72  {
73  _report->start(progress);
74  _first = false;
75  }
76 
77  _report->progress(progress);
78  bool value = true;
79  if ( _fnc )
80  value = _fnc(progress);
81 
82 
83  if ( progress.finalReport() )
84  {
85  _report->finish(progress);
86  }
87  return value;
88  }
89 
92  bool _first;
93  };
94 
96 
97  namespace repo
98  {
99  // progress for downloading a resolvable
101  {
102  enum Action {
103  ABORT, // abort and return error
104  RETRY, // retry
105  IGNORE, // ignore this resolvable but continue
106  };
107 
108  enum Error {
110  NOT_FOUND, // the requested Url was not found
111  IO, // IO error
112  INVALID // the downloaded file is invalid
113  };
114 
118  virtual void infoInCache( Resolvable::constPtr res_r, const Pathname & localfile_r )
119  {}
120 
121  virtual void start(
122  Resolvable::constPtr /*resolvable_ptr*/
123  , const Url &/*url*/
124  ) {}
125 
126 
127  // Dowmload delta rpm:
128  // - path below url reported on start()
129  // - expected download size (0 if unknown)
130  // - download is interruptable
131  // - problems are just informal
132  virtual void startDeltaDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
133  {}
134 
135  virtual bool progressDeltaDownload( int /*value*/ )
136  { return true; }
137 
138  virtual void problemDeltaDownload( const std::string &/*description*/ )
139  {}
140 
141  virtual void finishDeltaDownload()
142  {}
143 
144  // Apply delta rpm:
145  // - local path of downloaded delta
146  // - aplpy is not interruptable
147  // - problems are just informal
148  virtual void startDeltaApply( const Pathname & /*filename*/ )
149  {}
150 
151  virtual void progressDeltaApply( int /*value*/ )
152  {}
153 
154  virtual void problemDeltaApply( const std::string &/*description*/ )
155  {}
156 
157  virtual void finishDeltaApply()
158  {}
159 
161  virtual ZYPP_DEPRECATED void startPatchDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
162  {}
163 
165  virtual ZYPP_DEPRECATED bool progressPatchDownload( int /*value*/ )
166  { return true; }
167 
169  virtual ZYPP_DEPRECATED void problemPatchDownload( const std::string &/*description*/ )
170  {}
171 
174  {}
175 
176 
177  // return false if the download should be aborted right now
178  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable_ptr*/)
179  { return true; }
180 
181  virtual Action problem(
182  Resolvable::constPtr /*resolvable_ptr*/
183  , Error /*error*/
184  , const std::string &/*description*/
185  ) { return ABORT; }
186 
187 
200  virtual void pkgGpgCheck( const UserData & userData_r = UserData() )
201  {}
202 
203  virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
204  , Error /*error*/
205  , const std::string &/*reason*/
206  ) {}
207  };
208 
209  // progress for probing a source
211  {
212  enum Action {
213  ABORT, // abort and return error
214  RETRY // retry
215  };
216 
217  enum Error {
219  NOT_FOUND, // the requested Url was not found
220  IO, // IO error
221  INVALID, // th source is invalid
223  };
224 
225  virtual void start(const Url &/*url*/) {}
226  virtual void failedProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
227  virtual void successProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
228  virtual void finish(const Url &/*url*/, Error /*error*/, const std::string &/*reason*/ ) {}
229 
230  virtual bool progress(const Url &/*url*/, int /*value*/)
231  { return true; }
232 
233  virtual Action problem( const Url &/*url*/, Error /*error*/, const std::string &/*description*/ ) { return ABORT; }
234  };
235 
237  {
238  enum Action {
239  ABORT, // abort and return error
240  RETRY, // retry
241  IGNORE // skip refresh, ignore failed refresh
242  };
243 
244  enum Error {
246  NOT_FOUND, // the requested Url was not found
247  IO, // IO error
249  INVALID, // th source is invali
251  };
252 
253  virtual void start( const zypp::Url &/*url*/ ) {}
254  virtual bool progress( int /*value*/ )
255  { return true; }
256 
257  virtual Action problem(
258  const zypp::Url &/*url*/
259  , Error /*error*/
260  , const std::string &/*description*/ )
261  { return ABORT; }
262 
263  virtual void finish(
264  const zypp::Url &/*url*/
265  , Error /*error*/
266  , const std::string &/*reason*/ )
267  {}
268  };
269 
271  {
272  enum Action {
273  ABORT, // abort and return error
274  RETRY, // retry
275  IGNORE // skip refresh, ignore failed refresh
276  };
277 
278  enum Error {
280  NOT_FOUND, // the requested Url was not found
281  IO, // IO error
282  INVALID // th source is invalid
283  };
284 
285  virtual void start( const ProgressData &/*task*/, const RepoInfo /*repo*/ ) {}
286  virtual bool progress( const ProgressData &/*task*/ )
287  { return true; }
288 
289  virtual Action problem(
290  Repository /*source*/
291  , Error /*error*/
292  , const std::string &/*description*/ )
293  { return ABORT; }
294 
295  virtual void finish(
296  Repository /*source*/
297  , const std::string &/*task*/
298  , Error /*error*/
299  , const std::string &/*reason*/ )
300  {}
301  };
302 
303 
305  } // namespace source
307 
309  namespace media
310  {
311  // media change request callback
313  {
314  enum Action {
315  ABORT, // abort and return error
316  RETRY, // retry
317  IGNORE, // ignore this media in future, not available anymore
318  IGNORE_ID, // ignore wrong medium id
319  CHANGE_URL, // change media URL
320  EJECT // eject the medium
321  };
322 
323  enum Error {
325  NOT_FOUND, // the medie not found at all
326  IO, // error accessing the media
327  INVALID, // media is broken
328  WRONG, // wrong media, need a different one
330  };
331 
346  Url & /* url (I/O parameter) */
347  , unsigned /*mediumNr*/
348  , const std::string & /* label */
349  , Error /*error*/
350  , const std::string & /*description*/
351  , const std::vector<std::string> & /* devices */
352  , unsigned int & /* dev_current (I/O param) */
353  ) { return ABORT; }
354  };
355 
362  {
364  ScopedDisableMediaChangeReport( bool condition_r = true );
365  private:
366  shared_ptr<callback::TempConnect<media::MediaChangeReport> > _guard;
367  };
368 
369  // progress for downloading a file
371  {
372  enum Action {
373  ABORT, // abort and return error
374  RETRY, // retry
375  IGNORE // ignore the failure
376  };
377 
378  enum Error {
380  NOT_FOUND, // the requested Url was not found
381  IO, // IO error
382  ACCESS_DENIED, // user authent. failed while accessing restricted file
383  ERROR // other error
384  };
385 
386  virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
387 
396  virtual bool progress(int /*value*/, const Url &/*file*/,
397  double dbps_avg = -1,
398  double dbps_current = -1)
399  { return true; }
400 
401  virtual Action problem(
402  const Url &/*file*/
403  , Error /*error*/
404  , const std::string &/*description*/
405  ) { return ABORT; }
406 
407  virtual void finish(
408  const Url &/*file*/
409  , Error /*error*/
410  , const std::string &/*reason*/
411  ) {}
412  };
413 
414  // authentication issues report
416  {
431  virtual bool prompt(const Url & /* url */,
432  const std::string & /* msg */,
433  AuthData & /* auth_data */)
434  {
435  return false;
436  }
437  };
438 
440  } // namespace media
442 
444  namespace target
445  {
448  {
452  virtual bool show( Patch::constPtr & /*patch*/ )
453  { return true; }
454  };
455 
461  {
462  enum Notify { OUTPUT, PING };
463  enum Action {
464  ABORT, // abort commit and return error
465  RETRY, // (re)try to execute this script
466  IGNORE // ignore any failue and continue
467  };
468 
471  virtual void start( const Package::constPtr & /*package*/,
472  const Pathname & /*script path*/ )
473  {}
478  virtual bool progress( Notify /*OUTPUT or PING*/,
479  const std::string & /*output*/ = std::string() )
480  { return true; }
482  virtual Action problem( const std::string & /*description*/ )
483  { return ABORT; }
485  virtual void finish()
486  {}
487  };
488 
500  {
505  virtual bool start( const ProgressData & progress_r )
506  { return true; }
507 
513  virtual bool progress( const ProgressData & progress_r, const sat::Queue & noFilelist_r )
514  { return true; }
515 
522  virtual bool result( const ProgressData & progress_r, const sat::Queue & noFilelist_r, const sat::FileConflicts & conflicts_r )
523  { return true; }
524  };
525 
526 
528  namespace rpm
529  {
530 
531  // progress for installing a resolvable
533  {
534  enum Action {
535  ABORT, // abort and return error
536  RETRY, // retry
537  IGNORE // ignore the failure
538  };
539 
540  enum Error {
542  NOT_FOUND, // the requested Url was not found
543  IO, // IO error
544  INVALID // th resolvable is invalid
545  };
546 
547  // the level of RPM pushing
549  enum RpmLevel {
553  };
554 
555  virtual void start(
556  Resolvable::constPtr /*resolvable*/
557  ) {}
558 
559  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
560  { return true; }
561 
562  virtual Action problem(
563  Resolvable::constPtr /*resolvable*/
564  , Error /*error*/
565  , const std::string &/*description*/
566  , RpmLevel /*level*/
567  ) { return ABORT; }
568 
569  virtual void finish(
570  Resolvable::constPtr /*resolvable*/
571  , Error /*error*/
572  , const std::string &/*reason*/
573  , RpmLevel /*level*/
574  ) {}
575  };
576 
577  // progress for removing a resolvable
579  {
580  enum Action {
581  ABORT, // abort and return error
582  RETRY, // retry
583  IGNORE // ignore the failure
584  };
585 
586  enum Error {
588  NOT_FOUND, // the requested Url was not found
589  IO, // IO error
590  INVALID // th resolvable is invalid
591  };
592 
593  virtual void start(
594  Resolvable::constPtr /*resolvable*/
595  ) {}
596 
597  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
598  { return true; }
599 
600  virtual Action problem(
601  Resolvable::constPtr /*resolvable*/
602  , Error /*error*/
603  , const std::string &/*description*/
604  ) { return ABORT; }
605 
606  virtual void finish(
607  Resolvable::constPtr /*resolvable*/
608  , Error /*error*/
609  , const std::string &/*reason*/
610  ) {}
611  };
612 
613  // progress for rebuilding the database
615  {
616  enum Action {
617  ABORT, // abort and return error
618  RETRY, // retry
619  IGNORE // ignore the failure
620  };
621 
622  enum Error {
624  FAILED // failed to rebuild
625  };
626 
627  virtual void start(Pathname /*path*/) {}
628 
629  virtual bool progress(int /*value*/, Pathname /*path*/)
630  { return true; }
631 
632  virtual Action problem(
633  Pathname /*path*/
634  , Error /*error*/
635  , const std::string &/*description*/
636  ) { return ABORT; }
637 
638  virtual void finish(
639  Pathname /*path*/
640  , Error /*error*/
641  , const std::string &/*reason*/
642  ) {}
643  };
644 
645  // progress for converting the database
647  {
648  enum Action {
649  ABORT, // abort and return error
650  RETRY, // retry
651  IGNORE // ignore the failure
652  };
653 
654  enum Error {
656  FAILED // conversion failed
657  };
658 
659  virtual void start(
660  Pathname /*path*/
661  ) {}
662 
663  virtual bool progress(int /*value*/, Pathname /*path*/)
664  { return true; }
665 
666  virtual Action problem(
667  Pathname /*path*/
668  , Error /*error*/
669  , const std::string &/*description*/
670  ) { return ABORT; }
671 
672  virtual void finish(
673  Pathname /*path*/
674  , Error /*error*/
675  , const std::string &/*reason*/
676  ) {}
677  };
678 
680  } // namespace rpm
682 
684  } // namespace target
686 
687  class PoolQuery;
688 
696  {
700  enum Action {
704  };
705 
709  enum Error {
712  };
713 
717  virtual void start(
718  ) {}
719 
724  virtual bool progress(int /*value*/)
725  { return true; }
726 
731  virtual Action execute(
732  const PoolQuery& /*error*/
733  ) { return DELETE; }
734 
738  virtual void finish(
739  Error /*error*/
740  ) {}
741 
742  };
743 
748  {
753  enum Action {
757  };
758 
762  enum Error {
765  };
766 
774  };
775 
776  virtual void start() {}
777 
782  virtual bool progress()
783  { return true; }
784 
788  virtual Action conflict(
789  const PoolQuery&,
791  ) { return DELETE; }
792 
793  virtual void finish(
794  Error /*error*/
795  ) {}
796  };
797 
803  {
804  public:
806  struct _MsgTypeDef {
808  };
809  typedef base::EnumClass<_MsgTypeDef> MsgType;
810 
813 
814  public:
816  virtual bool message( MsgType type_r, const std::string & msg_r, const UserData & userData_r ) const
817  { return true; }
818 
819 
823  static callback::SendReport<JobReport> & instance(); // impl in ZYppImpl.cc
824 
826  static bool debug( const MessageString & msg_r, const UserData & userData_r = UserData() )
827  { return instance()->message( MsgType::debug, msg_r, userData_r ); }
828 
830  static bool info( const MessageString & msg_r, const UserData & userData_r = UserData() )
831  { return instance()->message( MsgType::info, msg_r, userData_r ); }
832 
834  static bool warning( const MessageString & msg_r, const UserData & userData_r = UserData() )
835  { return instance()->message( MsgType::warning, msg_r, userData_r ); }
836 
838  static bool error( const MessageString & msg_r, const UserData & userData_r = UserData() )
839  { return instance()->message( MsgType::error, msg_r, userData_r ); }
840 
842  static bool important( const MessageString & msg_r, const UserData & userData_r = UserData() )
843  { return instance()->message( MsgType::important, msg_r, userData_r ); }
844 
846  static bool data( const MessageString & msg_r, const UserData & userData_r = UserData() )
847  { return instance()->message( MsgType::data, msg_r, userData_r ); }
849  };
850 
851 
853 } // namespace zypp
855 
856 #endif // ZYPP_ZYPPCALLBACKS_H
bool operator()(const ProgressData &progress)
Definition: ZYppCallbacks.h:69
virtual void start(Resolvable::constPtr, const Url &)
static bool data(const MessageString &msg_r, const UserData &userData_r=UserData())
send data message
virtual bool progress(int, const Url &, double dbps_avg=-1, double dbps_current=-1)
Download progress.
Generic report for sending messages.
ProgressData::ReceiverFnc _fnc
Definition: ZYppCallbacks.h:90
message type (use like 'enum class MsgType')
virtual Action problem(Resolvable::constPtr, Error, const std::string &)
virtual void start(const ProgressData &)
Definition: ZYppCallbacks.h:41
virtual Action problem(const Url &, Error, const std::string &)
virtual void pkgGpgCheck(const UserData &userData_r=UserData())
Detail information about the result of a performed pkgGpgCheck.
virtual bool progress(int, Resolvable::constPtr)
virtual void start(const zypp::Url &)
virtual Action problem(Resolvable::constPtr, Error, const std::string &, RpmLevel)
virtual void finish(Resolvable::constPtr, Error, const std::string &)
virtual void finish(const zypp::Url &, Error, const std::string &)
virtual void finish(const Url &, Error, const std::string &)
virtual void finish(Pathname, Error, const std::string &)
Store and operate with byte count.
Definition: ByteCount.h:30
static bool important(const MessageString &msg_r, const UserData &userData_r=UserData())
send important message text
virtual bool start(const ProgressData &progress_r)
callback::UserData UserData
typsafe map of userdata
virtual void start(Resolvable::constPtr)
virtual Action problem(Repository, Error, const std::string &)
virtual void finish(const ProgressData &)
Definition: ZYppCallbacks.h:53
virtual bool progress(const ProgressData &)
IO error which can happen on worse connection like timeout exceed.
bool finalReport() const
Definition: ProgressData.h:333
virtual void finish(Pathname, Error, const std::string &)
virtual void finish()
Report success.
Error
result of cleaning
What is known about a repository.
Definition: RepoInfo.h:71
virtual void finish(Resolvable::constPtr, Error, const std::string &)
cleaning aborted by user
DBusError error
Definition: HalContext.cc:86
delete conflicted lock
Error
result of merging
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
Definition: ProgressData.h:139
virtual bool result(const ProgressData &progress_r, const sat::Queue &noFilelist_r, const sat::FileConflicts &conflicts_r)
callback::UserData UserData
Definition: Callback.h:140
Indicate execution of a patch script.
virtual void start(Pathname)
virtual void successProbe(const Url &, const std::string &)
Libsolv queue representing file conflicts.
Definition: FileConflicts.h:30
Action
action performed by cleaning api to specific lock
virtual void start(Resolvable::constPtr)
locks lock some file and unlocking lock unlock only part of iti, so removing old lock can unlock more...
Check for package file conflicts in commit (after download)
virtual bool progress(int, Pathname)
virtual void startDeltaDownload(const Pathname &, const ByteCount &)
virtual void start(const Url &, Pathname)
virtual Action problem(const Url &, Error, const std::string &)
virtual void finish(Error)
cleaning is done
ProgressReportAdaptor(const ProgressData::ReceiverFnc &fnc, callback::SendReport< ProgressReport > &report)
Definition: ZYppCallbacks.h:61
virtual void start(Pathname)
virtual bool progress(const ProgressData &progress_r, const sat::Queue &noFilelist_r)
virtual Action problem(Pathname, Error, const std::string &)
cleaning aborted by user
virtual void finish(const Url &, Error, const std::string &)
virtual Action problem(const zypp::Url &, Error, const std::string &)
virtual Action problem(Resolvable::constPtr, Error, const std::string &)
virtual bool progress(int, Resolvable::constPtr)
Maintain [min,max] and counter (value) for progress counting.
Definition: ProgressData.h:130
virtual bool progress()
merging still live
Request to display the pre commit message of a patch.
virtual Action problem(const std::string &)
Report error.
static bool error(const MessageString &msg_r, const UserData &userData_r=UserData())
send error text
locks lock same item in pool but his parameters is different
TraitsType::constPtrType constPtr
Definition: Patch.h:42
virtual void problemDeltaApply(const std::string &)
this callback handles merging old locks with newly added or removed
Class for handling media authentication data.
Definition: MediaUserAuth.h:30
virtual void finish(Resolvable::constPtr, Error, const std::string &, RpmLevel)
virtual void problemDeltaDownload(const std::string &)
virtual bool prompt(const Url &, const std::string &, AuthData &)
Prompt for authentication data.
Temporarily disable MediaChangeReport Sometimes helpful to suppress interactive messages connected to...
ScopedDisableMediaChangeReport(bool condition_r=true)
Disbale MediaChangeReport if condition_r is true.
Definition: ZYppImpl.cc:38
virtual void failedProbe(const Url &, const std::string &)
Libsolv Id queue wrapper.
Definition: Queue.h:38
virtual void start(const ProgressData &, const RepoInfo)
virtual ZYPP_DEPRECATED bool progressPatchDownload(int)
TraitsType::constPtrType constPtr
Definition: Resolvable.h:49
virtual bool progress(int)
progress of cleaning specifies in percents
Action
action for old lock which is in conflict
Meta-data query API.
Definition: PoolQuery.h:90
virtual void start(const Url &)
virtual bool progress(int)
callback::SendReport< ProgressReport > & _report
Definition: ZYppCallbacks.h:91
virtual ZYPP_DEPRECATED void problemPatchDownload(const std::string &)
virtual void start(const Package::constPtr &, const Pathname &)
Start executing the script provided by package.
callback::SendReport< DownloadProgressReport > * report
Definition: MediaCurl.cc:178
Typesafe passing of user data via callbacks.
Definition: UserData.h:38
virtual bool progress(int, Pathname)
static bool debug(const MessageString &msg_r, const UserData &userData_r=UserData())
send debug message text
abort and return error
virtual void finish(Repository, const std::string &, Error, const std::string &)
virtual Action execute(const PoolQuery &)
When find empty lock ask what to do with it.
virtual Action requestMedia(Url &, unsigned, const std::string &, Error, const std::string &, const std::vector< std::string > &, unsigned int &)
virtual ZYPP_DEPRECATED void startPatchDownload(const Pathname &, const ByteCount &)
virtual void startDeltaApply(const Pathname &)
virtual bool progress(Notify, const std::string &=std::string())
Progress provides the script output.
virtual bool progress(const ProgressData &)
Definition: ZYppCallbacks.h:44
virtual bool progress(int, Resolvable::constPtr)
ConflictState
type of conflict of old and new lock
shared_ptr< callback::TempConnect< media::MediaChangeReport > > _guard
Callback for cleaning locks which doesn't lock anything in pool.
static bool warning(const MessageString &msg_r, const UserData &userData_r=UserData())
send warning text
static callback::SendReport< JobReport > & instance()
Singleton sender instance.
Definition: ZYppImpl.cc:51
#define ZYPP_DEPRECATED
The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings with gcc >= 3...
Definition: APIConfig.h:86
virtual Action problem(Pathname, Error, const std::string &)
Convenience interface for handling authentication data of media user.
Url manipulation class.
Definition: Url.h:87
virtual void start()
cleaning is started
TraitsType::constPtrType constPtr
Definition: Package.h:38
base::EnumClass< _MsgTypeDef > MsgType
'enum class MsgType'
virtual bool message(MsgType type_r, const std::string &msg_r, const UserData &userData_r) const
Send a ready to show message text.
virtual bool progress(const Url &, int)
virtual void infoInCache(Resolvable::constPtr res_r, const Pathname &localfile_r)
Hint that package is available in the local cache (no download needed).
virtual bool show(Patch::constPtr &)
Display patch->message().
static bool info(const MessageString &msg_r, const UserData &userData_r=UserData())
send message text
virtual Action conflict(const PoolQuery &, ConflictState)
When user unlock something which is locked by non-identical query.
virtual void finish(Error)
virtual ZYPP_DEPRECATED void finishPatchDownload()