#ifndef SENDSYSTEM_H
#define SENDSYSTEM_H

#include "dataparser.h"
#include "Systems/Tools.h"
#include "Client.h"
#include <QObject>
#include <QString>
#include <QtNetwork>

class DataParser;
class FileData;
class SendSystem : public QObject
{

    Q_OBJECT
public:
    explicit SendSystem(QObject* parent = nullptr);

    void initialize(DataParser* dataParser,Logger *logger);
    void setClient(Client* client,QTcpSocket *socket);
    void sendMessageBlock(QString message);
    void sendFileBlock(QString path);
    void sendFileBlockWithRename(QString path,QString newName);
    void sendFolderBlock(QString path);
    void sendDeleteBlock(QString path);
    void sendHello();
    void sendFinish();
    void sendNotify(QString notify);
    void sendStop();
    void sendXmlAnswer(QByteArray array);
    void sendNeedUpdate(bool flag,quint64 size,quint64 fileCount);
    void updateFiles(QList<FileData> fileSendList, QList<FileData> clientDataList);
    bool getIsSendStopped() const;

    ~SendSystem();


public slots:
    void socketWrite(QByteArray array);
    void socketClose();
signals:
    void sigLoadHash();
    void sigSendToLogger(QString message);
    QByteArray sigSendXMLmessage(QString message);
    QByteArray sigSendNotify(QString message);

private:
    Client *client;
    QTcpSocket* socket;
    DataParser* dataParser;
    Logger *logger;
    QMutex *mutex;
    quint64 fileSize;
    int countSend;
    bool isSendStopped;
    bool isUnity;


};

#endif // SENDSYSTEM_H
