-------------------------------------------------------------------
+Fri Aug 15 15:30:32 CEST 2008 - ma@suse.de
+
+- Fixes to Selectable doing staus manipulation on non-USER level.
+- revision 10873
+
+-------------------------------------------------------------------
Fri Aug 15 14:23:02 CEST 2008 - ma@suse.de
- Add method ZYpp::getTarget that returns the Target or a NULL pointer,
PoolItem Selectable::candidateObj() const
{ return _pimpl->candidateObj(); }
- PoolItem Selectable::setCandidate( ResObject::constPtr byUser_r )
- { return _pimpl->setCandidate( byUser_r ); }
+ PoolItem Selectable::setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r )
+ { return _pimpl->setCandidate( newCandidate_r, causer_r ); }
+
+ PoolItem Selectable::setCandidate( ResObject::constPtr newCandidate_r, ResStatus::TransactByValue causer_r )
+ { return _pimpl->setCandidate( PoolItem( newCandidate_r ), causer_r ); }
PoolItem Selectable::theObj() const
{ return _pimpl->theObj(); }
* \return The new candidate, or NULL if choice was invalid
* (NULL or not among availableObjs). An invalid choice
* selects the default candidate.
+ * In case the causer is not \c ResStatus::USER the operation
+ * may also fail if there are insufficient permissions to change
+ * a transacting candidate.
*/
- PoolItem setCandidate( ResObject::constPtr byUser_r );
+ PoolItem setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
+ /** \overload */
+ PoolItem setCandidate( ResObject::constPtr newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
/** Best among all objects. */
PoolItem theObj() const;
return false;
}
- PoolItem Selectable::Impl::setCandidate( ResObject::constPtr byUser_r )
+ PoolItem Selectable::Impl::setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r )
{
- _candidate = PoolItem();
+ PoolItem newCandidate;
- if ( byUser_r ) // must be in available list
+ if ( newCandidate_r ) // must be in available list
+ {
+ for_( it, availableBegin(), availableEnd() )
{
- for ( available_const_iterator it = availableBegin();
- it != availableEnd(); ++it )
- {
- if ( it->resolvable() == byUser_r )
- {
- _candidate = *it;
- break;
- }
- }
+ if ( *it == newCandidate_r )
+ {
+ newCandidate = *it;
+ break;
+ }
}
+ }
- if ( _candidate )
+ if ( newCandidate )
+ {
+ PoolItem trans( transactingCandidate() );
+ if ( trans && trans != newCandidate )
{
- PoolItem trans( transactingCandidate() );
- if ( trans && trans != _candidate )
- {
- // adjust transact to the new cancidate
- trans.status().setTransact( false, ResStatus::USER );
- _candidate.status().setTransact( true, ResStatus::USER );
- }
+ // adjust transact to the new cancidate
+ if ( trans.status().maySetTransact( false, causer_r )
+ && newCandidate.status().maySetTransact( true, causer_r ) )
+ {
+ trans.status().setTransact( false, causer_r );
+ newCandidate.status().setTransact( true, causer_r );
+ }
+ else
+ {
+ // No permission to change a transacting candidate.
+ // Leave _candidate untouched and return NULL.
+ return PoolItem();
+ }
}
+ }
- return _candidate;
+ return _candidate = newCandidate;
}
ResStatus::TransactByValue Selectable::Impl::modifiedBy() const
else
_availableItems.insert( *it );
}
- setCandidate( NULL );
}
public:
* \return The new userCandidate or NULL if choice was invalid
* (not among availableObjs).
*/
- PoolItem setCandidate( ResObject::constPtr byUser_r );
+ PoolItem setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r );
/** Best among all objects. */
PoolItem theObj() const