libzypp  17.14.0
RepoInfo.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP2_REPOSITORYINFO_H
13 #define ZYPP2_REPOSITORYINFO_H
14 
15 #include <list>
16 #include <set>
17 
18 #include "zypp/base/Iterator.h"
19 #include "zypp/APIConfig.h"
20 
21 #include "zypp/Url.h"
22 #include "zypp/Locale.h"
23 #include "zypp/TriBool.h"
24 #include "zypp/repo/RepoType.h"
26 
27 #include "zypp/repo/RepoInfoBase.h"
28 
30 namespace zypp
31 {
32 
34  //
35  // CLASS NAME : RepoInfo
36  //
72  {
73  friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
74 
75  public:
76  RepoInfo();
77  virtual ~RepoInfo();
78 
80  static const RepoInfo noRepo;
81 
82  public:
86  static unsigned defaultPriority();
90  static unsigned noPriority();
95  unsigned priority() const;
101  void setPriority( unsigned newval_r );
102 
103  typedef std::list<Url> url_set;
105  typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
109  bool baseUrlsEmpty() const;
114  bool baseUrlSet() const;
127 
131  Url url() const
132  { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); }
136  Url rawUrl() const;
137 
144  url_set baseUrls() const;
148  url_set rawBaseUrls() const;
149 
157  void addBaseUrl( const Url &url );
161  void setBaseUrl( const Url &url );
165  void setBaseUrls( url_set urls );
166 
187  Pathname path() const;
192  void setPath( const Pathname &path );
193 
197  Url mirrorListUrl() const;
201  Url rawMirrorListUrl() const;
206  void setMirrorListUrl( const Url &url );
210  void setMetalinkUrl( const Url &url );
211 
216  repo::RepoType type() const;
223  void setProbedType( const repo::RepoType &t ) const;
228  void setType( const repo::RepoType &t );
229 
236  Pathname metadataPath() const;
263  void setMetadataPath( const Pathname &path );
264 
266  bool usesAutoMethadataPaths() const;
267 
271  Pathname packagesPath() const;
277  void setPackagesPath( const Pathname &path );
278 
279 
337  bool gpgCheck() const;
339  void setGpgCheck( TriBool value_r );
341  void setGpgCheck( bool value_r );
342 
344  bool repoGpgCheck() const;
346  bool repoGpgCheckIsMandatory() const;
348  void setRepoGpgCheck( TriBool value_r );
349 
351  bool pkgGpgCheck() const;
353  bool pkgGpgCheckIsMandatory() const;
355  void setPkgGpgCheck( TriBool value_r );
356 
360  TriBool validRepoSignature() const;
362  void setValidRepoSignature( TriBool value_r );
363 
365  enum class GpgCheck {
366  indeterminate, //< not specified
367  On, //< 1** --gpgcheck
368  Strict, //< 111 --gpgcheck-strict
369  AllowUnsigned, //< 100 --gpgcheck-allow-unsigned
370  AllowUnsignedRepo, //< 10* --gpgcheck-allow-unsigned-repo
371  AllowUnsignedPackage, //< 1*0 --gpgcheck-allow-unsigned-package
372  Default, //< *** --default-gpgcheck
373  Off, //< 0** --no-gpgcheck
374  };
375 
380  bool setGpgCheck( GpgCheck mode_r );
382 
383 
385  bool gpgKeyUrlsEmpty() const;
388 
390  url_set gpgKeyUrls() const;
392  url_set rawGpgKeyUrls() const;
394  void setGpgKeyUrls( url_set urls );
395 
397  Url gpgKeyUrl() const;
399  Url rawGpgKeyUrl() const;
401  void setGpgKeyUrl( const Url &gpgkey );
402 
404  Pathname provideKey(const std::string &keyID_r, const Pathname &targetDirectory_r ) const;
405 
409  bool keepPackages() const;
419  void setKeepPackages( bool keep );
420 
425  std::string service() const;
429  void setService( const std::string& name );
430 
434  std::string targetDistribution() const;
440  void setTargetDistribution(const std::string & targetDistribution);
441 
442 
444  const std::set<std::string> & contentKeywords() const;
445 
447  void addContent( const std::string & keyword_r );
449  template <class TIterator>
450  void addContentFrom( TIterator begin_r, TIterator end_r )
451  { for_( it, begin_r, end_r ) addContent( *it ); }
453  template <class TContainer>
454  void addContentFrom( const TContainer & container_r )
455  { addContentFrom( container_r.begin(), container_r.end() ); }
456 
460  bool hasContent() const;
462  bool hasContent( const std::string & keyword_r ) const;
464  template <class TIterator>
465  bool hasContentAll( TIterator begin_r, TIterator end_r ) const
466  { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
468  template <class TContainer>
469  bool hasContentAll( const TContainer & container_r ) const
470  { return hasContentAll( container_r.begin(), container_r.end() ); }
472  template <class TIterator>
473  bool hasContentAny( TIterator begin_r, TIterator end_r ) const
474  { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
476  template <class TContainer>
477  bool hasContentAny( const TContainer & container_r ) const
478  { return hasContentAny( container_r.begin(), container_r.end() ); }
479 
480  public:
494  bool hasLicense() const;
496  bool hasLicense( const std::string & name_r ) const;
497 
501  bool needToAcceptLicense() const;
503  bool needToAcceptLicense( const std::string & name_r ) const;
504 
506  std::string getLicense( const Locale & lang_r = Locale() ) const;
508  std::string getLicense( const Locale & lang_r = Locale() ); // LEGACY API
510  std::string getLicense( const std::string & name_r, const Locale & lang_r = Locale() ) const;
511 
518  LocaleSet getLicenseLocales( const std::string & name_r ) const;
520 
521  public:
526  virtual std::ostream & dumpOn( std::ostream & str ) const;
527 
532  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
533 
542  virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
543 
544  struct Impl;
545  private:
546  friend class RepoManager;
548  void getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const;
549 
552  };
554 
556  typedef shared_ptr<RepoInfo> RepoInfo_Ptr;
558  typedef shared_ptr<const RepoInfo> RepoInfo_constPtr;
560  typedef std::list<RepoInfo> RepoInfoList;
561 
563  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
564 
566  std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj );
567 
569 } // namespace zypp
571 #endif // ZYPP2_REPOSITORYINFO_H