first callback with a bit of details in
[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
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 { /////////////////////////////////////////////////////////////////
23   namespace source
24   {
25     // progress for downloading a resolvable
26     struct DownloadResolvableReport : public callback::ReportBase
27     {
28       enum Action { 
29         ABORT,  // abort and return error
30         RETRY   // retry
31       }; 
32       
33       enum Error {
34         NOT_FOUND,      // the requested URL was not found
35         IO,             // IO error
36         INVALID         // the downloaded file is invalid
37       }
38
39       virtual void start(
40         Resolvable::Ptr resolvable_ptr
41         , Source_Ref source
42         , Url url
43       ) {}
44
45       virtual void progress(int value, Resolvable::Ptr resolvable_ptr) {]
46
47       virtual Action problem(
48         Resolvable::Ptr resolvable_ptr
49         , Error error
50         , TranslatedText description
51       ) { return ABORT; ]
52
53       virtual void finish(Resolvable::Ptr resolvable_ptr
54         , Error error
55         , TranslatedText reason
56       ) {}
57     };
58     
59
60     // progress for downloading a specific file
61     struct DownloadFileReport : public callback::ReportBase
62     {
63       virtual void start() {}
64       virtual void progress(int value) {]
65       virtual void finish() {}
66     };
67
68     // progress for refreshing a source data
69     struct RefreshSourceReport : public callback::ReportBase
70     {
71       virtual void start() {}
72       virtual void progress(int value) {]
73       virtual void finish() {}
74     };
75
76     // progress for downloading a resolvable
77     struct CreateSourceReport : public callback::ReportBase
78     {
79       virtual void start() {}
80       virtual void progress(int value) {]
81       virtual void finish() {}
82     };
83     
84     // progress for downloading a resolvable
85     struct RefreshSourceReport : public callback::ReportBase
86     {
87       virtual void start() {}
88       virtual void progress(int value) {]
89       virtual void finish() {}
90     };
91     
92     /////////////////////////////////////////////////////////////////
93   } // namespace source
94   ///////////////////////////////////////////////////////////////////
95   
96   ///////////////////////////////////////////////////////////////////
97   namespace media 
98   { 
99
100     // media change request callback
101     struct MediaChangeReport : public callback::ReportBase
102     {
103       enum Action { 
104         ABORT,  // abort and return error
105         RETRY   // retry
106       }; 
107
108       virtual Action userAction() { return ABORT; }
109     };
110
111     /////////////////////////////////////////////////////////////////
112   } // namespace media
113   ///////////////////////////////////////////////////////////////////
114
115   ///////////////////////////////////////////////////////////////////
116   namespace target 
117   { ///////////////////////////////////////////////////////////////////
118     namespace rpm 
119     { 
120
121       // progress for installing a resolvable
122       struct InstallResolvableReport : public callback::ReportBase
123       {
124         enum Action { 
125           ABORT,  // abort and return error
126           RETRY,  // retry
127           IGNORE  // ignore
128         }; 
129
130         virtual void start() {}
131         virtual void progress(int value) {]
132         virtual Action error () { return ABORT; }
133         virtual void finish() {}
134       };
135     
136       // progress for removing a resolvable
137       struct RemoveResolvableReport : public callback::ReportBase
138       {
139         enum Action { 
140           ABORT,  // abort and return error
141           RETRY,  // retry
142           IGNORE  // ignore
143         }; 
144
145         virtual void start() {}
146         virtual void progress(int value) {]
147         virtual Action error () { return ABORT; }
148         virtual void finish() {}
149       };
150     
151       // progress for rebuilding the database
152       struct RebuildDBReport : public callback::ReportBase
153       {
154         virtual void start() {}
155         virtual void progress(int value) {]
156         virtual void finish() {}
157       };
158
159       // progress for converting the database
160       struct ConvertDBReport : public callback::ReportBase
161       {
162         virtual void start() {}
163         virtual void progress(int value) {]
164         virtual void finish() {}
165       };
166
167       /////////////////////////////////////////////////////////////////
168     } // namespace rpm
169     ///////////////////////////////////////////////////////////////////
170
171     /////////////////////////////////////////////////////////////////
172   } // namespace target
173   ///////////////////////////////////////////////////////////////////
174
175   /////////////////////////////////////////////////////////////////
176 } // namespace zypp
177 ///////////////////////////////////////////////////////////////////
178
179 #endif // ZYPP_ZYPPCALLBACKS_H