2025-06-17 11:48:13 +08:00
|
|
|
#ifndef INFO_MSG_H
|
2025-06-15 14:31:54 +08:00
|
|
|
#define INFO_MSG_H
|
|
|
|
|
|
|
|
|
|
#include <QBuffer>
|
|
|
|
|
#include <QDataStream>
|
|
|
|
|
#include <QIODevice>
|
2025-11-08 18:11:52 +08:00
|
|
|
#include <QMap>
|
2025-06-15 14:31:54 +08:00
|
|
|
#include <QString>
|
|
|
|
|
#include <QVector>
|
2025-11-05 23:09:37 +08:00
|
|
|
|
2026-03-25 14:53:24 +08:00
|
|
|
struct FileStruct {
|
|
|
|
|
QString root;
|
|
|
|
|
QString mid;
|
|
|
|
|
QString relative;
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-05 23:09:37 +08:00
|
|
|
struct PropertyData {
|
2025-11-08 18:11:52 +08:00
|
|
|
QString uuid;
|
|
|
|
|
QString command;
|
2025-11-06 23:36:55 +08:00
|
|
|
QString userAction;
|
2025-11-08 21:51:42 +08:00
|
|
|
QString localPath;
|
|
|
|
|
QString remotePath;
|
2025-11-06 23:36:55 +08:00
|
|
|
qint32 state;
|
2025-11-06 23:12:13 +08:00
|
|
|
qint32 properE;
|
2025-11-05 23:09:37 +08:00
|
|
|
};
|
2025-06-15 14:31:54 +08:00
|
|
|
|
|
|
|
|
struct InfoMsg {
|
|
|
|
|
qint32 mark{};
|
2025-11-05 10:57:40 +08:00
|
|
|
QString command;
|
2025-06-15 14:31:54 +08:00
|
|
|
QString msg;
|
2025-06-17 16:42:39 +08:00
|
|
|
QString fromPath;
|
|
|
|
|
QString toPath;
|
2025-11-16 19:23:59 +08:00
|
|
|
QString type;
|
2025-06-17 16:42:39 +08:00
|
|
|
quint64 size{};
|
|
|
|
|
quint32 permissions{};
|
2026-03-25 14:53:24 +08:00
|
|
|
QVector<QString> listSend;
|
2025-11-05 10:57:40 +08:00
|
|
|
QVector<QString> list;
|
2025-11-05 23:09:37 +08:00
|
|
|
QMap<QString, PropertyData> mapData;
|
2026-03-25 14:53:24 +08:00
|
|
|
FileStruct fst;
|
|
|
|
|
QMap<QString, QVector<FileStruct>> infos;
|
2025-06-15 14:31:54 +08:00
|
|
|
|
|
|
|
|
void serialize(QDataStream& data) const
|
|
|
|
|
{
|
2025-11-16 19:23:59 +08:00
|
|
|
data << mark << command << msg << fromPath << toPath << type << size << permissions;
|
2026-03-25 14:53:24 +08:00
|
|
|
|
|
|
|
|
data << static_cast<qint32>(listSend.size());
|
|
|
|
|
for (const auto& item : listSend) {
|
|
|
|
|
data << item;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-08 18:11:52 +08:00
|
|
|
data << static_cast<qint32>(list.size());
|
2025-11-05 10:57:40 +08:00
|
|
|
for (const auto& item : list) {
|
|
|
|
|
data << item;
|
|
|
|
|
}
|
2026-03-25 14:53:24 +08:00
|
|
|
|
2025-11-08 18:11:52 +08:00
|
|
|
data << static_cast<qint32>(mapData.size());
|
|
|
|
|
for (auto it = mapData.constBegin(); it != mapData.constEnd(); ++it) {
|
|
|
|
|
data << it.key();
|
2026-03-25 14:53:24 +08:00
|
|
|
data << it.value().uuid << it.value().command << it.value().userAction << it.value().localPath
|
|
|
|
|
<< it.value().remotePath << it.value().state << it.value().properE;
|
|
|
|
|
}
|
|
|
|
|
data << fst.root << fst.mid << fst.relative;
|
|
|
|
|
data << static_cast<qint32>(infos.size());
|
|
|
|
|
for (auto it = infos.constBegin(); it != infos.constEnd(); ++it) {
|
|
|
|
|
data << it.key();
|
|
|
|
|
data << static_cast<qint32>(it.value().size());
|
|
|
|
|
for (const auto& fileStruct : it.value()) {
|
|
|
|
|
data << fileStruct.root << fileStruct.mid << fileStruct.relative;
|
|
|
|
|
}
|
2025-11-05 23:09:37 +08:00
|
|
|
}
|
2025-06-15 14:31:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void deserialize(QDataStream& data)
|
|
|
|
|
{
|
2025-11-16 19:23:59 +08:00
|
|
|
data >> mark >> command >> msg >> fromPath >> toPath >> type >> size >> permissions;
|
2025-11-08 18:11:52 +08:00
|
|
|
|
2025-11-05 10:57:40 +08:00
|
|
|
qint32 listSize;
|
2026-03-25 14:53:24 +08:00
|
|
|
data >> listSize;
|
|
|
|
|
listSend.resize(listSize);
|
|
|
|
|
for (auto& item : listSend) {
|
|
|
|
|
data >> item;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-05 10:57:40 +08:00
|
|
|
data >> listSize;
|
|
|
|
|
list.resize(listSize);
|
|
|
|
|
for (auto& item : list) {
|
|
|
|
|
data >> item;
|
|
|
|
|
}
|
2025-11-08 18:11:52 +08:00
|
|
|
|
2025-11-05 23:09:37 +08:00
|
|
|
qint32 mapSize;
|
|
|
|
|
data >> mapSize;
|
2025-11-08 18:11:52 +08:00
|
|
|
mapData.clear();
|
2025-11-05 23:09:37 +08:00
|
|
|
for (int i = 0; i < mapSize; ++i) {
|
2025-11-08 18:11:52 +08:00
|
|
|
QString key;
|
2025-11-05 23:09:37 +08:00
|
|
|
PropertyData prop;
|
2025-11-08 18:11:52 +08:00
|
|
|
data >> key;
|
2026-03-25 14:53:24 +08:00
|
|
|
data >> prop.uuid >> prop.command >> prop.userAction >> prop.localPath >> prop.remotePath >> prop.state >>
|
|
|
|
|
prop.properE;
|
2025-11-08 18:11:52 +08:00
|
|
|
mapData.insert(key, prop);
|
2025-11-05 23:09:37 +08:00
|
|
|
}
|
2026-03-25 14:53:24 +08:00
|
|
|
|
|
|
|
|
data >> fst.root >> fst.mid >> fst.relative;
|
|
|
|
|
|
|
|
|
|
data >> mapSize;
|
|
|
|
|
infos.clear();
|
|
|
|
|
for (int i = 0; i < mapSize; ++i) {
|
|
|
|
|
QString key;
|
|
|
|
|
data >> key;
|
|
|
|
|
|
|
|
|
|
qint32 vectorSize;
|
|
|
|
|
data >> vectorSize;
|
|
|
|
|
QVector<FileStruct> fileVector;
|
|
|
|
|
fileVector.resize(vectorSize);
|
|
|
|
|
for (int j = 0; j < vectorSize; ++j) {
|
|
|
|
|
data >> fileVector[j].root >> fileVector[j].mid >> fileVector[j].relative;
|
|
|
|
|
}
|
|
|
|
|
infos.insert(key, fileVector);
|
|
|
|
|
}
|
2025-06-15 14:31:54 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
QDataStream& operator<<(QDataStream& data, const InfoMsg& info);
|
|
|
|
|
QDataStream& operator>>(QDataStream& data, InfoMsg& info);
|
|
|
|
|
|
2025-11-08 18:11:52 +08:00
|
|
|
#endif // INFO_MSG_H
|