libzypp 17.37.10

TargetCallbackReceiver.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13#include <utility>
14
15#include <zypp/target/TargetCallbackReceiver.h>
16
17#include <zypp/target/rpm/RpmCallbacks.h>
18
20 namespace zypp
21{
23 namespace target
24 {
25
26 RpmInstallPackageReceiver::RpmInstallPackageReceiver (Resolvable::constPtr res)
27 : callback::ReceiveReport<rpm::RpmInstallReport> ()
28 , _resolvable (std::move(res))
29 , _level( target::rpm::InstallResolvableReport::RPM )
30 , _abort (false)
31 {
32 }
33
34 RpmInstallPackageReceiver::~RpmInstallPackageReceiver ()
35 {
36 }
37
38 void RpmInstallPackageReceiver::reportbegin()
39 {
40 }
41
42 void RpmInstallPackageReceiver::reportend()
43 {
44 }
45
46 void RpmInstallPackageReceiver::report( const UserData & userData_r )
47 {
48 if ( ! userData_r.haskey( "solvable" ) )
49 userData_r.set( "solvable", _resolvable->satSolvable() );
50 _report->report( userData_r );
51 }
52
54 void RpmInstallPackageReceiver::start( const Pathname & name )
55 {
56 _report->start( _resolvable );
57 _abort = false;
58 }
59
64 bool RpmInstallPackageReceiver::progress( unsigned percent )
65 {
66 _abort = ! _report->progress( percent, _resolvable );
67 return _abort;
68 }
69
70 rpm::RpmInstallReport::Action
71 RpmInstallPackageReceiver::problem( Exception & excpt_r )
72 {
73 rpm::InstallResolvableReport::Action user =
74 _report->problem( _resolvable
75 , rpm::InstallResolvableReport::INVALID
76 , excpt_r.asUserHistory()
77 , _level
78 );
79
80 switch (user) {
81 case rpm::InstallResolvableReport::RETRY:
82 return rpm::RpmInstallReport::RETRY;
83 case rpm::InstallResolvableReport::ABORT:
84 _abort = true;
85 return rpm::RpmInstallReport::ABORT;
86 case rpm::InstallResolvableReport::IGNORE:
87 return rpm::RpmInstallReport::IGNORE;
88 }
89
90 return rpm::RpmInstallReport::problem( excpt_r );
91 }
92
93 void RpmInstallPackageReceiver::finishInfo( const std::string & info_r )
94 {
95 _finishInfo = info_r;
96 }
97
99 void RpmInstallPackageReceiver::finish()
100 {
101 _report->finish( _resolvable, rpm::InstallResolvableReport::NO_ERROR, _finishInfo, _level );
102 }
103
105 void RpmInstallPackageReceiver::finish( Exception & excpt_r )
106 {
107 _report->finish( _resolvable, rpm::InstallResolvableReport::INVALID, std::string(), _level );
108 }
109
110 void RpmInstallPackageReceiver::tryLevel( target::rpm::InstallResolvableReport::RpmLevel level_r )
111 {
112 _level = level_r;
113 }
114
115
119
120 RpmRemovePackageReceiver::RpmRemovePackageReceiver (Resolvable::constPtr res)
121 : callback::ReceiveReport<rpm::RpmRemoveReport> ()
122 , _resolvable (std::move(res))
123 , _abort(false)
124 {
125 }
126
127 RpmRemovePackageReceiver::~RpmRemovePackageReceiver ()
128 {
129 }
130
131 void RpmRemovePackageReceiver::reportbegin()
132 {
133 }
134
135 void RpmRemovePackageReceiver::reportend()
136 {
137 }
138
140 void RpmRemovePackageReceiver::report( const UserData & userData_r )
141 {
142 if ( ! userData_r.haskey( "solvable" ) )
143 userData_r.set( "solvable", _resolvable->satSolvable() );
144 _report->report( userData_r );
145 }
146
147 void RpmRemovePackageReceiver::start( const std::string & name )
148 {
149 _report->start( _resolvable );
150 _abort = false;
151 }
152
157 bool RpmRemovePackageReceiver::progress( unsigned percent )
158 {
159 _abort = ! _report->progress( percent, _resolvable );
160 return _abort;
161 }
162
163 rpm::RpmRemoveReport::Action
164 RpmRemovePackageReceiver::problem( Exception & excpt_r )
165 {
166 rpm::RemoveResolvableReport::Action user =
167 _report->problem( _resolvable
168 , rpm::RemoveResolvableReport::INVALID
169 , excpt_r.asUserHistory()
170 );
171
172 switch (user) {
173 case rpm::RemoveResolvableReport::RETRY:
174 return rpm::RpmRemoveReport::RETRY;
175 case rpm::RemoveResolvableReport::ABORT:
176 _abort = true;
177 return rpm::RpmRemoveReport::ABORT;
178 case rpm::RemoveResolvableReport::IGNORE:
179 return rpm::RpmRemoveReport::IGNORE;
180 }
181
182 return rpm::RpmRemoveReport::problem( excpt_r );
183 }
184
185 void RpmRemovePackageReceiver::finishInfo( const std::string & info_r )
186 {
187 _finishInfo = info_r;
188 }
189
191 void RpmRemovePackageReceiver::finish()
192 {
193 _report->progress( 100, _resolvable );
194 _report->finish( _resolvable, rpm::RemoveResolvableReport::NO_ERROR, _finishInfo );
195 }
196
198 void RpmRemovePackageReceiver::finish( Exception & excpt_r )
199 {
200 _report->finish( _resolvable, rpm::RemoveResolvableReport::INVALID, std::string() );
201 }
202
204 } // namespace target
206
208} // namespace zypp
RpmCallbacks.h
TargetCallbackReceiver.h
zypp::Exception
Base class for Exception.
Definition Exception.h:153
zypp::Exception::asUserHistory
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
Definition Exception.cc:140
zypp::Resolvable::constPtr
TraitsType::constPtrType constPtr
Definition Resolvable.h:59
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zypp::target::RpmInstallPackageReceiver::_abort
bool _abort
Definition TargetCallbackReceiver.h:31
zypp::target::RpmInstallPackageReceiver::finish
virtual void finish()
Finish operation in case of success.
Definition TargetCallbackReceiver.cc:99
zypp::target::RpmInstallPackageReceiver::tryLevel
void tryLevel(target::rpm::InstallResolvableReport::RpmLevel level_r)
Definition TargetCallbackReceiver.cc:110
zypp::target::RpmInstallPackageReceiver::finishInfo
virtual void finishInfo(const std::string &info_r)
Additional rpm output to be reported in finish in case of success.
Definition TargetCallbackReceiver.cc:93
zypp::target::RpmInstallPackageReceiver::_finishInfo
std::string _finishInfo
Definition TargetCallbackReceiver.h:32
zypp::target::RpmInstallPackageReceiver::~RpmInstallPackageReceiver
virtual ~RpmInstallPackageReceiver()
Definition TargetCallbackReceiver.cc:34
zypp::target::RpmInstallPackageReceiver::start
virtual void start(const Pathname &name)
Start the operation.
Definition TargetCallbackReceiver.cc:54
zypp::target::RpmInstallPackageReceiver::report
void report(const UserData &userData_r) override
Forwards generic reports.
Definition TargetCallbackReceiver.cc:46
zypp::target::RpmInstallPackageReceiver::problem
virtual rpm::RpmInstallReport::Action problem(Exception &excpt_r)
inform user about a problem
Definition TargetCallbackReceiver.cc:71
zypp::target::RpmInstallPackageReceiver::RpmInstallPackageReceiver
RpmInstallPackageReceiver(Resolvable::constPtr res)
Definition TargetCallbackReceiver.cc:26
zypp::target::RpmInstallPackageReceiver::reportend
virtual void reportend()
Definition TargetCallbackReceiver.cc:42
zypp::target::RpmInstallPackageReceiver::_level
target::rpm::InstallResolvableReport::RpmLevel _level
Definition TargetCallbackReceiver.h:30
zypp::target::RpmInstallPackageReceiver::progress
virtual bool progress(unsigned percent)
Inform about progress Return true on abort.
Definition TargetCallbackReceiver.cc:64
zypp::target::RpmInstallPackageReceiver::reportbegin
virtual void reportbegin()
Definition TargetCallbackReceiver.cc:38
zypp::target::RpmInstallPackageReceiver::_report
callback::SendReport< rpm::InstallResolvableReport > _report
Definition TargetCallbackReceiver.h:28
zypp::target::RpmInstallPackageReceiver::_resolvable
Resolvable::constPtr _resolvable
Definition TargetCallbackReceiver.h:29
zypp::target::RpmRemovePackageReceiver::RpmRemovePackageReceiver
RpmRemovePackageReceiver(Resolvable::constPtr res)
RpmRemovePackageReceiver.
Definition TargetCallbackReceiver.cc:120
zypp::target::RpmRemovePackageReceiver::reportend
virtual void reportend()
Definition TargetCallbackReceiver.cc:135
zypp::target::RpmRemovePackageReceiver::_finishInfo
std::string _finishInfo
Definition TargetCallbackReceiver.h:78
zypp::target::RpmRemovePackageReceiver::reportbegin
virtual void reportbegin()
Definition TargetCallbackReceiver.cc:131
zypp::target::RpmRemovePackageReceiver::start
virtual void start(const std::string &name)
Definition TargetCallbackReceiver.cc:147
zypp::target::RpmRemovePackageReceiver::finish
virtual void finish()
Finish operation in case of success.
Definition TargetCallbackReceiver.cc:191
zypp::target::RpmRemovePackageReceiver::report
void report(const UserData &userData_r) override
Start the operation.
Definition TargetCallbackReceiver.cc:140
zypp::target::RpmRemovePackageReceiver::_report
callback::SendReport< rpm::RemoveResolvableReport > _report
Definition TargetCallbackReceiver.h:75
zypp::target::RpmRemovePackageReceiver::_resolvable
Resolvable::constPtr _resolvable
Definition TargetCallbackReceiver.h:76
zypp::target::RpmRemovePackageReceiver::progress
virtual bool progress(unsigned percent)
Inform about progress Return true on abort.
Definition TargetCallbackReceiver.cc:157
zypp::target::RpmRemovePackageReceiver::finishInfo
virtual void finishInfo(const std::string &info_r)
Additional rpm output to be reported in finish in case of success.
Definition TargetCallbackReceiver.cc:185
zypp::target::RpmRemovePackageReceiver::problem
virtual rpm::RpmRemoveReport::Action problem(Exception &excpt_r)
inform user about a problem
Definition TargetCallbackReceiver.cc:164
zypp::target::RpmRemovePackageReceiver::_abort
bool _abort
Definition TargetCallbackReceiver.h:77
zypp::target::RpmRemovePackageReceiver::~RpmRemovePackageReceiver
virtual ~RpmRemovePackageReceiver()
Definition TargetCallbackReceiver.cc:127
std
Definition Arch.h:364
zypp::callback
Callbacks light.
Definition Callback.h:146
zypp::target::rpm
Definition KeyRing.h:327
zypp::target
Definition KeyRing.h:325
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::target::rpm::InstallResolvableReport::Action
Action
Definition ZYppCallbacks.h:593
zypp::target::rpm::InstallResolvableReport::IGNORE
@ IGNORE
Definition ZYppCallbacks.h:596
zypp::target::rpm::InstallResolvableReport::RETRY
@ RETRY
Definition ZYppCallbacks.h:595
zypp::target::rpm::InstallResolvableReport::ABORT
@ ABORT
Definition ZYppCallbacks.h:594
zypp::target::rpm::InstallResolvableReport::NO_ERROR
@ NO_ERROR
Definition ZYppCallbacks.h:600
zypp::target::rpm::InstallResolvableReport::INVALID
@ INVALID
Definition ZYppCallbacks.h:603
zypp::target::rpm::InstallResolvableReport::RpmLevel
RpmLevel
Definition ZYppCallbacks.h:608
zypp::target::rpm::RemoveResolvableReport::INVALID
@ INVALID
Definition ZYppCallbacks.h:657
zypp::target::rpm::RemoveResolvableReport::NO_ERROR
@ NO_ERROR
Definition ZYppCallbacks.h:654
zypp::target::rpm::RemoveResolvableReport::Action
Action
Definition ZYppCallbacks.h:647
zypp::target::rpm::RemoveResolvableReport::RETRY
@ RETRY
Definition ZYppCallbacks.h:649
zypp::target::rpm::RemoveResolvableReport::IGNORE
@ IGNORE
Definition ZYppCallbacks.h:650
zypp::target::rpm::RemoveResolvableReport::ABORT
@ ABORT
Definition ZYppCallbacks.h:648
zypp::target::rpm::RpmInstallReport::Action
Action
Definition RpmCallbacks.h:73
zypp::target::rpm::RpmInstallReport::RETRY
@ RETRY
Definition RpmCallbacks.h:75
zypp::target::rpm::RpmInstallReport::IGNORE
@ IGNORE
Definition RpmCallbacks.h:76
zypp::target::rpm::RpmInstallReport::ABORT
@ ABORT
Definition RpmCallbacks.h:74
zypp::target::rpm::RpmInstallReport::problem
virtual Action problem(Exception &excpt_r)
Definition RpmCallbacks.h:97
zypp::target::rpm::RpmRemoveReport::Action
Action
Definition RpmCallbacks.h:36
zypp::target::rpm::RpmRemoveReport::ABORT
@ ABORT
Definition RpmCallbacks.h:37
zypp::target::rpm::RpmRemoveReport::RETRY
@ RETRY
Definition RpmCallbacks.h:38
zypp::target::rpm::RpmRemoveReport::IGNORE
@ IGNORE
Definition RpmCallbacks.h:39
zypp::target::rpm::RpmRemoveReport::problem
virtual Action problem(Exception &excpt_r)
Definition RpmCallbacks.h:52