Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

InstSrcManager.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       InstSrcManager.h
00014 
00015   Author:     Michael Andres <ma@suse.de>
00016   Maintainer: Michael Andres <ma@suse.de>
00017 
00018 /-*/
00019 #ifndef InstSrcManager_h
00020 #define InstSrcManager_h
00021 
00022 #include <iosfwd>
00023 
00024 #include <y2util/Url.h>
00025 
00026 #include <y2pm/PMTypes.h>
00027 
00028 #include <y2pm/InstSrcPtr.h>
00029 #include <y2pm/InstSrcError.h>
00030 #include <y2pm/PkgPubkeyCache.h>
00031 
00033 //
00034 //      CLASS NAME : InstSrcManager
00038 class InstSrcManager {
00039 
00040   friend std::ostream & operator<<( std::ostream & str, const InstSrcManager & obj );
00041 
00042   InstSrcManager & operator=( const InstSrcManager & );
00043   InstSrcManager            ( const InstSrcManager & );
00044 
00045   public:
00046 
00050     typedef InstSrcError Error;
00051 
00052     static const unsigned NO_RANK = unsigned(-1);
00053 
00054   private:
00055 
00056     friend class Y2PM;
00057     InstSrcManager( const bool autoEnable_r = true );
00058     ~InstSrcManager();
00059 
00060   private:
00061 
00065     static Pathname _cache_root_dir;
00066 
00070     static const Pathname _cache_tmp_dir;
00071 
00075     static const Pathname _cache_pubkey_dir;
00076 
00080     Pathname cachePath( const Pathname & sub_r ) const { return( _cache_root_dir + sub_r ); }
00081 
00082   private:
00083 
00087     Pathname cache_root_dir() const { return _cache_root_dir; }
00088 
00092     Pathname cache_tmp_dir() const { return cachePath( _cache_tmp_dir ); }
00093 
00097     Pathname cache_pubkey_dir() const { return cachePath( _cache_pubkey_dir ); }
00098 
00102     Pathname genSrcCacheName() const;
00103 
00104   private:
00105 
00106     struct ProductEntry {
00107       Pathname    _dir;
00108       std::string _name;
00109       ProductEntry( const Pathname & dir_r = "/", const std::string & name_r = std::string() ){
00110         _dir  = dir_r;
00111         _name = name_r;
00112       }
00113       bool operator<( const ProductEntry & rhs ) const {
00114         return( _dir.asString() < rhs._dir.asString() );
00115       }
00116     };
00117 
00118     typedef std::set<ProductEntry> ProductSet;
00119 
00120     PMError scanProductsFile( const Pathname & file_r, ProductSet & pset_r ) const;
00121 
00122   public:
00123 
00127     typedef InstSrcError Error;
00128 
00129     typedef PM::ISrcId     ISrcId;
00130     typedef PM::ISrcIdList ISrcIdList;
00131 
00132   private:
00133 
00134     typedef std::list<InstSrcPtr> ISrcPool;
00135 
00136     ISrcPool _knownSources;
00137 
00143     bool _want_sources_enabled;
00144 
00148     PMError initSrcPool( const bool autoEnable_r );
00149 
00153     PMError scanSrcCache( const Pathname & srccache_r );
00154 
00158     PMError writeNewRanks();
00159 
00164     ISrcPool::iterator poolHandle( const ISrcId & isrc_r );
00165 
00170     InstSrcPtr lookupId( const ISrcId & isrc_r ) const;
00171 
00176     InstSrcPtr lookupSourceByID( PM::NumericISrcID srcID_r ) const;
00177 
00190     ISrcId poolAdd( InstSrcPtr nsrc_r, bool rankcheck_r = true );
00191 
00195     PMError activateSource( const InstSrcPtr & isrc_r, bool yesno_r );
00196 
00200     PMError activateSource( const ISrcId & isrc_r, bool yesno_r );
00201 
00205     PMError intern_cacheCopyTo();
00206 
00207   public:
00208 
00216     PMError scanMedia( ISrcIdList & idlist_r, const Url & mediaurl_r );
00217 
00224     PMError scanMedia( ISrcId & isrc_r, const Url & mediaurl_r, const Pathname & product_dir_r );
00225 
00229     PMError enableSource( const ISrcId & isrc_r ) { return activateSource( isrc_r, true ); }
00230 
00234     PMError disableSource( const ISrcId & isrc_r ) { return activateSource( isrc_r, false ); }
00235 
00236   public:
00237 
00246     PMError setAutoenable( const ISrcId isrc_r, const bool yesno );
00247 
00251     PMError rankUp( const ISrcId isrc_r );
00252 
00256     PMError rankDown( const ISrcId isrc_r );
00257 
00262     PMError rankBehind( const ISrcId isrc_r, const ISrcId point_r );
00263 
00268     PMError rankBefore( const ISrcId isrc_r, const ISrcId point_r );
00269 
00274     PMError setNewRanks();
00275 
00284     PMError deleteSource( ISrcId & isrc_r );
00285 
00289     PMError rewriteUrl( const ISrcId isrc_r, const Url & newUrl_r );
00290 
00291     typedef PM::SrcState       SrcState;
00292     typedef PM::SrcStateVector SrcStateVector;
00293 
00298     SrcStateVector editGet() const;
00299 
00305     PMError editSet( const SrcStateVector & keep_r );
00306 
00307   public:
00308 
00312     unsigned knownSources() const { return _knownSources.size(); }
00313 
00320     ISrcIdList getSources( const bool enabled_only = false ) const;
00321 
00328     void getSources( ISrcIdList & idlist_r, const bool enabled_only = false ) const {
00329       idlist_r = getSources( enabled_only );
00330     }
00331 
00343     ISrcId getSourceByID( PM::NumericISrcID srcID_r ) const { return lookupSourceByID( srcID_r ); }
00344 
00348     void disableAllSources();
00349 
00354     void enableDefaultSources();
00355 
00361     PMError releaseMedia( const ISrcId isrc_r, bool if_removable_r = false ) const;
00362 
00367     PMError releaseAllMedia( bool if_removable_r = false ) const;
00368 
00373     void preferredLocaleChanged() const;
00374 
00380     PMError cacheCopyTo( const Pathname & newRoot_r );
00381 
00383     //
00384     // Temporary interface for handling install order (yast.order)
00385     // during installation/update.
00386     //
00388 
00389   public:
00390 
00391     typedef PM::InstOrder InstOrder;
00392 
00393   private:
00394 
00395     InstOrder _instOrder;
00396 
00397   public:
00398 
00408     void setInstOrder( const InstOrder & newOrder_r );
00409 
00414     void setDefaultInstOrder();
00415 
00419     const InstOrder & instOrder() const { return _instOrder; }
00420 
00426     ISrcIdList instOrderSources() const;
00427 
00432     int instOrderIndex( const ISrcId & isrc_r ) const;
00433 
00435     //
00436     // Manage gpg-pubkeys (package singning keys)
00437     //
00439 
00440   private:
00441 
00442     PkgPubkeyCache _pubkeyCache;
00443 
00444   public:
00445 
00446     PkgPubkeyCache & pkgPubkeyCache() { return _pubkeyCache; }
00447 
00448 };
00449 
00451 
00452 #endif // InstSrcManager_h

Generated on Fri Nov 9 14:30:31 2007 for yast2-packagemanager by doxygen 1.3.6