98 lines
2.8 KiB
C++
Executable File
98 lines
2.8 KiB
C++
Executable File
#ifndef MYBACKUPMANAGER_H
|
|
#define MYBACKUPMANAGER_H
|
|
|
|
#include <QObject>
|
|
#include <QtDBus/QDBusVariant>
|
|
#include <QHash>
|
|
#include "mythread.h"
|
|
#include "../common/mydefine.h"
|
|
#include "../common/spinlock_mutex.h"
|
|
|
|
class MyBackupManager : public QObject {
|
|
Q_OBJECT
|
|
// Q_CLASSINFO("D-Bus Interface", "com.kylin.backup.manager")
|
|
|
|
public:
|
|
explicit MyBackupManager();
|
|
virtual ~MyBackupManager();
|
|
|
|
signals:
|
|
// 这3个信号供控制面板/自动更新等外围模块使用
|
|
// 开始备份结果信号
|
|
void sendStartBackupResult(int result);
|
|
// 备份结果信号
|
|
void sendBackupResult(bool result);
|
|
// 进度信号
|
|
void sendRate(int, int);
|
|
|
|
// 模块内使用的信号
|
|
// 进度信号
|
|
void progress(int, int);
|
|
// 备份结果信号
|
|
void backupFinished(bool result);
|
|
// 环境检查结果信号
|
|
void sendEnvCheckResult(int result);
|
|
// 还原结果信号
|
|
void sendRestoreResult(bool result);
|
|
// 删除备份结果信号
|
|
void sendDeleteResult(bool result);
|
|
// ghost备份结果信号
|
|
void sendGhostBackupResult(bool result);
|
|
|
|
public slots:
|
|
// 备份分区挂载
|
|
int Mount_backup_partition();
|
|
// 卸载backup分区
|
|
bool umountBackupPartition();
|
|
// 环境检测
|
|
int checkEnv(const BackupWrapper& backupWrapper);
|
|
// 备份
|
|
int goBackup(const BackupWrapper& backupWrapper);
|
|
// 还原
|
|
int goRestore(const BackupWrapper& backupWrapper);
|
|
// 删除备份
|
|
int deleteBackupPoint(const BackupWrapper& backupWrapper);
|
|
// ghost镜像
|
|
int ghostBackup(const BackupWrapper& backupWrapper);
|
|
// 控制面板调用的备份接口,重构暂时先兼容以前的老接口
|
|
void autoBackUpForSystemUpdate_noreturn(const QString& autobackup_name, const QString& create_note, const QString& inc_note, const QString& frontUserName, int frontUid);
|
|
// 控制面板调用的获取系统备份接口
|
|
QString getBackupCommentForSystemUpdate(QString& state);
|
|
// 获取备份状态
|
|
int getBackupState(bool& isActive);
|
|
// 取消操作
|
|
int cancel(const BackupWrapper& backupWrapper);
|
|
// 任务结束
|
|
void finished();
|
|
|
|
private slots:
|
|
// 卸载backup分区
|
|
bool umountBackup();
|
|
|
|
private:
|
|
// 锁定
|
|
bool lock(int frontUid);
|
|
// 解锁
|
|
bool unlock();
|
|
// 自旋锁
|
|
spinlock_mutex m_mutex;
|
|
|
|
// 关闭、开启安全保护
|
|
void setKysecStatus(bool status);
|
|
|
|
private:
|
|
// 锁文件描述符
|
|
int m_fdLockFile = -1;
|
|
// 备份还原状态
|
|
BackupState m_backupState = BackupState::BACKUP_STATE_INIT;
|
|
// 是否活动的,兼容以前用的,和m_backupState的实际使用功能有重复
|
|
bool m_isActive = false;
|
|
bool m_needUmount = false;
|
|
bool m_bOpenKysec = false;
|
|
bool m_bStartKysecDeamon = false;
|
|
// 工作者线程
|
|
MyThread workerThread;
|
|
};
|
|
|
|
#endif // MYBACKUPMANAGER_H
|