#ifndef GUARDCORE_H
#define GUARDCORE_H

#include <QObject>
#include <qmqtt.h>
#include <QSqlDatabase>
#include <QSqlQuery>
#include "logthread.h"
#include "httpthread.h"
#include "databasethread.h"
#include "tcpserver.h"
#include "devinfotcpserver.h"

class GuardCore : public QObject
{
    Q_OBJECT
public:
    explicit GuardCore(QObject *parent = nullptr);
    ~GuardCore();
    void start();
    bool shm_load();
    void shm_init();

signals:

public slots:
    void onConnected();
    void dataLog(QString log);
    void mqtt_data(QString mqtt_msg);
    void mqtt_event(QString mqtt_event);
    void appendSql(QString sql);

private:
    LogThread *logthread;
    HttpThread *httpthread;
    DatabaseThread *dbthread;
    TcpServer *tcpserver;
    DevInfoTcpServer *devinfoserver;

    QMQTT::Client *m_client;
    QSqlDatabase db;
    quint16 mqttIdx,mqttEventIdx;
    QString ip,port,username,password;
    QString devinfourl,devinfokey,devinfosignature;
    QString httpurl,httpkey,httpsignature;
    QString httpurl1,httpkey1,httpsignature1;
    QString tcpserverurl,tcpserverkey,tcpserversignature;
};

#endif // GUARDCORE_H
