1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/TargetCallbackReceiver.cc
14 #include <zypp/target/TargetCallbackReceiver.h>
16 #include <zypp/target/rpm/RpmCallbacks.h>
18 ///////////////////////////////////////////////////////////////////
20 { /////////////////////////////////////////////////////////////////
21 ///////////////////////////////////////////////////////////////////
23 { /////////////////////////////////////////////////////////////////
25 RpmInstallPackageReceiver::RpmInstallPackageReceiver (Resolvable::constPtr res)
26 : callback::ReceiveReport<rpm::RpmInstallReport> ()
28 , _level( target::rpm::InstallResolvableReport::RPM )
33 RpmInstallPackageReceiver::~RpmInstallPackageReceiver ()
37 void RpmInstallPackageReceiver::reportbegin()
41 void RpmInstallPackageReceiver::reportend()
45 /** Start the operation */
46 void RpmInstallPackageReceiver::start( const Pathname & name )
48 _report->start( _resolvable );
53 * Inform about progress
54 * Return true on abort
56 bool RpmInstallPackageReceiver::progress( unsigned percent )
58 _abort = ! _report->progress( percent, _resolvable );
62 rpm::RpmInstallReport::Action
63 RpmInstallPackageReceiver::problem( Exception & excpt_r )
65 rpm::InstallResolvableReport::Action user =
66 _report->problem( _resolvable
67 , rpm::InstallResolvableReport::INVALID
68 , excpt_r.asUserHistory()
73 case rpm::InstallResolvableReport::RETRY:
74 return rpm::RpmInstallReport::RETRY;
75 case rpm::InstallResolvableReport::ABORT:
77 return rpm::RpmInstallReport::ABORT;
78 case rpm::InstallResolvableReport::IGNORE:
79 return rpm::RpmInstallReport::IGNORE;
82 return rpm::RpmInstallReport::problem( excpt_r );
85 void RpmInstallPackageReceiver::finishInfo( const std::string & info_r )
90 /** Finish operation in case of success */
91 void RpmInstallPackageReceiver::finish()
93 _report->finish( _resolvable, rpm::InstallResolvableReport::NO_ERROR, _finishInfo, _level );
96 /** Finish operation in case of success */
97 void RpmInstallPackageReceiver::finish( Exception & excpt_r )
99 _report->finish( _resolvable, rpm::InstallResolvableReport::INVALID, std::string(), _level );
102 void RpmInstallPackageReceiver::tryLevel( target::rpm::InstallResolvableReport::RpmLevel level_r )
108 /////////////////////////////////////////////////////////////////
109 /// RpmRemovePackageReceiver
110 /////////////////////////////////////////////////////////////////
112 RpmRemovePackageReceiver::RpmRemovePackageReceiver (Resolvable::constPtr res)
113 : callback::ReceiveReport<rpm::RpmRemoveReport> ()
119 RpmRemovePackageReceiver::~RpmRemovePackageReceiver ()
123 void RpmRemovePackageReceiver::reportbegin()
127 void RpmRemovePackageReceiver::reportend()
131 /** Start the operation */
132 void RpmRemovePackageReceiver::start( const std::string & name )
134 _report->start( _resolvable );
139 * Inform about progress
140 * Return true on abort
142 bool RpmRemovePackageReceiver::progress( unsigned percent )
144 _abort = ! _report->progress( percent, _resolvable );
148 rpm::RpmRemoveReport::Action
149 RpmRemovePackageReceiver::problem( Exception & excpt_r )
151 rpm::RemoveResolvableReport::Action user =
152 _report->problem( _resolvable
153 , rpm::RemoveResolvableReport::INVALID
154 , excpt_r.asUserHistory()
158 case rpm::RemoveResolvableReport::RETRY:
159 return rpm::RpmRemoveReport::RETRY;
160 case rpm::RemoveResolvableReport::ABORT:
162 return rpm::RpmRemoveReport::ABORT;
163 case rpm::RemoveResolvableReport::IGNORE:
164 return rpm::RpmRemoveReport::IGNORE;
167 return rpm::RpmRemoveReport::problem( excpt_r );
170 void RpmRemovePackageReceiver::finishInfo( const std::string & info_r )
172 _finishInfo = info_r;
175 /** Finish operation in case of success */
176 void RpmRemovePackageReceiver::finish()
178 _report->progress( 100, _resolvable );
179 _report->finish( _resolvable, rpm::RemoveResolvableReport::NO_ERROR, _finishInfo );
182 /** Finish operation in case of success */
183 void RpmRemovePackageReceiver::finish( Exception & excpt_r )
185 _report->finish( _resolvable, rpm::RemoveResolvableReport::INVALID, std::string() );
188 /////////////////////////////////////////////////////////////////
189 } // namespace target
190 ///////////////////////////////////////////////////////////////////
192 /////////////////////////////////////////////////////////////////
194 ///////////////////////////////////////////////////////////////////