- Service::enabled() added
authorJan Kupec <jkupec@suse.cz>
Wed, 23 Jul 2008 14:15:32 +0000 (14:15 +0000)
committerJan Kupec <jkupec@suse.cz>
Wed, 23 Jul 2008 14:15:32 +0000 (14:15 +0000)
tests/zypp/RepoManager_test.cc
zypp/RepoManager.cc
zypp/Service.cc
zypp/Service.h
zypp/parser/ServiceFileReader.cc

index 7f617ae..dd2d8e9 100644 (file)
@@ -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)
+//{
+//}
index f6bdbbd..0db0381 100644 (file)
@@ -1422,6 +1422,9 @@ namespace zypp
     for (std::set<Service>::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);
     }
index 981e7c3..39c2c28 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <ostream>
 
+#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<bool,false> 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;
   }
 
index b416217..33a9388 100644 (file)
@@ -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
index 0558a29..d10df43 100644 (file)
@@ -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;
         }