Main Page | Namespace List | Class Hierarchy | Class List | Directories | 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 );
00064     void launch();
00065     ~InstSrcManager();
00066 
00067   private:
00068 
00072     static Pathname _cache_root_dir;
00073 
00077     static const Pathname _cache_tmp_dir;
00078 
00082     static const Pathname _cache_pubkey_dir;
00083 
00087     Pathname cachePath( const Pathname & sub_r ) const { return( _cache_root_dir + sub_r ); }
00088 
00089   private:
00090 
00094     Pathname cache_root_dir() const { return _cache_root_dir; }
00095 
00099     Pathname cache_tmp_dir() const { return cachePath( _cache_tmp_dir ); }
00100 
00104     Pathname cache_pubkey_dir() const { return cachePath( _cache_pubkey_dir ); }
00105 
00109     Pathname genSrcCacheName() const;
00110 
00111   private:
00112 
00113     struct ProductEntry {
00114       Pathname    _dir;
00115       std::string _name;
00116       ProductEntry( const Pathname & dir_r = "/", const std::string & name_r = std::string() ){
00117         _dir  = dir_r;
00118         _name = name_r;
00119       }
00120       bool operator<( const ProductEntry & rhs ) const {
00121         return( _dir.asString() < rhs._dir.asString() );
00122       }
00123     };
00124 
00125     typedef std::set<ProductEntry> ProductSet;
00126 
00127     PMError scanProductsFile( const Pathname & file_r, ProductSet & pset_r ) const;
00128 
00129   public:
00130 
00131     typedef PM::ISrcId     ISrcId;
00132     typedef PM::ISrcIdList ISrcIdList;
00133 
00134   private:
00135 
00136     typedef std::list<InstSrcPtr> ISrcPool;
00137 
00138     ISrcPool _knownSources;
00139 
00145     bool _want_sources_enabled;
00146 
00150     PMError initSrcPool( const bool autoEnable_r );
00151 
00155     PMError scanSrcCache( const Pathname & srccache_r );
00156 
00160     PMError writeNewRanks();
00161 
00166     ISrcPool::iterator poolHandle( const ISrcId & isrc_r );
00167 
00172     InstSrcPtr lookupId( const ISrcId & isrc_r ) const;
00173 
00178     InstSrcPtr lookupSourceByID( PM::NumericISrcID srcID_r ) const;
00179 
00192     ISrcId poolAdd( InstSrcPtr nsrc_r, bool rankcheck_r = true );
00193 
00197     PMError activateSource( const InstSrcPtr & isrc_r, bool yesno_r );
00198 
00202     PMError activateSource( const ISrcId & isrc_r, bool yesno_r );
00203 
00207     PMError intern_cacheCopyTo();
00208 
00209   public:
00210 
00218     PMError scanMedia( ISrcIdList & idlist_r, const Url & mediaurl_r );
00219 
00226     PMError scanMedia( ISrcId & isrc_r, const Url & mediaurl_r, const Pathname & product_dir_r );
00227 
00231     PMError enableSource( const ISrcId & isrc_r ) { return activateSource( isrc_r, true ); }
00232 
00236     PMError disableSource( const ISrcId & isrc_r ) { return activateSource( isrc_r, false ); }
00237 
00242     PMError refreshSource( const ISrcId & isrc_r, bool force = false );
00243 
00244   public:
00245 
00254     PMError setAutoenable( const ISrcId isrc_r, const bool yesno );
00255 
00260     PMError setAutorefresh( const ISrcId isrc_r, const bool yesno );
00261 
00265     PMError rankUp( const ISrcId isrc_r );
00266 
00270     PMError rankDown( const ISrcId isrc_r );
00271 
00276     PMError rankBehind( const ISrcId isrc_r, const ISrcId point_r );
00277 
00282     PMError rankBefore( const ISrcId isrc_r, const ISrcId point_r );
00283 
00288     PMError setNewRanks();
00289 
00298     PMError deleteSource( ISrcId & isrc_r );
00299 
00303     PMError rewriteUrl( const ISrcId isrc_r, const Url & newUrl_r );
00304 
00305     typedef PM::SrcState       SrcState;
00306     typedef PM::SrcStateVector SrcStateVector;
00307 
00312     SrcStateVector editGet() const;
00313 
00319     PMError editSet( const SrcStateVector & keep_r );
00320 
00321   public:
00322 
00326     unsigned knownSources() const { return _knownSources.size(); }
00327 
00334     ISrcIdList getSources( const bool enabled_only = false ) const;
00335 
00342     void getSources( ISrcIdList & idlist_r, const bool enabled_only = false ) const {
00343       idlist_r = getSources( enabled_only );
00344     }
00345 
00357     ISrcId getSourceByID( PM::NumericISrcID srcID_r ) const { return lookupSourceByID( srcID_r ); }
00358 
00362     void disableAllSources();
00363 
00368     void enableDefaultSources();
00369 
00375     PMError releaseMedia( const ISrcId isrc_r, bool if_removable_r = false ) const;
00376 
00381     PMError releaseAllMedia( bool if_removable_r = false ) const;
00382 
00387     void preferredLocaleChanged() const;
00388 
00394     PMError cacheCopyTo( const Pathname & newRoot_r );
00395 
00397     //
00398     // Temporary interface for handling install order (yast.order)
00399     // during installation/update.
00400     //
00402 
00403   public:
00404 
00405     typedef PM::InstOrder InstOrder;
00406 
00407   private:
00408 
00409     InstOrder _instOrder;
00410 
00411   public:
00412 
00422     void setInstOrder( const InstOrder & newOrder_r );
00423 
00428     void setDefaultInstOrder();
00429 
00433     const InstOrder & instOrder() const { return _instOrder; }
00434 
00440     ISrcIdList instOrderSources() const;
00441 
00446     int instOrderIndex( const ISrcId & isrc_r ) const;
00447 
00449     //
00450     // Manage gpg-pubkeys (package singning keys)
00451     //
00453 
00454   private:
00455 
00456     PkgPubkeyCache _pubkeyCache;
00457 
00458   public:
00459 
00460     PkgPubkeyCache & pkgPubkeyCache() { return _pubkeyCache; }
00461 
00462 };
00463 
00465 
00466 #endif // InstSrcManager_h

Generated on Mon Sep 12 21:52:12 2005 for yast2-packagemanager by  doxygen 1.4.4