2013-11-24 06:36:16 +01:00
|
|
|
#pragma once
|
2026-01-09 00:32:00 +02:00
|
|
|
#include <memory>
|
|
|
|
|
|
2013-11-24 06:36:16 +01:00
|
|
|
#include <QProcess>
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
2016-01-02 00:35:54 +01:00
|
|
|
#include "JavaVersion.h"
|
2024-01-24 18:26:43 +02:00
|
|
|
#include "QObjectPtr.h"
|
|
|
|
|
#include "tasks/Task.h"
|
2013-12-11 03:54:39 +00:00
|
|
|
|
2024-01-24 18:26:43 +02:00
|
|
|
class JavaChecker : public Task {
|
2013-11-24 06:36:16 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2024-01-24 18:26:43 +02:00
|
|
|
using Ptr = shared_qobject_ptr<JavaChecker>;
|
|
|
|
|
|
|
|
|
|
struct Result {
|
|
|
|
|
QString path;
|
|
|
|
|
int id;
|
|
|
|
|
QString mojangPlatform;
|
|
|
|
|
QString realPlatform;
|
|
|
|
|
JavaVersion javaVersion;
|
|
|
|
|
QString javaVendor;
|
|
|
|
|
QString outLog;
|
|
|
|
|
QString errorLog;
|
|
|
|
|
bool is_64bit = false;
|
|
|
|
|
enum class Validity { Errored, ReturnedInvalidData, Valid } validity = Validity::Errored;
|
|
|
|
|
};
|
|
|
|
|
|
2024-10-28 19:13:14 +02:00
|
|
|
explicit JavaChecker(QString path, QString args, int minMem = 0, int maxMem = 0, int permGen = 0, int id = 0);
|
2026-01-09 00:32:00 +02:00
|
|
|
~JavaChecker() override = default;
|
2013-11-24 06:36:16 +01:00
|
|
|
|
|
|
|
|
signals:
|
2024-01-30 12:37:34 +02:00
|
|
|
void checkFinished(const Result& result);
|
2024-01-24 18:26:43 +02:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void executeTask() override;
|
2023-08-02 18:35:35 +02:00
|
|
|
|
2013-11-24 06:36:16 +01:00
|
|
|
private:
|
2026-01-09 00:32:00 +02:00
|
|
|
std::unique_ptr<QProcess> m_process;
|
|
|
|
|
QTimer m_killTimer;
|
2015-05-04 01:20:48 +02:00
|
|
|
QString m_stdout;
|
|
|
|
|
QString m_stderr;
|
2024-01-24 18:26:43 +02:00
|
|
|
|
|
|
|
|
QString m_path;
|
|
|
|
|
QString m_args;
|
|
|
|
|
int m_minMem = 0;
|
|
|
|
|
int m_maxMem = 0;
|
|
|
|
|
int m_permGen = 64;
|
|
|
|
|
int m_id = 0;
|
|
|
|
|
|
|
|
|
|
private slots:
|
2013-11-24 06:36:16 +01:00
|
|
|
void timeout();
|
|
|
|
|
void finished(int exitcode, QProcess::ExitStatus);
|
|
|
|
|
void error(QProcess::ProcessError);
|
2015-05-04 01:20:48 +02:00
|
|
|
void stdoutReady();
|
|
|
|
|
void stderrReady();
|
2013-11-24 06:36:16 +01:00
|
|
|
};
|