Author: mlandres Date: Thu May 8 10:59:29 2008 New Revision: 9984 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9984&view=rev Log: Provide enumerated patch category Patch::categoryEnum() Modified: trunk/libzypp/zypp/Patch.cc trunk/libzypp/zypp/Patch.h trunk/libzypp/zypp/sat/LookupAttr.cc Modified: trunk/libzypp/zypp/Patch.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Patch.cc?rev=9984&r1=9983&r2=9984&view=diff ============================================================================== --- trunk/libzypp/zypp/Patch.cc (original) +++ trunk/libzypp/zypp/Patch.cc Thu May 8 10:59:29 2008 @@ -45,6 +45,30 @@ // /////////////////////////////////////////////////////////////////// + Patch::Category Patch::categoryEnum() const + { + static const IdString cat_yast( "yast" ); + static const IdString cat_security( "security" ); + static const IdString cat_recommended( "recommended" ); + static const IdString cat_optional( "optional" ); + static const IdString cat_document( "document" ); + + IdString cat( sat::LookupAttr( sat::SolvAttr::patchcategory ).begin().idStr() ); + + if ( cat == cat_yast ) + return CAT_YAST; + if ( cat == cat_security ) + return CAT_SECURITY; + if ( cat == cat_recommended ) + return CAT_RECOMMENDED; + if ( cat == cat_optional ) + return CAT_OPTIONAL; + if ( cat == cat_document ) + return CAT_DOCUMENT; + + return CAT_OTHER; + } + std::string Patch::category() const { return lookupStrAttribute( sat::SolvAttr::patchcategory ); } @@ -79,9 +103,9 @@ Patch::Contents Patch::contents() const { Contents result; - sat::LookupAttr col_name(sat::LookupAttr( sat::SolvAttr::updateCollectionName, *this )); - sat::LookupAttr col_evr(sat::LookupAttr( sat::SolvAttr::updateCollectionEvr, *this )); - sat::LookupAttr col_arch(sat::LookupAttr( sat::SolvAttr::updateCollectionArch, *this )); + sat::LookupAttr col_name( sat::SolvAttr::updateCollectionName, *this ); + sat::LookupAttr col_evr( sat::SolvAttr::updateCollectionEvr, *this ); + sat::LookupAttr col_arch( sat::SolvAttr::updateCollectionArch, *this ); sat::LookupAttr::iterator col_name_it(col_name.begin()); sat::LookupAttr::iterator col_evr_it(col_evr.begin()); @@ -100,24 +124,24 @@ IdString nameid( col_name_it.asString() ); /* IdString for fast compare */ Arch arch( col_arch_it.asString() ); - + /* search providers of name */ sat::WhatProvides providers( Capability( col_name_it.asString() ) ); MIL << *this << " providers: " << endl; MIL << providers << endl; - + if (providers.empty()) { WAR << *this << " misses provider for '" << col_name_it.asString() << "'" << endl; continue; } - + bool is_relevant = false; for_( it, providers.begin(), providers.end() ) { if (it->ident() != nameid) /* package _name_ must match */ continue; - + if (it->isSystem() /* only look at installed providers with same arch */ && it->arch() == arch) { @@ -127,10 +151,10 @@ if (!is_relevant) { MIL << *this << " is not relevant to the system" << endl; - + continue; /* skip if name.arch is not installed */ } - + /* find exact providers first (this matches the _real_ 'collection content' of the patch */ sat::WhatProvides exact_providers( Capability( col_name_it.asString(), Rel::EQ, col_evr_it.asString(), ResKind::package ) ); Modified: trunk/libzypp/zypp/Patch.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Patch.h?rev=9984&r1=9983&r2=9984&view=diff ============================================================================== --- trunk/libzypp/zypp/Patch.h (original) +++ trunk/libzypp/zypp/Patch.h Thu May 8 10:59:29 2008 @@ -43,6 +43,15 @@ public: typedef sat::SolvableSet Contents; + enum Category { + CAT_OTHER, + CAT_YAST, + CAT_SECURITY, + CAT_RECOMMENDED, + CAT_OPTIONAL, + CAT_DOCUMENT + }; + public: /** * Issue date time. For now it is the same as @@ -56,11 +65,16 @@ */ std::string category() const; + /** Patch category as enum of wellknown categories. + * Unknown values are mapped to \ref CAT_OTHER. + */ + Category categoryEnum() const; + /** * Does the system need to reboot to finish the update process? */ bool rebootSuggested() const; - + /** * Does the patch affect the package manager itself? * restart is suggested then Modified: trunk/libzypp/zypp/sat/LookupAttr.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttr.cc?rev=9984&r1=9983&r2=9984&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/LookupAttr.cc (original) +++ trunk/libzypp/zypp/sat/LookupAttr.cc Thu May 8 10:59:29 2008 @@ -396,7 +396,7 @@ { const ::_Dataiterator * dip = obj.get(); if ( ! dip ) - return str << "EndOfQuery" << endl; + return str << "EndOfQuery"; if ( obj.inSolvable() ) str << obj.inSolvable(); -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org