Author: lslezak Date: Wed Jul 11 08:22:28 2007 New Revision: 39307 URL: http://svn.opensuse.org/viewcvs/yast?rev=39307&view=rev Log: - reimplemented PkgMediaNames() Modified: branches/REFACTORING-10_3/pkg-bindings/src/Package.cc Modified: branches/REFACTORING-10_3/pkg-bindings/src/Package.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/REFACTORING-10_3/pkg-bindings/src/Package.cc?rev=39307&r1=39306&r2=39307&view=diff ============================================================================== --- branches/REFACTORING-10_3/pkg-bindings/src/Package.cc (original) +++ branches/REFACTORING-10_3/pkg-bindings/src/Package.cc Wed Jul 11 08:22:28 2007 @@ -191,70 +191,61 @@ PkgModuleFunctions::PkgMediaNames () { # warning No installation order - -#warning PkgMediaNames is NOT implemented!!! -// FIXME -/* -// std::listzypp::SourceManager::SourceId source_ids = zypp::SourceManager::sourceManager()->enabledSources(); - YCPList res; - // initialize -// FIXME: for all enabled sources... - for( std::listzypp::SourceManager::SourceId::const_iterator sit = source_ids.begin(); - sit != source_ids.end(); ++sit) + std::vectorzypp::RepoInfo::size_type index = 0; + // for all enabled sources + for( std::vectorzypp::RepoInfo::const_iterator repoit = repos.begin(); + repoit != repos.end(); ++repoit,++index) { - unsigned id = *sit; + if (repoit->enabled()) + { + try + { + // find a product for the given source + zypp::ResPool::byKind_iterator it = zypp_ptr()->pool().byKindBegin(zypp::ResTraitszypp::Product::kind); -//FIXME -// zypp::Source_Ref src = zypp::SourceManager::sourceManager()->findSource( id ); + for( ; it != zypp_ptr()->pool().byKindEnd(zypp::ResTraitszypp::Product::kind) + ; ++it) { + zypp::Product::constPtr product = boost::dynamic_pointer_cast<const zypp::Product>( it->resolvable() ); - try - { - // find a product for the given source - zypp::ResPool::byKind_iterator it = zypp_ptr()->pool().byKindBegin(zypp::ResTraitszypp::Product::kind); + y2debug ("Checking product: %s", product->summary().c_str()); + if( product->repository().info().alias() == repoit->alias()) + { + y2debug ("Found"); + + YCPList src_desc; + src_desc->add( YCPString( product->summary() ) ); + src_desc->add( YCPInteger( index ) ); - for( ; it != zypp_ptr()->pool().byKindEnd(zypp::ResTraitszypp::Product::kind) - ; ++it) { - zypp::Product::constPtr product = boost::dynamic_pointer_cast<const zypp::Product>( it->resolvable() ); + res->add( src_desc ); + break; + } + } - y2debug ("Checking product: %s", product->summary().c_str()); - if( product->source() == src ) + // the product hasn't been found, resolvables are probably not loaded + // use URL as the product name in such case + if( it == zypp_ptr()->pool().byKindEnd(zypp::ResTraitszypp::Product::kind) ) { - y2debug ("Found"); + y2warning("Product for source '%d' not found", index); YCPList src_desc; - src_desc->add( YCPString( product->summary() ) ); - src_desc->add( YCPInteger( src.numericId() ) ); + src_desc->add( YCPString( repoit->baseUrlsBegin()->asString()) ); + src_desc->add( YCPInteger( index ) ); res->add( src_desc ); - break; } } - - if( it == zypp_ptr()->pool().byKindEnd(zypp::ResTraitszypp::Product::kind) ) + catch (...) { - y2error ("Product for source '%d' not found", id); - - YCPList src_desc; - src_desc->add( YCPString( src.url().asString() ) ); - src_desc->add( YCPInteger( src.numericId() ) ); - - res->add( src_desc ); + return res; } } - catch (...) - { - return res; - } } y2milestone( "Pkg::PkgMediaNames result: %s", res->toString().c_str()); return res; -*/ - - return YCPList(); } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org