00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_ZYPPCALLBACKS_H
00013 #define ZYPP_ZYPPCALLBACKS_H
00014
00015 #include "zypp/Callback.h"
00016 #include "zypp/Resolvable.h"
00017 #include "zypp/RepoInfo.h"
00018 #include "zypp/Pathname.h"
00019 #include "zypp/Package.h"
00020 #include "zypp/Patch.h"
00021 #include "zypp/Url.h"
00022 #include "zypp/ProgressData.h"
00023 #include "zypp/media/MediaUserAuth.h"
00024
00026 namespace zypp
00027 {
00028
00029 struct ProgressReport : public callback::ReportBase
00030 {
00031 virtual void start( const ProgressData & )
00032 {}
00033
00034 virtual bool progress( const ProgressData & )
00035 { return true; }
00036
00037
00038
00039
00040
00041
00042
00043 virtual void finish( const ProgressData & )
00044 {}
00045
00046 };
00047
00048 struct ProgressReportAdaptor
00049 {
00050
00051 ProgressReportAdaptor( const ProgressData::ReceiverFnc &fnc,
00052 callback::SendReport<ProgressReport> &report )
00053 : _fnc(fnc)
00054 , _report(report)
00055 , _first(true)
00056 {
00057 }
00058
00059 bool operator()( const ProgressData &progress )
00060 {
00061 if ( _first )
00062 {
00063 _report->start(progress);
00064 _first = false;
00065 }
00066
00067 _report->progress(progress);
00068 bool value = true;
00069 if ( _fnc )
00070 value = _fnc(progress);
00071
00072
00073 if ( progress.finalReport() )
00074 {
00075 _report->finish(progress);
00076 }
00077 return value;
00078 }
00079
00080 ProgressData::ReceiverFnc _fnc;
00081 callback::SendReport<ProgressReport> &_report;
00082 bool _first;
00083 };
00084
00086
00087 namespace repo
00088 {
00089
00090 struct DownloadResolvableReport : public callback::ReportBase
00091 {
00092 enum Action {
00093 ABORT,
00094 RETRY,
00095 IGNORE,
00096 };
00097
00098 enum Error {
00099 NO_ERROR,
00100 NOT_FOUND,
00101 IO,
00102 INVALID
00103 };
00104
00105 virtual void start(
00106 Resolvable::constPtr
00107 , const Url &
00108 ) {}
00109
00110
00111
00112
00113
00114
00115
00116 virtual void startDeltaDownload( const Pathname & , const ByteCount & )
00117 {}
00118
00119 virtual bool progressDeltaDownload( int )
00120 { return true; }
00121
00122 virtual void problemDeltaDownload( const std::string & )
00123 {}
00124
00125 virtual void finishDeltaDownload()
00126 {}
00127
00128
00129
00130
00131
00132 virtual void startDeltaApply( const Pathname & )
00133 {}
00134
00135 virtual void progressDeltaApply( int )
00136 {}
00137
00138 virtual void problemDeltaApply( const std::string & )
00139 {}
00140
00141 virtual void finishDeltaApply()
00142 {}
00143
00144
00145
00146
00147
00148 virtual void startPatchDownload( const Pathname & , const ByteCount & )
00149 {}
00150
00151 virtual bool progressPatchDownload( int )
00152 { return true; }
00153
00154 virtual void problemPatchDownload( const std::string & )
00155 {}
00156
00157 virtual void finishPatchDownload()
00158 {}
00159
00160
00161
00162 virtual bool progress(int , Resolvable::constPtr )
00163 { return true; }
00164
00165 virtual Action problem(
00166 Resolvable::constPtr
00167 , Error
00168 , const std::string &
00169 ) { return ABORT; }
00170
00171 virtual void finish(Resolvable::constPtr
00172 , Error
00173 , const std::string &
00174 ) {}
00175 };
00176
00177
00178 struct ProbeRepoReport : public callback::ReportBase
00179 {
00180 enum Action {
00181 ABORT,
00182 RETRY
00183 };
00184
00185 enum Error {
00186 NO_ERROR,
00187 NOT_FOUND,
00188 IO,
00189 INVALID,
00190 UNKNOWN
00191 };
00192
00193 virtual void start(const Url &) {}
00194 virtual void failedProbe( const Url &, const std::string & ) {}
00195 virtual void successProbe( const Url &, const std::string & ) {}
00196 virtual void finish(const Url &, Error , const std::string & ) {}
00197
00198 virtual bool progress(const Url &, int )
00199 { return true; }
00200
00201 virtual Action problem( const Url &, Error , const std::string & ) { return ABORT; }
00202 };
00203
00204 struct RepoCreateReport : public callback::ReportBase
00205 {
00206 enum Action {
00207 ABORT,
00208 RETRY,
00209 IGNORE
00210 };
00211
00212 enum Error {
00213 NO_ERROR,
00214 NOT_FOUND,
00215 IO,
00216 REJECTED,
00217 INVALID,
00218 UNKNOWN
00219 };
00220
00221 virtual void start( const zypp::Url & ) {}
00222 virtual bool progress( int )
00223 { return true; }
00224
00225 virtual Action problem(
00226 const zypp::Url &
00227 , Error
00228 , const std::string & )
00229 { return ABORT; }
00230
00231 virtual void finish(
00232 const zypp::Url &
00233 , Error
00234 , const std::string & )
00235 {}
00236 };
00237
00238 struct RepoReport : public callback::ReportBase
00239 {
00240 enum Action {
00241 ABORT,
00242 RETRY,
00243 IGNORE
00244 };
00245
00246 enum Error {
00247 NO_ERROR,
00248 NOT_FOUND,
00249 IO,
00250 INVALID
00251 };
00252
00253 virtual void start( const ProgressData &, const RepoInfo ) {}
00254 virtual bool progress( const ProgressData & )
00255 { return true; }
00256
00257 virtual Action problem(
00258 Repository
00259 , Error
00260 , const std::string & )
00261 { return ABORT; }
00262
00263 virtual void finish(
00264 Repository
00265 , const std::string &
00266 , Error
00267 , const std::string & )
00268 {}
00269 };
00270
00271
00273 }
00275
00277 namespace media
00278 {
00279
00280 struct MediaChangeReport : public callback::ReportBase
00281 {
00282 enum Action {
00283 ABORT,
00284 RETRY,
00285 IGNORE,
00286 IGNORE_ID,
00287 CHANGE_URL,
00288 EJECT
00289 };
00290
00291 enum Error {
00292 NO_ERROR,
00293 NOT_FOUND,
00294 IO,
00295 INVALID,
00296 WRONG,
00297 IO_SOFT
00298 };
00299
00313 virtual Action requestMedia(
00314 Url &
00315 , unsigned
00316 , const std::string &
00317 , Error
00318 , const std::string &
00319 , const std::vector<std::string> &
00320 , unsigned int &
00321 ) { return ABORT; }
00322 };
00323
00324
00325 struct DownloadProgressReport : public callback::ReportBase
00326 {
00327 enum Action {
00328 ABORT,
00329 RETRY,
00330 IGNORE
00331 };
00332
00333 enum Error {
00334 NO_ERROR,
00335 NOT_FOUND,
00336 IO,
00337 ACCESS_DENIED,
00338 ERROR
00339 };
00340
00341 virtual void start( const Url &, Pathname ) {}
00342
00351 virtual bool progress(int , const Url &,
00352 double dbps_avg = -1,
00353 double dbps_current = -1)
00354 { return true; }
00355
00356 virtual Action problem(
00357 const Url &
00358 , Error
00359 , const std::string &
00360 ) { return ABORT; }
00361
00362 virtual void finish(
00363 const Url &
00364 , Error
00365 , const std::string &
00366 ) {}
00367 };
00368
00369
00370 struct AuthenticationReport : public callback::ReportBase
00371 {
00386 virtual bool prompt(const Url & ,
00387 const std::string & ,
00388 AuthData & )
00389 {
00390 return false;
00391 }
00392 };
00393
00395 }
00397
00399 namespace target
00400 {
00402 struct PatchMessageReport : public callback::ReportBase
00403 {
00407 virtual bool show( Patch::constPtr & )
00408 { return true; }
00409 };
00410
00415 struct PatchScriptReport : public callback::ReportBase
00416 {
00417 enum Notify { OUTPUT, PING };
00418 enum Action {
00419 ABORT,
00420 RETRY,
00421 IGNORE
00422 };
00423
00426 virtual void start( const Package::constPtr & ,
00427 const Pathname & )
00428 {}
00433 virtual bool progress( Notify ,
00434 const std::string & = std::string() )
00435 { return true; }
00437 virtual Action problem( const std::string & )
00438 { return ABORT; }
00440 virtual void finish()
00441 {}
00442 };
00443
00445 namespace rpm
00446 {
00447
00448
00449 struct InstallResolvableReport : public callback::ReportBase
00450 {
00451 enum Action {
00452 ABORT,
00453 RETRY,
00454 IGNORE
00455 };
00456
00457 enum Error {
00458 NO_ERROR,
00459 NOT_FOUND,
00460 IO,
00461 INVALID
00462 };
00463
00464
00466 enum RpmLevel {
00467 RPM,
00468 RPM_NODEPS,
00469 RPM_NODEPS_FORCE
00470 };
00471
00472 virtual void start(
00473 Resolvable::constPtr
00474 ) {}
00475
00476 virtual bool progress(int , Resolvable::constPtr )
00477 { return true; }
00478
00479 virtual Action problem(
00480 Resolvable::constPtr
00481 , Error
00482 , const std::string &
00483 , RpmLevel
00484 ) { return ABORT; }
00485
00486 virtual void finish(
00487 Resolvable::constPtr
00488 , Error
00489 , const std::string &
00490 , RpmLevel
00491 ) {}
00492 };
00493
00494
00495 struct RemoveResolvableReport : public callback::ReportBase
00496 {
00497 enum Action {
00498 ABORT,
00499 RETRY,
00500 IGNORE
00501 };
00502
00503 enum Error {
00504 NO_ERROR,
00505 NOT_FOUND,
00506 IO,
00507 INVALID
00508 };
00509
00510 virtual void start(
00511 Resolvable::constPtr
00512 ) {}
00513
00514 virtual bool progress(int , Resolvable::constPtr )
00515 { return true; }
00516
00517 virtual Action problem(
00518 Resolvable::constPtr
00519 , Error
00520 , const std::string &
00521 ) { return ABORT; }
00522
00523 virtual void finish(
00524 Resolvable::constPtr
00525 , Error
00526 , const std::string &
00527 ) {}
00528 };
00529
00530
00531 struct RebuildDBReport : public callback::ReportBase
00532 {
00533 enum Action {
00534 ABORT,
00535 RETRY,
00536 IGNORE
00537 };
00538
00539 enum Error {
00540 NO_ERROR,
00541 FAILED
00542 };
00543
00544 virtual void start(Pathname ) {}
00545
00546 virtual bool progress(int , Pathname )
00547 { return true; }
00548
00549 virtual Action problem(
00550 Pathname
00551 , Error
00552 , const std::string &
00553 ) { return ABORT; }
00554
00555 virtual void finish(
00556 Pathname
00557 , Error
00558 , const std::string &
00559 ) {}
00560 };
00561
00562
00563 struct ConvertDBReport : public callback::ReportBase
00564 {
00565 enum Action {
00566 ABORT,
00567 RETRY,
00568 IGNORE
00569 };
00570
00571 enum Error {
00572 NO_ERROR,
00573 FAILED
00574 };
00575
00576 virtual void start(
00577 Pathname
00578 ) {}
00579
00580 virtual bool progress(int , Pathname )
00581 { return true; }
00582
00583 virtual Action problem(
00584 Pathname
00585 , Error
00586 , const std::string &
00587 ) { return ABORT; }
00588
00589 virtual void finish(
00590 Pathname
00591 , Error
00592 , const std::string &
00593 ) {}
00594 };
00595
00597 }
00599
00601 }
00603
00604 class PoolQuery;
00605
00612 struct CleanEmptyLocksReport : public callback::ReportBase
00613 {
00617 enum Action {
00618 ABORT,
00619 DELETE,
00620 IGNORE
00621 };
00622
00626 enum Error {
00627 NO_ERROR,
00628 ABORTED
00629 };
00630
00634 virtual void start(
00635 ) {}
00636
00641 virtual bool progress(int )
00642 { return true; }
00643
00648 virtual Action execute(
00649 const PoolQuery&
00650 ) { return DELETE; }
00651
00655 virtual void finish(
00656 Error
00657 ) {}
00658
00659 };
00660
00664 struct SavingLocksReport : public callback::ReportBase
00665 {
00670 enum Action {
00671 ABORT,
00672 DELETE,
00673 IGNORE
00674 };
00675
00679 enum Error {
00680 NO_ERROR,
00681 ABORTED
00682 };
00683
00687 enum ConflictState{
00688 SAME_RESULTS,
00689 INTERSECT
00691 };
00692
00693 virtual void start() {}
00694
00699 virtual bool progress()
00700 { return true; }
00701
00705 virtual Action conflict(
00706 const PoolQuery&,
00707 ConflictState
00708 ) { return DELETE; }
00709
00710 virtual void finish(
00711 Error
00712 ) {}
00713 };
00714
00715
00717 }
00719
00720 #endif // ZYPP_ZYPPCALLBACKS_H