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"
21 #include "zypp/media/MediaUserAuth.h"
23 ///////////////////////////////////////////////////////////////////
25 { /////////////////////////////////////////////////////////////////
28 // progress for downloading a resolvable
29 struct DownloadResolvableReport : public callback::ReportBase
32 ABORT, // abort and return error
34 IGNORE, // ignore this resolvable but continue
39 NOT_FOUND, // the requested Url was not found
41 INVALID // the downloaded file is invalid
45 Resolvable::constPtr /*resolvable_ptr*/
50 // Dowmload delta rpm:
51 // - path below url reported on start()
52 // - expected download size (0 if unknown)
53 // - download is interruptable
54 // - problems are just informal
55 virtual void startDeltaDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
58 virtual bool progressDeltaDownload( int /*value*/ )
61 virtual void problemDeltaDownload( const std::string &/*description*/ )
64 virtual void finishDeltaDownload()
68 // - local path of downloaded delta
69 // - aplpy is not interruptable
70 // - problems are just informal
71 virtual void startDeltaApply( const Pathname & /*filename*/ )
74 virtual void progressDeltaApply( int /*value*/ )
77 virtual void problemDeltaApply( const std::string &/*description*/ )
80 virtual void finishDeltaApply()
83 // Dowmload patch rpm:
84 // - path below url reported on start()
85 // - expected download size (0 if unknown)
86 // - download is interruptable
87 virtual void startPatchDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
90 virtual bool progressPatchDownload( int /*value*/ )
93 virtual void problemPatchDownload( const std::string &/*description*/ )
96 virtual void finishPatchDownload()
100 // return false if the download should be aborted right now
101 virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable_ptr*/)
104 virtual Action problem(
105 Resolvable::constPtr /*resolvable_ptr*/
107 , const std::string &/*description*/
110 virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
112 , const std::string &/*reason*/
116 // progress for probing a source
117 struct ProbeSourceReport : public callback::ReportBase
120 ABORT, // abort and return error
126 NOT_FOUND, // the requested Url was not found
128 INVALID, // th source is invalid
132 virtual void start(const Url &/*url*/) {}
133 virtual void failedProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
134 virtual void successProbe( const Url &/*url*/, const std::string &/*type*/ ) {}
135 virtual void finish(const Url &/*url*/, Error /*error*/, const std::string &/*reason*/ ) {}
137 virtual bool progress(const Url &/*url*/, int /*value*/)
140 virtual Action problem( const Url &/*url*/, Error /*error*/, const std::string &/*description*/ ) { return ABORT; }
143 struct SourceCreateReport : public callback::ReportBase
146 ABORT, // abort and return error
148 IGNORE // skip refresh, ignore failed refresh
153 NOT_FOUND, // the requested Url was not found
156 INVALID, // th source is invali
160 virtual void start( const zypp::Url &/*url*/ ) {}
161 virtual bool progress( int /*value*/ )
164 virtual Action problem(
165 const zypp::Url &/*url*/
167 , const std::string &/*description*/ )
171 const zypp::Url &/*url*/
173 , const std::string &/*reason*/ )
177 struct SourceReport : public callback::ReportBase
180 ABORT, // abort and return error
182 IGNORE // skip refresh, ignore failed refresh
187 NOT_FOUND, // the requested Url was not found
189 INVALID // th source is invalid
192 virtual void start( Source_Ref /*source*/, const std::string &/*task*/ ) {}
193 virtual bool progress( int /*value*/ )
196 virtual Action problem(
197 Source_Ref /*source*/
199 , const std::string &/*description*/ )
203 Source_Ref /*source*/
204 , const std::string &/*task*/
206 , const std::string &/*reason*/ )
211 /////////////////////////////////////////////////////////////////
212 } // namespace source
213 ///////////////////////////////////////////////////////////////////
215 ///////////////////////////////////////////////////////////////////
218 // media change request callback
219 struct MediaChangeReport : public callback::ReportBase
222 ABORT, // abort and return error
224 IGNORE, // ignore this media in future, not available anymore
225 IGNORE_ID, // ignore wrong medium id
226 CHANGE_URL, // change media URL
227 EJECT // eject the medium
232 NOT_FOUND, // the medie not found at all
233 IO, // error accessing the media
234 INVALID, // media is broken
235 WRONG // wrong media, need a different one
238 virtual Action requestMedia(
239 Source_Ref /*source*/
240 , unsigned /*mediumNr*/
242 , const std::string &/*description*/
246 // progress for downloading a file
247 struct DownloadProgressReport : public callback::ReportBase
250 ABORT, // abort and return error
252 IGNORE // ignore the failure
257 NOT_FOUND, // the requested Url was not found
259 ACCESS_DENIED // user authent. failed while accessing restricted file
262 virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
264 virtual bool progress(int /*value*/, const Url &/*file*/)
267 virtual Action problem(
270 , const std::string &/*description*/
276 , const std::string &/*reason*/
280 // authentication issues report
281 struct AuthenticationReport : public callback::ReportBase
284 * Prompt for authentication data.
286 * \param url URL which required the authentication
287 * \param msg prompt text
288 * \param auth_data input/output object for handling authentication
289 * data. As an input parameter auth_data can be prefilled with
290 * username (from previous try) or auth_type (available
291 * authentication methods aquired from server (only CurlAuthData)).
292 * As an output parameter it serves for sending username, pasword
293 * or other special data (derived AuthData objects).
294 * \return true if user chooses to continue with authentication,
297 virtual bool prompt(const Url & /* url */,
298 const std::string & /* msg */,
299 AuthData & /* auth_data */)
305 /////////////////////////////////////////////////////////////////
307 ///////////////////////////////////////////////////////////////////
309 ///////////////////////////////////////////////////////////////////
313 // resolvable Message
314 struct MessageResolvableReport : public callback::ReportBase
317 Message::constPtr /*message*/
322 struct ScriptResolvableReport : public callback::ReportBase
324 enum Task { DO, UNDO };
325 enum Notify { OUTPUT, PING };
327 /** Whether executing do_script on install or undo_script on delete. */
328 virtual void start( const Resolvable::constPtr & /*script_r*/,
329 const Pathname & /*path_r*/,
332 /** Progress provides the script output. If the script is quiet,
333 * from time to time still-alive pings are sent to the ui. Returning \c FALSE
334 * aborts script execution.
336 virtual bool progress( Notify , const std::string & = std::string() )
339 virtual void problem( const std::string & /*description*/ )
341 /** Report success. */
342 virtual void finish()
346 ///////////////////////////////////////////////////////////////////
350 // progress for installing a resolvable
351 struct InstallResolvableReport : public callback::ReportBase
354 ABORT, // abort and return error
356 IGNORE // ignore the failure
361 NOT_FOUND, // the requested Url was not found
363 INVALID // th resolvable is invalid
366 // the level of RPM pushing
374 Resolvable::constPtr /*resolvable*/
377 virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
380 virtual Action problem(
381 Resolvable::constPtr /*resolvable*/
383 , const std::string &/*description*/
388 Resolvable::constPtr /*resolvable*/
390 , const std::string &/*reason*/
395 // progress for removing a resolvable
396 struct RemoveResolvableReport : public callback::ReportBase
399 ABORT, // abort and return error
401 IGNORE // ignore the failure
406 NOT_FOUND, // the requested Url was not found
408 INVALID // th resolvable is invalid
412 Resolvable::constPtr /*resolvable*/
415 virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
418 virtual Action problem(
419 Resolvable::constPtr /*resolvable*/
421 , const std::string &/*description*/
425 Resolvable::constPtr /*resolvable*/
427 , const std::string &/*reason*/
431 // progress for rebuilding the database
432 struct RebuildDBReport : public callback::ReportBase
435 ABORT, // abort and return error
437 IGNORE // ignore the failure
442 FAILED // failed to rebuild
445 virtual void start(Pathname /*path*/) {}
447 virtual bool progress(int /*value*/, Pathname /*path*/)
450 virtual Action problem(
453 , const std::string &/*description*/
459 , const std::string &/*reason*/
463 // progress for converting the database
464 struct ConvertDBReport : public callback::ReportBase
467 ABORT, // abort and return error
469 IGNORE // ignore the failure
474 FAILED // conversion failed
481 virtual bool progress(int /*value*/, Pathname /*path*/)
484 virtual Action problem(
487 , const std::string &/*description*/
493 , const std::string &/*reason*/
497 // progress for scanning the database
498 struct ScanDBReport : public callback::ReportBase
501 ABORT, // abort and return error
503 IGNORE // ignore the failure
508 FAILED // conversion failed
514 virtual bool progress(int /*value*/)
517 virtual Action problem(
519 , const std::string &/*description*/
524 , const std::string &/*reason*/
528 /////////////////////////////////////////////////////////////////
530 ///////////////////////////////////////////////////////////////////
532 /////////////////////////////////////////////////////////////////
533 } // namespace target
534 ///////////////////////////////////////////////////////////////////
536 /////////////////////////////////////////////////////////////////
538 ///////////////////////////////////////////////////////////////////
540 #endif // ZYPP_ZYPPCALLBACKS_H