follow the progress signature from the PackageManager
[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/TranslatedText.h"
19 #include "zypp/Pathname.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         NOT_FOUND,      // the requested URL was not found
36         IO,             // IO error
37         INVALID         // the downloaded file is invalid
38       };
39
40       virtual void start(
41         Resolvable::Ptr resolvable_ptr
42         , Source_Ref source
43         , Url url
44       ) {}
45
46       // return true if the download should be aborted right now
47       virtual bool progress(int value, Resolvable::Ptr resolvable_ptr) 
48       { return false; }
49
50       virtual Action problem(
51         Resolvable::Ptr resolvable_ptr
52         , Error error
53         , TranslatedText description
54       ) { return ABORT; }
55
56       virtual void finish(Resolvable::Ptr resolvable_ptr
57         , Error error
58         , TranslatedText 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         NOT_FOUND,      // the requested URL was not found
73         IO,             // IO error
74         INVALID         // the downloaded file is invalid
75       };
76       virtual void start(
77         Source_Ref source
78         , Url url
79       ) {}
80
81       virtual bool progress(int value, URL url) 
82       { return false; }
83
84       virtual Action problem(
85         URL url
86         , Error error
87         , TranslatedText description
88       ) { return ABORT; }
89
90       virtual void finish(
91         URL url
92         , Error error
93         , TranslatedText reason
94       ) {}
95     };
96
97     // progress for refreshing a source data
98     struct RefreshSourceReport : public callback::ReportBase
99     {
100       enum Action { 
101         ABORT,  // abort and return error
102         RETRY   // retry
103       }; 
104       
105       enum Error {
106         NOT_FOUND,      // the requested URL was not found
107         IO,             // IO error
108         INVALID         // th source is invalid
109       };
110       virtual void start(
111         Source_Ref source
112         , Url url
113       ) {}
114
115       virtual bool progress(int value, Source_Ref source) 
116       { return false; }
117
118       virtual Action problem(
119         Source_Ref source
120         , Error error
121         , TranslatedText description
122       ) { return ABORT; }
123
124       virtual void finish(
125         Source_Ref source
126         , Error error
127         , TranslatedText reason
128       ) {}
129     };
130
131     // progress for creating a source (download and parsing)
132     struct CreateSourceReport : public callback::ReportBase
133     {
134       enum Action { 
135         ABORT,  // abort and return error
136         RETRY   // retry
137       }; 
138       
139       enum Error {
140         NOT_FOUND,      // the requested URL was not found
141         IO,             // IO error
142         INVALID         // th source is invalid
143       };
144       virtual void start(
145         Source_Ref source
146         , Url url
147       ) {}
148
149       virtual bool progress(int value, URL url) 
150       { return false; }
151
152       virtual Action problem(
153         URL url
154         , Error error
155         , TranslatedText description
156       ) { return ABORT; }
157
158       virtual void finish(
159         URL url
160         , Error error
161         , TranslatedText reason
162       ) {}
163     };
164     
165     /////////////////////////////////////////////////////////////////
166   } // namespace source
167   ///////////////////////////////////////////////////////////////////
168   
169   ///////////////////////////////////////////////////////////////////
170   namespace media 
171   { 
172     // media change request callback
173     struct MediaChangeReport : public callback::ReportBase
174     {
175       enum Action { 
176         ABORT,  // abort and return error
177         RETRY,  // retry
178         IGNORE, // ignore this media in future, not available anymore
179       }; 
180
181       virtual Action requestMedia(
182         Source_ref source
183         , unsigned mediumNr
184         , Error error
185         , TranslatedText description
186       ) { return ABORT; }
187     };
188
189     /////////////////////////////////////////////////////////////////
190   } // namespace media
191   ///////////////////////////////////////////////////////////////////
192
193   ///////////////////////////////////////////////////////////////////
194   namespace target 
195   { 
196   
197     ///////////////////////////////////////////////////////////////////
198     namespace rpm 
199     { 
200
201       // progress for installing a resolvable
202       struct InstallResolvableReport : public callback::ReportBase
203       {
204         enum Action { 
205           ABORT,  // abort and return error
206           RETRY,        // retry
207           IGNORE        // ignore the failure
208         }; 
209       
210         enum Error {
211           NOT_FOUND,    // the requested URL was not found
212           IO,           // IO error
213           INVALID               // th resolvable is invalid
214         };
215       
216         virtual void start(
217           Resolvable::Ptr resolvable
218         ) {}
219
220         virtual bool progress(int value, Resolvable::Ptr resolvable) 
221         { return false; }
222
223         virtual Action problem(
224           Resolvable::Ptr resolvable
225           , Error error
226          , TranslatedText description
227         ) { return ABORT; }
228
229         virtual void finish(
230           Resolvable::Ptr resolvable
231           , Error error
232           , TranslatedText reason
233         ) {}
234       };
235     
236       // progress for removing a resolvable
237       struct RemoveResolvableReport : public callback::ReportBase
238       {
239         enum Action { 
240           ABORT,  // abort and return error
241           RETRY,        // retry
242           IGNORE        // ignore the failure
243         }; 
244       
245         enum Error {
246           NOT_FOUND,    // the requested URL was not found
247           IO,           // IO error
248           INVALID               // th resolvable is invalid
249         };
250       
251         virtual void start(
252           Resolvable::Ptr resolvable
253         ) {}
254
255         virtual bool progress(int value, Resolvable::Ptr resolvable) 
256         { return false; }
257
258         virtual Action problem(
259           Resolvable::Ptr resolvable
260           , Error error
261          , TranslatedText description
262         ) { return ABORT; }
263
264         virtual void finish(
265           Resolvable::Ptr resolvable
266           , Error error
267           , TranslatedText reason
268         ) {}
269       };
270     
271       // progress for rebuilding the database
272       struct RebuildDBReport : public callback::ReportBase
273       {
274         enum Action { 
275           ABORT,  // abort and return error
276           RETRY,        // retry
277           IGNORE        // ignore the failure
278         }; 
279       
280         enum Error {
281           NOT_FOUND,    // the requested URL was not found
282           IO,           // IO error
283           INVALID               // th resolvable is invalid
284         };
285       
286         virtual void start(
287           Pathname path
288         ) {}
289
290         virtual bool progress(int value, Pathname path) 
291         { return false; } 
292
293         virtual Action problem(
294           Pathname path
295           , Error error
296          , TranslatedText description
297         ) { return ABORT; }
298
299         virtual void finish(
300           Pathname path
301           , Error error
302           , TranslatedText reason
303         ) {}
304       };
305
306       // progress for converting the database
307       struct ConvertDBReport : public callback::ReportBase
308       {
309         enum Action { 
310           ABORT,  // abort and return error
311           RETRY,        // retry
312           IGNORE        // ignore the failure
313         }; 
314       
315         enum Error {
316           NOT_FOUND,    // the requested URL was not found
317           IO,           // IO error
318           INVALID               // th resolvable is invalid
319         };
320       
321         virtual void start(
322           Pathname path
323         ) {}
324
325         virtual bool progress(int value, Pathname path) 
326         { return false; }
327
328         virtual Action problem(
329           Pathname path
330           , Error error
331          , TranslatedText description
332         ) { return ABORT; }
333
334         virtual void finish(
335           Pathname path
336           , Error error
337           , TranslatedText reason
338         ) {}
339       };
340
341       /////////////////////////////////////////////////////////////////
342     } // namespace rpm
343     ///////////////////////////////////////////////////////////////////
344
345     /////////////////////////////////////////////////////////////////
346   } // namespace target
347   ///////////////////////////////////////////////////////////////////
348
349   /////////////////////////////////////////////////////////////////
350 } // namespace zypp
351 ///////////////////////////////////////////////////////////////////
352
353 #endif // ZYPP_ZYPPCALLBACKS_H