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