don't warn about unused parameters
[platform/upstream/libzypp.git] / zypp / ZYppCallbacks.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ZYppCallbacks.h
10  *
11 */
12 #ifndef ZYPP_ZYPPCALLBACKS_H
13 #define ZYPP_ZYPPCALLBACKS_H
14
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"
20 #include "zypp/Url.h"
21
22 ///////////////////////////////////////////////////////////////////
23 namespace zypp
24 { /////////////////////////////////////////////////////////////////
25   namespace source
26   {
27     // progress for downloading a resolvable
28     struct DownloadResolvableReport : public callback::ReportBase
29     {
30       enum Action {
31         ABORT,  // abort and return error
32         RETRY,  // retry
33         IGNORE, // ignore this resolvable but continue
34       };
35
36       enum Error {
37         NO_ERROR,
38         NOT_FOUND,      // the requested Url was not found
39         IO,             // IO error
40         INVALID         // the downloaded file is invalid
41       };
42
43       virtual void start(
44         Resolvable::constPtr /*resolvable_ptr*/
45         , const Url &/*url*/
46       ) {}
47
48
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*/ )
55       {}
56
57       virtual bool progressDeltaDownload( int /*value*/ )
58       { return true; }
59
60       virtual void problemDeltaDownload( const std::string &/*description*/ )
61       {}
62
63       virtual void finishDeltaDownload()
64       {}
65
66       // Apply delta rpm:
67       // - local path of downloaded delta
68       // - aplpy is not interruptable
69       // - problems are just informal
70       virtual void startDeltaApply( const Pathname & /*filename*/ )
71       {}
72
73       virtual void progressDeltaApply( int /*value*/ )
74       {}
75
76       virtual void problemDeltaApply( const std::string &/*description*/ )
77       {}
78
79       virtual void finishDeltaApply()
80       {}
81
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*/ )
87       {}
88
89       virtual bool progressPatchDownload( int /*value*/ )
90       { return true; }
91
92       virtual void problemPatchDownload( const std::string &/*description*/ )
93       {}
94
95       virtual void finishPatchDownload()
96       {}
97
98
99       // return false if the download should be aborted right now
100       virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable_ptr*/)
101       { return true; }
102
103       virtual Action problem(
104         Resolvable::constPtr /*resolvable_ptr*/
105         , Error /*error*/
106         , const std::string &/*description*/
107       ) { return ABORT; }
108
109       virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
110         , Error /*error*/
111         , const std::string &/*reason*/
112       ) {}
113     };
114
115     // progress for probing a source
116     struct ProbeSourceReport : public callback::ReportBase
117     {
118       enum Action {
119         ABORT,  // abort and return error
120         RETRY   // retry
121       };
122
123       enum Error {
124         NO_ERROR,
125         NOT_FOUND,      // the requested Url was not found
126         IO,             // IO error
127         INVALID,                // th source is invalid
128         UNKNOWN
129       };
130
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*/ ) {}
135
136       virtual bool progress(const Url &/*url*/, int /*value*/)
137       { return true; }
138
139       virtual Action problem( const Url &/*url*/, Error /*error*/, const std::string &/*description*/ ) { return ABORT; }
140     };
141
142     struct SourceCreateReport : public callback::ReportBase
143     {
144       enum Action {
145         ABORT,  // abort and return error
146         RETRY,  // retry
147         IGNORE  // skip refresh, ignore failed refresh
148       };
149
150       enum Error {
151         NO_ERROR,
152         NOT_FOUND,      // the requested Url was not found
153         IO,             // IO error
154         REJECTED,
155         INVALID, // th source is invali
156         UNKNOWN
157       };
158
159       virtual void start( const zypp::Url &/*url*/ ) {}
160       virtual bool progress( int /*value*/ )
161       { return true; }
162
163       virtual Action problem(
164           const zypp::Url &/*url*/
165           , Error /*error*/
166           , const std::string &/*description*/ )
167       { return ABORT; }
168
169       virtual void finish(
170           const zypp::Url &/*url*/
171           , Error /*error*/
172           , const std::string &/*reason*/ )
173       {}
174     };
175
176     struct SourceReport : public callback::ReportBase
177     {
178       enum Action {
179         ABORT,  // abort and return error
180         RETRY,  // retry
181         IGNORE  // skip refresh, ignore failed refresh
182       };
183
184       enum Error {
185         NO_ERROR,
186         NOT_FOUND,      // the requested Url was not found
187         IO,             // IO error
188         INVALID         // th source is invalid
189       };
190
191       virtual void start( Source_Ref /*source*/, const std::string &/*task*/ ) {}
192       virtual bool progress( int /*value*/ )
193       { return true; }
194
195       virtual Action problem(
196           Source_Ref /*source*/
197           , Error /*error*/
198           , const std::string &/*description*/ )
199       { return ABORT; }
200
201       virtual void finish(
202           Source_Ref /*source*/
203           , const std::string &/*task*/
204           , Error /*error*/
205           , const std::string &/*reason*/ )
206       {}
207     };
208
209
210     /////////////////////////////////////////////////////////////////
211   } // namespace source
212   ///////////////////////////////////////////////////////////////////
213
214   ///////////////////////////////////////////////////////////////////
215   namespace media
216   {
217     // media change request callback
218     struct MediaChangeReport : public callback::ReportBase
219     {
220       enum Action {
221         ABORT,  // abort and return error
222         RETRY,  // retry
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
227       };
228
229       enum Error {
230         NO_ERROR,
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
235       };
236
237       virtual Action requestMedia(
238         Source_Ref /*source*/
239         , unsigned /*mediumNr*/
240         , Error /*error*/
241         , const std::string &/*description*/
242       ) { return ABORT; }
243     };
244
245     // progress for downloading a file
246     struct DownloadProgressReport : public callback::ReportBase
247     {
248         enum Action {
249           ABORT,  // abort and return error
250           RETRY,        // retry
251           IGNORE        // ignore the failure
252         };
253
254         enum Error {
255           NO_ERROR,
256           NOT_FOUND,    // the requested Url was not found
257           IO            // IO error
258         };
259
260         virtual void start( const Url &/*file*/, Pathname /*localfile*/ ) {}
261
262         virtual bool progress(int /*value*/, const Url &/*file*/)
263         { return true; }
264
265         virtual Action problem(
266           const Url &/*file*/
267           , Error /*error*/
268           , const std::string &/*description*/
269         ) { return ABORT; }
270
271         virtual void finish(
272           const Url &/*file*/
273           , Error /*error*/
274           , const std::string &/*reason*/
275         ) {}
276     };
277
278     /////////////////////////////////////////////////////////////////
279   } // namespace media
280   ///////////////////////////////////////////////////////////////////
281
282   ///////////////////////////////////////////////////////////////////
283   namespace target
284   {
285
286     // resolvable Message
287     struct MessageResolvableReport : public callback::ReportBase
288     {
289         virtual void show(
290           Message::constPtr /*message*/
291         ) {}
292     };
293
294     // resolvable Script
295     struct ScriptResolvableReport : public callback::ReportBase
296     {
297       enum Task   { DO, UNDO };
298       enum Notify { OUTPUT, PING };
299
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*/,
303                           Task )
304       {}
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.
308       */
309       virtual bool progress( Notify , const std::string & = std::string() )
310       { return true; }
311       /** Report error. */
312       virtual void problem( const std::string & /*description*/ )
313       {}
314       /** Report success. */
315       virtual void finish()
316       {}
317     };
318
319     ///////////////////////////////////////////////////////////////////
320     namespace rpm
321     {
322
323       // progress for installing a resolvable
324       struct InstallResolvableReport : public callback::ReportBase
325       {
326         enum Action {
327           ABORT,  // abort and return error
328           RETRY,        // retry
329           IGNORE        // ignore the failure
330         };
331
332         enum Error {
333           NO_ERROR,
334           NOT_FOUND,    // the requested Url was not found
335           IO,           // IO error
336           INVALID               // th resolvable is invalid
337         };
338
339         // the level of RPM pushing
340         enum RpmLevel {
341             RPM,
342             RPM_NODEPS,
343             RPM_NODEPS_FORCE
344         };
345
346         virtual void start(
347           Resolvable::constPtr /*resolvable*/
348         ) {}
349
350         virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
351         { return true; }
352
353         virtual Action problem(
354           Resolvable::constPtr /*resolvable*/
355           , Error /*error*/
356           , const std::string &/*description*/
357           , RpmLevel /*level*/
358         ) { return ABORT; }
359
360         virtual void finish(
361           Resolvable::constPtr /*resolvable*/
362           , Error /*error*/
363           , const std::string &/*reason*/
364           , RpmLevel /*level*/
365         ) {}
366       };
367
368       // progress for removing a resolvable
369       struct RemoveResolvableReport : public callback::ReportBase
370       {
371         enum Action {
372           ABORT,  // abort and return error
373           RETRY,        // retry
374           IGNORE        // ignore the failure
375         };
376
377         enum Error {
378           NO_ERROR,
379           NOT_FOUND,    // the requested Url was not found
380           IO,           // IO error
381           INVALID               // th resolvable is invalid
382         };
383
384         virtual void start(
385           Resolvable::constPtr /*resolvable*/
386         ) {}
387
388         virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
389         { return true; }
390
391         virtual Action problem(
392           Resolvable::constPtr /*resolvable*/
393           , Error /*error*/
394           , const std::string &/*description*/
395         ) { return ABORT; }
396
397         virtual void finish(
398           Resolvable::constPtr /*resolvable*/
399           , Error /*error*/
400           , const std::string &/*reason*/
401         ) {}
402       };
403
404       // progress for rebuilding the database
405       struct RebuildDBReport : public callback::ReportBase
406       {
407         enum Action {
408           ABORT,  // abort and return error
409           RETRY,        // retry
410           IGNORE        // ignore the failure
411         };
412
413         enum Error {
414           NO_ERROR,
415           FAILED                // failed to rebuild
416         };
417
418         virtual void start(Pathname /*path*/) {}
419
420         virtual bool progress(int /*value*/, Pathname /*path*/)
421         { return true; }
422
423         virtual Action problem(
424           Pathname /*path*/
425          , Error /*error*/
426          , const std::string &/*description*/
427         ) { return ABORT; }
428
429         virtual void finish(
430           Pathname /*path*/
431           , Error /*error*/
432           , const std::string &/*reason*/
433         ) {}
434       };
435
436       // progress for converting the database
437       struct ConvertDBReport : public callback::ReportBase
438       {
439         enum Action {
440           ABORT,  // abort and return error
441           RETRY,        // retry
442           IGNORE        // ignore the failure
443         };
444
445         enum Error {
446           NO_ERROR,
447           FAILED                // conversion failed
448         };
449
450         virtual void start(
451           Pathname /*path*/
452         ) {}
453
454         virtual bool progress(int /*value*/, Pathname /*path*/)
455         { return true; }
456
457         virtual Action problem(
458           Pathname /*path*/
459           , Error /*error*/
460          , const std::string &/*description*/
461         ) { return ABORT; }
462
463         virtual void finish(
464           Pathname /*path*/
465           , Error /*error*/
466           , const std::string &/*reason*/
467         ) {}
468       };
469
470        // progress for scanning the database
471       struct ScanDBReport : public callback::ReportBase
472       {
473         enum Action {
474           ABORT,  // abort and return error
475           RETRY,        // retry
476           IGNORE        // ignore the failure
477         };
478
479         enum Error {
480           NO_ERROR,
481           FAILED                // conversion failed
482         };
483
484         virtual void start(
485         ) {}
486
487         virtual bool progress(int /*value*/)
488         { return true; }
489
490         virtual Action problem(
491           Error /*error*/
492          , const std::string &/*description*/
493         ) { return ABORT; }
494
495         virtual void finish(
496           Error /*error*/
497           , const std::string &/*reason*/
498         ) {}
499       };
500
501       /////////////////////////////////////////////////////////////////
502     } // namespace rpm
503     ///////////////////////////////////////////////////////////////////
504
505     /////////////////////////////////////////////////////////////////
506   } // namespace target
507   ///////////////////////////////////////////////////////////////////
508
509   /////////////////////////////////////////////////////////////////
510 } // namespace zypp
511 ///////////////////////////////////////////////////////////////////
512
513 #endif // ZYPP_ZYPPCALLBACKS_H