2023-08-03 16:16:02 +08:00
|
|
|
|
//
|
|
|
|
|
// Created by HW on 2023/07/27.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#ifndef OFFICEASSISTANT_NETIO_H
|
|
|
|
|
#define OFFICEASSISTANT_NETIO_H
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#include <QJsonDocument>
|
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
#include <QtNetwork/QtNetwork>
|
2023-08-08 15:15:19 +08:00
|
|
|
|
#include "buttonstruct.h"
|
|
|
|
|
#include "sqlitehelper.h"
|
2023-08-03 16:16:02 +08:00
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
QString img;
|
|
|
|
|
QString img_cover;
|
|
|
|
|
QString title;
|
2023-08-08 15:15:19 +08:00
|
|
|
|
QString orig_name;
|
|
|
|
|
QString categroy_id;
|
|
|
|
|
QString op;
|
2023-08-03 16:16:02 +08:00
|
|
|
|
QString func;
|
|
|
|
|
QString url;
|
2023-08-08 15:15:19 +08:00
|
|
|
|
} Button;
|
2023-08-10 15:36:08 +08:00
|
|
|
|
struct ConfigResponse {
|
2023-08-03 16:16:02 +08:00
|
|
|
|
bool succeed;
|
|
|
|
|
struct {
|
|
|
|
|
QString logo_url;
|
|
|
|
|
QString device_id;
|
|
|
|
|
QString dev_id;
|
|
|
|
|
QString token;
|
|
|
|
|
QString backgroud_color;
|
|
|
|
|
QString title_color;
|
|
|
|
|
QString title_cover_color;
|
|
|
|
|
}basic;
|
2023-08-08 15:15:19 +08:00
|
|
|
|
QList<Button> buttons;
|
2023-08-10 15:36:08 +08:00
|
|
|
|
};
|
2023-08-03 16:16:02 +08:00
|
|
|
|
|
|
|
|
|
class RequestBodyBase:public QObject{
|
|
|
|
|
Q_OBJECT;
|
|
|
|
|
public:
|
|
|
|
|
RequestBodyBase();
|
|
|
|
|
virtual void sendRequest();
|
|
|
|
|
protected:
|
|
|
|
|
QString product;
|
|
|
|
|
QString parter_id;
|
|
|
|
|
QString os;
|
|
|
|
|
QString os_version;
|
|
|
|
|
QString device_id;
|
|
|
|
|
QString request_id;
|
|
|
|
|
QString version;
|
|
|
|
|
QString release;
|
|
|
|
|
QString sign;
|
|
|
|
|
QJsonDocument qJsonDocument;
|
|
|
|
|
QNetworkReply *reply;
|
|
|
|
|
QEventLoop eventLoop;
|
|
|
|
|
QTimer *timer;
|
2023-08-13 12:16:22 +08:00
|
|
|
|
bool downloadSuccess = true;
|
2023-08-03 16:16:02 +08:00
|
|
|
|
protected slots:
|
|
|
|
|
void cancelDownload();
|
|
|
|
|
};
|
|
|
|
|
class ConfigRequest:public RequestBodyBase{
|
|
|
|
|
public:
|
|
|
|
|
ConfigRequest():RequestBodyBase(){}
|
|
|
|
|
void sendRequest(ConfigResponse * configResponse);
|
|
|
|
|
};
|
|
|
|
|
class OpRequest:public RequestBodyBase{
|
|
|
|
|
public:
|
|
|
|
|
OpRequest(QString Op,QString OpValue):RequestBodyBase(),op(Op),op_value(OpValue){
|
|
|
|
|
QJsonObject obj_root=qJsonDocument.object();
|
|
|
|
|
QJsonValue value=op;
|
|
|
|
|
obj_root.insert("op",op);
|
|
|
|
|
value=op_value;
|
|
|
|
|
obj_root.insert("op_value",op_value);
|
|
|
|
|
qJsonDocument.setObject(obj_root);
|
|
|
|
|
}
|
|
|
|
|
QString getOpValue(){
|
|
|
|
|
return op_value;
|
|
|
|
|
}
|
|
|
|
|
QString getOp(){
|
|
|
|
|
return op;
|
|
|
|
|
}
|
|
|
|
|
void setOpValue(QString op_value){
|
|
|
|
|
this->op_value=op_value;
|
|
|
|
|
}
|
|
|
|
|
void setOp(QString op){
|
|
|
|
|
this->op=op;
|
|
|
|
|
}
|
|
|
|
|
void sendRequest();
|
|
|
|
|
protected:
|
|
|
|
|
QString op;
|
|
|
|
|
QString op_value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DeviceRequest:RequestBodyBase{
|
2023-08-13 12:16:22 +08:00
|
|
|
|
public:
|
2023-08-03 16:16:02 +08:00
|
|
|
|
DeviceRequest();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class OpenMulitiWechat:public RequestBodyBase{
|
|
|
|
|
public:
|
|
|
|
|
OpenMulitiWechat(): RequestBodyBase(){}
|
|
|
|
|
};
|
|
|
|
|
inline QString getMachineGUID() {
|
|
|
|
|
HKEY hKey;
|
|
|
|
|
RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography",
|
|
|
|
|
0, KEY_READ | KEY_WOW64_64KEY, &hKey);
|
|
|
|
|
DWORD dwType1 = REG_SZ;
|
|
|
|
|
DWORD dwLen = MAX_PATH;
|
|
|
|
|
WCHAR buf[100];
|
|
|
|
|
RegQueryValueExA(hKey, "MachineGuid", 0, &dwType1, (LPBYTE)buf, &dwLen);
|
|
|
|
|
QString guid = QString::fromWCharArray(buf);
|
|
|
|
|
return guid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class SoftwareRequest :public RequestBodyBase {
|
2023-08-08 15:15:19 +08:00
|
|
|
|
public:
|
|
|
|
|
SoftwareRequest():RequestBodyBase(){}
|
2023-08-15 11:17:09 +08:00
|
|
|
|
bool sendRequest(QHash<QString, QString>&startMenu, QHash<QString, Record>*records,QJsonArray &software_exists);
|
2023-08-13 12:16:22 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class OpenWeChatRequest:public RequestBodyBase
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
OpenWeChatRequest():RequestBodyBase(){}
|
|
|
|
|
QString sendRequest(bool notuse=false/*Ϊ<>˹<EFBFBD><CBB9>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/);
|
2023-08-03 16:16:02 +08:00
|
|
|
|
};
|
|
|
|
|
#endif //OFFICEASSISTANT_NETIO_H
|