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/Repository.h"
00018 #include "zypp/Pathname.h"
00019 #include "zypp/Message.h"
00020 #include "zypp/Url.h"
00021 #include "zypp/ProgressData.h"
00022 #include "zypp/media/MediaUserAuth.h"
00023
00025 namespace zypp
00026 {
00027
00028 struct ProgressReport : public callback::ReportBase
00029 {
00030 virtual void start( const ProgressData & )
00031 {}
00032
00033 virtual bool progress( const ProgressData & )
00034 { return true; }
00035
00036
00037
00038
00039
00040
00041
00042 virtual void finish( const ProgressData & )
00043 {}
00044
00045 };
00046
00047 struct ProgressReportAdaptor
00048 {
00049
00050 ProgressReportAdaptor( const ProgressData::ReceiverFnc &fnc,
00051 callback::SendReport<ProgressReport> &report )
00052 : _fnc(fnc)
00053 , _report(report)
00054 , _first(true)
00055 {
00056 }
00057
00058 bool operator()( const ProgressData &progress )
00059 {
00060 if ( _first )
00061 {
00062 _report->start(progress);
00063 _first = false;
00064 }
00065
00066 _report->progress(progress);
00067 bool value = true;
00068 if ( _fnc )
00069 value = _fnc(progress);
00070
00071
00072 if ( progress.finalReport() )
00073 {
00074 _report->finish(progress);
00075 }
00076 return value;
00077 }
00078
00079 ProgressData::ReceiverFnc _fnc;
00080 callback::SendReport<ProgressReport> &_report;
00081 bool _first;
00082 };
00083
00085
00086 namespace repo
00087 {
00088
00089 struct DownloadResolvableReport : public callback::ReportBase
00090 {
00091 enum Action {
00092 ABORT,
00093 RETRY,
00094 IGNORE,
00095 };
00096
00097 enum Error {
00098 NO_ERROR,
00099 NOT_FOUND,
00100 IO,
00101 INVALID
00102 };
00103
00104 virtual void start(
00105 Resolvable::constPtr
00106 , const Url &
00107 ) {}
00108
00109
00110
00111
00112
00113
00114
00115 virtual void startDeltaDownload( const Pathname & , const ByteCount & )
00116 {}
00117
00118 virtual bool progressDeltaDownload( int )
00119 { return true; }
00120
00121 virtual void problemDeltaDownload( const std::string & )
00122 {}
00123
00124 virtual void finishDeltaDownload()
00125 {}
00126
00127
00128
00129
00130
00131 virtual void startDeltaApply( const Pathname & )
00132 {}
00133
00134 virtual void progressDeltaApply( int )
00135 {}
00136
00137 virtual void problemDeltaApply( const std::string & )
00138 {}
00139
00140 virtual void finishDeltaApply()
00141 {}
00142
00143
00144
00145
00146
00147 virtual void startPatchDownload( const Pathname & , const ByteCount & )
00148 {}
00149
00150 virtual bool progressPatchDownload( int )
00151 { return true; }
00152
00153 virtual void problemPatchDownload( const std::string & )
00154 {}
00155
00156 virtual void finishPatchDownload()
00157 {}
00158
00159
00160
00161 virtual bool progress(int , Resolvable::constPtr )
00162 { return true; }
00163
00164 virtual Action problem(
00165 Resolvable::constPtr
00166 , Error
00167 , const std::string &
00168 ) { return ABORT; }
00169
00170 virtual void finish(Resolvable::constPtr
00171 , Error
00172 , const std::string &
00173 ) {}
00174 };
00175
00176
00177 struct ProbeRepoReport : public callback::ReportBase
00178 {
00179 enum Action {
00180 ABORT,
00181 RETRY
00182 };
00183
00184 enum Error {
00185 NO_ERROR,
00186 NOT_FOUND,
00187 IO,
00188 INVALID,
00189 UNKNOWN
00190 };
00191
00192 virtual void start(const Url &) {}
00193 virtual void failedProbe( const Url &, const std::string & ) {}
00194 virtual void successProbe( const Url &, const std::string & ) {}
00195 virtual void finish(const Url &, Error , const std::string & ) {}
00196
00197 virtual bool progress(const Url &, int )
00198 { return true; }
00199
00200 virtual Action problem( const Url &, Error , const std::string & ) { return ABORT; }
00201 };
00202
00203 struct RepoCreateReport : public callback::ReportBase
00204 {
00205 enum Action {
00206 ABORT,
00207 RETRY,
00208 IGNORE
00209 };
00210
00211 enum Error {
00212 NO_ERROR,
00213 NOT_FOUND,
00214 IO,
00215 REJECTED,
00216 INVALID,
00217 UNKNOWN
00218 };
00219
00220 virtual void start( const zypp::Url & ) {}
00221 virtual bool progress( int )
00222 { return true; }
00223
00224 virtual Action problem(
00225 const zypp::Url &
00226 , Error
00227 , const std::string & )
00228 { return ABORT; }
00229
00230 virtual void finish(
00231 const zypp::Url &
00232 , Error
00233 , const std::string & )
00234 {}
00235 };
00236
00237 struct RepoReport : public callback::ReportBase
00238 {
00239 enum Action {
00240 ABORT,
00241 RETRY,
00242 IGNORE
00243 };
00244
00245 enum Error {
00246 NO_ERROR,
00247 NOT_FOUND,
00248 IO,
00249 INVALID
00250 };
00251
00252 virtual void start( const ProgressData &, const RepoInfo ) {}
00253 virtual bool progress( const ProgressData & )
00254 { return true; }
00255
00256 virtual Action problem(
00257 Repository
00258 , Error
00259 , const std::string & )
00260 { return ABORT; }
00261
00262 virtual void finish(
00263 Repository
00264 , const std::string &
00265 , Error
00266 , const std::string & )
00267 {}
00268 };
00269
00270
00272 }
00274
00276 namespace media
00277 {
00278
00279 struct MediaChangeReport : public callback::ReportBase
00280 {
00281 enum Action {
00282 ABORT,
00283 RETRY,
00284 IGNORE,
00285 IGNORE_ID,
00286 CHANGE_URL,
00287 EJECT
00288 };
00289
00290 enum Error {
00291 NO_ERROR,
00292 NOT_FOUND,
00293 IO,
00294 INVALID,
00295 WRONG
00296 };
00297
00298 virtual Action requestMedia(
00299 Url &
00300 , unsigned
00301 , Error
00302 , const std::string &
00303 ) { return ABORT; }
00304 };
00305
00306
00307 struct DownloadProgressReport : public callback::ReportBase
00308 {
00309 enum Action {
00310 ABORT,
00311 RETRY,
00312 IGNORE
00313 };
00314
00315 enum Error {
00316 NO_ERROR,
00317 NOT_FOUND,
00318 IO,
00319 ACCESS_DENIED,
00320 ERROR
00321 };
00322
00323 virtual void start( const Url &, Pathname ) {}
00324
00325 virtual bool progress(int , const Url &)
00326 { return true; }
00327
00328 virtual Action problem(
00329 const Url &
00330 , Error
00331 , const std::string &
00332 ) { return ABORT; }
00333
00334 virtual void finish(
00335 const Url &
00336 , Error
00337 , const std::string &
00338 ) {}
00339 };
00340
00341
00342 struct AuthenticationReport : public callback::ReportBase
00343 {
00358 virtual bool prompt(const Url & ,
00359 const std::string & ,
00360 AuthData & )
00361 {
00362 return false;
00363 }
00364 };
00365
00367 }
00369
00371 namespace target
00372 {
00373
00374
00375 struct MessageResolvableReport : public callback::ReportBase
00376 {
00377 virtual void show(
00378 Message::constPtr
00379 ) {}
00380 };
00381
00382
00383 struct ScriptResolvableReport : public callback::ReportBase
00384 {
00385 enum Task { DO, UNDO };
00386 enum Notify { OUTPUT, PING };
00387
00389 virtual void start( const Resolvable::constPtr & ,
00390 const Pathname & ,
00391 Task )
00392 {}
00397 virtual bool progress( Notify , const std::string & = std::string() )
00398 { return true; }
00400 virtual void problem( const std::string & )
00401 {}
00403 virtual void finish()
00404 {}
00405 };
00406
00408 namespace rpm
00409 {
00410
00411
00412 struct InstallResolvableReport : public callback::ReportBase
00413 {
00414 enum Action {
00415 ABORT,
00416 RETRY,
00417 IGNORE
00418 };
00419
00420 enum Error {
00421 NO_ERROR,
00422 NOT_FOUND,
00423 IO,
00424 INVALID
00425 };
00426
00427
00429 enum RpmLevel {
00430 RPM,
00431 RPM_NODEPS,
00432 RPM_NODEPS_FORCE
00433 };
00434
00435 virtual void start(
00436 Resolvable::constPtr
00437 ) {}
00438
00439 virtual bool progress(int , Resolvable::constPtr )
00440 { return true; }
00441
00442 virtual Action problem(
00443 Resolvable::constPtr
00444 , Error
00445 , const std::string &
00446 , RpmLevel
00447 ) { return ABORT; }
00448
00449 virtual void finish(
00450 Resolvable::constPtr
00451 , Error
00452 , const std::string &
00453 , RpmLevel
00454 ) {}
00455 };
00456
00457
00458 struct RemoveResolvableReport : public callback::ReportBase
00459 {
00460 enum Action {
00461 ABORT,
00462 RETRY,
00463 IGNORE
00464 };
00465
00466 enum Error {
00467 NO_ERROR,
00468 NOT_FOUND,
00469 IO,
00470 INVALID
00471 };
00472
00473 virtual void start(
00474 Resolvable::constPtr
00475 ) {}
00476
00477 virtual bool progress(int , Resolvable::constPtr )
00478 { return true; }
00479
00480 virtual Action problem(
00481 Resolvable::constPtr
00482 , Error
00483 , const std::string &
00484 ) { return ABORT; }
00485
00486 virtual void finish(
00487 Resolvable::constPtr
00488 , Error
00489 , const std::string &
00490 ) {}
00491 };
00492
00493
00494 struct RebuildDBReport : public callback::ReportBase
00495 {
00496 enum Action {
00497 ABORT,
00498 RETRY,
00499 IGNORE
00500 };
00501
00502 enum Error {
00503 NO_ERROR,
00504 FAILED
00505 };
00506
00507 virtual void start(Pathname ) {}
00508
00509 virtual bool progress(int , Pathname )
00510 { return true; }
00511
00512 virtual Action problem(
00513 Pathname
00514 , Error
00515 , const std::string &
00516 ) { return ABORT; }
00517
00518 virtual void finish(
00519 Pathname
00520 , Error
00521 , const std::string &
00522 ) {}
00523 };
00524
00525
00526 struct ConvertDBReport : public callback::ReportBase
00527 {
00528 enum Action {
00529 ABORT,
00530 RETRY,
00531 IGNORE
00532 };
00533
00534 enum Error {
00535 NO_ERROR,
00536 FAILED
00537 };
00538
00539 virtual void start(
00540 Pathname
00541 ) {}
00542
00543 virtual bool progress(int , Pathname )
00544 { return true; }
00545
00546 virtual Action problem(
00547 Pathname
00548 , Error
00549 , const std::string &
00550 ) { return ABORT; }
00551
00552 virtual void finish(
00553 Pathname
00554 , Error
00555 , const std::string &
00556 ) {}
00557 };
00558
00559
00560 struct ScanDBReport : public callback::ReportBase
00561 {
00562 enum Action {
00563 ABORT,
00564 RETRY,
00565 IGNORE
00566 };
00567
00568 enum Error {
00569 NO_ERROR,
00570 FAILED
00571 };
00572
00573 virtual void start(
00574 ) {}
00575
00576 virtual bool progress(int )
00577 { return true; }
00578
00579 virtual Action problem(
00580 Error
00581 , const std::string &
00582 ) { return ABORT; }
00583
00584 virtual void finish(
00585 Error
00586 , const std::string &
00587 ) {}
00588 };
00589
00591 }
00593
00595 }
00597
00599 }
00601
00602 #endif // ZYPP_ZYPPCALLBACKS_H