Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4GUI/TGo4StartClient.ui.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 
00017 void TGo4StartClient::init()
00018 {
00019    // TGo4LockGuard glob;
00020     QApplication::restoreOverrideCursor(); // get rid of waitclock mousepointer if last launch failed
00021     setCaption("Start Analysis Slave");
00022     TGo4QSettings settings;
00023     TGo4GUIRegistry *fxTGo4GUIRegistry;
00024     fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00025     fxTGo4StartClientSlots = (TGo4StartClientSlots *) fxTGo4GUIRegistry->GetSlotClass("TGo4StartClientSlots");
00026     if(fxTGo4StartClientSlots !=0) 
00027         {
00028           fxTGo4StartClientStatus = (TGo4StartClientStatus *)  fxTGo4StartClientSlots->GetStatus();
00029           fxTGo4StartClientSlots->SetGUI(this);
00030       }
00031     else
00032         {
00033           fxTGo4StartClientSlots = new TGo4StartClientSlots ("TGo4StartClientSlots", "Slots Class for Qt GUI", this);
00034           fxTGo4StartClientStatus = (TGo4StartClientStatus *)  fxTGo4StartClientSlots->GetStatus();
00035     
00036           QString ClientName = settings.readEntry( TGo4QSettings::GetSettingsName()+"/ClientSetting/Name", "MyAnalysis");
00037           QString ClientNode = settings.readEntry( TGo4QSettings::GetSettingsName()+"/ClientSetting/Node", "localhost");
00038           QString ClientDir  = settings.readEntry( TGo4QSettings::GetSettingsName()+"/ClientSetting/Dir", (QDir::currentDirPath()).data());
00039           QString ClientExec = settings.readEntry( TGo4QSettings::GetSettingsName()+"/ClientSetting/Exec", "MainUserAnalysis");
00040           
00042           QString remote = settings.readEntry( TGo4QSettings::GetSettingsName()+"/ClientSetting/Shell", "ssh");
00043           int anamode=0;
00044           if(remote.contains("rsh")) 
00045             anamode=1;
00046           else if(remote.contains("ssh")) 
00047             anamode=2;
00048           else 
00049             anamode=2;  
00050           //AnalysisModeGroup->setButton(anamode);
00052           QString terminal = settings.readEntry( TGo4QSettings::GetSettingsName()+"/ClientSetting/Term", "qt");
00053           int termmode=0;
00054           if(terminal.contains("qt"))
00055             termmode=1;
00056           else if(terminal.contains("xterm"))
00057             termmode=2;
00058           else
00059             termmode=1;  
00060           //AnalysisShellMode->setButton(termmode);
00061           fxTGo4StartClientStatus->SetSlaveNode(ClientNode);
00062           //LineEditClientNode->setText(ClientNode);
00063           fxTGo4StartClientStatus->SetSlaveName(ClientName);
00064           //LineEditClientName->setText(ClientName);
00065           fxTGo4StartClientStatus->SetSlaveDir(ClientDir);
00066           //LineEditClientDir->setText(ClientDir);
00067           fxTGo4StartClientStatus->SetSlaveExec(ClientExec);
00068           //LineEditClientExec->setText(ClientExec);
00069           AnalysisMode(anamode); 
00070           AnalysisShell(termmode);
00071          
00072         }
00073       LineEditClientName->setText(fxTGo4StartClientStatus->GetSlaveName());
00074       LineEditClientNode->setText(fxTGo4StartClientStatus->GetSlaveNode());
00075       LineEditClientDir->setText(fxTGo4StartClientStatus->GetSlaveDir());
00076       LineEditClientExec->setText(fxTGo4StartClientStatus->GetSlaveExec());
00077       AnalysisModeGroup->setButton(fxTGo4StartClientStatus->GetSlaveMode());
00078       AnalysisShellMode->setButton(fxTGo4StartClientStatus->GetSlaveShell());
00079       PortBox->setValue(fxTGo4StartClientStatus->GetServerPort());
00080       StartServerBox->setChecked(fxTGo4StartClientStatus->IsStartServer());
00081       Int_t role=fxTGo4GUIRegistry->GetClientRole();
00082       if(role>=0)// we did launch client before; take old values
00083             {
00084                 LoginCombo->setCurrentItem(role);
00085                 LineEditPasswd->setText(fxTGo4GUIRegistry->GetClientPassword());
00086             }
00087       else
00088             {
00089                 role=0;
00090             }
00091       RoleSelection(role);
00092 }
00093 
00094 void TGo4StartClient::destroy()
00095 {
00096    // TGo4LockGuard glob;
00097    TGo4QSettings settings;
00098    settings.writeEntry( TGo4QSettings::GetSettingsName()+"/ClientSetting/Name", fxTGo4StartClientStatus->GetSlaveName());
00099    settings.writeEntry( TGo4QSettings::GetSettingsName()+"/ClientSetting/Node", fxTGo4StartClientStatus->GetSlaveNode());
00100    settings.writeEntry( TGo4QSettings::GetSettingsName()+"/ClientSetting/Dir", fxTGo4StartClientStatus->GetSlaveDir());
00101    settings.writeEntry( TGo4QSettings::GetSettingsName()+"/ClientSetting/Exec", fxTGo4StartClientStatus->GetSlaveExec());
00103    QString remotemode;
00104    switch(fxTGo4StartClientStatus->GetSlaveMode())
00105        {
00106          case 1:
00107             remotemode="rsh";
00108             break;
00109          case 2:
00110             remotemode="ssh";
00111             break;       
00112          default:
00113             remotemode="ssh";
00114             break;         
00115        };
00116    settings.writeEntry( TGo4QSettings::GetSettingsName()+"/ClientSetting/Shell", remotemode);
00118    QString termmode;
00119    switch(fxTGo4StartClientStatus->GetSlaveShell())
00120        {
00121          case 1:
00122             termmode="qt";
00123             break;
00124          case 2:
00125             termmode="xterm";
00126             break;       
00127          default:
00128             termmode="qt";
00129             break;         
00130        };
00131    settings.writeEntry( TGo4QSettings::GetSettingsName()+"/ClientSetting/Term", termmode);
00132    fxTGo4StartClientSlots->SetGUI(0);
00133 }
00134 
00135 void TGo4StartClient::GetClientHost( const QString &Node )
00136 {
00137 // TGo4LockGuard glob;
00138     QString result=Node.simplifyWhiteSpace().section(' ',0,0); // strip everything after first blank
00139     if(result.isEmpty()) result="localhost";
00140     fxTGo4StartClientStatus->SetSlaveNode(result.data());
00141 }
00142 
00143 void TGo4StartClient::GetClientName( const QString &Name )
00144 {
00145 // TGo4LockGuard glob;
00146     QString result=Name.simplifyWhiteSpace().section(' ',0,0); // strip everything after first blank
00147     if(result.isEmpty()) result="a"; // might crash analysis program if no name given
00148     fxTGo4StartClientStatus->SetSlaveName(result.data());
00149 }
00150 
00151 
00152 
00153 void TGo4StartClient::GetClientDir( const QString &Dir )
00154 {
00155     // TGo4LockGuard glob;
00156     QString result=Dir.simplifyWhiteSpace().section(' ',0,0); // strip everything after first blank
00157     if(result.isEmpty()) result="."; 
00158     fxTGo4StartClientStatus->SetSlaveDir(result.data());
00159 }
00160 
00161 void TGo4StartClient::GetClientExc( const QString &Exc )
00162 {
00163     // TGo4LockGuard glob;
00164     QString result=Exc.simplifyWhiteSpace().section(' ',0,0); // strip everything after first blank
00165     if(result.isEmpty()) result="MainUserAnalysis"; 
00166     fxTGo4StartClientStatus->SetSlaveExec(result.data());
00167 }
00168 
00169 void TGo4StartClient::GetServerPort( int num )
00170 {
00171     fxTGo4StartClientStatus->SetServerPort(num);
00172 }
00173 
00174 void TGo4StartClient::SelectDir()
00175 {
00176     QFileDialog* fd = new QFileDialog( this, "file name", kTRUE );
00177     fd->setMode( QFileDialog::DirectoryOnly);
00178     fd->setName( "Select your working dir");
00179 
00180     if ( fd->exec() == QDialog::Accepted )  {
00181        QString fileName = fd->selectedFile();
00182        LineEditClientDir->setText(fileName);
00183        QDir::setCurrent(fileName);
00184     }
00185     delete fd;
00186 
00187 }
00188 
00189 void TGo4StartClient::SelectProg()
00190 {
00191     QFileDialog* fd = new QFileDialog( this, "file name", kTRUE );
00192     fd->setMode( QFileDialog::ExistingFile);
00193     fd->setName( "Select your analysis program");
00194     if ( fd->exec() == QDialog::Accepted )  {
00195        QString fileName = fd->selectedFile();
00196        QFileInfo fi(fileName);
00197        LineEditClientExec->setText(fi.fileName());
00198     }
00199     delete fd;
00200 }
00201 
00202 
00203 void TGo4StartClient::AnalysisMode( int t )
00204 {
00205 
00206     switch(t){
00207     case 1:
00208        fxTGo4StartClientStatus->SetSlaveMode(1); // use rsh
00209       break;
00210     case 2:
00211        fxTGo4StartClientStatus->SetSlaveMode(2); // use ssh
00212       break;
00213     }
00214 
00215 }
00216 
00217 void TGo4StartClient::AnalysisShell( int t )
00218 {
00219   switch(t){
00220     case 1:
00221        fxTGo4StartClientStatus->SetSlaveShell(1); // use Qt
00222       break;
00223     case 2:
00224        fxTGo4StartClientStatus->SetSlaveShell(2); // use Xterm
00225       break;
00226 
00227     }
00228 }
00229 
00230 void TGo4StartClient::StartAnalysisClient()
00231 {
00232    // TGo4LockGuard glob;
00233     
00234     fxTGo4StartClientSlots->StartClient(fxTGo4StartClientStatus->GetSlaveName(), 
00235                                         fxTGo4StartClientStatus->GetSlaveNode(),
00236                                         fxTGo4StartClientStatus->GetSlaveDir(),
00237                                         fxTGo4StartClientStatus->GetSlaveExec(),
00238                                         fxTGo4StartClientStatus->GetServerPort(),
00239                                         fxTGo4StartClientStatus->IsStartServer());
00240    TGo4GUIRegistry* reg=TGo4GUIRegistry::Instance();
00241    TGo4Display* disp=reg->GetDisplay();
00242    if(disp->IsServer())
00243     {
00244         QApplication::setOverrideCursor( Qt::WaitCursor );
00245         // waitclock only if we are server that expects analysis to send
00246         // back the settings after initialization.
00247         close();
00248     }
00249    else
00250     {
00251         if(fxTGo4StartClientStatus->IsStartServer())
00252             {
00253                // we just started the server, need to connect us manually now: 
00254                // do not close, but change mode:
00255                StartServerBox->setChecked(false);
00256                ChangeServerStartMode(false);
00257                setCaption("Please connect with correct port number after server is ready:"); 
00258             }
00259         else
00260             {
00261                 
00262                 TGo4MainWindow* mw= (TGo4MainWindow*) reg->GetMainWindow();
00263                 mw->AnalysisStatusSlot(); 
00264                 close();
00265                 // display ratemeter to immedeately see running mode when connected
00266             }
00267     }
00268    
00269 }
00270 
00271 
00272 void TGo4StartClient::closeEvent( QCloseEvent * ce )
00273 {
00274 // TGo4LockGuard glob;
00275     ce->accept();
00276     delete this;
00277 }
00278 
00279 
00280 
00281 void TGo4StartClient::SetServerMode( bool on )
00282 {
00283     Servermodeframe->setShown(!on);    
00284     StartAnalysisframe->setEnabled(on);   
00285     if(!on)
00286         { 
00287             ShowServerStartMode(fxTGo4StartClientStatus->IsStartServer());
00288         }
00289     else
00290         {
00291             polish();
00292             update();
00293             show();
00294         }
00295 }
00296 
00297 
00298 void TGo4StartClient::ChangeServerStartMode( bool on )
00299 {
00300     fxTGo4StartClientStatus->SetStartServer(on);    
00301     ShowServerStartMode(on);
00302 }
00303 
00304 
00305 
00306 
00307 void TGo4StartClient::ShowServerStartMode( bool on )
00308 {
00309     StartAnalysisframe->setEnabled(on);
00310     PortBox->setEnabled(!on);
00311     LoginCombo->setEnabled(!on);
00312     LineEditPasswd->setEnabled(!on);
00313     AnalysisShellMode->setEnabled(!on);
00314     if (on) PushButtonStartClient->setText("Start");
00315        else PushButtonStartClient->setText("Connect");
00316     if(on)
00317         {
00318             AnalysisShellMode->setButton(2);
00319             AnalysisShell(2);
00320         }
00321     polish();
00322     update();
00323     show(); 
00324 }    
00325 
00326 
00327 void TGo4StartClient::GetPassword( const QString & pass )
00328 {
00329 QString result=pass.simplifyWhiteSpace().section(' ',0,0); // strip everything after first blank
00330 if(result.isEmpty()) result="x"; 
00331 fxTGo4StartClientStatus->SetPasswd(result.data());
00332 TGo4GUIRegistry::Instance()->SetClientPassword(result.data());
00333 }
00334 
00335 
00336 void TGo4StartClient::RoleSelection( int num )
00337 {
00338 fxTGo4StartClientStatus->SetLoginMode(num+1);
00339 TGo4GUIRegistry::Instance()->SetClientRole(num);
00340 }
00341 
00342 
00343 
00344 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:03 2005 for Go4-v2.10-5 by doxygen1.2.15