]> SALOME platform Git repositories - tools/install.git/blob - src/SALOME_InstallWizard.cxx
Salome HOME
NPAL19776(installation of Salome without gui in install wisard is not good): correct...
[tools/install.git] / src / SALOME_InstallWizard.cxx
1 //  File      : SALOME_InstallWizard.cxx
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 #include "globals.h"
9
10 #include "SALOME_InstallWizard.hxx"
11 #include "SALOME_ProductsView.hxx"
12 #include "SALOME_ProgressView.hxx"
13 #include "SALOME_XmlHandler.hxx"
14 #include "SALOME_HelpWindow.hxx"
15
16 #include "icons.h"
17
18 #include <qlineedit.h>
19 #include <qpushbutton.h>
20 #include <qlistview.h>
21 #include <qlabel.h>
22 #include <qtextedit.h>
23 #include <qtextbrowser.h>
24 #include <qprocess.h>
25 #include <qcheckbox.h>
26 #include <qsplitter.h>
27 #include <qlayout.h>
28 #include <qfiledialog.h>
29 #include <qapplication.h>
30 #include <qfileinfo.h>
31 #include <qmessagebox.h>
32 #include <qtimer.h>
33 #include <qvbox.h>
34 #include <qwhatsthis.h>
35 #include <qtooltip.h>
36 #include <qfile.h>
37 #include <qthread.h>
38 #include <qwaitcondition.h>
39 #include <qmutex.h>
40 #include <qstringlist.h>
41 #include <qpopupmenu.h>
42 #include <qregexp.h>
43 #include <qradiobutton.h>
44 #include <qbuttongroup.h>
45 #include <qregexp.h>
46
47 #ifdef WNT
48 #include <iostream.h>
49 #include <process.h>
50 #else
51 #include <unistd.h>
52 #include <algo.h>
53 #endif
54
55 #ifdef WNT
56 #define max( x, y ) ( x ) > ( y ) ? ( x ) : ( y )
57 #endif
58
59 QString tmpDirName() { return QString(  "/INSTALLWORK" ) + QString::number( getpid() ); }
60 #define TEMPDIRNAME tmpDirName()
61
62 // ================================================================
63 /*!
64  *  ProcessThread
65  *  Class for executing systen commands
66  */
67 // ================================================================
68 static QMutex myMutex(false);
69 static QWaitCondition myWC;
70 class ProcessThread: public QThread
71 {
72   typedef QPtrList<QCheckListItem> ItemList;
73 public:
74   ProcessThread( SALOME_InstallWizard* iw ) : QThread(), myWizard( iw ) { myItems.setAutoDelete( false ); }
75
76   void addCommand( QCheckListItem* item, const QString& cmd ) {
77     myItems.append( item );
78     myCommands.push_back( cmd );
79   }
80
81   bool hasCommands() const { return myCommands.count() > 0; }
82   void clearCommands()     { myCommands.clear(); myItems.clear(); }
83
84   virtual void run() {
85     while ( hasCommands() ) {
86       ___MESSAGE___( "ProcessThread::run - Processing command : " << myCommands[ 0 ].latin1() );
87       int result = system( myCommands[ 0 ] ) / 256; // return code is <errno> * 256
88       ___MESSAGE___( "ProcessThread::run - Result : " << result );
89       QCheckListItem* item = myItems.first();
90       myCommands.pop_front();
91       myItems.removeFirst();
92       myMutex.lock();
93       SALOME_InstallWizard::postValidateEvent( myWizard, result, (void*)item );
94       if ( hasCommands() )
95         myWC.wait(&myMutex);
96       myMutex.unlock();
97     };
98   }
99
100 private:
101   QStringList           myCommands;
102   ItemList              myItems;
103   SALOME_InstallWizard* myWizard;
104 };
105
106 // ================================================================
107 /*!
108  *  WarnDialog
109  *  Warning dialog box
110  */
111 // ================================================================
112 class WarnDialog: public QDialog
113 {
114   static WarnDialog* myDlg;
115   bool myCloseFlag;
116
117   WarnDialog( QWidget* parent )
118   : QDialog( parent, "WarnDialog", true, WDestructiveClose ) {
119     setCaption( tr( "Information" ) );
120     myCloseFlag = false;
121     QLabel* lab = new QLabel( tr( "Please, wait while checking native products configuration ..." ), this );
122     lab->setAlignment( AlignCenter );
123     lab->setFrameStyle( QFrame::Box | QFrame::Plain );
124     QVBoxLayout* l = new QVBoxLayout( this );
125     l->setMargin( 0 );
126     l->add( lab );
127     this->setFixedSize( lab->sizeHint().width()  + 50,
128                         lab->sizeHint().height() * 5 );
129   }
130   void accept() { return; }
131   void reject() { return; }
132   void closeEvent( QCloseEvent* e )
133   { if ( !myCloseFlag ) return;
134     e->accept();
135     QDialog::closeEvent( e );
136   }
137   ~WarnDialog() { myDlg = 0; }
138 public:
139   static void showWarnDlg( QWidget* parent, bool show ) {
140     if ( show ) {
141       if ( !myDlg ) {
142         myDlg = new WarnDialog( parent );
143         QSize sh = myDlg->size();
144         myDlg->move( parent->x() + (parent->width()-sh.width())/2,
145                      parent->y() + (parent->height()-sh.height())/2 );
146         myDlg->show();
147       }
148       myDlg->raise();
149       myDlg->setFocus();
150     }
151     else {
152       if ( myDlg ) {
153         myDlg->myCloseFlag = true;
154         myDlg->close();
155       }
156     }
157   }
158   static bool isWarnDlgShown() { return myDlg != 0; }
159 };
160 WarnDialog* WarnDialog::myDlg = 0;
161
162 // ================================================================
163 /*!
164  *  InstallInfo
165  *  Installation progress info window class
166  */
167 // ================================================================
168 class InstallInfo : public QTextEdit
169 {
170 public:
171   InstallInfo( QWidget* parent ) : QTextEdit( parent ), finished( false ) {}
172   void setFinished( const bool f ) { finished = f; }
173 protected:
174   QPopupMenu* createPopupMenu( const QPoint& )
175   {
176     int para1, col1, para2, col2;
177     getSelection(&para1, &col1, &para2, &col2);
178     bool allSelected = hasSelectedText() &&
179       para1 == 0 && para2 == paragraphs()-1 && col1 == 0 && col2 == paragraphLength(para2);
180     QPopupMenu* popup = new QPopupMenu( this );
181     int id = popup->insertItem( tr( "&Copy" ) );
182     popup->setItemEnabled( id, hasSelectedText() );
183     popup->connectItem ( id, this, SLOT( copy() ) );
184     id = popup->insertItem( tr( "Select &All" ) );
185     popup->setItemEnabled( id, (bool)text().length() && !allSelected );
186     popup->connectItem ( id, this, SLOT( selectAll() ) );
187     if ( finished ) {
188       QWidget* p = parentWidget();
189       while ( p && !p->inherits( "SALOME_InstallWizard" ) )
190         p = p->parentWidget();
191       if ( p && p->inherits( "SALOME_InstallWizard" ) ) {
192         popup->insertSeparator();
193         id = popup->insertItem( tr( "&Save Log" ) );
194         popup->setItemEnabled( id, (bool)text().length() );
195         popup->connectItem ( id, (SALOME_InstallWizard*)p, SLOT( saveLog() ) );
196       }
197     }
198     return popup;
199   }
200 private:
201   bool finished;
202 };
203
204 // ================================================================
205 /*!
206  *  getAllProducts [ static ]
207  *  Defines list of all products as a string separated by space symbols
208  */
209 // ================================================================
210 static QString getAllProducts(MapProducts& theProductsMap)
211 {
212   QStringList aModules, aPrereqs;
213   for ( MapProducts::Iterator mapIter = theProductsMap.begin(); mapIter != theProductsMap.end(); ++mapIter ) {
214     QCheckListItem* item = mapIter.key();
215     Dependancies dep = mapIter.data();
216     QString curModule = item->text(0);
217     if ( !aModules.contains( curModule ) && !aPrereqs.contains( curModule ) ) {
218       if ( dep.getType() == "component" ) {
219         aModules.append( curModule );
220         aModules.append( curModule + "_src" );
221       }
222       else {
223         aPrereqs.append( curModule );
224         aPrereqs.append( curModule + "_src" );
225       }
226     }
227   }
228   return QStringList(aPrereqs+aModules).join(" ");
229 }
230
231 // ================================================================
232 /*!
233  *  setAboutInfo [ static ]
234  *  Sets 'what's this' and 'tooltip' information for the widget
235  */
236 // ================================================================
237 static void setAboutInfo( QWidget* widget, const QString& tip )
238 {
239   QWhatsThis::add( widget, tip );
240   QToolTip::add  ( widget, tip );
241 }
242
243 #define QUOTE(arg) QString("'") + QString(arg) + QString("'")
244
245 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
246                T H E   O L D   I M P L E M E N T A T I O N
247 static QString DefineDependeces(MapProducts& theProductsMap, QCheckListItem* product ){
248   QStringList aProducts;
249   if ( theProductsMap.contains( product ) ) {
250     Dependancies dep = theProductsMap[ product ];
251     QStringList deps = dep.getDependancies();
252     for (int i = 0; i<(int)deps.count(); i++ ) {
253       aProducts.append( deps[i] );
254     }
255   }
256   return QString("\"") + aProducts.join(" ") + QString("\"");
257 }
258 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
259
260 // ================================================================
261 /*!
262  *  makeDir [ static ]
263  *  Makes directory recursively, returns false if not succedes
264  */
265 // ================================================================
266 static bool makeDir( const QString& theDir, QString& theCreated )
267 {
268   if ( theDir.isEmpty() )
269     return false;
270   QString aDir = QDir::cleanDirPath( QFileInfo( theDir ).absFilePath() );
271   int start = 1;
272   while ( start > 0 ) {
273     start = aDir.find( QDir::separator(), start );
274     if ( start > 0 ) {
275       QFileInfo fi( aDir.left( start ) );
276       if ( !fi.exists() ) {
277         // VSR: Create directory and set permissions to allow other users to remove it
278         QString script = "mkdir " + fi.absFilePath();
279         script += "; chmod 777 " + fi.absFilePath();
280         script += " > /dev/null";
281         if ( system( script.latin1() ) )
282           return false;
283         // VSR: Remember the top of the created directory (to remove it in the end of the installation)
284         if ( theCreated.isNull() )
285           theCreated = fi.absFilePath();
286       }
287     }
288     start++;
289   }
290   if ( !QFileInfo( aDir ).exists() ) {
291     // VSR: Create directory, other users should NOT have possibility to remove it!!!
292     QString script = "mkdir " + aDir;
293     script += " > /dev/null";
294     if ( system( script.latin1() ) )
295       return false;
296     // VSR: Remember the top of the created directory (to remove it in the end of the installation)
297     if ( theCreated.isNull() )
298       theCreated = aDir;
299   }
300   return true;
301 }
302 // ================================================================
303 /*!
304  *  readFile [ static ]
305  *  Reads the file, returns false if can't open it
306  */
307 // ================================================================
308 static bool readFile( const QString& fileName, QString& text )
309 {
310   if ( QFile::exists( fileName ) ) {
311     QFile file( fileName );
312     if ( file.open( IO_ReadOnly ) ) {
313       QTextStream stream( &file );
314       QString line;
315       while ( !stream.eof() ) {
316         line = stream.readLine(); // line of text excluding '\n'
317         text += line + "\n";
318       }
319       file.close();
320       return true;
321     }
322   }
323   return false;
324 }
325 // ================================================================
326 /*!
327  *  hasSpace [ static ]
328  *  Checks if string contains spaces; used to check directory paths
329  */
330 // ================================================================
331 static bool hasSpace( const QString& dir )
332 {
333   for ( int i = 0; i < (int)dir.length(); i++ ) {
334     if ( dir[ i ].isSpace() )
335       return true;
336   }
337   return false;
338 }
339
340 // ================================================================
341 /*!
342  *  makeTitle
343  *  Creates HTML-wrapped title text
344  */
345 // ================================================================
346 QString makeTitle( const QString& text, const QString& separator = " ", bool fl = true )
347 {
348   QStringList words = QStringList::split( separator, text );
349   if ( fl ) {
350     for ( uint i = 0; i < words.count(); i++ )
351       words[i] = QString( "<font color=red>%1</font>" ).arg( words[i].left(1) ) + words[i].mid(1);
352   }
353   else {
354     if ( words.count() > 0 )
355       words[0] = QString( "<font color=red>%1</font>" ).arg( words[0] );
356     if ( words.count() > 1 )
357       words[words.count()-1] = QString( "<font color=red>%1</font>" ).arg( words[words.count()-1] );
358   }
359   QString res = words.join( separator );
360   if ( !res.isEmpty() )
361     res = QString( "<b>%1</b>" ).arg( res );
362   return res;
363 }
364
365 // ================================================================
366 /*!
367  *  QMyCheckBox class : custom check box
368  *  The only goal is to give access to the protected setState() method
369  */
370 // ================================================================
371 class QMyCheckBox: public QCheckBox
372 {
373 public:
374   QMyCheckBox( const QString& text, QWidget* parent, const char* name = 0 ) : QCheckBox ( text, parent, name ) {}
375   void setState ( ToggleState s ) { QCheckBox::setState( s ); }
376 };
377
378 // ================================================================
379 /*!
380  *  AboutDlg
381  *  "About dialog box.
382  */
383 // ================================================================
384 class AboutDlg: public QDialog
385 {
386 public:
387   AboutDlg( SALOME_InstallWizard* parent ) : QDialog( parent, "About dialog box", true )
388   {
389     // caption
390     setCaption( QString( "About %1" ).arg( parent->getIWName() ) );
391     // palette
392     QPalette pal = palette();
393     QColorGroup cg = pal.active();
394     cg.setColor( QColorGroup::Foreground, Qt::darkBlue );
395     cg.setColor( QColorGroup::Background, Qt::white );
396     pal.setActive( cg ); pal.setInactive( cg ); pal.setDisabled( cg );
397     setPalette( pal );
398     // layout
399     QGridLayout* main = new QGridLayout( this, 1, 1, 11, 6 );
400     // image
401     QLabel* logo = new QLabel( this, "logo" );
402     logo->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
403     logo->setMinimumSize( 32, 32 ); logo->setMaximumSize( 32, 32 );
404     logo->setPaletteBackgroundColor( QColor( 234, 250, 234 ) );
405     logo->setFrameStyle( QLabel::NoFrame | QLabel::Plain );
406     logo->setPixmap( pixmap( pxAbout ) );
407     logo->setScaledContents( false );
408     logo->setAlignment( QLabel::AlignCenter );
409     // decoration
410     QLabel* decorLeft = new QLabel( this, "decorLeft" );
411     decorLeft->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) );
412     decorLeft->setMinimumWidth( 32 ); decorLeft->setMaximumWidth( 32 );
413     decorLeft->setPaletteBackgroundColor( QColor( 234, 250, 234 ) );
414     decorLeft->setScaledContents( false );
415     QLabel* decorTop = new QLabel( this, "decorTop" );
416     decorTop->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
417     decorTop->setMinimumHeight( 32 ); decorTop->setMaximumHeight( 32 );
418     decorTop->setPaletteBackgroundColor( QColor( 234, 250, 234 ) );
419     decorTop->setScaledContents( false );
420     // contents
421     QLabel* title = new QLabel( this, "title" );
422     QString tlt = parent->getIWName();
423     title->setText( makeTitle( tlt ) );
424     QLabel* version = new QLabel( this, "version" );
425     version->setText( QString( "<b>Version</b>: %1.%1.%1" ).arg( __IW_VERSION_MAJOR__ ) \
426                       .arg( __IW_VERSION_MINOR__ ) \
427                       .arg( __IW_VERSION_PATCH__ ) );
428     QLabel* copyright = new QLabel( this, "copyright" );
429     copyright->setText( "<b>Copyright</b> &copy; 2004-2008 CEA" );
430     QFont font = title->font();
431     font.setPointSize( (int)( font.pointSize() * 1.8 ) );
432     title->setFont( font );
433     QFrame* line = new QFrame( this, "line" );
434     line->setFrameStyle( QFrame::HLine | QFrame::Sunken );
435     QLabel* url = new QLabel( this, "url" );
436     url->setText( makeTitle( "www.salome-platform.org", ".", false ) );
437     url->setAlignment( AlignRight );
438     font = version->font();
439     font.setPointSize( (int)( font.pointSize() / 1.2 ) );
440     version->setFont( font );
441     copyright->setFont( font );
442     url->setFont( font );
443     // layout
444     main->addWidget( logo, 0, 0 );
445     main->addMultiCellWidget( decorLeft, 1, 5, 0, 0 );
446     main->addWidget( decorTop, 0, 1 );
447     main->addWidget( title, 1, 1 );
448     main->addWidget( version, 2, 1 );
449     main->addWidget( copyright, 3, 1 );
450     main->addWidget( line, 4, 1 );
451     main->addWidget( url, 5, 1 );
452     // resize
453     QFontMetrics fm( title->font() );
454     int width = (int)( fm.width( tlt ) * 1.5 );
455     title->setMinimumWidth( width );
456     setMaximumSize( minimumSize() );
457   }
458   void mousePressEvent( QMouseEvent* )
459   {
460     accept();
461   }
462 };
463
464 // ================================================================
465 /*!
466  *  SALOME_InstallWizard::SALOME_InstallWizard
467  *  Constructor
468  */
469 // ================================================================
470 SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName,
471                                            const QString& aTargetDir,
472                                            const QString& aTmpDir)
473      : InstallWizard( qApp->desktop(), "SALOME_InstallWizard", false, 0 ),
474        helpWindow( NULL ),
475        moreMode( false ),
476        previousPage( 0 ),
477        exitConfirmed( false ),
478        hasErrors( false )
479 {
480   myIWName     = tr( "Installation Wizard" );
481   tmpCreated   = QString::null;
482   xmlFileName  = aXmlFileName;
483   myTargetPath = aTargetDir;
484   myTmpPath    = aTmpDir;
485   stateChanged = true;
486   binPath = QDir::currentDirPath() + "/Products/BINARIES";
487   srcPath = QDir::currentDirPath() + "/Products/SOURCES";
488   oneModDirName = "SALOME";
489   oneProdDirName = "PRODUCTS";
490   
491   singleBinPlts << "Debian4.0" 
492                 << "Debian3.1" 
493                 << "Mandrake10.1" 
494                 << "Mandriva2006.0" 
495                 << "Mandriva2007.0" 
496                 << "Mandriva2008.0" 
497                 << "Mandriva2006.0_64"
498                 << "Mandriva2008.0_64"
499                 << "RedHat8.0"
500                 << "RedHat9"
501                 << "RedHatEnterprise4"
502                 << "Scientific4.2"
503                 << "Scientific4.3";
504   commonPlatform = "Debian3.1";
505   
506   //
507   // get XML filename and current platform
508   //
509   // ... get current platform
510   curPlatform = currentPlatform();
511 //   cout << "curOS = " << curPlatform << endl;
512 //   curPlatform = "";
513   // ... check XML and platform definition
514   getXmlAndPlatform();
515
516   // set application font
517   QFont fnt = font();
518   fnt.setPointSize( 14 );
519   fnt.setBold( true );
520   setTitleFont( fnt );
521
522   // set icon
523   setIcon( pixmap( pxIcon ) );
524   // enable sizegrip
525   setSizeGripEnabled( true );
526
527   // add logo
528   addLogo( pixmap( pxLogo ) );
529
530   // set defaults
531   setVersion( "4.1.1" );
532   setCaption( tr( "SALOME %1" ).arg( myVersion ) );
533   setCopyright( tr( "Copyright (C) 2008 CEA" ) );
534   setLicense( tr( "All rights reserved." ) );
535
536   ___MESSAGE___( "Configuration file : " << xmlFileName.latin1() );
537   ___MESSAGE___( "Target directory   : " << myTargetPath.latin1() );
538   ___MESSAGE___( "Temporary directory: " << myTmpPath.latin1() );
539
540   //
541   // xml reader
542   //
543   StructureParser* parser = new StructureParser( this );
544   parser->readXmlFile(xmlFileName);
545
546   // create instance of class for starting shell script to get available disk space
547   diskSpaceProc = new QProcess( this, "procDiskSpace" );
548   connect( diskSpaceProc, SIGNAL( processExited() ), this, SLOT( updateAvailableSpace() ) );
549
550   // create instance of class for starting shell install script
551   shellProcess = new QProcess( this, "shellProcess" );
552
553   // create instance of class for starting shell script to modify SALOME *.la files
554   modifyLaProc = new QProcess( this, "modifyLaProc" );
555   connect(modifyLaProc, SIGNAL( processExited() ), this, SLOT( checkModifyLaResult() ) );
556   // create instance of class for starting shell script to check Fortran libraries
557   checkFLibProc = new QProcess( this, "checkFLibProc" );
558   connect(checkFLibProc, SIGNAL( processExited() ), this, SLOT( checkFLibResult() ) );
559
560   // create introduction page
561   setupIntroPage();
562   // create page to select installation type
563   setupTypePage();
564   // create page to select the reference installation platform (if necessary)
565   setupPlatformPage();
566   // create directories page
567   setupDirPage();
568   // create products page
569   setupProductsPage();
570   // create prestart page
571   setupCheckPage();
572   // create progress page
573   setupProgressPage();
574   // create readme page
575   setupReadmePage();
576
577   // common buttons
578   setAboutInfo( backButton(),   tr( "Return to the previous step\nof the installation procedure" ) );
579   setAboutInfo( nextButton(),   tr( "Move to the next step\nof the installation procedure" ) );
580   setAboutInfo( finishButton(), tr( "Finish the installation and quit the program" ) );
581   setAboutInfo( cancelButton(), tr( "Cancel the installation and quit the program" ) );
582   setAboutInfo( helpButton(),   tr( "Show the help information" ) );
583
584   // common signals connections
585   connect( this, SIGNAL( selected( const QString& ) ),
586                                            this, SLOT( pageChanged( const QString& ) ) );
587   connect( this, SIGNAL( helpClicked() ),  this, SLOT( helpClicked() ) );
588   connect( this, SIGNAL( aboutClicked() ), this, SLOT( onAbout() ) );
589
590   // catch signals from launched script
591   connect(shellProcess, SIGNAL( readyReadStdout() ), this, SLOT( readFromStdout() ) );
592   connect(shellProcess, SIGNAL( readyReadStderr() ), this, SLOT( readFromStderr() ) );
593   connect(shellProcess, SIGNAL( processExited() ),   this, SLOT( productInstalled() ) );
594   connect(shellProcess, SIGNAL( wroteToStdin() ),    this, SLOT( wroteToStdin() ) );
595
596   // create validation thread
597   myThread = new ProcessThread( this );
598
599   // show about button
600   setAboutIcon( pixmap( pxAbout ) );
601   showAboutBtn( true );
602 }
603 // ================================================================
604 /*!
605  *  SALOME_InstallWizard::~SALOME_InstallWizard
606  *  Destructor
607  */
608 // ================================================================
609 SALOME_InstallWizard::~SALOME_InstallWizard()
610 {
611   shellProcess->kill(); // kill it for sure
612   QString script = "kill -9 ";
613   int PID = (int)shellProcess->processIdentifier();
614   if ( PID > 0 ) {
615     script += QString::number( PID );
616     script += " > /dev/null";
617     ___MESSAGE___( "script: " << script.latin1() );
618     if ( system( script.latin1() ) ) {
619     }
620   }
621   delete myThread;
622 }
623 // ================================================================
624 /*!
625  *  SALOME_InstallWizard::getBasePlatform
626  *  Determine the base platform for binaries installation
627  */
628 // ================================================================
629 QString SALOME_InstallWizard::getBasePlatform()
630 {
631   QString aBasePlt = "";
632   if ( singleBinPlts.contains(curPlatform) )
633     aBasePlt = curPlatform;
634   else
635     aBasePlt = commonPlatform;
636   return aBasePlt;
637 }
638 // ================================================================
639 /*!
640  *  SALOME_InstallWizard::currentPlatform
641  *  Tries to determine the current user's operating system
642  */
643 // ================================================================
644 QString SALOME_InstallWizard::currentPlatform()
645 {
646   // file parsing
647   QString curOS = "";
648   QString osFileName = "/etc/issue";
649   if ( QFile::exists( osFileName ) ) {
650     QFile file( osFileName );
651     if ( file.open( IO_ReadOnly ) ) {
652       QTextStream stream( &file );
653       QString str = stream.readLine();
654       file.close();
655       // line parsing
656       QString pltName = "", platVersion = "", platBit = "";
657       QRegExp rx( "(.*)[L|l]inux.*release\\s+([\\d.]*)" );
658 //       str = "Debian GNU/Linux 3.1 \n \l";
659 //       str = "Red Hat Enterprise Linux WS release 4 (Nahant)";
660 //       str = "Mandriva Linux release 2006.0 (Official) for x86_64";
661       int pos = rx.search( str );
662       if ( pos == -1 ) {// Debian case
663         rx = QRegExp( "(.*)GNU/Linux\\s+([\\d.]*)" );
664         pos = rx.search( str );
665       }
666       if ( pos > -1 ) {
667         pltName = rx.cap( 1 );
668         platVersion = rx.cap( 2 );
669         rx = QRegExp( "x86_64" );
670         pos = rx.search( str );
671         if ( pos > -1 )
672           platBit = "_64";
673         curOS = pltName + platVersion + platBit;
674       }
675     }
676   }
677   //   return curOS.remove( " " );
678   QString str( " " );
679   int index = 0;
680   while ( (index = curOS.find( str, index, true)) != -1 )
681     curOS.remove( index, str.length() );
682   return curOS;
683 }
684 // ================================================================
685 /*!
686  *  SALOME_InstallWizard::getXmlMap
687  *  Creates a map of the supported operating systems and 
688  *  corresponding XML files.
689  */
690 // ================================================================
691 MapXmlFiles SALOME_InstallWizard::getXmlMap( const QString& xmlFileName )
692 {
693   MapXmlFiles xmlMap;
694   QStringList xmlList;
695   if ( xmlFileName )
696     xmlList.append( xmlFileName );
697   else {
698     QDir dir( QDir::currentDirPath() );
699     xmlList = dir.entryList( "*.xml", QDir::Files | QDir::Readable );
700   }
701 //   cout << xmlList.join(",") << endl;
702   // XML files parsing
703   QFile file;
704   QDomDocument doc( "xml_doc" );
705   QDomElement docElem;
706   QDomNodeList nodeList;
707   QDomNode node;
708   QDomElement elem;
709   QString platforms = "";
710   QStringList platList;
711   for ( uint i = 0; i < xmlList.count(); i++ ) {
712     file.setName( xmlList[i] );
713     if ( !doc.setContent( &file ) ) {
714       file.close();
715       continue;
716     }
717     file.close();
718     
719     docElem = doc.documentElement();
720     nodeList = docElem.elementsByTagName( "config" );
721     if ( nodeList.count() == 0 )
722       continue;      
723     node = nodeList.item( 0 );
724     if ( node.isElement() ) {
725       elem = node.toElement();
726       if ( elem.attribute( "platforms" ) ) {
727         platforms = elem.attribute( "platforms" ).stripWhiteSpace();
728         QStringList platList = QStringList::split( ",", platforms );
729         for ( uint j = 0; j < platList.count(); j++ ) {
730           if ( !platList[j].isEmpty() )
731             if ( xmlMap.find( platList[j] ) == xmlMap.end() || 
732                  xmlMap[ platList[j] ] == "config.xml" )
733               xmlMap[ platList[j] ] = xmlList[i];
734         }
735 //      if ( !curPlatform.isEmpty() && xmlMap.find( curPlatform ) != xmlMap.end() )
736 //        return xmlMap;
737       }
738     }
739   }
740   return xmlMap;
741 }
742 // ================================================================
743 /*!
744  *  SALOME_InstallWizard::checkXmlAndPlatform
745  *  Check XML file and current platform definition
746  */
747 // ================================================================
748 void SALOME_InstallWizard::getXmlAndPlatform()
749 {
750   MapXmlFiles xmlMap;
751   if ( xmlFileName.isNull() ) {
752     xmlMap = getXmlMap();
753     if ( !curPlatform.isEmpty() ) {
754       // try to get XML file for current platform
755       if ( xmlMap.find( curPlatform ) != xmlMap.end() ) {
756         xmlFileName = xmlMap[ getBasePlatform() ];
757         QFileInfo fibp( QDir::cleanDirPath( getBinPath() + "/" + getBasePlatform() ) );
758         if ( !fibp.isDir() ) {
759           warnMsg = tr( "Binaries are absent for current platform" );
760         }
761         platformsMap = xmlMap;
762       }
763       else {
764         platformsMap = xmlMap;
765         warnMsg = tr( "Your Linux platform is not supported by this SALOME package" );
766       }
767     }
768     else {
769       // get all supported platforms
770       platformsMap = xmlMap;
771       warnMsg = tr( "Install Wizard can't define your Linux platform" );
772     }
773   }
774   else {
775     xmlMap = getXmlMap( xmlFileName );
776     if ( !curPlatform.isEmpty() ) {
777       // check that the user's XML file supports current platform
778       if ( xmlMap.find( curPlatform ) == xmlMap.end() ) {
779         platformsMap = getXmlMap();
780         MapXmlFiles::Iterator it;
781         for ( it = xmlMap.begin(); it != xmlMap.end(); ++it )
782           platformsMap.insert( it.key(), it.data(), true );
783         warnMsg = tr( "The given configuration file doesn't support your Linux platform" );
784       }
785     }
786     else {
787       // get all supported platforms
788       platformsMap = getXmlMap();
789       MapXmlFiles::Iterator it;
790       for ( it = xmlMap.begin(); it != xmlMap.end(); ++it )
791         platformsMap.insert( it.key(), it.data(), true );
792       warnMsg = tr( "Install Wizard can't define your Linux platform" );
793     }
794   }
795 }
796 // ================================================================
797 /*!
798  *  SALOME_InstallWizard::eventFilter
799  *  Event filter, spies for Help window closing
800  */
801 // ================================================================
802 bool SALOME_InstallWizard::eventFilter( QObject* object, QEvent* event )
803 {
804   if ( object && object == helpWindow && event->type() == QEvent::Close )
805     helpWindow = NULL;
806   return InstallWizard::eventFilter( object, event );
807 }
808 // ================================================================
809 /*!
810  *  SALOME_InstallWizard::closeEvent
811  *  Close event handler
812  */
813 // ================================================================
814 void SALOME_InstallWizard::closeEvent( QCloseEvent* ce )
815 {
816   if ( WarnDialog::isWarnDlgShown() ) {
817     ce->ignore();
818     return;
819   }
820   if ( !exitConfirmed ) {
821     if ( QMessageBox::information( this,
822                                    tr( "Exit" ),
823                                    tr( "Do you want to quit %1?" ).arg( getIWName() ),
824                                    tr( "&Yes" ),
825                                    tr( "&No" ),
826                                    QString::null,
827                                    0,
828                                    1 ) == 1 ) {
829       ce->ignore();
830     }
831     else {
832       ce->accept();
833       exitConfirmed = true;
834       reject();
835     }
836   }
837 }
838 // ================================================================
839 /*!
840  *  SALOME_InstallWizard::setupIntroPage
841  *  Creates introduction page
842  */
843 // ================================================================
844 void SALOME_InstallWizard::setupIntroPage()
845 {
846   // create page
847   introPage = new QWidget( this, "IntroPage" );
848   QGridLayout* pageLayout = new QGridLayout( introPage );
849   pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
850   // create logo picture
851   logoLab = new QLabel( introPage );
852   logoLab->setPixmap( pixmap( pxBigLogo ) );
853   logoLab->setScaledContents( false );
854   logoLab->setFrameStyle( QLabel::Plain | QLabel::NoFrame );
855   logoLab->setAlignment( AlignCenter );
856   // create version box
857   QVBox* versionBox = new QVBox( introPage ); versionBox->setSpacing( 6 );
858   versionBox->setFrameStyle( QVBox::Panel | QVBox::Sunken );
859   QWidget* stretch1 = new QWidget( versionBox ); versionBox->setStretchFactor( stretch1, 5 );
860   versionLab = new QLabel( QString("%1 %2").arg( tr( "Version" ) ).arg(myVersion), versionBox );
861   versionLab->setAlignment( AlignCenter );
862   copyrightLab = new QLabel( myCopyright, versionBox );
863   copyrightLab->setAlignment( AlignCenter );
864   licenseLab = new QLabel( myLicense, versionBox );
865   licenseLab->setAlignment( AlignCenter );
866   QWidget* stretch2 = new QWidget( versionBox ); versionBox->setStretchFactor( stretch2, 5 );
867   // create info box
868   info = new QLabel( introPage );
869   info->setText( tr( "This program will install <b>%1</b>."
870                      "<br><br>The wizard will also help you to install all products "
871                      "which are necessary for <b>%2</b> and setup "
872                      "your environment.<br><br>Click <code>Cancel</code> button to abort "
873                      "installation and quit. Click <code>Next</code> button to continue with the "
874                      "installation program." ).arg( myCaption ).arg( myCaption ) );
875   info->setFrameStyle( QLabel::WinPanel | QLabel::Sunken );
876   info->setMargin( 6 );
877   info->setAlignment( WordBreak );
878   info->setMinimumWidth( 250 );
879   QPalette pal = info->palette();
880   pal.setColor( QColorGroup::Background, QApplication::palette().active().base() );
881   info->setPalette( pal );
882   info->setLineWidth( 2 );
883   // layouting
884   pageLayout->addWidget( logoLab, 0, 0 );
885   pageLayout->addWidget( versionBox, 1, 0 );
886   pageLayout->addMultiCellWidget( info, 0, 1, 1, 1 );
887   pageLayout->setColStretch( 1, 5 );
888   pageLayout->setRowStretch( 1, 5 );
889   // adding page
890   addPage( introPage, tr( "Introduction" ) );
891 }
892 // ================================================================
893 /*!
894  *  SALOME_InstallWizard::setupTypePage
895  *  Creates installation types page
896  */
897 // ================================================================
898 void SALOME_InstallWizard::setupTypePage()
899 {
900   // create page
901   typePage = new QWidget( this, "TypePage" );
902   QGridLayout* pageLayout = new QGridLayout( typePage );
903   pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
904   // create installation type button group
905   buttonGrp = new QButtonGroup( typePage );
906   buttonGrp->setFrameShape(QButtonGroup::NoFrame);
907   QGridLayout* buttonGrpLayout = new QGridLayout( buttonGrp );
908   buttonGrpLayout->setMargin( 0 ); buttonGrpLayout->setSpacing( 6 );
909   QSpacerItem* spacer1 = new QSpacerItem( 16, 50, QSizePolicy::Minimum, QSizePolicy::Expanding );
910   QSpacerItem* spacer2 = new QSpacerItem( 16, 50, QSizePolicy::Minimum, QSizePolicy::Expanding );
911   QLabel* selectLab = new QLabel( tr( "Select a type of the installation:" ), buttonGrp );
912   QSpacerItem* spacer3 = new QSpacerItem( 20, 20, QSizePolicy::Fixed, QSizePolicy::Minimum );
913   // ... 'install binaries' layout
914   QGridLayout* binLayout = new QGridLayout( 2, 2, 0 );
915   binBtn = new QRadioButton( tr( "Install binaries" ), buttonGrp );
916   QFont rbFont = binBtn->font();
917   rbFont.setBold( true );
918   binBtn->setFont( rbFont );
919   QSpacerItem* spacer4 = new QSpacerItem( 16, 16, QSizePolicy::Fixed, QSizePolicy::Minimum );
920   QLabel* binLab = new QLabel( tr( "- all the binaries and sources of the chosen SALOME modules will be installed.\n"
921                                    "- all the binaries of the chosen prerequisites will be installed." ), 
922                                buttonGrp );
923   binLayout->addMultiCellWidget( binBtn,  0, 0, 0, 1 );
924   binLayout->addItem           ( spacer4, 1,    0    );
925   binLayout->addWidget         ( binLab,  1,    1    );
926   // ... 'install sources' layout
927   QGridLayout* srcLayout = new QGridLayout( 2, 2, 0 );
928   srcBtn = new QRadioButton( tr( "Install sources" ), buttonGrp );
929   srcBtn->setFont( rbFont );
930   QSpacerItem* spacer5 = new QSpacerItem( 16, 16, QSizePolicy::Fixed, QSizePolicy::Minimum );
931   QLabel* srcLab = new QLabel( tr( "- all the sources of the chosen modules and prerequisites will be installed without\ncompilation." ), 
932                                buttonGrp );
933   srcLayout->addMultiCellWidget( srcBtn,  0, 0, 0, 1 );
934   srcLayout->addItem           ( spacer5, 1,    0    );
935   srcLayout->addWidget         ( srcLab,  1,    1    );
936   // ... 'install sources and make compilation' layout
937   QGridLayout* srcCompileLayout = new QGridLayout( 3, 3, 0 );
938   srcCompileBtn = new QRadioButton( tr( "Install sources and make a compilation" ), buttonGrp );
939   srcCompileBtn->setFont( rbFont );
940   QSpacerItem* spacer6 = new QSpacerItem( 16, 16, QSizePolicy::Fixed, QSizePolicy::Minimum );
941   QLabel* srcCompileLab1 = new QLabel( tr( "- all the sources of the chosen modules and prerequisites will be installed and\ncompiled." ), 
942                                        buttonGrp );
943   QLabel* srcCompileLab2 = new QLabel( tr( "Note:" ), 
944                                        buttonGrp );
945   QFont noteFont = srcCompileLab2->font();
946   noteFont.setUnderline( true );
947   srcCompileLab2->setFont( noteFont );
948   srcCompileLab2->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) );
949   srcCompileLab2->setAlignment( Qt::AlignHCenter | Qt::AlignTop );
950   QLabel* srcCompileLab3 = new QLabel( " " + 
951                                        tr( "it is a long time operation and it can take more than 24 hours depending\n on the computer." ), 
952                                        buttonGrp );
953   removeSrcBtn = new QCheckBox( tr( "Remove sources and temporary files after compilation" ), typePage );
954   setAboutInfo( removeSrcBtn, tr( "Check this option if you want to remove sources of the products\nwith all the temporary files after build finishing" ) );
955   removeSrcBtn->setChecked( false );
956   removeSrcBtn->setEnabled( false );
957   rmSrcPrevState = removeSrcBtn->isChecked();
958
959   srcCompileLayout->addMultiCellWidget( srcCompileBtn,  0, 0, 0, 2 );
960   srcCompileLayout->addMultiCell      ( spacer6,        1, 2, 0, 0 );
961   srcCompileLayout->addMultiCellWidget( srcCompileLab1, 1, 1, 1, 2 );
962   srcCompileLayout->addWidget         ( srcCompileLab2, 2,    1    );
963   srcCompileLayout->addWidget         ( srcCompileLab3, 2,    2    );
964   srcCompileLayout->addMultiCellWidget( removeSrcBtn,   3, 3, 1, 2 );
965   // layout widgets in the button group
966   buttonGrpLayout->addItem           ( spacer1,          0,    1    );
967   buttonGrpLayout->addMultiCellWidget( selectLab,        1, 1, 0, 1 );
968   buttonGrpLayout->addMultiCell      ( spacer3,          2, 4, 0, 0 );
969   buttonGrpLayout->addLayout         ( binLayout,        2,    1    );
970   buttonGrpLayout->addLayout         ( srcLayout,        3,    1    );
971   buttonGrpLayout->addLayout         ( srcCompileLayout, 4,    1    );
972   buttonGrpLayout->addItem           ( spacer2,          5,    1    );
973   // layout button group at the page
974   pageLayout->addWidget( buttonGrp, 0, 0 );
975   // connecting signals
976   connect( buttonGrp, SIGNAL( clicked(int) ), this, SLOT ( onButtonGroup(int) ) );
977   // adding page
978   addPage( typePage, tr( "Installation type" ) );
979 }
980 // ================================================================
981 /*!
982  *  SALOME_InstallWizard::setupPlatformPage
983  *  Creates platforms page, if necessary
984  */
985 // ================================================================
986 void SALOME_InstallWizard::setupPlatformPage()
987 {
988   // create page
989   platformsPage = new QWidget( this, "PlatformsPage" );
990   QGridLayout* pageLayout = new QGridLayout( platformsPage );
991   pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
992   // create warning labels
993   QLabel* warnLab2 = new QLabel( tr( "WARNING!" ), platformsPage );
994   warnLab2->setAlignment( Qt::AlignHCenter );
995   QFont fnt = warnLab2->font();
996   fnt.setBold( true );
997   warnLab2->setFont( fnt );
998   warnLab = new QLabel( warnMsg, platformsPage );
999   warnLab->setAlignment( Qt::AlignHCenter | Qt::WordBreak );
1000   warnLab3 = new QLabel( tr( "If you want to proceed anyway, please select platform from the following list:" ), 
1001                                  platformsPage );
1002   warnLab3->setAlignment( Qt::AlignHCenter | Qt::WordBreak );
1003   // create button group
1004   platBtnGrp = new QButtonGroup( platformsPage );
1005   platBtnGrp->setFrameShape(QButtonGroup::LineEditPanel);
1006   platBtnGrp->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) );
1007   QVBoxLayout* platBtnGrpLayout = new QVBoxLayout( platBtnGrp );
1008   platBtnGrpLayout->setMargin( 11 ); platBtnGrpLayout->setSpacing( 6 );
1009   // create platforms radio-buttons
1010   QString plat;
1011   MapXmlFiles::Iterator it;
1012   for ( it = platformsMap.begin(); it != platformsMap.end(); ++it ) {
1013     plat = it.key();
1014     QRadioButton* rb = new QRadioButton( plat, platBtnGrp, plat );
1015     platBtnGrpLayout->addWidget( rb );
1016   }
1017   // create spacers
1018   QSpacerItem* spacer1 = new QSpacerItem( 16, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
1019   QSpacerItem* spacer2 = new QSpacerItem( 16, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
1020
1021   // layout widgets on page
1022   pageLayout->addItem           ( spacer1,    0,    0    );
1023   pageLayout->addWidget         ( warnLab2,   1,    0    );
1024   pageLayout->addWidget         ( warnLab,    2,    0    );
1025   pageLayout->addWidget         ( warnLab3,   3,    0    );
1026   pageLayout->addItem           ( spacer2,    4,    0    );
1027   pageLayout->addMultiCellWidget( platBtnGrp, 0, 4, 1, 1 );
1028
1029   // connecting signals
1030   connect( platBtnGrp, SIGNAL( clicked(int) ), this, SLOT ( onButtonGroup(int) ) );
1031
1032   // adding page
1033   addPage( platformsPage, tr( "Installation platform" ) );
1034 }
1035 // ================================================================
1036 /*!
1037  *  SALOME_InstallWizard::setupDirPage
1038  *  Creates directories page
1039  */
1040 // ================================================================
1041 void SALOME_InstallWizard::setupDirPage()
1042 {
1043   // create page
1044   dirPage = new QWidget( this, "DirPage" );
1045   QGridLayout* pageLayout = new QGridLayout( dirPage );
1046   pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
1047   QSpacerItem* spacer1 = new QSpacerItem( 16, 50, QSizePolicy::Minimum, QSizePolicy::Expanding );
1048   QSpacerItem* spacer2 = new QSpacerItem( 16, 50, QSizePolicy::Minimum, QSizePolicy::Expanding );
1049   // target directory
1050   QGridLayout* targetLayout = new QGridLayout( 2, 2, 0 );
1051   QLabel* targetLab = new QLabel( tr( "Set a target directory to install SALOME platform:" ), dirPage );
1052   targetFolder = new QLineEdit( dirPage );
1053   targetBtn = new QPushButton( tr( "Browse..." ), dirPage );
1054   setAboutInfo( targetBtn, tr( "Click this button to browse\nthe installation directory" ) );
1055   targetLayout->addMultiCellWidget( targetLab,    0, 0, 0, 1 );
1056   targetLayout->addWidget         ( targetFolder, 1,    0    );
1057   targetLayout->addWidget         ( targetBtn,    1,    1    );
1058   // temporary directory
1059   QGridLayout* tempLayout = new QGridLayout( 2, 2, 0 );
1060   QLabel* tempLab = new QLabel( tr( "Set a directory that should be used for temporary SALOME files:" ), dirPage );
1061   tempFolder = new QLineEdit( dirPage );
1062   tempBtn = new QPushButton( tr( "Browse..." ), dirPage );
1063   setAboutInfo( tempBtn, tr( "Click this button to browse\nthe temporary directory" ) );
1064   tempLayout->addMultiCellWidget( tempLab,    0, 0, 0, 1 );
1065   tempLayout->addWidget         ( tempFolder, 1,    0    );
1066   tempLayout->addWidget         ( tempBtn,    1,    1    );
1067   // AKL: 13/08/07 - disable temporary directory setting in GUI ==>
1068   tempLab->hide();
1069   tempFolder->hide();
1070   tempBtn->hide();
1071   // AKL: 13/08/07 - disable temporary directory setting in GUI <==
1072   // layout widgets
1073   pageLayout->addItem  ( spacer1,      0, 0 );
1074   pageLayout->addLayout( targetLayout, 1, 0 );
1075   pageLayout->addLayout( tempLayout,   2, 0 );
1076   pageLayout->addItem  ( spacer2,      3, 0 );
1077   // connecting signals
1078   connect( targetFolder,  SIGNAL( textChanged( const QString& ) ),
1079            this,          SLOT( directoryChanged( const QString& ) ) );
1080   connect( targetBtn,     SIGNAL( clicked() ), 
1081            this,          SLOT( browseDirectory() ) );
1082   connect( tempFolder,    SIGNAL( textChanged( const QString& ) ),
1083            this,          SLOT( directoryChanged( const QString& ) ) );
1084   connect( tempBtn,       SIGNAL( clicked() ), this, SLOT( browseDirectory() ) );
1085
1086   // adding page
1087   addPage( dirPage, tr( "Installation directory" ) );
1088 }
1089 // ================================================================
1090 /*!
1091  *  SALOME_InstallWizard::setupProductsPage
1092  *  Creates products page
1093  */
1094 // ================================================================
1095 void SALOME_InstallWizard::setupProductsPage()
1096 {
1097   // create page
1098   productsPage = new QWidget( this, "ProductsPage" );
1099   QGridLayout* pageLayout = new QGridLayout( productsPage );
1100   pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
1101   //
1102   // create left column widgets
1103   //
1104   QVBoxLayout* leftBoxLayout = new QVBoxLayout;
1105   leftBoxLayout->setMargin( 0 ); leftBoxLayout->setSpacing( 6 );
1106   // ... modules list
1107   modulesView = new ProductsView( productsPage, "modulesView" );
1108   setAboutInfo( modulesView, tr( "The modules available for the installation" ) );
1109   modulesView->setColumnAlignment( 1, Qt::AlignRight );
1110   leftBoxLayout->addWidget( modulesView );
1111   // ... 'Installation with GUI' checkbox
1112   installGuiBtn = new QMyCheckBox( tr( "Installation with GUI" ), productsPage );
1113   setAboutInfo( installGuiBtn, tr( "Check this option if you want\nto install SALOME with GUI" ) );
1114   leftBoxLayout->addWidget( installGuiBtn );
1115   // ... prerequisites list
1116   prereqsView = new ProductsView( productsPage, "prereqsView" );
1117   prereqsView->renameColumn( 0, "Prerequisite" );
1118   setAboutInfo( prereqsView, tr( "The prerequisites that can be installed" ) );
1119   prereqsView->setColumnAlignment( 1, Qt::AlignRight );
1120   leftBoxLayout->addWidget( prereqsView );
1121   // ... 'Show/Hide prerequisites' button
1122   moreBtn = new QPushButton( tr( "Show prerequisites..." ), productsPage );
1123   setAboutInfo( moreBtn, tr( "Click to show list of prerequisites" ) );
1124   leftBoxLayout->addWidget( moreBtn );
1125   //
1126   // create right column widgets
1127   //
1128   // ... info box
1129   productInfo = new QTextBrowser( productsPage );
1130   productInfo->setFrameShape( QFrame::LineEditPanel );
1131   productInfo->setPaletteBackgroundColor( productsPage->paletteBackgroundColor() );
1132   setAboutInfo( productInfo, tr( "Short information about the product being selected" ) );
1133   // ... disk space labels
1134   QLabel* reqLab1 = new QLabel( tr( "Disk space required:" ), productsPage );
1135   setAboutInfo( reqLab1, tr( "Total disk space required for the installation\nof the selected products" ) );
1136   requiredSize = new QLabel( productsPage );
1137   setAboutInfo( requiredSize, tr( "Total disk space required for the installation\nof the selected products" ) );
1138   requiredSize->setAlignment( Qt::AlignRight );
1139   QLabel* reqLab2 = new QLabel( tr( "Space for temporary files:" ), productsPage );
1140   setAboutInfo( reqLab2, tr( "Disk space required for the temporary files" ) );
1141   requiredTemp = new QLabel( productsPage );
1142   setAboutInfo( requiredTemp, tr( "Disk space required for the temporary files" ) );
1143   requiredTemp->setAlignment( Qt::AlignRight );
1144   QLabel* reqLab3 = new QLabel( tr( "Available disk space:" ), productsPage );
1145   setAboutInfo( reqLab3, tr( "Disk space available on the selected device" ) );
1146   availableSize = new QLabel( productsPage );
1147   setAboutInfo( availableSize, tr( "Disk space available on the selected device" ) );
1148   availableSize->setAlignment( Qt::AlignRight );
1149   // layout size widgets
1150   QGridLayout* sizeLayout = new QGridLayout; sizeLayout->setMargin( 0 ); sizeLayout->setSpacing( 6 );
1151   sizeLayout->addWidget( reqLab1,       0, 0 );
1152   sizeLayout->addWidget( requiredSize,  0, 1 );
1153   sizeLayout->addWidget( reqLab2,       1, 0 );
1154   sizeLayout->addWidget( requiredTemp,  1, 1 );
1155   sizeLayout->addWidget( reqLab3,       2, 0 );
1156   sizeLayout->addWidget( availableSize, 2, 1 );
1157   // ... 'single installation directory' check-boxes
1158   oneModDirBtn = new QMyCheckBox( tr( "Install modules to a single directory" ), productsPage );
1159   setAboutInfo( oneModDirBtn, tr( "Check this box if you want to install binaries of\nthe selected SALOME modules into a single directory" ) );
1160   oneProdDirBtn = new QMyCheckBox( tr( "Install prerequisites to a single directory" ), productsPage );
1161   setAboutInfo( oneProdDirBtn, tr( "Check this box if you want to install binaries of\nthe selected prerequisites into a single directory" ) );
1162   oneProdDirBtn->hide(); // temporarily! waiting for correct prerequisites availability
1163   QFrame* split_line = new QFrame( productsPage, "split_line" );
1164   split_line->setFrameStyle( QFrame::HLine | QFrame::Sunken );
1165
1166   // layout common widgets
1167   pageLayout->addMultiCellLayout( leftBoxLayout, 0, 4, 0, 0 );
1168   pageLayout->addWidget         ( productInfo,   0,    1    );
1169   pageLayout->addLayout         ( sizeLayout,    1,    1    );
1170   pageLayout->addWidget         ( split_line,    2,    1    );
1171   pageLayout->addWidget         ( oneModDirBtn,  3,    1    );
1172   pageLayout->addWidget         ( oneProdDirBtn, 4,    1    );
1173
1174   // adding page
1175   addPage( productsPage, tr( "Choice of the products to be installed" ) );
1176
1177   // connecting signals
1178   connect( modulesView,   SIGNAL( selectionChanged() ),
1179            this, SLOT( onSelectionChanged() ) );
1180   connect( prereqsView,   SIGNAL( selectionChanged() ),
1181            this, SLOT( onSelectionChanged() ) );
1182   connect( modulesView,   SIGNAL( clicked ( QListViewItem * item ) ),
1183            this, SLOT( onSelectionChanged() ) );
1184   connect( prereqsView,   SIGNAL( clicked ( QListViewItem * item ) ),
1185            this, SLOT( onSelectionChanged() ) );
1186   connect( modulesView,   SIGNAL( itemToggled( QCheckListItem* ) ),
1187            this, SLOT( onItemToggled( QCheckListItem* ) ) );
1188   connect( prereqsView,   SIGNAL( itemToggled( QCheckListItem* ) ),
1189            this, SLOT( onItemToggled( QCheckListItem* ) ) );
1190   connect( installGuiBtn, SIGNAL( toggled( bool ) ), 
1191            this, SLOT( onInstallGuiBtn() ) );
1192   connect( moreBtn, SIGNAL( clicked() ), this, SLOT( onMoreBtn() ) );
1193   // start on default - non-advanced mode
1194   prereqsView->hide();
1195 }
1196 // ================================================================
1197 /*!
1198  *  SALOME_InstallWizard::setupCheckPage
1199  *  Creates prestart page
1200  */
1201 // ================================================================
1202 void SALOME_InstallWizard::setupCheckPage()
1203 {
1204   // create page
1205   prestartPage = new QWidget( this, "PrestartPage" );
1206   QVBoxLayout* pageLayout = new QVBoxLayout( prestartPage );
1207   pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
1208   // choice text view
1209   choices = new QTextEdit( prestartPage );
1210   choices->setReadOnly( true );
1211   choices->setTextFormat( RichText );
1212   choices->setUndoRedoEnabled ( false );
1213   setAboutInfo( choices, tr( "Information about the installation choice you have made" ) );
1214   choices->setPaletteBackgroundColor( prestartPage->paletteBackgroundColor() );
1215   choices->setMinimumHeight( 10 );
1216   // layouting
1217   pageLayout->addWidget( choices );
1218   pageLayout->setStretchFactor( choices, 5 );
1219   // adding page
1220   addPage( prestartPage, tr( "Check your choice" ) );
1221 }
1222 // ================================================================
1223 /*!
1224  *  SALOME_InstallWizard::setupProgressPage
1225  *  Creates progress page
1226  */
1227 // ================================================================
1228 void SALOME_InstallWizard::setupProgressPage()
1229 {
1230   // create page
1231   progressPage = new QWidget( this, "progressPage" );
1232   QGridLayout* pageLayout = new QGridLayout( progressPage );
1233   pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
1234   // top splitter
1235   splitter = new QSplitter( Vertical, progressPage );
1236   splitter->setOpaqueResize( true );
1237   // the parent for the widgets
1238   QWidget* widget = new QWidget( splitter );
1239   QGridLayout* layout = new QGridLayout( widget );
1240   layout->setMargin( 0 ); layout->setSpacing( 6 );
1241   // installation progress view box
1242   installInfo = new InstallInfo( widget );
1243   installInfo->setReadOnly( true );
1244   installInfo->setTextFormat( RichText );
1245   installInfo->setUndoRedoEnabled ( false );
1246   installInfo->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
1247   installInfo->setMinimumSize( 100, 10 );
1248   setAboutInfo( installInfo, tr( "Installation process output" ) );
1249   // parameters for the script
1250   parametersLab = new QLabel( tr( "Enter your answer here:" ), widget );
1251   passedParams = new QLineEdit ( widget );
1252   setAboutInfo( passedParams, tr( "Use this field to enter the answer\nfor the running script when it is necessary") );
1253   // VSR: 10/11/05 - disable answer mode ==>
1254   parametersLab->hide();
1255   passedParams->hide();
1256   // VSR: 10/11/05 - disable answer mode <==
1257   // layouting
1258   layout->addWidget( installInfo,   0, 0 );
1259   layout->addWidget( parametersLab, 1, 0 );
1260   layout->addWidget( passedParams,  2, 0 );
1261   layout->addRowSpacing( 3, 6 );
1262   // the parent for the widgets
1263   widget = new QWidget( splitter );
1264   layout = new QGridLayout( widget );
1265   layout->setMargin( 0 ); layout->setSpacing( 6 );
1266   // installation results view box
1267   QLabel* resultLab = new QLabel( tr( "Installation Status:" ), widget );
1268   progressView = new ProgressView( widget );
1269   progressView->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
1270   progressView->setMinimumSize( 100, 10 );
1271   statusLab = new QLabel( widget );
1272   statusLab->setFrameShape( QButtonGroup::LineEditPanel );
1273   setAboutInfo( progressView, tr( "Installation status on the selected products" ) );
1274   // layouting
1275   layout->addRowSpacing( 0, 6 );
1276   layout->addWidget( resultLab,    1, 0 );
1277   layout->addWidget( progressView, 2, 0 );
1278   layout->addWidget( statusLab,    3, 0 );
1279   // layouting
1280   pageLayout->addWidget( splitter,  0, 0 );
1281   // adding page
1282   addPage( progressPage, tr( "Installation progress" ) );
1283   // connect signals
1284   connect( passedParams, SIGNAL( returnPressed() ), this, SLOT( onReturnPressed() ) ) ;
1285 }
1286 // ================================================================
1287 /*!
1288  *  SALOME_InstallWizard::setupReadmePage
1289  *  Creates readme page
1290  */
1291 // ================================================================
1292 void SALOME_InstallWizard::setupReadmePage()
1293 {
1294   // create page
1295   readmePage = new QWidget( this, "readmePage" );
1296   QVBoxLayout* pageLayout = new QVBoxLayout( readmePage );
1297   pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
1298   // README info text box
1299   readme = new QTextEdit( readmePage );
1300   readme->setReadOnly( true );
1301   readme->setTextFormat( PlainText );
1302   readme->setFont( QFont( "Fixed", 12 ) );
1303   readme->setUndoRedoEnabled ( false );
1304   setAboutInfo( readme, tr( "README information" ) );
1305   readme->setPaletteBackgroundColor( readmePage->paletteBackgroundColor() );
1306   readme->setMinimumHeight( 10 );
1307
1308   pageLayout->addWidget( readme );
1309   pageLayout->setStretchFactor( readme, 5 );
1310
1311   // Operation buttons
1312   QHBoxLayout* hLayout = new QHBoxLayout( -1, "finishButtons" );
1313   hLayout->setMargin( 0 ); hLayout->setSpacing( 6 );
1314   hLayout->addStretch();
1315   pageLayout->addLayout( hLayout );
1316
1317   // loading README file
1318   QString readmeFile = QDir::currentDirPath() + "/README";
1319   QString text;
1320   if ( readFile( readmeFile, text ) )
1321     readme->setText( text );
1322   else
1323     readme->setText( tr( "README file has not been found" ) );
1324
1325   // adding page
1326   addPage( readmePage, tr( "Finish installation" ) );
1327 }
1328 // ================================================================
1329 /*!
1330  *  SALOME_InstallWizard::showChoiceInfo
1331  *  Displays choice info
1332  */
1333 // ================================================================
1334 void SALOME_InstallWizard::showChoiceInfo()
1335 {
1336   choices->clear();
1337
1338   long totSize, tempSize;
1339   checkSize( &totSize, &tempSize );
1340   int nbProd = 0;
1341   QString text;
1342
1343   text += tr( "Current Linux platform" )+ ": <b>" + (!curPlatform.isEmpty() ? curPlatform : QString( "Unknown" )) + "</b><br>";
1344   if ( !refPlatform.isEmpty() )
1345     text += tr( "Reference Linux platform" ) + ": <b>" + refPlatform + "</b><br>";
1346   text += "<br>";
1347
1348   text += tr( "Target directory:" ) + " <b>" + QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) + "</b><br>";
1349   text += tr( "Temporary directory:" ) + " <b>" + QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + "</b><br>";
1350   text += "<br>";
1351
1352   text += tr( "SALOME modules to be installed" ) + ":<ul>";
1353   QCheckListItem* item = (QCheckListItem*)( modulesView->firstChild() );
1354   while( item ) {
1355     if ( productsMap.contains( item ) ) {
1356       if ( item->isOn() ) {
1357         text += "<li><b>" + item->text() + "</b><br>";
1358         nbProd++;
1359       }
1360     }
1361     item = (QCheckListItem*)( item->nextSibling() );
1362   }
1363   if ( nbProd == 0 ) {
1364     text += "<li><b>" + tr( "none" ) + "</b><br>";
1365   }
1366   text += "</ul>";
1367   nbProd = 0;
1368   text += tr( "Prerequisites to be installed" ) + ":<ul>";
1369   item = (QCheckListItem*)( prereqsView->firstChild() );
1370   while( item ) {
1371     if ( productsMap.contains( item ) ) {
1372       if ( item->isOn() ) {
1373         text += "<li><b>" + item->text() + " " + productsMap[ item ].getVersion() + "</b><br>";
1374         nbProd++;
1375       }
1376     }
1377     item = (QCheckListItem*)( item->nextSibling() );
1378   }
1379   if ( nbProd == 0 ) {
1380     text += "<li><b>" + tr( "none" ) + "</b><br>";
1381   }
1382   text += "</ul>";
1383   text += tr( "Total disk space required:" ) + " <b>" + QString::number( totSize ) + " KB</b><br>" ;
1384   text += tr( "Space for temporary files required:" ) + " <b>" + QString::number( tempSize ) + " KB</b><br>" ;
1385   choices->setText( text );
1386 }
1387 // ================================================================
1388 /*!
1389  *  SALOME_InstallWizard::acceptData
1390  *  Validates page when <Next> button is clicked
1391  */
1392 // ================================================================
1393 bool SALOME_InstallWizard::acceptData( const QString& pageTitle )
1394 {
1395   QString tmpstr;
1396   QWidget* aPage = InstallWizard::page( pageTitle );
1397   if ( aPage == typePage ) {
1398     // installation type page
1399     warnLab3->show();
1400     this->setAppropriate( platformsPage, false );
1401     if ( installType == Binaries ) { // 'Binary' installation type
1402       // check binaries directory
1403       QFileInfo fib( QDir::cleanDirPath( getBinPath() ) );
1404       if ( !fib.exists() ) {
1405         QMessageBox::warning( this,
1406                               tr( "Warning" ),
1407                               tr( "The directory %1 doesn't exist.\n"
1408                                   "This directory must contains another one directory with binary archives for current platform.").arg( fib.absFilePath() ),
1409                               QMessageBox::Ok,
1410                               QMessageBox::NoButton, 
1411                               QMessageBox::NoButton );
1412         return false;
1413       }
1414       if ( platformsMap.find( curPlatform ) == platformsMap.end() ) {
1415         // Unknown platform case
1416         QString aMsg = warnMsg + tr( ".\nBy default the universal binary package will be installed." );
1417         aMsg += tr( "\nIf you want to select another one, please use the following list:" );
1418         warnLab->setText( aMsg );
1419         warnLab3->hide();
1420         this->setAppropriate( platformsPage, true );
1421       }
1422       else {
1423         // Supported platform case
1424         QString aPlatform = curPlatform;
1425         if ( curPlatform != getBasePlatform() ) {
1426           refPlatform = getBasePlatform();
1427           xmlFileName = platformsMap[ refPlatform ];
1428           aPlatform = getPlatform();
1429         }
1430         QFileInfo fibp( QDir::cleanDirPath( getBinPath() + "/" + aPlatform ) );
1431         if ( !fibp.isDir() ) {
1432           warnLab->setText( tr( "Binaries are absent for current platform." ) );
1433           this->setAppropriate( platformsPage, true );
1434         }
1435       }
1436
1437       // check sources directory
1438       QFileInfo fis( QDir::cleanDirPath( getSrcPath() ) );
1439       if ( !fis.exists() )
1440         if ( QMessageBox::warning( this,
1441                                    tr( "Warning" ),
1442                                    tr( "The directory %1 doesn't exist.\n"
1443                                        "This directory must contains sources archives.\n"
1444                                        "Continue?" ).arg( fis.absFilePath() ),
1445                                    tr( "&Yes" ),
1446                                    tr( "&No" ), 
1447                                    QString::null, 1, 1 ) == 1 )
1448           return false;
1449     }
1450     else { // 'Source' or 'Compile' installation type
1451       // check sources directory
1452       QFileInfo fis( QDir::cleanDirPath( getSrcPath() ) );
1453       if ( !fis.exists() ) {
1454         QMessageBox::warning( this,
1455                               tr( "Warning" ),
1456                               tr( "The directory %1 doesn't exist.\n"
1457                                   "This directory must contains sources archives.\n" ).arg( fis.absFilePath() ),
1458                               QMessageBox::Ok,
1459                               QMessageBox::NoButton, 
1460                               QMessageBox::NoButton );
1461         return false;
1462       }
1463       if ( platformsMap.find( curPlatform ) == platformsMap.end() ) {
1464         QString aMsg = warnMsg + ".";
1465         if ( installType == Compile )
1466           aMsg = warnMsg + tr( " and compilation is not tested on this one." );
1467         warnLab->setText( aMsg );
1468         this->setAppropriate( platformsPage, true );
1469       }
1470     }
1471   }
1472
1473   else if ( aPage == platformsPage ) {
1474     // installation platform page
1475     if ( platBtnGrp->id( platBtnGrp->selected() ) == -1 ) {
1476       QMessageBox::warning( this,
1477                             tr( "Warning" ),
1478                             tr( "Select installation platform before" ),
1479                             QMessageBox::Ok,
1480                             QMessageBox::NoButton,
1481                             QMessageBox::NoButton );
1482       return false;
1483     }
1484   }
1485
1486   else if ( aPage == dirPage ) {
1487     // installation directory page
1488     // ########## check target and temp directories (existence and available disk space)
1489     // get dirs
1490     QString targetDir = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() );
1491     QString tempDir   = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() );
1492     // check target directory
1493     if ( targetDir.isEmpty() ) {
1494       QMessageBox::warning( this,
1495                             tr( "Warning" ),
1496                             tr( "Please, enter valid target directory path" ),
1497                             QMessageBox::Ok,
1498                             QMessageBox::NoButton,
1499                             QMessageBox::NoButton );
1500       return false;
1501     }
1502     QFileInfo fi( QDir::cleanDirPath( targetDir ) );
1503     if ( !fi.exists() ) {
1504       bool toCreate =
1505         QMessageBox::warning( this,
1506                               tr( "Warning" ),
1507                               tr( "The directory %1 doesn't exist.\n"
1508                                   "Create directory?" ).arg( fi.absFilePath() ),
1509                               QMessageBox::Yes,
1510                               QMessageBox::No,
1511                               QMessageBox::NoButton ) == QMessageBox::Yes;
1512       if ( !toCreate)
1513         return false;
1514       if ( !makeDir( fi.absFilePath(), tmpstr ) ) {
1515         QMessageBox::critical( this,
1516                                tr( "Error" ),
1517                                tr( "Can't create the directory\n%1").arg( fi.absFilePath() ),
1518                                QMessageBox::Ok,
1519                                QMessageBox::NoButton,
1520                                QMessageBox::NoButton );
1521         return false;
1522       }
1523     }
1524     if ( !fi.isDir() ) {
1525       QMessageBox::warning( this,
1526                             tr( "Warning" ),
1527                             tr( "%1 is not a directory.\n"
1528                                 "Please, enter valid target directory path" ).arg( fi.absFilePath() ),
1529                             QMessageBox::Ok,
1530                             QMessageBox::NoButton,
1531                             QMessageBox::NoButton );
1532       return false;
1533     }
1534     if ( !fi.isWritable() ) {
1535       QMessageBox::warning( this,
1536                             tr( "Warning" ),
1537                             tr( "The directory %1 is not writable.\n"
1538                                 "Please, enter valid target directory path or change permissions" ).arg( fi.absFilePath() ),
1539                             QMessageBox::Ok,
1540                             QMessageBox::NoButton,
1541                             QMessageBox::NoButton );
1542       return false;
1543     }
1544     if ( hasSpace( fi.absFilePath() ) &&
1545          QMessageBox::warning( this,
1546                                tr( "Warning" ),
1547                                tr( "The target directory contains space symbols.\n"
1548                                    "This may cause problems with compiling or installing of products.\n\n"
1549                                    "Do you want to continue?"),
1550                                QMessageBox::Yes,
1551                                QMessageBox::No,
1552                                QMessageBox::NoButton ) == QMessageBox::No ) {
1553       return false;
1554     }
1555     // check temp directory
1556     if ( tempDir.isEmpty() ) {
1557       QMessageBox::warning( this,
1558                             tr( "Warning" ),
1559                             tr( "Please, enter valid temporary directory path" ),
1560                             QMessageBox::Ok,
1561                             QMessageBox::NoButton,
1562                             QMessageBox::NoButton );
1563       return false;
1564     }
1565     QFileInfo fit( QDir::cleanDirPath( tempDir ) );
1566     if ( !makeDir( fit.absFilePath() + TEMPDIRNAME, tmpCreated ) ) {
1567       QMessageBox::critical( this,
1568                              tr( "Error" ),
1569                              tr( "Can't use temporary directory.\nCheck permissions for the %1 directory.").arg( fit.absFilePath() ),
1570                              QMessageBox::Ok,
1571                              QMessageBox::NoButton,
1572                              QMessageBox::NoButton );
1573       return false;
1574     }
1575   }
1576
1577   else if ( aPage == productsPage ) {
1578     // products page
1579     // ########## check if any products are selected to be installed
1580     long totSize, tempSize;
1581     bool anySelected = checkSize( &totSize, &tempSize );
1582     if ( installType == Compile && removeSrcBtn->isOn() ) {
1583       totSize += tempSize;
1584     }
1585     if ( !anySelected ) {
1586       QMessageBox::warning( this,
1587                             tr( "Warning" ),
1588                             tr( "Select one or more products to install" ),
1589                             QMessageBox::Ok,
1590                             QMessageBox::NoButton,
1591                             QMessageBox::NoButton );
1592       return false;
1593     }
1594     // run script that checks available disk space for installing of products    // returns 1 in case of error
1595     QFileInfo fi( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) );
1596     QString script = "./config_files/checkSize.sh '";
1597     script += fi.absFilePath();
1598     script += "' ";
1599     script += QString( "%1" ).arg( totSize );
1600     ___MESSAGE___( "script = " << script.latin1() );
1601     if ( system( script ) ) {
1602       QMessageBox::critical( this,
1603                              tr( "Out of space" ),
1604                              tr( "There is no available disk space for installing of selected products" ),
1605                              QMessageBox::Ok,
1606                              QMessageBox::NoButton,
1607                              QMessageBox::NoButton );
1608       return false;
1609     }
1610     // AKL: 13/08/07 - skip tmp disk space checking (all files are unpacked into installation directory) ==>
1611     /*
1612     // run script that check available disk space for temporary files
1613     // returns 1 in case of error
1614     QFileInfo fit( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) );
1615     QString tscript = "./config_files/checkSize.sh '";
1616     tscript += fit.absFilePath();
1617     tscript += "' ";
1618     tscript += QString( "%1" ).arg( tempSize );
1619     ___MESSAGE___( "script = " << tscript.latin1() );
1620     if ( system( tscript ) ) {
1621       QMessageBox::critical( this,
1622                              tr( "Out of space" ),
1623                              tr( "There is no available disk space for the temporary files" ),
1624                              QMessageBox::Ok,
1625                              QMessageBox::NoButton,
1626                              QMessageBox::NoButton );
1627       return false;
1628       }
1629     */
1630     // AKL: 13/08/07 - skip tmp disk space checking (all files are unpacked into installation directory) <==
1631
1632     // ########## check installation scripts
1633     QCheckListItem* item;
1634     ProductsView* prodsView = modulesView;
1635     for ( int i = 0; i < 2; i++ ) {
1636       item = (QCheckListItem*)( prodsView->firstChild() );
1637       while( item ) {
1638         if ( productsMap.contains( item ) && item->isOn() ) {
1639           // check installation script definition
1640           if ( item->text(2).isEmpty() || item->text(2).isNull() ) {
1641             QMessageBox::warning( this,
1642                                   tr( "Error" ),
1643                                   tr( "The installation script for %1 is not defined.").arg(item->text(0)),
1644                                   QMessageBox::Ok,
1645                                   QMessageBox::NoButton,
1646                                   QMessageBox::NoButton );
1647             if ( !moreMode ) onMoreBtn();
1648             QListView* listView = item->listView();
1649             listView->setCurrentItem( item );
1650             listView->setSelected( item, true );
1651             listView->ensureItemVisible( item );
1652             return false;
1653           }
1654           // check installation script existence
1655           else {
1656             QFileInfo fi( QString("./config_files/") + item->text(2) );
1657             if ( !fi.exists() || !fi.isExecutable() ) {
1658               QMessageBox::warning( this,
1659                                     tr( "Error" ),
1660                                     tr( "The script %1 required for %2 doesn't exist or doesn't have execute permissions.").arg("./config_files/" + item->text(2)).arg(item->text(0)),
1661                                     QMessageBox::Ok,
1662                                     QMessageBox::NoButton,
1663                                     QMessageBox::NoButton );
1664               if ( !moreMode ) onMoreBtn();
1665               QListView* listView = item->listView();
1666               listView->setCurrentItem( item );
1667               listView->setSelected( item, true );
1668               listView->ensureItemVisible( item );
1669               return false;
1670             }
1671           }
1672           // check installation scripts dependencies
1673           QStringList dependOn = productsMap[ item ].getDependancies();
1674           QString version = productsMap[ item ].getVersion();
1675           for ( int i = 0; i < (int)dependOn.count(); i++ ) {
1676             QCheckListItem* depitem = findItem( dependOn[ i ] );
1677             if ( !depitem ) {
1678               QMessageBox::warning( this,
1679                                     tr( "Error" ),
1680                                     tr( "%1 is required for %2 %3 installation.\n"
1681                                         "This product is missing in the configuration file %4.").arg(dependOn[ i ]).arg(item->text(0)).arg(version).arg(xmlFileName),
1682                                     QMessageBox::Ok,
1683                                     QMessageBox::NoButton,
1684                                     QMessageBox::NoButton );
1685               return false;
1686             }
1687           }
1688         }
1689         item = (QCheckListItem*)( item->nextSibling() );
1690       }
1691       prodsView = prereqsView;
1692     }
1693 //     return true; // return in order to avoid default postValidateEvent() action
1694   }
1695   return InstallWizard::acceptData( pageTitle );
1696 }
1697 // ================================================================
1698 /*!
1699  *  SALOME_InstallWizard::checkSize
1700  *  Calculates disk space required for the installation
1701  */
1702 // ================================================================
1703 bool SALOME_InstallWizard::checkSize( long* totSize, long* tempSize )
1704 {
1705   long tots = 0, temps = 0;
1706   long maxSrcTmp = 0;
1707   int nbSelected = 0;
1708
1709   MapProducts::Iterator mapIter;
1710   for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
1711     QCheckListItem* item = mapIter.key();
1712     Dependancies dep = mapIter.data();
1713     if ( !item->isOn() )
1714       continue;
1715     tots += ( QStringList::split( " ", item->text(1) )[0] ).toLong();
1716     maxSrcTmp = max( maxSrcTmp, dep.getSize( Compile ) - dep.getSize( Binaries ) );
1717     temps += dep.getTempSize( installType );
1718     nbSelected++;
1719   }
1720
1721   if ( totSize )
1722     if ( installType == Compile && removeSrcBtn->isOn() )
1723       temps += maxSrcTmp;
1724     *totSize = tots;
1725   if ( tempSize )
1726     *tempSize = temps;
1727   return ( nbSelected > 0 );
1728 }
1729 // ================================================================
1730 /*!
1731  *  SALOME_InstallWizard::updateAvailableSpace
1732  *  Slot to update 'Available disk space' field
1733  */
1734 // ================================================================
1735 void SALOME_InstallWizard::updateAvailableSpace()
1736 {
1737   if ( diskSpaceProc->normalExit() )
1738     availableSize->setText( diskSpaceProc->readLineStdout() + " KB");
1739 }
1740 // ================================================================
1741 /*!
1742  *  SALOME_InstallWizard::runModifyLaFiles
1743  *  Run the modification of SALOME *.la files
1744  */
1745 // ================================================================
1746 void SALOME_InstallWizard::runModifyLaFiles()
1747 {
1748   // ... update status label
1749   statusLab->setText( tr( "Modification of *.la files of SALOME modules..." ) );
1750   // set process arguments
1751   modifyLaProc->setWorkingDirectory( QDir::cleanDirPath( QFileInfo( "./config_files/" ).absFilePath() ) );
1752   modifyLaProc->addArgument( "modifyLaFiles.sh" );
1753   modifyLaProc->addArgument( "modify_la_files" );
1754   modifyLaProc->addArgument( QDir::cleanDirPath( QFileInfo( targetFolder->text().stripWhiteSpace() ).absFilePath() ) );
1755   modifyLaProc->addArgument( oneModDirName );
1756   // ... run script
1757   if ( !modifyLaProc->start() )
1758     ___MESSAGE___( "Error: process could not start!" );
1759 }
1760 // ================================================================
1761 /*!
1762  *  SALOME_InstallWizard::checkModifyLaResult
1763  *  Slot to take result of modification SALOME *.la files
1764  */
1765 // ================================================================
1766 void SALOME_InstallWizard::checkModifyLaResult()
1767 {
1768   if ( modifyLaProc->normalExit() && modifyLaProc->exitStatus() == 1 )
1769     runCheckFLib();
1770   else {
1771     // abort of the current installation
1772     abort();
1773     statusLab->setText( tr( "Installation has been aborted" ) );
1774     QMessageBox::critical( this,
1775                            tr( "Error" ),
1776                            tr( "There is a problem during modification of *.la SALOME files"),
1777                            QMessageBox::Ok,
1778                            QMessageBox::NoButton,
1779                            QMessageBox::NoButton );
1780   }
1781 }
1782 // ================================================================
1783 /*!
1784  *  SALOME_InstallWizard::runCheckFLib
1785  *  Run the Fortran libraries checking
1786  */
1787 // ================================================================
1788 void SALOME_InstallWizard::runCheckFLib()
1789 {
1790   // Check Fortran libraries
1791   // ... update status label
1792   statusLab->setText( tr( "Check Fortran libraries..." ) );
1793   // ... search "not found" libraries
1794   checkFLibProc->setWorkingDirectory( QDir::cleanDirPath( QFileInfo( "./config_files/" ).absFilePath() ) );
1795   checkFLibProc->addArgument( "checkFortran.sh" );
1796   checkFLibProc->addArgument( "find_libraries" );
1797   checkFLibProc->addArgument( QDir::cleanDirPath( QFileInfo( targetFolder->text().stripWhiteSpace() ).absFilePath() ) );
1798   // ... run script
1799   if ( !checkFLibProc->start() )
1800     ___MESSAGE___( "Error: process could not start!" );
1801 }
1802 // ================================================================
1803 /*!
1804  *  SALOME_InstallWizard::checkFLibResult
1805  *  Slot to take result of Fortran libraries checking
1806  */
1807 // ================================================================
1808 void SALOME_InstallWizard::checkFLibResult()
1809 {
1810   if ( checkFLibProc->normalExit() && checkFLibProc->exitStatus() == 1 ) {
1811     QStringList notFoundLibsList;
1812     QString record = "";
1813     while ( checkFLibProc->canReadLineStdout() ) {
1814       record = checkFLibProc->readLineStdout();
1815       if ( !record.isEmpty() && !notFoundLibsList.contains( record ) )
1816         notFoundLibsList.append( record );
1817     }
1818     QMessageBox::warning( this,
1819                           tr( "Warning" ),
1820                           tr( "The following libraries are absent on current system:\n"
1821                           "%1").arg( notFoundLibsList.join( "\n" ) ),
1822                           QMessageBox::Ok,
1823                           QMessageBox::NoButton,
1824                           QMessageBox::NoButton );
1825   }
1826   // Update GUI and check installation errors
1827   completeInstallation();
1828 }
1829 // ================================================================
1830 /*!
1831  *  SALOME_InstallWizard::updateSizeColumn
1832  *  Sets required size for each product according to 
1833  *  installation type and 'Remove SRC & TMP' checkbox state
1834  */
1835 // ================================================================
1836 void SALOME_InstallWizard::updateSizeColumn()
1837 {
1838   long prodSize = 0;
1839   bool removeSrc = removeSrcBtn->isChecked();
1840   MapProducts::Iterator mapIter;
1841   for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
1842     QCheckListItem* item = mapIter.key();
1843     Dependancies dep = mapIter.data();
1844     // get required size for current product
1845     long binSize = dep.getSize( Binaries );
1846     long srcSize = dep.getSize( Sources );
1847     long bldSize = dep.getSize( Compile );
1848     InstallationType instType = getInstType();
1849     if ( instType == Binaries ) {
1850       if ( dep.getType() == "component" )
1851         prodSize = binSize + srcSize;
1852       else
1853         prodSize = ( binSize != 0 ? binSize : srcSize );
1854     }
1855     else if ( instType == Sources )
1856       prodSize = srcSize;
1857     else
1858       if ( removeSrc )
1859         prodSize = ( binSize != 0 ? binSize : srcSize );
1860       else {
1861         prodSize = ( bldSize != 0 ? bldSize : srcSize );
1862       }
1863     // fill in 'Size' field
1864     item->setText( 1, QString::number( prodSize )+" KB" );
1865   }
1866 }
1867 // ================================================================
1868 /*!
1869  *  SALOME_InstallWizard::checkProductPage
1870  *  Checks products page validity (directories and products selection) and
1871  *  enabled/disables "Next" button for the Products page
1872  */
1873 // ================================================================
1874 void SALOME_InstallWizard::checkProductPage()
1875 {
1876   if ( this->currentPage() != productsPage )
1877     return;
1878   long tots = 0, temps = 0;
1879   // check if any product is selected;
1880   bool isAnyProductSelected = checkSize( &tots, &temps );
1881
1882   // update required size information
1883   requiredSize->setText( QString::number( tots )  + " KB");
1884   requiredTemp->setText( QString::number( temps ) + " KB");
1885
1886   // update available size information
1887   QFileInfo fi( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) );
1888   if ( fi.exists() ) {
1889     diskSpaceProc->clearArguments();
1890     QString script = "./config_files/diskSpace.sh";
1891     diskSpaceProc->addArgument( script );
1892     diskSpaceProc->addArgument( fi.absFilePath() );
1893     // run script
1894     diskSpaceProc->start();
1895   }
1896
1897   // enable/disable "Next" button
1898   setNextEnabled( productsPage, isAnyProductSelected );
1899 }
1900 // ================================================================
1901 /*!
1902  *  SALOME_InstallWizard::setPrerequisites
1903  *  Sets the product and all products this one depends on to be checked ( recursively )
1904  */
1905 // ================================================================
1906 void SALOME_InstallWizard::setPrerequisites( QCheckListItem* item )
1907 {
1908   if ( !productsMap.contains( item ) )
1909     return;
1910   if ( !item->isOn() )
1911     return;
1912   // get all prerequisites
1913   QStringList dependOn = productsMap[ item ].getDependancies();
1914   // install SALOME without GUI case
1915   if ( installGuiBtn->state() != QButton::On && woGuiModules.contains( item->text(0) ) != 0 ) {
1916     dependOn.remove( "GUI" );
1917   }
1918   // setting prerequisites
1919   for ( int i = 0; i < (int)dependOn.count(); i++ ) {
1920     MapProducts::Iterator itProd;
1921     for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) {
1922       if ( itProd.data().getName() == dependOn[ i ] ) {
1923         if ( itProd.data().getType() == "component" && !itProd.key()->isOn() )
1924           itProd.key()->setOn( true );
1925         else if ( itProd.data().getType() == "prerequisite" ) {
1926           itProd.key()->setOn( true );
1927           itProd.key()->setEnabled( false );
1928         }
1929       }
1930     }
1931   }
1932 }
1933 // ================================================================
1934 /*!
1935  *  SALOME_InstallWizard::unsetPrerequisites
1936  *  Unsets all modules which depend of the unchecked product ( recursively )
1937  */
1938 // ================================================================
1939 void SALOME_InstallWizard::unsetPrerequisites( QCheckListItem* item )
1940 {
1941   if ( !productsMap.contains( item ) )
1942     return;
1943   if ( item->isOn() )
1944     return;
1945
1946 // uncheck dependent products
1947   QString itemName = productsMap[ item ].getName();
1948   MapProducts::Iterator itProd;
1949   for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) {
1950     if ( itProd.data().getType() == productsMap[ item ].getType() ) {
1951       QStringList dependOn = itProd.data().getDependancies();
1952       for ( int i = 0; i < (int)dependOn.count(); i++ ) {
1953         if ( dependOn[ i ] == itemName ) {
1954           if ( itProd.key()->isOn() ) {
1955             itProd.key()->setOn( false );
1956           }
1957         }
1958       }
1959     }
1960   }
1961
1962 // uncheck prerequisites
1963   int nbDependents;
1964 //   cout << "item name = " << productsMap[ item ].getName() << endl;
1965   QStringList dependOnList = productsMap[ item ].getDependancies();
1966   for ( int j = 0; j < (int)dependOnList.count(); j++ ) {
1967     nbDependents = 0;
1968     MapProducts::Iterator itProd1;
1969     for ( itProd1 = productsMap.begin(); itProd1 != productsMap.end(); ++itProd1 ) {
1970       if ( itProd1.data().getName() == dependOnList[ j ] ) {
1971         if ( itProd1.data().getType() == "prerequisite" ) {
1972           MapProducts::Iterator itProd2;
1973           for ( itProd2 = productsMap.begin(); itProd2 != productsMap.end(); ++itProd2 ) {
1974             if ( itProd2.key()->isOn() ) {
1975               QStringList prereqsList = productsMap[ itProd2.key() ].getDependancies();
1976               for ( int k = 0; k < (int)prereqsList.count(); k++ ) {
1977                 if ( prereqsList[ k ] == itProd1.data().getName() ) {
1978                   nbDependents++;
1979                 }
1980               }
1981             }
1982           }
1983           if ( nbDependents == 0 ) {
1984             itProd1.key()->setEnabled( true );
1985             itProd1.key()->setOn( false );
1986           }
1987         }
1988       }
1989     }
1990   }
1991 }
1992 // ================================================================
1993 /*!
1994  *  SALOME_InstallWizard::launchScript
1995  *  Runs installation script
1996  */
1997 // ================================================================
1998 void SALOME_InstallWizard::launchScript()
1999 {
2000   // try to find product being processed now
2001   QString prodProc = progressView->findStatus( Processing );
2002   if ( !prodProc.isNull() ) {
2003     ___MESSAGE___( "Found <Processing>: " );
2004
2005     // if found - set status to "completed"
2006     progressView->setStatus( prodProc, Completed );
2007     // ... clear status label
2008     statusLab->clear();
2009     // ... and call this method again
2010     launchScript();
2011     return;
2012   }
2013   // else try to find next product which is not processed yet
2014   prodProc = progressView->findStatus( Waiting );
2015   if ( !prodProc.isNull() ) {
2016     ___MESSAGE___( "Found <Waiting>: " << prodProc.latin1() );
2017     // if found - set status to "processed" and run script
2018     progressView->setStatus( prodProc, Processing );
2019     progressView->ensureVisible( prodProc );
2020     
2021     QCheckListItem* item;
2022     // fill in script parameters
2023     shellProcess->clearArguments();
2024     // ... script name
2025     shellProcess->setWorkingDirectory( QDir::cleanDirPath( QFileInfo( "./config_files/" ).absFilePath() ) );
2026     if ( !extraProducts.contains( prodProc ) ) {
2027       item = findItem( prodProc );
2028       shellProcess->addArgument( item->text(2) );
2029     }
2030     else
2031       shellProcess->addArgument( extraProducts[ prodProc ] );
2032
2033     // ... get folder with binaries
2034     QString binDir = QDir::cleanDirPath( getBinPath() );
2035     QString OS = getPlatform();
2036     if ( refPlatform.isEmpty() && singleBinPlts.contains(curPlatform) == 0 )
2037       OS = commonPlatform;
2038     binDir += "/" + OS;
2039     // ... temp folder
2040     QString tmpFolder = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
2041     //if( !tempFolder->isEnabled() )
2042     //  tmpFolder = "/tmp";
2043
2044     // ... not install : try to find preinstalled
2045     if ( notInstall.contains( prodProc ) || prodProc == "gcc" ) {
2046       shellProcess->addArgument( "try_preinstalled" );
2047       shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
2048       shellProcess->addArgument( QDir::currentDirPath() + "/Products" );
2049       statusLab->setText( tr( "Collecting environment for '" ) + prodProc + "'..." );
2050     }
2051     // ... binaries ?
2052     else if ( installType == Binaries ) {
2053       shellProcess->addArgument( "install_binary" );
2054       shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
2055       shellProcess->addArgument( binDir );
2056       statusLab->setText( tr( "Installing '" ) + prodProc + "'..." );
2057     }
2058     // ... sources or sources_and_compilation ?
2059     else {
2060       shellProcess->addArgument( installType == Sources ? "install_source" : 
2061                                  "install_source_and_build" );
2062       shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
2063       shellProcess->addArgument( QDir::cleanDirPath( getSrcPath() ) );
2064       statusLab->setText( tr( "Installing '" ) + prodProc + "'..." );
2065     }
2066     // ... target folder
2067     QString tgtFolder = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() );
2068     shellProcess->addArgument( QFileInfo( tgtFolder ).absFilePath() );
2069     // ... list of all products
2070     QString depproducts = getAllProducts(productsMap);
2071     depproducts.prepend( QStringList( extraProducts.keys() ).join(" ") + " " );
2072     ___MESSAGE___( "Dependancies"<< depproducts.latin1() );
2073     shellProcess->addArgument( depproducts );
2074     // ... product name - currently installed product
2075     if ( !extraProducts.contains( prodProc ) )
2076       shellProcess->addArgument( item->text(0) );
2077     else
2078       shellProcess->addArgument( prodProc );
2079     // ... list of products being installed
2080     shellProcess->addArgument( prodSequence.join( " " ) );
2081     // ... sources directory
2082     shellProcess->addArgument( QDir::cleanDirPath( getSrcPath() ) );
2083     // ... remove sources and tmp files or not?
2084     if ( installType == Compile && removeSrcBtn->isOn() )
2085       shellProcess->addArgument( "TRUE" );
2086     else 
2087       shellProcess->addArgument( "FALSE" );
2088     // ... binaries directory
2089     shellProcess->addArgument( binDir );
2090     // ... install SALOME with GUI or not?
2091     if ( woGuiModules.contains( prodProc ) != 0 ) {
2092       if ( installGuiBtn->state() != QButton::On )
2093         shellProcess->addArgument( "FALSE" );
2094       else
2095         shellProcess->addArgument( "TRUE" );
2096     }
2097     // ... single installation directory for SALOME modules, if this option was selected
2098     if ( oneModDirBtn->isChecked() ) {
2099       MapProducts::Iterator mapIter;
2100       for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter )
2101         if ( mapIter.data().getName() == prodProc && mapIter.data().getType() == "component" )
2102           shellProcess->addArgument( oneModDirName );
2103     }
2104     // ... single installation directory for prerequisites, if this option was selected
2105     if ( oneProdDirBtn->isChecked() ) {
2106       if ( prodProc == "DebianLibsForSalome" )
2107         shellProcess->addArgument( oneProdDirName );
2108       else {
2109         MapProducts::Iterator mapIter;
2110         for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter )
2111           if ( mapIter.data().getName() == prodProc && mapIter.data().getType() == "prerequisite" )
2112             shellProcess->addArgument( oneProdDirName );
2113       }
2114     }
2115     
2116     // run script
2117     if ( !shellProcess->start() ) {
2118       // error handling can be here
2119       ___MESSAGE___( "error" );
2120     }
2121     return;
2122   }
2123   ___MESSAGE___( "All products have been installed successfully" );
2124   // all products are installed successfully
2125   MapProducts::Iterator mapIter;
2126   ___MESSAGE___( "starting pick-up environment" );
2127   QString depproducts = QUOTE( getAllProducts(productsMap).prepend( QStringList( extraProducts.keys() ).join(" ") + " " ) );
2128   for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
2129     QCheckListItem* item = mapIter.key();
2130     Dependancies dep = mapIter.data();
2131     if ( item->isOn() && dep.pickUpEnvironment() ) {
2132       statusLab->setText( tr( "Pick-up products environment for " ) + dep.getName().latin1() + "..." );
2133       ___MESSAGE___( "... for " << dep.getName().latin1() );
2134       QString script;
2135       script += "cd " + QUOTE( QFileInfo( QDir::cleanDirPath( "./config_files/" ) ).absFilePath() ) + "; ";
2136       script += item->text(2) + " ";
2137       script += "pickup_env ";
2138       script += QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() ) + " ";
2139       script += QUOTE( QFileInfo( QDir::cleanDirPath( QDir::currentDirPath() + "/Products" ) ).absFilePath() ) + " ";
2140       script += QUOTE( QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) ).absFilePath() ) + " ";
2141       script += depproducts + " ";
2142       script += item->text(0) + " ";
2143       script += QUOTE( prodSequence.join( " " ) );
2144       ___MESSAGE___( "... --> " << script.latin1() );
2145       if ( system( script.latin1() ) ) {
2146         ___MESSAGE___( "ERROR" );
2147       }
2148     }
2149   }
2150
2151   if ( installType == Binaries ) {
2152     if ( oneModDirBtn->isChecked() )
2153       runModifyLaFiles();
2154     else
2155       runCheckFLib();
2156   }
2157   else {
2158     // Update GUI and check installation errors
2159     completeInstallation();
2160   }
2161   
2162 }
2163 // ================================================================
2164 /*!
2165  *  SALOME_InstallWizard::completeInstallation
2166  *  Update GUI and check installation errors
2167  */
2168 // ================================================================
2169 void SALOME_InstallWizard::completeInstallation()
2170 {
2171   // update status label
2172   statusLab->setText( tr( "Installation completed" ) );
2173   // <Next> button
2174   setNextEnabled( true );
2175   nextButton()->setText( tr( "&Next >" ) );
2176   setAboutInfo( nextButton(), tr( "Move to the next step of the installation procedure" ) );
2177   disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
2178   disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
2179   connect(    this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
2180   // <Back> button
2181   setBackEnabled( true );
2182   // script parameters
2183   passedParams->clear();
2184   passedParams->setEnabled( false );
2185   QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
2186   installInfo->setFinished( true );
2187   if ( isMinimized() )
2188     showNormal();
2189   raise();
2190   if ( hasErrors ) {
2191     if ( QMessageBox::warning( this,
2192                                tr( "Warning" ),
2193                                tr( "There were some errors and/or warnings during the installation.\n"
2194                                    "Do you want to save the installation log?" ),
2195                                tr( "&Save" ),
2196                                tr( "&Cancel" ),
2197                                QString::null,
2198                                0,
2199                                1 ) == 0 )
2200       saveLog();
2201   }
2202   hasErrors = false;
2203
2204 }
2205 // ================================================================
2206 /*!
2207  *  SALOME_InstallWizard::onInstallGuiBtn
2208  *  <Installation with GUI> check-box slot
2209  */
2210 // ================================================================
2211 void SALOME_InstallWizard::onInstallGuiBtn()
2212 {
2213   MapProducts::Iterator itProd;
2214   for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) {
2215     if ( itProd.data().getType() == "component" ) {
2216       if ( installGuiBtn->state() == QButton::On ) {
2217         itProd.key()->setEnabled( true );
2218         itProd.key()->setOn( true );
2219       }
2220       else {
2221         QString itemName = itProd.data().getName();
2222         if ( woGuiModules.contains( itemName ) == 0 ) {
2223           itProd.key()->setOn( false );
2224           itProd.key()->setEnabled( false );
2225         }
2226         else
2227           itProd.key()->setOn( true );
2228       }
2229     }
2230   }
2231 }
2232 // ================================================================
2233 /*!
2234  *  SALOME_InstallWizard::onMoreBtn
2235  *  <More...> button slot
2236  */
2237 // ================================================================
2238 void SALOME_InstallWizard::onMoreBtn()
2239 {
2240   if ( moreMode ) {
2241     prereqsView->hide();
2242     moreBtn->setText( tr( "Show prerequisites..." ) );
2243     setAboutInfo( moreBtn, tr( "Show list of prerequisites" ) );
2244   }
2245   else {
2246     prereqsView->show();
2247     moreBtn->setText( tr( "Hide prerequisites" ) );
2248     setAboutInfo( moreBtn, tr( "Hide list of prerequisites" ) );
2249   }
2250   qApp->processEvents();
2251   moreMode = !moreMode;
2252   InstallWizard::layOut();
2253   qApp->processEvents();
2254   if ( !isMaximized() ) {
2255     qApp->processEvents();
2256   }
2257   checkProductPage();
2258 }
2259 // ================================================================
2260 /*!
2261  *  SALOME_InstallWizard::onFinishButton
2262  *  Operation buttons slot
2263  */
2264 // ================================================================
2265 void SALOME_InstallWizard::onFinishButton()
2266 {
2267   const QObject* btn = sender();
2268   ButtonList::Iterator it;
2269   for ( it = buttons.begin(); it != buttons.end(); ++it ) {
2270     if ( (*it).button() && (*it).button() == btn ) {
2271       QString script;
2272       script += "( cd " + QUOTE( QFileInfo( QDir::cleanDirPath( "./config_files/" ) ).absFilePath() ) + "; ";
2273       script +=  + (*it).script();
2274       script += " execute ";
2275       script += QUOTE( QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) ).absFilePath() ) + " ";
2276       script += QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() ) + " ";
2277       script += " > /dev/null )";
2278       ___MESSAGE___( "script: " << script.latin1() );
2279       if ( (*it).script().isEmpty() || system( script.latin1() ) ) {
2280         QMessageBox::warning( this,
2281                               tr( "Error" ),
2282                               tr( "Can't perform action!"),
2283                               QMessageBox::Ok,
2284                               QMessageBox::NoButton,
2285                               QMessageBox::NoButton );
2286       }
2287       return;
2288     }
2289   }
2290 }
2291 // ================================================================
2292 /*!
2293  *  SALOME_InstallWizard::onAbout
2294  *  <About> button slot: shows <About> dialog box
2295  */
2296 // ================================================================
2297 void SALOME_InstallWizard::onAbout()
2298 {
2299   AboutDlg d( this );
2300   d.exec();
2301 }
2302
2303 // ================================================================
2304 /*!
2305  *  SALOME_InstallWizard::findItem
2306  *  Searches product listview item with given symbolic name
2307  */
2308 // ================================================================
2309 QCheckListItem* SALOME_InstallWizard::findItem( const QString& sName )
2310 {
2311   MapProducts::Iterator mapIter;
2312   for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
2313     if ( mapIter.data().getName() == sName )
2314       return mapIter.key();
2315   }
2316   return 0;
2317 }
2318 // ================================================================
2319 /*!
2320  *  SALOME_InstallWizard::abort
2321  *  Sets progress state to Aborted
2322  */
2323 // ================================================================
2324 void SALOME_InstallWizard::abort()
2325 {
2326   QString prod = progressView->findStatus( Processing );
2327   while ( !prod.isNull() ) {
2328     progressView->setStatus( prod, Aborted );
2329     prod = progressView->findStatus( Processing );
2330   }
2331   prod = progressView->findStatus( Waiting );
2332   while ( !prod.isNull() ) {
2333     progressView->setStatus( prod, Aborted );
2334     prod = progressView->findStatus( Waiting );
2335   }
2336 }
2337 // ================================================================
2338 /*!
2339  *  SALOME_InstallWizard::reject
2340  *  Reject slot, clears temporary directory and closes application
2341  */
2342 // ================================================================
2343 void SALOME_InstallWizard::reject()
2344 {
2345   ___MESSAGE___( "REJECTED" );
2346   if ( !exitConfirmed ) {
2347     if ( QMessageBox::information( this,
2348                                    tr( "Exit" ),
2349                                    tr( "Do you want to quit %1?" ).arg( getIWName() ),
2350                                    tr( "&Yes" ),
2351                                    tr( "&No" ),
2352                                    QString::null,
2353                                    0,
2354                                    1 ) == 1 ) {
2355       return;
2356     }
2357     exitConfirmed = true;
2358   }
2359   clean(true);
2360   InstallWizard::reject();
2361 }
2362 // ================================================================
2363 /*!
2364  *  SALOME_InstallWizard::accept
2365  *  Accept slot, clears temporary directory and closes application
2366  */
2367 // ================================================================
2368 void SALOME_InstallWizard::accept()
2369 {
2370   ___MESSAGE___( "ACCEPTED" );
2371   clean(true);
2372   InstallWizard::accept();
2373 }
2374 // ================================================================
2375 /*!
2376  *  SALOME_InstallWizard::clean
2377  *  Clears and (optionally) removes temporary directory
2378  */
2379 // ================================================================
2380 void SALOME_InstallWizard::clean(bool rmDir)
2381 {
2382   WarnDialog::showWarnDlg( 0, false );
2383   myThread->clearCommands();
2384   myWC.wakeAll();
2385   while ( myThread->running() );
2386   // first remove temporary files
2387   QString script = "cd ./config_files/; remove_tmp.sh '";
2388   script += tempFolder->text().stripWhiteSpace() + TEMPDIRNAME;
2389   script += "' ";
2390   script += QUOTE(getAllProducts(productsMap));
2391   script += " > /dev/null";
2392   ___MESSAGE___( "script = " << script.latin1() );
2393   if ( system( script.latin1() ) ) {
2394   }
2395   // then try to remove created temporary directory
2396   //script = "rm -rf " + QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
2397   if ( rmDir && !tmpCreated.isNull() ) {
2398     script = "rm -rf " + tmpCreated;
2399     script += " > /dev/null";
2400     if ( system( script.latin1() ) ) {
2401     }
2402     ___MESSAGE___( "script = " << script.latin1() );
2403   }
2404 }
2405 // ================================================================
2406 /*!
2407  *  SALOME_InstallWizard::pageChanged
2408  *  Called when user moves from page to page
2409  */
2410 // ================================================================
2411 void SALOME_InstallWizard::pageChanged( const QString & mytitle)
2412 {
2413   nextButton()->setText( tr( "&Next >" ) );
2414   setAboutInfo( nextButton(), tr( "Move to the next step of the installation procedure" ) );
2415   disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
2416   disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
2417   connect(    this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
2418   cancelButton()->disconnect();
2419   connect( cancelButton(), SIGNAL( clicked()), this, SLOT( reject() ) );
2420
2421   QWidget* aPage = InstallWizard::page( mytitle );
2422   if ( !aPage )
2423     return;
2424   updateCaption();
2425
2426   if ( aPage == typePage ) {
2427     // installation type page
2428     if ( buttonGrp->id( buttonGrp->selected() ) == -1 )
2429       binBtn->animateClick(); // set default installation type
2430   }
2431   else if ( aPage == platformsPage ) {
2432     // installation platforms page
2433     MapXmlFiles::Iterator it;
2434     if ( previousPage == typePage ) {
2435       for ( it = platformsMap.begin(); it != platformsMap.end(); ++it ) {
2436         QString plat = it.key();
2437         QRadioButton* rb = ( (QRadioButton*) platBtnGrp->child( plat ) );
2438         if ( installType == Binaries ) {
2439           QFileInfo fib( QDir::cleanDirPath( getBinPath() + "/" + plat ) );
2440           rb->setEnabled( fib.exists() );
2441           if ( platBtnGrp->id( platBtnGrp->selected() ) == -1 && plat == getBasePlatform() )
2442             rb->animateClick();
2443         }
2444         else {
2445           QFileInfo fis( QDir::cleanDirPath( getSrcPath() ) );
2446           rb->setEnabled( fis.exists() );
2447         }
2448         rb->setChecked( rb->isChecked() && rb->isEnabled() );
2449       }
2450       setNextEnabled( platformsPage, platBtnGrp->id( platBtnGrp->selected() ) != -1 );
2451     }
2452   }
2453   else  if ( aPage == dirPage ) {
2454     // installation and temporary directories page
2455     if ( ( ( this->indexOf( platformsPage ) != -1 && this->appropriate( platformsPage ) ) ? 
2456            previousPage == platformsPage : previousPage == typePage ) 
2457          && stateChanged ) {
2458       // clear global variables before reading XML file
2459       modulesView->clear();
2460       prereqsView->clear();
2461       productsMap.clear();
2462       // read XML file
2463       StructureParser* parser = new StructureParser( this );
2464       parser->setProductsLists( modulesView, prereqsView );
2465       if ( targetFolder->text().isEmpty() )
2466         parser->setTargetDir( targetFolder );
2467       if ( tempFolder->text().isEmpty() )
2468         parser->setTempDir( tempFolder );
2469       parser->readXmlFile( xmlFileName );
2470       // create a list of SALOME modules, that support installation without GUI mode
2471       if ( woGuiModules.isEmpty() ) {
2472         MapProducts::Iterator mapIter;
2473         for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); mapIter++ ) {
2474           Dependancies dep = mapIter.data();
2475           if ( dep.supportWoGuiMode() )
2476             woGuiModules.append( dep.getName() );
2477         }
2478       }
2479   
2480       // update required size for each product
2481       updateSizeColumn();
2482       // take into account command line parameters
2483       if ( !myTargetPath.isEmpty() )
2484         targetFolder->setText( myTargetPath );
2485       if ( !myTmpPath.isEmpty() )
2486         tempFolder->setText( myTmpPath );
2487       // set all modules to be checked and first module to be selected
2488       installGuiBtn->setState( QButton::Off );
2489       installGuiBtn->setState( QButton::On );
2490       if ( modulesView->childCount() > 0 && !modulesView->selectedItem() )
2491         modulesView->setSelected( modulesView->firstChild(), true );
2492       stateChanged = false;
2493     } 
2494     else if ( rmSrcPrevState != removeSrcBtn->isChecked() ) {
2495       // only update required size for each product
2496       updateSizeColumn();
2497       rmSrcPrevState = removeSrcBtn->isChecked();
2498     }
2499     // add extra products to install list
2500     extraProducts.clear();
2501     extraProducts.insert( "gcc", "gcc-common.sh" );
2502     if ( refPlatform == commonPlatform && installType == Binaries )
2503       extraProducts.insert( "DebianLibsForSalome", "DEBIANFORSALOME-3.1.sh" );
2504   }
2505   else if ( aPage == productsPage ) {
2506     // products page
2507     onSelectionChanged();
2508     checkProductPage();
2509   }
2510   else if ( aPage == prestartPage ) {
2511     // prestart page
2512     showChoiceInfo();
2513   }
2514   else if ( aPage == progressPage ) {
2515     if ( previousPage == prestartPage ) {
2516       // progress page
2517       statusLab->clear();
2518       progressView->clear();
2519       installInfo->clear();
2520       installInfo->setFinished( false );
2521       passedParams->clear();
2522       passedParams->setEnabled( false );
2523       QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
2524       nextButton()->setText( tr( "&Start" ) );
2525       setAboutInfo( nextButton(), tr( "Start installation process" ) );
2526       // reconnect Next button - to use it as Start button
2527       disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
2528       disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
2529       connect(    this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
2530       setNextEnabled( true );
2531       // reconnect Cancel button to terminate process
2532       cancelButton()->disconnect();
2533       connect( cancelButton(), SIGNAL( clicked() ), this, SLOT( tryTerminate() ) );
2534     }
2535   }
2536   else if ( aPage == readmePage ) {
2537     ButtonList::Iterator it;
2538     for ( it = buttons.begin(); it != buttons.end(); ++it ) {
2539       if ( (*it).button() ) {
2540         QString script;
2541         script += "( cd " + QUOTE( QFileInfo( QDir::cleanDirPath( "./config_files/" ) ).absFilePath() ) + "; ";
2542         script +=  + (*it).script();
2543         script += " check_enabled ";
2544         script += QUOTE( QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) ).absFilePath() ) + " ";
2545         script += QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() ) + " ";
2546         script += " > /dev/null )";
2547         ___MESSAGE___( "script: " << script.latin1() );
2548         (*it).button()->setEnabled( !(*it).script().isEmpty() && !system( script.latin1() ) );
2549       }
2550     }
2551     finishButton()->setEnabled( true );
2552   }
2553   previousPage = aPage;
2554   ___MESSAGE___( "previousPage = " << previousPage );
2555 }
2556 // ================================================================
2557 /*!
2558  *  SALOME_InstallWizard::onButtonGroup
2559  *  Called when user selected either installation type or installation platform
2560  */
2561 // ================================================================
2562 void SALOME_InstallWizard::onButtonGroup( int rbIndex )
2563 {
2564   int prevType = installType;
2565   QString prevPlat = getPlatform();
2566   QWidget* aPage = InstallWizard::currentPage();
2567   if ( aPage == typePage ) {
2568     installType = InstallationType( rbIndex );
2569     // management of the <Remove source and tmp files> check-box
2570     removeSrcBtn->setEnabled( installType == Compile );
2571     oneModDirBtn->setEnabled( installType == Binaries /*|| installType == Compile*/ );
2572     oneProdDirBtn->setEnabled( installType == Binaries || installType == Compile );
2573   }
2574   else if ( aPage == platformsPage ) {
2575     refPlatform = platBtnGrp->find( rbIndex )->name();
2576     xmlFileName = platformsMap[ refPlatform ];
2577 //     cout << xmlFileName << endl;
2578     setNextEnabled( platformsPage, true );
2579   }
2580   if ( prevType != installType || 
2581        ( indexOf( platformsPage ) != -1 ? prevPlat != getPlatform() : false ) ) {
2582     stateChanged = true;
2583     oneModDirBtn->setChecked( false );
2584     oneProdDirBtn->setChecked( false );
2585   }
2586 }
2587 // ================================================================
2588 /*!
2589  *  SALOME_InstallWizard::helpClicked
2590  *  Shows help window
2591  */
2592 // ================================================================
2593 void SALOME_InstallWizard::helpClicked()
2594 {
2595   if ( helpWindow == NULL ) {
2596     helpWindow = HelpWindow::openHelp( this );
2597     if ( helpWindow ) {
2598       helpWindow->show();
2599       helpWindow->installEventFilter( this );
2600     }
2601     else {
2602       QMessageBox::warning( this,
2603                             tr( "Help file not found" ),
2604                             tr( "Sorry, help is unavailable" ) );
2605     }
2606   }
2607   else {
2608     helpWindow->raise();
2609     helpWindow->setActiveWindow();
2610   }
2611 }
2612 // ================================================================
2613 /*!
2614  *  SALOME_InstallWizard::browseDirectory
2615  *  Shows directory selection dialog
2616  */
2617 // ================================================================
2618 void SALOME_InstallWizard::browseDirectory()
2619 {
2620   const QObject* theSender = sender();
2621   QLineEdit* theFolder;
2622   if ( theSender == targetBtn )
2623     theFolder = targetFolder;
2624   else if (theSender == tempBtn)
2625     theFolder = tempFolder;
2626   else
2627     return;
2628   QString typedDir = QFileDialog::getExistingDirectory( QDir::cleanDirPath( theFolder->text().stripWhiteSpace() ), this );
2629   if ( !typedDir.isNull() ) {
2630     theFolder->setText( typedDir );
2631     theFolder->end( false );
2632   }
2633 }
2634 // ================================================================
2635 /*!
2636  *  SALOME_InstallWizard::directoryChanged
2637  *  Called when directory path (target or temp) is changed
2638  */
2639 // ================================================================
2640 void SALOME_InstallWizard::directoryChanged( const QString& /*text*/ )
2641 {
2642   checkProductPage();
2643 }
2644 // ================================================================
2645 /*!
2646  *  SALOME_InstallWizard::onStart
2647  *  <Start> button's slot - runs installation
2648  */
2649 // ================================================================
2650 void SALOME_InstallWizard::onStart()
2651 {
2652   if ( nextButton()->text() == tr( "&Stop" ) ) {
2653     statusLab->setText( tr( "Aborting installation..." ) );
2654     shellProcess->kill();
2655     while( shellProcess->isRunning() );
2656     statusLab->setText( tr( "Installation has been aborted by user" ) );
2657     return;
2658   }
2659
2660   hasErrors = false;
2661   progressView->clear();
2662   installInfo->clear();
2663   installInfo->setFinished( false );
2664   passedParams->clear();
2665   passedParams->setEnabled( false );
2666   QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
2667
2668   // update status label
2669   statusLab->setText( tr( "Preparing for installation..." ) );
2670   // clear lists of products
2671   toInstall.clear();
2672   notInstall.clear();
2673   toInstall += extraProducts.keys();
2674   // ... and fill it for new process
2675   QCheckListItem* item = (QCheckListItem*)( prereqsView->firstChild() );
2676   while( item ) {
2677     if ( productsMap.contains( item ) ) {
2678       if ( item->isOn() )
2679         toInstall.append( productsMap[item].getName() );
2680       else
2681         notInstall.append( productsMap[item].getName() );
2682     }
2683     item = (QCheckListItem*)( item->nextSibling() );
2684   }
2685   item = (QCheckListItem*)( modulesView->firstChild() );
2686   while( item ) {
2687     if ( productsMap.contains( item ) ) {
2688       if ( item->isOn() )
2689         toInstall.append( productsMap[item].getName() );
2690       else
2691         notInstall.append( productsMap[item].getName() );
2692     }
2693     item = (QCheckListItem*)( item->nextSibling() );
2694   }
2695   // if something at all is selected
2696   if ( (int)toInstall.count() > 1 ) {
2697
2698     if ( installType == Compile ) {
2699       // update status label
2700       statusLab->setText( tr( "Check Fortran compiler..." ) );
2701       // check Fortran compiler.
2702       QString script = "./config_files/checkFortran.sh find_compilers";
2703       script += " " + QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() );
2704       ___MESSAGE___( "script = " << script.latin1() );
2705       if ( system( script ) ) {
2706         QMessageBox::critical( this,
2707                                tr( "Error" ),
2708                                tr( "Fortran compiler was not found at current system!\n"
2709                                    "Installation can not be continued!"),
2710                                QMessageBox::Ok,
2711                                QMessageBox::NoButton,
2712                                QMessageBox::NoButton );
2713         // installation aborted
2714         abort();
2715         statusLab->setText( tr( "Installation has been aborted" ) );
2716         // enable <Next> button
2717         setNextEnabled( true );
2718         nextButton()->setText( tr( "&Start" ) );
2719         setAboutInfo( nextButton(), tr( "Start installation process" ) );
2720         // reconnect Next button - to use it as Start button
2721         disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
2722         disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
2723         connect(    this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
2724         // enable <Back> button
2725         setBackEnabled( true );
2726         return;
2727       }
2728     }  
2729     
2730     // update status label
2731     statusLab->setText( tr( "Preparing for installation..." ) );
2732
2733     clean(false); // VSR 07/02/05 - bug fix: first we should clear temporary directory
2734     // disable <Next> button
2735     //setNextEnabled( false );
2736     nextButton()->setText( tr( "&Stop" ) );
2737     setAboutInfo( nextButton(), tr( "Abort installation process" ) );
2738     // disable <Back> button
2739     setBackEnabled( false );
2740     // enable script parameters line edit
2741     // VSR commented: 18/09/03: passedParams->setEnabled( true );
2742     // VSR commented: 18/09/03: passedParams->setFocus();
2743     ProgressViewItem* progressItem;
2744     // set status for installed products
2745     for ( int i = 0; i < (int)toInstall.count(); i++ ) {
2746       if ( !extraProducts.contains( toInstall[i] ) ) {
2747         item = findItem( toInstall[i] );
2748         progressView->addProduct( item->text(0), item->text(2) );
2749         continue;
2750       }
2751       progressItem = progressView->addProduct( toInstall[i], extraProducts[toInstall[i]] );
2752       progressItem->setVisible( false );
2753     }
2754     // set status for not installed products
2755     for ( int i = 0; i < (int)notInstall.count(); i++ ) {
2756       item = findItem( notInstall[i] );
2757       progressItem = progressView->addProduct( item->text(0), item->text(2) );
2758       progressItem->setVisible( false );
2759     }
2760     // get specified list of products being installed
2761     prodSequence.clear();
2762     for (int i = 0; i<(int)toInstall.count(); i++ ) {
2763       if ( extraProducts.contains( toInstall[i] ) ) {
2764         prodSequence.append( toInstall[i] );
2765         continue;
2766       }
2767       if ( installType == Binaries ) {
2768         prodSequence.append( toInstall[i] );
2769         QString prodType;
2770         MapProducts::Iterator mapIter;
2771         for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
2772           if ( mapIter.data().getName() == toInstall[i] && mapIter.data().getType() == "component" ) {
2773             prodSequence.append( toInstall[i] + "_src" );
2774             break;
2775           }
2776         }
2777       }
2778       else if ( installType == Sources )
2779         prodSequence.append( toInstall[i] + "_src" );
2780       else {
2781         prodSequence.append( toInstall[i] );
2782         prodSequence.append( toInstall[i] + "_src" );
2783       }
2784     }
2785
2786     // create a backup of 'env_build.csh', 'env_build.sh', 'env_products.csh', 'env_products.sh'
2787     // ( backup of 'salome.csh' and 'salome.sh' is made if pick-up environment is called )
2788     QString script = "./config_files/backupEnv.sh ";
2789     script += QUOTE( QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) ).absFilePath() );
2790     ___MESSAGE___( "script = " << script.latin1() );
2791     if ( system( script ) ) {
2792       if ( QMessageBox::warning( this,
2793                                  tr( "Warning" ),
2794                                  tr( "Backup environment files have not been created.\n"
2795                                      "Do you want to continue an installation process?" ),
2796                                  tr( "&Yes" ),
2797                                  tr( "&No" ), 
2798                                  QString::null, 0, 1 ) == 1 ) {
2799         // installation aborted
2800         abort();
2801         statusLab->setText( tr( "Installation has been aborted by user" ) );
2802         // enable <Next> button
2803         setNextEnabled( true );
2804         nextButton()->setText( tr( "&Start" ) );
2805         setAboutInfo( nextButton(), tr( "Start installation process" ) );
2806         // reconnect Next button - to use it as Start button
2807         disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
2808         disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
2809         connect(    this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
2810         // enable <Back> button
2811         setBackEnabled( true );
2812         return;
2813       }
2814     }
2815
2816     // launch install script
2817     launchScript();
2818   }
2819 }
2820 // ================================================================
2821 /*!
2822  *  SALOME_InstallWizard::onReturnPressed
2823  *  Called when users tries to pass parameters for the script
2824  */
2825 // ================================================================
2826 void SALOME_InstallWizard::onReturnPressed()
2827 {
2828   QString txt = passedParams->text();
2829   installInfo->append( txt );
2830   txt += "\n";
2831   shellProcess->writeToStdin( txt );
2832   passedParams->clear();
2833   progressView->setFocus();
2834   passedParams->setEnabled( false );
2835   QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
2836 }
2837 /*!
2838   Callback function - as response for the script finishing
2839 */
2840 void SALOME_InstallWizard::productInstalled()
2841 {
2842   ___MESSAGE___( "process exited" );
2843   if ( shellProcess->normalExit() ) {
2844     ___MESSAGE___( "...normal exit" );
2845     // normal exit - try to proceed installation further
2846     launchScript();
2847   }
2848   else {
2849     ___MESSAGE___( "...abnormal exit" );
2850     statusLab->setText( tr( "Installation has been aborted" ) );
2851     // installation aborted
2852     abort();
2853     // clear script passed parameters lineedit
2854     passedParams->clear();
2855     passedParams->setEnabled( false );
2856     QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
2857     installInfo->setFinished( true );
2858     // enable <Next> button
2859     setNextEnabled( true );
2860     nextButton()->setText( tr( "&Start" ) );
2861     setAboutInfo( nextButton(), tr( "Start installation process" ) );
2862     // reconnect Next button - to use it as Start button
2863     disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
2864     disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
2865     connect(    this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
2866     //nextButton()->setText( tr( "&Next >" ) );
2867     //setAboutInfo( nextButton(), tr( "Move to the next step of the installation procedure" ) );
2868     //disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
2869     //disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
2870     //connect(    this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
2871     // enable <Back> button
2872     setBackEnabled( true );
2873   }
2874 }
2875 // ================================================================
2876 /*!
2877  *  SALOME_InstallWizard::tryTerminate
2878  *  Slot, called when <Cancel> button is clicked during installation script running
2879  */
2880 // ================================================================
2881 void SALOME_InstallWizard::tryTerminate()
2882 {
2883   if ( shellProcess->isRunning() ) {
2884     if ( QMessageBox::information( this,
2885                                    tr( "Exit" ),
2886                                    tr( "Do you want to quit %1?" ).arg( getIWName() ),
2887                                    tr( "&Yes" ),
2888                                    tr( "&No" ),
2889                                    QString::null,
2890                                    0,
2891                                    1 ) == 1 ) {
2892       return;
2893     }
2894     exitConfirmed = true;
2895     // if process still running try to terminate it first
2896     shellProcess->tryTerminate();
2897     abort();
2898     //QTimer::singleShot( 3000, this, SLOT( onCancel() ) );
2899     connect( shellProcess, SIGNAL( processExited() ), this, SLOT( onCancel() ) );
2900   }
2901   else {
2902     // else just quit install wizard
2903     reject();
2904   }
2905 }
2906 // ================================================================
2907 /*!
2908  *  SALOME_InstallWizard::onCancel
2909  *  Kills installation process and quits application
2910  */
2911 // ================================================================
2912 void SALOME_InstallWizard::onCancel()
2913 {
2914   shellProcess->kill();
2915   reject();
2916 }
2917 // ================================================================
2918 /*!
2919  *  SALOME_InstallWizard::onSelectionChanged
2920  *  Called when selection is changed in the products list view
2921  *  to fill in the 'Information about product' text box
2922  */
2923 // ================================================================
2924 void SALOME_InstallWizard::onSelectionChanged()
2925 {
2926   const QObject* snd = sender();
2927   QListViewItem* item = modulesView->selectedItem();
2928   if ( snd == prereqsView )
2929     item = prereqsView->selectedItem();
2930   if ( !item )
2931     return;
2932   productInfo->clear();
2933   QCheckListItem* anItem = (QCheckListItem*)item;
2934   if ( !productsMap.contains( anItem ) )
2935     return;
2936   Dependancies dep = productsMap[ anItem ];
2937   QString text = "<b>" + anItem->text(0) + "</b>" + "<br>";
2938   if ( !dep.getVersion().isEmpty() )
2939     text += tr( "Version" ) + ": " + dep.getVersion() + "<br>";
2940   text += "<br>";
2941   if ( !dep.getDescription().isEmpty() ) {
2942     text += "<i>" + dep.getDescription() + "</i><br><br>";
2943   }
2944   /* AKL: 07/08/28 - hide required disk space for tmp files for each product ==>
2945      long tempSize = 0;
2946      tempSize = dep.getTempSize( installType );
2947      text += tr( "Disk space for tmp files required" ) + ": " + QString::number( tempSize ) + " KB<br>";
2948      AKL: 07/08/28 - hide required disk space for tmp files for each product <==
2949   */
2950   text += tr( "Disk space required" ) + ": " + item->text(1) + "<br>";
2951   text += "<br>";
2952   QString req = ( dep.getDependancies().count() > 0 ? dep.getDependancies().join(", ") : tr( "none" ) );
2953   text +=  tr( "Prerequisites" ) + ": " + req;
2954   productInfo->setText( text );
2955 }
2956 // ================================================================
2957 /*!
2958  *  SALOME_InstallWizard::onItemToggled
2959  *  Called when user checks/unchecks any product item
2960  *  Recursively sets all prerequisites and updates "Next" button state
2961  */
2962 // ================================================================
2963 void SALOME_InstallWizard::onItemToggled( QCheckListItem* item )
2964 {
2965   if ( productsMap.contains( item ) ) {
2966     if ( item->isOn() )
2967       setPrerequisites( item );
2968     else 
2969       unsetPrerequisites( item );
2970   }
2971   onSelectionChanged();
2972   checkProductPage();
2973 }
2974 // ================================================================
2975 /*!
2976  *  SALOME_InstallWizard::wroteToStdin
2977  *  QProcess slot: -->something was written to stdin
2978  */
2979 // ================================================================
2980 void SALOME_InstallWizard::wroteToStdin( )
2981 {
2982   ___MESSAGE___( "Something was sent to stdin" );
2983 }
2984 // ================================================================
2985 /*!
2986  *  SALOME_InstallWizard::readFromStdout
2987  *  QProcess slot: -->something was written to stdout
2988  */
2989 // ================================================================
2990 void SALOME_InstallWizard::readFromStdout( )
2991 {
2992   ___MESSAGE___( "Something was sent to stdout" );
2993   while ( shellProcess->canReadLineStdout() ) {
2994     installInfo->append( QString( shellProcess->readLineStdout() ) );
2995     installInfo->scrollToBottom();
2996   }
2997   QString str( shellProcess->readStdout() );
2998   if ( !str.isEmpty() ) {
2999     installInfo->append( str );
3000     installInfo->scrollToBottom();
3001   }
3002 }
3003
3004 #define OUTLINE_TEXT(x) QString( "<font color=#FF0000><b>" ) + QString( x ) + QString( "</b></font>" )
3005
3006 // ================================================================
3007 /*!
3008  *  SALOME_InstallWizard::readFromStderr
3009  *  QProcess slot: -->something was written to stderr
3010  */
3011 // ================================================================
3012 void SALOME_InstallWizard::readFromStderr( )
3013 {
3014   ___MESSAGE___( "Something was sent to stderr" );
3015   while ( shellProcess->canReadLineStderr() ) {
3016     installInfo->append( OUTLINE_TEXT( QString( shellProcess->readLineStderr() ) ) );
3017     installInfo->scrollToBottom();
3018     hasErrors = true;
3019   }
3020   QString str( shellProcess->readStderr() );
3021   if ( !str.isEmpty() ) {
3022     installInfo->append( OUTLINE_TEXT( str ) );
3023     installInfo->scrollToBottom();
3024     hasErrors = true;
3025   }
3026   // VSR: 10/11/05 - disable answer mode ==>
3027   // passedParams->setEnabled( true );
3028   // passedParams->setFocus();
3029   // QFont f = parametersLab->font(); f.setBold( true ); parametersLab->setFont( f );
3030   // VSR: 10/11/05 - disable answer mode <==
3031 }
3032 // ================================================================
3033 /*!
3034  *  SALOME_InstallWizard::setDependancies
3035  *  Sets dependancies for the product item
3036  */
3037 // ================================================================
3038 void SALOME_InstallWizard::setDependancies( QCheckListItem* item, Dependancies dep)
3039 {
3040   productsMap[item] = dep;
3041 }
3042 // ================================================================
3043 /*!
3044  *  SALOME_InstallWizard::addFinishButton
3045  *  Add button for the <Finish> page.
3046  *  Clear list of buttons if <toClear> flag is true.
3047  */
3048 // ================================================================
3049 void SALOME_InstallWizard::addFinishButton( const QString& label,
3050                                             const QString& tooltip,
3051                                             const QString& script,
3052                                             bool toClear )
3053 {
3054   ButtonList btns;
3055   if ( toClear ) {
3056     btns = buttons;
3057     buttons.clear();
3058   }
3059   buttons.append( Button( label, tooltip, script ) );
3060   // create finish buttons
3061   QButton* b = new QPushButton( tr( buttons.last().label() ), readmePage );
3062   if ( !buttons.last().tootip().isEmpty() )
3063     setAboutInfo( b, tr( buttons.last().tootip() ) );
3064   QHBoxLayout* hLayout = (QHBoxLayout*)readmePage->layout()->child("finishButtons");
3065   if ( toClear ) {
3066     // remove previous buttons
3067     ButtonList::Iterator it;
3068     for ( it = btns.begin(); it != btns.end(); ++it ) {
3069       hLayout->removeChild( (*it).button() );
3070       delete (*it).button();
3071     }
3072   }
3073   // add buttons to finish page
3074   hLayout->insertWidget( buttons.count()-1, b );
3075   buttons.last().setButton( b );
3076   connect( b, SIGNAL( clicked() ), this, SLOT( onFinishButton() ) );
3077 }
3078 // ================================================================
3079 /*!
3080  *  SALOME_InstallWizard::polish
3081  *  Polishing of the widget - to set right initial size
3082  */
3083 // ================================================================
3084 void SALOME_InstallWizard::polish()
3085 {
3086   resize( 0, 0 );
3087   InstallWizard::polish();
3088 }
3089 // ================================================================
3090 /*!
3091  *  SALOME_InstallWizard::saveLog
3092  *  Save installation log to file
3093  */
3094 // ================================================================
3095 void SALOME_InstallWizard::saveLog()
3096 {
3097   QString txt = installInfo->text();
3098   if ( txt.length() <= 0 )
3099     return;
3100   QDateTime dt = QDateTime::currentDateTime();
3101   QString fileName = dt.toString("ddMMyy-hhmm");
3102   fileName.prepend("install-"); fileName.append(".html");
3103   fileName = QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ), fileName ).absFilePath();
3104   fileName = QFileDialog::getSaveFileName( fileName,
3105                                            QString( "HTML files (*.htm *.html)" ),
3106                                            this, 0,
3107                                            tr( "Save Log file" ) );
3108   if ( !fileName.isEmpty() ) {
3109     QFile f( fileName );
3110     if ( f.open( IO_WriteOnly ) ) {
3111       QTextStream stream( &f );
3112       stream << txt;
3113       f.close();
3114     }
3115     else {
3116       QMessageBox::critical( this,
3117                              tr( "Error" ),
3118                              tr( "Can't save file %1.\nCheck path and permissions.").arg( fileName ),
3119                              QMessageBox::Ok,
3120                              QMessageBox::NoButton,
3121                              QMessageBox::NoButton );
3122     }
3123   }
3124 }
3125 // ================================================================
3126 /*!
3127  *  SALOME_InstallWizard::updateCaption
3128  *  Updates caption according to the current page number
3129  */
3130 // ================================================================
3131 void SALOME_InstallWizard::updateCaption()
3132 {
3133   QWidget* aPage = InstallWizard::currentPage();
3134   if ( !aPage )
3135     return;
3136   InstallWizard::setCaption( tr( myCaption ) + " " +
3137                              tr( getIWName() ) + " - " +
3138                              tr( "Step %1 of %2").arg( QString::number( this->indexOf( aPage )+1 ) ).arg( QString::number( this->pageCount() ) ) );
3139 }
3140
3141 // ================================================================
3142 /*!
3143  *  SALOME_InstallWizard::processValidateEvent
3144  *  Processes validation event (<val> is validation code)
3145  */
3146 // ================================================================
3147 void SALOME_InstallWizard::processValidateEvent( const int val, void* data )
3148 {
3149   QWidget* aPage = InstallWizard::currentPage();
3150   if ( aPage != productsPage ) {
3151     InstallWizard::processValidateEvent( val, data );
3152     return;
3153   }
3154   myMutex.lock();
3155   myMutex.unlock();
3156   if ( val > 0 ) {
3157   }
3158   if ( myThread->hasCommands() )
3159     myWC.wakeAll();
3160   else {
3161     WarnDialog::showWarnDlg( 0, false );
3162     InstallWizard::processValidateEvent( val, data );
3163   }
3164 }