libzypp  17.7.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/Gettext.h"
16 #include "zypp/base/EnumClass.h"
17 #include "zypp/Callback.h"
18 #include "zypp/UserData.h"
19 #include "zypp/Resolvable.h"
20 #include "zypp/RepoInfo.h"
21 #include "zypp/Pathname.h"
22 #include "zypp/Package.h"
23 #include "zypp/Patch.h"
24 #include "zypp/Url.h"
25 #include "zypp/ProgressData.h"
27 
29 namespace zypp
30 {
31 
33  namespace sat
34  {
35  class Queue;
36  class FileConflicts;
37  } // namespace sat
39 
41  {
42  virtual void start( const ProgressData &/*task*/ )
43  {}
44 
45  virtual bool progress( const ProgressData &/*task*/ )
46  { return true; }
47 
48 // virtual Action problem(
49 // Repo /*source*/
50 // , Error /*error*/
51 // , const std::string &/*description*/ )
52 // { return ABORT; }
53 
54  virtual void finish( const ProgressData &/*task*/ )
55  {}
56 
57  };
58 
60  {
61 
64  : _fnc(fnc)
65  , _report(report)
66  , _first(true)
67  {
68  }
69 
70  bool operator()( const ProgressData &progress )
71  {
72  if ( _first )
73  {
74  _report->start(progress);
75  _first = false;
76  }
77 
78  bool value = _report->progress(progress);
79  if ( _fnc )
80  value &= _fnc(progress);
81 
82  if ( progress.finalReport() )
83  {
84  _report->finish(progress);
85  }
86  return value;
87  }
88 
91  bool _first;
92  };
93 
95 
96  namespace repo
97  {
98  // progress for downloading a resolvable
100  {
101  enum Action {
102  ABORT, // abort and return error
103  RETRY, // retry
104  IGNORE, // ignore this resolvable but continue
105  };
106 
107  enum Error {
109  NOT_FOUND, // the requested Url was not found
110  IO, // IO error
111  INVALID // the downloaded file is invalid
112  };
113 
117  virtual void infoInCache( Resolvable::constPtr res_r, const Pathname & localfile_r )
118  {}
119 
120  virtual void start(
121  Resolvable::constPtr /*resolvable_ptr*/
122  , const Url &/*url*/
123  ) {}
124 
125 
126  // Dowmload delta rpm:
127  // - path below url reported on start()
128  // - expected download size (0 if unknown)
129  // - download is interruptable
130  // - problems are just informal
131  virtual void startDeltaDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
132  {}
133 
134  virtual bool progressDeltaDownload( int /*value*/ )
135  { return true; }
136 
137  virtual void problemDeltaDownload( const std::string &/*description*/ )
138  {}
139 
140  virtual void finishDeltaDownload()
141  {}
142 
143  // Apply delta rpm:
144  // - local path of downloaded delta
145  // - aplpy is not interruptable
146  // - problems are just informal
147  virtual void startDeltaApply( const Pathname & /*filename*/ )
148  {}
149 
150  virtual void progressDeltaApply( int /*value*/ )
151  {}
152 
153  virtual void problemDeltaApply( const std::string &/*description*/ )
154  {}
155 
156  virtual void finishDeltaApply()
157  {}
158 
159  // return false if the download should be aborted right now
160  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable_ptr*/)
161  { return true; }
162 
163  virtual Action problem(
164  Resolvable::constPtr /*resolvable_ptr*/
165  , Error /*error*/
166  , const std::string &/*description*/
167  ) { return ABORT; }
168 
169 
185  virtual void pkgGpgCheck( const UserData & userData_r = UserData() )
186  {}
187 
188  virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
189  , Error /*error*/
190  , const std::string &/*reason*/
191  ) {}
192  };
193 
194  // progress for probing a source
196  {
197  enum Action {
198  ABORT, // abort and return error
199  RETRY // retry
200  };
201 
202  enum Error {
204  NOT_FOUND, // the requested Url was not found
205  IO, // IO error
206  INVALID, // th source is invalid
207  UNKNOWN
208  };
209 
210  virtual void start(const Url &/*url*/) {}
211  virtual void failedProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
212  virtual void successProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
213  virtual void finish(const Url &/*url*/, Error /*error*/, const std::string &/*reason*/ ) {}
214 
215  virtual bool progress(const Url &/*url*/, int /*value*/)
216  { return true; }
217 
218  virtual Action problem( const Url &/*url*/, Error /*error*/, const std::string &/*description*/ ) { return ABORT; }
219  };
220 
222  {
223  enum Action {
224  ABORT, // abort and return error
225  RETRY, // retry
226  IGNORE // skip refresh, ignore failed refresh
227  };
228 
229  enum Error {
231  NOT_FOUND, // the requested Url was not found
232  IO, // IO error
234  INVALID, // th source is invali
235  UNKNOWN
236  };
237 
238  virtual void start( const zypp::Url &/*url*/ ) {}
239  virtual bool progress( int /*value*/ )
240  { return true; }
241 
242  virtual Action problem(
243  const zypp::Url &/*url*/
244  , Error /*error*/
245  , const std::string &/*description*/ )
246  { return ABORT; }
247 
248  virtual void finish(
249  const zypp::Url &/*url*/
250  , Error /*error*/
251  , const std::string &/*reason*/ )
252  {}
253  };
254 
256  {
257  enum Action {
258  ABORT, // abort and return error
259  RETRY, // retry
260  IGNORE // skip refresh, ignore failed refresh
261  };
262 
263  enum Error {
265  NOT_FOUND, // the requested Url was not found
266  IO, // IO error
267  INVALID // th source is invalid
268  };
269 
270  virtual void start( const ProgressData &/*task*/, const RepoInfo /*repo*/ ) {}
271  virtual bool progress( const ProgressData &/*task*/ )
272  { return true; }
273 
274  virtual Action problem(
275  Repository /*source*/
276  , Error /*error*/
277  , const std::string &/*description*/ )
278  { return ABORT; }
279 
280  virtual void finish(
281  Repository /*source*/
282  , const std::string &/*task*/
283  , Error /*error*/
284  , const std::string &/*reason*/ )
285  {}
286  };
287 
288 
290  } // namespace source
292 
294  namespace media
295  {
296  // media change request callback
298  {
299  enum Action {
300  ABORT, // abort and return error
301  RETRY, // retry
302  IGNORE, // ignore this media in future, not available anymore
303  IGNORE_ID, // ignore wrong medium id
304  CHANGE_URL, // change media URL
305  EJECT // eject the medium
306  };
307 
308  enum Error {
310  NOT_FOUND, // the medie not found at all
311  IO, // error accessing the media
312  INVALID, // media is broken
313  WRONG, // wrong media, need a different one
314  IO_SOFT
315  };
316 
331  Url & /* url (I/O parameter) */
332  , unsigned /*mediumNr*/
333  , const std::string & /* label */
334  , Error /*error*/
335  , const std::string & /*description*/
336  , const std::vector<std::string> & /* devices */
337  , unsigned int & /* dev_current (I/O param) */
338  ) { return ABORT; }
339  };
340 
347  {
349  ScopedDisableMediaChangeReport( bool condition_r = true );
350  private:
351  shared_ptr<callback::TempConnect<media::MediaChangeReport> > _guard;
352  };
353 
354  // progress for downloading a file
356  {
357  enum Action {
358  ABORT, // abort and return error
359  RETRY, // retry
360  IGNORE // ignore the failure
361  };
362 
363  enum Error {
365  NOT_FOUND, // the requested Url was not found
366  IO, // IO error
367  ACCESS_DENIED, // user authent. failed while accessing restricted file
368  ERROR // other error
369  };
370 
371  virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
372 
381  virtual bool progress(int /*value*/, const Url &/*file*/,
382  double dbps_avg = -1,
383  double dbps_current = -1)
384  { return true; }
385 
386  virtual Action problem(
387  const Url &/*file*/
388  , Error /*error*/
389  , const std::string &/*description*/
390  ) { return ABORT; }
391 
392  virtual void finish(
393  const Url &/*file*/
394  , Error /*error*/
395  , const std::string &/*reason*/
396  ) {}
397  };
398 
399  // authentication issues report
401  {
416  virtual bool prompt(const Url & /* url */,
417  const std::string & /* msg */,
418  AuthData & /* auth_data */)
419  {
420  return false;
421  }
422  };
423 
425  } // namespace media
427 
429  namespace target
430  {
433  {
437  virtual bool show( Patch::constPtr & /*patch*/ )
438  { return true; }
439  };
440 
446  {
447  enum Notify { OUTPUT, PING };
448  enum Action {
449  ABORT, // abort commit and return error
450  RETRY, // (re)try to execute this script
451  IGNORE // ignore any failue and continue
452  };
453 
456  virtual void start( const Package::constPtr & /*package*/,
457  const Pathname & /*script path*/ )
458  {}
463  virtual bool progress( Notify /*OUTPUT or PING*/,
464  const std::string & /*output*/ = std::string() )
465  { return true; }
467  virtual Action problem( const std::string & /*description*/ )
468  { return ABORT; }
470  virtual void finish()
471  {}
472  };
473 
485  {
490  virtual bool start( const ProgressData & progress_r )
491  { return true; }
492 
498  virtual bool progress( const ProgressData & progress_r, const sat::Queue & noFilelist_r )
499  { return true; }
500 
507  virtual bool result( const ProgressData & progress_r, const sat::Queue & noFilelist_r, const sat::FileConflicts & conflicts_r )
508  { return true; }
509  };
510 
511 
513  namespace rpm
514  {
515 
516  // progress for installing a resolvable
518  {
519  enum Action {
520  ABORT, // abort and return error
521  RETRY, // retry
522  IGNORE // ignore the failure
523  };
524 
525  enum Error {
527  NOT_FOUND, // the requested Url was not found
528  IO, // IO error
529  INVALID // th resolvable is invalid
530  };
531 
532  // the level of RPM pushing
534  enum RpmLevel {
537  RPM_NODEPS_FORCE
538  };
539 
540  virtual void start(
541  Resolvable::constPtr /*resolvable*/
542  ) {}
543 
544  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
545  { return true; }
546 
547  virtual Action problem(
548  Resolvable::constPtr /*resolvable*/
549  , Error /*error*/
550  , const std::string &/*description*/
551  , RpmLevel /*level*/
552  ) { return ABORT; }
553 
554  virtual void finish(
555  Resolvable::constPtr /*resolvable*/
556  , Error /*error*/
557  , const std::string &/*reason*/
558  , RpmLevel /*level*/
559  ) {}
560  };
561 
562  // progress for removing a resolvable
564  {
565  enum Action {
566  ABORT, // abort and return error
567  RETRY, // retry
568  IGNORE // ignore the failure
569  };
570 
571  enum Error {
573  NOT_FOUND, // the requested Url was not found
574  IO, // IO error
575  INVALID // th resolvable is invalid
576  };
577 
578  virtual void start(
579  Resolvable::constPtr /*resolvable*/
580  ) {}
581 
582  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
583  { return true; }
584 
585  virtual Action problem(
586  Resolvable::constPtr /*resolvable*/
587  , Error /*error*/
588  , const std::string &/*description*/
589  ) { return ABORT; }
590 
591  virtual void finish(
592  Resolvable::constPtr /*resolvable*/
593  , Error /*error*/
594  , const std::string &/*reason*/
595  ) {}
596  };
597 
598  // progress for rebuilding the database
600  {
601  enum Action {
602  ABORT, // abort and return error
603  RETRY, // retry
604  IGNORE // ignore the failure
605  };
606 
607  enum Error {
609  FAILED // failed to rebuild
610  };
611 
612  virtual void start(Pathname /*path*/) {}
613 
614  virtual bool progress(int /*value*/, Pathname /*path*/)
615  { return true; }
616 
617  virtual Action problem(
618  Pathname /*path*/
619  , Error /*error*/
620  , const std::string &/*description*/
621  ) { return ABORT; }
622 
623  virtual void finish(
624  Pathname /*path*/
625  , Error /*error*/
626  , const std::string &/*reason*/
627  ) {}
628  };
629 
630  // progress for converting the database
632  {
633  enum Action {
634  ABORT, // abort and return error
635  RETRY, // retry
636  IGNORE // ignore the failure
637  };
638 
639  enum Error {
641  FAILED // conversion failed
642  };
643 
644  virtual void start(
645  Pathname /*path*/
646  ) {}
647 
648  virtual bool progress(int /*value*/, Pathname /*path*/)
649  { return true; }
650 
651  virtual Action problem(
652  Pathname /*path*/
653  , Error /*error*/
654  , const std::string &/*description*/
655  ) { return ABORT; }
656 
657  virtual void finish(
658  Pathname /*path*/
659  , Error /*error*/
660  , const std::string &/*reason*/
661  ) {}
662  };
663 
665  } // namespace rpm
667 
669  } // namespace target
671 
672  class PoolQuery;
673 
681  {
685  enum Action {
688  IGNORE
689  };
690 
694  enum Error {
696  ABORTED
697  };
698 
702  virtual void start(
703  ) {}
704 
709  virtual bool progress(int /*value*/)
710  { return true; }
711 
716  virtual Action execute(
717  const PoolQuery& /*error*/
718  ) { return DELETE; }
719 
723  virtual void finish(
724  Error /*error*/
725  ) {}
726 
727  };
728 
733  {
738  enum Action {
741  IGNORE
742  };
743 
747  enum Error {
749  ABORTED
750  };
751 
757  INTERSECT
759  };
760 
761  virtual void start() {}
762 
767  virtual bool progress()
768  { return true; }
769 
773  virtual Action conflict(
774  const PoolQuery&,
776  ) { return DELETE; }
777 
778  virtual void finish(
779  Error /*error*/
780  ) {}
781  };
782 
788  {
789  public:
791  struct EMsgTypeDef {
792  enum Enum { debug, info, warning, error, important, data };
793  };
794  typedef base::EnumClass<EMsgTypeDef> MsgType;
795 
798 
799  public:
801  virtual bool message( MsgType type_r, const std::string & msg_r, const UserData & userData_r ) const
802  { return true; }
803 
804 
808  static callback::SendReport<JobReport> & instance(); // impl in ZYppImpl.cc
809 
811  static bool debug( const std::string & msg_r, const UserData & userData_r = UserData() )
812  { return instance()->message( MsgType::debug, msg_r, userData_r ); }
813 
815  static bool info( const std::string & msg_r, const UserData & userData_r = UserData() )
816  { return instance()->message( MsgType::info, msg_r, userData_r ); }
817 
819  static bool warning( const std::string & msg_r, const UserData & userData_r = UserData() )
820  { return instance()->message( MsgType::warning, msg_r, userData_r ); }
821 
823  static bool error( const std::string & msg_r, const UserData & userData_r = UserData() )
824  { return instance()->message( MsgType::error, msg_r, userData_r ); }
825 
827  static bool important( const std::string & msg_r, const UserData & userData_r = UserData() )
828  { return instance()->message( MsgType::important, msg_r, userData_r ); }
829 
831  static bool data( const std::string & msg_r, const UserData & userData_r = UserData() )
832  { return instance()->message( MsgType::data, msg_r, userData_r ); }
834  };
835 
836 
838 } // namespace zypp
840 
841 #endif // ZYPP_ZYPPCALLBACKS_H
bool operator()(const ProgressData &progress)
Definition: ZYppCallbacks.h:70
virtual void start(Resolvable::constPtr, const Url &)
Interface to gettext.
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:89
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:42
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:54
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 bool message(MsgType type_r, const std::string &msg_r, const UserData &userData_r) const
Send a ready to show message text.
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:62
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:90
virtual void start(const Package::constPtr &, const Pathname &)
Start executing the script provided by package.
callback::SendReport< DownloadProgressReport > * report
Definition: MediaCurl.cc:203
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:45
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 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)