From: Jan Kupec Date: Wed, 23 Jul 2008 14:15:32 +0000 (+0000) Subject: - Service::enabled() added X-Git-Tag: BASE-SuSE-Code-11-Branch~577 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a7b6475afe77856310b2d679585a6510af622cd;p=platform%2Fupstream%2Flibzypp.git - Service::enabled() added --- diff --git a/tests/zypp/RepoManager_test.cc b/tests/zypp/RepoManager_test.cc index 7f617ae..dd2d8e9 100644 --- a/tests/zypp/RepoManager_test.cc +++ b/tests/zypp/RepoManager_test.cc @@ -84,6 +84,7 @@ BOOST_AUTO_TEST_CASE(repomanager_test) urlS.setPathName(DATADIR.asString()); urlS.setScheme("dir"); Service service("test",urlS); + service.setEnabled(true); manager.addService(service); manager.refreshServices(); @@ -93,6 +94,7 @@ BOOST_AUTO_TEST_CASE(repomanager_test) urlS.setPathName((DATADIR+"second").asString()); urlS.setScheme("dir"); service.setUrl(urlS); + service.setEnabled(true); manager.modifyService(service.name(),service); manager.refreshServices(); @@ -177,3 +179,8 @@ BOOST_AUTO_TEST_CASE(repo_seting_test) repo.setBaseUrl(string("http://test.org")); BOOST_CHECK_MESSAGE( repo.keepPackages(), "cache is depend on second url."); } + +//! \todo test this +//BOOST_AUTO_TEST_CASE(repo_dont_overwrite_external_settings_test) +//{ +//} diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc index f6bdbbd..0db0381 100644 --- a/zypp/RepoManager.cc +++ b/zypp/RepoManager.cc @@ -1422,6 +1422,9 @@ namespace zypp for (std::set::iterator it = _pimpl->services.begin(); it != _pimpl->services.end(); ++it) { + if ( !it->enabled() ) + continue; + MIL << "refresh: " << it->name() << " with url: "<< it->url().asString() << endl; refreshService(*it); } diff --git a/zypp/Service.cc b/zypp/Service.cc index 981e7c3..39c2c28 100644 --- a/zypp/Service.cc +++ b/zypp/Service.cc @@ -2,6 +2,7 @@ #include +#include "zypp/base/DefaultIntegral.h" #include "zypp/Url.h" #include "zypp/RepoInfo.h" #include "zypp/media/MediaManager.h" @@ -19,14 +20,15 @@ namespace zypp repos.push_back(info); return true; } - }; class Service::Impl{ public: string name; Url url; + DefaultIntegral enabled; Pathname loc; + Impl() : name("") {}; Impl(const string& name_) : name(name_) {}; Impl(const string& name_, const Url& url_) : name(name_), url(url_) {}; @@ -46,18 +48,20 @@ namespace zypp const Service Service::noService; string Service::name() const { return _pimpl->name; } - void Service::setName( const std::string& name ) { _pimpl->name = name; } Url Service::url() const { return _pimpl->url; } - void Service::setUrl( const Url& url ) { _pimpl->url = url; } + bool Service::enabled() const { return _pimpl->enabled; } + void Service::setEnabled( const bool enabled ) { _pimpl->enabled = enabled; } + void Service::dumpServiceOn( std::ostream& str ) const { str << endl; str << "[" << name() << "]" << endl; str << "url = " << url() << endl; + str << "enabled = " << ( enabled() ? "1" : "0") << endl; str << endl; } diff --git a/zypp/Service.h b/zypp/Service.h index b416217..33a9388 100644 --- a/zypp/Service.h +++ b/zypp/Service.h @@ -67,6 +67,16 @@ namespace zypp Url url() const; /** + * Returns 'enabled' flag of the services. + * + * Disabled services imply disabled repositories of these services + * and they won't be refreshed by \ref RepoManager::refreshServices(). + * + * Enabled services will be refreshed by \ref RepoManager::refreshServices(). + */ + bool enabled() const; + + /** * Gets from which file is this service loaded or saved. * * \note this is empty for newly created file until it is saved @@ -99,6 +109,12 @@ namespace zypp */ void setName( const std::string& name ); + /** + * Sets enabled status of the services. + * \param enabled The desired status. + */ + void setEnabled( const bool enabled ); + public: /** * Writes Service to stream in ".service" format diff --git a/zypp/parser/ServiceFileReader.cc b/zypp/parser/ServiceFileReader.cc index 0558a29..d10df43 100644 --- a/zypp/parser/ServiceFileReader.cc +++ b/zypp/parser/ServiceFileReader.cc @@ -59,8 +59,10 @@ namespace zypp ++it ) { //MIL << (*it).first << endl; - if (it->first == "url" ) + if ( it->first == "url" ) service.setUrl( Url (it->second) ); + else if ( it->first == "enabled" ) + service.setEnabled( str::strToTrue( it->second ) ); else ERR << "Unknown attribute " << it->second << " ignored" << endl; }