libzypp  16.2.1
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 
183  virtual void pkgGpgCheck( const UserData & userData_r = UserData() )
184  {}
185 
186  virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
187  , Error /*error*/
188  , const std::string &/*reason*/
189  ) {}
190  };
191 
192  // progress for probing a source
194  {
195  enum Action {
196  ABORT, // abort and return error
197  RETRY // retry
198  };
199 
200  enum Error {
202  NOT_FOUND, // the requested Url was not found
203  IO, // IO error
204  INVALID, // th source is invalid
205  UNKNOWN
206  };
207 
208  virtual void start(const Url &/*url*/) {}
209  virtual void failedProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
210  virtual void successProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
211  virtual void finish(const Url &/*url*/, Error /*error*/, const std::string &/*reason*/ ) {}
212 
213  virtual bool progress(const Url &/*url*/, int /*value*/)
214  { return true; }
215 
216  virtual Action problem( const Url &/*url*/, Error /*error*/, const std::string &/*description*/ ) { return ABORT; }
217  };
218 
220  {
221  enum Action {
222  ABORT, // abort and return error
223  RETRY, // retry
224  IGNORE // skip refresh, ignore failed refresh
225  };
226 
227  enum Error {
229  NOT_FOUND, // the requested Url was not found
230  IO, // IO error
232  INVALID, // th source is invali
233  UNKNOWN
234  };
235 
236  virtual void start( const zypp::Url &/*url*/ ) {}
237  virtual bool progress( int /*value*/ )
238  { return true; }
239 
240  virtual Action problem(
241  const zypp::Url &/*url*/
242  , Error /*error*/
243  , const std::string &/*description*/ )
244  { return ABORT; }
245 
246  virtual void finish(
247  const zypp::Url &/*url*/
248  , Error /*error*/
249  , const std::string &/*reason*/ )
250  {}
251  };
252 
254  {
255  enum Action {
256  ABORT, // abort and return error
257  RETRY, // retry
258  IGNORE // skip refresh, ignore failed refresh
259  };
260 
261  enum Error {
263  NOT_FOUND, // the requested Url was not found
264  IO, // IO error
265  INVALID // th source is invalid
266  };
267 
268  virtual void start( const ProgressData &/*task*/, const RepoInfo /*repo*/ ) {}
269  virtual bool progress( const ProgressData &/*task*/ )
270  { return true; }
271 
272  virtual Action problem(
273  Repository /*source*/
274  , Error /*error*/
275  , const std::string &/*description*/ )
276  { return ABORT; }
277 
278  virtual void finish(
279  Repository /*source*/
280  , const std::string &/*task*/
281  , Error /*error*/
282  , const std::string &/*reason*/ )
283  {}
284  };
285 
286 
288  } // namespace source
290 
292  namespace media
293  {
294  // media change request callback
296  {
297  enum Action {
298  ABORT, // abort and return error
299  RETRY, // retry
300  IGNORE, // ignore this media in future, not available anymore
301  IGNORE_ID, // ignore wrong medium id
302  CHANGE_URL, // change media URL
303  EJECT // eject the medium
304  };
305 
306  enum Error {
308  NOT_FOUND, // the medie not found at all
309  IO, // error accessing the media
310  INVALID, // media is broken
311  WRONG, // wrong media, need a different one
312  IO_SOFT
313  };
314 
329  Url & /* url (I/O parameter) */
330  , unsigned /*mediumNr*/
331  , const std::string & /* label */
332  , Error /*error*/
333  , const std::string & /*description*/
334  , const std::vector<std::string> & /* devices */
335  , unsigned int & /* dev_current (I/O param) */
336  ) { return ABORT; }
337  };
338 
345  {
347  ScopedDisableMediaChangeReport( bool condition_r = true );
348  private:
349  shared_ptr<callback::TempConnect<media::MediaChangeReport> > _guard;
350  };
351 
352  // progress for downloading a file
354  {
355  enum Action {
356  ABORT, // abort and return error
357  RETRY, // retry
358  IGNORE // ignore the failure
359  };
360 
361  enum Error {
363  NOT_FOUND, // the requested Url was not found
364  IO, // IO error
365  ACCESS_DENIED, // user authent. failed while accessing restricted file
366  ERROR // other error
367  };
368 
369  virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
370 
379  virtual bool progress(int /*value*/, const Url &/*file*/,
380  double dbps_avg = -1,
381  double dbps_current = -1)
382  { return true; }
383 
384  virtual Action problem(
385  const Url &/*file*/
386  , Error /*error*/
387  , const std::string &/*description*/
388  ) { return ABORT; }
389 
390  virtual void finish(
391  const Url &/*file*/
392  , Error /*error*/
393  , const std::string &/*reason*/
394  ) {}
395  };
396 
397  // authentication issues report
399  {
414  virtual bool prompt(const Url & /* url */,
415  const std::string & /* msg */,
416  AuthData & /* auth_data */)
417  {
418  return false;
419  }
420  };
421 
423  } // namespace media
425 
427  namespace target
428  {
431  {
435  virtual bool show( Patch::constPtr & /*patch*/ )
436  { return true; }
437  };
438 
444  {
445  enum Notify { OUTPUT, PING };
446  enum Action {
447  ABORT, // abort commit and return error
448  RETRY, // (re)try to execute this script
449  IGNORE // ignore any failue and continue
450  };
451 
454  virtual void start( const Package::constPtr & /*package*/,
455  const Pathname & /*script path*/ )
456  {}
461  virtual bool progress( Notify /*OUTPUT or PING*/,
462  const std::string & /*output*/ = std::string() )
463  { return true; }
465  virtual Action problem( const std::string & /*description*/ )
466  { return ABORT; }
468  virtual void finish()
469  {}
470  };
471 
483  {
488  virtual bool start( const ProgressData & progress_r )
489  { return true; }
490 
496  virtual bool progress( const ProgressData & progress_r, const sat::Queue & noFilelist_r )
497  { return true; }
498 
505  virtual bool result( const ProgressData & progress_r, const sat::Queue & noFilelist_r, const sat::FileConflicts & conflicts_r )
506  { return true; }
507  };
508 
509 
511  namespace rpm
512  {
513 
514  // progress for installing a resolvable
516  {
517  enum Action {
518  ABORT, // abort and return error
519  RETRY, // retry
520  IGNORE // ignore the failure
521  };
522 
523  enum Error {
525  NOT_FOUND, // the requested Url was not found
526  IO, // IO error
527  INVALID // th resolvable is invalid
528  };
529 
530  // the level of RPM pushing
532  enum RpmLevel {
535  RPM_NODEPS_FORCE
536  };
537 
538  virtual void start(
539  Resolvable::constPtr /*resolvable*/
540  ) {}
541 
542  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
543  { return true; }
544 
545  virtual Action problem(
546  Resolvable::constPtr /*resolvable*/
547  , Error /*error*/
548  , const std::string &/*description*/
549  , RpmLevel /*level*/
550  ) { return ABORT; }
551 
552  virtual void finish(
553  Resolvable::constPtr /*resolvable*/
554  , Error /*error*/
555  , const std::string &/*reason*/
556  , RpmLevel /*level*/
557  ) {}
558  };
559 
560  // progress for removing a resolvable
562  {
563  enum Action {
564  ABORT, // abort and return error
565  RETRY, // retry
566  IGNORE // ignore the failure
567  };
568 
569  enum Error {
571  NOT_FOUND, // the requested Url was not found
572  IO, // IO error
573  INVALID // th resolvable is invalid
574  };
575 
576  virtual void start(
577  Resolvable::constPtr /*resolvable*/
578  ) {}
579 
580  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
581  { return true; }
582 
583  virtual Action problem(
584  Resolvable::constPtr /*resolvable*/
585  , Error /*error*/
586  , const std::string &/*description*/
587  ) { return ABORT; }
588 
589  virtual void finish(
590  Resolvable::constPtr /*resolvable*/
591  , Error /*error*/
592  , const std::string &/*reason*/
593  ) {}
594  };
595 
596  // progress for rebuilding the database
598  {
599  enum Action {
600  ABORT, // abort and return error
601  RETRY, // retry
602  IGNORE // ignore the failure
603  };
604 
605  enum Error {
607  FAILED // failed to rebuild
608  };
609 
610  virtual void start(Pathname /*path*/) {}
611 
612  virtual bool progress(int /*value*/, Pathname /*path*/)
613  { return true; }
614 
615  virtual Action problem(
616  Pathname /*path*/
617  , Error /*error*/
618  , const std::string &/*description*/
619  ) { return ABORT; }
620 
621  virtual void finish(
622  Pathname /*path*/
623  , Error /*error*/
624  , const std::string &/*reason*/
625  ) {}
626  };
627 
628  // progress for converting the database
630  {
631  enum Action {
632  ABORT, // abort and return error
633  RETRY, // retry
634  IGNORE // ignore the failure
635  };
636 
637  enum Error {
639  FAILED // conversion failed
640  };
641 
642  virtual void start(
643  Pathname /*path*/
644  ) {}
645 
646  virtual bool progress(int /*value*/, Pathname /*path*/)
647  { return true; }
648 
649  virtual Action problem(
650  Pathname /*path*/
651  , Error /*error*/
652  , const std::string &/*description*/
653  ) { return ABORT; }
654 
655  virtual void finish(
656  Pathname /*path*/
657  , Error /*error*/
658  , const std::string &/*reason*/
659  ) {}
660  };
661 
663  } // namespace rpm
665 
667  } // namespace target
669 
670  class PoolQuery;
671 
679  {
683  enum Action {
686  IGNORE
687  };
688 
692  enum Error {
694  ABORTED
695  };
696 
700  virtual void start(
701  ) {}
702 
707  virtual bool progress(int /*value*/)
708  { return true; }
709 
714  virtual Action execute(
715  const PoolQuery& /*error*/
716  ) { return DELETE; }
717 
721  virtual void finish(
722  Error /*error*/
723  ) {}
724 
725  };
726 
731  {
736  enum Action {
739  IGNORE
740  };
741 
745  enum Error {
747  ABORTED
748  };
749 
755  INTERSECT
757  };
758 
759  virtual void start() {}
760 
765  virtual bool progress()
766  { return true; }
767 
771  virtual Action conflict(
772  const PoolQuery&,
774  ) { return DELETE; }
775 
776  virtual void finish(
777  Error /*error*/
778  ) {}
779  };
780 
786  {
787  public:
789  struct EMsgTypeDef {
790  enum Enum { debug, info, warning, error, important, data };
791  };
792  typedef base::EnumClass<EMsgTypeDef> MsgType;
793 
796 
797  public:
799  virtual bool message( MsgType type_r, const std::string & msg_r, const UserData & userData_r ) const
800  { return true; }
801 
802 
806  static callback::SendReport<JobReport> & instance(); // impl in ZYppImpl.cc
807 
809  static bool debug( const std::string & msg_r, const UserData & userData_r = UserData() )
810  { return instance()->message( MsgType::debug, msg_r, userData_r ); }
811 
813  static bool info( const std::string & msg_r, const UserData & userData_r = UserData() )
814  { return instance()->message( MsgType::info, msg_r, userData_r ); }
815 
817  static bool warning( const std::string & msg_r, const UserData & userData_r = UserData() )
818  { return instance()->message( MsgType::warning, msg_r, userData_r ); }
819 
821  static bool error( const std::string & msg_r, const UserData & userData_r = UserData() )
822  { return instance()->message( MsgType::error, msg_r, userData_r ); }
823 
825  static bool important( const std::string & msg_r, const UserData & userData_r = UserData() )
826  { return instance()->message( MsgType::important, msg_r, userData_r ); }
827 
829  static bool data( const std::string & msg_r, const UserData & userData_r = UserData() )
830  { return instance()->message( MsgType::data, msg_r, userData_r ); }
832  };
833 
834 
836 } // namespace zypp
838 
839 #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:177
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)