- add Target::baseProduct for convenence. disable flavor header for now
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 28 Oct 2008 16:31:13 +0000 (16:31 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 28 Oct 2008 16:31:13 +0000 (16:31 +0000)
until I find a better solution

zypp/Target.cc
zypp/Target.h
zypp/media/MediaAria2c.cc
zypp/media/MediaAria2c.h
zypp/media/MediaCurl.cc
zypp/media/MediaCurl.h
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h

index 4c4731e..5a894dd 100644 (file)
@@ -109,6 +109,10 @@ namespace zypp
   std::string Target::distributionVersion() const
   { return _pimpl->distributionVersion(); }
 
+  Product::constPtr Target::baseProduct() const
+  { return _pimpl->baseProduct(); }
+    
+
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
index 8cc0097..252c7bc 100644 (file)
@@ -19,6 +19,7 @@
 #include "zypp/base/PtrTypes.h"
 #include "zypp/base/Deprecated.h"
 
+#include "zypp/Product.h"
 #include "zypp/Pathname.h"
 #include "zypp/ResPool.h"
 
@@ -104,6 +105,24 @@ namespace zypp
     /** return the last modification date of the target */
     Date timestamp() const;
 
+    /**
+     * returns the target base installed product, also known as
+     * the distribution or platform.
+     *
+     * returns 0 if there is no base installed product in the
+     * pool.
+     *
+     * \note this method requires the target to be loaded,
+     * otherwise it will return 0 as no product is found.
+     *
+     * if you require some base product attributes when the
+     * target is not loaded into the pool, see
+     * \ref targetDistribution , \ref targetDistributionRelease
+     * and \ref distributionVersion that obtain the data 
+     * on demand from the installed product information.
+     */
+    Product::constPtr baseProduct() const;
+
     /** \name Base product and registration. */
     //@{
     /** The targets distribution release string (/etc/SuSE-release)
index dadf40a..1aec7bc 100644 (file)
@@ -79,7 +79,7 @@ MediaAria2c::existsAria2cmd()
         return false;
 }
 
-const char *const MediaAria2c::anonymousIdHeader()
+static const char *const anonymousIdHeader()
 {
   // we need to add the release and identifier to the
   // agent string.
@@ -200,7 +200,6 @@ void MediaAria2c::attachTo (bool next)
   
    // add the anonymous id.
    _args.push_back(str::form("--header=%s", anonymousIdHeader() ));
-
   // TODO add debug option
    
   // Transfer timeout
index fcbc629..4b83552 100644 (file)
@@ -88,10 +88,7 @@ class MediaAria2c : public MediaHandler {
 
   protected:
 
-    /** The user agent string */
     static const char *const agentString();   
-    /** anonymous id header used to count unique users */
-    static const char *const anonymousIdHeader();    
 
   private:
 
index 7c3cf3c..d22af54 100644 (file)
@@ -185,7 +185,7 @@ namespace zypp {
 
 Pathname MediaCurl::_cookieFile = "/var/lib/YaST2/cookies";
 
-const char *const MediaCurl::anonymousIdHeader()
+static const char *const anonymousIdHeader()
 {
   // we need to add the release and identifier to the
   // agent string.
@@ -209,8 +209,8 @@ const char *const MediaCurl::anonymousIdHeader()
   );
   return _value.c_str();
 }
-      
-const char *const MediaCurl::agentString()
+     
+static const char *const agentString()
 {
   // we need to add the release and identifier to the
   // agent string.
@@ -706,6 +706,7 @@ void MediaCurl::attachTo (bool next)
 
   // now add the anonymous id header
   _customHeaders = curl_slist_append(_customHeaders, anonymousIdHeader());
+  
   ret = curl_easy_setopt ( _curl, CURLOPT_HTTPHEADER, _customHeaders );
     
   if ( ret != 0) {
index 9a0f22b..248341b 100644 (file)
@@ -94,13 +94,6 @@ class MediaCurl : public MediaHandler {
 
     static int progressCallback( void *clientp, double dltotal, double dlnow,
                                  double ultotal, double ulnow );
-
-    /** The user agent string */
-    static const char *const agentString();
-
-    /** anonymous id header used to count unique users */
-    static const char *const anonymousIdHeader();
-
   private:
     /**
      * Return a comma separated list of available authentication methods
index 7aff868..1e8892c 100644 (file)
@@ -936,6 +936,22 @@ namespace zypp
       }
     }
 
+    Product::constPtr TargetImpl::baseProduct() const
+    {
+      ResPool pool(ResPool::instance());
+      for_( it, pool.byKindBegin<Product>(), pool.byKindEnd<Product>() )
+      {
+        Product::constPtr p = asKind<Product>((*it).resolvable());  
+        if ( p && (*it).status().isInstalled() )
+        {
+          if ( p->isTargetDistribution() )
+            return p;
+        }      
+      }
+        
+      return 0L;
+    }  
+
     std::string TargetImpl::targetDistribution() const
     { return rpmdb2solvAttr( "register.target", _root ); }
 
index 052bcae..23b765b 100644 (file)
@@ -138,6 +138,9 @@ namespace zypp
       /** return the last modification date of the target */
       Date timestamp() const;
 
+      /** \copydoc Target::baseProduct() */
+      Product::constPtr baseProduct() const;
+
       /** \copydoc Target::release() */
       std::string release() const;