/** \file zypp/ResObject.cc
*
*/
+
#include "zypp/ResObject.h"
-#include "zypp/Repository.h"
#include "zypp/sat/SolvAttr.h"
-extern "C"
-{
-#include "satsolver/repo.h"
-}
-
-class SearchQuery
-{
- void search(Repo *repo, Id p, Id key, const char *match, int flags)
- {
- repo_search( repo, p, key, match, flags, SearchQuery::repo_search_cb, (void*) this);
- }
-
- static int repo_search_cb(void *cbdata, ::Solvable *s, ::Repodata *data, ::Repokey *key, ::KeyValue *kv)
- {
- SearchQuery *q = (SearchQuery *) cbdata;
- }
-};
+#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
//
std::ostream & ResObject::dumpOn( std::ostream & str ) const
{
- return Resolvable::dumpOn( str << "[S" << repository().numericId() << ":" << mediaNr() << "]" );
+ return Resolvable::dumpOn( str );
}
///////////////////////////////////////////////////////////////////
- //
- // ResObject interface forwarded to implementation
- //
- ///////////////////////////////////////////////////////////////////
- Text ResObject::summary() const
- { return Text(); }
+ std::string ResObject::summary( const Locale & lang_r ) const
+ { return lookupStrAttribute( sat::SolvAttr::summary, lang_r ); }
- Text ResObject::description() const
- { return Text(); }
+ std::string ResObject::description( const Locale & lang_r ) const
+ { return lookupStrAttribute( sat::SolvAttr::description, lang_r ); }
- Text ResObject::insnotify() const
- { return Text(); }
+ std::string ResObject::insnotify( const Locale & lang_r ) const
+ { return lookupStrAttribute( sat::SolvAttr::insnotify, lang_r ); }
- Text ResObject::delnotify() const
- { return Text(); }
+ std::string ResObject::delnotify( const Locale & lang_r ) const
+ { return lookupStrAttribute( sat::SolvAttr::delnotify, lang_r ); }
- License ResObject::licenseToConfirm() const
- { return License(); }
+ 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;
+ }
- Vendor ResObject::vendor() const
- { return Vendor(); }
+ std::string ResObject::distribution() const
+ { return lookupStrAttribute( sat::SolvAttr::distribution ); }
- ByteCount ResObject::size() const
- { return ByteCount(); }
+ CpeId ResObject::cpeId() const
+ { return CpeId( lookupStrAttribute( sat::SolvAttr::cpeid ), CpeId::noThrow ); }
- Repository ResObject::repository() const
- { return Repository(); }
+ ByteCount ResObject::installSize() const
+ { return ByteCount( lookupNumAttribute( sat::SolvAttr::installsize ) ); }
ByteCount ResObject::downloadSize() const
- { return ByteCount(); }
+ { return ByteCount( lookupNumAttribute( sat::SolvAttr::downloadsize ) ); }
unsigned ResObject::mediaNr() const
- { return 0; }
-
- bool ResObject::installOnly() const
- { return false; }
+ { return lookupNumAttribute( sat::SolvAttr::medianr ); }
Date ResObject::buildtime() const
- { return Date(); }
+ { return Date( lookupNumAttribute( sat::SolvAttr::buildtime ) ); }
Date ResObject::installtime() const
- { return Date(); }
-
- const DiskUsage & ResObject::diskusage() const
- {
- static DiskUsage _du;
- return _du;
- }
+ { return Date( lookupNumAttribute( sat::SolvAttr::installtime ) ); }
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#include "zypp/ResObjects.h"
-
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
ResObject::Ptr makeResObject( const sat::Solvable & solvable_r )
{
+ if ( ! solvable_r )
+ return 0;
+
ResKind kind( solvable_r.kind() );
#define OUTS(X) if ( kind == ResTraits<X>::kind ) return make<X>( solvable_r );
- OUTS( Atom );
- OUTS( Message );
OUTS( Package );
OUTS( Patch );
OUTS( Pattern );
OUTS( Product );
- OUTS( Script );
OUTS( SrcPackage );
+ OUTS( Application );
#undef OUTS
- return 0;
+ // unknow => return a plain ResObject
+ return new ResObject( solvable_r );
}
/////////////////////////////////////////////////////////////////