#ifndef RECOGNIZESYSTEM_H
#define RECOGNIZESYSTEM_H

#include "client.h"
#include "updatecontroller.h"

#include <QDataStream>
#include <QTcpSocket>
#include "Systems/tools.h"
#include "Systems/dataparser.h"
#include "serverlmswidget.h"
#include <QMutex>

class UpdateController;
class ServerLMSWidget;
class ClientHandler;

class RecognizeSystem : public QObject
{

  Q_OBJECT

public:
    RecognizeSystem(QObject *parent = nullptr);
    void initialize(UpdateController *updateController,DataParser *dataParser,
                    ServerLMSWidget *server,SendSystem *sendSystem, ClientHandler *handler);
    void recognize();
    ~RecognizeSystem();

signals:
    void sigCalculateHash();
    void sigSendToLogger(QString string);
    void sigXmlParser(ClientHandler *clientHandler,QByteArray data);

private:
    UpdateController *updateController;
    SendSystem *sendSystem;
    DataParser *dataParser;
    ServerLMSWidget *server;
    QString command;
    PacketType packetType;
    QString filePath;
    ClientHandler *clientHandler;
    QMutex *mutex;

    QTcpSocket *socket;

    QByteArray tmpBlock;

    qint64 sizeReceiveData;
    qint64 fileSize;
    int countSend;
    bool isPackageTypeInited;

    void packetTypeInit(PacketType packet,Client *client);
    void packetTypeInit(PacketType type);
    QString createFullPath(QString path);
};
#endif // RECOGNIZESYSTEM_H
