libzypp: zypp/target/TargetCallbackReceiver.cc Source File

libzypp 17.25.10

TargetCallbackReceiver.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include <iostream>
13
14 #include <zypp/target/TargetCallbackReceiver.h>
15
16 #include <zypp/target/rpm/RpmCallbacks.h>
17
19 namespace zypp
20 {
22 namespace target
23 {
24
25 RpmInstallPackageReceiver::RpmInstallPackageReceiver (Resolvable::constPtr res)
26 : callback::ReceiveReport<rpm::RpmInstallReport> ()
27 , _resolvable (res)
28 , _level( target::rpm::InstallResolvableReport::RPM )
29 , _abort (false)
30 {
31 }
32
33 RpmInstallPackageReceiver::~RpmInstallPackageReceiver ()
34 {
35 }
36
37 void RpmInstallPackageReceiver::reportbegin()
38 {
39 }
40
41 void RpmInstallPackageReceiver::reportend()
42 {
43 }
44
45 void RpmInstallPackageReceiver::report( const UserData & userData_r )
46 {
47 if ( ! userData_r.haskey( "solvable" ) )
48 userData_r.set( "solvable", _resolvable->satSolvable() );
49 _report->report( userData_r );
50 }
51
53 void RpmInstallPackageReceiver::start( const Pathname & name )
54 {
55 _report->start( _resolvable );
56 _abort = false;
57 }
58
63 bool RpmInstallPackageReceiver::progress( unsigned percent )
64 {
65 _abort = ! _report->progress( percent, _resolvable );
66 return _abort;
67 }
68
69 rpm::RpmInstallReport::Action
70 RpmInstallPackageReceiver::problem( Exception & excpt_r )
71 {
72 rpm::InstallResolvableReport::Action user =
73 _report->problem( _resolvable
74 , rpm::InstallResolvableReport::INVALID
75 , excpt_r.asUserHistory()
76 , _level
77 );
78
79 switch (user) {
80 case rpm::InstallResolvableReport::RETRY:
81 return rpm::RpmInstallReport::RETRY;
82 case rpm::InstallResolvableReport::ABORT:
83 _abort = true;
84 return rpm::RpmInstallReport::ABORT;
85 case rpm::InstallResolvableReport::IGNORE:
86 return rpm::RpmInstallReport::IGNORE;
87 }
88
89 return rpm::RpmInstallReport::problem( excpt_r );
90 }
91
92 void RpmInstallPackageReceiver::finishInfo( const std::string & info_r )
93 {
94 _finishInfo = info_r;
95 }
96
98 void RpmInstallPackageReceiver::finish()
99 {
100 _report->finish( _resolvable, rpm::InstallResolvableReport::NO_ERROR, _finishInfo, _level );
101 }
102
104 void RpmInstallPackageReceiver::finish( Exception & excpt_r )
105 {
106 _report->finish( _resolvable, rpm::InstallResolvableReport::INVALID, std::string(), _level );
107 }
108
109 void RpmInstallPackageReceiver::tryLevel( target::rpm::InstallResolvableReport::RpmLevel level_r )
110 {
111 _level = level_r;
112 }
113
114
118
119 RpmRemovePackageReceiver::RpmRemovePackageReceiver (Resolvable::constPtr res)
120 : callback::ReceiveReport<rpm::RpmRemoveReport> ()
121 , _resolvable (res)
122 , _abort(false)
123 {
124 }
125
126 RpmRemovePackageReceiver::~RpmRemovePackageReceiver ()
127 {
128 }
129
130 void RpmRemovePackageReceiver::reportbegin()
131 {
132 }
133
134 void RpmRemovePackageReceiver::reportend()
135 {
136 }
137
139 void RpmRemovePackageReceiver::report( const UserData & userData_r )
140 {
141 if ( ! userData_r.haskey( "solvable" ) )
142 userData_r.set( "solvable", _resolvable->satSolvable() );
143 _report->report( userData_r );
144 }
145
146 void RpmRemovePackageReceiver::start( const std::string & name )
147 {
148 _report->start( _resolvable );
149 _abort = false;
150 }
151
156 bool RpmRemovePackageReceiver::progress( unsigned percent )
157 {
158 _abort = ! _report->progress( percent, _resolvable );
159 return _abort;
160 }
161
162 rpm::RpmRemoveReport::Action
163 RpmRemovePackageReceiver::problem( Exception & excpt_r )
164 {
165 rpm::RemoveResolvableReport::Action user =
166 _report->problem( _resolvable
167 , rpm::RemoveResolvableReport::INVALID
168 , excpt_r.asUserHistory()
169 );
170
171 switch (user) {
172 case rpm::RemoveResolvableReport::RETRY:
173 return rpm::RpmRemoveReport::RETRY;
174 case rpm::RemoveResolvableReport::ABORT:
175 _abort = true;
176 return rpm::RpmRemoveReport::ABORT;
177 case rpm::RemoveResolvableReport::IGNORE:
178 return rpm::RpmRemoveReport::IGNORE;
179 }
180
181 return rpm::RpmRemoveReport::problem( excpt_r );
182 }
183
184 void RpmRemovePackageReceiver::finishInfo( const std::string & info_r )
185 {
186 _finishInfo = info_r;
187 }
188
190 void RpmRemovePackageReceiver::finish()
191 {
192 _report->progress( 100, _resolvable );
193 _report->finish( _resolvable, rpm::RemoveResolvableReport::NO_ERROR, _finishInfo );
194 }
195
197 void RpmRemovePackageReceiver::finish( Exception & excpt_r )
198 {
199 _report->finish( _resolvable, rpm::RemoveResolvableReport::INVALID, std::string() );
200 }
201
203 } // namespace target
205
207 } // namespace zypp
RpmCallbacks.h
TargetCallbackReceiver.h
zypp::Exception
Base class for Exception.
Definition: Exception.h:146
zypp::Exception::asUserHistory
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
Definition: Exception.cc:91
zypp::Resolvable::constPtr
TraitsType::constPtrType constPtr
Definition: Resolvable.h:59
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:45
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:98
zypp::target::RpmInstallPackageReceiver::tryLevel
void tryLevel(target::rpm::InstallResolvableReport::RpmLevel level_r)
Definition: TargetCallbackReceiver.cc:109
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:92
zypp::target::RpmInstallPackageReceiver::_finishInfo
std::string _finishInfo
Definition: TargetCallbackReceiver.h:32
zypp::target::RpmInstallPackageReceiver::~RpmInstallPackageReceiver
virtual ~RpmInstallPackageReceiver()
Definition: TargetCallbackReceiver.cc:33
zypp::target::RpmInstallPackageReceiver::start
virtual void start(const Pathname &name)
Start the operation.
Definition: TargetCallbackReceiver.cc:53
zypp::target::RpmInstallPackageReceiver::report
void report(const UserData &userData_r) override
Forwards generic reports.
Definition: TargetCallbackReceiver.cc:45
zypp::target::RpmInstallPackageReceiver::problem
virtual rpm::RpmInstallReport::Action problem(Exception &excpt_r)
inform user about a problem
Definition: TargetCallbackReceiver.cc:70
zypp::target::RpmInstallPackageReceiver::RpmInstallPackageReceiver
RpmInstallPackageReceiver(Resolvable::constPtr res)
Definition: TargetCallbackReceiver.cc:25
zypp::target::RpmInstallPackageReceiver::reportend
virtual void reportend()
Definition: TargetCallbackReceiver.cc:41
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:63
zypp::target::RpmInstallPackageReceiver::reportbegin
virtual void reportbegin()
Definition: TargetCallbackReceiver.cc:37
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:119
zypp::target::RpmRemovePackageReceiver::reportend
virtual void reportend()
Definition: TargetCallbackReceiver.cc:134
zypp::target::RpmRemovePackageReceiver::_finishInfo
std::string _finishInfo
Definition: TargetCallbackReceiver.h:78
zypp::target::RpmRemovePackageReceiver::reportbegin
virtual void reportbegin()
Definition: TargetCallbackReceiver.cc:130
zypp::target::RpmRemovePackageReceiver::start
virtual void start(const std::string &name)
Definition: TargetCallbackReceiver.cc:146
zypp::target::RpmRemovePackageReceiver::finish
virtual void finish()
Finish operation in case of success.
Definition: TargetCallbackReceiver.cc:190
zypp::target::RpmRemovePackageReceiver::report
void report(const UserData &userData_r) override
Start the operation.
Definition: TargetCallbackReceiver.cc:139
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:156
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:184
zypp::target::RpmRemovePackageReceiver::problem
virtual rpm::RpmRemoveReport::Action problem(Exception &excpt_r)
inform user about a problem
Definition: TargetCallbackReceiver.cc:163
zypp::target::RpmRemovePackageReceiver::_abort
bool _abort
Definition: TargetCallbackReceiver.h:77
zypp::target::RpmRemovePackageReceiver::~RpmRemovePackageReceiver
virtual ~RpmRemovePackageReceiver()
Definition: TargetCallbackReceiver.cc:126
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::target::rpm::InstallResolvableReport::Action
Action
Definition: ZYppCallbacks.h:518
zypp::target::rpm::InstallResolvableReport::IGNORE
@ IGNORE
Definition: ZYppCallbacks.h:521
zypp::target::rpm::InstallResolvableReport::RETRY
@ RETRY
Definition: ZYppCallbacks.h:520
zypp::target::rpm::InstallResolvableReport::ABORT
@ ABORT
Definition: ZYppCallbacks.h:519
zypp::target::rpm::InstallResolvableReport::NO_ERROR
@ NO_ERROR
Definition: ZYppCallbacks.h:525
zypp::target::rpm::InstallResolvableReport::INVALID
@ INVALID
Definition: ZYppCallbacks.h:528
zypp::target::rpm::InstallResolvableReport::RpmLevel
RpmLevel
Definition: ZYppCallbacks.h:533
zypp::target::rpm::RemoveResolvableReport::INVALID
@ INVALID
Definition: ZYppCallbacks.h:582
zypp::target::rpm::RemoveResolvableReport::NO_ERROR
@ NO_ERROR
Definition: ZYppCallbacks.h:579
zypp::target::rpm::RemoveResolvableReport::Action
Action
Definition: ZYppCallbacks.h:572
zypp::target::rpm::RemoveResolvableReport::RETRY
@ RETRY
Definition: ZYppCallbacks.h:574
zypp::target::rpm::RemoveResolvableReport::IGNORE
@ IGNORE
Definition: ZYppCallbacks.h:575
zypp::target::rpm::RemoveResolvableReport::ABORT
@ ABORT
Definition: ZYppCallbacks.h:573
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