ZYppCallbacks.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
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/Source.h"
00018 #include "zypp/Pathname.h"
00019 #include "zypp/Message.h"
00020 #include "zypp/Url.h"
00021 
00023 namespace zypp
00024 { 
00025   namespace source
00026   {
00027     // progress for downloading a resolvable
00028     struct DownloadResolvableReport : public callback::ReportBase
00029     {
00030       enum Action {
00031         ABORT,  // abort and return error
00032         RETRY,  // retry
00033         IGNORE, // ignore this resolvable but continue
00034       };
00035 
00036       enum Error {
00037         NO_ERROR,
00038         NOT_FOUND,      // the requested Url was not found
00039         IO,             // IO error
00040         INVALID         // the downloaded file is invalid
00041       };
00042 
00043       virtual void start(
00044         Resolvable::constPtr /*resolvable_ptr*/
00045         , const Url &/*url*/
00046       ) {}
00047 
00048 
00049       // Dowmload delta rpm:
00050       // - path below url reported on start()
00051       // - expected download size (0 if unknown)
00052       // - download is interruptable
00053       // - problems are just informal
00054       virtual void startDeltaDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
00055       {}
00056 
00057       virtual bool progressDeltaDownload( int /*value*/ )
00058       { return true; }
00059 
00060       virtual void problemDeltaDownload( const std::string &/*description*/ )
00061       {}
00062 
00063       virtual void finishDeltaDownload()
00064       {}
00065 
00066       // Apply delta rpm:
00067       // - local path of downloaded delta
00068       // - aplpy is not interruptable
00069       // - problems are just informal
00070       virtual void startDeltaApply( const Pathname & /*filename*/ )
00071       {}
00072 
00073       virtual void progressDeltaApply( int /*value*/ )
00074       {}
00075 
00076       virtual void problemDeltaApply( const std::string &/*description*/ )
00077       {}
00078 
00079       virtual void finishDeltaApply()
00080       {}
00081 
00082       // Dowmload patch rpm:
00083       // - path below url reported on start()
00084       // - expected download size (0 if unknown)
00085       // - download is interruptable
00086       virtual void startPatchDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
00087       {}
00088 
00089       virtual bool progressPatchDownload( int /*value*/ )
00090       { return true; }
00091 
00092       virtual void problemPatchDownload( const std::string &/*description*/ )
00093       {}
00094 
00095       virtual void finishPatchDownload()
00096       {}
00097 
00098 
00099       // return false if the download should be aborted right now
00100       virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable_ptr*/)
00101       { return true; }
00102 
00103       virtual Action problem(
00104         Resolvable::constPtr /*resolvable_ptr*/
00105         , Error /*error*/
00106         , const std::string &/*description*/
00107       ) { return ABORT; }
00108 
00109       virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
00110         , Error /*error*/
00111         , const std::string &/*reason*/
00112       ) {}
00113     };
00114 
00115     // progress for probing a source
00116     struct ProbeSourceReport : public callback::ReportBase
00117     {
00118       enum Action {
00119         ABORT,  // abort and return error
00120         RETRY   // retry
00121       };
00122 
00123       enum Error {
00124         NO_ERROR,
00125         NOT_FOUND,      // the requested Url was not found
00126         IO,             // IO error
00127         INVALID,                // th source is invalid
00128         UNKNOWN
00129       };
00130 
00131       virtual void start(const Url &/*url*/) {}
00132       virtual void failedProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
00133       virtual void successProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
00134       virtual void finish(const Url &/*url*/, Error /*error*/, const std::string &/*reason*/ ) {}
00135 
00136       virtual bool progress(const Url &/*url*/, int /*value*/)
00137       { return true; }
00138 
00139       virtual Action problem( const Url &/*url*/, Error /*error*/, const std::string &/*description*/ ) { return ABORT; }
00140     };
00141 
00142     struct SourceCreateReport : public callback::ReportBase
00143     {
00144       enum Action {
00145         ABORT,  // abort and return error
00146         RETRY,  // retry
00147         IGNORE  // skip refresh, ignore failed refresh
00148       };
00149 
00150       enum Error {
00151         NO_ERROR,
00152         NOT_FOUND,      // the requested Url was not found
00153         IO,             // IO error
00154         REJECTED,
00155         INVALID, // th source is invali
00156         UNKNOWN
00157       };
00158 
00159       virtual void start( const zypp::Url &/*url*/ ) {}
00160       virtual bool progress( int /*value*/ )
00161       { return true; }
00162 
00163       virtual Action problem(
00164           const zypp::Url &/*url*/
00165           , Error /*error*/
00166           , const std::string &/*description*/ )
00167       { return ABORT; }
00168 
00169       virtual void finish(
00170           const zypp::Url &/*url*/
00171           , Error /*error*/
00172           , const std::string &/*reason*/ )
00173       {}
00174     };
00175 
00176     struct SourceReport : public callback::ReportBase
00177     {
00178       enum Action {
00179         ABORT,  // abort and return error
00180         RETRY,  // retry
00181         IGNORE  // skip refresh, ignore failed refresh
00182       };
00183 
00184       enum Error {
00185         NO_ERROR,
00186         NOT_FOUND,      // the requested Url was not found
00187         IO,             // IO error
00188         INVALID         // th source is invalid
00189       };
00190 
00191       virtual void start( Source_Ref /*source*/, const std::string &/*task*/ ) {}
00192       virtual bool progress( int /*value*/ )
00193       { return true; }
00194 
00195       virtual Action problem(
00196           Source_Ref /*source*/
00197           , Error /*error*/
00198           , const std::string &/*description*/ )
00199       { return ABORT; }
00200 
00201       virtual void finish(
00202           Source_Ref /*source*/
00203           , const std::string &/*task*/
00204           , Error /*error*/
00205           , const std::string &/*reason*/ )
00206       {}
00207     };
00208 
00209 
00211   } // namespace source
00213 
00215   namespace media
00216   {
00217     // media change request callback
00218     struct MediaChangeReport : public callback::ReportBase
00219     {
00220       enum Action {
00221         ABORT,  // abort and return error
00222         RETRY,  // retry
00223         IGNORE, // ignore this media in future, not available anymore
00224         IGNORE_ID,      // ignore wrong medium id
00225         CHANGE_URL,     // change media URL
00226         EJECT           // eject the medium
00227       };
00228 
00229       enum Error {
00230         NO_ERROR,
00231         NOT_FOUND,  // the medie not found at all
00232         IO,     // error accessing the media
00233         INVALID, // media is broken
00234         WRONG   // wrong media, need a different one
00235       };
00236 
00237       virtual Action requestMedia(
00238         Source_Ref /*source*/
00239         , unsigned /*mediumNr*/
00240         , Error /*error*/
00241         , const std::string &/*description*/
00242       ) { return ABORT; }
00243     };
00244 
00245     // progress for downloading a file
00246     struct DownloadProgressReport : public callback::ReportBase
00247     {
00248         enum Action {
00249           ABORT,  // abort and return error
00250           RETRY,        // retry
00251           IGNORE        // ignore the failure
00252         };
00253 
00254         enum Error {
00255           NO_ERROR,
00256           NOT_FOUND,    // the requested Url was not found
00257           IO            // IO error
00258         };
00259 
00260         virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
00261 
00262         virtual bool progress(int /*value*/, const Url &/*file*/)
00263         { return true; }
00264 
00265         virtual Action problem(
00266           const Url &/*file*/
00267           , Error /*error*/
00268           , const std::string &/*description*/
00269         ) { return ABORT; }
00270 
00271         virtual void finish(
00272           const Url &/*file*/
00273           , Error /*error*/
00274           , const std::string &/*reason*/
00275         ) {}
00276     };
00277 
00279   } // namespace media
00281 
00283   namespace target
00284   {
00285 
00286     // resolvable Message
00287     struct MessageResolvableReport : public callback::ReportBase
00288     {
00289         virtual void show(
00290           Message::constPtr /*message*/
00291         ) {}
00292     };
00293 
00294     // resolvable Script
00295     struct ScriptResolvableReport : public callback::ReportBase
00296     {
00297       enum Task   { DO, UNDO };
00298       enum Notify { OUTPUT, PING };
00299 
00301       virtual void start( const Resolvable::constPtr & /*script_r*/,
00302                           const Pathname & /*path_r*/,
00303                           Task )
00304       {}
00309       virtual bool progress( Notify , const std::string & = std::string() )
00310       { return true; }
00312       virtual void problem( const std::string & /*description*/ )
00313       {}
00315       virtual void finish()
00316       {}
00317     };
00318 
00320     namespace rpm
00321     {
00322 
00323       // progress for installing a resolvable
00324       struct InstallResolvableReport : public callback::ReportBase
00325       {
00326         enum Action {
00327           ABORT,  // abort and return error
00328           RETRY,        // retry
00329           IGNORE        // ignore the failure
00330         };
00331 
00332         enum Error {
00333           NO_ERROR,
00334           NOT_FOUND,    // the requested Url was not found
00335           IO,           // IO error
00336           INVALID               // th resolvable is invalid
00337         };
00338 
00339         // the level of RPM pushing
00340         enum RpmLevel {
00341             RPM,
00342             RPM_NODEPS,
00343             RPM_NODEPS_FORCE
00344         };
00345 
00346         virtual void start(
00347           Resolvable::constPtr /*resolvable*/
00348         ) {}
00349 
00350         virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
00351         { return true; }
00352 
00353         virtual Action problem(
00354           Resolvable::constPtr /*resolvable*/
00355           , Error /*error*/
00356           , const std::string &/*description*/
00357           , RpmLevel /*level*/
00358         ) { return ABORT; }
00359 
00360         virtual void finish(
00361           Resolvable::constPtr /*resolvable*/
00362           , Error /*error*/
00363           , const std::string &/*reason*/
00364           , RpmLevel /*level*/
00365         ) {}
00366       };
00367 
00368       // progress for removing a resolvable
00369       struct RemoveResolvableReport : public callback::ReportBase
00370       {
00371         enum Action {
00372           ABORT,  // abort and return error
00373           RETRY,        // retry
00374           IGNORE        // ignore the failure
00375         };
00376 
00377         enum Error {
00378           NO_ERROR,
00379           NOT_FOUND,    // the requested Url was not found
00380           IO,           // IO error
00381           INVALID               // th resolvable is invalid
00382         };
00383 
00384         virtual void start(
00385           Resolvable::constPtr /*resolvable*/
00386         ) {}
00387 
00388         virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
00389         { return true; }
00390 
00391         virtual Action problem(
00392           Resolvable::constPtr /*resolvable*/
00393           , Error /*error*/
00394           , const std::string &/*description*/
00395         ) { return ABORT; }
00396 
00397         virtual void finish(
00398           Resolvable::constPtr /*resolvable*/
00399           , Error /*error*/
00400           , const std::string &/*reason*/
00401         ) {}
00402       };
00403 
00404       // progress for rebuilding the database
00405       struct RebuildDBReport : public callback::ReportBase
00406       {
00407         enum Action {
00408           ABORT,  // abort and return error
00409           RETRY,        // retry
00410           IGNORE        // ignore the failure
00411         };
00412 
00413         enum Error {
00414           NO_ERROR,
00415           FAILED                // failed to rebuild
00416         };
00417 
00418         virtual void start(Pathname /*path*/) {}
00419 
00420         virtual bool progress(int /*value*/, Pathname /*path*/)
00421         { return true; }
00422 
00423         virtual Action problem(
00424           Pathname /*path*/
00425          , Error /*error*/
00426          , const std::string &/*description*/
00427         ) { return ABORT; }
00428 
00429         virtual void finish(
00430           Pathname /*path*/
00431           , Error /*error*/
00432           , const std::string &/*reason*/
00433         ) {}
00434       };
00435 
00436       // progress for converting the database
00437       struct ConvertDBReport : public callback::ReportBase
00438       {
00439         enum Action {
00440           ABORT,  // abort and return error
00441           RETRY,        // retry
00442           IGNORE        // ignore the failure
00443         };
00444 
00445         enum Error {
00446           NO_ERROR,
00447           FAILED                // conversion failed
00448         };
00449 
00450         virtual void start(
00451           Pathname /*path*/
00452         ) {}
00453 
00454         virtual bool progress(int /*value*/, Pathname /*path*/)
00455         { return true; }
00456 
00457         virtual Action problem(
00458           Pathname /*path*/
00459           , Error /*error*/
00460          , const std::string &/*description*/
00461         ) { return ABORT; }
00462 
00463         virtual void finish(
00464           Pathname /*path*/
00465           , Error /*error*/
00466           , const std::string &/*reason*/
00467         ) {}
00468       };
00469 
00470        // progress for scanning the database
00471       struct ScanDBReport : public callback::ReportBase
00472       {
00473         enum Action {
00474           ABORT,  // abort and return error
00475           RETRY,        // retry
00476           IGNORE        // ignore the failure
00477         };
00478 
00479         enum Error {
00480           NO_ERROR,
00481           FAILED                // conversion failed
00482         };
00483 
00484         virtual void start(
00485         ) {}
00486 
00487         virtual bool progress(int /*value*/)
00488         { return true; }
00489 
00490         virtual Action problem(
00491           Error /*error*/
00492          , const std::string &/*description*/
00493         ) { return ABORT; }
00494 
00495         virtual void finish(
00496           Error /*error*/
00497           , const std::string &/*reason*/
00498         ) {}
00499       };
00500 
00502     } // namespace rpm
00504 
00506   } // namespace target
00508 
00510 } // namespace zypp
00512 
00513 #endif // ZYPP_ZYPPCALLBACKS_H

Generated on Tue Nov 28 16:49:35 2006 for zypp by  doxygen 1.5.0