libzypp  16.17.20
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 
160  // return false if the download should be aborted right now
161  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable_ptr*/)
162  { return true; }
163 
164  virtual Action problem(
165  Resolvable::constPtr /*resolvable_ptr*/
166  , Error /*error*/
167  , const std::string &/*description*/
168  ) { return ABORT; }
169 
170 
186  virtual void pkgGpgCheck( const UserData & userData_r = UserData() )
187  {}
188 
189  virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
190  , Error /*error*/
191  , const std::string &/*reason*/
192  ) {}
193  };
194 
195  // progress for probing a source
197  {
198  enum Action {
199  ABORT, // abort and return error
200  RETRY // retry
201  };
202 
203  enum Error {
205  NOT_FOUND, // the requested Url was not found
206  IO, // IO error
207  INVALID, // th source is invalid
208  UNKNOWN
209  };
210 
211  virtual void start(const Url &/*url*/) {}
212  virtual void failedProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
213  virtual void successProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
214  virtual void finish(const Url &/*url*/, Error /*error*/, const std::string &/*reason*/ ) {}
215 
216  virtual bool progress(const Url &/*url*/, int /*value*/)
217  { return true; }
218 
219  virtual Action problem( const Url &/*url*/, Error /*error*/, const std::string &/*description*/ ) { return ABORT; }
220  };
221 
223  {
224  enum Action {
225  ABORT, // abort and return error
226  RETRY, // retry
227  IGNORE // skip refresh, ignore failed refresh
228  };
229 
230  enum Error {
232  NOT_FOUND, // the requested Url was not found
233  IO, // IO error
235  INVALID, // th source is invali
236  UNKNOWN
237  };
238 
239  virtual void start( const zypp::Url &/*url*/ ) {}
240  virtual bool progress( int /*value*/ )
241  { return true; }
242 
243  virtual Action problem(
244  const zypp::Url &/*url*/
245  , Error /*error*/
246  , const std::string &/*description*/ )
247  { return ABORT; }
248 
249  virtual void finish(
250  const zypp::Url &/*url*/
251  , Error /*error*/
252  , const std::string &/*reason*/ )
253  {}
254  };
255 
257  {
258  enum Action {
259  ABORT, // abort and return error
260  RETRY, // retry
261  IGNORE // skip refresh, ignore failed refresh
262  };
263 
264  enum Error {
266  NOT_FOUND, // the requested Url was not found
267  IO, // IO error
268  INVALID // th source is invalid
269  };
270 
271  virtual void start( const ProgressData &/*task*/, const RepoInfo /*repo*/ ) {}
272  virtual bool progress( const ProgressData &/*task*/ )
273  { return true; }
274 
275  virtual Action problem(
276  Repository /*source*/
277  , Error /*error*/
278  , const std::string &/*description*/ )
279  { return ABORT; }
280 
281  virtual void finish(
282  Repository /*source*/
283  , const std::string &/*task*/
284  , Error /*error*/
285  , const std::string &/*reason*/ )
286  {}
287  };
288 
289 
291  } // namespace source
293 
295  namespace media
296  {
297  // media change request callback
299  {
300  enum Action {
301  ABORT, // abort and return error
302  RETRY, // retry
303  IGNORE, // ignore this media in future, not available anymore
304  IGNORE_ID, // ignore wrong medium id
305  CHANGE_URL, // change media URL
306  EJECT // eject the medium
307  };
308 
309  enum Error {
311  NOT_FOUND, // the medie not found at all
312  IO, // error accessing the media
313  INVALID, // media is broken
314  WRONG, // wrong media, need a different one
315  IO_SOFT
316  };
317 
332  Url & /* url (I/O parameter) */
333  , unsigned /*mediumNr*/
334  , const std::string & /* label */
335  , Error /*error*/
336  , const std::string & /*description*/
337  , const std::vector<std::string> & /* devices */
338  , unsigned int & /* dev_current (I/O param) */
339  ) { return ABORT; }
340  };
341 
348  {
350  ScopedDisableMediaChangeReport( bool condition_r = true );
351  private:
352  shared_ptr<callback::TempConnect<media::MediaChangeReport> > _guard;
353  };
354 
355  // progress for downloading a file
357  {
358  enum Action {
359  ABORT, // abort and return error
360  RETRY, // retry
361  IGNORE // ignore the failure
362  };
363 
364  enum Error {
366  NOT_FOUND, // the requested Url was not found
367  IO, // IO error
368  ACCESS_DENIED, // user authent. failed while accessing restricted file
369  ERROR // other error
370  };
371 
372  virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
373 
382  virtual bool progress(int /*value*/, const Url &/*file*/,
383  double dbps_avg = -1,
384  double dbps_current = -1)
385  { return true; }
386 
387  virtual Action problem(
388  const Url &/*file*/
389  , Error /*error*/
390  , const std::string &/*description*/
391  ) { return ABORT; }
392 
393  virtual void finish(
394  const Url &/*file*/
395  , Error /*error*/
396  , const std::string &/*reason*/
397  ) {}
398  };
399 
400  // authentication issues report
402  {
417  virtual bool prompt(const Url & /* url */,
418  const std::string & /* msg */,
419  AuthData & /* auth_data */)
420  {
421  return false;
422  }
423  };
424 
426  } // namespace media
428 
430  namespace target
431  {
434  {
438  virtual bool show( Patch::constPtr & /*patch*/ )
439  { return true; }
440  };
441 
447  {
448  enum Notify { OUTPUT, PING };
449  enum Action {
450  ABORT, // abort commit and return error
451  RETRY, // (re)try to execute this script
452  IGNORE // ignore any failue and continue
453  };
454 
457  virtual void start( const Package::constPtr & /*package*/,
458  const Pathname & /*script path*/ )
459  {}
464  virtual bool progress( Notify /*OUTPUT or PING*/,
465  const std::string & /*output*/ = std::string() )
466  { return true; }
468  virtual Action problem( const std::string & /*description*/ )
469  { return ABORT; }
471  virtual void finish()
472  {}
473  };
474 
486  {
491  virtual bool start( const ProgressData & progress_r )
492  { return true; }
493 
499  virtual bool progress( const ProgressData & progress_r, const sat::Queue & noFilelist_r )
500  { return true; }
501 
508  virtual bool result( const ProgressData & progress_r, const sat::Queue & noFilelist_r, const sat::FileConflicts & conflicts_r )
509  { return true; }
510  };
511 
512 
514  namespace rpm
515  {
516 
517  // progress for installing a resolvable
519  {
520  enum Action {
521  ABORT, // abort and return error
522  RETRY, // retry
523  IGNORE // ignore the failure
524  };
525 
526  enum Error {
528  NOT_FOUND, // the requested Url was not found
529  IO, // IO error
530  INVALID // th resolvable is invalid
531  };
532 
533  // the level of RPM pushing
535  enum RpmLevel {
538  RPM_NODEPS_FORCE
539  };
540 
541  virtual void start(
542  Resolvable::constPtr /*resolvable*/
543  ) {}
544 
545  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
546  { return true; }
547 
548  virtual Action problem(
549  Resolvable::constPtr /*resolvable*/
550  , Error /*error*/
551  , const std::string &/*description*/
552  , RpmLevel /*level*/
553  ) { return ABORT; }
554 
555  virtual void finish(
556  Resolvable::constPtr /*resolvable*/
557  , Error /*error*/
558  , const std::string &/*reason*/
559  , RpmLevel /*level*/
560  ) {}
561  };
562 
563  // progress for removing a resolvable
565  {
566  enum Action {
567  ABORT, // abort and return error
568  RETRY, // retry
569  IGNORE // ignore the failure
570  };
571 
572  enum Error {
574  NOT_FOUND, // the requested Url was not found
575  IO, // IO error
576  INVALID // th resolvable is invalid
577  };
578 
579  virtual void start(
580  Resolvable::constPtr /*resolvable*/
581  ) {}
582 
583  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
584  { return true; }
585 
586  virtual Action problem(
587  Resolvable::constPtr /*resolvable*/
588  , Error /*error*/
589  , const std::string &/*description*/
590  ) { return ABORT; }
591 
592  virtual void finish(
593  Resolvable::constPtr /*resolvable*/
594  , Error /*error*/
595  , const std::string &/*reason*/
596  ) {}
597  };
598 
599  // progress for rebuilding the database
601  {
602  enum Action {
603  ABORT, // abort and return error
604  RETRY, // retry
605  IGNORE // ignore the failure
606  };
607 
608  enum Error {
610  FAILED // failed to rebuild
611  };
612 
613  virtual void start(Pathname /*path*/) {}
614 
615  virtual bool progress(int /*value*/, Pathname /*path*/)
616  { return true; }
617 
618  virtual Action problem(
619  Pathname /*path*/
620  , Error /*error*/
621  , const std::string &/*description*/
622  ) { return ABORT; }
623 
624  virtual void finish(
625  Pathname /*path*/
626  , Error /*error*/
627  , const std::string &/*reason*/
628  ) {}
629  };
630 
631  // progress for converting the database
633  {
634  enum Action {
635  ABORT, // abort and return error
636  RETRY, // retry
637  IGNORE // ignore the failure
638  };
639 
640  enum Error {
642  FAILED // conversion failed
643  };
644 
645  virtual void start(
646  Pathname /*path*/
647  ) {}
648 
649  virtual bool progress(int /*value*/, Pathname /*path*/)
650  { return true; }
651 
652  virtual Action problem(
653  Pathname /*path*/
654  , Error /*error*/
655  , const std::string &/*description*/
656  ) { return ABORT; }
657 
658  virtual void finish(
659  Pathname /*path*/
660  , Error /*error*/
661  , const std::string &/*reason*/
662  ) {}
663  };
664 
666  } // namespace rpm
668 
670  } // namespace target
672 
673  class PoolQuery;
674 
682  {
686  enum Action {
689  IGNORE
690  };
691 
695  enum Error {
697  ABORTED
698  };
699 
703  virtual void start(
704  ) {}
705 
710  virtual bool progress(int /*value*/)
711  { return true; }
712 
717  virtual Action execute(
718  const PoolQuery& /*error*/
719  ) { return DELETE; }
720 
724  virtual void finish(
725  Error /*error*/
726  ) {}
727 
728  };
729 
734  {
739  enum Action {
742  IGNORE
743  };
744 
748  enum Error {
750  ABORTED
751  };
752 
758  INTERSECT
760  };
761 
762  virtual void start() {}
763 
768  virtual bool progress()
769  { return true; }
770 
774  virtual Action conflict(
775  const PoolQuery&,
777  ) { return DELETE; }
778 
779  virtual void finish(
780  Error /*error*/
781  ) {}
782  };
783 
789  {
790  public:
792  struct EMsgTypeDef {
793  enum Enum { debug, info, warning, error, important, data };
794  };
795  typedef base::EnumClass<EMsgTypeDef> MsgType;
796 
799 
800  public:
802  virtual bool message( MsgType type_r, const std::string & msg_r, const UserData & userData_r ) const
803  { return true; }
804 
805 
809  static callback::SendReport<JobReport> & instance(); // impl in ZYppImpl.cc
810 
812  static bool debug( const std::string & msg_r, const UserData & userData_r = UserData() )
813  { return instance()->message( MsgType::debug, msg_r, userData_r ); }
814 
816  static bool info( const std::string & msg_r, const UserData & userData_r = UserData() )
817  { return instance()->message( MsgType::info, msg_r, userData_r ); }
818 
820  static bool warning( const std::string & msg_r, const UserData & userData_r = UserData() )
821  { return instance()->message( MsgType::warning, msg_r, userData_r ); }
822 
824  static bool error( const std::string & msg_r, const UserData & userData_r = UserData() )
825  { return instance()->message( MsgType::error, msg_r, userData_r ); }
826 
828  static bool important( const std::string & msg_r, const UserData & userData_r = UserData() )
829  { return instance()->message( MsgType::important, msg_r, userData_r ); }
830 
832  static bool data( const std::string & msg_r, const UserData & userData_r = UserData() )
833  { return instance()->message( MsgType::data, msg_r, userData_r ); }
835  };
836 
837 
839 } // namespace zypp
841 
842 #endif // ZYPP_ZYPPCALLBACKS_H
bool operator()(const ProgressData &progress)
Definition: ZYppCallbacks.h:69
virtual void start(Resolvable::constPtr, const Url &)
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
static bool error(const std::string &msg_r, const UserData &userData_r=UserData())
send error text
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.
base::EnumClass< EMsgTypeDef > MsgType
&#39;enum class MsgType&#39;
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
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 &)
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
static bool warning(const std::string &msg_r, const UserData &userData_r=UserData())
send warning text
virtual void finish(Resolvable::constPtr, Error, const std::string &)
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)
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)
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
message type (use like &#39;enum class MsgType&#39;)
virtual void start(Pathname)
virtual bool progress(const ProgressData &progress_r, const sat::Queue &noFilelist_r)
virtual Action problem(Pathname, Error, const std::string &)
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.
locks lock same item in pool but his parameters is different
TraitsType::constPtrType constPtr
Definition: Patch.h:42
static bool important(const std::string &msg_r, const UserData &userData_r=UserData())
send important message text
virtual void problemDeltaApply(const std::string &)
this callback handles merging old locks with newly added or removed
static bool data(const std::string &msg_r, const UserData &userData_r=UserData())
send data message
Class for handling media authentication data.
Definition: MediaUserAuth.h:30
static bool debug(const std::string &msg_r, const UserData &userData_r=UserData())
send debug message text
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...
virtual void failedProbe(const Url &, const std::string &)
Libsolv Id queue wrapper.
Definition: Queue.h:34
virtual void start(const ProgressData &, const RepoInfo)
TraitsType::constPtrType constPtr
Definition: Resolvable.h:59
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 void start(const Package::constPtr &, const Pathname &)
Start executing the script provided by package.
callback::SendReport< DownloadProgressReport > * report
Definition: MediaCurl.cc:199
Typesafe passing of user data via callbacks.
Definition: UserData.h:38
virtual bool progress(int, Pathname)
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 void startDeltaApply(const Pathname &)
virtual bool progress(Notify, const std::string &=std::string())
Progress provides the script output.
static bool info(const std::string &msg_r, const UserData &userData_r=UserData())
send message text
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&#39;t lock anything in pool.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
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
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().
virtual Action conflict(const PoolQuery &, ConflictState)
When user unlock something which is locked by non-identical query.
virtual void finish(Error)