2017-11-10 13:36:29 +00:00
|
|
|
#ifndef LOGMANAGER_H
|
|
|
|
#define LOGMANAGER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
2017-11-17 03:46:35 +00:00
|
|
|
class AppBlockedModel;
|
2017-12-01 14:13:06 +00:00
|
|
|
class DatabaseManager;
|
2017-11-10 13:36:29 +00:00
|
|
|
class DriverWorker;
|
|
|
|
class LogBuffer;
|
2017-11-17 03:46:35 +00:00
|
|
|
class LogEntry;
|
2017-11-10 13:36:29 +00:00
|
|
|
|
|
|
|
class LogManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2017-11-17 11:44:33 +00:00
|
|
|
Q_PROPERTY(AppBlockedModel *appBlockedModel READ appBlockedModel CONSTANT)
|
2017-11-10 13:36:29 +00:00
|
|
|
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
|
|
|
|
|
|
|
|
public:
|
2017-12-01 14:13:06 +00:00
|
|
|
explicit LogManager(DatabaseManager *databaseManager,
|
|
|
|
DriverWorker *driverWorker,
|
2017-11-10 13:36:29 +00:00
|
|
|
QObject *parent = nullptr);
|
|
|
|
|
2017-11-17 11:44:33 +00:00
|
|
|
AppBlockedModel *appBlockedModel() const { return m_appBlockedModel; }
|
|
|
|
|
2017-11-10 13:36:29 +00:00
|
|
|
QString errorMessage() const { return m_errorMessage; }
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void errorMessageChanged();
|
|
|
|
|
|
|
|
public slots:
|
2017-11-17 10:33:14 +00:00
|
|
|
|
|
|
|
void clearModels() const;
|
2017-11-17 03:46:35 +00:00
|
|
|
|
2017-11-10 13:36:29 +00:00
|
|
|
void setLogReadingEnabled(bool enabled);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void processLogBuffer(LogBuffer *logBuffer, bool success,
|
|
|
|
const QString &errorMessage);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void setErrorMessage(const QString &errorMessage);
|
|
|
|
|
2017-12-01 14:13:06 +00:00
|
|
|
void setupDatabaseManager();
|
2017-11-10 13:36:29 +00:00
|
|
|
void setupDriverWorker();
|
|
|
|
|
|
|
|
void readLogAsync(LogBuffer *logBuffer);
|
|
|
|
void cancelAsyncIo();
|
|
|
|
|
2017-11-17 03:46:35 +00:00
|
|
|
LogBuffer *getFreeBuffer();
|
|
|
|
|
|
|
|
void readLogEntries(LogBuffer *logBuffer);
|
|
|
|
|
2017-11-10 13:36:29 +00:00
|
|
|
private:
|
|
|
|
bool m_logReadingEnabled;
|
|
|
|
|
2017-12-01 14:13:06 +00:00
|
|
|
DatabaseManager *m_databaseManager;
|
|
|
|
|
2017-11-10 13:36:29 +00:00
|
|
|
DriverWorker *m_driverWorker;
|
2017-11-17 03:46:35 +00:00
|
|
|
QList<LogBuffer *> m_freeBuffers;
|
|
|
|
|
|
|
|
AppBlockedModel *m_appBlockedModel;
|
2017-11-10 13:36:29 +00:00
|
|
|
|
|
|
|
QString m_errorMessage;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LOGMANAGER_H
|