1
/*---------------------------------------------------------------------\
3
| |__ / \ / / . \ . \ |
8
\---------------------------------------------------------------------*/
9
/** \file zypp/ZYppCallbacks.h
12
#ifndef ZYPP_ZYPPCALLBACKS_H
13
#define ZYPP_ZYPPCALLBACKS_H
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"
22
#include "zypp/ProgressData.h"
23
#include "zypp/media/MediaUserAuth.h"
25
///////////////////////////////////////////////////////////////////
27
{ /////////////////////////////////////////////////////////////////
29
///////////////////////////////////////////////////////////////////
35
///////////////////////////////////////////////////////////////////
37
struct ProgressReport : public callback::ReportBase
39
virtual void start( const ProgressData &/*task*/ )
42
virtual bool progress( const ProgressData &/*task*/ )
45
// virtual Action problem(
48
// , const std::string &/*description*/ )
51
virtual void finish( const ProgressData &/*task*/ )
56
struct ProgressReportAdaptor
59
ProgressReportAdaptor( const ProgressData::ReceiverFnc &fnc,
60
callback::SendReport<ProgressReport> &report )
67
bool operator()( const ProgressData &progress )
71
_report->start(progress);
75
_report->progress(progress);
78
value = _fnc(progress);
81
if ( progress.finalReport() )
83
_report->finish(progress);
88
ProgressData::ReceiverFnc _fnc;
89
callback::SendReport<ProgressReport> &_report;
93
////////////////////////////////////////////////////////////////////////////
97
// progress for downloading a resolvable
98
struct DownloadResolvableReport : public callback::ReportBase
101
ABORT, // abort and return error
103
IGNORE, // ignore this resolvable but continue
108
NOT_FOUND, // the requested Url was not found
110
INVALID // the downloaded file is invalid
114
Resolvable::constPtr /*resolvable_ptr*/
119
// Dowmload delta rpm:
120
// - path below url reported on start()
121
// - expected download size (0 if unknown)
122
// - download is interruptable
123
// - problems are just informal
124
virtual void startDeltaDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
127
virtual bool progressDeltaDownload( int /*value*/ )
130
virtual void problemDeltaDownload( const std::string &/*description*/ )
133
virtual void finishDeltaDownload()
137
// - local path of downloaded delta
138
// - aplpy is not interruptable
139
// - problems are just informal
140
virtual void startDeltaApply( const Pathname & /*filename*/ )
143
virtual void progressDeltaApply( int /*value*/ )
146
virtual void problemDeltaApply( const std::string &/*description*/ )
149
virtual void finishDeltaApply()
152
// Dowmload patch rpm:
153
// - path below url reported on start()
154
// - expected download size (0 if unknown)
155
// - download is interruptable
156
virtual void startPatchDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
159
virtual bool progressPatchDownload( int /*value*/ )
162
virtual void problemPatchDownload( const std::string &/*description*/ )
165
virtual void finishPatchDownload()
169
// return false if the download should be aborted right now
170
virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable_ptr*/)
173
virtual Action problem(
174
Resolvable::constPtr /*resolvable_ptr*/
176
, const std::string &/*description*/
179
virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
181
, const std::string &/*reason*/
185
// progress for probing a source
186
struct ProbeRepoReport : public callback::ReportBase
189
ABORT, // abort and return error
195
NOT_FOUND, // the requested Url was not found
197
INVALID, // th source is invalid
201
virtual void start(const Url &/*url*/) {}
202
virtual void failedProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
203
virtual void successProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
204
virtual void finish(const Url &/*url*/, Error /*error*/, const std::string &/*reason*/ ) {}
206
virtual bool progress(const Url &/*url*/, int /*value*/)
209
virtual Action problem( const Url &/*url*/, Error /*error*/, const std::string &/*description*/ ) { return ABORT; }
212
struct RepoCreateReport : public callback::ReportBase
215
ABORT, // abort and return error
217
IGNORE // skip refresh, ignore failed refresh
222
NOT_FOUND, // the requested Url was not found
225
INVALID, // th source is invali
229
virtual void start( const zypp::Url &/*url*/ ) {}
230
virtual bool progress( int /*value*/ )
233
virtual Action problem(
234
const zypp::Url &/*url*/
236
, const std::string &/*description*/ )
240
const zypp::Url &/*url*/
242
, const std::string &/*reason*/ )
246
struct RepoReport : public callback::ReportBase
249
ABORT, // abort and return error
251
IGNORE // skip refresh, ignore failed refresh
256
NOT_FOUND, // the requested Url was not found
258
INVALID // th source is invalid
261
virtual void start( const ProgressData &/*task*/, const RepoInfo /*repo*/ ) {}
262
virtual bool progress( const ProgressData &/*task*/ )
265
virtual Action problem(
266
Repository /*source*/
268
, const std::string &/*description*/ )
272
Repository /*source*/
273
, const std::string &/*task*/
275
, const std::string &/*reason*/ )
280
/////////////////////////////////////////////////////////////////
281
} // namespace source
282
///////////////////////////////////////////////////////////////////
284
///////////////////////////////////////////////////////////////////
287
// media change request callback
288
struct MediaChangeReport : public callback::ReportBase
291
ABORT, // abort and return error
293
IGNORE, // ignore this media in future, not available anymore
294
IGNORE_ID, // ignore wrong medium id
295
CHANGE_URL, // change media URL
296
EJECT // eject the medium
301
NOT_FOUND, // the medie not found at all
302
IO, // error accessing the media
303
INVALID, // media is broken
304
WRONG, // wrong media, need a different one
305
IO_SOFT /**< IO error which can happen on worse connection like timeout exceed */
310
* \param url in: url for which the media is requested,
311
* out: url to use instead of the original one
312
* \param mediumNr requested medium number
313
* \param label label of requested medium
314
* \param error type of error from \ref Error enum
315
* \param description error message (media not desired or error foo occured)
316
* \param devices list of the available devices (for eject)
317
* \param dev_current in: index of the currently used device in the \a devices list
318
* out: index of the devices to be ejected in the \a devices list
319
* \return \ref Action (ABORT by default)
321
virtual Action requestMedia(
322
Url & /* url (I/O parameter) */
323
, unsigned /*mediumNr*/
324
, const std::string & /* label */
326
, const std::string & /*description*/
327
, const std::vector<std::string> & /* devices */
328
, unsigned int & /* dev_current (I/O param) */
332
// progress for downloading a file
333
struct DownloadProgressReport : public callback::ReportBase
336
ABORT, // abort and return error
338
IGNORE // ignore the failure
343
NOT_FOUND, // the requested Url was not found
345
ACCESS_DENIED, // user authent. failed while accessing restricted file
349
virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
354
* \param value Percentage value.
355
* \param file File URI.
356
* \param dbps_avg Average download rate so far. -1 if unknown.
357
* \param dbps_current Current download (cca last 1 sec). -1 if unknown.
359
virtual bool progress(int /*value*/, const Url &/*file*/,
360
double dbps_avg = -1,
361
double dbps_current = -1)
364
virtual Action problem(
367
, const std::string &/*description*/
373
, const std::string &/*reason*/
377
// authentication issues report
378
struct AuthenticationReport : public callback::ReportBase
381
* Prompt for authentication data.
383
* \param url URL which required the authentication
384
* \param msg prompt text
385
* \param auth_data input/output object for handling authentication
386
* data. As an input parameter auth_data can be prefilled with
387
* username (from previous try) or auth_type (available
388
* authentication methods aquired from server (only CurlAuthData)).
389
* As an output parameter it serves for sending username, pasword
390
* or other special data (derived AuthData objects).
391
* \return true if user chooses to continue with authentication,
394
virtual bool prompt(const Url & /* url */,
395
const std::string & /* msg */,
396
AuthData & /* auth_data */)
402
/////////////////////////////////////////////////////////////////
404
///////////////////////////////////////////////////////////////////
406
///////////////////////////////////////////////////////////////////
409
/** Request to display the pre commit message of a patch. */
410
struct PatchMessageReport : public callback::ReportBase
412
/** Display \c patch->message().
413
* Return \c true to continue, \c false to abort commit.
415
virtual bool show( Patch::constPtr & /*patch*/ )
419
/** Indicate execution of a patch script. This is a sort of
420
* \c %post script shipped by a package and to be executed
421
* after the package was installed.
423
struct PatchScriptReport : public callback::ReportBase
425
enum Notify { OUTPUT, PING };
427
ABORT, // abort commit and return error
428
RETRY, // (re)try to execute this script
429
IGNORE // ignore any failue and continue
432
/** Start executing the script provided by package.
434
virtual void start( const Package::constPtr & /*package*/,
435
const Pathname & /*script path*/ )
437
/** Progress provides the script output. If the script is quiet,
438
* from time to time still-alive pings are sent to the ui. Returning \c FALSE
439
* aborts script execution.
441
virtual bool progress( Notify /*OUTPUT or PING*/,
442
const std::string & /*output*/ = std::string() )
445
virtual Action problem( const std::string & /*description*/ )
447
/** Report success. */
448
virtual void finish()
452
///////////////////////////////////////////////////////////////////
453
/// \class FindFileConflictstReport
454
/// \brief Check for package file conflicts in commit (after download)
456
/// File conflict check requires that all packages are downloaded and
457
/// now available in the cache (need to access the filelists). Missing
458
/// packages are omitted from check and their number is reported in
459
/// \a noFilelist_r. This usually happens if download mode 'as-needed'
461
///////////////////////////////////////////////////////////////////
462
struct FindFileConflictstReport : public callback::ReportBase
465
* \param progress_r Progress counter for packages to check.
466
* \return \c true to continue, \c false upon user abort request.
468
virtual bool start( const ProgressData & progress_r )
472
* \param progress_r Progress counter for packages to check.
473
* \param noFilelist_r Queue of so far skipped solvables (no filelist/not yet downloaded).
474
* \return \c true to continue, \c false upon user abort request.
476
virtual bool progress( const ProgressData & progress_r, const sat::Queue & noFilelist_r )
480
* \param progress_r Progress counter for packages to check.
481
* \param noFilelist_r Queue of skipped solvables (no filelist/not yet downloaded).
482
* \param conflicts_r File conflits queue.
483
* \return \c true to continue, \c false upon user abort request.
485
virtual bool result( const ProgressData & progress_r, const sat::Queue & noFilelist_r, const sat::FileConflicts & conflicts_r )
490
///////////////////////////////////////////////////////////////////
494
// progress for installing a resolvable
495
struct InstallResolvableReport : public callback::ReportBase
498
ABORT, // abort and return error
500
IGNORE // ignore the failure
505
NOT_FOUND, // the requested Url was not found
507
INVALID // th resolvable is invalid
510
// the level of RPM pushing
511
/** \deprecated We fortunately no longer do 3 attempts. */
515
RPM_NODEPS_FORCE //!< only this one used
519
Resolvable::constPtr /*resolvable*/
522
virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
525
virtual Action problem(
526
Resolvable::constPtr /*resolvable*/
528
, const std::string &/*description*/
533
Resolvable::constPtr /*resolvable*/
535
, const std::string &/*reason*/
540
// progress for removing a resolvable
541
struct RemoveResolvableReport : public callback::ReportBase
544
ABORT, // abort and return error
546
IGNORE // ignore the failure
551
NOT_FOUND, // the requested Url was not found
553
INVALID // th resolvable is invalid
557
Resolvable::constPtr /*resolvable*/
560
virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
563
virtual Action problem(
564
Resolvable::constPtr /*resolvable*/
566
, const std::string &/*description*/
570
Resolvable::constPtr /*resolvable*/
572
, const std::string &/*reason*/
576
// progress for rebuilding the database
577
struct RebuildDBReport : public callback::ReportBase
580
ABORT, // abort and return error
582
IGNORE // ignore the failure
587
FAILED // failed to rebuild
590
virtual void start(Pathname /*path*/) {}
592
virtual bool progress(int /*value*/, Pathname /*path*/)
595
virtual Action problem(
598
, const std::string &/*description*/
604
, const std::string &/*reason*/
608
// progress for converting the database
609
struct ConvertDBReport : public callback::ReportBase
612
ABORT, // abort and return error
614
IGNORE // ignore the failure
619
FAILED // conversion failed
626
virtual bool progress(int /*value*/, Pathname /*path*/)
629
virtual Action problem(
632
, const std::string &/*description*/
638
, const std::string &/*reason*/
642
/////////////////////////////////////////////////////////////////
644
///////////////////////////////////////////////////////////////////
646
/////////////////////////////////////////////////////////////////
647
} // namespace target
648
///////////////////////////////////////////////////////////////////
655
* Callback for cleaning locks which doesn't lock anything in pool.
658
struct CleanEmptyLocksReport : public callback::ReportBase
661
* action performed by cleaning api to specific lock
664
ABORT, /**< abort and return error */
665
DELETE, /**< delete empty lock */
666
IGNORE /**< skip empty lock */
673
NO_ERROR, /**< no problem */
674
ABORTED /** cleaning aborted by user */
678
* cleaning is started
684
* progress of cleaning specifies in percents
685
* \return if continue
687
virtual bool progress(int /*value*/)
691
* When find empty lock ask what to do with it
694
virtual Action execute(
695
const PoolQuery& /*error*/
708
* this callback handles merging old locks with newly added or removed
710
struct SavingLocksReport : public callback::ReportBase
713
* action for old lock which is in conflict
717
ABORT, /**< abort and return error*/
718
DELETE, /**< delete conflicted lock */
719
IGNORE /**< skip conflict lock */
726
NO_ERROR, /**< no problem */
727
ABORTED /**< cleaning aborted by user */
731
* type of conflict of old and new lock
734
SAME_RESULTS, /**< locks lock same item in pool but his parameters is different */
735
INTERSECT /**< locks lock some file and unlocking lock unlock only part
736
* of iti, so removing old lock can unlock more items in pool */
739
virtual void start() {}
743
* \return if continue
745
virtual bool progress()
749
* When user unlock something which is locked by non-identical query
751
virtual Action conflict(
752
const PoolQuery&, /**< problematic query*/
762
/////////////////////////////////////////////////////////////////
764
///////////////////////////////////////////////////////////////////
766
#endif // ZYPP_ZYPPCALLBACKS_H