#ifndef RECOGNIZESYSTEM_H
#define RECOGNIZESYSTEM_H

#include <QObject>
#include <QDataStream>
#include <QTcpSocket>
#include <streamingVersionData.h>
//#include <mainwindow.h>
#include <Core\tools.h>
#include "dataparser.h"
#include "instructor.h"
#include "trainee.h"
#include "group.h"
#include "Datas.h"
#include "tasksAmmFim.h"


class RecognizeSystem : public QObject
{

    Q_OBJECT

public:
    explicit RecognizeSystem(QObject *parent = 0);
    ~RecognizeSystem();
    void initialize(DataParser *dataParser/*,MainWindow *mainWindow*/);
    void recognize(QTcpSocket *socket);

signals:
    void sigUpdateBytesAvailable();
    void sigLoadComplete();
    void sigNeedUpdate(bool flag,qint64 size,quint64 fileCount);
    void sigSendDebugLog(QString message);
    void sigSocketDisabled();
    void sigServerBlocked();
    void sigAuth(ServerAuthorization *serverAuth);
    void sigDeAuth(ServerDeAuthorization *serverDeAuth);
    void sigAnswerQueryToDB(QList<Instructor>* listInstructors,
                            QList<Trainee>* listTrainees,
                            QList<Group>* listGroups);
    void sigSocketWaitForReadyRead(int waitTime);
    void sigStartCompare();

    void signal_MessageForGUI(QString login, QString text);

    void sigAnswerQueryToDB_ListInstructors(QList<Instructor> listInstructors);
    void sigAnswerQueryToDB_ListGroups(QList<Group> listGroups);
    void sigAnswerQueryToDB_ListTrainees(QList<Trainee> listTrainees);
    void sigAnswerQueryToDB_ListComputers(QList<Computer> listComputers);
    void sigAnswerQueryToDB_ListClassrooms(QList<Classroom> listClassrooms);
    void sigAnswerQueryToDB_ListTasks(QList<Task> listTasks);
    void sigAnswerQueryTasksXML_FIM(QByteArray array);
    void sigAnswerQueryTasksXML_AMM(QByteArray array);
    void sigShowServerDataList(QList<StreamingVersionData*> *versions);
    void sigSetVersion(StreamingVersionData* serverVersion);
    void sigNotify(QString text);
    void sigAnimationActivated(bool flag);

private:
    QList<QString> *folderList;
    //MainWindow *mainWindow;
    DataParser *dataParser;
    PacketType packetType;
    QString message;
    QString filePath;
    QByteArray tmpBlock;

    qint64 sizeReceiveData;
    qint64 fileSize;
    int countSend;

    void xmlParser(QByteArray array);
    void xmlParserQueryToDB(PacketType packetType, QByteArray array);
    void xmlParserQueryTasksXML(PacketType packetType, QByteArray array);

    void checkAccessType(QString type);
};

#endif // RECOGNIZESYSTEM_H
