MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / executeTask

Method executeTask

launcher/launch/steps/CheckJava.cpp:45–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43#include "java/JavaUtils.h"
44
45void CheckJava::executeTask()
46{
47 auto instance = m_parent->instance();
48 auto settings = instance->settings();
49
50 QString javaPathSetting = settings->get("JavaPath").toString();
51 m_javaPath = FS::ResolveExecutable(javaPathSetting);
52
53 bool perInstance = settings->get("OverrideJava").toBool() || settings->get("OverrideJavaLocation").toBool();
54
55 auto realJavaPath = QStandardPaths::findExecutable(m_javaPath);
56 if (realJavaPath.isEmpty()) {
57 if (perInstance) {
58 emit logLine(QString("The Java binary \"%1\" couldn't be found. Please fix the Java path "
59 "override in the instance's settings or disable it.")
60 .arg(javaPathSetting),
61 MessageLevel::Warning);
62 } else {
63 emit logLine(QString("The Java binary \"%1\" couldn't be found. Please set up Java in "
64 "the settings.")
65 .arg(javaPathSetting),
66 MessageLevel::Warning);
67 }
68 emitFailed(QString("Java path is not valid."));
69 return;
70 } else {
71 emit logLine("Java path is:\n" + m_javaPath + "\n\n", MessageLevel::Launcher);
72 }
73
74 if (JavaUtils::getJavaCheckPath().isEmpty()) {
75 const char* reason = QT_TR_NOOP("Java checker library could not be found. Please check your installation.");
76 emit logLine(tr(reason), MessageLevel::Fatal);
77 emitFailed(tr(reason));
78 return;
79 }
80
81 QFileInfo javaInfo(realJavaPath);
82 qint64 javaUnixTime = javaInfo.lastModified().toMSecsSinceEpoch();
83 auto storedSignature = settings->get("JavaSignature").toString();
84 auto storedArchitecture = settings->get("JavaArchitecture").toString();
85 auto storedRealArchitecture = settings->get("JavaRealArchitecture").toString();
86 auto storedVersion = settings->get("JavaVersion").toString();
87 auto storedVendor = settings->get("JavaVendor").toString();
88
89 QCryptographicHash hash(QCryptographicHash::Sha1);
90 hash.addData(QByteArray::number(javaUnixTime));
91 hash.addData(m_javaPath.toUtf8());
92 m_javaSignature = hash.result().toHex();
93
94 // if timestamps are not the same, or something is missing, check!
95 if (m_javaSignature != storedSignature || storedVersion.size() == 0 || storedArchitecture.size() == 0 ||
96 storedRealArchitecture.size() == 0 || storedVendor.size() == 0) {
97 m_JavaChecker.reset(new JavaChecker(realJavaPath, "", 0, 0, 0, 0));
98 emit logLine(QString("Checking Java version..."), MessageLevel::Launcher);
99 connect(m_JavaChecker.get(), &JavaChecker::checkFinished, this, &CheckJava::checkJavaFinished);
100 m_JavaChecker->start();
101 return;
102 } else {

Callers

nothing calls this directly

Calls 12

ResolveExecutableFunction · 0.85
QStringClass · 0.85
instanceMethod · 0.45
settingsMethod · 0.45
toStringMethod · 0.45
getMethod · 0.45
isEmptyMethod · 0.45
resultMethod · 0.45
sizeMethod · 0.45
resetMethod · 0.45
startMethod · 0.45
updateRuntimeContextMethod · 0.45

Tested by

no test coverage detected