Main Page | Namespace List | Class Hierarchy | Class List | 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 InstYou::retrieveFile( const PMYouFile &file );
00304 
00305     PMError executeScript( const std::string &, const PMYouProductPtr & );
00306     PMError executeScript( const std::string & script, const PMYouProductPtr & product,
00307                            const std::list<std::string> & arguments );
00308 
00319     bool hasOnlyNewPackages( const PMYouPatchPtr &patch );
00324     bool hasNewPackages( const PMYouPatchPtr &patch );
00325 
00330     bool isNewerPackage( const PMPackagePtr &pkg );
00331 
00335     bool packageToBeInstalled( const PMYouPatchPtr &patch,
00336                                const PMPackagePtr &pkg );
00337 
00338     bool firesPackageTrigger( const PMYouPatchPtr &patch );
00339     bool firesScriptTrigger( const PMYouPatchPtr &patch );
00340 
00341     bool hasPatchRpm( const PMPackagePtr &pkg );
00342 
00347     PMError verifyMediaNumber( int number, int lastNumber );
00348 
00349   private:
00350     PMYouPatchInfoPtr _info;
00351     PMYouSettingsPtr _settings;
00352     
00353     std::vector<PMYouPatchPtr> _patches;
00354 
00355     std::vector<PMYouPatchPtr>::const_iterator _selectedPatchesIt;
00356 
00357     std::map<std::string,int> _mediaMap;
00358 
00359     int _progressTotal;
00360     int _progressCurrent;
00361     
00362     MediaAccess _media;
00363 
00364     std::string _username;
00365     std::string _password;
00366 
00367     FSize _totalDownloadSize;
00368 
00369     int _installedPatches;
00370 
00371     int _currentMediaNumber;
00372 };
00373 
00375 
00376 #endif // InstYou_h

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