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
|
|
|
|
|
|
|
|
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{};
|
2025-11-05 10:57:40 +08:00
|
|
|
QVector<QString> list;
|
2025-11-05 23:09:37 +08:00
|
|
|
QMap<QString, PropertyData> mapData;
|
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;
|
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;
|
|
|
|
|
}
|
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();
|
|
|
|
|
data << it.value().uuid << it.value().command << it.value().userAction
|
2025-11-08 21:51:42 +08:00
|
|
|
<< it.value().localPath << it.value().remotePath << it.value().state << it.value().properE;
|
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;
|
|
|
|
|
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;
|
2025-11-08 21:51:42 +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
|
|
|
}
|
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
|