yhkylin-backup-tools/backup-daemon/parsebackuplist.h

86 lines
2.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef PARSEBACKUPLIST_H
#define PARSEBACKUPLIST_H
#include <QString>
#include <QDomDocument>
#include <QDomElement>
#include "../common/mydefine.h"
class ParseBackupList {
public:
enum ParseResult {
// xml解析错误
XML_PARSE_ERR,
// 失败
FAIL,
// 成功
SUCCESS,
};
struct BackupPoint {
// 备份或还原指定的UUID
QString m_uuid;
// 备份名称用来替换m_comment
QString m_backupName;
// 备份时间
QString m_time;
// 本地备份还是U盘备份: 0-本地备份1-移动设备备份
int m_iPosition = -1;
// 操作类型,如:系统备份, 系统还原
int m_type = -1;
// 备份大小
QString m_size;
// 备份状态,如是否完成
QString m_state;
bool isNull() { return m_uuid.isEmpty(); }
};
ParseBackupList(const QString& xmlPath);
/**
* @brief 出厂备份修改backuplist.xml仅保留出厂备份信息
* @param factoryBackupUuid出厂备份的uuid
* @return ParseResult枚举类型
* @author zhaominyong
* @since 2021/06/27
*/
ParseResult updateForFactoryRestore(const QString &factoryBackupUuid);
/**
* @brief 根据comment查找uuid
* @param comment
* @return uuid
*/
QString findUuidByComment(const QString& comment);
/**
* @brief 根据Uuid查找备份点信息
* @param Uuid
* @return 备份点信息
*/
BackupPoint findBackupPointByUuid(const QString& Uuid);
/**
* @brief 获取最后一次系统备份
* @return
*/
BackupPoint getLastSysBackupPoint();
inline QString getXmlPath() { return m_xmlPath; }
private:
bool InitXml();
bool isXmlCorrect();
bool Doc_setContent(QDomDocument& doc);
void elementNodeToBackupPoint(const QDomElement& eleNode, BackupPoint& backupPoint);
void backupPointToElementNode(const BackupPoint& backupPoint, QDomElement& eleNode);
QDomElement createTextElement(const QString& tagName, const QString& text);
private:
QString m_xmlPath;
};
#endif // PARSEBACKUPLIST_H