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/Source.h"
18 #include "zypp/Pathname.h"
19 #include "zypp/Message.h"
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
27 // progress for downloading a resolvable
28 struct DownloadResolvableReport : public callback::ReportBase
31 ABORT, // abort and return error
33 IGNORE, // ignore this resolvable but continue
38 NOT_FOUND, // the requested Url was not found
40 INVALID // the downloaded file is invalid
44 Resolvable::constPtr /*resolvable_ptr*/
49 // Dowmload delta rpm:
50 // - path below url reported on start()
51 // - expected download size (0 if unknown)
52 // - download is interruptable
53 // - problems are just informal
54 virtual void startDeltaDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
57 virtual bool progressDeltaDownload( int /*value*/ )
60 virtual void problemDeltaDownload( const std::string &/*description*/ )
63 virtual void finishDeltaDownload()
67 // - local path of downloaded delta
68 // - aplpy is not interruptable
69 // - problems are just informal
70 virtual void startDeltaApply( const Pathname & /*filename*/ )
73 virtual void progressDeltaApply( int /*value*/ )
76 virtual void problemDeltaApply( const std::string &/*description*/ )
79 virtual void finishDeltaApply()
82 // Dowmload patch rpm:
83 // - path below url reported on start()
84 // - expected download size (0 if unknown)
85 // - download is interruptable
86 virtual void startPatchDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
89 virtual bool progressPatchDownload( int /*value*/ )
92 virtual void problemPatchDownload( const std::string &/*description*/ )
95 virtual void finishPatchDownload()
99 // return false if the download should be aborted right now
100 virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable_ptr*/)
103 virtual Action problem(
104 Resolvable::constPtr /*resolvable_ptr*/
106 , const std::string &/*description*/
109 virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
111 , const std::string &/*reason*/
115 // progress for probing a source
116 struct ProbeSourceReport : public callback::ReportBase
119 ABORT, // abort and return error
125 NOT_FOUND, // the requested Url was not found
127 INVALID, // th source is invalid
131 virtual void start(const Url &/*url*/) {}
132 virtual void failedProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
133 virtual void successProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
134 virtual void finish(const Url &/*url*/, Error /*error*/, const std::string &/*reason*/ ) {}
136 virtual bool progress(const Url &/*url*/, int /*value*/)
139 virtual Action problem( const Url &/*url*/, Error /*error*/, const std::string &/*description*/ ) { return ABORT; }
142 struct SourceCreateReport : public callback::ReportBase
145 ABORT, // abort and return error
147 IGNORE // skip refresh, ignore failed refresh
152 NOT_FOUND, // the requested Url was not found
155 INVALID, // th source is invali
159 virtual void start( const zypp::Url &/*url*/ ) {}
160 virtual bool progress( int /*value*/ )
163 virtual Action problem(
164 const zypp::Url &/*url*/
166 , const std::string &/*description*/ )
170 const zypp::Url &/*url*/
172 , const std::string &/*reason*/ )
176 struct SourceReport : public callback::ReportBase
179 ABORT, // abort and return error
181 IGNORE // skip refresh, ignore failed refresh
186 NOT_FOUND, // the requested Url was not found
188 INVALID // th source is invalid
191 virtual void start( Source_Ref /*source*/, const std::string &/*task*/ ) {}
192 virtual bool progress( int /*value*/ )
195 virtual Action problem(
196 Source_Ref /*source*/
198 , const std::string &/*description*/ )
202 Source_Ref /*source*/
203 , const std::string &/*task*/
205 , const std::string &/*reason*/ )
210 /////////////////////////////////////////////////////////////////
211 } // namespace source
212 ///////////////////////////////////////////////////////////////////
214 ///////////////////////////////////////////////////////////////////
217 // media change request callback
218 struct MediaChangeReport : public callback::ReportBase
221 ABORT, // abort and return error
223 IGNORE, // ignore this media in future, not available anymore
224 IGNORE_ID, // ignore wrong medium id
225 CHANGE_URL, // change media URL
226 EJECT // eject the medium
231 NOT_FOUND, // the medie not found at all
232 IO, // error accessing the media
233 INVALID, // media is broken
234 WRONG // wrong media, need a different one
237 virtual Action requestMedia(
238 Source_Ref /*source*/
239 , unsigned /*mediumNr*/
241 , const std::string &/*description*/
245 // progress for downloading a file
246 struct DownloadProgressReport : public callback::ReportBase
249 ABORT, // abort and return error
251 IGNORE // ignore the failure
256 NOT_FOUND, // the requested Url was not found
260 virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
262 virtual bool progress(int /*value*/, const Url &/*file*/)
265 virtual Action problem(
268 , const std::string &/*description*/
274 , const std::string &/*reason*/
278 /////////////////////////////////////////////////////////////////
280 ///////////////////////////////////////////////////////////////////
282 ///////////////////////////////////////////////////////////////////
286 // resolvable Message
287 struct MessageResolvableReport : public callback::ReportBase
290 Message::constPtr /*message*/
295 struct ScriptResolvableReport : public callback::ReportBase
297 enum Task { DO, UNDO };
298 enum Notify { OUTPUT, PING };
300 /** Whether executing do_script on install or undo_script on delete. */
301 virtual void start( const Resolvable::constPtr & /*script_r*/,
302 const Pathname & /*path_r*/,
305 /** Progress provides the script output. If the script is quiet,
306 * from time to time still-alive pings are sent to the ui. Returning \c FALSE
307 * aborts script execution.
309 virtual bool progress( Notify , const std::string & = std::string() )
312 virtual void problem( const std::string & /*description*/ )
314 /** Report success. */
315 virtual void finish()
319 ///////////////////////////////////////////////////////////////////
323 // progress for installing a resolvable
324 struct InstallResolvableReport : public callback::ReportBase
327 ABORT, // abort and return error
329 IGNORE // ignore the failure
334 NOT_FOUND, // the requested Url was not found
336 INVALID // th resolvable is invalid
339 // the level of RPM pushing
347 Resolvable::constPtr /*resolvable*/
350 virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
353 virtual Action problem(
354 Resolvable::constPtr /*resolvable*/
356 , const std::string &/*description*/
361 Resolvable::constPtr /*resolvable*/
363 , const std::string &/*reason*/
368 // progress for removing a resolvable
369 struct RemoveResolvableReport : public callback::ReportBase
372 ABORT, // abort and return error
374 IGNORE // ignore the failure
379 NOT_FOUND, // the requested Url was not found
381 INVALID // th resolvable is invalid
385 Resolvable::constPtr /*resolvable*/
388 virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
391 virtual Action problem(
392 Resolvable::constPtr /*resolvable*/
394 , const std::string &/*description*/
398 Resolvable::constPtr /*resolvable*/
400 , const std::string &/*reason*/
404 // progress for rebuilding the database
405 struct RebuildDBReport : public callback::ReportBase
408 ABORT, // abort and return error
410 IGNORE // ignore the failure
415 FAILED // failed to rebuild
418 virtual void start(Pathname /*path*/) {}
420 virtual bool progress(int /*value*/, Pathname /*path*/)
423 virtual Action problem(
426 , const std::string &/*description*/
432 , const std::string &/*reason*/
436 // progress for converting the database
437 struct ConvertDBReport : public callback::ReportBase
440 ABORT, // abort and return error
442 IGNORE // ignore the failure
447 FAILED // conversion failed
454 virtual bool progress(int /*value*/, Pathname /*path*/)
457 virtual Action problem(
460 , const std::string &/*description*/
466 , const std::string &/*reason*/
470 // progress for scanning the database
471 struct ScanDBReport : public callback::ReportBase
474 ABORT, // abort and return error
476 IGNORE // ignore the failure
481 FAILED // conversion failed
487 virtual bool progress(int /*value*/)
490 virtual Action problem(
492 , const std::string &/*description*/
497 , const std::string &/*reason*/
501 /////////////////////////////////////////////////////////////////
503 ///////////////////////////////////////////////////////////////////
505 /////////////////////////////////////////////////////////////////
506 } // namespace target
507 ///////////////////////////////////////////////////////////////////
509 /////////////////////////////////////////////////////////////////
511 ///////////////////////////////////////////////////////////////////
513 #endif // ZYPP_ZYPPCALLBACKS_H