libzypp  15.3.0
ResObject.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
13 #include "zypp/ResObject.h"
14 #include "zypp/sat/SolvAttr.h"
15 #include "zypp/sat/Solvable.h"
16 #include "zypp/Repository.h"
17 #include "zypp/RepoInfo.h"
18 #include "zypp/IdString.h"
19 
20 #include "zypp/ui/Selectable.h"
21 
22 using namespace zypp;
23 using namespace std;
24 
26 namespace zypp
27 {
28 
30 
32  //
33  // METHOD NAME : ResObject::ResObject
34  // METHOD TYPE : Ctor
35  //
36  ResObject::ResObject( const sat::Solvable & solvable_r )
37  : Resolvable( solvable_r )
38  {}
39 
41  //
42  // METHOD NAME : ResObject::~ResObject
43  // METHOD TYPE : Dtor
44  //
46  {}
47 
49  //
50  // METHOD NAME : ResObject::dumpOn
51  // METHOD TYPE : std::ostream &
52  //
53  std::ostream & ResObject::dumpOn( std::ostream & str ) const
54  {
55  return Resolvable::dumpOn( str );
56  }
57 
59 
60  std::string ResObject::summary( const Locale & lang_r ) const
61  { return lookupStrAttribute( sat::SolvAttr::summary, lang_r ); }
62 
63  std::string ResObject::description( const Locale & lang_r ) const
64  { return lookupStrAttribute( sat::SolvAttr::description, lang_r ); }
65 
66  std::string ResObject::insnotify( const Locale & lang_r ) const
67  { return lookupStrAttribute( sat::SolvAttr::insnotify, lang_r ); }
68 
69  std::string ResObject::delnotify( const Locale & lang_r ) const
70  { return lookupStrAttribute( sat::SolvAttr::delnotify, lang_r ); }
71 
72  std::string ResObject::licenseToConfirm( const Locale & lang_r ) const
73  {
74  std::string ret = lookupStrAttribute( sat::SolvAttr::eula, lang_r );
75  if ( ret.empty() && isKind<Product>() )
76  {
77  const RepoInfo & ri( repoInfo() );
78  if ( ri.needToAcceptLicense() || ! ui::Selectable::get( *this )->hasInstalledObj() )
79  ret = ri.getLicense( lang_r ); // bnc#908976: suppress informal license upon update
80  }
81  return ret;
82  }
83 
85  {
86  if ( isKind<Product>() )
87  return repoInfo().needToAcceptLicense( );
88  return true;
89  }
90 
91  std::string ResObject::distribution() const
93 
96 
99 
102 
103  unsigned ResObject::mediaNr() const
105 
108 
111 
113 } // namespace zypp
115 
116 #include "zypp/ResObjects.h"
117 
119 namespace zypp
120 {
121 
123  {
124  if ( ! solvable_r )
125  return 0;
126 
127  ResKind kind( solvable_r.kind() );
128 #define OUTS(X) if ( kind == ResTraits<X>::kind ) return make<X>( solvable_r );
129  OUTS( Package );
130  OUTS( Patch );
131  OUTS( Pattern );
132  OUTS( Product );
133  OUTS( SrcPackage );
134  OUTS( Application );
135 #undef OUTS
136  // unknow => return a plain ResObject
137  return new ResObject( solvable_r );
138  }
139 
141 } // namespace zypp
Product interface.
Definition: Product.h:32
bool needToAcceptLicense() const
Acceptance of Product License needed?
Definition: ResObject.cc:84
std::string distribution() const
The distribution string.
Definition: ResObject.cc:91
A Solvable object within the sat Pool.
Definition: Solvable.h:55
Store and operate with byte count.
Definition: ByteCount.h:30
static const SolvAttr installtime
Definition: SolvAttr.h:76
TraitsType::PtrType Ptr
Definition: ResObject.h:49
std::string lookupStrAttribute(const SolvAttr &attr) const
returns the string attribute value for attr or an empty string if it does not exists.
Definition: Solvable.cc:144
String related utilities and Regular expression matching.
Definition: Arch.h:330
What is known about a repository.
Definition: RepoInfo.h:71
Common Platform Enumearation (2.3) See http://cpe.mitre.org/ for more information on the Common Platf...
Definition: CpeId.h:31
Interface base for resolvable objects (identification and dependencies).
Definition: Resolvable.h:39
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
License or agreement to accept.
Definition: ResObject.cc:72
Class representing a patch.
Definition: Patch.h:36
static const SolvAttr insnotify
Definition: SolvAttr.h:73
virtual std::ostream & dumpOn(std::ostream &str) const
Helper for stream output.
Definition: ResObject.cc:53
ByteCount installSize() const
Installed (unpacked) size.
Definition: ResObject.cc:97
std::string description(const Locale &lang_r=Locale()) const
Long text describing the resolvable.
Definition: ResObject.cc:63
Store and operate on date (time_t).
Definition: Date.h:32
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:431
Pattern interface.
Definition: Pattern.h:30
Package interface.
Definition: Package.h:32
std::string summary(const Locale &lang_r=Locale()) const
Short text describing the resolvable.
Definition: ResObject.cc:60
IMPL_PTR_TYPE(Application)
RepoInfo repoInfo() const
RepoInfo associated with the repository providing this resolvable.
Definition: ResObject.h:190
ByteCount downloadSize() const
Download size.
Definition: ResObject.cc:100
unsigned long long lookupNumAttribute(const SolvAttr &attr) const
returns the numeric attribute value for attr or 0 if it does not exists.
Definition: Solvable.cc:170
virtual std::ostream & dumpOn(std::ostream &str) const
Helper for stream output.
Definition: Resolvable.cc:52
Interface base for resolvable objects (common data).
Definition: ResObject.h:44
#define OUTS(X)
static const SolvAttr downloadsize
Definition: SolvAttr.h:79
std::string insnotify(const Locale &lang_r=Locale()) const
Installation Notification.
Definition: ResObject.cc:66
Date buildtime() const
build time of the resolvable
Definition: ResObject.cc:106
static const SolvAttr delnotify
Definition: SolvAttr.h:74
virtual ~ResObject()
Dtor.
Definition: ResObject.cc:45
static const SolvAttr installsize
Definition: SolvAttr.h:78
static constexpr NoThrowType noThrow
Indicator argument for non-trowing ctor.
Definition: CpeId.h:62
ResKind kind() const
Definition: Solvable.cc:274
static Ptr get(const pool::ByIdent &ident_r)
Get the Selctable.
Definition: Selectable.cc:28
SrcPackage interface.
Definition: SrcPackage.h:29
CpeId cpeId() const
The Common Platform Enumeration name for this product.
Definition: ResObject.cc:94
static const SolvAttr buildtime
Definition: SolvAttr.h:77
static const SolvAttr cpeid
Definition: SolvAttr.h:81
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:462
unsigned mediaNr() const
Media number where the resolvable is located 0 if no media access is required.
Definition: ResObject.cc:103
static const SolvAttr description
Definition: SolvAttr.h:72
std::string delnotify(const Locale &lang_r=Locale()) const
De-Installation Notification.
Definition: ResObject.cc:69
ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
Definition: ResObject.cc:122
Date installtime() const
Installation time 0 if the resolvable is not installed.
Definition: ResObject.cc:109
static const SolvAttr eula
Definition: SolvAttr.h:75
static const SolvAttr summary
Definition: SolvAttr.h:71
static const SolvAttr distribution
Definition: SolvAttr.h:92
ResObject(const sat::Solvable &solvable_r)
Ctor.
Definition: ResObject.cc:36
Resolvable kinds.
Definition: ResKind.h:32
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Class representing an application (appdata.xml)
Definition: Application.h:27
static const SolvAttr medianr
Definition: SolvAttr.h:88