]> SALOME platform Git repositories - tools/install.git/blob - src/SALOME_InstallWizard.hxx
Salome HOME
Update logo for 5.x
[tools/install.git] / src / SALOME_InstallWizard.hxx
1 //  File      : SALOME_InstallWizard.hxx
2 //  Created   : Thu Dec 18 12:01:00 2002
3 //  Author    : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
4 //  Project   : SALOME
5 //  Module    : Installation Wizard
6 //  Copyright : 2002-2008 CEA
7
8 #ifndef __SALOME_InstallWizard
9 #define __SALOME_InstallWizard
10
11 #include "InstallWizard.h"
12
13 #include <qmap.h>
14 #include <qvaluelist.h>
15 #include <qstringlist.h> 
16
17 class QLineEdit;
18 class QPushButton;
19 class QListViewItem;
20 class QCheckListItem;
21 class QLabel;
22 class QTextEdit;
23 class QTextBrowser;
24 class QProcess;
25 class QCheckBox;
26 class QSplitter;
27 class QMyCheckBox;
28 class ProcessThread;
29 class ProductsView;
30 class ProgressView;
31 class HelpWindow;
32 class InstallInfo;
33 class QButton;
34 class QRadioButton;
35 class QButtonGroup;
36
37 // This enum describes the possible types of the SALOME installation
38 enum InstallationType { Binaries, Sources, Compile };
39 // This enum describes the possible states of a tristate parameter
40 enum BoolTristate { False, True, NotDefined };
41
42 /*! 
43   Class Dependancies : Products info
44   This class stores all product dependancies for correct work of installation procedure
45 */
46 class Dependancies
47 {
48  public:
49   // default constructor, necessary for map
50   Dependancies() {}
51   // constructor
52   Dependancies( const QString&     name, 
53                 const QStringList& depend, 
54                 const long         Binsize,  
55                 const long         Sourcessize, 
56                 const long         SrcBuildsize, 
57                 const long         tempsize, 
58                 const QString&     vers = QString::null,
59                 const QString&     descr = QString::null,
60                 const QString&     tp = QString::null,
61                 bool               pickup = false,
62                 BoolTristate       woGui = NotDefined )
63     : smbName( name ), 
64       dependsOn( depend ), 
65       sizeBinaryTotal( Binsize ), 
66       sizeSourcesTotal( Sourcessize ), 
67       sizeSrcBuildTotal( SrcBuildsize ), 
68       sizeTemp( tempsize ),
69       version( vers ),
70       description( descr ),
71       type( tp ),
72       pickupEnv( pickup ),
73       woGuiMode( woGui ) {}
74
75   // gets symbolic name
76   QString     getName() const         { return smbName;   }
77   // gets dependancies
78   QStringList getDependancies() const { return dependsOn; }
79   // gets disk space required
80   long        getSize( InstallationType instType ) const 
81   { 
82     return instType == Binaries ? sizeBinaryTotal : 
83       instType == Sources ? sizeSourcesTotal : 
84       sizeSrcBuildTotal;
85   }
86   // gets temporary disk space required
87   long        getTempSize( InstallationType instType ) const     
88   { 
89     return ( instType == Binaries ? 0 : instType == Sources ? 0 : sizeTemp );
90   }
91   // gets product's version
92   QString     getVersion() const      { return version; }
93   // gets product's description
94   QString     getDescription() const  { return description; }
95   // gets product's type
96   QString     getType() const         { return type; }
97   // returns true if this product needs to pick-up environment
98   bool        pickUpEnvironment()     { return pickupEnv; }
99   // returns true if this product supports installation without GUI mode
100   BoolTristate supportWoGuiMode()     { return woGuiMode; }
101
102  private:
103   QString     smbName;           // symbolic name
104   QStringList dependsOn;         // prerequisites list
105   long        sizeBinaryTotal;   // disk space for binaries required
106   long        sizeSourcesTotal;  // disk space for sources required
107   long        sizeSrcBuildTotal; // disk space for compiled sources required
108   long        sizeTemp;          // disk space for temporary files required
109   QString     version;           // product's version
110   QString     description;       // product's description
111   QString     type;              // product's type (salome sources, binaries or prerequisite)
112   bool        pickupEnv;        // "Pick-up environment" flag
113   BoolTristate woGuiMode;        // support of installation without GUI flag
114 };
115
116 /*! 
117   Class Button : Operation button info
118   This class stores information about the custom operation buttons which appear on
119   the <Finish> page of the Install Wizard.
120 */
121 class Button
122 {
123  public:
124   // default constructor, required for list
125   Button() : myButton( 0 ) {}
126   // constructor
127   Button( const QString& label, const QString& tooltip, const QString& script )
128     : myLabel( label ), myTootip( tooltip ), myScript( script ), myButton( 0 ) {}
129
130   // set operation button
131   void setButton( QButton* btn ) { myButton = btn; }
132
133   // get label
134   QString  label()  const { return myLabel;  } 
135   // get tooltip
136   QString  tootip() const { return myTootip; }
137   // get script name
138   QString  script() const { return myScript; }
139   // get operation button
140   QButton* button() const { return myButton; }
141
142  private:
143   QString  myLabel;    // button label
144   QString  myTootip;   // button tooltip
145   QString  myScript;   // operation script
146   QButton* myButton;   // operation button
147 };
148
149 typedef QMap<QCheckListItem*, Dependancies> MapProducts;
150 typedef QValueList<Button>                  ButtonList;
151 typedef QMap<QString, QString>              MapXmlFiles;
152 typedef QMap<QString, BoolTristate>         MapAttrStates;
153
154 /*!
155   Class SALOME_InstallWizard : Installation Wizard's main window
156 */
157 class SALOME_InstallWizard: public InstallWizard
158 {
159   Q_OBJECT
160     
161  public:
162   // constructor
163   SALOME_InstallWizard( const QString& aXmlFileName = QString::null,
164                         const QString& aTargetDir   = QString::null,
165                         const QString& aTmpDir      = QString::null,
166                         const bool     aForceSrc    = false,
167                         const bool     aSingleDir   = false );
168   // destructor
169   virtual ~SALOME_InstallWizard( );
170
171   // get base platform to install binaries package
172   QString getBasePlatform();
173   // get current platform
174   static QStringList currentPlatform();
175
176   // get binaries path
177   QString getBinPath() const { return binPath; }
178   // get sources path
179   QString getSrcPath() const { return srcPath; }
180   // get platform binaries path
181   QString getPlatformBinPath( const QString& ) const;
182
183   // get map of supported platforms and corresponding XML files
184   MapXmlFiles getXmlMap( const QString& aXmlFileName = QString::null );
185   // check/get XML file and current platform
186   void getXmlAndPlatform();
187
188   // event filter
189   bool eventFilter( QObject* object, QEvent* event );
190
191   // set dependancies
192   void setDependancies( QCheckListItem* item, Dependancies dep);
193
194   // add button for the <Finish> page
195   void addFinishButton( const QString& label, 
196                         const QString& tooltip, 
197                         const QString& script,
198                         bool toClear = false );
199
200   // set version
201   void setVersion( const QString& version ) { myVersion = version; }
202   // set caption
203   void setCaption( const QString& caption ) { myCaption = caption; updateCaption(); }
204   // set copyright
205   void setCopyright( const QString& copyright ) { myCopyright = copyright; }
206   // set license
207   void setLicense( const QString& license ) { myLicense = license; }
208
209   // get version
210   QString getVersion() { return myVersion; }
211   // get caption
212   QString getCaption() { return myCaption; }
213   // get copyright
214   QString getCopyright() { return myCopyright; }
215   // get license
216   QString getLicense() { return myLicense; }
217   // get platform
218   QString getPlatform() { return !refPlatform.isEmpty() ? refPlatform : curPlatform; }
219   // get corresponding XML file
220   QString getXmlFile( const QString& platform ) {
221     return (platformsMap.find( platform ) != platformsMap.end() ) ? 
222       platformsMap[ platform ] : 
223       QString("");
224   }
225   // get InstallWizard's name
226   QString getIWName() { return myIWName; }
227
228   // process validation event (<val> is validation code)
229   void processValidateEvent( const int val, void* data );
230   // get private installation type
231   InstallationType getInstType() { return installType; };
232
233  public slots:
234   // polishing of the widget
235   void polish();
236   
237   // save install log to file
238   void saveLog();
239
240  protected:
241   // updates caption according to the current page number
242   void updateCaption();
243   // close event handler
244   void closeEvent( QCloseEvent* ce );
245   // creates introduction page
246   void setupIntroPage();   
247   // create installation types page
248   void setupTypePage();
249   // create platforms page
250   void setupPlatformPage();
251   // create directories page
252   void setupDirPage();
253   // creates products page
254   void setupProductsPage();
255   // creates prestart page
256   void setupCheckPage();
257   // creates progress page
258   void setupProgressPage();
259   // creates readme page
260   void setupReadmePage();
261   // displays choice info
262   void showChoiceInfo();
263   // validates page when <Next> button is clicked
264   bool acceptData( const QString& );
265   // calculates disk space required for the installation, returns true if any product selected to be installed (src, bin or native)
266   bool checkSize( long* totSize = 0, long* tempSize = 0 );
267   // checks products page validity (directories and products selection)
268   void checkProductPage();
269   // sets the product and all products this one depends on to be checked
270   void setPrerequisites( QCheckListItem* item );
271   // unsets all products which depend of unchecked product ( recursively )
272   void unsetPrerequisites( QCheckListItem* item );
273   // runs installation script
274   void launchScript(); 
275   // searches product listview item with given symbolic name 
276   QCheckListItem* findItem( const QString& sName );
277   // sets progress state to Aborted
278   void abort();
279   // clears and (optionally) removes temporary directory
280   void clean(bool rmDir = false);
281   // Update GUI and check installation errors
282   void completeInstallation();
283   // Run the modification of SALOME *.la files
284   void runModifyLaFiles();
285   // Run the Fortran libraries checking
286   void runCheckFLib();
287
288  protected slots:
289   // reject slot
290   void reject();
291   // accept slot
292   void accept();
293   
294  private slots:
295   // called when user moves from page to page
296   void pageChanged( const QString & mytitle);
297   // called when user selected either installation type or installation platform
298   void onButtonGroup( int index );
299   // invokes Help window
300   void helpClicked();
301   // invokes directory selection dialog box
302   void browseDirectory();
303   // called when directory path (target or temp) is changed
304   void directoryChanged( const QString& text );
305   // <Start> button's slot - runs installation
306   void onStart();
307   // called when users tries to pass parameters for the script
308   void onReturnPressed();
309   // callback function - as response for the script finishing
310   void productInstalled();
311   // called when <Cancel> button is clicked during installation script running
312   void tryTerminate();
313   // kills installation process and quits application
314   void onCancel();
315   // called when selection is changed in the products list view
316   void onSelectionChanged();
317   // called when user checks/unchecks any product item
318   void onItemToggled( QCheckListItem* );
319   // <Installation with GUI> check-box slot
320   void onInstallGuiBtn();
321   // <More...> button slot
322   void onMoreBtn();
323   // Slot to update 'Available disk space' field
324   void updateAvailableSpace();
325   // Slot to take result of modification SALOME *.la files
326   void checkModifyLaResult();
327   // Slot to take result of Fortran libraries checking
328   void checkFLibResult();
329   // Slot to update 'Size' column for modules and prerequisites
330   void updateSizeColumn();
331
332   // <Finish> page buttons slot
333   void onFinishButton();
334
335   // <About> button slot
336   void onAbout();
337
338   // QProcess slots:
339   // -->something was written to stdin
340   void wroteToStdin();
341   // -->something was written to stout
342   void readFromStdout();
343   // -->something was written to stderr
344   void readFromStderr();
345
346  private:
347   QString          myIWName;       // Installation Wizard's name
348   QString          myVersion;      // version info
349   QString          myCaption;      // application name
350   QString          myCopyright;    // copyright info 
351   QString          myLicense;      // license info
352   QString          myTargetPath;   // target directory path
353   QString          myTmpPath;      // temporary directory path
354   
355   HelpWindow*      helpWindow;     // help window
356   QProcess*        shellProcess;   // shell process (install script)
357   QProcess*        diskSpaceProc;  // shell process (to get available disk space script)
358   QProcess*        modifyLaProc;   // shell process (to modify SALOME *.la files script)
359   QProcess*        checkFLibProc;  // shell process (to check Fortran libraries script)
360   MapProducts      productsMap;    // products info (name, dependancies, disk space )
361   MapXmlFiles      extraProducts;  // additional products to be installed
362   QStringList      toInstall;      // list of products being installed
363   QStringList      notInstall;     // list of products being not installed
364   QStringList      prodSequence;   // specified list of products being installed
365   MapAttrStates    woGuiModules;   // map of SALOME modules names, that can support installation without GUI mode
366   InstallationType installType;    // type of the installation
367   QString          curPlatform;    // current operating system
368   QString          refPlatform;    // referenced operating system (selected by user). It is defined, 
369                                    //   if current OS is not determined or not supported only
370   MapXmlFiles      platformsMap;   // supported operating systems and corresponding XML files
371   QString          xmlFileName;    // xml file
372   QString          binPath;        // binaries path
373   QString          srcPath;        // sources path
374   QString          oneProdDirName; // name of the single directory for binaries of prerequisites
375   QString          commonPlatform; // platform with universal binaries
376   bool             moreMode;       // advanced mode flag
377   QWidget*         previousPage;   // previous page
378   QString          tmpCreated;     // created temporary directory
379   bool             stateChanged;   // flag: whether installation type or platform was changed
380   bool             exitConfirmed;  // flag: "Exit confirmed"
381   bool             rmSrcPrevState; // flag: status of "Remove SRC & TMP files" is changed ?
382   // Widgets
383   // --> introduction page
384   QWidget*         introPage;      // page itself
385   QLabel*          logoLab;        // logo pixmap
386   QLabel*          versionLab;     // version info
387   QLabel*          copyrightLab;   // copyright info
388   QLabel*          licenseLab;     // license info
389   QLabel*          info;           // program info
390   // --> installation types page
391   QWidget*         typePage;       // page itself
392   QButtonGroup*    buttonGrp;      // group of the available installation types radio-buttons
393   QRadioButton*    binBtn;         // install binaries button
394   QRadioButton*    srcBtn;         // install sources button
395   QRadioButton*    srcCompileBtn;  // install sources and compile button
396   QCheckBox*       removeSrcBtn;   // <Remove sources & tmp files> checkbox
397   bool             forceSrc;       // Force all products to be compiled from sources
398   // --> installation platform page
399   QWidget*         platformsPage;  // page itself
400   QButtonGroup*    platBtnGrp;     // group of platforms for selection
401   QString          warnMsg;        // warning message
402   QLabel*          warnLab;        // warning label
403   QLabel*          warnLab3;       // additional warning label
404   // --> installation directories page
405   QWidget*         dirPage;        // page itself
406   QLineEdit*       targetFolder;   // target directory for installing of products
407   QPushButton*     targetBtn;      // browse target directory button
408   QLineEdit*       tempFolder;     // directory for the temporary files: /tmp by default
409   QPushButton*     tempBtn;        // browse temp directory button
410   // --> products page
411   QWidget*         productsPage;   // page itself
412   ProductsView*    modulesView;    // modules list view
413   QMyCheckBox*     installGuiBtn;  // <Installation with GUI> checkbox
414   ProductsView*    prereqsView;    // prerequisites list view
415   QMyCheckBox*     oneModDirBtn;   // <Install SALOME modules to a single directory> checkbox
416   QMyCheckBox*     oneProdDirBtn;  // <Install prerequisites to a single directory> checkbox
417   QPushButton*     moreBtn;        // <Show/Hide prerequisites> button
418   QTextBrowser*    productInfo;    // products info box
419   QLabel*          requiredSize;   // <Total disk space required> label
420   QLabel*          requiredTemp;   // <Space required for temporary files> label
421   QLabel*          availableSize;  // <Available disk space> label
422   bool             singleDir;      // Force all SALOME modules to be installed into single directory
423   // --> prestart page
424   QWidget*         prestartPage;   // page itself
425   QTextEdit*       choices;        // choice text view
426   // --> progress page
427   QWidget*         progressPage;   // page itself
428   QSplitter*       splitter;       // splitter window
429   InstallInfo*     installInfo;    // information about running installation scripts
430   QLabel*          parametersLab;  // answer field's label
431   QLineEdit*       passedParams;   // user can pass data to running script
432   QTextEdit*       installProgress;// contains information about progress of installing selected products
433   ProgressView*    progressView;   // displays information about progress of installing selected products
434   QLabel*          statusLab;      // displays currently performed action
435   // --> finish page
436   QWidget*         readmePage;     // page itself
437   QTextEdit*       readme;         // Readme information window
438   ButtonList       buttons;        // operation buttons
439
440   ProcessThread*   myThread;       // validation thread
441   bool             hasErrors;      // flag: if there were any errors or warnings during the installation
442 };
443
444 #endif