Product now retrieves all attributes from the solv file.
authorMichael Andres <ma@suse.de>
Fri, 9 May 2008 21:19:13 +0000 (21:19 +0000)
committerMichael Andres <ma@suse.de>
Fri, 9 May 2008 21:19:13 +0000 (21:19 +0000)
VERSION.cmake
devel/devel.ma/NewPool.cc
package/libzypp.changes
zypp/Product.cc
zypp/sat/SolvAttr.cc
zypp/sat/SolvAttr.h

index 395b143..41013c0 100644 (file)
@@ -47,4 +47,4 @@
 SET(LIBZYPP_MAJOR "4")
 SET(LIBZYPP_MINOR "21")
 SET(LIBZYPP_COMPATMINOR "21")
-SET(LIBZYPP_PATCH "0")
+SET(LIBZYPP_PATCH "1")
index c451c0c..a7cf65b 100644 (file)
@@ -459,12 +459,6 @@ namespace zypp
 {
 }
 
-bool PCDC( const parser::ProductConfData & d )
-{
-  SEC << d << endl;
-  return true;
-}
-
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -478,12 +472,6 @@ try {
   INT << "===[START]==========================================" << endl;
   ZConfig::instance();
 
-  parser::ProductConfReader::scanDir( &PCDC, ZConfig::instance().productsPath() );
-  ///////////////////////////////////////////////////////////////////
-  INT << "===[END]============================================" << endl << endl;
-  zypp::base::LogControl::instance().logNothing();
-  return 0;
-
   ResPool   pool( ResPool::instance() );
   sat::Pool satpool( sat::Pool::instance() );
 
@@ -571,6 +559,21 @@ try {
   ///////////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////////
 
+  for_( it, pool.byKindBegin<Product>(), pool.byKindEnd<Product>() )
+  {
+    Product::constPtr p( asKind<Product>( *it ) );
+    USR << p << endl;
+    MIL << p->type() << endl;
+    MIL << p->releaseNotesUrl() << endl;
+    MIL << p->updateUrls() << endl;
+    MIL << p->extraUrls() << endl;
+    MIL << p->optionalUrls() << endl;
+    MIL << p->flags() << endl;
+    MIL << p->shortName() << endl;
+    MIL << p->distributionName() << endl;
+    MIL << p->distributionEdition() << endl;
+  }
+
 
   ///////////////////////////////////////////////////////////////////
   INT << "===[END]============================================" << endl << endl;
index d07e6a0..2e95741 100644 (file)
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Fri May  9 23:15:53 CEST 2008 - ma@suse.de
+
+- Product now retrieves all attributes from the solv file.
+- version 4.21.1
+- revision 10031
+
+-------------------------------------------------------------------
 Fri May  9 21:28:42 CEST 2008 - ma@suse.de
 
 - Add zypp.conf option configdir (/etc/zypp) and arrange 
index 3fdb728..80c7d00 100644 (file)
@@ -9,15 +9,48 @@
 /** \file zypp/Product.cc
  *
 */
+#include <iostream>
+#include "zypp/base/LogTools.h"
+
 #include "zypp/Product.h"
 #include "zypp/Url.h"
 
+#include "zypp/sat/LookupAttr.h"
+
+using std::endl;
+
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
 
   IMPL_PTR_TYPE(Product);
 
+  namespace
+  {
+    void fillList( std::list<Url> & ret_r, sat::Solvable solv_r, sat::SolvAttr attr_r )
+    {
+      sat::LookupAttr query( attr_r, solv_r );
+      for_( it, query.begin(), query.end() )
+      {
+        try // ignore malformed urls
+        {
+          ret_r.push_back( Url( it.asString() ) );
+        }
+        catch( const url::UrlException & )
+        {}
+      }
+    }
+
+    void fillList( std::list<std::string> & ret_r, sat::Solvable solv_r, sat::SolvAttr attr_r )
+    {
+      sat::LookupAttr query( attr_r, solv_r );
+      for_( it, query.begin(), query.end() )
+      {
+        ret_r.push_back( it.asString() );
+      }
+    }
+  }
+
   ///////////////////////////////////////////////////////////////////
   //
   //   METHOD NAME : Product::Product
@@ -40,44 +73,58 @@ namespace zypp
   //   Package interface forwarded to implementation
   //
   ///////////////////////////////////////////////////////////////////
-#warning DUMMY type
+
   std::string Product::type() const
-  { return std::string(); }
+  { return lookupStrAttribute( sat::SolvAttr::productType ); }
 
-#warning DUMMY releaseNotesUrl
   Url Product::releaseNotesUrl() const
-  { return Url(); }
+  {
+    std::list<Url> ret;
+    fillList( ret, satSolvable(), sat::SolvAttr::productRelnotesurl );
+    if ( ! ret.empty() )
+      return  ret.front();
+    return Url();
+  }
 
-#warning DUMMY updateUrls
   std::list<Url> Product::updateUrls() const
-  { return std::list<Url>(); }
+  {
+    std::list<Url> ret;
+    fillList( ret, satSolvable(), sat::SolvAttr::productUpdateurls );
+    return ret;
+  }
 
-#warning DUMMY extraUrls
   std::list<Url> Product::extraUrls() const
-  { return std::list<Url>(); }
+  {
+    std::list<Url> ret;
+    fillList( ret, satSolvable(), sat::SolvAttr::productExtraurls );
+    return ret;
+  }
 
-#warning DUMMY optionalUrls
   std::list<Url> Product::optionalUrls() const
-  { return std::list<Url>(); }
+  {
+    std::list<Url> ret;
+    fillList( ret, satSolvable(), sat::SolvAttr::productOptionalurls );
+    return ret;
+  }
 
-#warning DUMMY flags
   std::list<std::string> Product::flags() const
-  { return std::list<std::string>(); }
+  {
+    std::list<std::string> ret;
+    fillList( ret, satSolvable(), sat::SolvAttr::productFlags );
+    return ret;
+  }
 
-#warning DUMMY shortName
   std::string Product::shortName() const
-  { return std::string(); }
+  { return lookupStrAttribute( sat::SolvAttr::productShortlabel ); }
 
   std::string Product::longName( const Locale & lang_r ) const
   { return summary( lang_r ); }
 
-#warning DUMMY distributionName
   std::string Product::distributionName() const
-  { return std::string(); }
+  { return lookupStrAttribute( sat::SolvAttr::productDistproduct ); }
 
-#warning DUMMY distributionEdition
   Edition Product::distributionEdition() const
-  { return Edition(); }
+  { return Edition( lookupStrAttribute( sat::SolvAttr::productDistversion ) ); }
 
 
   /////////////////////////////////////////////////////////////////
index f9d212d..99700c3 100644 (file)
@@ -69,7 +69,7 @@ namespace sat
   // patch
   const SolvAttr SolvAttr::patchcategory            ( SOLVABLE_PATCHCATEGORY );
   const SolvAttr SolvAttr::rebootSuggested          ( UPDATE_REBOOT );
-  const SolvAttr SolvAttr::restartSuggested          ( UPDATE_RESTART );
+  const SolvAttr SolvAttr::restartSuggested         ( UPDATE_RESTART );
   const SolvAttr SolvAttr::updateCollectionName     ( UPDATE_COLLECTION_NAME );
   const SolvAttr SolvAttr::updateCollectionEvr      ( UPDATE_COLLECTION_EVR );
   const SolvAttr SolvAttr::updateCollectionArch     ( UPDATE_COLLECTION_ARCH );
@@ -90,6 +90,17 @@ namespace sat
   const SolvAttr SolvAttr::includes     ( SOLVABLE_INCLUDES );
   const SolvAttr SolvAttr::extends      ( SOLVABLE_EXTENDS );
 
+  // product
+  const SolvAttr SolvAttr::productShortlabel   ( PRODUCT_SHORTLABEL );
+  const SolvAttr SolvAttr::productDistproduct  ( PRODUCT_DISTPRODUCT );
+  const SolvAttr SolvAttr::productDistversion  ( PRODUCT_DISTVERSION );
+  const SolvAttr SolvAttr::productType         ( PRODUCT_TYPE );
+  const SolvAttr SolvAttr::productRelnotesurl  ( PRODUCT_RELNOTESURL );
+  const SolvAttr SolvAttr::productUpdateurls   ( PRODUCT_UPDATEURLS );
+  const SolvAttr SolvAttr::productExtraurls    ( PRODUCT_EXTRAURLS );
+  const SolvAttr SolvAttr::productOptionalurls ( PRODUCT_OPTIONALURLS );
+  const SolvAttr SolvAttr::productFlags        ( PRODUCT_FLAGS );
+
 } // namespace sat
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
index eac8655..51de463 100644 (file)
@@ -41,6 +41,8 @@ namespace sat
       /** Value representing \c noAttr (<tt>""</tt>)*/
       static const SolvAttr noAttr;
 
+      /** \name common */
+      //@{
       static const SolvAttr name;
       static const SolvAttr summary;
       static const SolvAttr description;
@@ -52,8 +54,10 @@ namespace sat
       static const SolvAttr installsize;
       static const SolvAttr downloadsize;
       static const SolvAttr diskusage;
+      //@}
 
-      //package
+      /** \name package */
+      //@{
       static const SolvAttr checksum;
       static const SolvAttr mediadir;
       static const SolvAttr medianr;
@@ -73,8 +77,10 @@ namespace sat
       static const SolvAttr sourcename;
       static const SolvAttr sourceevr;
       static const SolvAttr headerend;
+      //@}
 
-      // patch
+       /** \name patch */
+      //@{
       static const SolvAttr patchcategory;
       static const SolvAttr rebootSuggested;
       static const SolvAttr restartSuggested;
@@ -87,8 +93,10 @@ namespace sat
       static const SolvAttr updateReferenceHref;
       static const SolvAttr updateReferenceId;
       static const SolvAttr updateReferenceTitle;
-    
-      // pattern
+      //@}
+
+      /** \name pattern */
+      //@{
       static const SolvAttr isvisible;
       static const SolvAttr icon;
       static const SolvAttr order;
@@ -97,9 +105,22 @@ namespace sat
       static const SolvAttr script;
       static const SolvAttr includes;
       static const SolvAttr extends;
+      //@}
 
+      /** \name product */
+      //@{
+      static const SolvAttr productShortlabel;
+      static const SolvAttr productDistproduct;
+      static const SolvAttr productDistversion;
+      static const SolvAttr productType;
+      static const SolvAttr productRelnotesurl;
+      static const SolvAttr productUpdateurls;
+      static const SolvAttr productExtraurls;
+      static const SolvAttr productOptionalurls;
+      static const SolvAttr productFlags;
       //@}
 
+      //@}
     public:
       /** Default ctor: \ref noAttr */
       SolvAttr() {}