00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 void TGo4StartClient::init()
00018 {
00019
00020 QApplication::restoreOverrideCursor();
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
00052
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
00061 fxTGo4StartClientStatus->SetSlaveNode(ClientNode);
00062
00063 fxTGo4StartClientStatus->SetSlaveName(ClientName);
00064
00065 fxTGo4StartClientStatus->SetSlaveDir(ClientDir);
00066
00067 fxTGo4StartClientStatus->SetSlaveExec(ClientExec);
00068
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)
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
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
00138 QString result=Node.simplifyWhiteSpace().section(' ',0,0);
00139 if(result.isEmpty()) result="localhost";
00140 fxTGo4StartClientStatus->SetSlaveNode(result.data());
00141 }
00142
00143 void TGo4StartClient::GetClientName( const QString &Name )
00144 {
00145
00146 QString result=Name.simplifyWhiteSpace().section(' ',0,0);
00147 if(result.isEmpty()) result="a";
00148 fxTGo4StartClientStatus->SetSlaveName(result.data());
00149 }
00150
00151
00152
00153 void TGo4StartClient::GetClientDir( const QString &Dir )
00154 {
00155
00156 QString result=Dir.simplifyWhiteSpace().section(' ',0,0);
00157 if(result.isEmpty()) result=".";
00158 fxTGo4StartClientStatus->SetSlaveDir(result.data());
00159 }
00160
00161 void TGo4StartClient::GetClientExc( const QString &Exc )
00162 {
00163
00164 QString result=Exc.simplifyWhiteSpace().section(' ',0,0);
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);
00209 break;
00210 case 2:
00211 fxTGo4StartClientStatus->SetSlaveMode(2);
00212 break;
00213 }
00214
00215 }
00216
00217 void TGo4StartClient::AnalysisShell( int t )
00218 {
00219 switch(t){
00220 case 1:
00221 fxTGo4StartClientStatus->SetSlaveShell(1);
00222 break;
00223 case 2:
00224 fxTGo4StartClientStatus->SetSlaveShell(2);
00225 break;
00226
00227 }
00228 }
00229
00230 void TGo4StartClient::StartAnalysisClient()
00231 {
00232
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
00246
00247 close();
00248 }
00249 else
00250 {
00251 if(fxTGo4StartClientStatus->IsStartServer())
00252 {
00253
00254
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
00266 }
00267 }
00268
00269 }
00270
00271
00272 void TGo4StartClient::closeEvent( QCloseEvent * ce )
00273 {
00274
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);
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