From 5c53f1258d1b5c6ed603066e7a85669f2e7d3a01 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Mon, 23 Oct 2006 11:34:38 +0000 Subject: [PATCH] add extra and optional urls to product --- zypp/Product.cc | 6 ++++ zypp/Product.h | 19 ++++++++-- zypp/detail/ProductImplIf.cc | 6 ++++ zypp/detail/ProductImplIf.h | 14 ++++++++ zypp/parser/xmlstore/XMLParserData.h | 4 ++- zypp/parser/xmlstore/XMLProductParser.cc | 29 ++++++++++----- zypp/parser/xmlstore/XMLProductParser.h | 6 +++- zypp/source/susetags/SuseTagsProductImpl.cc | 10 ++++++ zypp/source/susetags/SuseTagsProductImpl.h | 8 +++++ zypp/target/store/XMLFilesBackend.cc | 56 ++++++++++++++++++++++------- zypp/target/store/serialize.cc | 18 ++++++++++ zypp/target/store/xml/XMLProductImpl.cc | 6 ++++ zypp/target/store/xml/XMLProductImpl.h | 8 +++++ 13 files changed, 165 insertions(+), 25 deletions(-) diff --git a/zypp/Product.cc b/zypp/Product.cc index 3d9e34e..fd3466e 100644 --- a/zypp/Product.cc +++ b/zypp/Product.cc @@ -55,6 +55,12 @@ namespace zypp std::list Product::updateUrls() const { return pimpl().updateUrls(); } + + std::list Product::extraUrls() const + { return pimpl().extraUrls(); } + + std::list Product::optionalUrls() const + { return pimpl().optionalUrls(); } std::list Product::flags() const { return pimpl().flags(); } diff --git a/zypp/Product.h b/zypp/Product.h index ff8e1c1..8ed01bc 100644 --- a/zypp/Product.h +++ b/zypp/Product.h @@ -49,10 +49,25 @@ namespace zypp /** The URL to download the release notes for this product */ Url releaseNotesUrl() const; - /** Online updates for the product. - They are complementary, not alternatives. #163192 */ + /** + * Online updates for the product. + * They are complementary, not alternatives. #163192 + */ std::list updateUrls() const; + /** + * Additional software for the product + * They are complementary, not alternatives. + */ + std::list extraUrls() const; + + /** + * Optional software for the product + * (for example. Non OSS repositories) + * They are complementary, not alternatives. + */ + std::list optionalUrls() const; + /** The product flags */ std::list flags() const; diff --git a/zypp/detail/ProductImplIf.cc b/zypp/detail/ProductImplIf.cc index 99a212e..cfbc2e1 100644 --- a/zypp/detail/ProductImplIf.cc +++ b/zypp/detail/ProductImplIf.cc @@ -33,6 +33,12 @@ namespace zypp std::list ProductImplIf::updateUrls() const { return std::list(); } + + std::list ProductImplIf::extraUrls() const + { return std::list(); } + + std::list ProductImplIf::optionalUrls() const + { return std::list(); } std::list ProductImplIf::flags() const { return std::list(); } diff --git a/zypp/detail/ProductImplIf.h b/zypp/detail/ProductImplIf.h index 375d7bf..cb14c27 100644 --- a/zypp/detail/ProductImplIf.h +++ b/zypp/detail/ProductImplIf.h @@ -51,6 +51,20 @@ namespace zypp virtual Url releaseNotesUrl() const PURE_VIRTUAL; virtual std::list updateUrls() const PURE_VIRTUAL; + + /** + * Additional software for the product + * They are complementary, not alternatives. + */ + virtual std::list extraUrls() const PURE_VIRTUAL; + + /** + * Optional software for the product + * (for example. Non OSS repositories) + * They are complementary, not alternatives. + */ + virtual std::list optionalUrls() const PURE_VIRTUAL; + /** The product flags */ virtual std::list flags() const PURE_VIRTUAL; diff --git a/zypp/parser/xmlstore/XMLParserData.h b/zypp/parser/xmlstore/XMLParserData.h index e06348c..10c960e 100644 --- a/zypp/parser/xmlstore/XMLParserData.h +++ b/zypp/parser/xmlstore/XMLParserData.h @@ -113,10 +113,12 @@ namespace zypp { ~XMLProductData() {}; std::string type; - TranslatedText short_name; + TranslatedText short_name; // those are suse specific tags std::string releasenotesurl; std::list update_urls; + std::list extra_urls; + std::list optional_urls; std::list flags; std::string dist_name; std::string dist_version; diff --git a/zypp/parser/xmlstore/XMLProductParser.cc b/zypp/parser/xmlstore/XMLProductParser.cc index fffeee1..dae3565 100644 --- a/zypp/parser/xmlstore/XMLProductParser.cc +++ b/zypp/parser/xmlstore/XMLProductParser.cc @@ -68,8 +68,9 @@ namespace zypp { if (_helper.isElement(child)) { string name = _helper.name(child); - if (name == "vendor") { - productPtr->vendor = _helper.content(child); + if (name == "vendor") + { + productPtr->vendor = _helper.content(child); } else if (name == "release-notes-url") { productPtr->releasenotesurl = _helper.content(child); @@ -85,11 +86,20 @@ namespace zypp { } else if (name == "product-flags") { parseProductFlags( productPtr, child); + } + else if (name == "update-urls") + { + parseList( "update-url", productPtr->update_urls, child); + } + else if (name == "extra-urls") + { + parseList( "extra-url", productPtr->extra_urls, child); + } + else if (name == "optional-urls") + { + parseList( "optional-url", productPtr->optional_urls, child); } - else if (name == "update-urls") { - parseUpdateUrls( productPtr, child); - } } } return productPtr; @@ -111,21 +121,22 @@ namespace zypp { } } - void - XMLProductParser::parseUpdateUrls( XMLProductData_Ptr productPtr, xmlNodePtr node) + template + void XMLProductParser::parseList( const std::string &tagname, std::list &list, xmlNodePtr node) { for (xmlNodePtr child = node->children; child && child != node; child = child->next) { if (_helper.isElement(child)) { string name = _helper.name(child); - if (name == "update-url") + if (name == tagname) { - productPtr->update_urls.push_back(_helper.content(child)); + list.push_back(_helper.content(child)); } } } } + } // namespace yum } // namespace parser } // namespace zypp diff --git a/zypp/parser/xmlstore/XMLProductParser.h b/zypp/parser/xmlstore/XMLProductParser.h index 3b4875d..f82c9e4 100644 --- a/zypp/parser/xmlstore/XMLProductParser.h +++ b/zypp/parser/xmlstore/XMLProductParser.h @@ -13,6 +13,7 @@ #ifndef XMLProductParser_h #define XMLProductParser_h +#include "zypp/Url.h" #include "zypp/parser/xmlstore/XMLParserData.h" #include "zypp/parser/xmlstore/XMLResObjectParser.h" #include "zypp/parser/XMLNodeIterator.h" @@ -33,7 +34,10 @@ namespace zypp { private: void parseProductFlags( XMLProductData_Ptr productPtr, xmlNodePtr node); - void parseUpdateUrls( XMLProductData_Ptr productPtr, xmlNodePtr node); + + template + void parseList( const std::string &tagname, std::list &list, xmlNodePtr node); + virtual bool isInterested(const xmlNodePtr nodePtr); virtual XMLProductData_Ptr process(const xmlTextReaderPtr reader); }; diff --git a/zypp/source/susetags/SuseTagsProductImpl.cc b/zypp/source/susetags/SuseTagsProductImpl.cc index c1699de..2ad5d8f 100644 --- a/zypp/source/susetags/SuseTagsProductImpl.cc +++ b/zypp/source/susetags/SuseTagsProductImpl.cc @@ -70,6 +70,16 @@ namespace zypp return _update_urls; } + std::list SuseTagsProductImpl::extraUrls() const + { + return _extra_urls; + } + + std::list SuseTagsProductImpl::optionalUrls() const + { + return _optional_urls; + } + std::list SuseTagsProductImpl::flags() const { return _flags; diff --git a/zypp/source/susetags/SuseTagsProductImpl.h b/zypp/source/susetags/SuseTagsProductImpl.h index ac90d91..53ddeeb 100644 --- a/zypp/source/susetags/SuseTagsProductImpl.h +++ b/zypp/source/susetags/SuseTagsProductImpl.h @@ -47,7 +47,11 @@ namespace zypp virtual TranslatedText summary() const; virtual Source_Ref source() const; virtual Url releaseNotesUrl() const; + virtual std::list updateUrls() const; + virtual std::list extraUrls() const; + virtual std::list optionalUrls() const; + virtual std::list flags() const; virtual TranslatedText shortName() const; virtual std::string distributionName() const; @@ -66,7 +70,11 @@ namespace zypp std::string _shortlabel; std::string _vendor; Url _release_notes_url; + std::list _update_urls; + std::list _extra_urls; + std::list _optional_urls; + std::map< std::string, std::list > _arch; // map of 'arch : "arch1 arch2 arch3"', arch1 being 'best', arch3 being 'noarch' (ususally) std::string _default_base; Dependencies _deps; diff --git a/zypp/target/store/XMLFilesBackend.cc b/zypp/target/store/XMLFilesBackend.cc index 3b49c4d..d4e4b35 100644 --- a/zypp/target/store/XMLFilesBackend.cc +++ b/zypp/target/store/XMLFilesBackend.cc @@ -61,6 +61,8 @@ #define ZYPP_DB_DIR ( getZYpp()->homePath().asString()+"/db/" ) using std::endl; +using std::string; +using std::list; using namespace boost::filesystem; using namespace zypp; using namespace zypp::filesystem; @@ -1012,20 +1014,50 @@ XMLFilesBackend::createProduct( const zypp::parser::xmlstore::XMLProductData & p impl->_release_notes_url = Url(); // update_urls - std::list::const_iterator - b = parsed.update_urls.begin(), - e = parsed.update_urls.end(), - i; - for (i = b; i != e; ++i) { - Url u; - try { - u = *i; - } - catch (...) { - } - impl->_update_urls.push_back (u); + list update_urls = parsed.update_urls; + for ( list::const_iterator it = update_urls.begin(); it != update_urls.end(); ++it ) + { + try + { + Url u(*it); + impl->_update_urls.push_back (u); + } + catch ( const Exception &e ) + { + ZYPP_THROW(Exception("Error parsing update url: " + e.msg())); + } } + // extra_urls + list extra_urls = parsed.extra_urls; + for ( list::const_iterator it = extra_urls.begin(); it != extra_urls.end(); ++it ) + { + try + { + Url u(*it); + impl->_extra_urls.push_back (u); + } + catch ( const Exception &e ) + { + ZYPP_THROW(Exception("Error parsing extra url: " + e.msg())); + } + } + + // extra_urls + list optional_urls = parsed.optional_urls; + for ( list::const_iterator it = optional_urls.begin(); it != optional_urls.end(); ++it ) + { + try + { + Url u(*it); + impl->_optional_urls.push_back (u); + } + catch ( const Exception &e ) + { + ZYPP_THROW(Exception("Error parsing optional url: " + e.msg())); + } + } + impl->_flags = parsed.flags; Arch arch; diff --git a/zypp/target/store/serialize.cc b/zypp/target/store/serialize.cc index 312ea48..c194cf7 100644 --- a/zypp/target/store/serialize.cc +++ b/zypp/target/store/serialize.cc @@ -354,6 +354,7 @@ std::string toXML( const Product::constPtr &obj ) out << " " << xml_escape(obj->distributionEdition().asString()) << "" << std::endl; out << " " << xml_escape(obj->source().alias()) << "" << std::endl; out << " " << xml_escape(obj->releaseNotesUrl().asString()) << "" << std::endl; + out << " " << std::endl; std::list updateUrls = obj->updateUrls(); for ( std::list::const_iterator it = updateUrls.begin(); it != updateUrls.end(); ++it) @@ -361,6 +362,23 @@ std::string toXML( const Product::constPtr &obj ) out << " " << xml_escape(it->asString()) << "" << std::endl; } out << " " << std::endl; + + out << " " << std::endl; + std::list extraUrls = obj->extraUrls(); + for ( std::list::const_iterator it = extraUrls.begin(); it != extraUrls.end(); ++it) + { + out << " " << xml_escape(it->asString()) << "" << std::endl; + } + out << " " << std::endl; + + out << " " << std::endl; + std::list optionalUrls = obj->optionalUrls(); + for ( std::list::const_iterator it = optionalUrls.begin(); it != optionalUrls.end(); ++it) + { + out << " " << xml_escape(it->asString()) << "" << std::endl; + } + out << " " << std::endl; + out << " " << std::endl; std::list flags = obj->flags(); for ( std::list::const_iterator it = flags.begin(); it != flags.end(); ++it) diff --git a/zypp/target/store/xml/XMLProductImpl.cc b/zypp/target/store/xml/XMLProductImpl.cc index 632b329..830e584 100644 --- a/zypp/target/store/xml/XMLProductImpl.cc +++ b/zypp/target/store/xml/XMLProductImpl.cc @@ -46,6 +46,12 @@ namespace zypp std::list XMLProductImpl::updateUrls() const { return _update_urls; } + + std::list XMLProductImpl::extraUrls() const + { return _extra_urls; } + + std::list XMLProductImpl::optionalUrls() const + { return _optional_urls; } std::list XMLProductImpl::flags() const { return _flags; } diff --git a/zypp/target/store/xml/XMLProductImpl.h b/zypp/target/store/xml/XMLProductImpl.h index 8a09d0c..69948d1 100644 --- a/zypp/target/store/xml/XMLProductImpl.h +++ b/zypp/target/store/xml/XMLProductImpl.h @@ -61,14 +61,22 @@ namespace zypp virtual std::string category() const; virtual TranslatedText shortName() const; virtual Url releaseNotesUrl() const; + virtual std::list updateUrls() const; + virtual std::list extraUrls() const; + virtual std::list optionalUrls() const; + virtual std::list flags() const; virtual std::string distributionName() const; virtual Edition distributionEdition() const; std::string _category; Url _release_notes_url; + std::list _update_urls; + std::list _extra_urls; + std::list _optional_urls; + std::list _flags; TranslatedText _summary; -- 2.7.4