/** \file zypp/ResObject.cc
*
*/
+
#include "zypp/ResObject.h"
-#include "zypp/source/SourceImpl.h"
-#include "zypp/detail/ResObjectImplIf.h"
+#include "zypp/sat/SolvAttr.h"
+#include "zypp/sat/Solvable.h"
+#include "zypp/Repository.h"
+#include "zypp/RepoInfo.h"
+#include "zypp/IdString.h"
+
+#include "zypp/ui/Selectable.h"
+using namespace zypp;
using namespace std;
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
+ IMPL_PTR_TYPE(ResObject);
+
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : ResObject::ResObject
// METHOD TYPE : Ctor
//
- ResObject::ResObject( const Kind & kind_r,
- const NVRAD & nvrad_r )
- : Resolvable( kind_r, nvrad_r )
+ ResObject::ResObject( const sat::Solvable & solvable_r )
+ : Resolvable( solvable_r )
{}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
//
- // ResObject interface forwarded to implementation
+ // METHOD NAME : ResObject::dumpOn
+ // METHOD TYPE : std::ostream &
//
+ std::ostream & ResObject::dumpOn( std::ostream & str ) const
+ {
+ return Resolvable::dumpOn( str );
+ }
+
///////////////////////////////////////////////////////////////////
- const TranslatedText & ResObject::summary() const
- { return pimpl().summary(); }
+ std::string ResObject::summary( const Locale & lang_r ) const
+ { return lookupStrAttribute( sat::SolvAttr::summary, lang_r ); }
+
+ std::string ResObject::description( const Locale & lang_r ) const
+ { return lookupStrAttribute( sat::SolvAttr::description, lang_r ); }
+
+ std::string ResObject::insnotify( const Locale & lang_r ) const
+ { return lookupStrAttribute( sat::SolvAttr::insnotify, lang_r ); }
+
+ std::string ResObject::delnotify( const Locale & lang_r ) const
+ { return lookupStrAttribute( sat::SolvAttr::delnotify, lang_r ); }
+
+ std::string ResObject::licenseToConfirm( const Locale & lang_r ) const
+ {
+ std::string ret = lookupStrAttribute( sat::SolvAttr::eula, lang_r );
+ if ( ret.empty() && isKind<Product>() )
+ {
+ const RepoInfo & ri( repoInfo() );
+ if ( ri.needToAcceptLicense() || ! ui::Selectable::get( *this )->hasInstalledObj() )
+ ret = ri.getLicense( lang_r ); // bnc#908976: suppress informal license upon update
+ }
+ return ret;
+ }
+
+ bool ResObject::needToAcceptLicense() const
+ {
+ if ( isKind<Product>() )
+ return repoInfo().needToAcceptLicense( );
+ return true;
+ }
+
+ std::string ResObject::distribution() const
+ { return lookupStrAttribute( sat::SolvAttr::distribution ); }
+
+ CpeId ResObject::cpeId() const
+ { return CpeId( lookupStrAttribute( sat::SolvAttr::cpeid ), CpeId::noThrow ); }
- const TranslatedText & ResObject::description() const
- { return pimpl().description(); }
+ ByteCount ResObject::installSize() const
+ { return ByteCount( lookupNumAttribute( sat::SolvAttr::installsize ) ); }
- Text ResObject::insnotify() const
- { return pimpl().insnotify(); }
+ ByteCount ResObject::downloadSize() const
+ { return ByteCount( lookupNumAttribute( sat::SolvAttr::downloadsize ) ); }
- Text ResObject::delnotify() const
- { return pimpl().delnotify(); }
+ unsigned ResObject::mediaNr() const
+ { return lookupNumAttribute( sat::SolvAttr::medianr ); }
+
+ Date ResObject::buildtime() const
+ { return Date( lookupNumAttribute( sat::SolvAttr::buildtime ) ); }
+
+ Date ResObject::installtime() const
+ { return Date( lookupNumAttribute( sat::SolvAttr::installtime ) ); }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+
+#include "zypp/ResObjects.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
- ByteCount ResObject::size() const
- { return pimpl().size(); }
+ ResObject::Ptr makeResObject( const sat::Solvable & solvable_r )
+ {
+ if ( ! solvable_r )
+ return 0;
- Source_Ref ResObject::source() const
- { return pimpl().source(); }
+ ResKind kind( solvable_r.kind() );
+#define OUTS(X) if ( kind == ResTraits<X>::kind ) return make<X>( solvable_r );
+ OUTS( Package );
+ OUTS( Patch );
+ OUTS( Pattern );
+ OUTS( Product );
+ OUTS( SrcPackage );
+ OUTS( Application );
+#undef OUTS
+ // unknow => return a plain ResObject
+ return new ResObject( solvable_r );
+ }
/////////////////////////////////////////////////////////////////
} // namespace zypp