implement "possibleLocales"
authorKlaus Kaempf <kkaempf@suse.de>
Sun, 26 Feb 2006 08:00:51 +0000 (08:00 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Sun, 26 Feb 2006 08:00:51 +0000 (08:00 +0000)
zypp/ZYpp.cc
zypp/ZYpp.h
zypp/zypp_detail/ZYppImpl.cc
zypp/zypp_detail/ZYppImpl.h

index b960d14..33f6d23 100644 (file)
@@ -110,6 +110,12 @@ namespace zypp
   ZYpp::LocaleSet ZYpp::getRequestedLocales() const
   { return _pimpl->getRequestedLocales(); }
 
+  void ZYpp::setPossibleLocales( const LocaleSet & locales_r )
+  { _pimpl->setPossibleLocales( locales_r ); }
+
+  ZYpp::LocaleSet ZYpp::getPossibleLocales() const
+  { return _pimpl->getPossibleLocales(); }
+
   Arch ZYpp::architecture() const
   { return _pimpl->architecture(); }
   void ZYpp::setArchitecture( const Arch & arch )
index deb4b27..ac32975 100644 (file)
@@ -120,6 +120,13 @@ namespace zypp
     /** */
     LocaleSet getRequestedLocales() const;
 
+    /** Set the available locales.
+     * Languages to be available for selection
+    */
+    void setPossibleLocales( const LocaleSet & locales_r );
+    /** */
+    LocaleSet getPossibleLocales() const;
+
   public:
     /** Get the path where zypp related plugins store persistent data and caches   */
     Pathname homePath() const;
index f9eced0..1fe83a4 100644 (file)
 //#include "zypp/base/Logger.h"
 
 #include "zypp/zypp_detail/ZYppImpl.h"
+#include "zypp/detail/LanguageImpl.h"
+#include "zypp/detail/ResImplTraits.h"
+#include "zypp/NVRAD.h"
+#include "zypp/Language.h"
 
 using std::endl;
 
@@ -82,6 +86,9 @@ namespace zypp
     {
     }
 
+    //------------------------------------------------------------------------
+    // add/remove resolvables
+
     void ZYppImpl::addResolvables (const ResStore& store, bool installed)
     {
        _pool.insert(store.begin(), store.end(), installed);
@@ -104,6 +111,9 @@ namespace zypp
        }
     }
 
+    //------------------------------------------------------------------------
+    // target
+
     Target_Ptr ZYppImpl::target() const
     {
       if (! _target)
@@ -135,6 +145,9 @@ namespace zypp
       _target = 0;
     }
 
+    //------------------------------------------------------------------------
+    // commit
+
     /** \todo Remove workflow from target, lot's of it could be done here,
     * and target used for transact. */
     ZYpp::CommitResult ZYppImpl::commit( int medianr_r )
@@ -167,14 +180,50 @@ namespace zypp
     }
 
 
+    //------------------------------------------------------------------------
+    // locales
+
+    /** */
+    void ZYppImpl::setPossibleLocales( const LocaleSet & locales_r )
+    {
+       removeResolvables( _possible_locales );
+       _possible_locales.clear();
+
+       for (LocaleSet::const_iterator it = locales_r.begin(); it != locales_r.end(); ++it) {
+           NVRA nvra( it->code(), Edition(), Arch_noarch );
+           NVRAD ldata( nvra, Dependencies() );
+           detail::ResImplTraits<detail::LanguageImpl>::Ptr limpl = new detail::LanguageImpl();
+           Language::Ptr language = detail::makeResolvableFromImpl( ldata, limpl );
+           _possible_locales.insert( language );
+       }
+       addResolvables( _possible_locales, false );
+    }
+
+    /** */
+    ZYppImpl::LocaleSet ZYppImpl::getPossibleLocales() const
+    {
+       LocaleSet lset;
+       for (ResStore::const_iterator it = _possible_locales.begin(); it != _possible_locales.end(); ++it) {
+           lset.insert( Locale( (*it)->name() ) );
+       }
+       return lset;
+    }
+
+    //------------------------------------------------------------------------
+    // architecture
+
     void ZYppImpl::setArchitecture( const Arch & arch )
     {
        _architecture = arch;
        if (_resolver) _resolver->setArchitecture( arch );
     }
 
+    //------------------------------------------------------------------------
+    // target store path
+
     Pathname ZYppImpl::homePath() const
     { return _home_path.empty() ? Pathname("/var/lib/zypp") : _home_path; }
+
     void ZYppImpl::setHomePath( const Pathname & path )
     { _home_path = path; }  
     
index cbe44de..cd68534 100644 (file)
@@ -100,10 +100,15 @@ namespace zypp
       typedef std::set<Locale> LocaleSet;
       /** */
       void setRequestedLocales( const LocaleSet & locales_r )
-      {}
+      {  _requested_locales = locales_r; }
       /** */
       LocaleSet getRequestedLocales() const
-      { return LocaleSet(); }
+      { return _requested_locales; }
+
+      /** */
+      void setPossibleLocales( const LocaleSet & locales_r );
+      /** */
+      LocaleSet getPossibleLocales() const;
 
     public:
       /** Get the system architecture.   */
@@ -130,7 +135,12 @@ namespace zypp
       Resolver_Ptr _resolver;
       /** */
       Arch _architecture;
+      /** */
       Pathname _home_path;
+      /** this is what the user wants. */
+      LocaleSet _requested_locales;
+      /** this is what is possible. */
+      ResStore _possible_locales;
     };
     ///////////////////////////////////////////////////////////////////