From: Michael Andres Date: Thu, 3 Dec 2009 13:02:20 +0000 (+0100) Subject: Compute proper Selectable::pickStatus X-Git-Tag: 6.27.0~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fdac326bcab7425ca021d4910e4668bd3ff95d31;p=platform%2Fupstream%2Flibzypp.git Compute proper Selectable::pickStatus --- diff --git a/zypp/ui/SelectableImpl.cc b/zypp/ui/SelectableImpl.cc index 8a118ef..877d636 100644 --- a/zypp/ui/SelectableImpl.cc +++ b/zypp/ui/SelectableImpl.cc @@ -340,11 +340,80 @@ namespace zypp return pi_r.status().setTransact( yesno_r, causer_r ); } + /////////////////////////////////////////////////////////////////// + Status Selectable::Impl::pickStatus( const PoolItem & pi_r ) const { - return status(); + if ( pi_r.satSolvable().ident() == ident() ) + { + if ( pi_r.satSolvable().isSystem() ) + { + // have installed! + if ( pi_r.status().isLocked() ) + return S_Protected; + + // at least one identical available transacing? + for_( it, _availableItems.begin(), _availableItems.end() ) + { + if ( identical( *it, pi_r ) ) + { + if ( (*it).status().transacts() ) + return( (*it).status().isByUser() ? S_Update : S_AutoUpdate ); + } + } + + // no update, so maybe delete? + if ( pi_r.status().transacts() ) + return ( pi_r.status().isByUser() ? S_Del : S_AutoDel ); + + // keep + return S_KeepInstalled; + } + else + { + // have available! + if ( pi_r.status().isLocked() ) + return S_Taboo; + + // have identical installed? (maybe transacting): + PoolItem inst; + for_( it, _installedItems.begin(), _installedItems.end() ) + { + if ( identical( *it, pi_r ) ) + { + if ( (*it).status().transacts() ) + { + inst = *it; + break; + } + if ( !inst ) + inst = *it; + } + } + + // check for inst/update + if ( pi_r.status().transacts() ) + { + if ( inst ) + return( pi_r.status().isByUser() ? S_Update : S_AutoUpdate ); + else + return( pi_r.status().isByUser() ? S_Install : S_AutoInstall ); + } + + // no inst/update, so maybe delete? + if ( ! inst ) + return S_NoInst; + + if ( inst.status().transacts() ) + return( inst.status().isByUser() ? S_Del : S_AutoDel ); + + return S_KeepInstalled; + } + } + return Status(-1); // not my PoolItem } + /////////////////////////////////////////////////////////////////// ResStatus::TransactByValue Selectable::Impl::modifiedBy() const {