#ifndef HTTPPASSWORDLOGIN_H
#define HTTPPASSWORDLOGIN_H
#include <QThread>
#include <QtQml/qqml.h>
#include <QNetworkAccessManager>
#include <QTimer>

class HttpPasswordLogin : public QThread
{
    Q_OBJECT
    QML_NAMED_ELEMENT(HttpPasswordLogin)

    Q_PROPERTY(QString username READ username WRITE setUsername)
    Q_PROPERTY(QString password READ userpassword WRITE setUserPassword)
public:
    explicit HttpPasswordLogin(QObject *parent = nullptr);

    QString username()
    {
        return this->m_username;
    }
    void setUsername(const QString& username)
    {
        m_username = username;
    }

    QString userpassword()
    {
        return this->m_password;
    }
    void setUserPassword(const QString& password)
    {
        m_password = password;
    }
protected:
    void run() override;
private:
    void httpRequestUsernameLogin(void);
public slots:
    void slotHttpResponseUsernameLogin(QByteArray data);
signals:
    void signalPostRequestData(quint64 id, QString postUrl, QByteArray data, QByteArray file, QString token);
    void signalLoginReturnStat(int stat, QString str);
    void signalLoginReturnParam(QString name, int auth);
private:
    QString m_username;
    QString m_password;
    QString m_accessToken;
    QString m_refreshToken;
};

#endif // HTTPPASSWORDLOGIN_H
