provide also the level of RPM pushing in callbacks
[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/Url.h"
20
21 ///////////////////////////////////////////////////////////////////
22 namespace zypp
23 { /////////////////////////////////////////////////////////////////
24   namespace source
25   {
26     // progress for downloading a resolvable
27     struct DownloadResolvableReport : public callback::ReportBase
28     {
29       enum Action { 
30         ABORT,  // abort and return error
31         RETRY   // retry
32       }; 
33       
34       enum Error {
35         NO_ERROR,
36         NOT_FOUND,      // the requested Url was not found
37         IO,             // IO error
38         INVALID         // the downloaded file is invalid
39       };
40
41       virtual void start(
42         Resolvable::Ptr resolvable_ptr
43         , Url url
44       ) {}
45
46       // return false if the download should be aborted right now
47       virtual bool progress(int value, Resolvable::Ptr resolvable_ptr) 
48       { return true; }
49
50       virtual Action problem(
51         Resolvable::Ptr resolvable_ptr
52         , Error error
53         , std::string description
54       ) { return ABORT; }
55
56       virtual void finish(Resolvable::Ptr resolvable_ptr
57         , Error error
58         , std::string reason
59       ) {}
60     };
61     
62
63     // progress for downloading a specific file
64     struct DownloadFileReport : public callback::ReportBase
65     {
66       enum Action { 
67         ABORT,  // abort and return error
68         RETRY   // retry
69       }; 
70       
71       enum Error {
72         NO_ERROR,
73         NOT_FOUND,      // the requested Url was not found
74         IO,             // IO error
75         INVALID         // the downloaded file is invalid
76       };
77       virtual void start(
78         Source_Ref source
79         , Url url
80       ) {}
81
82       virtual bool progress(int value, Url url) 
83       { return true; }
84
85       virtual Action problem(
86         Url url
87         , Error error
88         , std::string description
89       ) { return ABORT; }
90
91       virtual void finish(
92         Url url
93         , Error error
94         , std::string reason
95       ) {}
96     };
97
98     // progress for refreshing a source data
99     struct RefreshSourceReport : public callback::ReportBase
100     {
101       enum Action { 
102         ABORT,  // abort and return error
103         RETRY,  // retry
104         IGNORE  // skip refresh, ignore failed refresh
105       }; 
106       
107       enum Error {
108         NO_ERROR,
109         NOT_FOUND,      // the requested Url was not found
110         IO,             // IO error
111         INVALID         // th source is invalid
112       };
113       virtual void start(
114         Source_Ref source
115         , Url url
116       ) {}
117
118       virtual bool progress(int value, Source_Ref source) 
119       { return true; }
120
121       virtual Action problem(
122         Source_Ref source
123         , Error error
124         , std::string description
125       ) { return ABORT; }
126
127       virtual void finish(
128         Source_Ref source
129         , Error error
130         , std::string reason
131       ) {}
132     };
133
134     // progress for creating a source (download and parsing)
135     struct CreateSourceReport : public callback::ReportBase
136     {
137       enum Action { 
138         ABORT,  // abort and return error
139         RETRY   // retry
140       }; 
141       
142       enum Error {
143         NO_ERROR,
144         NOT_FOUND,      // the requested Url was not found
145         IO,             // IO error
146         INVALID         // th source is invalid
147       };
148
149       virtual void startData(
150         Url source_url
151       ) {}
152       
153       virtual void startProbe(Url url) {}
154
155       virtual void endProbe(Url url) {}
156
157       virtual bool progressData(int value, Url url) 
158       { return true; }
159
160       virtual Action problem(
161         Url url
162         , Error error
163         , std::string description
164       ) { return ABORT; }
165
166       virtual void finishData(
167         Url url
168         , Error error
169         , std::string reason
170       ) {}
171     };
172     
173     /////////////////////////////////////////////////////////////////
174   } // namespace source
175   ///////////////////////////////////////////////////////////////////
176   
177   ///////////////////////////////////////////////////////////////////
178   namespace media 
179   { 
180     // media change request callback
181     struct MediaChangeReport : public callback::ReportBase
182     {
183       enum Action { 
184         ABORT,  // abort and return error
185         RETRY,  // retry
186         IGNORE, // ignore this media in future, not available anymore
187         IGNORE_ID,      // ignore wrong medium id
188         CHANGE_URL,     // change media URL
189         EJECT           // eject the medium
190       }; 
191
192       enum Error { 
193         NO_ERROR,
194         NOT_FOUND,  // the medie not found at all
195         IO,     // error accessing the media
196         INVALID, // media is broken
197         WRONG   // wrong media, need a different one
198       };       
199       
200       virtual Action requestMedia(
201         const Source_Ref source
202         , unsigned mediumNr
203         , Error error
204         , std::string description
205       ) { return ABORT; }
206     };
207
208     /////////////////////////////////////////////////////////////////
209   } // namespace media
210   ///////////////////////////////////////////////////////////////////
211
212   ///////////////////////////////////////////////////////////////////
213   namespace target 
214   { 
215   
216     ///////////////////////////////////////////////////////////////////
217     namespace rpm 
218     { 
219
220       // progress for installing a resolvable
221       struct InstallResolvableReport : public callback::ReportBase
222       {
223         enum Action { 
224           ABORT,  // abort and return error
225           RETRY,        // retry
226           IGNORE        // ignore the failure
227         }; 
228       
229         enum Error {
230           NO_ERROR,
231           NOT_FOUND,    // the requested Url was not found
232           IO,           // IO error
233           INVALID               // th resolvable is invalid
234         };
235       
236         // the level of RPM pushing
237         enum RpmLevel {
238             RPM,
239             RPM_NODEPS,
240             RPM_NODEPS_FORCE
241         };
242
243         virtual void start(
244           Resolvable::constPtr resolvable
245         ) {}
246
247         virtual bool progress(int value, Resolvable::constPtr resolvable) 
248         { return true; }
249
250         virtual Action problem(
251           Resolvable::constPtr resolvable
252           , Error error
253           , std::string description
254           , RpmLevel level
255         ) { return ABORT; }
256
257         virtual void finish(
258           Resolvable::constPtr resolvable
259           , Error error
260           , std::string reason
261           , RpmLevel level
262         ) {}
263       };
264     
265       // progress for removing a resolvable
266       struct RemoveResolvableReport : public callback::ReportBase
267       {
268         enum Action { 
269           ABORT,  // abort and return error
270           RETRY,        // retry
271           IGNORE        // ignore the failure
272         }; 
273       
274         enum Error {
275           NO_ERROR,
276           NOT_FOUND,    // the requested Url was not found
277           IO,           // IO error
278           INVALID               // th resolvable is invalid
279         };
280       
281         virtual void start(
282           Resolvable::Ptr resolvable
283         ) {}
284
285         virtual bool progress(int value, Resolvable::Ptr resolvable) 
286         { return true; }
287
288         virtual Action problem(
289           Resolvable::Ptr resolvable
290           , Error error
291           , std::string description
292         ) { return ABORT; }
293
294         virtual void finish(
295           Resolvable::Ptr resolvable
296           , Error error
297           , std::string reason
298         ) {}
299       };
300     
301       // progress for rebuilding the database
302       struct RebuildDBReport : public callback::ReportBase
303       {
304         enum Action { 
305           ABORT,  // abort and return error
306           RETRY,        // retry
307           IGNORE        // ignore the failure
308         }; 
309       
310         enum Error {
311           NO_ERROR,
312           NOT_FOUND,    // the requested Url was not found
313           IO,           // IO error
314           INVALID               // th resolvable is invalid
315         };
316       
317         virtual void start(
318           Pathname path
319         ) {}
320
321         virtual bool progress(int value, Pathname path) 
322         { return true; } 
323
324         virtual Action problem(
325           Pathname path
326           , Error error
327          , std::string description
328         ) { return ABORT; }
329
330         virtual void finish(
331           Pathname path
332           , Error error
333           , std::string reason
334         ) {}
335       };
336
337       // progress for converting the database
338       struct ConvertDBReport : public callback::ReportBase
339       {
340         enum Action { 
341           ABORT,  // abort and return error
342           RETRY,        // retry
343           IGNORE        // ignore the failure
344         }; 
345       
346         enum Error {
347           NO_ERROR,
348           NOT_FOUND,    // the requested Url was not found
349           IO,           // IO error
350           INVALID               // th resolvable is invalid
351         };
352       
353         virtual void start(
354           Pathname path
355         ) {}
356
357         virtual bool progress(int value, Pathname path) 
358         { return true; }
359
360         virtual Action problem(
361           Pathname path
362           , Error error
363          , std::string description
364         ) { return ABORT; }
365
366         virtual void finish(
367           Pathname path
368           , Error error
369           , std::string reason
370         ) {}
371       };
372
373       /////////////////////////////////////////////////////////////////
374     } // namespace rpm
375     ///////////////////////////////////////////////////////////////////
376
377     /////////////////////////////////////////////////////////////////
378   } // namespace target
379   ///////////////////////////////////////////////////////////////////
380
381   /////////////////////////////////////////////////////////////////
382 } // namespace zypp
383 ///////////////////////////////////////////////////////////////////
384
385 #endif // ZYPP_ZYPPCALLBACKS_H