#ifndef KYLIN_OS_MANAGER_DAEMONS_SERVICE_JUNK_CLEAN_INTERFACE_H
#define KYLIN_OS_MANAGER_DAEMONS_SERVICE_JUNK_CLEAN_INTERFACE_H

#include <mutex>
#include <QDBusAbstractAdaptor>
#include <QList>
#include <QMap>

#define JUNK_CLEAN_DBUS_NAME "com.kylin-os-manager"
#define JUNK_CLEAN_DBUS_PATH "/com/KylinOsManager/JunkClean"
#define JUNK_CLEAN_DBUS_INTERFACE "com.KylinOsManager.JunkClean"

namespace junk_clean {

class JunkCleanAdaptor: public QDBusAbstractAdaptor {
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "com.KylinOsManager.JunkClean")
public:
    JunkCleanAdaptor(QObject *obj);

Q_SIGNALS:
    void ScanForJunk(QString cleaner_mark, quint64 junk_mark, QString path, quint64 size);
    void ScanFinish(QString cleaner_mark, quint64 total_size);
    void CleanForJunk(QString cleaner_mark, quint64 junk_mark);
    void CleanFinish(QString cleaner_mark);

public Q_SLOTS:
    // 安装包: installation_package_cleaner
    void ScanInstallationPackage();
    void CleanInstallationPackage(QList<quint64> junk_marks);

    // 安装包卸载残留: residual_cleaner
    void ScanUninstallResidual();
    void CleanUninstallResidual(QList<quint64> junk_marks);

    // 释放系统内存: system_memory_cleaner
    void CleanSystemMemory();

private:
    void EmitScanForJunkSignal(QString cleaner_mark, quint64 junk_mark, QString path, quint64 size) const;
    void EmitScanFinishSignal(QString cleaner_mark, quint64 total_size) const;
    void EmitCleanForJunk(QString cleaner_mark, quint64 junk_mark) const;
    void EmitCleanFinish(QString cleaner_mark) const;

    std::mutex installation_package_mutex_;
    QMap<quint64, QString> installation_package_junk_;

    std::mutex uninstall_residual_mutex_;
    QMap<quint64, QString> uninstall_residual_junk_;
};

}

Q_DECLARE_METATYPE(QList<quint64>)

#endif
