ref: refs/heads/master
commit 8509e945852ad0c32ac37c6f9ea991598fbfabfd
Author: Michael Andres
Date: Thu Oct 29 14:41:53 2009 +0100
Selectable: add setOnSystem to install a package unless an identical one is already installed.
---
zypp/ui/Selectable.cc | 7 +++++++
zypp/ui/Selectable.h | 8 ++++++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/zypp/ui/Selectable.cc b/zypp/ui/Selectable.cc
index 1c16d94..451c466 100644
--- a/zypp/ui/Selectable.cc
+++ b/zypp/ui/Selectable.cc
@@ -88,6 +88,13 @@ namespace zypp
PoolItem Selectable::setCandidate( ResObject::constPtr newCandidate_r, ResStatus::TransactByValue causer_r )
{ return _pimpl->setCandidate( PoolItem( newCandidate_r ), causer_r ); }
+ bool Selectable::setOnSystem( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r )
+ {
+ if ( identicalInstalled( newCandidate_r ) )
+ return setFate( UNMODIFIED, causer_r );
+ return setCandidate( newCandidate_r, causer_r ) && setFate( TO_INSTALL, causer_r );
+ }
+
PoolItem Selectable::theObj() const
{ return _pimpl->theObj(); }
diff --git a/zypp/ui/Selectable.h b/zypp/ui/Selectable.h
index 65b2faf..0331cab 100644
--- a/zypp/ui/Selectable.h
+++ b/zypp/ui/Selectable.h
@@ -191,6 +191,14 @@ namespace zypp
/** \overload */
PoolItem setCandidate( ResObject::constPtr newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
+ /** Arrange the specified candidate (out of available objects) to be on system after commit.
+ * If the specified candidate is not already installed (\ref identicalInstalled),
+ * and the \a causer_r has sufficient permisssion, then \a newCandidate_r is set as the new
+ * candidate (\ref setCandidate) and selected for installation.
+ * \returns \c True if \a newCandidate_r is already installed or sucessfully selected for installation.
+ */
+ bool setOnSystem( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
+
/** An object you could use as pars pro toto.
*
* \return the \ref candidateObj, or ,if no available objects
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org