#ifndef DATAPARSER_H
#define DATAPARSER_H

#include "FileData.h"
#include "instructor.h"

#include <QObject>
#include <Datas.h>
#include <QFile>
#include <QXmlStreamWriter>

class DataParser : public QObject
{

    Q_OBJECT

public:
    explicit DataParser(QObject *parent = 0);
    ~DataParser();
    ServerSettings* getServerSettings();
    void createServerSettings(QString server,QString port);
    void saveClientSettrings(QString language,bool isAutoStart);
    void createFileDataList(QList<FileData> fileDataList,QString filename);

    QByteArray createAuthMessage(ClientAutorization *auth);
    QByteArray createMessage(ClientMessage toClientMessage);
    QByteArray createQueryToDBMessage(ClientQueryToDB *queryToDB, int id = 0, void* data = nullptr);
    QByteArray createQueryTasksXMLMessage(QString type);
    QByteArray createQueryListSubProcMessage(QString dmCode);
    QByteArray createDeAuthMessage(ClientDeAutorization *deAuth);

    QByteArray createQueryBlockAuth(bool block);

    void createAuthData(ServerAuthorization *serverAuth);
    void createAuthDataOffline(QString username,QString pass);
    void addRunData(QList<int> displays);
    QByteArray xmlAnswer_notify(QString code);
    QByteArray xmlAnswer(QList<SXmlAnswerTag> listTag, QString elemUp1 = "", QString elemUp2 = "");

    QList<FileData>* xmlFileDataParse(QByteArray array,QString filter);
public slots:
    QByteArray slotGetXmlAnswer(QString);


private:
    const QString XMLLanguageProperty = "Language=\"";
    const QString XMLAutoStartProperty = "AutoStart=\"";
    ClientAutorization *authPassCache;

};

#endif // DATAPARSER_H
