libzypp 17.25.7
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
28namespace 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)
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 bool value = _report->progress(progress);
78 if ( _fnc )
79 value &= _fnc(progress);
80
81 if ( progress.finalReport() )
82 {
83 _report->finish(progress);
84 }
85 return value;
86 }
87
90 bool _first;
91 };
92
94
95 namespace repo
96 {
97 // progress for downloading a resolvable
99 {
100 enum Action {
101 ABORT, // abort and return error
102 RETRY, // retry
103 IGNORE, // ignore this resolvable but continue
104 };
105
106 enum Error {
108 NOT_FOUND, // the requested Url was not found
109 IO, // IO error
110 INVALID // the downloaded file is invalid
111 };
112
116 virtual void infoInCache( Resolvable::constPtr res_r, const Pathname & localfile_r )
117 {}
118
119 virtual void start(
120 Resolvable::constPtr /*resolvable_ptr*/
121 , const Url &/*url*/
122 ) {}
123
124
125 // Dowmload delta rpm:
126 // - path below url reported on start()
127 // - expected download size (0 if unknown)
128 // - download is interruptable
129 // - problems are just informal
130 virtual void startDeltaDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
131 {}
132
133 virtual bool progressDeltaDownload( int /*value*/ )
134 { return true; }
135
136 virtual void problemDeltaDownload( const std::string &/*description*/ )
137 {}
138
139 virtual void finishDeltaDownload()
140 {}
141
142 // Apply delta rpm:
143 // - local path of downloaded delta
144 // - aplpy is not interruptable
145 // - problems are just informal
146 virtual void startDeltaApply( const Pathname & /*filename*/ )
147 {}
148
149 virtual void progressDeltaApply( int /*value*/ )
150 {}
151
152 virtual void problemDeltaApply( const std::string &/*description*/ )
153 {}
154
155 virtual void finishDeltaApply()
156 {}
157
158 // return false if the download should be aborted right now
159 virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable_ptr*/)
160 { return true; }
161
163 Resolvable::constPtr /*resolvable_ptr*/
164 , Error /*error*/
165 , const std::string &/*description*/
166 ) { return ABORT; }
167
168
184 virtual void pkgGpgCheck( const UserData & userData_r = UserData() )
185 {}
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
206 UNKNOWN
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
234 UNKNOWN
235 };
236
237 virtual void start( const zypp::Url &/*url*/ ) {}
238 virtual bool progress( int /*value*/ )
239 { return true; }
240
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
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
313 IO_SOFT
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
346 {
348 ScopedDisableMediaChangeReport( bool condition_r = true );
349 private:
350 shared_ptr<callback::TempConnect<media::MediaChangeReport> > _guard;
351 };
352
353 // progress for downloading a file
355 {
356 enum Action {
357 ABORT, // abort and return error
358 RETRY, // retry
359 IGNORE // ignore the failure
360 };
361
362 enum Error {
364 NOT_FOUND, // the requested Url was not found
365 IO, // IO error
366 ACCESS_DENIED, // user authent. failed while accessing restricted file
367 ERROR // other error
368 };
369
370 virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
371
380 virtual bool progress(int /*value*/, const Url &/*file*/,
381 double dbps_avg = -1,
382 double dbps_current = -1)
383 { return true; }
384
386 const Url &/*file*/
387 , Error /*error*/
388 , const std::string &/*description*/
389 ) { return ABORT; }
390
391 virtual void finish(
392 const Url &/*file*/
393 , Error /*error*/
394 , const std::string &/*reason*/
395 ) {}
396 };
397
398 // authentication issues report
400 {
415 virtual bool prompt(const Url & /* url */,
416 const std::string & /* msg */,
417 AuthData & /* auth_data */)
418 {
419 return false;
420 }
421 };
422
424 } // namespace media
426
428 namespace target
429 {
432 {
436 virtual bool show( Patch::constPtr & /*patch*/ )
437 { return true; }
438 };
439
445 {
446 enum Notify { OUTPUT, PING };
447 enum Action {
448 ABORT, // abort commit and return error
449 RETRY, // (re)try to execute this script
450 IGNORE // ignore any failue and continue
451 };
452
455 virtual void start( const Package::constPtr & /*package*/,
456 const Pathname & /*script path*/ )
457 {}
462 virtual bool progress( Notify /*OUTPUT or PING*/,
463 const std::string & /*output*/ = std::string() )
464 { return true; }
466 virtual Action problem( const std::string & /*description*/ )
467 { return ABORT; }
469 virtual void finish()
470 {}
471 };
472
484 {
489 virtual bool start( const ProgressData & progress_r )
490 { return true; }
491
497 virtual bool progress( const ProgressData & progress_r, const sat::Queue & noFilelist_r )
498 { return true; }
499
506 virtual bool result( const ProgressData & progress_r, const sat::Queue & noFilelist_r, const sat::FileConflicts & conflicts_r )
507 { return true; }
508 };
509
510
512 namespace rpm
513 {
514
515 // progress for installing a resolvable
517 {
518 enum Action {
519 ABORT, // abort and return error
520 RETRY, // retry
521 IGNORE // ignore the failure
522 };
523
524 enum Error {
526 NOT_FOUND, // the requested Url was not found
527 IO, // IO error
528 INVALID // th resolvable is invalid
529 };
530
531 // the level of RPM pushing
533 enum RpmLevel {
537 };
538
539 virtual void start(
540 Resolvable::constPtr /*resolvable*/
541 ) {}
542
543 virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
544 { return true; }
545
547 Resolvable::constPtr /*resolvable*/
548 , Error /*error*/
549 , const std::string &/*description*/
550 , RpmLevel /*level*/
551 ) { return ABORT; }
552
553 virtual void finish(
554 Resolvable::constPtr /*resolvable*/
555 , Error /*error*/
556 , const std::string &/*reason*/
557 , RpmLevel /*level*/
558 ) {}
559
567 };
568
569 // progress for removing a resolvable
571 {
572 enum Action {
573 ABORT, // abort and return error
574 RETRY, // retry
575 IGNORE // ignore the failure
576 };
577
578 enum Error {
580 NOT_FOUND, // the requested Url was not found
581 IO, // IO error
582 INVALID // th resolvable is invalid
583 };
584
585 virtual void start(
586 Resolvable::constPtr /*resolvable*/
587 ) {}
588
589 virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
590 { return true; }
591
593 Resolvable::constPtr /*resolvable*/
594 , Error /*error*/
595 , const std::string &/*description*/
596 ) { return ABORT; }
597
598 virtual void finish(
599 Resolvable::constPtr /*resolvable*/
600 , Error /*error*/
601 , const std::string &/*reason*/
602 ) {}
603
608 };
609
610 // progress for rebuilding the database
612 {
613 enum Action {
614 ABORT, // abort and return error
615 RETRY, // retry
616 IGNORE // ignore the failure
617 };
618
619 enum Error {
621 FAILED // failed to rebuild
622 };
623
624 virtual void start(Pathname /*path*/) {}
625
626 virtual bool progress(int /*value*/, Pathname /*path*/)
627 { return true; }
628
630 Pathname /*path*/
631 , Error /*error*/
632 , const std::string &/*description*/
633 ) { return ABORT; }
634
635 virtual void finish(
636 Pathname /*path*/
637 , Error /*error*/
638 , const std::string &/*reason*/
639 ) {}
640 };
641
642#if LEGACY(17)
643 // progress for converting the database
645 struct ZYPP_DEPRECATED ConvertDBReport : public callback::ReportBase
646 {
647 enum Action {
648 ABORT, // abort and return error
649 RETRY, // retry
650 IGNORE // ignore the failure
651 };
652
653 enum Error {
654 NO_ERROR,
655 FAILED // conversion failed
656 };
657
658 virtual void start( Pathname /*path*/ )
659 {}
660
661 virtual bool progress( int/*value*/, Pathname/*path*/ )
662 { return true; }
663
664 virtual Action problem( Pathname/*path*/, Error/*error*/, const std::string &/*description*/ )
665 { return ABORT; }
666
667 virtual void finish( Pathname/*path*/, Error/*error*/, const std::string &/*reason*/ )
668 {}
669 };
670#endif
672 } // namespace rpm
674
676 } // namespace target
678
679 class PoolQuery;
680
688 {
692 enum Action {
695 IGNORE
696 };
697
701 enum Error {
703 ABORTED
704 };
705
709 virtual void start(
710 ) {}
711
716 virtual bool progress(int /*value*/)
717 { return true; }
718
724 const PoolQuery& /*error*/
725 ) { return DELETE; }
726
730 virtual void finish(
731 Error /*error*/
732 ) {}
733
734 };
735
740 {
745 enum Action {
748 IGNORE
749 };
750
754 enum Error {
756 ABORTED
757 };
758
764 INTERSECT
766 };
767
768 virtual void start() {}
769
774 virtual bool progress()
775 { return true; }
776
781 const PoolQuery&,
783 ) { return DELETE; }
784
785 virtual void finish(
786 Error /*error*/
787 ) {}
788 };
789
795 {
796 public:
798 struct EMsgTypeDef {
800 };
801 typedef base::EnumClass<EMsgTypeDef> MsgType;
802
805
806 public:
808 virtual bool message( MsgType type_r, const std::string & msg_r, const UserData & userData_r ) const
809 { return true; }
810
811
815 static callback::SendReport<JobReport> & instance(); // impl in ZYppImpl.cc
816
818 static bool debug( const std::string & msg_r, const UserData & userData_r = UserData() )
819 { return instance()->message( MsgType::debug, msg_r, userData_r ); }
820
822 static bool info( const std::string & msg_r, const UserData & userData_r = UserData() )
823 { return instance()->message( MsgType::info, msg_r, userData_r ); }
824
826 static bool warning( const std::string & msg_r, const UserData & userData_r = UserData() )
827 { return instance()->message( MsgType::warning, msg_r, userData_r ); }
828
830 static bool error( const std::string & msg_r, const UserData & userData_r = UserData() )
831 { return instance()->message( MsgType::error, msg_r, userData_r ); }
832
834 static bool important( const std::string & msg_r, const UserData & userData_r = UserData() )
835 { return instance()->message( MsgType::important, msg_r, userData_r ); }
836
838 static bool data( const std::string & msg_r, const UserData & userData_r = UserData() )
839 { return instance()->message( MsgType::data, msg_r, userData_r ); }
841 };
842
843
845} // namespace zypp
847
848#endif // ZYPP_ZYPPCALLBACKS_H
callback::SendReport< DownloadProgressReport > * report
Definition: MediaCurl.cc:70
Convenience interface for handling authentication data of media user.
Store and operate with byte count.
Definition: ByteCount.h:31
Mime type like 'type/subtype' classification of content.
Definition: ContentType.h:30
TraitsType::constPtrType constPtr
Definition: Package.h:38
TraitsType::constPtrType constPtr
Definition: Patch.h:43
Meta-data query API.
Definition: PoolQuery.h:91
Maintain [min,max] and counter (value) for progress counting.
Definition: ProgressData.h:131
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
Definition: ProgressData.h:139
bool finalReport() const
Definition: ProgressData.h:333
What is known about a repository.
Definition: RepoInfo.h:72
TraitsType::constPtrType constPtr
Definition: Resolvable.h:59
Url manipulation class.
Definition: Url.h:92
Typesafe passing of user data via callbacks.
Definition: UserData.h:39
Class for handling media authentication data.
Definition: MediaUserAuth.h:31
Libsolv queue representing file conflicts.
Definition: FileConflicts.h:31
Libsolv Id queue wrapper.
Definition: Queue.h:35
@ Error
Definition: IOTools.h:58
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
Callback for cleaning locks which doesn't lock anything in pool.
@ ABORTED
cleaning aborted by user
Action
action performed by cleaning api to specific lock
@ ABORT
abort and return error
@ DELETE
delete empty lock
virtual void start()
cleaning is started
virtual Action execute(const PoolQuery &)
When find empty lock ask what to do with it.
virtual bool progress(int)
progress of cleaning specifies in percents
virtual void finish(Error)
cleaning is done
message type (use like 'enum class MsgType')
Generic report for sending messages.
static bool debug(const std::string &msg_r, const UserData &userData_r=UserData())
send debug message text
base::EnumClass< EMsgTypeDef > MsgType
'enum class MsgType'
static bool warning(const std::string &msg_r, const UserData &userData_r=UserData())
send warning text
static bool error(const std::string &msg_r, const UserData &userData_r=UserData())
send error text
virtual bool message(MsgType type_r, const std::string &msg_r, const UserData &userData_r) const
Send a ready to show message text.
static bool data(const std::string &msg_r, const UserData &userData_r=UserData())
send data message
callback::UserData UserData
typsafe map of userdata
static bool important(const std::string &msg_r, const UserData &userData_r=UserData())
send important message text
static callback::SendReport< JobReport > & instance()
Singleton sender instance.
Definition: ZYppImpl.cc:51
static bool info(const std::string &msg_r, const UserData &userData_r=UserData())
send message text
ProgressData::ReceiverFnc _fnc
Definition: ZYppCallbacks.h:88
callback::SendReport< ProgressReport > & _report
Definition: ZYppCallbacks.h:89
ProgressReportAdaptor(const ProgressData::ReceiverFnc &fnc, callback::SendReport< ProgressReport > &report)
Definition: ZYppCallbacks.h:61
bool operator()(const ProgressData &progress)
Definition: ZYppCallbacks.h:69
virtual void start(const ProgressData &)
Definition: ZYppCallbacks.h:41
virtual void finish(const ProgressData &)
Definition: ZYppCallbacks.h:53
virtual bool progress(const ProgressData &)
Definition: ZYppCallbacks.h:44
this callback handles merging old locks with newly added or removed
Action
action for old lock which is in conflict
@ DELETE
delete conflicted lock
@ IGNORE
skip conflict lock
@ ABORT
abort and return error
virtual bool progress()
merging still live
virtual void finish(Error)
ConflictState
type of conflict of old and new lock
@ INTERSECT
locks lock some file and unlocking lock unlock only part of iti, so removing old lock can unlock more...
@ SAME_RESULTS
locks lock same item in pool but his parameters is different
Error
result of merging
@ ABORTED
cleaning aborted by user
virtual Action conflict(const PoolQuery &, ConflictState)
When user unlock something which is locked by non-identical query.
callback::UserData UserData
Definition: Callback.h:151
virtual bool prompt(const Url &, const std::string &, AuthData &)
Prompt for authentication data.
virtual void finish(const Url &, Error, const std::string &)
virtual bool progress(int, const Url &, double dbps_avg=-1, double dbps_current=-1)
Download progress.
virtual void start(const Url &, Pathname)
virtual Action problem(const Url &, Error, const std::string &)
@ IO_SOFT
IO error which can happen on worse connection like timeout exceed.
virtual Action requestMedia(Url &, unsigned, const std::string &, Error, const std::string &, const std::vector< std::string > &, unsigned int &)
Temporarily disable MediaChangeReport Sometimes helpful to suppress interactive messages connected to...
ScopedDisableMediaChangeReport(bool condition_r=true)
Disbale MediaChangeReport if condition_r is true.
Definition: ZYppImpl.cc:38
shared_ptr< callback::TempConnect< media::MediaChangeReport > > _guard
virtual void pkgGpgCheck(const UserData &userData_r=UserData())
Detail information about the result of a performed pkgGpgCheck.
virtual void problemDeltaApply(const std::string &)
virtual void finish(Resolvable::constPtr, Error, const std::string &)
virtual void startDeltaApply(const Pathname &)
virtual void infoInCache(Resolvable::constPtr res_r, const Pathname &localfile_r)
Hint that package is available in the local cache (no download needed).
virtual Action problem(Resolvable::constPtr, Error, const std::string &)
virtual void problemDeltaDownload(const std::string &)
virtual void startDeltaDownload(const Pathname &, const ByteCount &)
virtual bool progress(int, Resolvable::constPtr)
virtual void start(Resolvable::constPtr, const Url &)
virtual Action problem(const Url &, Error, const std::string &)
virtual void start(const Url &)
virtual void failedProbe(const Url &, const std::string &)
virtual void finish(const Url &, Error, const std::string &)
virtual bool progress(const Url &, int)
virtual void successProbe(const Url &, const std::string &)
virtual void finish(const zypp::Url &, Error, const std::string &)
virtual bool progress(int)
virtual void start(const zypp::Url &)
virtual Action problem(const zypp::Url &, Error, const std::string &)
virtual void start(const ProgressData &, const RepoInfo)
virtual void finish(Repository, const std::string &, Error, const std::string &)
virtual bool progress(const ProgressData &)
virtual Action problem(Repository, Error, const std::string &)
Check for package file conflicts in commit (after download)
virtual bool start(const ProgressData &progress_r)
virtual bool result(const ProgressData &progress_r, const sat::Queue &noFilelist_r, const sat::FileConflicts &conflicts_r)
virtual bool progress(const ProgressData &progress_r, const sat::Queue &noFilelist_r)
Request to display the pre commit message of a patch.
virtual bool show(Patch::constPtr &)
Display patch->message().
Indicate execution of a patch script.
virtual bool progress(Notify, const std::string &=std::string())
Progress provides the script output.
virtual Action problem(const std::string &)
Report error.
virtual void finish()
Report success.
virtual void start(const Package::constPtr &, const Pathname &)
Start executing the script provided by package.
virtual bool progress(int, Resolvable::constPtr)
virtual Action problem(Resolvable::constPtr, Error, const std::string &, RpmLevel)
virtual void start(Resolvable::constPtr)
virtual void finish(Resolvable::constPtr, Error, const std::string &, RpmLevel)
static const UserData::ContentType contentRpmout
"rpmout/installpkg": Additional rpm output (sent immediately).
virtual bool progress(int, Pathname)
virtual void finish(Pathname, Error, const std::string &)
virtual void start(Pathname)
virtual Action problem(Pathname, Error, const std::string &)
virtual void start(Resolvable::constPtr)
virtual Action problem(Resolvable::constPtr, Error, const std::string &)
static const UserData::ContentType contentRpmout
"rpmout/removepkg": Additional rpm output (sent immediately).
virtual void finish(Resolvable::constPtr, Error, const std::string &)
virtual bool progress(int, Resolvable::constPtr)