libzypp  13.10.6
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/Callback.h"
16 #include "zypp/Resolvable.h"
17 #include "zypp/RepoInfo.h"
18 #include "zypp/Pathname.h"
19 #include "zypp/Package.h"
20 #include "zypp/Patch.h"
21 #include "zypp/Url.h"
22 #include "zypp/ProgressData.h"
24 
26 namespace zypp
27 {
28 
30  {
31  virtual void start( const ProgressData &/*task*/ )
32  {}
33 
34  virtual bool progress( const ProgressData &/*task*/ )
35  { return true; }
36 
37 // virtual Action problem(
38 // Repo /*source*/
39 // , Error /*error*/
40 // , const std::string &/*description*/ )
41 // { return ABORT; }
42 
43  virtual void finish( const ProgressData &/*task*/ )
44  {}
45 
46  };
47 
49  {
50 
53  : _fnc(fnc)
54  , _report(report)
55  , _first(true)
56  {
57  }
58 
59  bool operator()( const ProgressData &progress )
60  {
61  if ( _first )
62  {
63  _report->start(progress);
64  _first = false;
65  }
66 
67  _report->progress(progress);
68  bool value = true;
69  if ( _fnc )
70  value = _fnc(progress);
71 
72 
73  if ( progress.finalReport() )
74  {
75  _report->finish(progress);
76  }
77  return value;
78  }
79 
82  bool _first;
83  };
84 
86 
87  namespace repo
88  {
89  // progress for downloading a resolvable
91  {
92  enum Action {
93  ABORT, // abort and return error
94  RETRY, // retry
95  IGNORE, // ignore this resolvable but continue
96  };
97 
98  enum Error {
100  NOT_FOUND, // the requested Url was not found
101  IO, // IO error
102  INVALID // the downloaded file is invalid
103  };
104 
105  virtual void start(
106  Resolvable::constPtr /*resolvable_ptr*/
107  , const Url &/*url*/
108  ) {}
109 
110 
111  // Dowmload delta rpm:
112  // - path below url reported on start()
113  // - expected download size (0 if unknown)
114  // - download is interruptable
115  // - problems are just informal
116  virtual void startDeltaDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
117  {}
118 
119  virtual bool progressDeltaDownload( int /*value*/ )
120  { return true; }
121 
122  virtual void problemDeltaDownload( const std::string &/*description*/ )
123  {}
124 
125  virtual void finishDeltaDownload()
126  {}
127 
128  // Apply delta rpm:
129  // - local path of downloaded delta
130  // - aplpy is not interruptable
131  // - problems are just informal
132  virtual void startDeltaApply( const Pathname & /*filename*/ )
133  {}
134 
135  virtual void progressDeltaApply( int /*value*/ )
136  {}
137 
138  virtual void problemDeltaApply( const std::string &/*description*/ )
139  {}
140 
141  virtual void finishDeltaApply()
142  {}
143 
144  // Dowmload patch rpm:
145  // - path below url reported on start()
146  // - expected download size (0 if unknown)
147  // - download is interruptable
148  virtual void startPatchDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
149  {}
150 
151  virtual bool progressPatchDownload( int /*value*/ )
152  { return true; }
153 
154  virtual void problemPatchDownload( const std::string &/*description*/ )
155  {}
156 
157  virtual void finishPatchDownload()
158  {}
159 
160 
161  // return false if the download should be aborted right now
162  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable_ptr*/)
163  { return true; }
164 
165  virtual Action problem(
166  Resolvable::constPtr /*resolvable_ptr*/
167  , Error /*error*/
168  , const std::string &/*description*/
169  ) { return ABORT; }
170 
171  virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
172  , Error /*error*/
173  , const std::string &/*reason*/
174  ) {}
175  };
176 
177  // progress for probing a source
179  {
180  enum Action {
181  ABORT, // abort and return error
182  RETRY // retry
183  };
184 
185  enum Error {
187  NOT_FOUND, // the requested Url was not found
188  IO, // IO error
189  INVALID, // th source is invalid
191  };
192 
193  virtual void start(const Url &/*url*/) {}
194  virtual void failedProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
195  virtual void successProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
196  virtual void finish(const Url &/*url*/, Error /*error*/, const std::string &/*reason*/ ) {}
197 
198  virtual bool progress(const Url &/*url*/, int /*value*/)
199  { return true; }
200 
201  virtual Action problem( const Url &/*url*/, Error /*error*/, const std::string &/*description*/ ) { return ABORT; }
202  };
203 
205  {
206  enum Action {
207  ABORT, // abort and return error
208  RETRY, // retry
209  IGNORE // skip refresh, ignore failed refresh
210  };
211 
212  enum Error {
214  NOT_FOUND, // the requested Url was not found
215  IO, // IO error
217  INVALID, // th source is invali
219  };
220 
221  virtual void start( const zypp::Url &/*url*/ ) {}
222  virtual bool progress( int /*value*/ )
223  { return true; }
224 
225  virtual Action problem(
226  const zypp::Url &/*url*/
227  , Error /*error*/
228  , const std::string &/*description*/ )
229  { return ABORT; }
230 
231  virtual void finish(
232  const zypp::Url &/*url*/
233  , Error /*error*/
234  , const std::string &/*reason*/ )
235  {}
236  };
237 
239  {
240  enum Action {
241  ABORT, // abort and return error
242  RETRY, // retry
243  IGNORE // skip refresh, ignore failed refresh
244  };
245 
246  enum Error {
248  NOT_FOUND, // the requested Url was not found
249  IO, // IO error
250  INVALID // th source is invalid
251  };
252 
253  virtual void start( const ProgressData &/*task*/, const RepoInfo /*repo*/ ) {}
254  virtual bool progress( const ProgressData &/*task*/ )
255  { return true; }
256 
257  virtual Action problem(
258  Repository /*source*/
259  , Error /*error*/
260  , const std::string &/*description*/ )
261  { return ABORT; }
262 
263  virtual void finish(
264  Repository /*source*/
265  , const std::string &/*task*/
266  , Error /*error*/
267  , const std::string &/*reason*/ )
268  {}
269  };
270 
271 
273  } // namespace source
275 
277  namespace media
278  {
279  // media change request callback
281  {
282  enum Action {
283  ABORT, // abort and return error
284  RETRY, // retry
285  IGNORE, // ignore this media in future, not available anymore
286  IGNORE_ID, // ignore wrong medium id
287  CHANGE_URL, // change media URL
288  EJECT // eject the medium
289  };
290 
291  enum Error {
293  NOT_FOUND, // the medie not found at all
294  IO, // error accessing the media
295  INVALID, // media is broken
296  WRONG, // wrong media, need a different one
298  };
299 
314  Url & /* url (I/O parameter) */
315  , unsigned /*mediumNr*/
316  , const std::string & /* label */
317  , Error /*error*/
318  , const std::string & /*description*/
319  , const std::vector<std::string> & /* devices */
320  , unsigned int & /* dev_current (I/O param) */
321  ) { return ABORT; }
322  };
323 
324  // progress for downloading a file
326  {
327  enum Action {
328  ABORT, // abort and return error
329  RETRY, // retry
330  IGNORE // ignore the failure
331  };
332 
333  enum Error {
335  NOT_FOUND, // the requested Url was not found
336  IO, // IO error
337  ACCESS_DENIED, // user authent. failed while accessing restricted file
338  ERROR // other error
339  };
340 
341  virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
342 
351  virtual bool progress(int /*value*/, const Url &/*file*/,
352  double dbps_avg = -1,
353  double dbps_current = -1)
354  { return true; }
355 
356  virtual Action problem(
357  const Url &/*file*/
358  , Error /*error*/
359  , const std::string &/*description*/
360  ) { return ABORT; }
361 
362  virtual void finish(
363  const Url &/*file*/
364  , Error /*error*/
365  , const std::string &/*reason*/
366  ) {}
367  };
368 
369  // authentication issues report
371  {
386  virtual bool prompt(const Url & /* url */,
387  const std::string & /* msg */,
388  AuthData & /* auth_data */)
389  {
390  return false;
391  }
392  };
393 
395  } // namespace media
397 
399  namespace target
400  {
403  {
407  virtual bool show( Patch::constPtr & /*patch*/ )
408  { return true; }
409  };
410 
416  {
417  enum Notify { OUTPUT, PING };
418  enum Action {
419  ABORT, // abort commit and return error
420  RETRY, // (re)try to execute this script
421  IGNORE // ignore any failue and continue
422  };
423 
426  virtual void start( const Package::constPtr & /*package*/,
427  const Pathname & /*script path*/ )
428  {}
433  virtual bool progress( Notify /*OUTPUT or PING*/,
434  const std::string & /*output*/ = std::string() )
435  { return true; }
437  virtual Action problem( const std::string & /*description*/ )
438  { return ABORT; }
440  virtual void finish()
441  {}
442  };
443 
445  namespace rpm
446  {
447 
448  // progress for installing a resolvable
450  {
451  enum Action {
452  ABORT, // abort and return error
453  RETRY, // retry
454  IGNORE // ignore the failure
455  };
456 
457  enum Error {
459  NOT_FOUND, // the requested Url was not found
460  IO, // IO error
461  INVALID // th resolvable is invalid
462  };
463 
464  // the level of RPM pushing
466  enum RpmLevel {
470  };
471 
472  virtual void start(
473  Resolvable::constPtr /*resolvable*/
474  ) {}
475 
476  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
477  { return true; }
478 
479  virtual Action problem(
480  Resolvable::constPtr /*resolvable*/
481  , Error /*error*/
482  , const std::string &/*description*/
483  , RpmLevel /*level*/
484  ) { return ABORT; }
485 
486  virtual void finish(
487  Resolvable::constPtr /*resolvable*/
488  , Error /*error*/
489  , const std::string &/*reason*/
490  , RpmLevel /*level*/
491  ) {}
492  };
493 
494  // progress for removing a resolvable
496  {
497  enum Action {
498  ABORT, // abort and return error
499  RETRY, // retry
500  IGNORE // ignore the failure
501  };
502 
503  enum Error {
505  NOT_FOUND, // the requested Url was not found
506  IO, // IO error
507  INVALID // th resolvable is invalid
508  };
509 
510  virtual void start(
511  Resolvable::constPtr /*resolvable*/
512  ) {}
513 
514  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
515  { return true; }
516 
517  virtual Action problem(
518  Resolvable::constPtr /*resolvable*/
519  , Error /*error*/
520  , const std::string &/*description*/
521  ) { return ABORT; }
522 
523  virtual void finish(
524  Resolvable::constPtr /*resolvable*/
525  , Error /*error*/
526  , const std::string &/*reason*/
527  ) {}
528  };
529 
530  // progress for rebuilding the database
532  {
533  enum Action {
534  ABORT, // abort and return error
535  RETRY, // retry
536  IGNORE // ignore the failure
537  };
538 
539  enum Error {
541  FAILED // failed to rebuild
542  };
543 
544  virtual void start(Pathname /*path*/) {}
545 
546  virtual bool progress(int /*value*/, Pathname /*path*/)
547  { return true; }
548 
549  virtual Action problem(
550  Pathname /*path*/
551  , Error /*error*/
552  , const std::string &/*description*/
553  ) { return ABORT; }
554 
555  virtual void finish(
556  Pathname /*path*/
557  , Error /*error*/
558  , const std::string &/*reason*/
559  ) {}
560  };
561 
562  // progress for converting the database
564  {
565  enum Action {
566  ABORT, // abort and return error
567  RETRY, // retry
568  IGNORE // ignore the failure
569  };
570 
571  enum Error {
573  FAILED // conversion failed
574  };
575 
576  virtual void start(
577  Pathname /*path*/
578  ) {}
579 
580  virtual bool progress(int /*value*/, Pathname /*path*/)
581  { return true; }
582 
583  virtual Action problem(
584  Pathname /*path*/
585  , Error /*error*/
586  , const std::string &/*description*/
587  ) { return ABORT; }
588 
589  virtual void finish(
590  Pathname /*path*/
591  , Error /*error*/
592  , const std::string &/*reason*/
593  ) {}
594  };
595 
597  } // namespace rpm
599 
601  } // namespace target
603 
604  class PoolQuery;
605 
613  {
617  enum Action {
621  };
622 
626  enum Error {
629  };
630 
634  virtual void start(
635  ) {}
636 
641  virtual bool progress(int /*value*/)
642  { return true; }
643 
648  virtual Action execute(
649  const PoolQuery& /*error*/
650  ) { return DELETE; }
651 
655  virtual void finish(
656  Error /*error*/
657  ) {}
658 
659  };
660 
665  {
670  enum Action {
674  };
675 
679  enum Error {
682  };
683 
691  };
692 
693  virtual void start() {}
694 
699  virtual bool progress()
700  { return true; }
701 
705  virtual Action conflict(
706  const PoolQuery&,
708  ) { return DELETE; }
709 
710  virtual void finish(
711  Error /*error*/
712  ) {}
713  };
714 
715 
717 } // namespace zypp
719 
720 #endif // ZYPP_ZYPPCALLBACKS_H
bool operator()(const ProgressData &progress)
Definition: ZYppCallbacks.h:59
virtual void start(Resolvable::constPtr, const Url &)
virtual bool progress(int, const Url &, double dbps_avg=-1, double dbps_current=-1)
Download progress.
virtual void problemPatchDownload(const std::string &)
ProgressData::ReceiverFnc _fnc
Definition: ZYppCallbacks.h:80
virtual Action problem(Resolvable::constPtr, Error, const std::string &)
virtual void start(const ProgressData &)
Definition: ZYppCallbacks.h:31
virtual Action problem(const Url &, Error, const std::string &)
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 void start(Resolvable::constPtr)
virtual Action problem(Repository, Error, const std::string &)
virtual void finish(const ProgressData &)
Definition: ZYppCallbacks.h:43
virtual bool progress(const ProgressData &)
IO error which can happen on worse connection like timeout exceed.
bool finalReport() const
Definition: ProgressData.h:330
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:66
virtual void finish(Resolvable::constPtr, Error, const std::string &)
cleaning aborted by user
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:144
Indicate execution of a patch script.
virtual void start(Pathname)
virtual void successProbe(const Url &, const std::string &)
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...
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:51
virtual void start(Pathname)
virtual void startPatchDownload(const Pathname &, const ByteCount &)
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:135
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
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.
virtual void failedProbe(const Url &, const std::string &)
virtual void start(const ProgressData &, const RepoInfo)
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:81
virtual void start(const Package::constPtr &, const Pathname &)
Start executing the script provided by package.
callback::SendReport< DownloadProgressReport > * report
Definition: MediaCurl.cc:178
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.
virtual bool progress(const ProgressData &)
Definition: ZYppCallbacks.h:34
virtual bool progress(int, Resolvable::constPtr)
ConflictState
type of conflict of old and new lock
Callback for cleaning locks which doesn&#39;t lock anything in pool.
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 progress(const Url &, int)
virtual bool show(Patch::constPtr &)
Display patch-&gt;message().
virtual Action conflict(const PoolQuery &, ConflictState)
When user unlock something which is locked by non-identical query.
virtual void finish(Error)