Salome HOME
Set default path to save an installation log equal to a target directory path instead...
[tools/install.git] / src / SALOME_InstallWizard.hxx
index 5f38c9f8e74d04c93b6f841d336e5a98ada52dc5..f3564b4890b0509680a472d32bc7aab7b9383b16 100644 (file)
@@ -1,9 +1,9 @@
 //  File      : SALOME_InstallWizard.hxx
 //  Created   : Thu Dec 18 12:01:00 2002
-//  Author    : Vadim SANDLER
+//  Author    : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
 //  Project   : SALOME
 //  Module    : Installation Wizard
-//  Copyright : 2004-2005 CEA
+//  Copyright : 2002-2007 CEA
 
 #ifndef __SALOME_InstallWizard
 #define __SALOME_InstallWizard
 #include "InstallWizard.h"
 
 #include <qmap.h>
+#include <qvaluelist.h>
 #include <qstringlist.h> 
 
+class QLineEdit;
+class QPushButton;
+class QListViewItem;
+class QCheckListItem;
+class QLabel;
+class QTextEdit;
+class QTextBrowser;
+class QProcess;
+class QCheckBox;
+class QSplitter;
+class QMyCheckBox;
+class ProcessThread;
+class ProductsView;
+class ProgressView;
+class HelpWindow;
+class InstallInfo;
+class QButton;
+class QRadioButton;
+class QButtonGroup;
+
+// This enum describes the possible types of the SALOME installation
+enum InstallationType { Binaries, Sources, Compile };
+
 /*! 
   Class Dependancies : Products info
   This class stores all product dependancies for correct work of installation procedure
-     smbName   - parameter for launching install shell script (e.g. cas for CASCADE4.0).
-     dependsOn - list of products needed for correct installation of product
-                 (e.g tcl is checked during installation of CASCADE 4).
-     sizeTotal - amount of disk space in Kbytes required for installation 
-                 of this product
-     sizeTemp  - amount of disk space in Kbytes required for the temporary files
 */
 class Dependancies
 {
@@ -33,17 +51,21 @@ class Dependancies
                 const QStringList& depend, 
                 const long         Binsize,  
                 const long         Sourcessize, 
+                const long         SrcBuildsize, 
                 const long         tempsize, 
-                const QString&     def = QString::null,
+                const QString&     vers = QString::null,
                 const QString&     descr = QString::null,
+                const QString&     tp = QString::null,
                 bool               pickup = false )
     : smbName( name ), 
       dependsOn( depend ), 
-      sizeSourcesTotal( Sourcessize ), 
       sizeBinaryTotal( Binsize ), 
+      sizeSourcesTotal( Sourcessize ), 
+      sizeSrcBuildTotal( SrcBuildsize ), 
       sizeTemp( tempsize ),
-      defaultMode( def ),
+      version( vers ),
       description( descr ),
+      type( tp ),
       pickupEnv( pickup ) {}
 
   // gets symbolic name
@@ -51,44 +73,75 @@ class Dependancies
   // gets dependancies
   QStringList getDependancies() const { return dependsOn; }
   // gets disk space required
-  long        getSize(bool sources = false) const { return ( sources ? sizeSourcesTotal : sizeBinaryTotal ); }
+  long        getSize( InstallationType instType ) const 
+  { 
+    return instType == Binaries ? sizeBinaryTotal : 
+      instType == Sources ? sizeSourcesTotal : 
+      sizeSrcBuildTotal;
+  }
   // gets temporary disk space required
-  long        getTempSize() const     { return sizeTemp;   }
+  long        getTempSize( InstallationType instType ) const     
+  { 
+    return ( instType == Binaries ? 0 : instType == Sources ? 0 : sizeTemp );
+  }
+  // gets product's version
+  QString     getVersion() const      { return version; }
   // gets product's description
   QString     getDescription() const  { return description; }
-  // gets default mode
-  QString     getDefault() const      { return defaultMode; }
+  // gets product's type
+  QString     getType() const         { return type; }
   // returns true if this product needs to pick-up environment
   bool        pickUpEnvironment()     { return pickupEnv; }
 
  private:
-  QString     smbName;          // symbolic name
-  QStringList dependsOn;        // prerequisites list
-  long        sizeSourcesTotal; // disk space required
-  long        sizeBinaryTotal;  // disk space required
-  long        sizeTemp;         // disk space for temporary files required
-  QString     defaultMode;      // default installation mode
-  QString     description;      // product's description
+  QString     smbName;           // symbolic name
+  QStringList dependsOn;         // prerequisites list
+  long        sizeBinaryTotal;   // disk space for binaries required
+  long        sizeSourcesTotal;  // disk space for sources required
+  long        sizeSrcBuildTotal; // disk space for compiled sources required
+  long        sizeTemp;          // disk space for temporary files required
+  QString     version;           // product's version
+  QString     description;       // product's description
+  QString     type;              // product's type (salome sources, binaries or prerequisite)
   bool        pickupEnv;        // "Pick-up environment" flag
 };
 
-class QLineEdit;
-class QPushButton;
-class QListViewItem;
-class QCheckListItem;
-class QLabel;
-class QTextEdit;
-class QTextBrowser;
-class QProcess;
-class QCheckBox;
-class QSplitter;
+/*! 
+  Class Button : Operation button info
+  This class stores information about the custom operation buttons which appear on
+  the <Finish> page of the Install Wizard.
+*/
+class Button
+{
+ public:
+  // default constructor, required for list
+  Button() : myButton( 0 ) {}
+  // constructor
+  Button( const QString& label, const QString& tooltip, const QString& script )
+    : myLabel( label ), myTootip( tooltip ), myScript( script ), myButton( 0 ) {}
 
-class QProcessThread;
-class ProductsView;
-class ProgressView;
-class HelpWindow;
+  // set operation button
+  void setButton( QButton* btn ) { myButton = btn; }
+
+  // get label
+  QString  label()  const { return myLabel;  } 
+  // get tooltip
+  QString  tootip() const { return myTootip; }
+  // get script name
+  QString  script() const { return myScript; }
+  // get operation button
+  QButton* button() const { return myButton; }
+
+ private:
+  QString  myLabel;    // button label
+  QString  myTootip;   // button tooltip
+  QString  myScript;   // operation script
+  QButton* myButton;   // operation button
+};
 
 typedef QMap<QCheckListItem*, Dependancies> MapProducts;
+typedef QValueList<Button>                  ButtonList;
+typedef QMap<QString, QString>              MapXmlFiles;
 
 /*!
   Class SALOME_InstallWizard : Installation Wizard's main window
@@ -99,23 +152,37 @@ class SALOME_InstallWizard: public InstallWizard
     
  public:
   // constructor
-  SALOME_InstallWizard(QString aXmlFileName);
+  SALOME_InstallWizard( const QString& aXmlFileName = QString::null,
+                       const QString& aTargetDir   = QString::null,
+                       const QString& aTmpDir      = QString::null );
   // destructor
   virtual ~SALOME_InstallWizard( );
 
+  // get current platform
+  QString currentPlatform();
+
+  // get binaries path
+  QString getBinPath() { return binPath; }
+  // get sources path
+  QString getSrcPath() { return srcPath; }
+
+  // get map of supported platforms and corresponding XML files
+  MapXmlFiles getXmlMap( const QString& aXmlFileName = QString::null );
+  // check/get XML file and current platform
+  void getXmlAndPlatform();
+
   // event filter
   bool eventFilter( QObject* object, QEvent* event );
 
   // set dependancies
   void setDependancies( QCheckListItem* item, Dependancies dep);
 
-  // process validation event (<val> is validation code)
-  void processValidateEvent( const int val, void* data );
+  // add button for the <Finish> page
+  void addFinishButton( const QString& label, 
+                       const QString& tooltip, 
+                       const QString& script,
+                       bool toClear = false );
 
- public slots:
-  // polishing of the widget
-  void polish();
-  
   // set version
   void setVersion( const QString& version ) { myVersion = version; }
   // set caption
@@ -124,8 +191,6 @@ class SALOME_InstallWizard: public InstallWizard
   void setCopyright( const QString& copyright ) { myCopyright = copyright; }
   // set license
   void setLicense( const QString& license ) { myLicense = license; }
-  // set OS
-  void setOS( const QString& OS ) { myOS = OS; }
 
   // get version
   QString getVersion() { return myVersion; }
@@ -135,11 +200,23 @@ class SALOME_InstallWizard: public InstallWizard
   QString getCopyright() { return myCopyright; }
   // get license
   QString getLicense() { return myLicense; }
-  // get OS
-  QString getOS() { return myOS; }
+  // get platform
+  QString getPlatform() { return refPlatform ? refPlatform : curPlatform; }
   // get InstallWizard's name
   QString getIWName() { return myIWName; }
 
+  // process validation event (<val> is validation code)
+  void processValidateEvent( const int val, void* data );
+  // get private installation type
+  InstallationType getInstType() { return installType; };
+
+ public slots:
+  // polishing of the widget
+  void polish();
+  
+  // save install log to file
+  void saveLog();
+
  protected:
   // updates caption according to the current page number
   void updateCaption();
@@ -147,10 +224,14 @@ class SALOME_InstallWizard: public InstallWizard
   void closeEvent( QCloseEvent* ce );
   // creates introduction page
   void setupIntroPage();   
+  // create installation types page
+  void setupTypePage();
+  // create platforms page
+  void setupPlatformPage();
+  // create directories page
+  void setupDirPage();
   // creates products page
   void setupProductsPage();
-  // creates directories page
-  void setupDirPage();
   // creates prestart page
   void setupCheckPage();
   // creates progress page
@@ -160,13 +241,15 @@ class SALOME_InstallWizard: public InstallWizard
   // displays choice info
   void showChoiceInfo();
   // validates page when <Next> button is clicked
-  bool acceptData( const QString& ); 
+  bool acceptData( const QString& );
   // calculates disk space required for the installation, returns true if any product selected to be installed (src, bin or native)
   bool checkSize( long* totSize = 0, long* tempSize = 0 );
   // checks products page validity (directories and products selection)
   void checkProductPage();
-  // sets the product and all products this one depends on to be checked ( recursively )
+  // sets the product and all products this one depends on to be checked
   void setPrerequisites( QCheckListItem* item );
+  // unsets all products which depend of unchecked product ( recursively )
+  void unsetPrerequisites( QCheckListItem* item );
   // runs installation script
   void launchScript(); 
   // searches product listview item with given symbolic name 
@@ -175,6 +258,8 @@ class SALOME_InstallWizard: public InstallWizard
   void abort();
   // clears and (optionally) removes temporary directory
   void clean(bool rmDir = false);
+  // Update GUI and check installation errors
+  void completeInstallation();
 
  protected slots:
   // reject slot
@@ -185,6 +270,8 @@ class SALOME_InstallWizard: public InstallWizard
  private slots:
   // called when user moves from page to page
   void pageChanged( const QString & mytitle);
+  // called when user selected either installation type or installation platform
+  void onButtonGroup( int index );
   // invokes Help window
   void helpClicked();
   // invokes directory selection dialog box
@@ -205,12 +292,22 @@ class SALOME_InstallWizard: public InstallWizard
   void onSelectionChanged();
   // called when user checks/unchecks any product item
   void onItemToggled( QCheckListItem* );
-  // <Select Sources>, <Select Binaries>, <Unselect All> buttons slot
-  void onProdBtn();
+  // <Installation with GUI> check-box slot
+  void onInstallGuiBtn();
   // <More...> button slot
   void onMoreBtn();
-  // <Launch Salome> button slot
-  void onLaunchSalome();
+  // Slot to update 'Available disk space' field
+  void updateAvailableSpace();
+  // Slot to take result of Fortran libraries checking
+  void checkFLibResult();
+  // Slot to update 'Size' column for modules and prerequisites
+  void updateSizeColumn();
+
+  // <Finish> page buttons slot
+  void onFinishButton();
+
+  // <About> button slot
+  void onAbout();
 
   // QProcess slots:
   // -->something was written to stdin
@@ -221,63 +318,91 @@ class SALOME_InstallWizard: public InstallWizard
   void readFromStderr();
 
  private:
-  QString       myIWName;       // Installation Wizard's name
-  QString       myVersion;      // version info
-  QString       myCaption;      // application name
-  QString       myCopyright;    // copyright info 
-  QString       myLicense;      // license info
-  QString       myOS;           // operation system
+  QString          myIWName;       // Installation Wizard's name
+  QString          myVersion;      // version info
+  QString          myCaption;      // application name
+  QString          myCopyright;    // copyright info 
+  QString          myLicense;      // license info
+  QString          myTargetPath;   // target directory path
+  QString          myTmpPath;      // temporary directory path
   
-  HelpWindow*   helpWindow;     // help window
-  QProcess*     shellProcess;   // shell process (install script)
-  MapProducts   productsMap;    // products info (name, dependancies, disk space )
-  QStringList   toInstall;      // list of products being installed
-  QString       xmlFileName;    // xml file
-  bool          moreMode;       // advanced mode flag
-  QWidget*      previousPage;   // previous page
-  QString       tmpCreated;     // created temporary directory
-  bool          exitConfirmed;  // flag: "Exit confirmed"
+  HelpWindow*      helpWindow;     // help window
+  QProcess*        shellProcess;   // shell process (install script)
+  QProcess*        diskSpaceProc;  // shell process (to get available disk space script)
+  QProcess*        checkFLibProc;  // shell process (to get available disk space script)
+  MapProducts      productsMap;    // products info (name, dependancies, disk space )
+  QStringList      toInstall;      // list of products being installed
+  QStringList      notInstall;     // list of products being not installed
+  QStringList      prodSequence;   // specified list of products being installed
+  InstallationType installType;    // type of the installation
+  QString          curPlatform;    // current operating system
+  QString          refPlatform;    // referenced operating system (selected by user). It is defined, 
+                                   //   if current OS is not determined or not supported only
+  MapXmlFiles      platformsMap;   // supported operating systems and corresponding XML files
+  QString          xmlFileName;    // xml file
+  QString          binPath;        // binaries path
+  QString          srcPath;        // sources path
+  bool             moreMode;       // advanced mode flag
+  QWidget*         previousPage;   // previous page
+  QString          tmpCreated;     // created temporary directory
+  bool             stateChanged;   // flag: whether installation type or platform was changed
+  bool             exitConfirmed;  // flag: "Exit confirmed"
+  bool             rmSrcPrevState; // flag: status of "Remove SRC & TMP files" is changed ?
   // Widgets
   // --> introduction page
-  QWidget*      introPage;      // page itself
-  QLabel*       logoLab;        // logo pixmap
-  QLabel*       versionLab;     // vesrsion info
-  QLabel*       copyrightLab;   // copyright info
-  QLabel*       licenseLab;     // license info
-  QLabel*       info;           // program info
+  QWidget*         introPage;      // page itself
+  QLabel*          logoLab;        // logo pixmap
+  QLabel*          versionLab;     // version info
+  QLabel*          copyrightLab;   // copyright info
+  QLabel*          licenseLab;     // license info
+  QLabel*          info;           // program info
+  // --> installation types page
+  QWidget*         typePage;       // page itself
+  QButtonGroup*    buttonGrp;      // group of the available installation types radio-buttons
+  QRadioButton*    binBtn;         // install binaries button
+  QRadioButton*    srcBtn;         // install sources button
+  QRadioButton*    srcCompileBtn;  // install sources and compile button
+  QCheckBox*       removeSrcBtn;   // <Remove sources & tmp files> checkbox
+  // --> installation platform page
+  QWidget*         platformsPage;  // page itself
+  QButtonGroup*    platBtnGrp;     // group of platforms for selection
+  QString          warnMsg;        // warning message
+  QLabel*          warnLab;        // warning label
+  // --> installation directories page
+  QWidget*         dirPage;        // page itself
+  QLineEdit*       targetFolder;   // target directory for installing of products
+  QPushButton*     targetBtn;      // browse target directory button
+  QLineEdit*       tempFolder;     // directory for the temporary files: /tmp by default
+  QPushButton*     tempBtn;        // browse temp directory button
   // --> products page
-  QWidget*      productsPage;   // page itself
-  QLineEdit*    targetFolder;   // target directory for installing of products
-  QPushButton*  targetBtn;      // browse target directory button
-  QLineEdit*    tempFolder;     // directory for the temporary files: /tmp by default
-  QPushButton*  tempBtn;        // browse temp directory button
-  QLabel*       requiredSize;   // <Total disk space required> label
-  QLabel*       requiredTemp;   // <Space required for temporary files> label
-  QPushButton*  moreBtn;        // <More...> button
-  QWidget*      moreBox;        // container for the <More...> mode widgets
-  ProductsView* productsView;   // products list view
-  QTextBrowser* productsInfo;   // products info box
-  QCheckBox*    prerequisites;  // <Auto check prerequisites products> checkbox
-  QPushButton*  selectSrcBtn;   // <Select Sources> button - NOT USED CURRENTLY
-  QPushButton*  selectBinBtn;   // <Select Binaries> button - NOT USED CURRENTLY
-  QPushButton*  unselectBtn;    // <Unselect All> button
+  QWidget*         productsPage;   // page itself
+  ProductsView*    modulesView;    // modules list view
+  QMyCheckBox*     installGuiBtn;  // <Installation with GUI> checkbox
+  ProductsView*    prereqsView;    // prerequisites list view
+  QPushButton*     moreBtn;        // <More...> button
+  QTextBrowser*    productInfo;    // products info box
+  QLabel*          requiredSize;   // <Total disk space required> label
+  QLabel*          requiredTemp;   // <Space required for temporary files> label
+  QLabel*          availableSize;  // <Available disk space> label
   // --> prestart page
-  QWidget*      prestartPage;   // page itself
-  QTextEdit*    choices;        // choice text view
+  QWidget*         prestartPage;   // page itself
+  QTextEdit*       choices;        // choice text view
   // --> progress page
-  QWidget*      progressPage;   // page itself
-  QSplitter*    splitter;       // splitter window
-  QTextEdit*    installInfo;    // information about running installation scripts
-  QLabel*       parametersLab;  // answer field's label
-  QLineEdit*    passedParams;   // user can pass data to running script
-  QTextEdit*    installProgress;// contains information about progress of installing selected products
-  ProgressView* progressView;   // displays information about progress of installing selected products
-  // --> readme page
-  QWidget*      readmePage;     // page itself
-  QTextEdit*    readme;         // Readme information window
-  QPushButton*  runSalomeBtn;   // <Launch Salome> buttnon
-
-  QProcessThread* myThread;     // validation thread
+  QWidget*         progressPage;   // page itself
+  QSplitter*       splitter;       // splitter window
+  InstallInfo*     installInfo;    // information about running installation scripts
+  QLabel*          parametersLab;  // answer field's label
+  QLineEdit*       passedParams;   // user can pass data to running script
+  QTextEdit*       installProgress;// contains information about progress of installing selected products
+  ProgressView*    progressView;   // displays information about progress of installing selected products
+  QLabel*          statusLab;      // displays currently performed action
+  // --> finish page
+  QWidget*         readmePage;     // page itself
+  QTextEdit*       readme;         // Readme information window
+  ButtonList       buttons;        // operation buttons
+
+  ProcessThread*   myThread;       // validation thread
+  bool             hasErrors;      // flag: if there were any errors or warnings during the installation
 };
 
 #endif