libzypp  14.29.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 
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  virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
188  , Error /*error*/
189  , const std::string &/*reason*/
190  ) {}
191  };
192 
193  // progress for probing a source
195  {
196  enum Action {
197  ABORT, // abort and return error
198  RETRY // retry
199  };
200 
201  enum Error {
203  NOT_FOUND, // the requested Url was not found
204  IO, // IO error
205  INVALID, // th source is invalid
207  };
208 
209  virtual void start(const Url &/*url*/) {}
210  virtual void failedProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
211  virtual void successProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
212  virtual void finish(const Url &/*url*/, Error /*error*/, const std::string &/*reason*/ ) {}
213 
214  virtual bool progress(const Url &/*url*/, int /*value*/)
215  { return true; }
216 
217  virtual Action problem( const Url &/*url*/, Error /*error*/, const std::string &/*description*/ ) { return ABORT; }
218  };
219 
221  {
222  enum Action {
223  ABORT, // abort and return error
224  RETRY, // retry
225  IGNORE // skip refresh, ignore failed refresh
226  };
227 
228  enum Error {
230  NOT_FOUND, // the requested Url was not found
231  IO, // IO error
233  INVALID, // th source is invali
235  };
236 
237  virtual void start( const zypp::Url &/*url*/ ) {}
238  virtual bool progress( int /*value*/ )
239  { return true; }
240 
241  virtual Action problem(
242  const zypp::Url &/*url*/
243  , Error /*error*/
244  , const std::string &/*description*/ )
245  { return ABORT; }
246 
247  virtual void finish(
248  const zypp::Url &/*url*/
249  , Error /*error*/
250  , const std::string &/*reason*/ )
251  {}
252  };
253 
255  {
256  enum Action {
257  ABORT, // abort and return error
258  RETRY, // retry
259  IGNORE // skip refresh, ignore failed refresh
260  };
261 
262  enum Error {
264  NOT_FOUND, // the requested Url was not found
265  IO, // IO error
266  INVALID // th source is invalid
267  };
268 
269  virtual void start( const ProgressData &/*task*/, const RepoInfo /*repo*/ ) {}
270  virtual bool progress( const ProgressData &/*task*/ )
271  { return true; }
272 
273  virtual Action problem(
274  Repository /*source*/
275  , Error /*error*/
276  , const std::string &/*description*/ )
277  { return ABORT; }
278 
279  virtual void finish(
280  Repository /*source*/
281  , const std::string &/*task*/
282  , Error /*error*/
283  , const std::string &/*reason*/ )
284  {}
285  };
286 
287 
289  } // namespace source
291 
293  namespace media
294  {
295  // media change request callback
297  {
298  enum Action {
299  ABORT, // abort and return error
300  RETRY, // retry
301  IGNORE, // ignore this media in future, not available anymore
302  IGNORE_ID, // ignore wrong medium id
303  CHANGE_URL, // change media URL
304  EJECT // eject the medium
305  };
306 
307  enum Error {
309  NOT_FOUND, // the medie not found at all
310  IO, // error accessing the media
311  INVALID, // media is broken
312  WRONG, // wrong media, need a different one
314  };
315 
330  Url & /* url (I/O parameter) */
331  , unsigned /*mediumNr*/
332  , const std::string & /* label */
333  , Error /*error*/
334  , const std::string & /*description*/
335  , const std::vector<std::string> & /* devices */
336  , unsigned int & /* dev_current (I/O param) */
337  ) { return ABORT; }
338  };
339 
340  // progress for downloading a file
342  {
343  enum Action {
344  ABORT, // abort and return error
345  RETRY, // retry
346  IGNORE // ignore the failure
347  };
348 
349  enum Error {
351  NOT_FOUND, // the requested Url was not found
352  IO, // IO error
353  ACCESS_DENIED, // user authent. failed while accessing restricted file
354  ERROR // other error
355  };
356 
357  virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
358 
367  virtual bool progress(int /*value*/, const Url &/*file*/,
368  double dbps_avg = -1,
369  double dbps_current = -1)
370  { return true; }
371 
372  virtual Action problem(
373  const Url &/*file*/
374  , Error /*error*/
375  , const std::string &/*description*/
376  ) { return ABORT; }
377 
378  virtual void finish(
379  const Url &/*file*/
380  , Error /*error*/
381  , const std::string &/*reason*/
382  ) {}
383  };
384 
385  // authentication issues report
387  {
402  virtual bool prompt(const Url & /* url */,
403  const std::string & /* msg */,
404  AuthData & /* auth_data */)
405  {
406  return false;
407  }
408  };
409 
411  } // namespace media
413 
415  namespace target
416  {
419  {
423  virtual bool show( Patch::constPtr & /*patch*/ )
424  { return true; }
425  };
426 
432  {
433  enum Notify { OUTPUT, PING };
434  enum Action {
435  ABORT, // abort commit and return error
436  RETRY, // (re)try to execute this script
437  IGNORE // ignore any failue and continue
438  };
439 
442  virtual void start( const Package::constPtr & /*package*/,
443  const Pathname & /*script path*/ )
444  {}
449  virtual bool progress( Notify /*OUTPUT or PING*/,
450  const std::string & /*output*/ = std::string() )
451  { return true; }
453  virtual Action problem( const std::string & /*description*/ )
454  { return ABORT; }
456  virtual void finish()
457  {}
458  };
459 
471  {
476  virtual bool start( const ProgressData & progress_r )
477  { return true; }
478 
484  virtual bool progress( const ProgressData & progress_r, const sat::Queue & noFilelist_r )
485  { return true; }
486 
493  virtual bool result( const ProgressData & progress_r, const sat::Queue & noFilelist_r, const sat::FileConflicts & conflicts_r )
494  { return true; }
495  };
496 
497 
499  namespace rpm
500  {
501 
502  // progress for installing a resolvable
504  {
505  enum Action {
506  ABORT, // abort and return error
507  RETRY, // retry
508  IGNORE // ignore the failure
509  };
510 
511  enum Error {
513  NOT_FOUND, // the requested Url was not found
514  IO, // IO error
515  INVALID // th resolvable is invalid
516  };
517 
518  // the level of RPM pushing
520  enum RpmLevel {
524  };
525 
526  virtual void start(
527  Resolvable::constPtr /*resolvable*/
528  ) {}
529 
530  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
531  { return true; }
532 
533  virtual Action problem(
534  Resolvable::constPtr /*resolvable*/
535  , Error /*error*/
536  , const std::string &/*description*/
537  , RpmLevel /*level*/
538  ) { return ABORT; }
539 
540  virtual void finish(
541  Resolvable::constPtr /*resolvable*/
542  , Error /*error*/
543  , const std::string &/*reason*/
544  , RpmLevel /*level*/
545  ) {}
546  };
547 
548  // progress for removing a resolvable
550  {
551  enum Action {
552  ABORT, // abort and return error
553  RETRY, // retry
554  IGNORE // ignore the failure
555  };
556 
557  enum Error {
559  NOT_FOUND, // the requested Url was not found
560  IO, // IO error
561  INVALID // th resolvable is invalid
562  };
563 
564  virtual void start(
565  Resolvable::constPtr /*resolvable*/
566  ) {}
567 
568  virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
569  { return true; }
570 
571  virtual Action problem(
572  Resolvable::constPtr /*resolvable*/
573  , Error /*error*/
574  , const std::string &/*description*/
575  ) { return ABORT; }
576 
577  virtual void finish(
578  Resolvable::constPtr /*resolvable*/
579  , Error /*error*/
580  , const std::string &/*reason*/
581  ) {}
582  };
583 
584  // progress for rebuilding the database
586  {
587  enum Action {
588  ABORT, // abort and return error
589  RETRY, // retry
590  IGNORE // ignore the failure
591  };
592 
593  enum Error {
595  FAILED // failed to rebuild
596  };
597 
598  virtual void start(Pathname /*path*/) {}
599 
600  virtual bool progress(int /*value*/, Pathname /*path*/)
601  { return true; }
602 
603  virtual Action problem(
604  Pathname /*path*/
605  , Error /*error*/
606  , const std::string &/*description*/
607  ) { return ABORT; }
608 
609  virtual void finish(
610  Pathname /*path*/
611  , Error /*error*/
612  , const std::string &/*reason*/
613  ) {}
614  };
615 
616  // progress for converting 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 // conversion failed
628  };
629 
630  virtual void start(
631  Pathname /*path*/
632  ) {}
633 
634  virtual bool progress(int /*value*/, Pathname /*path*/)
635  { return true; }
636 
637  virtual Action problem(
638  Pathname /*path*/
639  , Error /*error*/
640  , const std::string &/*description*/
641  ) { return ABORT; }
642 
643  virtual void finish(
644  Pathname /*path*/
645  , Error /*error*/
646  , const std::string &/*reason*/
647  ) {}
648  };
649 
651  } // namespace rpm
653 
655  } // namespace target
657 
658  class PoolQuery;
659 
667  {
671  enum Action {
675  };
676 
680  enum Error {
683  };
684 
688  virtual void start(
689  ) {}
690 
695  virtual bool progress(int /*value*/)
696  { return true; }
697 
702  virtual Action execute(
703  const PoolQuery& /*error*/
704  ) { return DELETE; }
705 
709  virtual void finish(
710  Error /*error*/
711  ) {}
712 
713  };
714 
719  {
724  enum Action {
728  };
729 
733  enum Error {
736  };
737 
745  };
746 
747  virtual void start() {}
748 
753  virtual bool progress()
754  { return true; }
755 
759  virtual Action conflict(
760  const PoolQuery&,
762  ) { return DELETE; }
763 
764  virtual void finish(
765  Error /*error*/
766  ) {}
767  };
768 
774  {
775  public:
777  struct _MsgTypeDef {
779  };
780  typedef base::EnumClass<_MsgTypeDef> MsgType;
781 
784 
785  public:
787  virtual bool message( MsgType type_r, const std::string & msg_r, const UserData & userData_r ) const
788  { return true; }
789 
790 
794  static callback::SendReport<JobReport> & instance(); // impl in ZYppImpl.cc
795 
797  static bool debug( const MessageString & msg_r, const UserData & userData_r = UserData() )
798  { return instance()->message( MsgType::debug, msg_r, userData_r ); }
799 
801  static bool info( const MessageString & msg_r, const UserData & userData_r = UserData() )
802  { return instance()->message( MsgType::info, msg_r, userData_r ); }
803 
805  static bool warning( const MessageString & msg_r, const UserData & userData_r = UserData() )
806  { return instance()->message( MsgType::warning, msg_r, userData_r ); }
807 
809  static bool error( const MessageString & msg_r, const UserData & userData_r = UserData() )
810  { return instance()->message( MsgType::error, msg_r, userData_r ); }
811 
813  static bool important( const MessageString & msg_r, const UserData & userData_r = UserData() )
814  { return instance()->message( MsgType::important, msg_r, userData_r ); }
815 
817  static bool data( const MessageString & msg_r, const UserData & userData_r = UserData() )
818  { return instance()->message( MsgType::data, msg_r, userData_r ); }
820  };
821 
822 
824 } // namespace zypp
826 
827 #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 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:66
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)
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.
virtual void failedProbe(const Url &, const std::string &)
Libsolv Id queue wrapper.
Definition: Queue.h:38
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:178
Typesafe passing of user data via callbacks.
Definition: UserData.h:35
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
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:35
#define ZYPP_DEPRECATED
The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings with gcc >= 3...
Definition: APIConfig.h:86
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
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()