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

InstYou.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                    (C) SuSE Linux AG |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       InstYou.h
00014 
00015   Author:     Cornelius Schumacher <cschum@suse.de>
00016   Maintainer: Cornelius Schumacher <cschum@suse.de>
00017 
00018   Purpose: YaST Online Update
00019 
00020 /-*/
00021 #ifndef InstYou_h
00022 #define InstYou_h
00023 
00024 #include <list>
00025 #include <string>
00026 
00027 #include <y2util/Url.h>
00028 #include <y2util/Pathname.h>
00029 #include <y2util/FSize.h>
00030 
00031 #include <y2pm/PMError.h>
00032 #include <y2pm/MediaAccess.h>
00033 
00034 #include <y2pm/PMYouPatch.h>
00035 #include <y2pm/PMYouPatchInfo.h>
00036 #include <y2pm/PMYouSettings.h>
00037 #include <y2pm/PMYouServers.h>
00038 
00040 //
00041 //      CLASS NAME : InstYou
00042 //
00043 class InstYou {
00044 
00045   public:
00050     InstYou();
00051 
00056     InstYou( const PMYouPatchInfoPtr &, const PMYouSettingsPtr & );
00057 
00061     ~InstYou();
00062 
00066     PMError initProduct();
00067 
00071     PMError servers( std::list<PMYouServer> & );
00072 
00077     PMError readUserPassword();
00078 
00086     PMError setUserPassword( const std::string &username,
00087                              const std::string &password, bool persistent );
00088 
00093     PMError retrievePatchDirectory();
00094 
00099     PMError retrievePatchInfo();
00100     
00109     PMError processPatches();
00110 
00126     void selectPatches( int kinds );
00127 
00131     void updatePackageStates();
00132 
00136     PMYouSettingsPtr settings() const { return _settings; }
00137 
00141     PMYouPatchInfoPtr patchInfo() const { return _info; }
00142 
00146     PMError removePackages();
00147 
00153     void showPatches( bool verbose = false );
00154 
00158     PMError progress( int );
00159 
00163     PMError patchProgress( int, const std::string &pkg = std::string() );
00164 
00168     PMError showError( const std::string &type, const std::string &text,
00169                        const std::string &details );
00170 
00174     PMError showError( const PMError &error );
00175 
00179     PMError showMessage( const std::string &type, std::list<PMYouPatchPtr> & );
00180 
00184     void log( const std::string &text );
00185 
00190     int lastUpdate();
00191 
00195     int installedPatches() { return _installedPatches; }
00196 
00201     FSize totalDownloadSize() { return _totalDownloadSize; }
00202 
00208     int quickCheckUpdates();
00209 
00210     /*
00211       Return currently set username used for authentificaton to the server.
00212     */
00213     std::string username() const { return _username; }
00214 
00215     /*
00216       Return currently set password used for authentificaton to the server.
00217     */
00218     std::string password() const { return _password; }
00219 
00224     void filterArchitectures( PMYouPatchPtr &patch );
00225 
00226   public:
00227     class Callbacks
00228     {
00229         public:
00230           Callbacks() {}
00231           virtual ~Callbacks() {}
00232     
00233           virtual bool progress( int percent ) = 0;
00234           virtual bool patchProgress( int percent, const std::string &str ) = 0;
00235 
00236           virtual PMError showError( const std::string &type,
00237                                      const std::string &text,
00238                                      const std::string &details ) = 0;
00239           virtual PMError showMessage( const std::string &type,
00240                                        const std::list<PMYouPatchPtr> & ) = 0;
00241           virtual void log( const std::string &text ) = 0;
00242 
00243           virtual bool executeYcpScript( const std::string &script ) = 0;
00244     };
00245 
00246     static void setCallbacks( Callbacks * );
00247 
00248   private:
00249     static Callbacks *_callbacks;
00250 
00251   private:
00252     void init();
00253 
00254   protected:
00258     PMError attachSource();
00262     PMError releaseSource();
00263 
00264     void resetProgress();
00265     bool incrementProgress();
00266 
00270     PMYouPatchPtr firstPatch();
00271     PMYouPatchPtr nextPatch();
00272 
00280     PMError retrieveCurrentPatch();
00281 
00285     PMError installCurrentPatch();
00286     
00290     PMError disconnect();
00291 
00295     PMError writeLastUpdate();
00296 
00297     PMError installPatches( const vector<PMYouPatchPtr> & );
00298     PMError installPatch( const PMYouPatchPtr & );
00299     PMError retrievePatch( const PMYouPatchPtr & );
00300     PMError retrievePackage( const PMPackagePtr &pkg, const PMYouProductPtr & );
00301     PMError retrieveScript( const std::string &script,
00302                             const PMYouProductPtr & );
00303     PMError retrieveFile( const PMYouFile &file );
00304     PMError retrieveDelta( const std::string& name, const PMYouProductPtr& prod, const std::string& md5sum);
00305 
00306     PMError executeScript( const std::string &, const PMYouProductPtr & );
00307 
00318     bool hasOnlyNewPackages( const PMYouPatchPtr &patch );
00323     bool hasNewPackages( const PMYouPatchPtr &patch );
00324 
00329     bool isNewerPackage( const PMPackagePtr &pkg );
00330 
00334     bool packageToBeInstalled( const PMYouPatchPtr &patch,
00335                                const PMPackagePtr &pkg );
00336 
00337     bool firesPackageTrigger( const PMYouPatchPtr &patch );
00338     bool firesScriptTrigger( const PMYouPatchPtr &patch );
00339 
00340     bool hasPatchRpm( const PMPackagePtr &pkg );
00341     
00346     PMError verifyMediaNumber( int number, int lastNumber );
00347 
00348   private:
00349     PMYouPatchInfoPtr _info;
00350     PMYouSettingsPtr _settings;
00351 
00352     std::vector<PMYouPatchPtr> _patches;
00353 
00354     std::vector<PMYouPatchPtr>::const_iterator _selectedPatchesIt;
00355 
00356     std::map<std::string,int> _mediaMap;
00357 
00358     int _progressTotal;
00359     int _progressCurrent;
00360     
00361     MediaAccess _media;
00362 
00363     std::string _username;
00364     std::string _password;
00365 
00366     FSize _totalDownloadSize;
00367 
00368     int _installedPatches;
00369 
00370     int _currentMediaNumber;
00371     
00372     enum
00373     {
00374       NO_DELTAS = 0,  // never use deltas
00375       ONLY_FS_DELTAS, // use deltas if they apply to installed files
00376       ANY_DELTAS,     // also use deltas that require a base rpm
00377     } _usedeltas;
00378 
00379   public:
00380     class DeltaToApply;
00381 
00382   private:
00383     std::vector<DeltaToApply*> _deltastoapply;
00384 
00394     DeltaToApply* FetchSuitableDelta(PMYouPatchPtr patch, PMPackagePtr pkg, bool quickcheck = false);
00395 
00397     void withdrawCandidates(void);
00398 };
00399 
00401 
00402 #endif // InstYou_h

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