2013-11-24 05:36:16 +00:00
|
|
|
#pragma once
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <memory>
|
|
|
|
|
2019-04-07 21:59:04 +00:00
|
|
|
#include "QObjectPtr.h"
|
|
|
|
|
2016-01-01 23:35:54 +00:00
|
|
|
#include "JavaVersion.h"
|
2013-12-11 03:54:39 +00:00
|
|
|
|
2016-01-01 23:35:54 +00:00
|
|
|
class JavaChecker;
|
2013-12-12 23:02:58 +00:00
|
|
|
|
2021-07-25 17:11:59 +00:00
|
|
|
struct JavaCheckResult
|
2013-11-24 05:36:16 +00:00
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
QString path;
|
|
|
|
QString mojangPlatform;
|
|
|
|
QString realPlatform;
|
|
|
|
JavaVersion javaVersion;
|
2020-09-07 20:28:41 +00:00
|
|
|
QString javaVendor;
|
2018-07-15 12:51:05 +00:00
|
|
|
QString outLog;
|
|
|
|
QString errorLog;
|
|
|
|
bool is_64bit = false;
|
|
|
|
int id;
|
|
|
|
enum class Validity
|
|
|
|
{
|
|
|
|
Errored,
|
|
|
|
ReturnedInvalidData,
|
|
|
|
Valid
|
|
|
|
} validity = Validity::Errored;
|
2013-11-24 05:36:16 +00:00
|
|
|
};
|
|
|
|
|
2019-04-07 21:59:04 +00:00
|
|
|
typedef shared_qobject_ptr<QProcess> QProcessPtr;
|
|
|
|
typedef shared_qobject_ptr<JavaChecker> JavaCheckerPtr;
|
2021-07-25 17:11:59 +00:00
|
|
|
class JavaChecker : public QObject
|
2013-11-24 05:36:16 +00:00
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
Q_OBJECT
|
2013-11-24 05:36:16 +00:00
|
|
|
public:
|
2018-07-15 12:51:05 +00:00
|
|
|
explicit JavaChecker(QObject *parent = 0);
|
|
|
|
void performCheck();
|
2013-12-11 03:54:39 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
QString m_path;
|
|
|
|
QString m_args;
|
|
|
|
int m_id = 0;
|
|
|
|
int m_minMem = 0;
|
|
|
|
int m_maxMem = 0;
|
|
|
|
int m_permGen = 64;
|
2013-11-24 05:36:16 +00:00
|
|
|
|
|
|
|
signals:
|
2018-07-15 12:51:05 +00:00
|
|
|
void checkFinished(JavaCheckResult result);
|
2013-11-24 05:36:16 +00:00
|
|
|
private:
|
2018-07-15 12:51:05 +00:00
|
|
|
QProcessPtr process;
|
|
|
|
QTimer killTimer;
|
|
|
|
QString m_stdout;
|
|
|
|
QString m_stderr;
|
2013-11-24 05:36:16 +00:00
|
|
|
public
|
|
|
|
slots:
|
2018-07-15 12:51:05 +00:00
|
|
|
void timeout();
|
|
|
|
void finished(int exitcode, QProcess::ExitStatus);
|
|
|
|
void error(QProcess::ProcessError);
|
|
|
|
void stdoutReady();
|
|
|
|
void stderrReady();
|
2013-11-24 05:36:16 +00:00
|
|
|
};
|