]> SALOME platform Git repositories - tools/install.git/blob - src/SALOME_InstallWizard.hxx
Salome HOME
Modifications in according to improvement 15165.
[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-2007 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
40 /*! 
41   Class Dependancies : Products info
42   This class stores all product dependancies for correct work of installation procedure
43 */
44 class Dependancies
45 {
46  public:
47   // default constructor, necessary for map
48   Dependancies() {}
49   // constructor
50   Dependancies( const QString&     name, 
51                 const QStringList& depend, 
52                 const long         Binsize,  
53                 const long         Sourcessize, 
54                 const long         SrcBuildsize, 
55                 const long         tempsize, 
56                 const QString&     vers = QString::null,
57                 const QString&     descr = QString::null,
58                 const QString&     tp = QString::null,
59                 bool               pickup = false )
60     : smbName( name ), 
61       dependsOn( depend ), 
62       sizeBinaryTotal( Binsize ), 
63       sizeSourcesTotal( Sourcessize ), 
64       sizeSrcBuildTotal( SrcBuildsize ), 
65       sizeTemp( tempsize ),
66       version( vers ),
67       description( descr ),
68       type( tp ),
69       pickupEnv( pickup ) {}
70
71   // gets symbolic name
72   QString     getName() const         { return smbName;   }
73   // gets dependancies
74   QStringList getDependancies() const { return dependsOn; }
75   // gets disk space required
76   long        getSize( InstallationType instType ) const 
77   { 
78     return ( instType == Binaries ? ( type == "component" ? sizeBinaryTotal + sizeSourcesTotal : sizeBinaryTotal ) :
79              ( instType == Sources ? sizeSourcesTotal : sizeSrcBuildTotal ) );
80   }
81   // gets temporary disk space required
82   long        getTempSize( InstallationType instType ) const     
83   { 
84     return ( instType == Binaries ? 0 : instType == Sources ? 0 : sizeTemp );
85   }
86   // gets product's version
87   QString     getVersion() const      { return version; }
88   // gets product's description
89   QString     getDescription() const  { return description; }
90   // gets product's type
91   QString     getType() const         { return type; }
92   // returns true if product supports given type
93   bool        hasType( const QString& tp ) const
94   {
95     QStringList tl = QStringList::split(",",type);
96     return tl.find( tp ) != tl.end();
97   }
98   // gets default mode
99   QString     getDefault() const      { return ""; }
100   // returns true if this product needs to pick-up environment
101   bool        pickUpEnvironment()     { return pickupEnv; }
102
103  private:
104   QString     smbName;           // symbolic name
105   QStringList dependsOn;         // prerequisites list
106   long        sizeBinaryTotal;   // disk space for binaries required
107   long        sizeSourcesTotal;  // disk space for sources required
108   long        sizeSrcBuildTotal; // disk space for compiled sources required
109   long        sizeTemp;          // disk space for temporary files required
110   QString     version;           // product's version
111   QString     description;       // product's description
112   QString     type;              // product's type (salome sources, binaries or prerequisite)
113   bool        pickupEnv;        // "Pick-up environment" 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
153 /*!
154   Class SALOME_InstallWizard : Installation Wizard's main window
155 */
156 class SALOME_InstallWizard: public InstallWizard
157 {
158   Q_OBJECT
159     
160  public:
161   // constructor
162   SALOME_InstallWizard( const QString& aXmlFileName = QString::null,
163                         const QString& aTargetDir   = QString::null,
164                         const QString& aTmpDir      = QString::null );
165   // destructor
166   virtual ~SALOME_InstallWizard( );
167
168   // get current platform
169   QString currentPlatform();
170
171   // get binaries path
172   QString getBinPath() { return binPath; }
173   // get sources path
174   QString getSrcPath() { return srcPath; }
175
176   // get map of supported platforms and corresponding XML files
177   MapXmlFiles getXmlMap( const QString& aXmlFileName = QString::null );
178   // check/get XML file and current platform
179   void getXmlAndPlatform();
180
181   // event filter
182   bool eventFilter( QObject* object, QEvent* event );
183
184   // set dependancies
185   void setDependancies( QCheckListItem* item, Dependancies dep);
186
187   // add button for the <Finish> page
188   void addFinishButton( const QString& label, 
189                         const QString& tooltip, 
190                         const QString& script,
191                         bool toClear = false );
192
193   // set version
194   void setVersion( const QString& version ) { myVersion = version; }
195   // set caption
196   void setCaption( const QString& caption ) { myCaption = caption; updateCaption(); }
197   // set copyright
198   void setCopyright( const QString& copyright ) { myCopyright = copyright; }
199   // set license
200   void setLicense( const QString& license ) { myLicense = license; }
201
202   // get version
203   QString getVersion() { return myVersion; }
204   // get caption
205   QString getCaption() { return myCaption; }
206   // get copyright
207   QString getCopyright() { return myCopyright; }
208   // get license
209   QString getLicense() { return myLicense; }
210   // get platform
211   QString getPlatform() { return refPlatform ? refPlatform : curPlatform; }
212   // get InstallWizard's name
213   QString getIWName() { return myIWName; }
214
215   // process validation event (<val> is validation code)
216   void processValidateEvent( const int val, void* data );
217   // get private installation type
218   InstallationType getInstType() { return installType; };
219
220  public slots:
221   // polishing of the widget
222   void polish();
223   
224   // save install log to file
225   void saveLog();
226
227  protected:
228   // updates caption according to the current page number
229   void updateCaption();
230   // close event handler
231   void closeEvent( QCloseEvent* ce );
232   // creates introduction page
233   void setupIntroPage();   
234   // create installation types page
235   void setupTypePage();
236   // create platforms page
237   void setupPlatformPage();
238   // create directories page
239   void setupDirPage();
240   // creates products page
241   void setupProductsPage();
242   // creates prestart page
243   void setupCheckPage();
244   // creates progress page
245   void setupProgressPage();
246   // creates readme page
247   void setupReadmePage();
248   // displays choice info
249   void showChoiceInfo();
250   // validates page when <Next> button is clicked
251   bool acceptData( const QString& );
252   // calculates disk space required for the installation, returns true if any product selected to be installed (src, bin or native)
253   bool checkSize( long* totSize = 0, long* tempSize = 0 );
254   // checks products page validity (directories and products selection)
255   void checkProductPage();
256   // sets the product and all products this one depends on to be checked
257   void setPrerequisites( QCheckListItem* item );
258   // unsets all products which depend of unchecked product ( recursively )
259   void unsetPrerequisites( QCheckListItem* item );
260   // runs installation script
261   void launchScript(); 
262   // searches product listview item with given symbolic name 
263   QCheckListItem* findItem( const QString& sName );
264   // sets progress state to Aborted
265   void abort();
266   // clears and (optionally) removes temporary directory
267   void clean(bool rmDir = false);
268
269  protected slots:
270   // reject slot
271   void reject();
272   // accept slot
273   void accept();
274   
275  private slots:
276   // called when user moves from page to page
277   void pageChanged( const QString & mytitle);
278   // called when user selected either installation type or installation platform
279   void onButtonGroup( int index );
280   // invokes Help window
281   void helpClicked();
282   // invokes directory selection dialog box
283   void browseDirectory();
284   // called when directory path (target or temp) is changed
285   void directoryChanged( const QString& text );
286   // <Start> button's slot - runs installation
287   void onStart();
288   // called when users tries to pass parameters for the script
289   void onReturnPressed();
290   // callback function - as response for the script finishing
291   void productInstalled();
292   // called when <Cancel> button is clicked during installation script running
293   void tryTerminate();
294   // kills installation process and quits application
295   void onCancel();
296   // called when selection is changed in the products list view
297   void onSelectionChanged();
298   // called when user checks/unchecks any product item
299   void onItemToggled( QCheckListItem* );
300   // <Installation with GUI> check-box slot
301   void onInstallGuiBtn();
302   // <More...> button slot
303   void onMoreBtn();
304   // Slot to update 'Available disk space' field
305   void updateAvailableSpace();
306
307   // <Finish> page buttons slot
308   void onFinishButton();
309
310   // <About> button slot
311   void onAbout();
312
313   // QProcess slots:
314   // -->something was written to stdin
315   void wroteToStdin();
316   // -->something was written to stout
317   void readFromStdout();
318   // -->something was written to stderr
319   void readFromStderr();
320
321  private:
322   QString          myIWName;       // Installation Wizard's name
323   QString          myVersion;      // version info
324   QString          myCaption;      // application name
325   QString          myCopyright;    // copyright info 
326   QString          myLicense;      // license info
327   QString          myTargetPath;   // target directory path
328   QString          myTmpPath;      // temporary directory path
329   
330   HelpWindow*      helpWindow;     // help window
331   QProcess*        shellProcess;   // shell process (install script)
332   QProcess*        diskSpaceProc;  // shell process (to get available disk space script)
333   MapProducts      productsMap;    // products info (name, dependancies, disk space )
334   QStringList      toInstall;      // list of products being installed
335   QStringList      notInstall;     // list of products being not installed
336   QStringList      prodSequence;   // specified list of products being installed
337   InstallationType installType;    // type of the installation
338   QString          curPlatform;    // current operating system
339   QString          refPlatform;    // referenced operating system (selected by user). It is defined, 
340                                    //   if current OS is not determined or not supported only
341   MapXmlFiles      platformsMap;   // supported operating systems and corresponding XML files
342   QString          xmlFileName;    // xml file
343   QString          binPath;        // binaries path
344   QString          srcPath;        // sources path
345   bool             moreMode;       // advanced mode flag
346   QWidget*         previousPage;   // previous page
347   QString          tmpCreated;     // created temporary directory
348   bool             stateChanged;   // flag: whether installation type or platform was changed
349   bool             exitConfirmed;  // flag: "Exit confirmed"
350   // Widgets
351   // --> introduction page
352   QWidget*         introPage;      // page itself
353   QLabel*          logoLab;        // logo pixmap
354   QLabel*          versionLab;     // version info
355   QLabel*          copyrightLab;   // copyright info
356   QLabel*          licenseLab;     // license info
357   QLabel*          info;           // program info
358   // --> installation types page
359   QWidget*         typePage;       // page itself
360   QButtonGroup*    buttonGrp;      // group of the available installation types radio-buttons
361   QRadioButton*    binBtn;         // install binaries button
362   QRadioButton*    srcBtn;         // install sources button
363   QRadioButton*    srcCompileBtn;  // install sources and compile button
364   QMyCheckBox*     removeSrcBtn;   // <Remove sources & tmp files> checkbox
365   // --> installation platform page
366   QWidget*         platformsPage;  // page itself
367   QButtonGroup*    platBtnGrp;     // group of platforms for selection
368   QString          warnMsg;        // warning message
369   QLabel*          warnLab;        // warning label
370   // --> installation directories page
371   QWidget*         dirPage;        // page itself
372   QLineEdit*       targetFolder;   // target directory for installing of products
373   QPushButton*     targetBtn;      // browse target directory button
374   QLineEdit*       tempFolder;     // directory for the temporary files: /tmp by default
375   QPushButton*     tempBtn;        // browse temp directory button
376   // --> products page
377   QWidget*         productsPage;   // page itself
378   ProductsView*    modulesView;    // modules list view
379   QMyCheckBox*     installGuiBtn;  // <Installation with GUI> checkbox
380   ProductsView*    prereqsView;    // prerequisites list view
381   QPushButton*     moreBtn;        // <More...> button
382   QTextBrowser*    productInfo;    // products info box
383   QLabel*          requiredSize;   // <Total disk space required> label
384   QLabel*          requiredTemp;   // <Space required for temporary files> label
385   QLabel*          availableSize;  // <Available disk space> label
386   // --> prestart page
387   QWidget*         prestartPage;   // page itself
388   QTextEdit*       choices;        // choice text view
389   // --> progress page
390   QWidget*         progressPage;   // page itself
391   QSplitter*       splitter;       // splitter window
392   InstallInfo*     installInfo;    // information about running installation scripts
393   QLabel*          parametersLab;  // answer field's label
394   QLineEdit*       passedParams;   // user can pass data to running script
395   QTextEdit*       installProgress;// contains information about progress of installing selected products
396   ProgressView*    progressView;   // displays information about progress of installing selected products
397   QLabel*          statusLab;      // displays currently performed action
398   // --> finish page
399   QWidget*         readmePage;     // page itself
400   QTextEdit*       readme;         // Readme information window
401   ButtonList       buttons;        // operation buttons
402
403   ProcessThread*   myThread;       // validation thread
404   bool             hasErrors;      // flag: if there were any errors or warnings during the installation
405 };
406
407 #endif