libzypp  14.48.5
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 
203  virtual void pkgGpgCheck( const UserData & userData_r = UserData() )
204  {}
205 
206  virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
207  , Error /*error*/
208  , const std::string &/*reason*/
209  ) {}
210  };
211 
212  // progress for probing a source
214  {
215  enum Action {
216  ABORT, // abort and return error
217  RETRY // retry
218  };
219 
220  enum Error {
222  NOT_FOUND, // the requested Url was not found
223  IO, // IO error
224  INVALID, // th source is invalid
226  };
227 
228  virtual void start(const Url &/*url*/) {}
229  virtual void failedProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
230  virtual void successProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
231  virtual void finish(const Url &/*url*/, Error /*error*/, const std::string &/*reason*/ ) {}
232 
233  virtual bool progress(const Url &/*url*/, int /*value*/)
234  { return true; }
235 
236  virtual Action problem( const Url &/*url*/, Error /*error*/, const std::string &/*description*/ ) { return ABORT; }
237  };
238 
240  {
241  enum Action {
242  ABORT, // abort and return error
243  RETRY, // retry
244  IGNORE // skip refresh, ignore failed refresh
245  };
246 
247  enum Error {
249  NOT_FOUND, // the requested Url was not found
250  IO, // IO error
252  INVALID, // th source is invali
254  };
255 
256  virtual void start( const zypp::Url &/*url*/ ) {}
257  virtual bool progress( int /*value*/ )
258  { return true; }
259 
260  virtual Action problem(
261  const zypp::Url &/*url*/
262  , Error /*error*/
263  , const std::string &/*description*/ )
264  { return ABORT; }
265 
266  virtual void finish(
267  const zypp::Url &/*url*/
268  , Error /*error*/
269  , const std::string &/*reason*/ )
270  {}
271  };
272 
274  {
275  enum Action {
276  ABORT, // abort and return error
277  RETRY, // retry
278  IGNORE // skip refresh, ignore failed refresh
279  };
280 
281  enum Error {
283  NOT_FOUND, // the requested Url was not found
284  IO, // IO error
285  INVALID // th source is invalid
286  };
287 
288  virtual void start( const ProgressData &/*task*/, const RepoInfo /*repo*/ ) {}
289  virtual bool progress( const ProgressData &/*task*/ )
290  { return true; }
291 
292  virtual Action problem(
293  Repository /*source*/
294  , Error /*error*/
295  , const std::string &/*description*/ )
296  { return ABORT; }
297 
298  virtual void finish(
299  Repository /*source*/
300  , const std::string &/*task*/
301  , Error /*error*/
302  , const std::string &/*reason*/ )
303  {}
304  };
305 
306 
308  } // namespace source
310 
312  namespace media
313  {
314  // media change request callback
316  {
317  enum Action {
318  ABORT, // abort and return error
319  RETRY, // retry
320  IGNORE, // ignore this media in future, not available anymore
321  IGNORE_ID, // ignore wrong medium id
322  CHANGE_URL, // change media URL
323  EJECT // eject the medium
324  };
325 
326  enum Error {
328  NOT_FOUND, // the medie not found at all
329  IO, // error accessing the media
330  INVALID, // media is broken
331  WRONG, // wrong media, need a different one
333  };
334 
349  Url & /* url (I/O parameter) */
350  , unsigned /*mediumNr*/
351  , const std::string & /* label */
352  , Error /*error*/
353  , const std::string & /*description*/
354  , const std::vector<std::string> & /* devices */
355  , unsigned int & /* dev_current (I/O param) */
356  ) { return ABORT; }
357  };
358 
365  {
367  ScopedDisableMediaChangeReport( bool condition_r = true );
368  private:
369  shared_ptr<callback::TempConnect<media::MediaChangeReport> > _guard;
370  };
371 
372  // progress for downloading a file
374  {
375  enum Action {
376  ABORT, // abort and return error
377  RETRY, // retry
378  IGNORE // ignore the failure
379  };
380 
381  enum Error {
383  NOT_FOUND, // the requested Url was not found
384  IO, // IO error
385  ACCESS_DENIED, // user authent. failed while accessing restricted file
386  ERROR // other error
387  };
388 
389  virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
390 
399  virtual bool progress(int /*value*/, const Url &/*file*/,
400  double dbps_avg = -1,
401  double dbps_current = -1)
402  { return true; }
403 
404  virtual Action problem(
405  const Url &/*file*/
406  , Error /*error*/
407  , const std::string &/*description*/
408  ) { return ABORT; }
409 
410  virtual void finish(
411  const Url &/*file*/
412  , Error /*error*/
413  , const std::string &/*reason*/
414  ) {}
415  };
416 
417  // authentication issues report
419  {
434  virtual bool prompt(const Url & /* url */,
435  const std::string & /* msg */,
436  AuthData & /* auth_data */)
437  {
438  return false;
439  }
440  };
441 
443  } // namespace media
445 
447  namespace target
448  {
451  {
455  virtual bool show( Patch::constPtr & /*patch*/ )
456  { return true; }
457  };
458 
464  {
465  enum Notify { OUTPUT, PING };
466  enum Action {
467  ABORT, // abort commit and return error
468  RETRY, // (re)try to execute this script
469  IGNORE // ignore any failue and continue
470  };
471 
474  virtual void start( const Package::constPtr & /*package*/,
475  const Pathname & /*script path*/ )
476  {}
481  virtual bool progress( Notify /*OUTPUT or PING*/,
482  const std::string & /*output*/ = std::string() )
483  { return true; }
485  virtual Action problem( const std::string & /*description*/ )
486  { return ABORT; }
488  virtual void finish()
489  {}
490  };
491 
503  {
508  virtual bool start( const ProgressData & progress_r )
509  { return true; }
510 
516  virtual bool progress( const ProgressData & progress_r, const sat::Queue & noFilelist_r )
517  { return true; }
518 
525  virtual bool result( const ProgressData & progress_r, const sat::Queue & noFilelist_r, const sat::FileConflicts & conflicts_r )
526  { return true; }
527  };
528 
529 
531  namespace rpm
532  {
533 
534  // progress for installing a resolvable
536  {
537  enum Action {
538  ABORT, // abort and return error
539  RETRY, // retry
540  IGNORE // ignore the failure
541  };
542 
543  enum Error {
545  NOT_FOUND, // the requested Url was not found
546  IO, // IO error
547  INVALID // th resolvable is invalid
548  };
549 
550  // the level of RPM pushing
552  enum RpmLevel {
556  };
557 
558  virtual void start(
559  Resolvable::constPtr /*resolvable*/
560  ) {}
561 
562  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
563  { return true; }
564 
565  virtual Action problem(
566  Resolvable::constPtr /*resolvable*/
567  , Error /*error*/
568  , const std::string &/*description*/
569  , RpmLevel /*level*/
570  ) { return ABORT; }
571 
572  virtual void finish(
573  Resolvable::constPtr /*resolvable*/
574  , Error /*error*/
575  , const std::string &/*reason*/
576  , RpmLevel /*level*/
577  ) {}
578  };
579 
580  // progress for removing a resolvable
582  {
583  enum Action {
584  ABORT, // abort and return error
585  RETRY, // retry
586  IGNORE // ignore the failure
587  };
588 
589  enum Error {
591  NOT_FOUND, // the requested Url was not found
592  IO, // IO error
593  INVALID // th resolvable is invalid
594  };
595 
596  virtual void start(
597  Resolvable::constPtr /*resolvable*/
598  ) {}
599 
600  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
601  { return true; }
602 
603  virtual Action problem(
604  Resolvable::constPtr /*resolvable*/
605  , Error /*error*/
606  , const std::string &/*description*/
607  ) { return ABORT; }
608 
609  virtual void finish(
610  Resolvable::constPtr /*resolvable*/
611  , Error /*error*/
612  , const std::string &/*reason*/
613  ) {}
614  };
615 
616  // progress for rebuilding the database
618  {
619  enum Action {
620  ABORT, // abort and return error
621  RETRY, // retry
622  IGNORE // ignore the failure
623  };
624 
625  enum Error {
627  FAILED // failed to rebuild
628  };
629 
630  virtual void start(Pathname /*path*/) {}
631 
632  virtual bool progress(int /*value*/, Pathname /*path*/)
633  { return true; }
634 
635  virtual Action problem(
636  Pathname /*path*/
637  , Error /*error*/
638  , const std::string &/*description*/
639  ) { return ABORT; }
640 
641  virtual void finish(
642  Pathname /*path*/
643  , Error /*error*/
644  , const std::string &/*reason*/
645  ) {}
646  };
647 
648  // progress for converting the database
650  {
651  enum Action {
652  ABORT, // abort and return error
653  RETRY, // retry
654  IGNORE // ignore the failure
655  };
656 
657  enum Error {
659  FAILED // conversion failed
660  };
661 
662  virtual void start(
663  Pathname /*path*/
664  ) {}
665 
666  virtual bool progress(int /*value*/, Pathname /*path*/)
667  { return true; }
668 
669  virtual Action problem(
670  Pathname /*path*/
671  , Error /*error*/
672  , const std::string &/*description*/
673  ) { return ABORT; }
674 
675  virtual void finish(
676  Pathname /*path*/
677  , Error /*error*/
678  , const std::string &/*reason*/
679  ) {}
680  };
681 
683  } // namespace rpm
685 
687  } // namespace target
689 
690  class PoolQuery;
691 
699  {
703  enum Action {
707  };
708 
712  enum Error {
715  };
716 
720  virtual void start(
721  ) {}
722 
727  virtual bool progress(int /*value*/)
728  { return true; }
729 
734  virtual Action execute(
735  const PoolQuery& /*error*/
736  ) { return DELETE; }
737 
741  virtual void finish(
742  Error /*error*/
743  ) {}
744 
745  };
746 
751  {
756  enum Action {
760  };
761 
765  enum Error {
768  };
769 
777  };
778 
779  virtual void start() {}
780 
785  virtual bool progress()
786  { return true; }
787 
791  virtual Action conflict(
792  const PoolQuery&,
794  ) { return DELETE; }
795 
796  virtual void finish(
797  Error /*error*/
798  ) {}
799  };
800 
806  {
807  public:
809  struct _MsgTypeDef {
811  };
812  typedef base::EnumClass<_MsgTypeDef> MsgType;
813 
816 
817  public:
819  virtual bool message( MsgType type_r, const std::string & msg_r, const UserData & userData_r ) const
820  { return true; }
821 
822 
826  static callback::SendReport<JobReport> & instance(); // impl in ZYppImpl.cc
827 
829  static bool debug( const MessageString & msg_r, const UserData & userData_r = UserData() )
830  { return instance()->message( MsgType::debug, msg_r, userData_r ); }
831 
833  static bool info( const MessageString & msg_r, const UserData & userData_r = UserData() )
834  { return instance()->message( MsgType::info, msg_r, userData_r ); }
835 
837  static bool warning( const MessageString & msg_r, const UserData & userData_r = UserData() )
838  { return instance()->message( MsgType::warning, msg_r, userData_r ); }
839 
841  static bool error( const MessageString & msg_r, const UserData & userData_r = UserData() )
842  { return instance()->message( MsgType::error, msg_r, userData_r ); }
843 
845  static bool important( const MessageString & msg_r, const UserData & userData_r = UserData() )
846  { return instance()->message( MsgType::important, msg_r, userData_r ); }
847 
849  static bool data( const MessageString & msg_r, const UserData & userData_r = UserData() )
850  { return instance()->message( MsgType::data, msg_r, userData_r ); }
852  };
853 
854 
856 } // namespace zypp
858 
859 #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:72
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:34
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:184
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()