1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ResObject.cc
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"
20 #include "zypp/ui/Selectable.h"
25 ///////////////////////////////////////////////////////////////////
27 { /////////////////////////////////////////////////////////////////
29 IMPL_PTR_TYPE(ResObject);
31 ///////////////////////////////////////////////////////////////////
33 // METHOD NAME : ResObject::ResObject
36 ResObject::ResObject( const sat::Solvable & solvable_r )
37 : Resolvable( solvable_r )
40 ///////////////////////////////////////////////////////////////////
42 // METHOD NAME : ResObject::~ResObject
45 ResObject::~ResObject()
48 ///////////////////////////////////////////////////////////////////
50 // METHOD NAME : ResObject::dumpOn
51 // METHOD TYPE : std::ostream &
53 std::ostream & ResObject::dumpOn( std::ostream & str ) const
55 return Resolvable::dumpOn( str );
58 ///////////////////////////////////////////////////////////////////
60 std::string ResObject::summary( const Locale & lang_r ) const
61 { return lookupStrAttribute( sat::SolvAttr::summary, lang_r ); }
63 std::string ResObject::description( const Locale & lang_r ) const
64 { return lookupStrAttribute( sat::SolvAttr::description, lang_r ); }
66 std::string ResObject::insnotify( const Locale & lang_r ) const
67 { return lookupStrAttribute( sat::SolvAttr::insnotify, lang_r ); }
69 std::string ResObject::delnotify( const Locale & lang_r ) const
70 { return lookupStrAttribute( sat::SolvAttr::delnotify, lang_r ); }
72 std::string ResObject::licenseToConfirm( const Locale & lang_r ) const
74 std::string ret = lookupStrAttribute( sat::SolvAttr::eula, lang_r );
75 if ( ret.empty() && isKind<Product>() )
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
84 bool ResObject::needToAcceptLicense() const
86 if ( isKind<Product>() )
87 return repoInfo().needToAcceptLicense( );
91 std::string ResObject::distribution() const
92 { return lookupStrAttribute( sat::SolvAttr::distribution ); }
94 CpeId ResObject::cpeId() const
95 { return CpeId( lookupStrAttribute( sat::SolvAttr::cpeid ), CpeId::noThrow ); }
97 ByteCount ResObject::installSize() const
98 { return ByteCount( lookupNumAttribute( sat::SolvAttr::installsize ) ); }
100 ByteCount ResObject::downloadSize() const
101 { return ByteCount( lookupNumAttribute( sat::SolvAttr::downloadsize ) ); }
103 unsigned ResObject::mediaNr() const
104 { return lookupNumAttribute( sat::SolvAttr::medianr ); }
106 Date ResObject::buildtime() const
107 { return Date( lookupNumAttribute( sat::SolvAttr::buildtime ) ); }
109 Date ResObject::installtime() const
110 { return Date( lookupNumAttribute( sat::SolvAttr::installtime ) ); }
112 /////////////////////////////////////////////////////////////////
114 ///////////////////////////////////////////////////////////////////
116 #include "zypp/ResObjects.h"
118 ///////////////////////////////////////////////////////////////////
120 { /////////////////////////////////////////////////////////////////
122 ResObject::Ptr makeResObject( const sat::Solvable & solvable_r )
127 ResKind kind( solvable_r.kind() );
128 #define OUTS(X) if ( kind == ResTraits<X>::kind ) return make<X>( solvable_r );
136 // unknow => return a plain ResObject
137 return new ResObject( solvable_r );
140 /////////////////////////////////////////////////////////////////
142 ///////////////////////////////////////////////////////////////////