OfficeAssistant_Win10/OfficeAssistant_msvc/netio.h

114 lines
2.5 KiB
C
Raw Normal View History

//
// 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>
2023-07-30 01:06:42 +08:00
#include <QtNetwork/QtNetwork>
typedef struct {
QString img;
QString img_cover;
QString title;
QString func;
QString url;
} Menu;
typedef struct {
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-07-30 13:57:54 +08:00
QList<Menu> menus;
}ConfigResponse;
class RequestBodyBase:public QObject{
2023-07-30 01:06:42 +08:00
Q_OBJECT;
public:
2023-07-29 07:20:49 +08:00
RequestBodyBase();
virtual void sendRequest();
protected:
QString product;
2023-08-01 09:04:53 +08:00
QString parter_id;
QString os;
QString os_version;
QString device_id;
QString request_id;
QString version;
QString release;
QString sign;
QJsonDocument qJsonDocument;
2023-07-30 01:06:42 +08:00
QNetworkReply *reply;
QEventLoop eventLoop;
QTimer *timer;
protected slots:
void cancelDownload();
};
class ConfigRequest:public RequestBodyBase{
public:
2023-07-29 07:20:49 +08:00
ConfigRequest():RequestBodyBase(){}
void sendRequest(ConfigResponse * configResponse);
};
class OpRequest:public RequestBodyBase{
public:
2023-07-29 07:20:49 +08:00
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;
}
2023-07-29 07:20:49 +08:00
void sendRequest();
protected:
QString op;
QString op_value;
};
class DeviceRequest:RequestBodyBase{
2023-07-29 07:20:49 +08:00
DeviceRequest();
};
2023-07-29 07:20:49 +08:00
class OpenMulitiWechat:public RequestBodyBase{
public:
OpenMulitiWechat(): RequestBodyBase(){}
};
2023-07-31 19:06:37 +08:00
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;
}
#endif //OFFICEASSISTANT_NETIO_H