1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#ifndef MODORGANIZER_LOOT_H
#define MODORGANIZER_LOOT_H
#include "envmodule.h"
#include <log.h>
#include <lootcli/lootcli.h>
#include <windows.h>
#include <QWidget>
Q_DECLARE_METATYPE(lootcli::Progress);
Q_DECLARE_METATYPE(MOBase::log::Levels);
class OrganizerCore;
class Loot : public QObject
{
Q_OBJECT;
public:
Loot();
~Loot();
bool start(QWidget* parent, OrganizerCore& core, bool didUpdateMasterList);
void cancel();
bool result() const;
signals:
void output(const QString& s);
void progress(const lootcli::Progress p);
void log(MOBase::log::Levels level, const QString& s);
void information(const QString& mod, const QString& info);
void finished();
private:
std::unique_ptr<QThread> m_thread;
std::atomic<bool> m_cancel;
std::atomic<bool> m_result;
QString m_outPath;
env::HandlePtr m_lootProcess;
env::HandlePtr m_stdout;
std::string m_outputBuffer;
std::string readFromPipe();
void lootThread();
bool waitForCompletion();
void processStdout(const std::string &lootOut);
void processMessage(const lootcli::Message& m);
void processOutputFile();
bool processOutputPlugin(const QJsonValue& pluginValue);
bool processPluginMessages(
const QString& pluginName, const QJsonObject& plugin);
bool processPluginMessage(
const QString& pluginName, const QJsonObject& message);
bool processPluginDirty(
const QString& pluginName, const QJsonObject& plugin);
template <class Format, class... Args>
void logJsonError(Format&& f, Args&&... args)
{
MOBase::log::error(
std::string("loot output file '{}': ") + f,
m_outPath, std::forward<Args>(args)...);
};
};
bool runLoot(QWidget* parent, OrganizerCore& core, bool didUpdateMasterList);
#endif // MODORGANIZER_LOOT_H
|