#ifndef PROCESSINGSYSTEM_H
#define PROCESSINGSYSTEM_H

#include <Systems/sendsystem.h>
#include <Data/typesDataServerClient.h>

#include <clienthandler.h>
#include <serverlmswidget.h>
#include "multithreadserver.h"
//#include "instructorsandtraineeswidget.h"
#include "chatsystem.h"
#include "providerdblms.h"

class SendSystem;
class ServerLMSWidget;
class InstructorsAndTrainees;
class Logger;
class DataParser;
class ClientHandler;
class CommonClientHandler;
class MultiThreadServer;

class ProcessingSystem : public QObject
{
    Q_OBJECT
public:
    explicit ProcessingSystem(ProviderDBLMS* providerDBLMS, UpdateController* updateController, QObject *parent = nullptr);

    void initialize(MultiThreadServer *server,
                    DataParser* dataParser,
                    CommonClientHandler *commonClientServer,
                    UpdateController *updateComtroller,
                    ChatSystem *chatSystem);

    void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization);
    void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization);
    void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr);
    void processingClientQueryTasksXML(ClientHandler *client, ClientQueryTasksXML clientQueryTasksXML);

    void processingSendMessage(ClientMessage clientMessage);
    void processingClientNotify(ClientHandler *client, ClientNotify clientNotify);

    void setCurrentDataInfo(DataInfo *dataInfo);

    void sendListTasksAMMofTraineetoClient(ClientHandler* client, int id_trainee);
    void sendListTasksFIMofTraineetoClient(ClientHandler* client, int id_trainee);

    void sendListTasksAMMofTraineeByIDtoClient(ClientHandler* client, int id_trainee, QList<int> listID);
    void sendListTasksFIMofTraineeByIDtoClient(ClientHandler* client, int id_trainee, QList<int> listID);

    void sendTaskAMMToClient(ClientHandler* client, int id_trainee, TaskAmmFim task);
    void sendTaskFIMToClient(ClientHandler* client, int id_trainee, TaskAmmFim task);

    ClientHandler* getUnityClientById(int id);
    void processingClientDeAutorization(QString login);

    void processingEntryUnityClient(ClientHandler *client);
    void processingExitUnityClient(ClientHandler *client);
signals:
    void sigUpdateListClients();
    void sigListsInstructorsTraineesChanged();
    void sigStatusTasksAMMofTraineeChanged(int trainee_id);
    void sigStatusTasksFIMofTraineeChanged(int trainee_id);
    void sigAddToMessanger(QString login,QString text);
    void sigSetData(DataInfo *dataInfo);

private:
    CommonClientHandler *commonClientServer;
    MultiThreadServer *server;
    DataParser *dataParser;
    UpdateController *updateController;
    ProviderDBLMS* providerDBLMS;
    ChatSystem *chatSystem;
    void sendTaskListToUnity(ClientHandler *client);
};

#endif // PROCESSINGSYSTEM_H
