2023-04-18 14:14:46 +08:00
|
|
|
|
#ifndef GLOBALDEFINE_H
|
|
|
|
|
#define GLOBALDEFINE_H
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QJsonValue>
|
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
#include <QJsonDocument>
|
|
|
|
|
#include <communication/hpptclient.h>
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
MainPage_DeviceManager = 0,
|
|
|
|
|
MainPage_ProgManager,
|
|
|
|
|
MainPage_Setting,
|
|
|
|
|
MainPage_LoraScreen,
|
|
|
|
|
MainPage_End,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct RESTORE_IP {
|
|
|
|
|
char cNewIp[20];
|
|
|
|
|
char cMask[20];
|
|
|
|
|
char cGateway[20];
|
|
|
|
|
char cDns[20];
|
|
|
|
|
};
|
|
|
|
|
struct Packet {
|
|
|
|
|
unsigned char SyncHead[3];
|
|
|
|
|
unsigned char ucCommType;
|
|
|
|
|
char serialCode[20];
|
|
|
|
|
unsigned int iLength;
|
|
|
|
|
};
|
|
|
|
|
struct STREAM_PACKET {
|
|
|
|
|
unsigned char SyncHead[3];
|
|
|
|
|
unsigned char ucCommType;
|
|
|
|
|
char ucSerialCode[20];
|
|
|
|
|
unsigned int iLength;
|
|
|
|
|
char pDataBuffer[2049];
|
|
|
|
|
};
|
|
|
|
|
struct ST_ANSY_PROGRAM_PACKET {
|
|
|
|
|
unsigned char SyncHead[3];
|
|
|
|
|
unsigned char ucCommType;
|
|
|
|
|
int iBaoLiu;
|
|
|
|
|
unsigned int iLength;
|
|
|
|
|
unsigned char pDataBuffer[20];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum _NET_COMMU_TYPE {
|
|
|
|
|
COMMAND_SAVE_ADVANCE_PARAM_NOT_RESET=0x40,
|
|
|
|
|
COMMAND_ONLY_RESET_CARD_IP=0X43,
|
|
|
|
|
COMMAND_SET_M31_DOUBLE_HUB=0X44,
|
|
|
|
|
COMMAND_CONNECT_COLSE =0x7A,
|
|
|
|
|
COMMAND_UPGRADE = 0x80,
|
|
|
|
|
COMMAND_SIGNLE_FILE_UPGRADE ,
|
|
|
|
|
COMMAND_LOOPCHECK ,
|
|
|
|
|
COMMAND_VERIFY_CLOCK ,
|
|
|
|
|
COMMAND_SCREEN_OPERATOR,//0x84
|
|
|
|
|
COMMAND_SET_SERIAL_NUM,
|
|
|
|
|
NET_COMMU_TYPE_PLAY_IN_LINE , // 网络同步在线播放.
|
|
|
|
|
NET_COMMU_TYPE_PREVIEW_IN_LINE, // 网络在线预览.
|
|
|
|
|
NET_COMMU_TYPE_UPGRADE_SYSTEM, // 系统升级.
|
|
|
|
|
NET_COMMU_TYPE_RECOVER_SYSTEM, // 系统还原到上一次正确的启动.
|
|
|
|
|
SCREEN_OPERATOR_COMM_PARAMS_SAVE, // 参数保存.
|
|
|
|
|
NET_COMMU_TYPE_COMM_EXIT,//普通退出,不重启
|
|
|
|
|
NET_COMMU_TYPE_AUDIO_PLAY,//0X8C
|
|
|
|
|
NET_COMMU_TYPE_IO,
|
|
|
|
|
NET_COMMU_TYPE_IO_CHECK,
|
|
|
|
|
NET_COMMU_TYPE_LIMITE_TIME,
|
|
|
|
|
NET_COMMU_TYPE_SYSTEM_BROADCAST,//0X90
|
|
|
|
|
NET_COMMU_TYPE_REALTIME_INSERT_PLAY,
|
|
|
|
|
|
|
|
|
|
NET_COMMU_TYPE_MODIFY_SERIAL_ID,
|
|
|
|
|
NET_COMMU_TYPE_KERNEL_UPGRADE_SYSTEM,
|
|
|
|
|
NET_COMMU_TYPE_UPGRADE_FINISHED_EXIT,
|
|
|
|
|
NET_COMMU_TYPE_REAL_TIME_INSERT_PLAY_WITH_LIST_EXIT,
|
|
|
|
|
NET_COMMU_TYPE_ZNSZ,// 智能设置命令.
|
|
|
|
|
NET_COMMU_TYPE_SELECT_PROGRAM_PLAY,// 选节目播放.0x97
|
|
|
|
|
NET_COMMU_TYPE_SELECT_MULI_PROGRAM_PLAY,//98选播多个节目
|
|
|
|
|
NET_COMMU_TYPE_GET_PROGRAM_NAME,//99获取所有节目的名称
|
|
|
|
|
NET_COMMU_TYPE_GET_CUR_PLAY_STATUS,//9a查询当前播放的详细信息
|
|
|
|
|
NET_COMMU_TYPE_POWER_PANEL_ON_OR_OFF,//9b开关大屏幕
|
|
|
|
|
NET_COMMU_TYPE_ADJUST_BRIGHTNESS,//9c调节亮度
|
|
|
|
|
NET_COMMU_TYPE_GET_SYSTEM_STATUS,//9d获取系统状态
|
|
|
|
|
NET_COMMU_TYPE_VERIFY_SIGN,//校验签名9e
|
|
|
|
|
NET_COMMU_TYPE_SET_WEB_SERVER_PARAM,//配置web服务器参数
|
|
|
|
|
NET_COMMU_TYPE_GET_WEB_SERVER_PARAM,//a0
|
|
|
|
|
NET_COMMU_TYPE_SET_WIFI_PARAM,//a1配置wifi参数
|
|
|
|
|
NET_COMMU_TYPE_GET_WIFI_PARAM,//a2获取wifi参数
|
|
|
|
|
NET_COMMU_TYPE_SCAN_AP_WIFI_PARAM,//a3获取ap热点的名称
|
|
|
|
|
NET_COMMU_TYPE_GET_ANDROID=0xa4,
|
|
|
|
|
NET_COMMU_TYPE_INSTALL_APK=0xa5,
|
|
|
|
|
NET_COMMU_TYPE_UNINSTALL_APK=0xa6,
|
|
|
|
|
NET_COMMU_TYPE_SET_DNS=0xa7,
|
|
|
|
|
NET_COMMU_TYPE_GET_DNS=0xa8,
|
|
|
|
|
NET_COMMU_TYPE_SET_PROXY=0xa9,
|
|
|
|
|
NET_COMMU_TYPE_GET_PROXY=0xaa,
|
|
|
|
|
NET_COMMU_TYPE_SET_ANDROID_COMMUNICATION=0xab,
|
|
|
|
|
NET_COMMU_TYPE_GET_ANDROID_COMMUNICATION=0xac,
|
|
|
|
|
NET_COMMU_TYPE_GET_SIM_STATUS=0xad,
|
|
|
|
|
NET_COMMU_TYPE_GET_APN_PARAM=0xae,
|
|
|
|
|
NET_COMMU_TYPE_GET_APK_VERSION=0xaf,
|
|
|
|
|
NET_COMMU_TYPE_SET_REALTIME_PARAM=0xb0,
|
|
|
|
|
NET_COMMU_TYPE_GET_REALTIME_PARAM=0xb1,
|
|
|
|
|
NET_COMMU_TYPE_SET_REALTIME_LINSTEN_PARAM=0xb2,
|
|
|
|
|
NET_COMMU_TYPE_GET_REALTIME_LINSTEN_PARAM=0xb3,
|
|
|
|
|
NET_COMMU_TYPE_SET_HUAWEI_4G=0xB4,
|
|
|
|
|
NET_COMMU_TYPE_GET_HUAWEI_4G=0xB5,
|
|
|
|
|
NET_COMMU_TYPE_CLEAR_ANDROID_PROGRAM=0xB6,
|
|
|
|
|
NET_COMMU_TYPE_SET_AP_PARAM=0xB7,
|
|
|
|
|
NET_COMMU_TYPE_GET_AP_PARAM=0xB8,
|
|
|
|
|
GET_REALY_RESOLUTION=0xB9,
|
|
|
|
|
GET_REALY_ANDROID_FIRMWARE_INFO=0xBA,
|
|
|
|
|
NET_COMMU_TYPE_NUM,
|
|
|
|
|
|
|
|
|
|
COMMAND_UPGRADE_ANSWER =0xC0,
|
|
|
|
|
COMMAND_SIGNLE_FILE_UPGRADE_ANSWER ,
|
|
|
|
|
COMMAND_LOOPCHECK_ANSWER ,
|
|
|
|
|
COMMAND_VERIFY_CLOCK_ANSWER ,
|
|
|
|
|
COMMAND_SCREEN_OPERATOR_ANSWER,
|
|
|
|
|
COMMAND_SET_SERIAL_NUM_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_PLAY_IN_LINE_ANSWER , // 网络同步在线播放.
|
|
|
|
|
NET_COMMU_TYPE_PREVIEW_IN_LINE_ANSWER, // 网络在线预览.
|
|
|
|
|
NET_COMMU_TYPE_UPGRADE_SYSTEM_ANSWER, // 系统升级.
|
|
|
|
|
NET_COMMU_TYPE_RECOVER_SYSTEM_ANSWER, // 系统还原到上一次正确的启动.
|
|
|
|
|
SCREEN_OPERATOR_COMM_PARAMS_SAVE_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_COMM_EXIT_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_AUDIO_PLAY_ANSWER,//0XcC
|
|
|
|
|
NET_COMMU_TYPE_IO_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_IO_CHECK_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_LIMITE_TIME_ANSWER,
|
|
|
|
|
|
|
|
|
|
NET_COMMU_TYPE_SYSTEM_BROADCAST_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_REALTIME_INSERT_PLAY_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_REALTIME_INSERT_PLAY_WITH_GLINT_ANSWER , //带闪烁功能的实时插播
|
|
|
|
|
|
|
|
|
|
NET_COMMU_TYPE_KERNEL_UPGRADE_SYSTEM_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_UPGRADE_FINISHED_EXIT_ANSWER,//0xd4
|
|
|
|
|
NET_COMMU_TYPE_REAL_TIME_INSERT_PLAY_WITH_LIST_EXIT_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_ZNSZ_ANSWER,// 智能设置命令.
|
|
|
|
|
NET_COMMU_TYPE_SELECT_PROGRAM_PLAY_ANSWER,//0x97 选节目播放.
|
|
|
|
|
NET_COMMU_TYPE_SELECT_MULI_PROGRAM_PLAY_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_GET_PROGRAM_NAME_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_GET_CUR_PLAY_STATUS_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_POWER_PANEL_ON_OR_OFF_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_ADJUST_BRIGHTNESS_ANSWER,
|
|
|
|
|
NET_COMMU_TYPE_GET_SYSTEM_STATUS_ANSWER,//获取系统状态
|
|
|
|
|
NET_COMMU_TYPE_NUM_ANSWER,
|
|
|
|
|
|
|
|
|
|
COMMAND_CONNECT_COLSE_ANSWER
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern bool gVideoCompress;
|
|
|
|
|
extern bool gVideoTranscoding;
|
|
|
|
|
extern bool gTextAntialiasing;
|
|
|
|
|
extern bool gShowLoraScreen;
|
|
|
|
|
extern bool gWidthSplit;
|
|
|
|
|
|
|
|
|
|
extern bool isTextValid(const QString &strIP);
|
|
|
|
|
extern quint64 dirFileSize(const QString &path);
|
|
|
|
|
extern bool isFileExist(QString fullFileName);
|
|
|
|
|
extern QString getRandomString(int length);
|
|
|
|
|
extern void HttpPostByTypeJsonObject(HpptClient *pHpptClient, QString strUrl,QJsonObject json);
|
|
|
|
|
extern bool copyDir(const QString &source, const QString &destination, bool override);
|
|
|
|
|
extern unsigned char GetCheckCodeIn8(unsigned char * pBuffer,unsigned int uiSize);
|
|
|
|
|
|
|
|
|
|
enum _ENUM_CONTRL_WIDGET {
|
|
|
|
|
Setting_Bright=0,
|
|
|
|
|
Setting_PowerControl,
|
|
|
|
|
Setting_NetCfg,
|
|
|
|
|
Setting_VerifyClock,
|
|
|
|
|
Setting_Encrypt,
|
|
|
|
|
Setting_HDMI,
|
|
|
|
|
Setting_Volume,
|
|
|
|
|
Setting_Advanced,
|
|
|
|
|
Setting_Test,
|
|
|
|
|
Setting_End,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QNetworkRequest netReq(const QString &url, const QByteArray & = QByteArray(), int = QNetworkRequest::DefaultTransferTimeoutConstant);
|
|
|
|
|
inline QNetworkRequest reqForJson(const QString &url, int timeout = QNetworkRequest::DefaultTransferTimeoutConstant) {
|
|
|
|
|
return netReq(url, "application/json", timeout);
|
|
|
|
|
}
|
|
|
|
|
QString replyErr(QNetworkReply *);
|
|
|
|
|
QString checkReply(QNetworkReply *, QJsonDocument * = 0);
|
|
|
|
|
QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0);
|
|
|
|
|
|
|
|
|
|
#define Def_CtrlReqPre \
|
|
|
|
|
waitingDlg->show();\
|
|
|
|
|
auto card = gSelCards->at(0);\
|
|
|
|
|
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));\
|
|
|
|
|
connect(waitingDlg, &WaitingDlg::rejected, reply, [reply] {\
|
|
|
|
|
reply->blockSignals(true);\
|
|
|
|
|
reply->abort();\
|
|
|
|
|
reply->blockSignals(false);\
|
|
|
|
|
reply->deleteLater();\
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
#define Def_CtrlSetReqAfter \
|
|
|
|
|
QString err = checkReplyForJson(reply);\
|
|
|
|
|
if(! err.isEmpty()) {\
|
|
|
|
|
waitingDlg->close();\
|
|
|
|
|
QMessageBox::critical(gMainWin, tr("Error"), err);\
|
|
|
|
|
return;\
|
|
|
|
|
}\
|
|
|
|
|
waitingDlg->success();
|
|
|
|
|
|
|
|
|
|
#define Def_CtrlSingleGetReply \
|
|
|
|
|
QJsonDocument json;\
|
|
|
|
|
QString err = checkReplyForJson(reply, &json);\
|
|
|
|
|
if(! err.isEmpty()) {\
|
|
|
|
|
waitingDlg->close();\
|
|
|
|
|
QMessageBox::critical(gMainWin, tr("Error"), err);\
|
|
|
|
|
return;\
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define Def_CtrlSetMulti(tip) \
|
|
|
|
|
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));\
|
|
|
|
|
connect(reply, &QNetworkReply::finished, card, [=] {\
|
|
|
|
|
QString err = checkReplyForJson(reply);\
|
|
|
|
|
gFdResInfo->append(card->m_strCardId+" "+tip+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err));\
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
#define CHECK_CARD_SELECTED \
|
|
|
|
|
if(gSelCards->isEmpty()) {\
|
|
|
|
|
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));\
|
|
|
|
|
return;\
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define MACRO_DEFINE_TIPDLG_FUCN(TIP,SUCCESS,FAILED) \
|
|
|
|
|
if(gSelCards->count()==1) {\
|
|
|
|
|
HttpPostByTypeJsonObject(pHpptClient, m_strUrl, json);\
|
|
|
|
|
if(m_PostingDlg==nullptr) {\
|
|
|
|
|
m_PostingDlg = new LoEmptyDialog(this);\
|
|
|
|
|
connect(m_PostingDlg,SIGNAL(sigClose()),this,SLOT(DeletePostingDlg()));\
|
|
|
|
|
connect(m_pGetAskTimer,SIGNAL(timeout()),m_PostingDlg,SLOT(TimerOutUnlock()));\
|
|
|
|
|
m_PostingDlg->lock(TIP,SUCCESS,FAILED);\
|
|
|
|
|
m_pGetAskTimer->start(5000);\
|
|
|
|
|
m_PostingDlg->exec();\
|
|
|
|
|
}\
|
|
|
|
|
} else if(gSelCards->count() > 1) emit sigSend(json,TIP);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define MACRO_DEFINE_TIPDLG_ALL_FUCN(READBACK,SUCCESS,FAILED) \
|
|
|
|
|
if(gSelCards->count()==1) {\
|
|
|
|
|
if(m_PostingDlg==nullptr) {\
|
|
|
|
|
m_PostingDlg = new LoEmptyDialog(this);\
|
|
|
|
|
connect(m_PostingDlg,SIGNAL(sigClose()),this,SLOT(DeletePostingDlg()));\
|
|
|
|
|
connect(m_pGetAskTimer,SIGNAL(timeout()),m_PostingDlg,SLOT(TimerOutUnlock()));\
|
|
|
|
|
m_PostingDlg->lock(READBACK+" "+gSelCards->at(0)->m_strCardId,SUCCESS,FAILED);\
|
|
|
|
|
m_pGetAskTimer->start(5000);\
|
|
|
|
|
m_PostingDlg->exec();\
|
|
|
|
|
}\
|
|
|
|
|
}\
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define MARCO_DEFINE_CONTROL_FUNC2(PARENT,PARENT1) \
|
|
|
|
|
pHpptClient = new HpptClient(this);\
|
|
|
|
|
connect(pHpptClient,SIGNAL(httpPostRspReady(QString , QString , QByteArray )),this,SLOT(OnProHttpResponse(QString , QString , QByteArray)));\
|
|
|
|
|
pHpptClientAll = new HpptClient(this);\
|
|
|
|
|
connect(pHpptClientAll,SIGNAL(httpPostRspReady(QString , QString , QByteArray )),this,SLOT(OnProHttpResponseAll(QString , QString , QByteArray)));\
|
|
|
|
|
m_pGetAskTimer=new QTimer(this);\
|
|
|
|
|
connect(PARENT1,SIGNAL(sigSwitchIndexChanged(int)),this,SLOT(OnControlTypeSwitchIndexChanged(int)));\
|
|
|
|
|
connect(PARENT,SIGNAL(sigSelectedDeviceList(QList<LedCard *> *)),this,SLOT(onSelectedDeviceList(QList<LedCard *> *)));\
|
|
|
|
|
connect(this,SIGNAL(sigSend(QJsonObject &,QString)),PARENT,SLOT(OnControlSendJson(QJsonObject &,QString)));\
|
|
|
|
|
onSelectedDeviceList(list);
|
|
|
|
|
|
|
|
|
|
#define MACRO_ASKTIME_STOP \
|
|
|
|
|
if(m_pGetAskTimer && m_pGetAskTimer->isActive()) m_pGetAskTimer->stop();
|
|
|
|
|
|
|
|
|
|
#define MACRO_POSTING_DLG_UNLOCK \
|
|
|
|
|
if(m_PostingDlg && m_PostingDlg->getLockStatus()) m_PostingDlg->unlock();
|
|
|
|
|
|
|
|
|
|
#define MACRO_DEFINE_CONTROL_FUNC3 \
|
|
|
|
|
if(m_pLedlist!=nullptr)\
|
|
|
|
|
{\
|
|
|
|
|
if(m_pLedlist->count()==1)\
|
|
|
|
|
{\
|
|
|
|
|
m_pLedCard=list->at(0);\
|
|
|
|
|
m_strUrl="http://"+m_pLedCard->m_strCardIp+":2016/settings";\
|
|
|
|
|
if(m_oldLedlist!=m_pLedCard&&m_bSelected==true)\
|
|
|
|
|
{\
|
|
|
|
|
m_oldLedlist=m_pLedCard;\
|
|
|
|
|
onReadbackAllThisPage();\
|
|
|
|
|
}\
|
|
|
|
|
}\
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // GLOBALDEFINE_H
|