#ifndef WUPGRADEAPKITEM_H
#define WUPGRADEAPKITEM_H

#include <QObject>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QDir>
#include <QDateTime>
#include <QJsonObject>
#include <QJsonDocument>
#include <QPushButton>
#include <LoQClass/loqpushbutton.h>
#include <LoQClass/loqtreewidget.h>
#include <wDevicesManager/ledcard.h>
#include <communication/hpptclient.h>
#include "threadupgradeapk.h"
#include <QProgressBar>
#include <QLabel>

class wUpgradeApkItem : public QObject, public QTreeWidgetItem
{
    Q_OBJECT
   // Q_PROPERTY(LedCard objLedCard    MEMBER m_LedCard   NOTIFY LedCardChanged   )
public:
    explicit wUpgradeApkItem(LedCard *pLedCard, LoQTreeWidget *parent = nullptr,QWidget *pWnd=nullptr,QString strProgramName="",QString strProgramPath="");
     ~wUpgradeApkItem();
private:
    void init();
    QString getRandomString(int length);
    void SetPasswordItem(LedCard *p);
public:
    void refreshLable();
    QString GetLedCardId();
    void SetItemParam(LedCard *p);
    void onUpgradeApk(QString strFileName);
    void onUpgradeFpga(QString strFileName);
    void onUninstallApk(QString strApkName);
    void onCheckRuningState(QString strApkName);

signals:
    void sigUpgradeSuccess();
    void sigUpgradeFail();

public slots:
    void onAttrChanged();
    void OnProHttpResponse(QString url, QString postMD5, QByteArray data);
    void OnThreadFinished();
    void OnThreadFpgaFinished();
    void OnSendStatusTip(QString);
    void onVerifyLockPassword();
    void onInputPasswordPro(QString strPassword);
    void slotTimeout();
    void OnCheckSoftVersions();
    void OnCheckFpgaVersions();


private:
    LedCard   *m_pLedCard = nullptr;
    QString m_strProgramName="";
    QString m_strProgramPath="";
    bool m_lockFlag=true;
    void OnSendStatusTip(QString,QColor cr);

private:
    QLabel *m_ImageOnline=nullptr;
    LoQTreeWidget *m_parent = nullptr;
    QString m_strUrl="";
    QWidget *m_pWnd=nullptr;
    HpptClient *pHpptClient = nullptr;
    QProgressBar *m_pProgress=nullptr;
    int m_iSendingFlag=0;
    QPushButton *m_bnLock = nullptr;//
    QString m_strApkFilePathName="";
    QString m_strFpgaFilePathName="";



     void postFileTask(const QString& strUrl, const QString& strFilePath);//需要的数据
public:
     void SetLockFlagFalse();
};
enum ENUM_DEVICE_PUBLISH_HEADERITEM
{
    ENUM_DEVICE_PUBLISH_HEADE_CHECK=0,
    ENUM_DEVICE_PUBLISH_HEADE_SCREEN_ID,
    ENUM_DEVICE_PUBLISH_HEADE_ONLINE,
    ENUM_DEVICE_PUBLISH_HEADE_SCREEN_IP,
    ENUM_DEVICE_PUBLISH_HEADE_ENCRYPT,
    ENUM_DEVICE_PUBLISH_HEADE_PROGRESS,
    ENUM_DEVICE_PUBLISH_HEADE_XIXUNPLAYER_VERSION,
    ENUM_DEVICE_PUBLISH_HEADE_CARDSYSTEM_VERSION,
    ENUM_DEVICE_PUBLISH_HEADE_STARTER_VERSION,
    ENUM_DEVICE_PUBLISH_HEADE_TAXIAPP_VERSION,
    ENUM_DEVICE_PUBLISH_HEADE_DISPLAYER_VERSION,
    ENUM_DEVICE_PUBLISH_HEADE_FPAG_VERSION,
    ENUM_DEVICE_PUBLISH_HEADE_REMARKS,
    ENUM_DEVICE_PUBLISH_HEADE_REMARK_NAME,
    ENUM_DEVICE_PUBLISH_HEADE_CONNECTION_VERSION,
    ENUM_DEVICE_PUBLISH_HEADE_UPDATE_VERSION,
//    ENUM_DEVICE_PUBLISH_HEADE_BASICAPP_VERSION,
    ENUM_DEVICE_PUBLISH_HEADE_END,
};


#endif // WPROGRAMPUBLISHITEM_H
