- Added PoolItem_Ref::statusReset. Resets the PoolItem status without
authorMichael Andres <ma@suse.de>
Tue, 23 May 2006 15:29:34 +0000 (15:29 +0000)
committerMichael Andres <ma@suse.de>
Tue, 23 May 2006 15:29:34 +0000 (15:29 +0000)
  loosing autoprotection (eg. for foreign vendor). (assists #177469)

package/libzypp.changes
zypp/PoolItem.cc
zypp/PoolItem.h
zypp/pool/PoolImpl.cc

index 52e4523..dbb2794 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Tue May 23 17:26:41 CEST 2006 - ma@suse.de
+
+- Added PoolItem_Ref::statusReset. Resets the PoolItem status without
+  loosing autoprotection (eg. for foreign vendor). (assists #177469)
+
+-------------------------------------------------------------------
 Tue May 23 17:04:04 CEST 2006 - jsrain@suse.cz
 
 - added mediaNr() to PatchRpm and DeltaRpm classes
@@ -8,7 +14,7 @@ Tue May 23 17:04:04 CEST 2006 - jsrain@suse.cz
 Tue May 23 15:58:04 CEST 2006 - dmacvicar@suse.de
 
 - enable YUM license to confirm.
-  needed for #174476 
+  needed for #174476
 - adapt store to serialize and read all new resobject fields
 - use install-time to now() when serializing (#174653)
 - rev 3427
index 2421a8b..2e322e3 100644 (file)
  *
 */
 #include <iostream>
-//#include "zypp/base/Logger.h"
+#include "zypp/base/Logger.h"
 
 #include "zypp/PoolItem.h"
+#include "zypp/Package.h"
+#include "zypp/VendorAttr.h"
 
 using std::endl;
 
@@ -34,14 +36,28 @@ namespace zypp
           const ResStatus & status_r = ResStatus() )
     : _status( status_r )
     , _resolvable( res_r )
-    {}
+    {
+      autoprotect();
+    }
 
     ResStatus & status() const
     { return _status; }
 
+    ResStatus & statusReset() const
+    {
+      if ( ! autoprotect() )
+        {
+          _status.setLock( false, zypp::ResStatus::USER );
+          _status.resetTransact( zypp::ResStatus::USER );
+        }
+      return _status;
+    }
+
     ResObject::constPtr resolvable() const
     { return _resolvable; }
 
+    bool autoprotect() const;
+
   private:
     mutable ResStatus   _status;
     ResObject::constPtr _resolvable;
@@ -89,6 +105,19 @@ namespace zypp
     return str;
   }
 
+  inline bool PoolItem_Ref::Impl::autoprotect() const
+  {
+    if ( _status.isInstalled()
+         && isKind<Package>( _resolvable )
+         && VendorAttr::instance().autoProtect( _resolvable->vendor() ) )
+      {
+        _status.setLock( true, zypp::ResStatus::USER );
+        MIL << "Protect vendor '" << _resolvable->vendor() << "' " << *this << endl;
+        return true;
+      }
+    return false;
+  }
+
   ///////////////////////////////////////////////////////////////////
   //
   //   CLASS NAME : PoolItem_Ref
@@ -139,6 +168,9 @@ namespace zypp
   ResStatus & PoolItem_Ref::status() const
   { return _pimpl->status(); }
 
+  ResStatus & PoolItem_Ref::statusReset() const
+  { return _pimpl->statusReset(); }
+
   ResObject::constPtr PoolItem_Ref::resolvable() const
   { return _pimpl->resolvable(); }
 
index 55a6376..6a21442 100644 (file)
@@ -63,9 +63,12 @@ namespace zypp
     ~PoolItem_Ref();
 
   public:
-    /** Returns */
+    /** Returns the current status. */
     ResStatus & status() const;
 
+    /** Reset status (applies autoprotection). */
+    ResStatus & statusReset() const;
+
     /** Returns the ResObject::constPtr.
      * \see \ref operator->
     */
index 73409f8..7f9c482 100644 (file)
@@ -244,19 +244,10 @@ namespace zypp
        * ------------------------------------------------------------------------------- */
       PoolImpl::Item item( ptr_r, ResStatus (_installed) );
 
-
       /* -------------------------------------------------------------------------------
        * 3.) Status adjustments
        * ------------------------------------------------------------------------------- */
-      if ( _installed )
-        {
-          Package::constPtr pkgptr( asKind<Package>( ptr_r ) );
-          if ( pkgptr && VendorAttr::instance().autoProtect( pkgptr->vendor() ) )
-            {
-              item.status().setTransactValue( ResStatus::LOCKED, ResStatus::USER );
-              MIL << "Protect vendor '" << pkgptr->vendor() << "' " << *pkgptr << endl;
-            }
-        }
+      // Foreign vendor protection handled in PoolItem ctor.
 
       /* -------------------------------------------------------------------------------
        * 3.) Feed