Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / RepoInfo.h
index 71eb895..7ddcc7c 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "zypp/Url.h"
 #include "zypp/Locale.h"
+#include "zypp/TriBool.h"
 #include "zypp/repo/RepoType.h"
 #include "zypp/repo/RepoVariables.h"
 
@@ -54,6 +55,7 @@ namespace zypp
    * name=Ruby repository (openSUSE_10.2)
    * type=rpm-md
    * baseurl=http://software.opensuse.org/download/ruby/openSUSE_10.2/
+   *         http://some.opensuse.mirror/ruby/openSUSE_10.2/
    * gpgcheck=1
    * gpgkey=http://software.opensuse.org/openSUSE-Build-Service.asc
    * enabled=1
@@ -62,6 +64,9 @@ namespace zypp
    *
    * \note A RepoInfo is a hint about how
    * to create a Repository.
+   *
+   * \note Name, baseUrls and mirrorUrl are subject to repo variable replacement
+   * (\see \ref RepoVariablesStringReplacer).
    */
   class RepoInfo : public repo::RepoInfoBase
   {
@@ -91,7 +96,7 @@ namespace zypp
        */
       void setPriority( unsigned newval_r );
 
-      typedef std::set<Url>           url_set;
+      typedef std::list<Url>          url_set;
       typedef url_set::size_type      urls_size_type;
       typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
       /**
@@ -99,7 +104,8 @@ namespace zypp
        */
       bool baseUrlsEmpty() const;
       /**
-       * whether there are manualy configured repository urls
+       * Whether there are manualy configured repository urls.
+       * If \c false, a mirrorlist might be used.
        */
       bool baseUrlSet() const;
       /**
@@ -114,21 +120,29 @@ namespace zypp
        * iterator that points at end of repository urls
        */
       urls_const_iterator baseUrlsEnd() const;
+
       /**
        * Pars pro toto: The first repository url
        */
       Url url() const
       { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); }
       /**
-       * A Url under which the metadata are located, or a set of mirrors.
-       *
-       * This can't be empty in order the repository to be valid
-       * unless the download of the mirror list succeeds and it
-       * contains a valid url.
+       * Pars pro toto: The first repository raw url (no variables replaced)
+       */
+      Url rawUrl() const;
+
+      /**
+       * The complete set of repository urls
        *
-       * \deprecated IMO superfluous as we provide begin/end iterator.
+       * These are either the configured baseurls, or if empty, the downloaded
+       * mirror list (\see \ref mirrorListUrl)
        */
-      std::set<Url> baseUrls() const;
+      url_set baseUrls() const;
+      /**
+       * The complete set of raw repository urls (no variables replaced)
+       */
+      url_set rawBaseUrls() const;
+
       /**
        * Add a base url. \see baseUrls
        * \param url The base url for the repository.
@@ -141,6 +155,10 @@ namespace zypp
        * Clears current base URL list and adds \a url.
        */
       void setBaseUrl( const Url &url );
+      /**
+       * Clears current base URL list and adds an \ref url_set.
+       */
+      void setBaseUrls( url_set urls );
 
       /**
        * \short Repository path
@@ -170,11 +188,14 @@ namespace zypp
       void setPath( const Pathname &path );
 
       /**
-       * Url of a file which contains a list of Urls
-       * If empty, the base url will be used.
+       * Url of a file which contains a list of repository urls
        */
       Url mirrorListUrl() const;
       /**
+       * The raw mirrorListUrl (no variables replaced).
+       */
+      Url rawMirrorListUrl() const;
+      /**
        * Set mirror list url. \see mirrorListUrl
        * \param url The base url for the list
        */
@@ -226,46 +247,62 @@ namespace zypp
        */
       void setPackagesPath( const Pathname &path );
 
-      /**
-       * \short Whether to check or not this repository with gpg
+
+      /** Whether default signature checking should be performed for this repo.
        *
-       * \note This is a just a hint to the application and can
-       * be ignored.
+       * This will turn on \ref repoGpgCheck for signed repos and
+       * \ref pkgGpgCheck for unsigned ones or if \ref repoGpgCheck is off.
        *
+       * The default is \c true but may be overwritten by \c zypp.conf or a \ref .repo file.
        */
       bool gpgCheck() const;
-      /**
-       * \short Whether to check or not this repository with gpg
-       *
-       * \param check true (check) or false (dont'check)
-       *
-       * \note This is a just a hint to the application and can
-       * be ignored.
-       *
+      /** Set the value for \ref gpgCheck (or \c indeterminate to use the default). */
+      void setGpgCheck( TriBool value_r );
+      /** \overload \deprecated legacy and for squid */
+      void setGpgCheck( bool value_r );
+
+      /** Whether the signature of repo metadata should be checked for this repo.
+       * The default is defined by \ref gpgCheck but may be overwritten by \c zypp.conf or a \ref .repo file.
        */
-      void setGpgCheck( bool check );
+      bool repoGpgCheck() const;
+      /** Set the value for \ref repoGpgCheck (or \c indeterminate to use the default). */
+      void setRepoGpgCheck( TriBool value_r );
 
-      /**
-       * \short Key to use for gpg checking of this repository
-       *
-       * \param url Url to the key in ASCII armored format
-       *
-       * \note This is a just a hint to the application and can
-       * be ignored.
-       *
+      /** Whether the signature of rpm packages should be checked for this repo.
+       * The default is defined by \ref gpgCheck but may be overwritten by \c zypp.conf or a \ref .repo file.
        */
-      Url gpgKeyUrl() const;
-      /**
-       * \short Key to use for gpg checking of this repository
-       *
-       * \param url Url to the key in ASCII armored format
-       *
-       * \note This is a just a hint to the application and can
-       * be ignored.
-       *
+      bool pkgGpgCheck() const;
+      /** Set the value for \ref pkgGpgCheck (or \c indeterminate to use the default). */
+      void setPkgGpgCheck( TriBool value_r );
+
+      /** Whether the repo metadata are signed and successfully validated or \c indeterminate if unsigned.
+       * The value is usually set by \ref repo::Downloader when retrieving the metadata.
        */
+      TriBool validRepoSignature() const;
+      /** Set the value for \ref validRepoSignature (or \c indeterminate if unsigned). */
+      void setValidRepoSignature( TriBool value_r );
+
+
+      /** Whether gpgkey URLs are defined */
+      bool gpgKeyUrlsEmpty() const;
+      /** Number of gpgkey URLs defined */
+      urls_size_type gpgKeyUrlsSize() const;
+
+      /** The list of gpgkey URLs defined for this repo */
+      url_set gpgKeyUrls() const;
+      /** The list of raw gpgkey URLs defined for this repo (no variables replaced) */
+      url_set rawGpgKeyUrls() const;
+      /** Set a list of gpgkey URLs defined for this repo */
+      void setGpgKeyUrls( url_set urls );
+
+      /** (leagcy API) The 1st gpgkey URL defined for this repo */
+      Url gpgKeyUrl() const;
+      /** (leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced) */
+      Url rawGpgKeyUrl() const;
+      /** (leagcy API) Set the gpgkey URL defined for this repo */
       void setGpgKeyUrl( const Url &gpgkey );
 
+
       /**
        * \short Whether packages downloaded from this repository will be kept in local cache
        */
@@ -302,6 +339,40 @@ namespace zypp
        */
       void setTargetDistribution(const std::string & targetDistribution);
 
+      /** Add content keywords */
+      void addContent( const std::string & keyword_r );
+      /** \overload add keywords from container */
+      template <class _Iterator>
+      void addContentFrom( _Iterator begin_r, _Iterator end_r )
+      { for_( it, begin_r, end_r ) addContent( *it ); }
+      /** \overload  */
+      template <class _Container>
+      void addContentFrom( const _Container & container_r )
+      { addContentFrom( container_r.begin(), container_r.end() ); }
+
+      /** Check for content keywords.
+       * Checking for an empty string returns whether content kewords are
+       * known at all. They may be missing due to missing metadata in disabled
+       * repos.
+       */
+      bool hasContent( const std::string & keyword_r = std::string() ) const;
+      /** \overload check for \b all keywords being present */
+      template <class _Iterator>
+      bool hasContentAll( _Iterator begin_r, _Iterator end_r ) const
+      { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
+      /** \overload  */
+      template <class _Container>
+      bool hasContentAll( const _Container & container_r ) const
+      { return hasContentAll( container_r.begin(), container_r.end() ); }
+      /** \overload check for \b any keyword being present */
+      template <class _Iterator>
+      bool hasContentAny( _Iterator begin_r, _Iterator end_r ) const
+      { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
+      /** \overload  */
+      template <class _Container>
+      bool hasContentAny( const _Container & container_r ) const
+      { return hasContentAny( container_r.begin(), container_r.end() ); }
+
     public:
       /** \name Repository license
       */
@@ -311,11 +382,12 @@ namespace zypp
 
       /** Whether the repo license has to be accepted, e.g. there is no
        * no acceptance needed for openSUSE.
-       */ 
+       */
       bool needToAcceptLicense() const;
-    
+
       /** Return the best license for the current (or a specified) locale. */
-      std::string getLicense( const Locale & lang_r = Locale() );
+      std::string getLicense( const Locale & lang_r = Locale() ) const;
+      std::string getLicense( const Locale & lang_r = Locale() ); // LEGACY API
 
       /** Return the locales the license is available for.
        * \ref Locale::noCode is included in case of \c license.txt which does
@@ -324,13 +396,6 @@ namespace zypp
       LocaleSet getLicenseLocales() const;
       //@}
 
-      /** \name Repository global unique id
-       *
-       *
-       */
-      //@{
-      //@}
-
     public:
       /**
        * Write a human-readable representation of this RepoInfo object
@@ -340,25 +405,26 @@ namespace zypp
 
       /**
        * Write this RepoInfo object into \a str in a <tr>.repo</tt> file format.
+       * Raw values, no variable replacement.
        */
       virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
 
       /**
        * Write an XML representation of this RepoInfo object.
-       */
-      virtual std::ostream & dumpAsXMLOn(std::ostream & str) const;
-
-      /**
-       * Write an XML representation of this RepoInfo object.
+       * Repo variables replaced.
        *
        * \param str
        * \param content this argument is ignored (used in other classed derived
        *                from RepoInfoBase.
        */
-      virtual std::ostream & dumpAsXMLOn( std::ostream & str, const std::string & content ) const;
+      virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
 
       class Impl;
     private:
+      friend class RepoManager;
+      /** Raw values for RepoManager */
+      void getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const;
+
       /** Pointer to implementation */
       RWCOW_pointer<Impl> _pimpl;
   };