Revision 8429 trunk/install/launcher/izpack-launcher-1.3/src/launcher.cpp
launcher.cpp | ||
---|---|---|
92 | 92 |
LauncherApp::LauncherApp() |
93 | 93 |
: wxApp() |
94 | 94 |
{ |
95 |
APPLICATION_NAME = wxString(_("gvSIG Install-Launcher"));
|
|
95 |
APPLICATION_NAME = wxString(_("Launcher")); |
|
96 | 96 |
completed = false; |
97 | 97 |
|
98 |
SetAppName(_( APPLICATION_NAME ));
|
|
98 |
SetAppName(_(APPLICATION_NAME));
|
|
99 | 99 |
//loadParams(); |
100 | 100 |
} |
101 | 101 |
|
... | ... | |
135 | 135 |
wxString askForCheckingProcess; |
136 | 136 |
wxString doChecks; |
137 | 137 |
|
138 |
paramsApplicationName = readPathFromINI( "appname","gvSIG"); |
|
138 | 139 |
paramsJar = readPathFromINI( "jar",wxEmptyString); |
139 | 140 |
paramsCommand = readPathFromINI( "command",wxEmptyString); |
140 | 141 |
paramsJre = readPathFromINI( "jre", wxEmptyString); |
... | ... | |
150 | 151 |
askForCheckingProcess = readFromINI( "askForCheckingProcess", wxEmptyString); |
151 | 152 |
doChecks = readFromINI( "doChecks",wxEmptyString); |
152 | 153 |
paramsJreHome = readPathFromINI( "jre_home", wxEmptyString); |
154 |
paramsLaunchMode = readPathFromINI( "launchMode", wxEmptyString); |
|
153 | 155 |
|
154 | 156 |
|
155 | 157 |
//echo(paramsCommand); |
... | ... | |
167 | 169 |
{ |
168 | 170 |
error(cfgName.Format(_("The configuration file '%s' does not contain a command entry."),cfgName.c_str())); |
169 | 171 |
} |
172 |
if (paramsLaunchMode == wxEmptyString ) |
|
173 |
{ |
|
174 |
error(cfgName.Format(_("The configuration file '%s' does not contain a mode entry."),cfgName.c_str())); |
|
175 |
} |
|
176 |
paramsLaunchMode = paramsLaunchMode.MakeUpper(); |
|
177 |
if ((!paramsLaunchMode.IsSameAs("APPLICATION")) && (!paramsLaunchMode.IsSameAs("INSTALL"))) { |
|
178 |
error(cfgName.Format(_("The configuration file '%s' contains a invalid mode entry."),cfgName.c_str())); |
|
179 |
} |
|
180 |
|
|
170 | 181 |
if (paramsJreVersionPrefered == wxEmptyString ) { |
171 | 182 |
paramsJreVersionPrefered = wxString(paramsJreVersion); |
172 | 183 |
} |
... | ... | |
218 | 229 |
|
219 | 230 |
} |
220 | 231 |
|
232 |
void LauncherApp::showStatusWindow(){ |
|
233 |
if (isStatusDialogVisible) { |
|
234 |
return; |
|
235 |
} |
|
236 |
|
|
237 |
statusDialog = new StatusDialog( APPLICATION_NAME ); |
|
221 | 238 |
|
239 |
statusDialog->Centre(); |
|
240 |
statusDialog->Show(TRUE); |
|
241 |
isStatusDialogVisible = true; |
|
242 |
} |
|
222 | 243 |
|
244 |
|
|
223 | 245 |
bool LauncherApp::OnInit() |
224 | 246 |
{ |
225 | 247 |
isStatusDialogVisible = false; |
... | ... | |
232 | 254 |
locale.AddCatalog("launcher"); |
233 | 255 |
loadParams(); |
234 | 256 |
|
235 |
if (paramsDoChecks) { |
|
236 |
|
|
237 |
statusDialog = new StatusDialog( APPLICATION_NAME ); |
|
238 |
|
|
239 |
statusDialog->Centre(); |
|
240 |
statusDialog->Show(TRUE); |
|
241 |
isStatusDialogVisible = true; |
|
257 |
|
|
258 |
if (paramsLaunchMode.IsSameAs("INSTALL")){ |
|
259 |
APPLICATION_NAME = wxString(APPLICATION_NAME.Format(_("%s Install-Launcher"),paramsApplicationName.c_str())); |
|
260 |
SetAppName(_(APPLICATION_NAME)); |
|
261 |
showStatusWindow(); |
|
262 |
} else { |
|
263 |
APPLICATION_NAME = wxString(APPLICATION_NAME.Format(_("%s Launcher"),paramsApplicationName.c_str())); |
|
264 |
SetAppName(_(APPLICATION_NAME)); |
|
242 | 265 |
} |
243 |
|
|
266 |
|
|
244 | 267 |
showStatusMsg(_("Intializing...")); |
245 | 268 |
|
246 | 269 |
myTimer = new wxTimer(this,LAUNCHAPP_TIMER_ID); |
247 | 270 |
myTimer->Start(150,true); |
248 | 271 |
this->MainLoop(); |
249 | 272 |
return true; |
250 |
/* |
|
251 |
|
|
252 |
if (!searchJRE()) |
|
253 |
{ |
|
254 |
jreInstall(); |
|
255 |
} |
|
256 |
|
|
257 |
fixSystemJREConfig(); |
|
258 |
|
|
259 |
jaiInstall(); |
|
260 |
|
|
261 |
jaiIoInstall(); |
|
262 |
|
|
263 |
runJRE(); |
|
264 |
|
|
265 |
exit(0); |
|
266 |
|
|
267 |
return false; |
|
268 |
*/ |
|
269 | 273 |
} |
270 | 274 |
|
271 | 275 |
void LauncherApp::fixSystemJREConfig(){ |
... | ... | |
283 | 287 |
if( !pRegKey->Exists() ) { |
284 | 288 |
error(_("JRE not found.")); |
285 | 289 |
} |
286 |
//pRegKey->SetValue("CurrentVersion",genericVersion); // ********** |
|
287 | 290 |
|
288 | 291 |
// compiamos el contenido de la rama de la version |
289 | 292 |
// que queremos a la generica (1.4 o 1.5 o ...) |
... | ... | |
296 | 299 |
wxString tempKey; |
297 | 300 |
wxString tempValue; |
298 | 301 |
size_t nValues; |
299 |
|
|
300 |
//pRegKeyGeneric->SetValue("hola","generico"); |
|
301 |
//pRegKeyVersion->SetValue("hola","version"); |
|
302 | 302 |
|
303 | 303 |
pRegKeyVersion->GetKeyInfo(NULL,NULL,&nValues,NULL); |
304 | 304 |
long pos = 1; |
... | ... | |
311 | 311 |
} |
312 | 312 |
|
313 | 313 |
|
314 |
//copiamos el java.exe a Windows/System32 |
|
315 |
//wxString source = javaHome + "\\bin\\java.exe"; |
|
316 |
//wxString target = getenv("windir"); |
|
317 |
//target = target + "\\system32\\java.exe"; |
|
318 |
|
|
319 |
//bool isOk = wxCopyFile(source, target, true); |
|
320 |
//if (!isOk) { |
|
321 |
// error(_("Error perform copy ") + source + _(" to ") + target); |
|
322 |
//} |
|
323 |
|
|
324 | 314 |
} |
325 | 315 |
|
326 | 316 |
|
... | ... | |
415 | 405 |
|
416 | 406 |
void LauncherApp::runJRE() |
417 | 407 |
{ |
418 |
showStatusMsg(_("Launching installation...")); |
|
419 |
/* |
|
420 |
if (!wxFile::Exists(paramsJar)) |
|
421 |
{ |
|
422 |
error(_("Could not find '") + paramsJar + _("' file referenced by the configuration file '") + cfgName + _("'")); |
|
408 |
if (paramsLaunchMode.IsSameAs("INSTALL")) { |
|
409 |
showStatusMsg(_("Launching installation...")); |
|
410 |
} else { |
|
411 |
showStatusMsg(_("Launching application...")); |
|
423 | 412 |
} |
424 |
*/ |
|
425 |
|
|
426 |
//wxString cmd = javaExecPath + paramsJarParams + wxString(" -jar ") + paramsJar; |
|
427 | 413 |
wxString cmd = parseCommand(); |
428 | 414 |
//echo(cmd); |
429 | 415 |
if (paramsLaunchJarAsync) { |
... | ... | |
443 | 429 |
|
444 | 430 |
void LauncherApp::jreInstall() |
445 | 431 |
{ |
432 |
showStatusWindow(); |
|
433 |
|
|
446 | 434 |
showStatusMsg(_("Preparing to install JRE...")); |
447 | 435 |
|
448 | 436 |
if (!checkInstallerFile(paramsJre, paramsJreDownload,_("Java JRE version ")+paramsJreVersion)) |
... | ... | |
471 | 459 |
browser = "rundll32 url.dll,FileProtocolHandler "; |
472 | 460 |
#endif |
473 | 461 |
|
474 |
#ifdef __UNIX__ |
|
475 |
// We try some browsers and use the first successful one. |
|
476 |
std::list<std::pair<wxString, wxString> > commands; |
|
477 |
std::pair<wxString, wxString> cmd; |
|
478 |
cmd.first = "konqueror "; cmd.second = "konqueror -v"; |
|
479 |
commands.push_back(cmd); |
|
480 |
cmd.first = "mozilla -splash "; cmd.second = "mozilla -v"; |
|
481 |
commands.push_back(cmd); |
|
482 |
cmd.first = "firefox -splash "; cmd.second = "firefox -v"; |
|
483 |
commands.push_back(cmd); |
|
484 |
cmd.first = "firebird -splash "; cmd.second = "firebird -v"; |
|
485 |
commands.push_back(cmd); |
|
486 |
cmd.first = "opera "; cmd.second = "opera -v"; |
|
487 |
commands.push_back(cmd); |
|
488 |
cmd.first = "netscape "; cmd.second = "netscape -v"; |
|
489 |
commands.push_back(cmd); |
|
490 |
std::list<std::pair<wxString, wxString> >::iterator it; |
|
491 |
for (it = commands.begin(); it != commands.end(); ++it) |
|
492 |
{ |
|
493 |
if (wxExecute(it->second, wxEXEC_SYNC) == 0) |
|
494 |
{ |
|
495 |
browser = it->first; |
|
496 |
break; |
|
497 |
} |
|
498 |
} |
|
499 |
#endif |
|
500 |
/* |
|
462 |
/* |
|
501 | 463 |
if (run_external(browser + paramsDownload)) |
502 | 464 |
{ |
503 | 465 |
completed = true; |
... | ... | |
529 | 491 |
isOK=true; |
530 | 492 |
if (!checksJai()) { |
531 | 493 |
//confirm(_("JAI library is required, Install it?")); |
494 |
showStatusWindow(); |
|
532 | 495 |
|
533 | 496 |
showStatusMsg(_("Preparing to install JAI Library...")); |
534 | 497 |
if (!checkInstallerFile(paramsJai, paramsJaiDownload, _("JAI Library"))) |
... | ... | |
570 | 533 |
isOK=true; |
571 | 534 |
if (!checksJaiIo()) { |
572 | 535 |
//confirm(_("JAI ImageIO library is required, Install it?")); |
536 |
showStatusWindow(); |
|
573 | 537 |
|
574 | 538 |
showStatusMsg(_("Preparing to install JAI imageIO Library...")); |
575 | 539 |
if (!checkInstallerFile(paramsJaiIo, paramsJaiIoDownload,"JAI ImageIO Library")) |
... | ... | |
764 | 728 |
|
765 | 729 |
void LauncherApp::run(){ |
766 | 730 |
bool doChecks =true; |
767 |
|
|
768 |
if (paramsDoChecks) { |
|
769 |
if (doChecks && paramsAskForCheckingProcess) { |
|
731 |
|
|
732 |
if (!paramsDoChecks) { |
|
733 |
javaHome = paramsJreHome; |
|
734 |
calculateJavaExePath(javaHome); |
|
735 |
} else { |
|
736 |
if (paramsAskForCheckingProcess) { |
|
770 | 737 |
wxString msg = _("Do you want to check the application requirements? \nThis will install missing components."); |
771 | 738 |
doChecks = confirmYesNoCancel(msg,true); |
739 |
if (!doChecks) { |
|
740 |
// No quiere comprobacion, por lo que solicitamos |
|
741 |
wxString msgDir = _("Please, select the Java VM."); |
|
742 |
wxFileDialog dlg( |
|
743 |
0, |
|
744 |
msgDir, |
|
745 |
wxEmptyString, |
|
746 |
wxString("java.exe"), |
|
747 |
wxString("Java VM executable file (java.exe)|java.exe"), |
|
748 |
wxOPEN | wxFILE_MUST_EXIST, |
|
749 |
wxDefaultPosition |
|
750 |
); |
|
751 |
int response = dlg.ShowModal(); |
|
752 |
if (response != wxID_OK) { |
|
753 |
notifyToUser(_("Canceled by user")); |
|
754 |
exit(1); |
|
755 |
} |
|
756 |
//caragamos la variable con el eljecutable |
|
757 |
javaExecPath = dlg.GetPath(); |
|
758 |
|
|
759 |
checkVersion(javaExecPath); |
|
760 |
|
|
761 |
//generamos el path para el JavaHome (por si acaso) |
|
762 |
wxFileName fileName(javaExecPath); |
|
763 |
fileName.SetFullName(""); |
|
764 |
fileName.AppendDir(".."); |
|
765 |
fileName.Normalize(); |
|
766 |
javaHome = fileName.GetPath(); |
|
767 |
|
|
768 |
} |
|
772 | 769 |
} |
773 | 770 |
|
774 | 771 |
|
... | ... | |
784 | 781 |
jaiInstall(); |
785 | 782 |
|
786 | 783 |
jaiIoInstall(); |
787 |
} else { |
|
788 |
// No quiere comprobacion, por lo que solicitamos |
|
789 |
wxString msgDir = _("Please, select the Java VM."); |
|
790 |
wxFileDialog dlg( |
|
791 |
0, |
|
792 |
msgDir, |
|
793 |
wxEmptyString, |
|
794 |
wxString("java.exe"), |
|
795 |
wxString("Java VM executable file (java.exe)|java.exe"), |
|
796 |
wxOPEN | wxFILE_MUST_EXIST, |
|
797 |
wxDefaultPosition |
|
798 |
); |
|
799 |
int response = dlg.ShowModal(); |
|
800 |
if (response != wxID_OK) { |
|
801 |
notifyToUser(_("Canceled by user")); |
|
802 |
exit(1); |
|
803 |
} |
|
804 |
//caragamos la variable con el eljecutable |
|
805 |
javaExecPath = dlg.GetPath(); |
|
806 |
|
|
807 |
checkVersion(javaExecPath); |
|
808 |
|
|
809 |
//generamos el path para el JavaHome (por si acaso) |
|
810 |
wxFileName fileName(javaExecPath); |
|
811 |
fileName.SetFullName(""); |
|
812 |
fileName.AppendDir(".."); |
|
813 |
fileName.Normalize(); |
|
814 |
javaHome = fileName.GetPath(); |
|
815 | 784 |
} |
816 |
} else { |
|
817 |
javaHome = paramsJreHome; |
|
818 |
calculateJavaExePath(javaHome); |
|
819 | 785 |
} |
820 | 786 |
|
821 | 787 |
copyRequiredFiles(); |
Also available in: Unified diff